Override delete function of senlin cluster/node
Recently senlin change its api, request to delete cluster/node will receive a response with location pointed to an action. Change-Id: I7ba991959e93a95cbb99354bc78093ba9a3bd480
This commit is contained in:
parent
a90769dcc4
commit
0ea34d1e34
|
@ -191,9 +191,11 @@ class Proxy(proxy.BaseProxy):
|
|||
the cluster could not be found. When set to ``True``, no exception
|
||||
will be raised when attempting to delete a non-existent cluster.
|
||||
|
||||
:returns: ``None``
|
||||
:returns: The instance of the Cluster which was deleted.
|
||||
:rtype: :class:`~openstack.cluster.v1.cluster.Cluster`.
|
||||
"""
|
||||
self._delete(_cluster.Cluster, cluster, ignore_missing=ignore_missing)
|
||||
return self._delete(_cluster.Cluster, cluster,
|
||||
ignore_missing=ignore_missing)
|
||||
|
||||
def find_cluster(self, name_or_id, ignore_missing=True):
|
||||
"""Find a single cluster.
|
||||
|
@ -427,9 +429,10 @@ class Proxy(proxy.BaseProxy):
|
|||
the node could not be found. When set to ``True``, no exception
|
||||
will be raised when attempting to delete a non-existent node.
|
||||
|
||||
:returns: ``None``
|
||||
:returns: The instance of the Node which was deleted.
|
||||
:rtype: :class:`~openstack.cluster.v1.node.Node`.
|
||||
"""
|
||||
self._delete(_node.Node, node, ignore_missing=ignore_missing)
|
||||
return self._delete(_node.Node, node, ignore_missing=ignore_missing)
|
||||
|
||||
def check_node(self, node, **params):
|
||||
"""check a node.
|
||||
|
|
|
@ -149,3 +149,17 @@ class Cluster(resource.Resource):
|
|||
'recover': params
|
||||
}
|
||||
return self.action(session, body)
|
||||
|
||||
def delete(self, session):
|
||||
"""Delete the remote resource associated with this instance.
|
||||
|
||||
:param session: The session to use for making this request.
|
||||
:type session: :class:`~openstack.session.Session`
|
||||
|
||||
:returns: The instance of the Cluster which was deleted.
|
||||
:rtype: :class:`~openstack.cluster.v1.cluster.Cluster`.
|
||||
"""
|
||||
url = self._get_url(self, self.id)
|
||||
resp = session.delete(url, endpoint_filter=self.service)
|
||||
self.location = resp.headers['location']
|
||||
return self
|
||||
|
|
|
@ -99,3 +99,17 @@ class Node(resource.Resource):
|
|||
'recover': params
|
||||
}
|
||||
return self._action(session, body)
|
||||
|
||||
def delete(self, session):
|
||||
"""Delete the remote resource associated with this instance.
|
||||
|
||||
:param session: The session to use for making this request.
|
||||
:type session: :class:`~openstack.session.Session`
|
||||
|
||||
:returns: The instance of the Node which was deleted.
|
||||
:rtype: :class:`~openstack.cluster.v1.node.Node`.
|
||||
"""
|
||||
url = self._get_url(self, self.id)
|
||||
resp = session.delete(url, endpoint_filter=self.service)
|
||||
self.location = resp.headers['location']
|
||||
return self
|
||||
|
|
|
@ -248,3 +248,14 @@ class TestCluster(testtools.TestCase):
|
|||
body = {'recover': {}}
|
||||
sess.post.assert_called_once_with(url, endpoint_filter=sot.service,
|
||||
json=body)
|
||||
|
||||
def test_cluster_delete(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
url = 'clusters/%s' % sot.id
|
||||
resp = mock.Mock(headers={'location': 'actions/fake_action'})
|
||||
sess = mock.Mock()
|
||||
sess.delete = mock.Mock(return_value=resp)
|
||||
clus = sot.delete(sess)
|
||||
self.assertEqual('actions/fake_action', clus.location)
|
||||
sess.delete.assert_called_once_with(url, endpoint_filter=sot.service)
|
||||
|
|
|
@ -106,3 +106,14 @@ class TestNode(testtools.TestCase):
|
|||
body = {'recover': {}}
|
||||
sess.post.assert_called_once_with(url, endpoint_filter=sot.service,
|
||||
json=body)
|
||||
|
||||
def test_node_delete(self):
|
||||
sot = node.Node(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
url = 'nodes/%s' % sot.id
|
||||
resp = mock.Mock(headers={'location': 'actions/fake_action'})
|
||||
sess = mock.Mock()
|
||||
sess.delete = mock.Mock(return_value=resp)
|
||||
nod = sot.delete(sess)
|
||||
self.assertEqual('actions/fake_action', nod.location)
|
||||
sess.delete.assert_called_once_with(url, endpoint_filter=sot.service)
|
||||
|
|
Loading…
Reference in New Issue