def test__get_node_id_conflict(self):
     node = self._get_node()
     handler = nodes.find_driver_handler('pxe_ipmitool')
     node_map = {'mac': {'aaa': 'abcdef'},
                 'pm_addr': {'foo.bar': 'defabc'}}
     self.assertRaises(exception.InvalidNode,
                       nodes._get_node_id,
                       node, handler, node_map)
Example #2
0
 def test__get_node_id_conflict(self):
     node = self._get_node()
     handler = nodes.find_driver_handler('pxe_ipmitool')
     node_map = {'mac': {'aaa': 'abcdef'},
                 'pm_addr': {'foo.bar': 'defabc'}}
     self.assertRaises(exception.InvalidNode,
                       nodes._get_node_id,
                       node, handler, node_map)
Example #3
0
    def _existing_ips(self):
        result = set()

        for node in self.existing_nodes:
            try:
                handler = nodes.find_driver_handler(node['driver'])
            except exception.InvalidNode:
                LOG.warning(
                    'No known handler for driver %(driver)s of '
                    'node %(node)s, ignoring it', {
                        'driver': node['driver'],
                        'node': node['uuid']
                    })
                continue

            address_field = handler.convert_key('pm_addr')
            if address_field is None:
                LOG.info(
                    'No address field for driver %(driver)s of '
                    'node %(node)s, ignoring it', {
                        'driver': node['driver'],
                        'node': node['uuid']
                    })
                continue

            address = node['driver_info'].get(address_field)
            if address is None:
                LOG.warning('No address for node %(node)s, ignoring it',
                            {'node': node['uuid']})
                continue

            try:
                ip = socket.gethostbyname(address)
            except socket.gaierror as exc:
                LOG.warning(
                    'Cannot resolve %(field)s "%(value)s" '
                    'for node %(node)s: %(error)s', {
                        'field': address_field,
                        'value': address,
                        'node': node['uuid'],
                        'error': exc
                    })
                continue

            port_field = handler.convert_key('pm_port')
            port = node['driver_info'].get(port_field, handler.default_port)
            if port is not None:
                port = int(port)

            LOG.debug('Detected existing BMC at %s with port %s', ip, port)
            result.add((ip, port))

        return result
Example #4
0
    def _existing_ips(self):
        result = set()

        for node in self.existing_nodes:
            try:
                handler = nodes.find_driver_handler(node['driver'])
            except exception.InvalidNode:
                LOG.warning('No known handler for driver %(driver)s of '
                            'node %(node)s, ignoring it',
                            {'driver': node['driver'], 'node': node['uuid']})
                continue

            address_field = handler.convert_key('pm_addr')
            if address_field is None:
                LOG.info('No address field for driver %(driver)s of '
                         'node %(node)s, ignoring it',
                         {'driver': node['driver'], 'node': node['uuid']})
                continue

            address = node['driver_info'].get(address_field)
            if address is None:
                LOG.warning('No address for node %(node)s, ignoring it',
                            {'node': node['uuid']})
                continue

            try:
                ip = socket.gethostbyname(address)
            except socket.gaierror as exc:
                LOG.warning('Cannot resolve %(field)s "%(value)s" '
                            'for node %(node)s: %(error)s',
                            {'field': address_field, 'value': address,
                             'node': node['uuid'], 'error': exc})
                continue

            port_field = handler.convert_key('pm_port')
            port = node['driver_info'].get(port_field, handler.default_port)
            if port is not None:
                port = int(port)

            LOG.debug('Detected existing BMC at %s with port %s', ip, port)
            result.add((ip, port))

        return result
 def test_get_node_id_valid_duplicate(self):
     node = self._get_node()
     handler = nodes.find_driver_handler('pxe_ipmitool')
     node_map = {'mac': {'aaa': 'id'},
                 'pm_addr': {'foo.bar': 'id'}}
     self.assertEqual('id', nodes._get_node_id(node, handler, node_map))
 def test__get_node_id_fake_pxe(self):
     node = self._get_node()
     node['pm_type'] = 'fake_pxe'
     handler = nodes.find_driver_handler('fake_pxe')
     node_map = {'mac': {'aaa': 'abcdef'}, 'pm_addr': {}}
     self.assertEqual('abcdef', nodes._get_node_id(node, handler, node_map))
Example #7
0
 def test_get_node_id_valid_duplicate(self):
     node = self._get_node()
     handler = nodes.find_driver_handler('pxe_ipmitool')
     node_map = {'mac': {'aaa': 'id'}, 'pm_addr': {'foo.bar': 'id'}}
     self.assertEqual('id', nodes._get_node_id(node, handler, node_map))
Example #8
0
 def test__get_node_id_fake_pxe(self):
     node = self._get_node()
     node['pm_type'] = 'fake_pxe'
     handler = nodes.find_driver_handler('fake_pxe')
     node_map = {'mac': {'aaa': 'abcdef'}, 'pm_addr': {}}
     self.assertEqual('abcdef', nodes._get_node_id(node, handler, node_map))