def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) senlin_client = self.app.client_manager.clustering spec = senlin_utils.get_spec_content(parsed_args.spec_file) type_name = spec.get('type', None) type_version = spec.get('version', None) properties = spec.get('properties', None) if type_name is None: raise exc.CommandError(_("Missing 'type' key in spec file.")) if type_version is None: raise exc.CommandError(_("Missing 'version' key in spec file.")) if properties is None: raise exc.CommandError(_("Missing 'properties' key in spec file.")) if type_name == 'os.heat.stack': stack_properties = senlin_utils.process_stack_spec(properties) spec['properties'] = stack_properties params = { 'name': parsed_args.name, 'spec': spec, 'metadata': senlin_utils.format_parameters(parsed_args.metadata), } profile = senlin_client.create_profile(**params) return _show_profile(senlin_client, profile_id=profile.id)
def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) senlin_client = self.app.client_manager.clustering spec = senlin_utils.get_spec_content(parsed_args.spec_file) attrs = { 'spec': spec, } policy = senlin_client.validate_policy(**attrs) formatters = { 'spec': senlin_utils.json_formatter } columns = [ 'created_at', 'data', 'domain', 'id', 'name', 'project', 'spec', 'type', 'updated_at', 'user' ] return columns, utils.get_dict_properties(policy.to_dict(), columns, formatters=formatters)
def do_profile_create(service, args): """Create a profile.""" spec = utils.get_spec_content(args.spec_file) type_name = spec.get('type', None) type_version = spec.get('version', None) properties = spec.get('properties', None) if type_name is None: raise exc.CommandError(_("Missing 'type' key in spec file.")) if type_version is None: raise exc.CommandError(_("Missing 'version' key in spec file.")) if properties is None: raise exc.CommandError(_("Missing 'properties' key in spec file.")) if type_name == 'os.heat.stack': stack_properties = utils.process_stack_spec(properties) spec['properties'] = stack_properties params = { 'name': args.name, 'spec': spec, 'metadata': utils.format_parameters(args.metadata), } profile = service.create_profile(**params) _show_profile(service, profile.id)
def do_policy_create(service, args): """Create a policy.""" spec = utils.get_spec_content(args.spec_file) attrs = { 'name': args.name, 'spec': spec, } policy = service.create_policy(**attrs) _show_policy(service, policy.id)
def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) senlin_client = self.app.client_manager.clustering spec = senlin_utils.get_spec_content(parsed_args.spec_file) attrs = { 'name': parsed_args.name, 'spec': spec, } policy = senlin_client.create_policy(**attrs) return _show_policy(senlin_client, policy.id)
def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) senlin_client = self.app.client_manager.clustering spec = senlin_utils.get_spec_content(parsed_args.spec_file) type_name = spec.get('type', None) type_version = spec.get('version', None) properties = spec.get('properties', None) if type_name is None: raise exc.CommandError(_("Missing 'type' key in spec file.")) if type_version is None: raise exc.CommandError(_("Missing 'version' key in spec file.")) if properties is None: raise exc.CommandError(_("Missing 'properties' key in spec file.")) if type_name == 'os.heat.stack': stack_properties = senlin_utils.process_stack_spec(properties) spec['properties'] = stack_properties params = { 'spec': spec, } profile = senlin_client.validate_profile(**params) formatters = {} formatters['metadata'] = senlin_utils.json_formatter formatters['spec'] = senlin_utils.nested_dict_formatter( ['type', 'version', 'properties'], ['property', 'value']) columns = [ 'created_at', 'domain', 'id', 'metadata', 'name', 'project_id', 'spec', 'type', 'updated_at', 'user_id' ] return columns, utils.get_dict_properties(profile.to_dict(), columns, formatters=formatters)