def check_resource(self, ctx, resource): current = resource.clone() exists = self._io.run( self._systemd_path, ["status", "%s.service" % resource.name] )[0] if re.search("Loaded: error", exists): raise ResourceNotFoundExcpetion( "The %s service does not exist" % resource.name ) running = ( self._io.run( self._systemd_path, ["is-active", "%s.service" % resource.name] )[2] == 0 ) enabled = ( self._io.run( self._systemd_path, ["is-enabled", "%s.service" % resource.name] )[2] == 0 ) if running: current.state = "running" else: current.state = "stopped" current.onboot = enabled return current
def check_resource(self, ctx, resource): current = resource.clone() current.purged = not Provider.isset(resource.id.get_agent_name(), resource.key) current.value = "that" return current
def check_resource(self, ctx, resource): current = resource.clone() current.purged = not Provider.isset(resource.id.get_agent_name(), resource.key) if not current.purged: current.value = Provider.get(resource.id.get_agent_name(), resource.key) else: current.value = None return current
def check_resource(self, ctx, resource): self.read(resource.id.get_agent_name(), resource.key) assert resource.value != const.UNKNOWN_STRING current = resource.clone() current.purged = not self.isset(resource.id.get_agent_name(), resource.key) if not current.purged: current.value = self.get(resource.id.get_agent_name(), resource.key) else: current.value = None return current
def check_resource(self, ctx, resource): current = resource.clone() exists = self._io.run("/sbin/chkconfig", ["--list", resource.name])[0] if re.search("error reading information on service", exists): raise ResourceNotFoundExcpetion( "The %s service does not exist" % resource.name ) raw_enabled = self._io.run("/sbin/chkconfig", ["--list", resource.name])[0] enabled = ":on" in raw_enabled running = self._io.run("/sbin/service", [resource.name, "status"])[2] == 0 current.onboot = enabled if running: current.state = "running" else: current.state = "stopped" return current
def check_resource(self, ctx, resource: Container): current = resource.clone() containers = self._client.containers(all=True) docker_resource = None for container in containers: names = container["Names"] search_name = resource.name if search_name[0] != "/": search_name = "/" + search_name if search_name in names: docker_resource = container if docker_resource is None: current.state = "purged" return current else: data = self._client.inspect_container(docker_resource["Id"]) current.state = data["State"]["Status"] ctx.set("container_id", docker_resource["Id"]) return current
def check_resource(self, ctx, resource): current = resource.clone() return current