Пример #1
0
 def initialize(self, config_file):
     """
     Initialize the plugin
     """
     config.load(config_file)
     self._directory = openstack.get_directory(
         config, openstack.SERVICE_CATEGORY.OPENSTACK)
Пример #2
0
    def initialize(self, config_file):
        """
        Initialize the plugin
        """
        config.load(config_file)
        self._directory = openstack.get_directory(
            config, openstack.SERVICE_CATEGORY.PLATFORM)
        self._openstack_directory = openstack.get_directory(
            config, openstack.SERVICE_CATEGORY.OPENSTACK)

        self._rest_api_server = rest_api.rest_api_get_server(
            config.CONF['guest-rest-api']['host'],
            config.CONF['guest-rest-api']['port'])

        self._rest_api_server.add_handler(
            'GET', '/nfvi-plugins/v1/hosts*',
            self.host_services_rest_api_get_handler)

        self._rest_api_server.add_handler(
            'GET', '/nfvi-plugins/v1/instances*',
            self.guest_services_rest_api_get_handler)

        self._rest_api_server.add_handler(
            'PATCH', '/nfvi-plugins/v1/instances*',
            self.guest_services_rest_api_patch_handler)
Пример #3
0
    def __init__(self, webserver_config, nfvi_config, vim_api_config):
        global _webserver_src_dir, _directory, _vim_api_ip

        _webserver_src_dir = webserver_config['source_dir']

        ip = webserver_config['host']
        port = int(webserver_config['port'])
        if ':' in ip:
            # Configure server class to use IPv6
            ThreadedHTTPServer.address_family = socket.AF_INET6
        self.server = ThreadedHTTPServer((ip, port), HTTPRequestHandler)
        self.server_thread = None

        config.load(nfvi_config['config_file'])
        _directory = openstack.get_directory(config)
        _vim_api_ip = vim_api_config['host']
        if ':' in _vim_api_ip:
            # Wrap IPv6 address for use in URLs
            _vim_api_ip = '[' + _vim_api_ip + ']'
Пример #4
0
def process_main():
    """
    Test - Process Main
    """
    try:
        want_teardown = False
        root_dir = os.path.dirname(__file__)
        data_dir = root_dir + '/data'
        loads_dir = data_dir + '/loads'
        setup_dir = data_dir + '/setup'
        tests_dir = data_dir + '/tests'
        j2_env = Environment(loader=FileSystemLoader([setup_dir, tests_dir]),
                             trim_blocks=True)
        j2_env.globals['uuid4'] = uuid.uuid4

        signal.signal(signal.SIGINT, process_signal_handler)

        arg_parser = argparse.ArgumentParser()
        arg_parser.add_argument('-c', '--config', help='configuration file')
        arg_parser.add_argument('-d', '--data', help='data file')
        arg_parser.add_argument('-s', '--setup', help='setup file')
        arg_parser.add_argument('-t', '--tests', help='tests file')
        arg_parser.add_argument('-r', '--repeat', help='repeat tests x times')
        arg_parser.add_argument('-f',
                                '--forever',
                                help='loop forever doing tests',
                                action='store_true')
        arg_parser.add_argument('-w',
                                '--wipe',
                                help='cleanup setup',
                                action='store_true')

        args = arg_parser.parse_args()

        if args.config:
            config.load(args.config)
        else:
            print("No configuration given.")
            sys.exit(1)

        if args.data:
            data_fill = yaml.load(
                open(data_dir + '/data/' + args.data + '.yaml'))
        else:
            print("No data file given.")
            sys.exit(1)

        if args.setup:
            setup_template = j2_env.get_template(args.setup + '.template')
            setup_yaml = setup_template.render(data_fill)
            setup_data = yaml.load(setup_yaml)
        else:
            print("No setup file given.")
            sys.exit(1)

        if args.tests:
            tests_template = j2_env.get_template(args.tests + '.template')
            tests_yaml = tests_template.render(data_fill)
            test_data = yaml.load(tests_yaml)
        else:
            print("No tests given.")
            sys.exit(1)

        if args.repeat:
            repeat = int(args.repeat)
            max_iteration_str = "max-iterations=%s" % repeat
        else:
            repeat = 0
            max_iteration_str = "single-execution"

        if args.forever:
            forever = True
            max_iteration_str = "forever"
        else:
            forever = False

        if args.wipe:
            want_teardown = True

        process_initialize()

        if want_teardown:
            setup_str = "===== Cleanup Previous Configuration"
            header_str = "%s %s" % (setup_str, '=' * (140 - len(setup_str)))
            footer_str = "%s" % '=' * 141

            sys.stdout.write("%s\n" % header_str)
            if not process_do_teardown(setup_data):
                print("Cleanup failed.")
                sys.exit(1)

            sys.stdout.write("%s\n" % footer_str)

            want_teardown = True
            time.sleep(60)

        setup_str = "===== Setup"
        header_str = "%s %s" % (setup_str, '=' * (140 - len(setup_str)))
        footer_str = "%s" % '=' * 141

        sys.stdout.write("%s\n" % header_str)
        if not process_do_setup(loads_dir, setup_data):
            print("Setup failed.")
            sys.exit(1)

        sys.stdout.write("%s\n" % footer_str)

        loop_i = 0
        while True:
            iteration_str = "===== Test Iteration %s (%s)" % (
                loop_i, max_iteration_str)
            header_str = "%s %s" % (iteration_str, '=' *
                                    (140 - len(iteration_str)))
            footer_str = "%s" % '=' * 141

            sys.stdout.write("%s\n" % header_str)
            process_do_tests(test_data)
            sys.stdout.write("%s\n" % footer_str)
            loop_i += 1

            if not forever:
                if loop_i >= repeat:
                    break

        if want_teardown:
            setup_str = "===== Teardown"
            header_str = "%s %s" % (setup_str, '=' * (140 - len(setup_str)))
            footer_str = "%s" % '=' * 141

            sys.stdout.write("%s\n" % header_str)
            if not process_do_teardown(setup_data):
                print("Teardown failed.")
                sys.exit(1)

            sys.stdout.write("%s\n" % footer_str)

    except KeyboardInterrupt:
        print("Keyboard Interrupt received.")

    except Exception as e:
        print("Exception: %s" % e)
        traceback.print_exc()
        sys.exit(1)

    finally:
        process_finalize()
Пример #5
0
 def initialize(self, config_file):
     """
     Initialize the plugin
     """
     config.load(config_file)
     self._directory = openstack.get_directory(config)