def test_full_url(self, mock_post): client.introspect('uuid1', base_url="http://host:port/v1/", auth_token="token") mock_post.assert_called_once_with( "http://host:port/v1/introspection/uuid1", headers={'X-Auth-Token': 'token'} )
def test_full_url(self, mock_post): client.introspect('uuid1', base_url="http://host:port/v1/", auth_token="token") mock_post.assert_called_once_with( "http://host:port/v1/introspection/uuid1", headers={'X-Auth-Token': 'token'})
def test_setup_ipmi(self): patch_credentials = [ {'op': 'add', 'path': '/driver_info/ipmi_username', 'value': 'admin'}, {'op': 'add', 'path': '/driver_info/ipmi_password', 'value': 'pwd'}, ] self.node.maintenance = True client.introspect(self.uuid, auth_token='token', new_ipmi_username='******', new_ipmi_password='******') eventlet.greenthread.sleep(1) self.assertFalse(self.cli.node.set_power_state.called) status = client.get_status(self.uuid, auth_token='token') self.assertEqual({'finished': False, 'error': None}, status) self.call_ramdisk() eventlet.greenthread.sleep(1) self.cli.node.update.assert_any_call(self.uuid, self.patch) self.cli.node.update.assert_any_call(self.uuid, patch_credentials) self.cli.port.create.assert_called_once_with( node_uuid=self.uuid, address='11:22:33:44:55:66') status = client.get_status(self.uuid, auth_token='token') self.assertEqual({'finished': True, 'error': None}, status) with open(os.path.join(self.temp, 'ipmi_calls.txt'), 'rb') as f: lines = f.readlines() self.assertIn('user set name 2 admin\n', lines) self.assertIn('user set password 2 pwd\n', lines)
def test_default_url(self, mock_post): client.introspect(self.uuid, auth_token="token") mock_post.assert_called_once_with( "%(my_ip)s/introspection/%(uuid)s" % {'my_ip': self.my_ip, 'uuid': self.uuid}, headers={'X-Auth-Token': 'token'}, params={'new_ipmi_username': None, 'new_ipmi_password': None} )
def test_none_ok(self, mock_post): client.introspect(self.uuid) mock_post.assert_called_once_with( "%(my_ip)s/introspection/%(uuid)s" % {'my_ip': self.my_ip, 'uuid': self.uuid}, headers={}, params={'new_ipmi_username': None, 'new_ipmi_password': None} )
def test_full_url(self, mock_post): client.introspect(self.uuid, base_url="http://host:port/v1/", auth_token="token") mock_post.assert_called_once_with( "http://host:port/v1/introspection/%s" % self.uuid, headers={'X-Auth-Token': 'token'}, params={'new_ipmi_username': None, 'new_ipmi_password': None} )
def test_set_ipmi_credentials(self, mock_post): client.introspect(self.uuid, base_url="http://host:port", auth_token="token", new_ipmi_password='******', new_ipmi_username='******') mock_post.assert_called_once_with( "http://host:port/v1/introspection/%s" % self.uuid, headers={'X-Auth-Token': 'token'}, params={'new_ipmi_username': '******', 'new_ipmi_password': '******'} )
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) client = self.app.client_manager.rdomanager_oscplugin.baremetal() auth_token = self.app.client_manager.auth_ref.auth_token node_uuids = [] print("Setting available nodes to manageable...") self.log.debug("Moving available nodes to manageable state.") available_nodes = [node for node in client.node.list() if node.provision_state == "available"] for uuid in utils.set_nodes_state(client, available_nodes, 'manage', 'manageable'): self.log.debug("Node {0} has been set to manageable.".format(uuid)) for node in client.node.list(): node_uuids.append(node.uuid) print("Starting introspection of node: {0}".format(node.uuid)) discoverd_client.introspect( node.uuid, base_url=parsed_args.discoverd_url, auth_token=auth_token) # NOTE(dtantsur): PXE firmware on virtual machines misbehaves when # a lot of nodes start DHCPing simultaneously: it ignores NACK from # DHCP server, tries to get the same address, then times out. Work # around it by using sleep, anyway introspection takes much longer. time.sleep(5) print("Waiting for discovery to finish...") for uuid, status in utils.wait_for_node_discovery( discoverd_client, auth_token, parsed_args.discoverd_url, node_uuids): if status['error'] is None: print("Discovery for UUID {0} finished successfully." .format(uuid)) else: print("Discovery for UUID {0} finished with error: {1}" .format(uuid, status['error'])) clients = self.app.client_manager baremetal_client = clients.rdomanager_oscplugin.baremetal() print("Setting manageable nodes to available...") self.log.debug("Moving manageable nodes to available state.") available_nodes = [node for node in client.node.list() if node.provision_state == "manageable"] for uuid in utils.set_nodes_state( baremetal_client, baremetal_client.node.list(), 'provide', 'available', skipped_states=("available", "active")): print("Node {0} has been set to available.".format(uuid)) print("Discovery completed.")
def take_action(self, parsed_args): auth_token = self.app.client_manager.auth_ref.auth_token client.introspect(parsed_args.uuid, base_url=parsed_args.discoverd_url, auth_token=auth_token, new_ipmi_username=parsed_args.new_ipmi_username, new_ipmi_password=parsed_args.new_ipmi_password) if parsed_args.new_ipmi_password: print('Setting IPMI credentials requested, please power on ' 'the machine manually')
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) client = self.app.client_manager.rdomanager_oscplugin.baremetal() for node in client.node.list(): self.log.debug("Starting introspection of Ironic node {0}".format( node.uuid)) auth_token = self.app.client_manager.auth_ref.auth_token discoverd_client.introspect( node.uuid, base_url=parsed_args.discoverd_url, auth_token=auth_token)
def discover(cls, request, uuids): """Set the maintenance status of node :param request: request object :type request: django.http.HttpRequest :param uuids: IDs of IronicNodes :type uuids: list of str """ if not IRONIC_DISCOVERD_URL: return for uuid in uuids: discoverd_client.introspect(uuid, IRONIC_DISCOVERD_URL, request.user.token.id)
def test_bmc(self): self.node.power_state = 'power off' client.introspect(self.uuid, auth_token='token') eventlet.greenthread.sleep(1) status = client.get_status(self.uuid, auth_token='token') self.assertEqual({'finished': False, 'error': None}, status) self.call_ramdisk() eventlet.greenthread.sleep(1) self.cli.node.update.assert_any_call(self.uuid, self.patch) self.cli.port.create.assert_called_once_with( node_uuid=self.uuid, address='11:22:33:44:55:66') status = client.get_status(self.uuid, auth_token='token') self.assertEqual({'finished': True, 'error': None}, status)
def test_bmc(self): self.node.power_state = 'power off' client.introspect(self.uuid, auth_token='token') eventlet.greenthread.sleep(1) status = client.get_status(self.uuid, auth_token='token') self.assertEqual({'finished': False, 'error': None}, status) self.call_ramdisk() eventlet.greenthread.sleep(1) self.cli.node.update.assert_any_call(self.uuid, self.patch) self.cli.port.create.assert_called_once_with( node_uuid=self.uuid, address='11:22:33:44:55:66') status = client.get_status(self.uuid, auth_token='token') self.assertEqual({'finished': True, 'error': None}, status)
def _run_introspection(self, nodes): auth_token = self.app.client_manager.auth_ref.auth_token node_uuids = [] for node in nodes: print("Starting introspection on node {0}".format(node.uuid)) discoverd_client.introspect(node.uuid, base_url=self.discoverd_url, auth_token=auth_token) node_uuids.append(node.uuid) print("Waiting for discovery to finish") for uuid, status in utils.wait_for_node_discovery( discoverd_client, auth_token, self.discoverd_url, node_uuids): if status['error'] is None: print("Discovery for node {0} finished successfully.".format( uuid)) else: print("Discovery for node {0} finished with error: {1}".format( uuid, status['error']))
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) client = self.app.client_manager.rdomanager_oscplugin.baremetal() for node in client.node.list(): if node.provision_state == "available": self.log.debug(("Setting provision state from {0} to " "'manageable' for Node {1}" ).format(node.provision_state, node.uuid)) client.node.set_provision_state(node.uuid, 'manage') self.log.debug("Starting introspection of Ironic node {0}".format( node.uuid)) auth_token = self.app.client_manager.auth_ref.auth_token discoverd_client.introspect( node.uuid, base_url=parsed_args.discoverd_url, auth_token=auth_token)
def _run_introspection(self, nodes): auth_token = self.app.client_manager.auth_ref.auth_token node_uuids = [] for node in nodes: print("Starting introspection on node {0}".format(node.uuid)) discoverd_client.introspect( node.uuid, base_url=self.discoverd_url, auth_token=auth_token) node_uuids.append(node.uuid) print("Waiting for discovery to finish") for uuid, status in utils.wait_for_node_discovery( discoverd_client, auth_token, self.discoverd_url, node_uuids): if status['error'] is None: print("Discovery for node {0} finished successfully." .format(uuid)) else: print("Discovery for node {0} finished with error: {1}" .format(uuid, status['error']))
def test_default_url(self, mock_post): client.introspect('uuid1', auth_token="token") mock_post.assert_called_once_with( "http://127.0.0.1:5050/v1/introspection/uuid1", headers={'X-Auth-Token': 'token'})
def test_default_url(self, mock_post): client.introspect('uuid1', auth_token="token") mock_post.assert_called_once_with( "http://127.0.0.1:5050/v1/introspection/uuid1", headers={'X-Auth-Token': 'token'} )