Esempio n. 1
0
    def test_getid(self):
        self.assertEqual(base.getid(4), 4)

        class TmpObject(object):
            id = 4

        self.assertEqual(base.getid(TmpObject), 4)
Esempio n. 2
0
    def delete(self, monitor_type):
        """
        Delete a specific monitor_type.

        :param monitor_type: The ID of the :class:`ServiceManageType` to get.
        """
        self._delete("/types/%s" % base.getid(monitor_type))
Esempio n. 3
0
    def delete(self, monitor):
        """
        Delete a monitor.

        :param monitor: The :class:`ServiceManage` to delete.
        """
        self._delete("/monitors/%s" % base.getid(monitor))
Esempio n. 4
0
    def delete(self, monitor):
        """
        Delete a monitor.

        :param monitor: The :class:`ServiceManage` to delete.
        """
        self._delete("/monitors/%s" % base.getid(monitor))
Esempio n. 5
0
    def delete(self, snapshot):
        """
        Delete a snapshot.

        :param snapshot: The :class:`Snapshot` to delete.
        """
        self._delete("/snapshots/%s" % base.getid(snapshot))
Esempio n. 6
0
    def delete(self, monitor_type):
        """
        Delete a specific monitor_type.

        :param monitor_type: The ID of the :class:`ServiceManageType` to get.
        """
        self._delete("/types/%s" % base.getid(monitor_type))
Esempio n. 7
0
    def delete(self, snapshot):
        """
        Delete a snapshot.

        :param snapshot: The :class:`Snapshot` to delete.
        """
        self._delete("/snapshots/%s" % base.getid(snapshot))
Esempio n. 8
0
 def _action(self, action, monitor, info=None, **kwargs):
     """
     Perform a monitor "action."
     """
     body = {action: info}
     self.run_hooks('modify_body_for_action', body, **kwargs)
     url = '/monitors/%s/action' % base.getid(monitor)
     return self.api.client.post(url, body=body)
Esempio n. 9
0
    def get(self, monitor_type):
        """
        Get a specific monitor type.

        :param monitor_type: The ID of the :class:`ServiceManageType` to get.
        :rtype: :class:`ServiceManageType`
        """
        return self._get("/types/%s" % base.getid(monitor_type), "monitor_type")
Esempio n. 10
0
 def _action(self, action, monitor, info=None, **kwargs):
     """
     Perform a monitor "action."
     """
     body = {action: info}
     self.run_hooks('modify_body_for_action', body, **kwargs)
     url = '/monitors/%s/action' % base.getid(monitor)
     return self.api.client.post(url, body=body)
Esempio n. 11
0
    def get(self, monitor_type):
        """
        Get a specific monitor type.

        :param monitor_type: The ID of the :class:`ServiceManageType` to get.
        :rtype: :class:`ServiceManageType`
        """
        return self._get("/types/%s" % base.getid(monitor_type),
                         "monitor_type")
Esempio n. 12
0
    def get_keys(self):
        """
        Get extra specs from a monitor type.

        :param vol_type: The :class:`ServiceManageType` to get extra specs from
        """
        _resp, body = self.manager.api.client.get("/types/%s/extra_specs" %
                                                  base.getid(self))
        return body["extra_specs"]
Esempio n. 13
0
    def delete_metadata(self, monitor, keys):
        """
        Delete specified keys from monitors metadata.

        :param monitor: The :class:`ServiceManage`.
        :param metadata: A list of keys to be removed.
        """
        for k in keys:
            self._delete("/monitors/%s/metadata/%s" % (base.getid(monitor), k))
Esempio n. 14
0
    def delete_metadata(self, monitor, keys):
        """
        Delete specified keys from monitors metadata.

        :param monitor: The :class:`ServiceManage`.
        :param metadata: A list of keys to be removed.
        """
        for k in keys:
            self._delete("/monitors/%s/metadata/%s" % (base.getid(monitor), k))
Esempio n. 15
0
    def set_metadata(self, monitor, metadata):
        """
        Update/Set a monitors metadata.

        :param monitor: The :class:`ServiceManage`.
        :param metadata: A list of keys to be set.
        """
        body = {'metadata': metadata}
        return self._create("/monitors/%s/metadata" % base.getid(monitor),
                            body, "metadata")
Esempio n. 16
0
    def get_keys(self):
        """
        Get extra specs from a monitor type.

        :param vol_type: The :class:`ServiceManageType` to get extra specs from
        """
        _resp, body = self.manager.api.client.get(
            "/types/%s/extra_specs" %
            base.getid(self))
        return body["extra_specs"]
Esempio n. 17
0
    def set_metadata(self, monitor, metadata):
        """
        Update/Set a monitors metadata.

        :param monitor: The :class:`ServiceManage`.
        :param metadata: A list of keys to be set.
        """
        body = {'metadata': metadata}
        return self._create("/monitors/%s/metadata" % base.getid(monitor),
                            body, "metadata")
Esempio n. 18
0
    def update(self, snapshot, **kwargs):
        """
        Update the display_name or display_description for a snapshot.

        :param snapshot: The :class:`Snapshot` to delete.
        """
        if not kwargs:
            return

        body = {"snapshot": kwargs}

        self._update("/snapshots/%s" % base.getid(snapshot), body)
Esempio n. 19
0
    def update(self, monitor, **kwargs):
        """
        Update the display_name or display_description for a monitor.

        :param monitor: The :class:`ServiceManage` to delete.
        """
        if not kwargs:
            return

        body = {"monitor": kwargs}

        self._update("/monitors/%s" % base.getid(monitor), body)
Esempio n. 20
0
    def set_keys(self, metadata):
        """
        Set extra specs on a monitor type.

        :param type : The :class:`ServiceManageType` to set extra spec on
        :param metadata: A dict of key/value pairs to be set
        """
        body = {'extra_specs': metadata}
        return self.manager._create("/types/%s/extra_specs" % base.getid(self),
                                    body,
                                    "extra_specs",
                                    return_raw=True)
Esempio n. 21
0
    def update(self, monitor, **kwargs):
        """
        Update the display_name or display_description for a monitor.

        :param monitor: The :class:`ServiceManage` to delete.
        """
        if not kwargs:
            return

        body = {"monitor": kwargs}

        self._update("/monitors/%s" % base.getid(monitor), body)
Esempio n. 22
0
    def update(self, snapshot, **kwargs):
        """
        Update the display_name or display_description for a snapshot.

        :param snapshot: The :class:`Snapshot` to delete.
        """
        if not kwargs:
            return

        body = {"snapshot": kwargs}

        self._update("/snapshots/%s" % base.getid(snapshot), body)
Esempio n. 23
0
    def set_keys(self, metadata):
        """
        Set extra specs on a monitor type.

        :param type : The :class:`ServiceManageType` to set extra spec on
        :param metadata: A dict of key/value pairs to be set
        """
        body = {'extra_specs': metadata}
        return self.manager._create(
            "/types/%s/extra_specs" % base.getid(self),
            body,
            "extra_specs",
            return_raw=True)
Esempio n. 24
0
    def unset_keys(self, keys):
        """
        Unset extra specs on a volue type.

        :param type_id: The :class:`ServiceManageType` to unset extra spec on
        :param keys: A list of keys to be unset
        """

        # NOTE(jdg): This wasn't actually doing all of the keys before
        # the return in the loop resulted in ony ONE key being unset.
        # since on success the return was NONE, we'll only interrupt the loop
        # and return if there's an error
        resp = None
        for k in keys:
            resp = self.manager._delete("/types/%s/extra_specs/%s" %
                                        (base.getid(self), k))
            if resp is not None:
                return resp
Esempio n. 25
0
    def unset_keys(self, keys):
        """
        Unset extra specs on a volue type.

        :param type_id: The :class:`ServiceManageType` to unset extra spec on
        :param keys: A list of keys to be unset
        """

        # NOTE(jdg): This wasn't actually doing all of the keys before
        # the return in the loop resulted in ony ONE key being unset.
        # since on success the return was NONE, we'll only interrupt the loop
        # and return if there's an error
        resp = None
        for k in keys:
            resp = self.manager._delete(
                "/types/%s/extra_specs/%s" % (
                base.getid(self), k))
            if resp is not None:
                return resp
Esempio n. 26
0
 def force_delete(self, monitor):
     return self._action('os-force_delete', base.getid(monitor))
Esempio n. 27
0
    def test_getid(self):
        self.assertEqual(base.getid(4), 4)

        class TmpObject(object):
            id = 4
        self.assertEqual(base.getid(TmpObject), 4)
Esempio n. 28
0
 def force_delete(self, monitor):
     return self._action('os-force_delete', base.getid(monitor))
Esempio n. 29
0
    def delete(self, backup):
        """Delete a monitor backup.

        :param backup: The :class:`ServiceManageBackup` to delete.
        """
        self._delete("/backups/%s" % base.getid(backup))
Esempio n. 30
0
    def delete(self, backup):
        """Delete a monitor backup.

        :param backup: The :class:`ServiceManageBackup` to delete.
        """
        self._delete("/backups/%s" % base.getid(backup))