New command to list all endpoints of one fabric
Change-Id: Iaf31e60813dab94e2d4a3b58f54aa841f77519a6
This commit is contained in:
parent
7b1f32f791
commit
1a99d79894
@ -49,3 +49,24 @@ class ShowFabric(command.Command):
|
||||
rsd_client = self.app.client_manager.rsd
|
||||
fabric_detail = rsd_client.fabric.show(parsed_args.fabric)
|
||||
print("{0}".format(json.dumps(fabric_detail, indent=2)))
|
||||
|
||||
|
||||
class ListEndpoint(command.Command):
|
||||
"""List all endpoints of one fabric."""
|
||||
|
||||
_description = "List all endpoints of one fabric"
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ListEndpoint, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'fabric',
|
||||
metavar='<fabric>',
|
||||
help='ID of the fabric.')
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)", parsed_args)
|
||||
rsd_client = self.app.client_manager.rsd
|
||||
endpoint_list = rsd_client.fabric.list_endpoint(parsed_args.fabric)
|
||||
print(endpoint_list)
|
||||
|
@ -61,3 +61,13 @@ class FabricTest(testtools.TestCase):
|
||||
self.mgr.client.get_fabric.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/PCIe')
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
def test_list_endpoint(self):
|
||||
mock_fabric = mock.Mock()
|
||||
self.client.get_fabric.return_value = mock_fabric
|
||||
mock_fabric.endpoints.get_members.return_value = ()
|
||||
|
||||
self.mgr.list_endpoint('/redfish/v1/Fabrics/1-ff-1')
|
||||
self.mgr.client.get_fabric.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/1-ff-1')
|
||||
mock_fabric.endpoints.get_members.assert_called_once()
|
||||
|
@ -45,3 +45,13 @@ class FabricManager(base.Manager):
|
||||
for item in fabric.zones.get_members()]
|
||||
|
||||
return fabric_dict
|
||||
|
||||
def list_endpoint(self, fabric_id):
|
||||
fabric = self.client.get_fabric(fabric_id)
|
||||
|
||||
endpoint_collection = fabric.endpoints.get_members()
|
||||
endpoints = [utils.extract_attr(endpoint)
|
||||
for endpoint in endpoint_collection]
|
||||
endpoint_info_table = utils.print_dict(
|
||||
endpoints, ["Identity", "Name", "Description"])
|
||||
return endpoint_info_table
|
||||
|
Loading…
x
Reference in New Issue
Block a user