def test_getid(self): self.assertEqual(base.getid(4), 4) class TmpObject(object): id = 4 self.assertEqual(base.getid(TmpObject), 4)
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))
def delete(self, monitor): """ Delete a monitor. :param monitor: The :class:`ServiceManage` to delete. """ self._delete("/monitors/%s" % base.getid(monitor))
def delete(self, snapshot): """ Delete a snapshot. :param snapshot: The :class:`Snapshot` to delete. """ self._delete("/snapshots/%s" % base.getid(snapshot))
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)
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")
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"]
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))
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")
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"]
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)
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)
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)
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)
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
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
def force_delete(self, monitor): return self._action('os-force_delete', base.getid(monitor))
def delete(self, backup): """Delete a monitor backup. :param backup: The :class:`ServiceManageBackup` to delete. """ self._delete("/backups/%s" % base.getid(backup))