def test_remote_port_hctl(self): from infi.hbaapi import get_ports_collection local_ports = get_ports_collection().get_ports() for local_port in local_ports: remote_ports = local_port.discovered_ports for remote_port in remote_ports: self.assertFalse(remote_port.hct is None)
def test_iterface(self, mock): from .test_generators import get_list_of_generators from infi.hbaapi import get_ports_collection, get_ports_generator mock.return_value = get_list_of_generators() generator = get_ports_generator() self.assertEqual(mock.call_count, 1) available_generators = [item for item in generator.iter_generators()] self.assertEqual(len(available_generators), 1) collection = get_ports_collection() self.assertEqual(len(collection.get_ports()), 0)
def _print_hbaapi_example(): import json from infi.dtypes.wwn import WWN class JSONEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, (WWN)): return str(obj) else: return json.JSONEncoder.default(self, obj) from infi.hbaapi import get_ports_collection print(json.dumps([port for port in get_ports_collection().get_ports()], indent=4, cls=JSONEncoder))
def _print_hbaapi_example(): import json from infi.dtypes.wwn import WWN class JSONEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, (WWN)): return str(obj) else: return json.JSONEncoder.default(self, obj) from infi.hbaapi import get_ports_collection print( json.dumps([port for port in get_ports_collection().get_ports()], indent=4, cls=JSONEncoder))
def test_with_mock_generator(self, mock): mock.return_value = [MockGenerator] from infi.hbaapi import get_ports_collection ports = [port for port in get_ports_collection().iter_ports()]
def test_real_thing(self): from infi.hbaapi import get_ports_collection ports = [port for port in get_ports_collection().iter_ports()] self.assertGreater(len(ports), 0)
def get_connector(self): from infi.hbaapi import get_ports_collection fc_ports = get_ports_collection().get_ports() wwns = [str(port.port_wwn) for port in fc_ports] return dict(initiator=None, host=gethostname(), ip="127.0.0.1", wwns=wwns, wwpns=wwns)
def _get_all_host_bus_adapter_numbers(): from infi.hbaapi import get_ports_collection return [port.hct[0] for port in get_ports_collection().get_ports()]