Ejemplo n.º 1
0
def sync_globalobj(config, srcmskengname, tgtmskengname, globalobjsync,
                   username, password, protocol):
    """ This module will sync global objects between 2 engines"""

    print_banner()
    if config.debug:
        globals.initialize()
        globals.debug = config.debug

    if config.verbose:
        print_debug('Verbose mode enabled')
        print_debug('srcmskengname = {0}'.format(srcmskengname))
        print_debug('tgtmskengname = {0}'.format(tgtmskengname))
        print_debug('globalobjsync = {0}'.format(globalobjsync))
        print_debug('username      = {0}'.format(username))
        print_debug('protocol      = {0}'.format(protocol))

    try:
        mskai = aimasking(config,
                          srcmskengname=srcmskengname,
                          tgtmskengname=tgtmskengname,
                          globalobjsync=globalobjsync,
                          username=username,
                          password=password,
                          protocol=protocol)
        mskai.sync_globalobj()
    except Exception as e:
        print("Error in MSK module")
        print(str(e))
        return
Ejemplo n.º 2
0
def offline_restore_eng(config, mskengname, username, password, protocol,
                        backup_dir):
    """ This module will offline restore engine from backups"""

    print_banner()
    if config.debug:
        globals.initialize()
        globals.debug = config.debug

    if config.verbose:
        print_debug('Verbose mode enabled')
        print_debug('mskengname    = {0}'.format(mskengname))
        print_debug('username      = {0}'.format(username))
        print_debug('protocol      = {0}'.format(protocol))
        print_debug('backup_dir    = {0}'.format(backup_dir))

    try:
        mskai = aimasking(config,
                          mskengname=mskengname,
                          username=username,
                          password=password,
                          protocol=protocol,
                          backup_dir=backup_dir)
        mskai.offline_restore_eng()
    except Exception as e:
        print("Error in MSK module")
        print(str(e))
        return
Ejemplo n.º 3
0
def test_connectors(config, mskengname, username, password, protocol):
    """ This module will cleanup engine"""

    print_banner()
    if config.debug:
        globals.initialize()
        globals.debug = config.debug

    if config.verbose:
        print_debug('Verbose mode enabled')
        print_debug('mskengname = {0}'.format(mskengname))
        print_debug('username      = {0}'.format(username))
        print_debug('protocol      = {0}'.format(protocol))

    try:
        mskai = aimasking(config,
                          mskengname=mskengname,
                          username=username,
                          password=password,
                          protocol=protocol)
        mskai.test_all_connectors()
    except Exception as e:
        print("Error in MSK module")
        print(str(e))
        return
Ejemplo n.º 4
0
def del_engine(config, mskengname):
    """ This module will remove engine from pool"""
    if config.verbose:
        click.echo('Verbose mode enabled')
        click.echo('mskengname = {0}'.format(mskengname))
    mskai = aimasking(config, mskengname=mskengname)
    mskai.del_engine()
Ejemplo n.º 5
0
def list_engine(config):
    """ This module will remove engine from pool"""
    if config.verbose:
        click.echo('Verbose mode enabled')

    mskai = aimasking(config, noparam='noparam')
    mskai.list_engine()
Ejemplo n.º 6
0
def gen_dxtools_conf(config, protocol):
    """ This module will generate dxtools conf file for engine"""
    if config.verbose:
        click.echo('Verbose mode enabled')

    print_banner()
    mskai = aimasking(config, protocol=protocol)
    mskai.gen_dxtools_conf()
Ejemplo n.º 7
0
def pull_joblist(config, mskengname, username, password, protocol):
    """ This module will pull joblist from engine"""
    if config.verbose or config.debug:
        click.echo('Verbose mode enabled')
        click.echo('mskengname = {0}'.format(mskengname))
        click.echo('username   = {0}'.format(username))
        click.echo('protocol   = {0}'.format(protocol))

    if config.debug:
        globals.initialize()
        globals.debug = config.debug

    print_banner()
    mskai = aimasking(config,
                      mskengname=mskengname,
                      username=username,
                      password=password,
                      protocol=protocol)
    mskai.pull_joblist()
Ejemplo n.º 8
0
def add_engine(config, mskengname, totalgb, systemgb):
    """ This module will add engine to pool"""

    print_banner()
    if config.debug:
        globals.initialize()
        globals.debug = config.debug

    if config.verbose:
        print_debug('Verbose mode enabled')

    globals.arguments['--debug'] = config.debug
    globals.arguments['--config'] = './dxtools.conf'

    mskai = aimasking(config,
                      mskengname=mskengname,
                      totalgb=totalgb,
                      systemgb=systemgb)
    mskai.add_engine()
Ejemplo n.º 9
0
def pull_jobpoolexeclist(config, username, password, protocol):
    """ This module will pull job pool exec list from all engines"""

    print_banner()
    if config.debug:
        globals.initialize()
        globals.debug = config.debug

    if config.verbose:
        print_debug('Verbose mode enabled')
        print_debug('username = {0}'.format(username))
        print_debug('protocol      = {0}'.format(protocol))

    try:
        mskai = aimasking(config,
                          username=username,
                          password=password,
                          protocol=protocol)
        mskai.pull_jobpoolexeclist()
    except Exception as e:
        print("Error in MSK module")
        print(str(e))
        return
Ejemplo n.º 10
0
def list_eng_usage(config, username, password, protocol, mock, dxtoolkit_path):
    """ This module will find green engines"""

    print_banner()
    if config.debug:
        globals.initialize()
        globals.debug = config.debug

    if config.verbose:
        print_debug('Verbose mode enabled')
        print_debug('mock     = {0}'.format(mock))
        print_debug('username = {0}'.format(username))
        print_debug('protocol      = {0}'.format(protocol))
        print_debug('dxtoolkit_path = {0}'.format(dxtoolkit_path))

    globals.arguments['--debug'] = config.debug
    globals.arguments['--config'] = './dxtools.conf'
    globals.arguments['--all'] = True
    globals.arguments['--engine'] = None
    globals.arguments['--logdir'] = './dx_skel.log'
    globals.arguments['--parallel'] = None
    globals.arguments['--poll'] = '10'
    globals.arguments['--version'] = False
    globals.arguments['--single_thread'] = True
    globals.arguments['--dxtoolkit_path'] = dxtoolkit_path

    try:
        mskai = aimasking(config,
                          mock=mock,
                          username=username,
                          password=password,
                          protocol=protocol)
        if not mock:
            mskai.pull_jobexeclist()

    except Exception as e:
        print("Error in MSK module")
        print(str(e))
        return

    try:
        print_debug(" ")
        print_debug("Capture CPU usage data...")
        scriptdir = os.path.dirname(os.path.abspath(__file__))
        outputdir = os.path.join(scriptdir, 'output')
        print_debug("dxtoolkit_path: {}".format(dxtoolkit_path))
        aive = virtualization(config,
                              config_file_path='./dxtools.conf',
                              scriptdir=scriptdir,
                              outputdir=outputdir,
                              protocol=protocol,
                              dxtoolkit_path=dxtoolkit_path)
        print_debug("dxtoolkit_path: {}".format(dxtoolkit_path))
        aive.gen_cpu_file()
        print_debug("Capture CPU usage data : done")
        print_debug(" ")
    except:
        print("Error in VE module")
        return

    try:
        mskai = aimasking(config,
                          mock=mock,
                          username=username,
                          password=password,
                          protocol=protocol)
        mskai.list_eng_usage()
    except Exception as e:
        print("Error in MSK module")
        print(str(e))
        return
Ejemplo n.º 11
0
def run_job(config, jobname, envname, run, mock, username, password, protocol,
            dxtoolkit_path):
    """ This module will execute masking job on best candidate engine"""

    print_banner()
    if config.debug:
        globals.initialize()
        globals.debug = config.debug

    if config.verbose:
        print_debug('Verbose mode enabled')
        print_debug('jobname  = {0}'.format(jobname))
        print_debug('envname  = {0}'.format(envname))
        print_debug('run      = {0}'.format(run))
        print_debug('mock     = {0}'.format(mock))
        print_debug('username = {0}'.format(username))
        print_debug('protocol      = {0}'.format(protocol))
        print_debug('dxtoolkit_path = {0}'.format(dxtoolkit_path))

    globals.arguments['--debug'] = config.debug
    globals.arguments['--config'] = './dxtools.conf'
    globals.arguments['--all'] = True
    globals.arguments['--engine'] = None
    globals.arguments['--logdir'] = './dx_skel.log'
    globals.arguments['--parallel'] = None
    globals.arguments['--poll'] = '10'
    globals.arguments['--version'] = False
    globals.arguments['--single_thread'] = True
    globals.arguments['--dxtoolkit_path'] = dxtoolkit_path

    try:
        mskai = aimasking(config,
                          jobname=jobname,
                          envname=envname,
                          run=run,
                          mock=mock,
                          username=username,
                          password=password,
                          protocol=protocol)
        if not mock:
            mskai.pull_jobexeclist()
        chk_status = mskai.chk_job_running()
        #print("chk_status={}".format(chk_status))
        if chk_status != 0:
            print(
                " Job {} on Env {} is already running on engine {}. Please retry later"
                .format(jobname, envname, chk_status))
            return
    except Exception as e:
        print("Error in MSK module")
        print(str(e))
        return

    try:
        print_debug(" ")
        print_debug(" ")
        print_debug(" ")
        print_debug(" ")
        print_debug("Capture CPU usage data...")
        scriptdir = os.path.dirname(os.path.abspath(__file__))
        outputdir = os.path.join(scriptdir, 'output')
        print_debug("dxtoolkit_path: {}".format(dxtoolkit_path))
        aive = virtualization(config,
                              config_file_path='./dxtools.conf',
                              scriptdir=scriptdir,
                              outputdir=outputdir,
                              protocol=protocol,
                              dxtoolkit_path=dxtoolkit_path)
        print_debug("dxtoolkit_path: {}".format(dxtoolkit_path))
        aive.gen_cpu_file()
        print_debug("Capture CPU usage data : done")
        print_debug(" ")
        print_debug(" ")
        print_debug(" ")
        print_debug(" ")
    except:
        print("Error in VE module")
        return

    try:
        mskai = aimasking(config,
                          jobname=jobname,
                          envname=envname,
                          run=run,
                          mock=mock,
                          username=username,
                          password=password,
                          protocol=protocol)
        mskai.run_job()
    except Exception as e:
        print("Error in MSK module")
        print(str(e))
        return