Beispiel #1
0
    dsmConfig = None
    dsmInit = False

    dbHost = ''
    vtKey = ''
    accessId = ''
    accessKey = ''
    smHost = ''

    for opt, arg in opts:
        if opt in ('-c'):
            dynConfig = Dyn_Config(arg)
            if not dynConfig.load_config():
                print_and_exit('Dyn Config %s does not exist.' % arg)
            if dynConfig.get_config_str('core', 'mode') == 'factory':
                dsmConfig = Dsm_Config_Factory()
            else:
                dsmConfig = Dsm_Config_Deployment()
            dsmInit = dynConfig.get_config_bool('core', 'init')
            dbHost = dynConfig.get_config_str('db', 'host')
            vtKey = dynConfig.get_config_str('vt', 'key')
            accessId = dynConfig.get_config_str('access', 'id')
            accessKey = dynConfig.get_config_str('access', 'key')
            smHost = dynConfig.get_config_str('sm', 'host')

    if dbHost == '' or vtKey == '' or accessId == '' or accessKey == '' or smHost == '':
        usage_and_exit()

    if dsmConfig is None:
        #default factory mode
Beispiel #2
0
def print_and_exit(msg, exitCode=1):
    print msg
    exit(exitCode)

if __name__ == '__main__':
    opts, args = getopt.getopt(sys.argv[1:], 'c:')

    smConfig = None
    smInit = False

    dbHost = ''

    for opt, arg in opts:
        if opt in ('-c'):
            dynConfig = Dyn_Config(arg)
            if not dynConfig.load_config():
                print_and_exit('Dyn Config %s does not exist.' % arg)
            if dynConfig.get_config_str('core', 'mode') == 'factory':
                smConfig = Sm_Config_Factory()
            else:
                smConfig = Sm_Config_Deployment()
            smInit = dynConfig.get_config_bool('core', 'init')
            dbHost = dynConfig.get_config_str('db', 'host')
            redisHost = dynConfig.get_config_str('redis', 'host')

    smConfig.SM_DB_HOST = dbHost
    smConfig.SM_REDIS_HOST = redisHost

    sysMessenger = Sys_Messenger(smConfig, smInit)
    sysMessenger.do_run()