Пример #1
0
def run(arg):
    try:
        daemon = Daemon()
        if not daemon.is_alive():
            raise Exception('DRM4G is stopped. ')
        if arg['submit']:
            dependencies = '-d "%s"' % ' '.join(
                arg['--dep']) if arg['--dep'] else ''
            number_of_tasks = '-n %s' % arg['--ntasks'] if arg[
                '--ntasks'] else ''
            cmd = 'gwsubmit %s -v %s %s' % (dependencies, arg['<template>'],
                                            number_of_tasks)
        elif arg['list']:
            cmd = 'gwps -o Jsetxjh '
            if arg['<job_id>']:
                cmd = cmd + arg['<job_id>'][0]
        elif arg['history']:
            cmd = 'gwhistory %s' % (arg['<job_id>'][0])
        elif arg['log']:
            directory = join(
                DRM4G_DIR, 'var',
                '%d00-%d99' % (int(int(float(arg['<job_id>'][0])) / 100),
                               int(int(float(arg['<job_id>'][0])) / 100)),
                arg['<job_id>'][0], 'job.log')
            if not exists(directory):
                raise Exception('There is not a log available for this job.')
            cmd = 'cat %s' % (directory)
        else:
            cmd = 'gwkill -9 %s' % (' '.join(arg['<job_id>']))
        out, err = exec_cmd(cmd)
        logger.info(out)
        if err:
            logger.info(err)
    except Exception as err:
        logger.error(str(err))
Пример #2
0
def run( arg ) :
    try:
        daemon = Daemon()
        daemon.stop()
        sleep( 2.0 )
        daemon.clear()
    except Exception as err :
        logger.error( str( err ) )
Пример #3
0
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))
Пример #4
0
def run(arg):
    #if arg[ '--dbg' ] :
    #    logger.setLevel(logging.DEBUG)
    try:
        daemon = Daemon()
        if not daemon.is_alive():
            raise Exception('DRM4G is stopped.')
        cmd = 'gwhost '
        if arg['<hid>']:
            cmd = cmd + arg['<hid>']
        out, err = exec_cmd(cmd)
        logger.info(out)
        if err:
            logger.info(err)
    except Exception as err:
        logger.error(str(err))
Пример #5
0
def run( arg ) :
    try :
        config = Configuration()
        resource = Resource( config )
        if arg[ 'edit' ] :
            resource.edit()
        else :
            daemon = Daemon()
            if not daemon.is_alive() :
                raise Exception( 'DRM4G is stopped.' )

            elif arg[ 'check' ] :
                resource.check_frontends( )
            elif arg[ 'create' ] :
                resource.create_vms()
            elif arg[ 'destroy' ] :
                resource.destroy_vms( )
            elif arg[ '--all' ] :
                resource.list_resources( )
            else :
                resource.list()
    except Exception as err :
        logger.error( str( err ) )
Пример #6
0
def run(arg):
    try:
        Daemon().start()
        #Agent().start()
    except Exception as err:
        logger.error(str(err))