def take_action(self, parsed_args): image_uuid, path = bs_image.make_bootstrap(vars(parsed_args)) self.app.stdout.write("Bootstrap image {0} has been built: {1}\n".format(image_uuid, path)) if parsed_args.activate: bs_image.import_image(path) bs_image.activate(image_uuid) self.app.stdout.write("Bootstrap image {0} has been activated.\n".format(image_uuid))
def take_action(self, parsed_args): image_uuid, path = bs_image.make_bootstrap(vars(parsed_args)) self.app.stdout.write("Bootstrap image {0} has been built: {1}\n" .format(image_uuid, path)) if parsed_args.activate: bs_image.import_image(path) bs_image.activate(image_uuid) self.app.stdout.write("Bootstrap image {0} has been activated.\n" .format(image_uuid))
def take_action(self, parsed_args): super(BuildCommand, self).take_action(parsed_args) #构造一个bootstrap image_uuid, path = bs_image.make_bootstrap(vars(parsed_args)) self.app.stdout.write( "Bootstrap image {0} has been built: {1}\n".format( image_uuid, path)) #导入bootstrap if parsed_args.activate: bs_image.import_image(path) bs_image.activate(image_uuid) self.app.stdout.write( "Bootstrap image {0} has been activated.\n".format(image_uuid))
def take_action(self, parsed_args): image_uuid, path = bs_image.call_wrapped_method( 'build', parsed_args.notify_webui, data=vars(parsed_args)) self.app.stdout.write( "Bootstrap image {0} has been built: {1}\n".format( image_uuid, path)) if parsed_args.activate: bs_image.import_image(path) bs_image.call_wrapped_method('activate', parsed_args.notify_webui, image_uuid=image_uuid) self.app.stdout.write( "Bootstrap image {0} has been activated.\n".format(image_uuid))
def take_action(self, parsed_args): image_uuid, path = bs_image.call_wrapped_method( 'build', parsed_args.notify_webui, data=vars(parsed_args)) self.app.stdout.write("Bootstrap image {0} has been built: {1}\n" .format(image_uuid, path)) if parsed_args.activate: bs_image.import_image(path) bs_image.call_wrapped_method( 'activate', parsed_args.notify_webui, image_uuid=image_uuid) self.app.stdout.write("Bootstrap image {0} has been activated.\n" .format(image_uuid))
def take_action(self, parsed_args): # Cliff handles errors by itself image_uuid = bs_image.import_image(parsed_args.filename) self.app.stdout.write("Bootstrap image {0} has been imported.\n" .format(image_uuid)) if parsed_args.activate: image_uuid = bs_image.activate(image_uuid) self.app.stdout.write("Bootstrap image {0} has been activated\n" .format(image_uuid))
def take_action(self, parsed_args): # Cliff handles errors by itself image_uuid = bs_image.import_image(parsed_args.filename) self.app.stdout.write( "Bootstrap image {0} has been imported.\n".format(image_uuid)) if parsed_args.activate: image_uuid = bs_image.activate(image_uuid) self.app.stdout.write( "Bootstrap image {0} has been activated\n".format(image_uuid))
def test_import_image(self, extract_mock, tempfile_mock, shutil_mock, chmod_mock): arch_path = '/path' extract_dir = '/tmp/test' dir_path = '/test/image_3' self.yaml_mock.return_value = {'uuid': dir_path} self.assertEqual(bs_image.import_image('/path'), dir_path) tempfile_mock.assert_called_once_with() extract_mock.assert_called_once_with(arch_path, extract_dir) shutil_mock.assert_called_once_with(extract_dir, dir_path) chmod_mock.assert_has_calls([ mock.call(dir_path, 0o755), mock.call(os.path.join(dir_path, 'directory'), 0o755), mock.call(os.path.join(dir_path, 'file'), 0o755)])
def test_import_image(self, extract_mock, tempfile_mock, shutil_mock, chmod_mock): arch_path = '/path' extract_dir = '/tmp/test' dir_path = '/test/image_3' self.yaml_mock.return_value = {'uuid': dir_path} self.assertEqual(bs_image.import_image('/path'), dir_path) tempfile_mock.assert_called_once_with() extract_mock.assert_called_once_with(arch_path, extract_dir) shutil_mock.assert_called_once_with(extract_dir, dir_path) chmod_mock.assert_has_calls([ mock.call(dir_path, 0o755), mock.call(os.path.join(dir_path, 'directory'), 0o755), mock.call(os.path.join(dir_path, 'file'), 0o755) ])
def test_import_exists_image(self, extract_mock, tempfile_mock): self.yaml_mock.return_value = DATA[0] image_uuid = DATA[0].get('uuid') error_msg = ("Image \[{0}] already exists.".format(image_uuid)) with self.assertRaisesRegexp(errors.ImageAlreadyExists, error_msg): bs_image.import_image('/path')