def test_get_nova_bm_client(self, client_mock, environ): clients.get_nova_bm_client() client_mock.assert_called_once_with(environ["OS_USERNAME"], environ["OS_PASSWORD"], environ["OS_AUTH_URL"], environ["OS_TENANT_NAME"], extensions=[mock.ANY])
def test_get_nova_bm_client(self, client_mock, environ): clients.get_nova_bm_client() client_mock.assert_called_once_with(environ["OS_USERNAME"], environ["OS_PASSWORD"], environ["OS_AUTH_URL"], environ["OS_TENANT_NAME"], extensions=[mock.ANY])
def main(): args = parse_args() environment._configure_logging(args) try: environment._ensure() client = clients.get_nova_bm_client() flavors.cleanup_flavors(client) root_disk = os.environ.get('ROOT_DISK', None) if args.nodes: with open(args.nodes, 'r') as nodes_file: nodes_list = json.load(nodes_file) flavors.create_flavors_from_nodes(client, nodes_list, args.kernel, args.ramdisk, root_disk) elif args.flavors: with open(args.flavors, 'r') as flavors_file: flavors_list = json.load(flavors_file) flavors.create_flavors_from_list(client, flavors_list, args.kernel, args.ramdisk) elif args.ironic: ironic_client = clients.get_ironic_client() flavors.create_flavors_from_ironic(client, ironic_client, args.kernel, args.ramdisk, root_disk) except Exception: logging.exception("Unexpected error during command execution") return 1 return 0
def main(): args = parse_args() environment._configure_logging(args) try: environment._ensure() client = clients.get_nova_bm_client() flavors.cleanup_flavors(client) root_disk = os.environ.get('ROOT_DISK', None) if args.nodes: with open(args.nodes, 'r') as nodes_file: nodes_list = json.load(nodes_file) flavors.create_flavors_from_nodes( client, nodes_list, args.kernel, args.ramdisk, root_disk) elif args.flavors: with open(args.flavors, 'r') as flavors_file: flavors_list = json.load(flavors_file) flavors.create_flavors_from_list( client, flavors_list, args.kernel, args.ramdisk) elif args.ironic: ironic_client = clients.get_ironic_client() flavors.create_flavors_from_ironic( client, ironic_client, args.kernel, args.ramdisk, root_disk) except Exception: logging.exception("Unexpected error during command execution") return 1 return 0
def register_all_nodes(service_host, nodes_list, client=None, remove=False): LOG.debug('Registering all nodes.') ironic_in_use = using_ironic(keystone=None) if ironic_in_use: if client is None: LOG.warn('Creating ironic client inline is deprecated, please ' 'pass the client as parameter.') client = clients.get_ironic_client() register_func = _update_or_register_ironic_node else: if client is None: LOG.warn('Creating nova-bm client inline is deprecated, please ' 'pass the client as parameter.') client = clients.get_nova_bm_client() register_func = _update_or_register_bm_node node_map = _populate_node_mapping(ironic_in_use, client) seen = set() for node in nodes_list: new_node = register_func(service_host, node, node_map, client=client) seen.add(new_node) _clean_up_extra_nodes(ironic_in_use, seen, client, remove=remove)
def main(): args = parse_args() environment._configure_logging(args) try: with open(args.nodes, 'r') as node_file: nodes_list = json.load(node_file) environment._ensure() keystone_client = _clients.get_keystone_client() if nodes.using_ironic(keystone=keystone_client): client = _clients.get_ironic_client() else: client = _clients.get_nova_bm_client() nodes.register_all_nodes( args.service_host, nodes_list, client=client, remove=args.remove) except Exception: logging.exception("Unexpected error during command execution") return 1 return 0
def register_all_nodes(service_host, nodes_list, client=None, remove=False): LOG.debug('Registering all nodes.') ironic_in_use = using_ironic(keystone=None) if ironic_in_use: if client is None: LOG.warn('Creating ironic client inline is deprecated, please ' 'pass the client as parameter.') client = clients.get_ironic_client() register_func = _update_or_register_ironic_node else: if client is None: LOG.warn('Creating nova-bm client inline is deprecated, please ' 'pass the client as parameter.') client = clients.get_nova_bm_client() register_func = _update_or_register_bm_node node_map = _populate_node_mapping(ironic_in_use, client) seen = set() for node in nodes_list: new_node = register_func(service_host, node, node_map, client=client) seen.add(new_node) _clean_up_extra_nodes(ironic_in_use, seen, client, remove=remove)
def main(): args = parse_args() environment._configure_logging(args) try: with open(args.nodes, 'r') as node_file: nodes_list = json.load(node_file) environment._ensure() keystone_client = _clients.get_keystone_client() if nodes.using_ironic(keystone=keystone_client): client = _clients.get_ironic_client() else: client = _clients.get_nova_bm_client() nodes.register_all_nodes(args.service_host, nodes_list, client=client, remove=args.remove) except Exception: logging.exception("Unexpected error during command execution") return 1 return 0