示例#1
0
    def update_password(self, user, password):
        """
        Update password
        """
        params = {"user": {"id": base.getid(user),
                           "password": password}}

        self._update("/users/%s/password" % base.getid(user), params)
示例#2
0
    def update_enabled(self, user, enabled):
        """
        Update enabled-ness
        """
        params = {"user": {"id": base.getid(user),
                           "enabled": enabled}}

        self._update("/users/%s/enabled" % base.getid(user), params)
示例#3
0
    def update_email(self, user, email):
        """
        Update email
        """
        # FIXME(ja): why do we have to send id in params and url?
        params = {"user": {"id": base.getid(user),
                           "email": email}}

        self._update("/users/%s" % base.getid(user), params)
示例#4
0
    def update_tenant(self, user, tenant):
        """
        Update default tenant.
        """
        params = {"user": {"id": base.getid(user),
                           "tenantId": base.getid(tenant)}}

        # FIXME(ja): seems like a bad url - default tenant is an attribute
        #            not a subresource!???
        self._update("/users/%s/tenant" % base.getid(user), params)
示例#5
0
    def share_ip(self, server, ipgroup, address, configure=True):
        """
        Share an IP address from the given IP group onto a server.

        :param server: The :class:`Server` (or its ID) to share onto.
        :param ipgroup: The :class:`IPGroup` that the given address belongs to.
        :param address: The IP address to share.
        :param configure: If ``True``, the server will be automatically
                         configured to use this IP. I don't know why you'd
                         want this to be ``False``.
        """
        server = base.getid(server)
        ipgroup = base.getid(ipgroup)
        body = {'shareIp': {'sharedIpGroupId': ipgroup,
                            'configureServer': configure}}
        self._update("/servers/%s/ips/public/%s" % (server, address), body)
示例#6
0
    def update(self, zone, api_url=None, username=None, password=None,
               weight_offset=None, weight_scale=None):
        """
        Update the name or the api_url for a zone.

        :param zone: The :class:`Zone` (or its ID) to update.
        :param api_url: Update the API URL.
        :param username: Update the username.
        :param password: Update the password.
        :param weight_offset: Update the child zone's weight offset.
        :param weight_scale: Update the child zone's weight scale.
        """

        body = {"zone": {}}
        if api_url:
            body["zone"]["api_url"] = api_url
        if username:
            body["zone"]["username"] = username
        if password:
            body["zone"]["password"] = password
        if weight_offset:
            body["zone"]["weight_offset"] = weight_offset
        if weight_scale:
            body["zone"]["weight_scale"] = weight_scale
        if not len(body["zone"]):
            return
        self._update("/zones/%s" % base.getid(zone), body)
    def delete(self, rule):
        """
        Delete a security group rule

        :param rule: The security group rule to delete (ID or Class)
        """
        return self._delete('/os-security-group-rules/%s' % base.getid(rule))
示例#8
0
    def delete(self, group):
        """
        Delete a group.

        :param group: The :class:`IPGroup` (or its ID) to delete.
        """
        self._delete("/shared_ip_groups/%s" % base.getid(group))
    def delete(self, floating_ip):
        """
        Delete (deallocate) a  floating ip for a tenant

        :param key: The :class:`Keypair` (or its ID) to delete.
        """
        return self._delete("/os-floating-ips/%s" % base.getid(floating_ip))
示例#10
0
    def delete(self, volume):
        """
        Delete a volume.

        :param volume: The :class:`Volume` to delete.
        """
        self._delete("/os-volumes/%s" % base.getid(volume))
示例#11
0
    def migrate(self, server):
        """
        Migrate a server to a new host in the same zone.

        :param server: The :class:`Server` (or its ID).
        """
        self.api.client.post('/servers/%s/migrate' % base.getid(server))
    def delete(self, snapshot):
        """
        Delete a snapshot.

        :param snapshot: The :class:`Snapshot` to delete.
        """
        self._delete("/os-snapshots/%s" % base.getid(snapshot))
示例#13
0
    def delete(self, key):
        """
        Delete a keypair

        :param key: The :class:`Keypair` (or its ID) to delete.
        """
        self._delete('/os-keypairs/%s' % (base.getid(key)))
示例#14
0
    def get(self, flavor):
        """
        Get a specific flavor.

        :param flavor: The ID of the :class:`Flavor` to get.
        :rtype: :class:`Flavor`
        """
        return self._get("/flavors/%s" % base.getid(flavor), "flavor")
示例#15
0
    def get(self, image):
        """
        Get an image.

        :param image: The ID of the image to get.
        :rtype: :class:`Image`
        """
        return self._get("/images/%s" % base.getid(image), "image")
    def delete(self, group):
        """
        Delete a security group

        :param group: The security group to delete (group or ID)
        :rtype: None
        """
        return self._delete('/os-security-groups/%s' % base.getid(group))
示例#17
0
    def get(self, zone):
        """
        Get a child zone.

        :param server: ID of the :class:`Zone` to get.
        :rtype: :class:`Zone`
        """
        return self._get("/zones/%s" % base.getid(zone), "zone")
示例#18
0
 def delete_meta(self, server, keys):
     """
     Delete metadata from an server
     :param server: The :class:`Server` to add metadata to
     :param keys: A list of metadata keys to delete from the server
     """
     for k in keys:
         self._delete("/servers/%s/metadata/%s" % (base.getid(server), k))
示例#19
0
    def rebuild(self, server, image):
        """
        Rebuild -- shut down and then re-image -- a server.

        :param server: The :class:`Server` (or its ID) to share onto.
        :param image: the :class:`Image` (or its ID) to re-image with.
        """
        self._action('rebuild', server, {'imageId': base.getid(image)})
    def delete(self, server):
        """
        Remove the scheduled backup for `server`.

        :arg server: The server (or its ID).
        """
        s = base.getid(server)
        self._delete('/servers/%s/backup_schedule' % s)
示例#21
0
    def get(self, server):
        """
        Get a server.

        :param server: ID of the :class:`Server` to get.
        :rtype: :class:`Server`
        """
        return self._get("/servers/%s" % base.getid(server), "server")
示例#22
0
    def unshare_ip(self, server, address):
        """
        Stop sharing the given address.

        :param server: The :class:`Server` (or its ID) to share onto.
        :param address: The IP address to stop sharing.
        """
        server = base.getid(server)
        self._delete("/servers/%s/ips/public/%s" % (server, address))
示例#23
0
 def set_meta(self, server, metadata):
     """
     Set a servers metadata
     :param server: The :class:`Server` to add metadata to
     :param metadata: A dict of metadata to add to the server
     """
     body = {'metadata': metadata}
     return self._create("/servers/%s/metadata" % base.getid(server),
                          body, "metadata")
示例#24
0
    def set_meta(self, image, metadata):
        """
        Set an images metadata

        :param image: The :class:`Image` to add metadata to
        :param metadata: A dict of metadata to add to the image
        """
        body = {"metadata": metadata}
        return self._create("/images/%s/metadata" % base.getid(image), body, "metadata")
示例#25
0
    def delete_meta(self, image, keys):
        """
        Delete metadata from an image

        :param image: The :class:`Image` to add metadata to
        :param keys: A list of metadata keys to delete from the image
        """
        for k in keys:
            self._delete("/images/%s/metadata/%s" % (base.getid(image), k))
示例#26
0
    def get(self, group):
        """
        Get an IP group.

        :param group: ID of the image to get.
        :rtype: :class:`IPGroup`
        """
        return self._get("/shared_ip_groups/%s" % base.getid(group),
                         "sharedIpGroup")
示例#27
0
    def delete(self, image):
        """
        Delete an image.

        It should go without saying that you can't delete an image
        that you didn't create.

        :param image: The :class:`Image` (or its ID) to delete.
        """
        self._delete("/images/%s" % base.getid(image))
示例#28
0
    def create(self, server, name):
        """
        Create a new image by snapshotting a running :class:`Server`

        :param name: An (arbitrary) name for the new image.
        :param server: The :class:`Server` (or its ID) to make a snapshot of.
        :rtype: :class:`Image`
        """
        data = {"image": {"serverId": base.getid(server), "name": name}}
        return self._create("/images", data, "image")
    def get(self, server):
        """
        Get the current backup schedule for a server.

        :arg server: The server (or its ID).
        :rtype: :class:`BackupSchedule`
        """
        s = base.getid(server)
        schedule = self._get('/servers/%s/backup_schedule' % s,
                             'backupSchedule')
        schedule.server = server
        return schedule
示例#30
0
    def resize(self, server, flavor):
        """
        Resize a server's resources.

        :param server: The :class:`Server` (or its ID) to share onto.
        :param flavor: the :class:`Flavor` (or its ID) to resize to.

        Until a resize event is confirmed with :meth:`confirm_resize`, the old
        server will be kept around and you'll be able to roll back to the old
        flavor quickly with :meth:`revert_resize`. All resizes are
        automatically confirmed after 24 hours.
        """
        self._action('resize', server, {'flavorId': base.getid(flavor)})