Exemplo n.º 1
0
 def update_resource(self, ctx: HandlerContext, changes: dict,
                     resource: PurgeableResource) -> None:
     if "permissions" in changes:
         mode = str(resource.permissions)
         self._io.chmod(resource.path, mode)
     if "owner" in changes or "group" in changes:
         self._io.chown(resource.path, resource.owner, resource.group)
     ctx.set_updated()
Exemplo n.º 2
0
    def update_resource(self, ctx: HandlerContext, changes: dict,
                        resource: Config) -> None:
        if resource.facts:
            return
        ctx.debug("Updating resource, invalidating cache")
        self._invalidate_cache(resource)

        self._execute(ctx, resource, delete=True)
        ctx.set_updated()
Exemplo n.º 3
0
    def update_resource(self, ctx: HandlerContext, changes: dict,
                        resource: PurgeableResource) -> None:
        if not self._io.file_exists(resource.path):
            raise Exception(
                f"Cannot update file {resource.path} because it doesn't exist")

        if "hash" in changes:
            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)

        if "permissions" in changes:
            self._io.chmod(resource.path, str(resource.permissions))

        if "owner" in changes or "group" in changes:
            self._io.chown(resource.path, resource.owner, resource.group)
        ctx.set_updated()
Exemplo n.º 4
0
 def update_resource(
     self, ctx: HandlerContext, changes: dict, resource: PurgeableResource
 ) -> None:
     self._io.remove(resource.target)
     self._io.symlink(resource.source, resource.target)
     ctx.set_updated()
Exemplo n.º 5
0
 def update_resource(self, ctx: HandlerContext, changes: dict,
                     resource: ResourceResource) -> None:
     a = self.run_sync(self.test_sync)
     assert a == 5
     ctx.set_updated()
Exemplo n.º 6
0
 def update_resource(self, ctx: HandlerContext, changes: dict,
                     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_updated()
Exemplo n.º 7
0
 def update_resource(self, ctx: HandlerContext, changes: dict,
                     resource: ResourceResource) -> None:
     ctx.set_updated()