def run(arg): try: daemon = Daemon() if not daemon.is_alive(): raise Exception('DRM4G is stopped.') config = Configuration() config.load() if config.check(): raise Exception("Review the configuration of '%s'." % (arg['<resource_name>'])) if arg['<resource_name>'] not in config.resources: raise Exception("'%s' is not a configured resource." % (arg['<resource_name>'])) lrms = config.resources.get(arg['<resource_name>'])['lrms'] communicator = config.resources.get( arg['<resource_name>'])['communicator'] if lrms != 'cream' and lrms != 'rocci' and communicator == 'local': raise Exception("'%s' does not have an identity to configure." % (arg['<resource_name>'])) if lrms == 'cream' or lrms == 'rocci': comm = config.make_communicators()[arg['<resource_name>']] if communicator == 'op_ssh': #paramiko will always be used to renew the grid certificate config.resources.get( arg['<resource_name>'])['communicator'] = 'pk_ssh' comm = config.make_communicators()[arg['<resource_name>']] proxy = Proxy(config.resources[arg['<resource_name>']], comm) config.resources.get( arg['<resource_name>'])['communicator'] = communicator config.make_communicators() if communicator != 'local': agent = Agent(config.resources[arg['<resource_name>']]) if arg['init']: if communicator != 'local': agent.start() agent.add_key(arg['--lifetime']) agent.copy_key() if lrms == 'cream' or lrms == 'rocci': proxy.configure() proxy.create(arg['--lifetime']) elif arg['delete']: if lrms == 'cream' or lrms == 'rocci': proxy.destroy() if communicator != 'local': agent.delete_key() else: if communicator != 'local': agent.list_key() if lrms == 'cream' or lrms == 'rocci': proxy.check() except Exception as err: logger.error(str(err))
def run(arg): logging.basicConfig(format='%(message)s', level=logging.DEBUG if arg['--dbg'] else logging.INFO, stream=sys.stdout) try: daemon = Daemon() if not daemon.is_alive(): raise Exception('DRM4G is stopped.') config = Configuration() config.load() if config.check(): raise Exception("Review the configuration of '%s'." % (arg['<resource>'])) if arg['<resource>'] not in config.resources: raise Exception("'%s' is not a configured resource." % (arg['<resource>'])) lrms = config.resources.get(arg['<resource>'])['lrms'] communicator = config.resources.get(arg['<resource>'])['communicator'] if lrms != 'cream' and communicator != 'ssh': raise Exception("'%s' does not have an identity to configure." % (arg['<resource>'])) if lrms == 'cream': proxy = Proxy(config.resources[arg['<resource>']], config.make_communicators()[arg['<resource>']]) if communicator == 'ssh': agent = Agent(config.resources[arg['<resource>']]) if arg['init']: if communicator == 'ssh': agent.start() agent.add_key(arg['--lifetime']) agent.copy_key() if lrms == 'cream': proxy.configure() proxy.create(arg['--lifetime']) elif arg['delete']: if lrms == 'cream': proxy.destroy() if communicator == 'ssh': agent.delete_key() else: if communicator == 'ssh': agent.list_key() if lrms == 'cream': proxy.check() except KeyboardInterrupt: pass except Exception as err: logging.error(str(err))