def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) cip = copy.deepcopy(kolla_builder.CONTAINER_IMAGE_PREPARE_PARAM) if parsed_args.push_destination: for entry in cip: entry['push_destination'] = True params = {'ContainerImagePrepare': cip} if parsed_args.registry_login: if parsed_args.push_destination: self.log.warning('[WARNING] --local-push-destination was used ' 'with --enable-registry-login. Please make ' 'sure you understand the use of these ' 'parameters together as they can cause ' 'deployment failures.') self.log.warning('[NOTE] Make sure to update the paramter_defaults' ' with ContainerImageRegistryCredentials for the ' 'registries requiring authentication.') params['ContainerImageRegistryLogin'] = True env_data = build_env_file(params, self.app.command_options) self.app.stdout.write(env_data) if parsed_args.output_env_file: if os.path.exists(parsed_args.output_env_file): self.log.warning("Output env file exists, " "moving it to backup.") shutil.move(parsed_args.output_env_file, parsed_args.output_env_file + ".backup") utils.safe_write(parsed_args.output_env_file, env_data)
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) if parsed_args.cleanup not in image_uploader.CLEANUP: raise oscexc.CommandError('--cleanup must be one of: %s' % ', '.join(image_uploader.CLEANUP)) roles_data = utils.fetch_roles_file(parsed_args.roles_file) env = utils.build_prepare_env( parsed_args.environment_files, parsed_args.environment_directories ) lock = processlock.ProcessLock() params = kolla_builder.container_images_prepare_multi( env, roles_data, dry_run=parsed_args.dry_run, cleanup=parsed_args.cleanup, lock=lock) env_data = build_env_file(params, self.app.command_options) if parsed_args.output_env_file: if os.path.exists(parsed_args.output_env_file): self.log.warning("Output env file exists, " "moving it to backup.") shutil.move(parsed_args.output_env_file, parsed_args.output_env_file + ".backup") utils.safe_write(parsed_args.output_env_file, env_data) else: self.app.stdout.write(env_data)
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) cip = copy.deepcopy(kolla_builder.CONTAINER_IMAGE_PREPARE_PARAM) if parsed_args.push_destination: for entry in cip: entry['push_destination'] = True params = {'ContainerImagePrepare': cip} env_data = build_env_file(params, self.app.command_options) self.app.stdout.write(env_data) if parsed_args.output_env_file: if os.path.exists(parsed_args.output_env_file): self.log.warning("Output env file exists, " "moving it to backup.") shutil.move(parsed_args.output_env_file, parsed_args.output_env_file + ".backup") utils.safe_write(parsed_args.output_env_file, env_data)
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) self.log.warning("[DEPRECATED] This command has been deprecated and " "replaced by the 'openstack tripleo container image " "prepare' command.") roles_data = utils.fetch_roles_file(parsed_args.roles_file) or set() env = utils.build_prepare_env( parsed_args.environment_files, parsed_args.environment_directories ) if roles_data: service_filter = kolla_builder.build_service_filter( env, roles_data) else: service_filter = None mapping_args = { 'tag': parsed_args.tag, 'namespace': parsed_args.namespace, 'name_prefix': parsed_args.prefix, 'name_suffix': parsed_args.suffix, } self.parse_set_values(mapping_args, parsed_args.set) pd = env.get('parameter_defaults', {}) kolla_builder.set_neutron_driver(pd, mapping_args) output_images_file = (parsed_args.output_images_file or 'container_images.yaml') modify_role = None modify_vars = None append_tag = None if parsed_args.modify_role: modify_role = parsed_args.modify_role append_tag = time.strftime('-modified-%Y%m%d%H%M%S') if parsed_args.modify_vars: with open(parsed_args.modify_vars) as m: modify_vars = yaml.safe_load(m.read()) prepare_data = kolla_builder.container_images_prepare( excludes=parsed_args.excludes, includes=parsed_args.includes, service_filter=service_filter, push_destination=parsed_args.push_destination, mapping_args=mapping_args, output_env_file=parsed_args.output_env_file, output_images_file=output_images_file, tag_from_label=parsed_args.tag_from_label, modify_role=modify_role, modify_vars=modify_vars, append_tag=append_tag, template_file=parsed_args.template_file ) if parsed_args.output_env_file: params = prepare_data[parsed_args.output_env_file] output_env_file_expanded = os.path.expanduser( parsed_args.output_env_file) if os.path.exists(output_env_file_expanded): self.log.warning("Output env file exists, " "moving it to backup.") shutil.move(output_env_file_expanded, output_env_file_expanded + ".backup") utils.safe_write(output_env_file_expanded, build_env_file(params, self.app.command_options)) result = prepare_data[output_images_file] result_str = yaml.safe_dump({'container_images': result}, default_flow_style=False) sys.stdout.write(result_str) if parsed_args.output_images_file: utils.safe_write(parsed_args.output_images_file, result_str)