def test_full_url(self, mock_v1): client.introspect(self.uuid, base_url="http://host:port/v1/", auth_token=self.token) mock_v1.assert_called_once_with(auth_token=self.token, inspector_url="http://host:port/v1/", api_version=client.DEFAULT_API_VERSION) mock_v1.return_value.introspect.assert_called_once_with( self.uuid, new_ipmi_username=None, new_ipmi_password=None)
def test_set_ipmi_credentials(self, mock_v1): client.introspect(self.uuid, base_url="http://host:port", auth_token=self.token, new_ipmi_password='******', new_ipmi_username='******') mock_v1.assert_called_once_with(auth_token=self.token, inspector_url="http://host:port", api_version=client.DEFAULT_API_VERSION) mock_v1.return_value.introspect.assert_called_once_with( self.uuid, new_ipmi_username='******', new_ipmi_password='******')
def test_full_url(self, mock_v1): client.introspect(self.uuid, base_url="http://host:port/v1/", session=self.session) mock_v1.assert_called_once_with(auth_token=None, session=self.session, inspector_url="http://host:port/v1/", api_version=client.DEFAULT_API_VERSION) mock_v1.return_value.introspect.assert_called_once_with( self.uuid, new_ipmi_username=None, new_ipmi_password=None)
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)) inspector_client.introspect(node.uuid, base_url=self.inspector_url, auth_token=auth_token) node_uuids.append(node.uuid) print("Waiting for introspection to finish") for uuid, status in utils.wait_for_node_introspection( inspector_client, auth_token, self.inspector_url, node_uuids): if status['error'] is None: print( "Introspection for node {0} finished successfully.".format( uuid)) else: print("Introspection for node {0} finished with error: {1}". format(uuid, status['error']))
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)) inspector_client.introspect( node.uuid, base_url=self.inspector_url, auth_token=auth_token) node_uuids.append(node.uuid) print("Waiting for introspection to finish") for uuid, status in utils.wait_for_node_introspection( inspector_client, auth_token, self.inspector_url, node_uuids): if status['error'] is None: print("Introspection for node {0} finished successfully." .format(uuid)) else: print("Introspection 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.tripleoclient.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(): if node.provision_state != "manageable": continue node_uuids.append(node.uuid) print("Starting introspection of node: {0}".format(node.uuid)) inspector_client.introspect( node.uuid, base_url=parsed_args.inspector_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 introspection to finish...") has_errors = False for uuid, status in utils.wait_for_node_introspection( inspector_client, auth_token, parsed_args.inspector_url, node_uuids): if status['error'] is None: print("Introspection for UUID {0} finished successfully." .format(uuid)) else: print("Introspection for UUID {0} finished with error: {1}" .format(uuid, status['error'])) has_errors = True clients = self.app.client_manager baremetal_client = clients.tripleoclient.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)) if has_errors: print("Introspection completed with errors.") else: print("Introspection completed.")
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) client = self.app.client_manager.tripleoclient.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(maintenance=False, associated=False) 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(maintenance=False, associated=False): if node.provision_state != "manageable": continue node_uuids.append(node.uuid) print("Starting introspection of node: {0}".format(node.uuid)) inspector_client.introspect(node.uuid, base_url=parsed_args.inspector_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 introspection to finish...") has_errors = False for uuid, status in utils.wait_for_node_introspection( inspector_client, auth_token, parsed_args.inspector_url, node_uuids): if status['error'] is None: print( "Introspection for UUID {0} finished successfully.".format( uuid)) else: print("Introspection for UUID {0} finished with error: {1}". format(uuid, status['error'])) has_errors = True print("Setting manageable nodes to available...") self.log.debug("Moving manageable nodes to available state.") available_nodes = [ node for node in client.node.list(maintenance=False, associated=False) if node.provision_state == "manageable" ] for uuid in utils.set_nodes_state(client, available_nodes, 'provide', 'available', skipped_states=("available", "active")): print("Node {0} has been set to available.".format(uuid)) if has_errors: print("Introspection completed with errors.") else: print("Introspection completed.")