New command to show endpoint details
Change-Id: I982d979ffae268de0ca0e94d6c4a9dfca8699082
This commit is contained in:
parent
1a99d79894
commit
52440b40bc
@ -70,3 +70,26 @@ class ListEndpoint(command.Command):
|
||||
rsd_client = self.app.client_manager.rsd
|
||||
endpoint_list = rsd_client.fabric.list_endpoint(parsed_args.fabric)
|
||||
print(endpoint_list)
|
||||
|
||||
|
||||
class ShowEndpoint(command.Command):
|
||||
"""Show endpoint details"""
|
||||
|
||||
_description = "Show endpoint details"
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowEndpoint, self).get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
'endpoint',
|
||||
metavar='<endpoint>',
|
||||
help='ID of the endpoint.')
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)", parsed_args)
|
||||
rsd_client = self.app.client_manager.rsd
|
||||
endpoint_detail = rsd_client.fabric.show_endpoint(
|
||||
parsed_args.endpoint)
|
||||
print("{0}".format(json.dumps(endpoint_detail, indent=2)))
|
||||
|
@ -28,6 +28,13 @@ class FabricTest(testtools.TestCase):
|
||||
self.client._fabrics_path = '/redfish/v1/Fabrics'
|
||||
self.mgr = fabric.FabricManager(self.client)
|
||||
|
||||
def test__extract_fabric_uri(self):
|
||||
self.assertIsNone(self.mgr._extract_fabric_uri('invalid uri'))
|
||||
self.assertEqual(
|
||||
'/redfish/v1/Fabrics/1-ff-1',
|
||||
self.mgr._extract_fabric_uri(
|
||||
'/redfish/v1/Fabrics/1-ff-1/Endpoints/1-ff-1-e-2'))
|
||||
|
||||
def test_list_fabric(self):
|
||||
mock_fabric_collection = mock.Mock()
|
||||
mock_fabric_collection.members_identities = \
|
||||
@ -71,3 +78,14 @@ class FabricTest(testtools.TestCase):
|
||||
self.mgr.client.get_fabric.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/1-ff-1')
|
||||
mock_fabric.endpoints.get_members.assert_called_once()
|
||||
|
||||
def test_show_volume(self):
|
||||
mock_fabric = mock.Mock()
|
||||
self.client.get_fabric.return_value = mock_fabric
|
||||
|
||||
self.mgr.show_endpoint(
|
||||
'/redfish/v1/Fabrics/1-ff-1/Endpoints/1-ff-1-e-2')
|
||||
self.mgr.client.get_fabric.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/1-ff-1')
|
||||
mock_fabric.endpoints.get_member.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/1-ff-1/Endpoints/1-ff-1-e-2')
|
||||
|
@ -24,6 +24,12 @@ class FabricManager(base.Manager):
|
||||
super(FabricManager, self).__init__(*args, **kwargs)
|
||||
self.fabrics_path = self.client._fabrics_path
|
||||
|
||||
def _extract_fabric_uri(self, uri):
|
||||
if not uri.startswith(self.fabrics_path):
|
||||
return None
|
||||
|
||||
return uri[:uri.find('/', len(self.fabrics_path) + 1)]
|
||||
|
||||
def list(self):
|
||||
fabric_collection = self.client.get_fabric_collection()
|
||||
fabrics = [utils.extract_attr(self.client.get_fabric(fabric_uri))
|
||||
@ -55,3 +61,10 @@ class FabricManager(base.Manager):
|
||||
endpoint_info_table = utils.print_dict(
|
||||
endpoints, ["Identity", "Name", "Description"])
|
||||
return endpoint_info_table
|
||||
|
||||
def show_endpoint(self, endpoint_id):
|
||||
fabric = self.client.get_fabric(
|
||||
self._extract_fabric_uri(endpoint_id))
|
||||
endpoint = fabric.endpoints.get_member(endpoint_id)
|
||||
|
||||
return utils.extract_attr(endpoint)
|
||||
|
@ -53,6 +53,7 @@ openstack.rsd.v1 =
|
||||
rsd_fabric_list = rsdclient.osc.v1.fabric:ListFabric
|
||||
rsd_fabric_show = rsdclient.osc.v1.fabric:ShowFabric
|
||||
rsd_fabric_endpoint_list = rsdclient.osc.v1.fabric:ListEndpoint
|
||||
rsd_fabric_endpoint_show = rsdclient.osc.v1.fabric:ShowEndpoint
|
||||
|
||||
[build_sphinx]
|
||||
all-files = 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user