Add new command to detach resource endpoint

New command 'openstack rsd node detach' to allow user to detach a
specific resource from existing composed node.

Change-Id: Ia9f15793c3d4b87b6647f2f7dc18411be632054b
This commit is contained in:
Lin Yang 2017-09-08 15:43:24 -07:00
parent 93554e3c16
commit cce43696f1
4 changed files with 34 additions and 0 deletions

View File

@ -310,3 +310,24 @@ class AttachEndpoint(command.Command):
rsd_client = self.app.client_manager.rsd
rsd_client.node.attach(parsed_args.node, parsed_args.resource,
parsed_args.capacity)
class DetachEndpoint(command.Command):
_description = "Detach drive from a composed node"
def get_parser(self, prog_name):
parser = super(DetachEndpoint, self).get_parser(prog_name)
parser.add_argument(
'node',
metavar='<node>',
help='ID of the node.')
parser.add_argument(
'--resource',
metavar='<resource uri>',
help='URI of the specific resource to detach from node.')
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)", parsed_args)
rsd_client = self.app.client_manager.rsd
rsd_client.node.detach(parsed_args.node, parsed_args.resource)

View File

@ -81,3 +81,11 @@ class NodeTest(testtools.TestCase):
self.mgr.attach(node_id, 'fake uri', 10)
self.mgr.client.get_node.assert_called_once_with('/redfish/v1/Nodes/1')
mock_node.attach_endpoint.assert_called_once_with('fake uri', 10)
def test_detach(self):
node_id = '1'
mock_node = mock.Mock()
self.client.get_node.return_value = mock_node
self.mgr.detach(node_id, 'fake uri')
self.mgr.client.get_node.assert_called_once_with('/redfish/v1/Nodes/1')
mock_node.detach_endpoint.assert_called_once_with('fake uri')

View File

@ -52,3 +52,7 @@ class NodeManager(base.Manager):
def attach(self, node_id, endpoint=None, capacity=None):
node = self.client.get_node(self._get_node_uri(node_id))
node.attach_endpoint(endpoint, capacity)
def detach(self, node_id, endpoint):
node = self.client.get_node(self._get_node_uri(node_id))
node.detach_endpoint(endpoint)

View File

@ -33,6 +33,7 @@ openstack.rsd.v1 =
rsd_node_show = rsdclient.osc.v1.node:ShowNode
rsd_node_list = rsdclient.osc.v1.node:ListNode
rsd_node_attach = rsdclient.osc.v1.node:AttachEndpoint
rsd_node_detach = rsdclient.osc.v1.node:DetachEndpoint
rsd_storage_list = rsdclient.osc.v1.storage_service:ListStorageServices
rsd_storage_show = rsdclient.osc.v1.storage_service:ShowStorageServices