Ejemplo n.º 1
0
def apply_stack_config():
    """
    does the necessary stack configuration changes
    :return: None
    """
    stack = fitargs()['stack']
    if stack is not None:
        mkcfg().add_from_file('stack_config.json', stack)
        if fitargs()['rackhd_host'] == 'localhost' and 'rackhd_host' in fitcfg():
            fitargs()['rackhd_host'] = fitcfg()['rackhd_host']
        if 'bmc' in fitcfg():
            fitargs()['bmc'] = fitcfg()['bmc']
        if 'hyper' in fitcfg():
            fitargs()['hyper'] = fitcfg()['hyper']
Ejemplo n.º 2
0
def add_globals():
    """
    create a handlful of global shortcuts
    :return:
    """
    global TEST_PATH
    global CONFIG_PATH
    global API_PORT
    global API_PROTOCOL
    global VERBOSITY

    # set api port and protocol from command line
    if fitargs()['port'] != "None":
        API_PORT = fitargs()['port']

    if fitargs()['http'] == "True":
        API_PROTOCOL = "http"
        if API_PORT == "None":
            API_PORT = fitports()['http']

    if fitargs()['https'] == "True":
        API_PROTOCOL = "https"
        if API_PORT == "None":
            API_PORT = fitports()['https']

    if fitargs()['rackhd_host'] == "localhost":
        if API_PROTOCOL == "None":
            API_PROTOCOL = 'http'
        if API_PORT == "None":
            API_PORT = '8080'

    # add globals section to base configuration
    TEST_PATH = fit_path.fit_path_root + '/'
    CONFIG_PATH = TEST_PATH + fitargs()['config'] + "/"
    mkcfg().add_from_dict({
        'globals': {
            'API_PORT': API_PORT,
            'API_PROTOCOL': API_PROTOCOL,
            'TEST_PATH': TEST_PATH,
            'CONFIG_PATH': CONFIG_PATH,
            'VERBOSITY': fitargs()['v']
        }
    })

    # set OVA template from command line
    if fitargs()["template"] == "None":
        fitargs()["template"] = fitcfg()['install-config']['template']
Ejemplo n.º 3
0
def apply_stack_config():
    """
    does the necessary stack configuration changes
    :return: None
    """
    stack = fitargs()['stack']
    if stack is not None:
        mkcfg().add_from_file('stack_config.json', stack)

    if mkcfg().config_exists('deploy_generated.json'):
        mkcfg().add_from_file('deploy_generated.json')

    if fitargs()['rackhd_host'] == 'localhost' and 'rackhd_host' in fitcfg():
        fitargs()['rackhd_host'] = fitcfg()['rackhd_host']
    if 'bmc' in fitcfg():
        fitargs()['bmc'] = fitcfg()['bmc']
    if 'hyper' in fitcfg():
        fitargs()['hyper'] = fitcfg()['hyper']
Ejemplo n.º 4
0
def add_globals():
    """
    create a handlful of global shortcuts
    :return:
    """
    global TEST_PATH
    global CONFIG_PATH
    global API_PORT
    global API_PROTOCOL
    global VERBOSITY

    # set api port and protocol from command line
    if fitargs()['http'] is True:
        API_PROTOCOL = "http"
        API_PORT = str(fitports()['http'])
    elif fitargs()['https'] is True:
        API_PROTOCOL = "https"
        API_PORT = str(fitports()['https'])
    else:  # default protocol is http
        API_PROTOCOL = "http"
        API_PORT = str(fitports()['http'])

    if fitargs(
    )['port'] != "None":  # port override via command line argument -port
        API_PORT = fitargs()['port']

    # add globals section to base configuration
    TEST_PATH = fit_path.fit_path_root + '/'
    CONFIG_PATH = TEST_PATH + fitargs()['config'] + "/"
    mkcfg().add_from_dict({
        'globals': {
            'API_PORT': API_PORT,
            'API_PROTOCOL': API_PROTOCOL,
            'TEST_PATH': TEST_PATH,
            'CONFIG_PATH': CONFIG_PATH,
            'VERBOSITY': fitargs()['v']
        }
    })

    # set OVA template from command line argument -template
    if fitargs()["template"] == "None":
        fitargs()["template"] = fitcfg()['install-config']['template']
Ejemplo n.º 5
0
def add_globals():
    """
    create a handlful of global shortcuts
    :return:
    """
    global TEST_PATH
    global CONFIG_PATH
    global API_PORT
    global API_PROTOCOL
    global VERBOSITY

    # set api port and protocol from command line
    if fitargs()['http'] is True:
        API_PROTOCOL = "http"
        API_PORT = str(fitports()['http'])
    elif fitargs()['https'] is True:
        API_PROTOCOL = "https"
        API_PORT = str(fitports()['https'])
    else:  # default protocol is http
        API_PROTOCOL = "http"
        API_PORT = str(fitports()['http'])

    if fitargs()['port'] != "None":  # port override via command line argument -port
        API_PORT = fitargs()['port']

    # add globals section to base configuration
    TEST_PATH = fit_path.fit_path_root + '/'
    CONFIG_PATH = TEST_PATH + fitargs()['config'] + "/"
    mkcfg().add_from_dict({
        'globals': {
            'API_PORT': API_PORT,
            'API_PROTOCOL': API_PROTOCOL,
            'TEST_PATH': TEST_PATH,
            'CONFIG_PATH': CONFIG_PATH,
            'VERBOSITY': fitargs()['v']
        }
    })

    # set OVA template from command line argument -template
    if fitargs()["template"] == "None":
        fitargs()["template"] = fitcfg()['install-config']['template']
Ejemplo n.º 6
0
 def _noserunner(pathspecs, noseopts):
     xmlfile = str(time.time()) + ".xml"  # XML report file name
     env = {
         'FIT_CONFIG': mkcfg().get_path(),
         'HOME': os.environ['HOME'],
         'PATH': os.environ['PATH'],
         'PYTHONPATH': ':'.join(sys.path)
     }
     argv = ['nosetests']
     argv.extend(noseopts)
     argv.append('--xunit-file')
     argv.append(xmlfile)
     argv.extend(pathspecs)
     argv.extend(fitcfg()['cmd-args-list']['unhandled_arguments'])
     return subprocess.call(argv, env=env)
Ejemplo n.º 7
0
 def _noserunner(pathspecs, noseopts):
     xmlfile = str(time.time()) + ".xml"  # XML report file name
     env = {
         'FIT_CONFIG': mkcfg().get_path(),
         'HOME': os.environ['HOME'],
         'PATH': os.environ['PATH'],
         'PYTHONPATH': ':'.join(sys.path)
     }
     argv = ['nosetests']
     argv.extend(noseopts)
     argv.append('--xunit-file')
     argv.append(xmlfile)
     argv.extend(pathspecs)
     argv.extend(fitcfg()['cmd-args-list']['unhandled_arguments'])
     return subprocess.call(argv, env=env)
Ejemplo n.º 8
0
def fitcfg():
    """
    returns the configuration dictionary
    :return: dictionary
    """
    return mkcfg().get()
Ejemplo n.º 9
0
def compose_config(use_sysargs=False):
    """
    creates a configuration based on
    :param use_sysargs: set to true if sys.argv is to be processed.
    :return: None
    """
    # create configuration object
    cfg_obj = mkcfg()
    if cfg_obj.config_is_loaded():
        # a previously generated configuration has been loaded
        # restore previously setup globals
        update_globals()
    else:
        # create new configuration
        #   * add cmd-args-list section
        #   * add the default config json file composition.
        #   * add stack overlay
        #   * save off environment
        #   * generate a few globals
        #   * save (generate) the configuration to a file
        args_list = {}
        if use_sysargs:
            # Args from command line, pass -config option to create
            args_list['cmd-args-list'] = mkargs()
            config = args_list['cmd-args-list']['config']
            cfg_obj.create(config)
        else:
            # Args from default set
            no_args = {}
            args_list['cmd-args-list'] = mkargs(no_args)
            cfg_obj.create()

        # add the 'cmd-args-list' section
        cfg_obj.add_from_dict(args_list)

        if fitargs()['config'] != 'config':
            print "*** Using config file path:", fitcfg(
            )['cmd-args-list']['config']

        if cfg_obj.get_path() is None:

            default_composition = [
                'rackhd_default.json', 'credentials_default.json',
                'install_default.json', 'cit_default.json'
            ]

            # config file composition
            cfg_obj.add_from_file_list(default_composition)

            # stack overlay configuration
            apply_stack_config()

            # apply any additional configurations specified on command line
            if fitcfg()['cmd-args-list']['extra']:
                cfg_obj.add_from_file_list(
                    fitcfg()['cmd-args-list']['extra'].split(','))

            # add significant environment variables
            cfg_obj.add_from_dict({
                'env': {
                    'HOME': os.environ['HOME'],
                    'PATH': os.environ['PATH']
                }
            })

            add_globals()

            # generate the configuration file
            cfg_obj.generate()
            print "*** Using config file: {0}".format(cfg_obj.get_path())
Ejemplo n.º 10
0
def fitcfg():
    """
    returns the configuration dictionary
    :return: dictionary
    """
    return mkcfg().get()
Ejemplo n.º 11
0
def compose_config(use_sysargs=False):
    """
    creates a configuration based on
    :param use_sysargs: set to true if sys.argv is to be processed.
    :return: None
    """
    # create configuration object
    cfg_obj = mkcfg()
    if cfg_obj.config_is_loaded():
        # a previously generated configuration has been loaded
        # restore previously setup globals
        update_globals()
    else:
        # create new configuration
        #   * add cmd-args-list section
        #   * add the default config json file composition.
        #   * add stack overlay
        #   * save off environment
        #   * generate a few globals
        #   * save (generate) the configuration to a file
        args_list = {}
        if use_sysargs:
            # Args from command line, pass -config option to create
            args_list['cmd-args-list'] = mkargs()
            config = args_list['cmd-args-list']['config']
            cfg_obj.create(config)
        else:
            # Args from default set
            no_args = {}
            args_list['cmd-args-list'] = mkargs(no_args)
            cfg_obj.create()

        # add the 'cmd-args-list' section
        cfg_obj.add_from_dict(args_list)

        if fitargs()['config'] != 'config':
            print "*** Using config file path:", fitcfg()['cmd-args-list']['config']

        if cfg_obj.get_path() is None:

            default_composition = ['rackhd_default.json',
                                   'credentials_default.json',
                                   'install_default.json',
                                   'cit_default.json']

            # config file composition
            cfg_obj.add_from_file_list(default_composition)

            # stack overlay configuration
            apply_stack_config()

            # apply any additional configurations specified on command line
            if fitcfg()['cmd-args-list']['extra']:
                cfg_obj.add_from_file_list(fitcfg()['cmd-args-list']['extra'].split(','))

            # add significant environment variables
            cfg_obj.add_from_dict({
                'env': {
                    'HOME': os.environ['HOME'],
                    'PATH': os.environ['PATH']
                }
            })

            add_globals()

            # generate the configuration file
            cfg_obj.generate()
            print "*** Using config file: {0}".format(cfg_obj.get_path())