def test_create_resources(self, mock_load, mock_validate, mock_chassis,
                           mock_nodes):
     resources_files = ['file.json']
     create_resources.create_resources(self.client, resources_files)
     mock_load.assert_has_calls([mock.call('file.json')])
     mock_validate.assert_called_once_with(valid_json, mock.ANY)
     mock_chassis.assert_called_once_with(self.client,
                                          valid_json['chassis'])
     mock_nodes.assert_called_once_with(self.client, valid_json['nodes'])
Esempio n. 2
0
def do_create(cc, args):
    """Create baremetal resources (chassis, nodes, and ports).

    The resources may be described in one or more JSON or YAML files. If any
    file cannot be validated, no resources are created. An attempt is made to
    create all the resources; those that could not be created are skipped
    (with a corresponding error message).
    """
    create_resources.create_resources(cc, args.resource_files)
def do_create(cc, args):
    """Create baremetal resources (chassis, nodes, and ports).

    The resources may be described in one or more JSON or YAML files. If any
    file cannot be validated, no resources are created. An attempt is made to
    create all the resources; those that could not be created are skipped
    (with a corresponding error message).
    """
    create_resources.create_resources(cc, args.resource_files)
 def test_create_resources(
         self, mock_load, mock_validate, mock_chassis, mock_nodes):
     resources_files = ['file.json']
     create_resources.create_resources(self.client, resources_files)
     mock_load.assert_has_calls([
         mock.call('file.json')
     ])
     mock_validate.assert_called_once_with(valid_json, mock.ANY)
     mock_chassis.assert_called_once_with(self.client,
                                          valid_json['chassis'])
     mock_nodes.assert_called_once_with(self.client,
                                        valid_json['nodes'])
Esempio n. 5
0
 def take_action(self, parsed_args):
     if parsed_args.driver:
         self.log.warning(_LW("This command is deprecated. Instead, use "
                              "'openstack baremetal node create'."))
         return super(CreateBaremetal, self).take_action(parsed_args)
     if not parsed_args.resource_files:
         raise exc.ValidationError(_(
             "If --driver is not supplied to openstack create command, "
             "it is considered that it will create ironic resources from "
             "one or more .json or .yaml files, but no files provided."))
     create_resources.create_resources(self.app.client_manager.baremetal,
                                       parsed_args.resource_files)
     # NOTE(vdrok): CreateBaremetal is still inherited from ShowOne class,
     # which requires the return value of the function to be of certain
     # type, leave this workaround until creation of nodes is removed and
     # then change it so that this inherits from command.Command
     return tuple(), tuple()
 def take_action(self, parsed_args):
     if parsed_args.driver:
         self.log.warning("This command is deprecated. Instead, use "
                          "'openstack baremetal node create'.")
         return super(CreateBaremetal, self).take_action(parsed_args)
     if not parsed_args.resource_files:
         raise exc.ValidationError(_(
             "If --driver is not supplied to openstack create command, "
             "it is considered that it will create ironic resources from "
             "one or more .json or .yaml files, but no files provided."))
     create_resources.create_resources(self.app.client_manager.baremetal,
                                       parsed_args.resource_files)
     # NOTE(vdrok): CreateBaremetal is still inherited from ShowOne class,
     # which requires the return value of the function to be of certain
     # type, leave this workaround until creation of nodes is removed and
     # then change it so that this inherits from command.Command
     return tuple(), tuple()
Esempio n. 7
0
 def take_action(self, parsed_args):
     create_resources.create_resources(self.app.client_manager.baremetal,
                                       parsed_args.resource_files)