コード例 #1
0
 def create_resource(self, ctx: HandlerContext,
                     resource: PurgeableResource) -> None:
     self._io.mkdir(resource.path)
     mode = str(resource.permissions)
     self._io.chmod(resource.path, mode)
     self._io.chown(resource.path, resource.owner, resource.group)
     ctx.set_created()
コード例 #2
0
ファイル: __init__.py プロジェクト: inmanta/vyos
    def create_resource(self, ctx: HandlerContext, resource: Config) -> None:
        if resource.facts:
            return
        ctx.debug("Creating resource, invalidating cache")
        self._invalidate_cache(resource)

        self._execute(ctx, resource, delete=False)
        ctx.set_created()
コード例 #3
0
    def create_resource(self, ctx: HandlerContext, resource: PurgeableResource) -> None:
        if self._io.file_exists(resource.path):
            raise Exception(
                f"Cannot create file {resource.path}, because it already exists."
            )

        data = self.get_file(resource.hash)
        if hash_file(data) != resource.hash:
            raise Exception(
                "File hash was %s expected %s" % (resource.hash, hash_file(data))
            )

        self._io.put(resource.path, data)
        self._io.chmod(resource.path, str(resource.permissions))
        self._io.chown(resource.path, resource.owner, resource.group)
        ctx.set_created()
コード例 #4
0
 def create_resource(self, ctx: HandlerContext, resource: PurgeableResource) -> None:
     self._io.symlink(resource.source, resource.target)
     ctx.set_created()
コード例 #5
0
 def create_resource(self, ctx: HandlerContext,
                     resource: ResourceResource) -> None:
     ctx.set_created()
コード例 #6
0
 def create_resource(self, ctx: HandlerContext,
                     resource: PurgeableResource) -> None:
     self.touch(resource.id.get_agent_name(), resource.key)
     self.set(resource.id.get_agent_name(), resource.key, resource.value)
     ctx.set_created()