def status(self, uuids): """ Get the status of the agent. Relies on heartbeat. @param uuids: A list of uuids. @type uuids: list @return: {} """ rest = Rest() path = '/agenthub/agent/%s/' % uuids[0] reply = rest.get(path) return reply[1]
def status(self, uuids): """ Get the status of the agent. Relies on heartbeat. @param uuids: A list of uuids. @type uuids: list @return: {} """ rest = Rest() result = {} for uuid in uuids: path = '/agenthub/agent/%s/' % uuid status, body = rest.get(path) if status == 200: result[uuid] = body else: raise Exception('Status Failed') return result
def status(cls, uuids): """ Get the status of the agent. Relies on heartbeat. @param uuids: A list of uuids. @type uuids: list @return: {} """ rest = Rest() result = {} for uuid in uuids: path = '/agenthub/agent/%s/' % uuid status, body = rest.get(path) if status == 200: result[uuid] = body else: raise Exception('Status Failed') return result
def cancel(self, task_id): """ Cancel an agent request by task ID. :param task_id: The ID of a task associated with an agent request. :type task_id: str """ agent = Agent(self.context.uuid, rest=Rest(), secret=self.context.secret, timeout=None, async=True) admin = agent.Admin() status, result = admin.cancel(criteria={'eq': task_id}) if status != 202: raise Exception('Cancellation Failed')
def send(self): """ Request the agent to send the package profile. @return: The RMI request serial number. @rtype: str @return: Tuple (<httpcode>, None); 202 expected. @rtype: tuple """ agent = Agent(self.context.uuid, rest=Rest(), secret=self.context.secret) profile = agent.Profile() status, result = profile.send() if status != 202: raise Exception('Profile Failed') return (status, result)
def unregistered(self): """ Notification that the consumer has been unregistered. Registration artifacts are cleaned up. @return: Tuple (<httpcode>, None); 202 expected. @rtype: tuple """ agent = Agent(self.context.uuid, rest=Rest(), secret=self.context.secret, async=True) consumer = agent.Consumer() status, result = consumer.unregistered() if status != 202: raise Exception('Unregistered Failed') return (status, result)
def uninstall(self, units, options): """ Uninstall content on a consumer. @param units: A list of content units to be uninstalled. @type units: list of: { type_id:<str>, unit_key:<dict> } @param options: Uninstall options; based on unit type. @type options: dict @return: Tuple (<httpcode>, None); 202 expected. @rtype: tuple """ agent = Agent(self.context.uuid, rest=Rest(), timeout=self.context.get_timeout('uninstall_timeout'), secret=self.context.secret, replyto=self.context.replyto, any=self.context.call_request_id) content = agent.Content() status, result = content.uninstall(units, options) if status != 202: raise Exception('Uninstall Failed') return (status, result)
def unbind(self, bindings, options): """ Unbind a consumer from the specified repository. @param bindings: A list of bindings to be removed. Each binding is: {type_id:<str>, repo_id:<str>} @type bindings: list @param options: Unbind options. @type options: dict @return: Tuple (<httpcode>, None); 202 expected. @rtype: tuple """ agent = Agent(self.context.uuid, rest=Rest(), timeout=self.context.get_timeout('unbind_timeout'), secret=self.context.secret, replyto=self.context.replyto, any=self.context.call_request_id) consumer = agent.Consumer() status, result = consumer.unbind(bindings, options) if status != 202: raise Exception('Unbind Failed') return (status, result)
def bind(self, bindings, options): """ Bind a consumer to the specified repository. @param bindings: A list of bindings to add/update. Each binding is: {type_id:<str>, repo_id:<str>, details:<dict>} The 'details' are at the discretion of the distributor. @type bindings: list @param options: Bind options. @type options: dict @return: The RMI request serial number. @rtype: str """ agent = Agent(self.context.uuid, rest=Rest(), timeout=self.context.get_timeout('bind_timeout'), secret=self.context.secret, replyto=self.context.replyto, any=self.context.call_request_id) consumer = agent.Consumer() status, result = consumer.bind(bindings, options) if status != 202: raise Exception('Bind Failed') return (status, result)