Esempio n. 1
0
    def put(self, pack_uninstall_request, pack_ref):
        """
            Create a new config for a pack.

            Handles requests:
                POST /configs/<pack_ref>
        """

        try:
            config_api = ConfigAPI(pack=pack_ref,
                                   values=vars(pack_uninstall_request))
            config_api.validate(validate_against_schema=True)
        except jsonschema.ValidationError as e:
            raise ValueValidationException(str(e))

        config_content = yaml.safe_dump(config_api.values,
                                        default_flow_style=False)

        configs_path = os.path.join(cfg.CONF.system.base_path, 'configs/')
        config_path = os.path.join(configs_path, '%s.yaml' % config_api.pack)
        with open(config_path, 'w') as f:
            f.write(config_content)

        ConfigsRegistrar.save_model(config_api)

        return config_api
Esempio n. 2
0
    def put(self,
            pack_uninstall_request,
            pack_ref,
            requester_user,
            show_secrets=False):
        """
            Create a new config for a pack.

            Handles requests:
                POST /configs/<pack_ref>
        """

        try:
            config_api = ConfigAPI(pack=pack_ref,
                                   values=vars(pack_uninstall_request))
            config_api.validate(validate_against_schema=True)
        except jsonschema.ValidationError as e:
            raise ValueValidationException(str(e))

        self._dump_config_to_disk(config_api)

        config_db = ConfigsRegistrar.save_model(config_api)

        mask_secrets = self._get_mask_secrets(requester_user,
                                              show_secrets=show_secrets)
        return ConfigAPI.from_model(config_db, mask_secrets=mask_secrets)
Esempio n. 3
0
    def put(self, pack_uninstall_request, pack_ref):
        """
            Create a new config for the action.

            Handles requests:
                POST /configs/<pack_ref>
        """

        try:
            config_api = ConfigAPI(pack=pack_ref, values=vars(pack_uninstall_request))
            config_api.validate(validate_against_schema=True)
        except jsonschema.ValidationError as e:
            raise ValueValidationException(str(e))

        config_content = yaml.safe_dump(config_api.values, default_flow_style=False)

        configs_path = os.path.join(cfg.CONF.system.base_path, 'configs/')
        config_path = os.path.join(configs_path, '%s.yaml' % config_api.pack)
        with open(config_path, 'w') as f:
            f.write(config_content)

        ConfigsRegistrar.save_model(config_api)

        return config_api
Esempio n. 4
0
    def put(self, pack_uninstall_request, pack_ref, requester_user, show_secrets=False):
        """
            Create a new config for a pack.

            Handles requests:
                POST /configs/<pack_ref>
        """

        try:
            config_api = ConfigAPI(pack=pack_ref, values=vars(pack_uninstall_request))
            config_api.validate(validate_against_schema=True)
        except jsonschema.ValidationError as e:
            raise ValueValidationException(str(e))

        self._dump_config_to_disk(config_api)

        config_db = ConfigsRegistrar.save_model(config_api)

        mask_secrets = self._get_mask_secrets(requester_user, show_secrets=show_secrets)
        return ConfigAPI.from_model(config_db, mask_secrets=mask_secrets)