def _process_entities(self, result): """Process the list of collected entities.""" # be able to look up all entities using entPhysicalIndex entities = EntityTable(result) containers = [self._container_from_entity(entity) for entity in entities.values()] self._fix_hierarchy(containers)
def _process_entities(self, result): """Process the list of collected entities.""" # be able to look up all entities using entPhysicalIndex entities = EntityTable(result) module_containers = self._process_modules(entities) self._process_ports(entities, module_containers)
def test_entity_without_serial_number_is_not_module(self): sensor = { 'entPhysicalDescr': 'Chassis', 'entPhysicalContainedIn': 1, 'entPhysicalClass': 'module', 'entPhysicalSerialNum': '', 'entPhysicalIsFRU': True, } self.assertFalse(EntityTable.is_module(self.entity_table, sensor))
def test_not_FRU_is_not_module(self): sensor = { 'entPhysicalDescr': 'Chassis', 'entPhysicalContainedIn': 1, 'entPhysicalClass': 'module', 'entPhysicalSerialNum': '1', 'entPhysicalIsFRU': False, } self.assertFalse(EntityTable.is_module(self.entity_table, sensor))
def test_transceiver_is_not_module(self): transceiver = { 'entPhysicalDescr': 'Transceiver', 'entPhysicalContainedIn': 2, 'entPhysicalClass': 'module', 'entPhysicalSerialNum': '1', 'entPhysicalIsFRU': True, } self.assertFalse(EntityTable.is_module(self.entity_table, transceiver))
def test_module_is_module(self): module = { 'entPhysicalDescr': 'Chassis', 'entPhysicalContainedIn': 1, 'entPhysicalClass': 'module', 'entPhysicalSerialNum': '1', 'entPhysicalIsFRU': True, } self.assertTrue(EntityTable.is_module(self.entity_table, module))
def handle(self): """Collect PSUs and FANs,- their corresponding statuses and store in database""" self._logger.debug("Collecting PSUs and FANs") entity_table = yield self.entity_mib.get_useful_physical_table_columns() entity_table = EntityTable(entity_table) psus_and_fans = self._get_psus_and_fans(entity_table) if psus_and_fans: for psu_or_fan in psus_and_fans: yield self._handle_unit(psu_or_fan)
def setUp(self): self.entity_table = EntityTable( { 1: { 'entPhysicalDescr': 'Transceiver Port', 'entPhysicalContainedIn': 0, 'entPhysicalClass': 'port', 'entPhysicalSerialNum': '', 'entPhysicalIsFRU': False, 0: 1, }, 2: { 'entPhysicalDescr': 'Transceiver Port Container', 'entPhysicalContainedIn': 1, 'entPhysicalClass': 'container', 'entPhysicalSerialNum': '', 'entPhysicalIsFRU': False, 0: 2, }, } )
def _get_named_table(self, table_name): df = self.retrieve_table(table_name) df.addCallback(self.translate_result) ret_table = yield df named_table = EntityTable(ret_table) defer.returnValue(named_table)