def send(self): """ Request the agent to send the package profile. @return: The RMI request serial number. @rtype: str """ agent = Agent(self.context.uuid, secret=self.context.secret) profile = agent.Profile() return profile.send()
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, url=self.context.url, secret=self.context.secret, async=True) admin = agent.Admin() admin.cancel(criteria={'eq': task_id})
def send(context): """ Request the agent to send the package profile. :param context: The call context. :type context: pulp.server.agent.context.Context """ agent = Agent(context.url, context.route, secret=context.secret, authenticator=context.authenticator) profile = agent.Profile() profile.send()
def unregistered(self): """ Notification that the consumer has been unregistered. Registration artifacts are cleaned up. @return: The RMI request serial number. @rtype: str """ agent = Agent(self.context.uuid, url=self.context.url, secret=self.context.secret, async=True) consumer = agent.Consumer() return consumer.unregistered()
def cancel(context, 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 """ with context: agent = Agent(context.url, context.address, authenticator=context.authenticator, wait=0) admin = agent.Admin() criteria = {'match': {'task_id': task_id}} admin.cancel(criteria=criteria)
def unregistered(context): """ Notification that the consumer has been unregistered. Registration artifacts are cleaned up. :param context: The call context. :type context: pulp.server.agent.context.Context """ agent = Agent(context.url, context.route, secret=context.secret, authenticator=context.authenticator, wait=0) consumer = agent.Consumer() consumer.unregistered()
def uninstall(context, units, options): """ Uninstall content on a consumer. :param context: The call context. :type context: pulp.server.agent.context.Context :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 """ agent = Agent(context.url, context.route, secret=context.secret, authenticator=context.authenticator, reply=context.reply_queue, data=context.details) content = agent.Content() content.uninstall(units, options)
def unbind(context, bindings, options): """ Unbind a consumer from the specified repository. :param context: The call context. :type context: pulp.server.agent.context.Context :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 """ agent = Agent(context.url, context.route, secret=context.secret, authenticator=context.authenticator, reply=context.reply_queue, data=context.details) consumer = agent.Consumer() consumer.unbind(bindings, options)
def unregister(context): """ Notification that the consumer has been unregistered. Registration artifacts are cleaned up. :param context: The call context. :type context: pulp.server.agent.context.Context """ with context: agent = Agent(context.url, context.address, secret=context.secret, authenticator=context.authenticator, wait=0) consumer = agent.Consumer() try: consumer.unregister() except NotFound: # cover the case where cleanup may find that the queue # has already been deleted pass
def test_init(self): url = 'qpid+amqp://host' address = 'xyz' options = {'A': 1, 'B': 2} _agent = Agent(url, address, **options) _options = Options(options) self.assertTrue(_agent, Container) self.assertEqual(_agent._Container__url, url) self.assertEqual(_agent._Container__address, address) self.assertEqual(_agent._Container__options.__dict__, _options.__dict__)
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: The RMI request serial number. @rtype: str """ agent = Agent(self.context.uuid, url=self.context.url, timeout=self.context.get_timeout('uninstall_timeout'), secret=self.context.secret, ctag=self.context.ctag, watchdog=self.context.watchdog, any=self.context.call_request_id) content = agent.Content() return content.uninstall(units, options)
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: The RMI request serial number. @rtype: str """ agent = Agent(self.context.uuid, url=self.context.url, timeout=self.context.get_timeout('unbind_timeout'), secret=self.context.secret, ctag=self.context.ctag, watchdog=self.context.watchdog, any=self.context.call_request_id) consumer = agent.Consumer() return consumer.unbind(bindings, options)
def bind(context, bindings, options): """ Bind a consumer to the specified repository. :param context: The call context. :type context: pulp.server.agent.context.Context :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 """ agent = Agent(context.url, context.route, secret=context.secret, authenticator=context.authenticator, reply=context.reply_queue, data=context.details) consumer = agent.Consumer() consumer.bind(bindings, options)
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, url=self.context.url, timeout=self.context.get_timeout('bind_timeout'), secret=self.context.secret, ctag=self.context.ctag, watchdog=self.context.watchdog, any=self.context.call_request_id) consumer = agent.Consumer() return consumer.bind(bindings, options)
def main(): g_opt = {} options, arguments, keywords = get_options() basicConfig(level=CRITICAL) validate(options) if options.ttl: g_opt['ttl'] = int(options.ttl) if options.wait: g_opt['wait'] = int(options.wait) if options.progress: def print_report(report): print ''.join((options.progress, str(report['details']))) g_opt['progress'] = print_report if options.data: g_opt['data'] = json.loads(options.data) if options.secret: g_opt['secret'] = options.secret if options.authenticator: parts = options.authenticator.split('.') path = '.'.join(parts[:-1]) name = parts[-1] mod = __import__(path, {}, {}, [name]) g_opt['authenticator'] = getattr(mod, name)() if options.user: g_opt['user'] = options.user if options.password: g_opt['password'] = options.password if options.reply: g_opt['reply'] = options.reply if options.input: document = json.loads(options.input) arguments = tuple(document[0]) keywords = document[1] with Connection(options.url, retry=False): agent = Agent(options.url, options.address, **g_opt) target = options.target.split('.', 1) stub = getattr(agent, target[0]) method = getattr(stub, target[1]) retval = method(*arguments, **keywords) print retval