def test_get_specific_fabric(self): """ Test for get_fabrics using specific UUID :return: """ all_fabrics = fabric.get_fabrics(cfm) my_fabric = all_fabrics[0]['uuid'] test_fabric = fabric.get_fabrics(cfm, fabric_uuid=my_fabric) my_attributes = [ 'description', 'foreign_manager_id', 'foreign_fabric_state', 'name', 'is_stable', 'foreign_management_state', 'foreign_manager_url', 'uuid' ] self.assertIs(type(test_fabric), dict) for i in test_fabric.keys(): self.assertIn(i, my_attributes)
def test_perform_fit(self): """ General test for pyhpecfm.fabric.perform_fit function """ cfm.connect() all_fabrics = fabric.get_fabrics(cfm) my_fabric = all_fabrics[0]['uuid'] fit = fabric.perform_fit(cfm, my_fabric, "Test Fit", "My Test Fit from Python Library") self.assertEqual(str(fit), '<Response [200]>')
def test_get_vlan_properties(self): """ General test for pyhpecfm.fabric.get_vlan_groups function """ all_fabrics = fabric.get_fabrics(cfm) my_fabric = all_fabrics[0]['uuid'] test_vlan_properties = fabric.get_vlan_properties(cfm, my_fabric) my_attributes = ['vlans', 'ipv4_igmp_snooping', 'ipv6_igmp_snooping'] self.assertIs(type(test_vlan_properties), dict) for i in test_vlan_properties['vlan_properties'][0].keys(): self.assertIn(i, my_attributes)
def test_get_fabric(self): """ General test for get_fabric function """ test_fabric = fabric.get_fabrics(cfm) my_attributes = [ 'description', 'foreign_manager_id', 'foreign_fabric_state', 'name', 'is_stable', 'foreign_management_state', 'foreign_manager_url', 'uuid' ] self.assertIs(type(test_fabric), list) self.assertIs(type(test_fabric[0]), dict) for i in test_fabric[0].keys(): self.assertIn(i, my_attributes)
def test_add_fabric_ip_networks(self): """ General test for pyhpecfm.fabric.add_fabric_ip_networks function """ cfm.connect() fabric_uuid = fabric.get_fabrics(cfm)[0]['uuid'] switch_uuid = fabric.get_switches(cfm)[0]['uuid'] test_fabric = fabric.add_ip_fabric(cfm, fabric_uuid, 'new ip fabric', 'my new fabric description', 'manual', '172.16.0.0', '24', '10', switch_uuid, '172.16.0.1') my_attributes = [ 'subnet', 'fabric_uuid', 'name', 'switch_addresses', 'vlan', 'uuid', 'mode', 'description' ] self.assertIs(type(test_fabric), dict) for i in test_fabric.keys(): self.assertIn(i, my_attributes)
def run(self): cfm_fabrics = fabric.get_fabrics(self.client) if isinstance(cfm_fabrics, list): fabric_data = [] # Loop through cfm_fabrics and process fabrics for fab in cfm_fabrics: desc = fab['description'] if desc == '': desc = 'HPE Composable Fabric' out ={ 'u_desc':desc, 'u_uuid':fab['uuid'], 'u_name':fab['name'], 'u_stable':fab['is_stable'], 'u_fms':fab['foreign_fabric_state'] } fabric_data.append(out) return (True, fabric_data) return (False, cfm_fabrics)