Example #1
0
    def __init__(self, filepath):
        if not isinstance(filepath, Path):
            filepath = Path(None, filepath)

        self._filepath = filepath.resolve()
        self._mapping = {}
        self.load_mapping_file(self._filepath)
Example #2
0
    def __init__(self, filepath):
        if not isinstance(filepath, Path):
            filepath = Path(None, filepath)

        self._filepath = filepath.resolve()
        self._mapping = {}
        self.load_mapping_file(self._filepath)
Example #3
0
    def connect_PerfRepo(self, mapping_file, url=None, username=None, password=None, max_retries=3):
        if not self._perf_repo_api.connected():
            if url is None:
                url = lnst_config.get_option("perfrepo", "url")
            if username is None:
                username = lnst_config.get_option("perfrepo", "username")
            if password is None:
                password = lnst_config.get_option("perfrepo", "password")

            if not url:
                logging.warn("No PerfRepo URL specified in config file")
            if not username:
                logging.warn("No PerfRepo username specified in config file")
            if not password:
                logging.warn("No PerfRepo password specified in config file")
            if url and username and password:
                self._perf_repo_api.connect(url, username, password, max_retries)

            root = Path(None, self._ctl._recipe_path).get_root()
            path = Path(root, mapping_file)
            self._perf_repo_api.load_mapping(path)

            if not self._perf_repo_api.connected():
                if PerfRepoRESTAPI is None:
                    logging.warn("Python PerfRepo library not found.")
                logging.warn("Connection to PerfRepo incomplete, further "\
                             "PerfRepo commands will be ignored.")
        return self._perf_repo_api
Example #4
0
    def _prepare_tasks(self):
        self._tasks = []
        for task_data in self._recipe["tasks"]:
            task = {}
            task["quit_on_fail"] = False
            if "quit_on_fail" in task_data:
                task["quit_on_fail"] = bool_it(task_data["quit_on_fail"])

            if "module_dir" in task_data:
                task["module_dir"] = task_data["module_dir"]

            if "tools_dir" in task_data:
                task["tools_dir"] = task_data["tools_dir"]

            if "python" in task_data:
                root = Path(None, self._recipe_path).get_root()
                path = Path(root, task_data["python"])

                task["python"] = path
                if not path.exists():
                    msg = "Task file '%s' not found." % path.to_str()
                    raise RecipeError(msg, task_data)

                self._tasks.append(task)
                continue

            task["commands"] = task_data["commands"]
            task["skeleton"] = []
            for cmd_data in task["commands"]:
                cmd = {"type": cmd_data["type"]}

                if "host" in cmd_data:
                    cmd["host"] = cmd_data["host"]
                    if cmd["host"] not in self._machines:
                        msg = "Invalid host id '%s'." % cmd["host"]
                        raise RecipeError(msg, cmd_data)

                if cmd["type"] in ["test", "exec"]:
                    if "bg_id" in cmd_data:
                        cmd["bg_id"] = cmd_data["bg_id"]
                elif cmd["type"] in ["wait", "intr", "kill"]:
                    cmd["proc_id"] = cmd_data["bg_id"]

                task["skeleton"].append(cmd)

            if self._check_task(task):
                raise RecipeError("Incorrect command sequence.", task_data)

            self._tasks.append(task)
Example #5
0
    def _prepare_tasks(self):
        self._tasks = []
        for task_data in self._recipe["tasks"]:
            task = {}
            task["quit_on_fail"] = False
            if "quit_on_fail" in task_data:
                task["quit_on_fail"] = bool_it(task_data["quit_on_fail"])

            if "module_dir" in task_data:
                task["module_dir"] = task_data["module_dir"]

            if "tools_dir" in task_data:
                task["tools_dir"] = task_data["tools_dir"]

            if "python" in task_data:
                root = Path(None, self._recipe_path).get_root()
                path = Path(root, task_data["python"])

                task["python"] = path
                if not path.exists():
                    msg = "Task file '%s' not found." % path
                    raise RecipeError(msg, task_data)

                self._tasks.append(task)
                continue

            task["commands"] = task_data["commands"]
            task["skeleton"] = []
            for cmd_data in task["commands"]:
                cmd = {"type": cmd_data["type"]}

                if "host" in cmd_data:
                    cmd["host"] = cmd_data["host"]
                    if cmd["host"] not in self._machines:
                        msg = "Invalid host id '%s'." % cmd["host"]
                        raise RecipeError(msg, cmd_data)

                if cmd["type"] in ["test", "exec"]:
                    if "bg_id" in cmd_data:
                        cmd["bg_id"] = cmd_data["bg_id"]
                elif cmd["type"] in ["wait", "intr", "kill"]:
                    cmd["proc_id"] = cmd_data["bg_id"]

                task["skeleton"].append(cmd)

            if self._check_task(task):
                raise RecipeError("Incorrect command sequence.", task_data)

            self._tasks.append(task)
Example #6
0
    def connect_PerfRepo(self, max_retries=3):
        if not self.connected():
            #TODO: store credentials in config or not
            #if self._url is None:
            #    self._url = lnst_config.get_option("perfrepo", "url")
            #if self._username is None:
            #    self._username = lnst_config.get_option("perfrepo", "username")
            #if self._password is None:
            #    self._password = lnst_config.get_option("perfrepo", "password")

            if not self._url:
                logging.warn("No PerfRepo URL specified in config file")
            if not self._username:
                logging.warn("No PerfRepo username specified in config file")
            if not self._password:
                logging.warn("No PerfRepo password specified in config file")
            if self._url and self._username and self._password:
                self.connect(self._url, self._username, self._password, max_retries)

            path = Path(None, self._mapping_file_path)
            self.load_mapping(path)

            if not self.connected():
                if PerfRepoRESTAPI is None:
                    logging.warn("Python PerfRepo library not found.")
                logging.warn("Connection to PerfRepo incomplete, further "\
                             "PerfRepo commands will be ignored.")
Example #7
0
    def __init__(self,
                 recipe_path,
                 log_ctl,
                 res_serializer=None,
                 pool_checks=True,
                 packet_capture=False,
                 defined_aliases=None,
                 overriden_aliases=None,
                 reduce_sync=False,
                 restrict_pools=[]):
        self._res_serializer = res_serializer
        self._remote_capture_files = {}
        self._log_ctl = log_ctl
        self._recipe_path = Path(None, recipe_path).abs_path()
        self._msg_dispatcher = MessageDispatcher(log_ctl)
        self._packet_capture = packet_capture
        self._reduce_sync = reduce_sync
        self._parser = RecipeParser(recipe_path)

        self.remove_saved_machine_config()

        self._machines = {}
        self._network_bridges = {}
        self._tasks = []

        mac_pool_range = lnst_config.get_option('environment',
                                                'mac_pool_range')
        self._mac_pool = MacPool(mac_pool_range[0], mac_pool_range[1])

        self._parser.set_machines(self._machines)
        self._parser.set_aliases(defined_aliases, overriden_aliases)
        self._recipe = self._parser.parse()

        conf_pools = lnst_config.get_pools()
        pools = {}
        if len(restrict_pools) > 0:
            for pool_name in restrict_pools:
                if pool_name in conf_pools:
                    pools[pool_name] = conf_pools[pool_name]
                elif len(restrict_pools) == 1 and os.path.isdir(pool_name):
                    pools = {"cmd_line_pool": pool_name}
                else:
                    raise NetTestError("Pool %s does not exist!" % pool_name)
        else:
            pools = conf_pools

        sp = SlavePool(pools, pool_checks)
        self._slave_pool = sp

        mreq = self._get_machine_requirements()
        sp.set_machine_requirements(mreq)

        modules_dirs = lnst_config.get_option('environment', 'module_dirs')
        tools_dirs = lnst_config.get_option('environment', 'tool_dirs')

        self._resource_table = {}
        self._resource_table["module"] = self._load_test_modules(modules_dirs)
        self._resource_table["tools"] = self._load_test_tools(tools_dirs)
Example #8
0
    def connect_PerfRepo(self, mapping_file, url=None, username=None, password=None):
        if not self._perf_repo_api.connected():
            if url is None:
                url = lnst_config.get_option("perfrepo", "url")
            if username is None:
                username = lnst_config.get_option("perfrepo", "username")
            if password is None:
                password = lnst_config.get_option("perfrepo", "password")
            self._perf_repo_api.connect(url, username, password)

            root = Path(None, self._ctl._recipe_path).get_root()
            path = Path(root, mapping_file)
            self._perf_repo_api.load_mapping(path)

            if not self._perf_repo_api.connected():
                logging.warn("Connection to PerfRepo incomplete, further "\
                             "PerfRepo commands will be ignored.")
        return self._perf_repo_api
Example #9
0
    def __init__(self,
                 recipe_path,
                 log_ctl,
                 res_serializer=None,
                 pool_checks=True,
                 packet_capture=False,
                 defined_aliases=None,
                 overriden_aliases=None,
                 reduce_sync=False):
        self._res_serializer = res_serializer
        self._remote_capture_files = {}
        self._log_ctl = log_ctl
        self._recipe_path = Path(None, recipe_path).abs_path()
        self._msg_dispatcher = MessageDispatcher(log_ctl)
        self._packet_capture = packet_capture
        self._reduce_sync = reduce_sync
        self._parser = RecipeParser(recipe_path)

        self.remove_saved_machine_config()

        sp = SlavePool(lnst_config.get_option('environment', 'pool_dirs'),
                       pool_checks)
        self._slave_pool = sp

        self._machines = {}
        self._network_bridges = {}
        self._tasks = []

        mac_pool_range = lnst_config.get_option('environment',
                                                'mac_pool_range')
        self._mac_pool = MacPool(mac_pool_range[0], mac_pool_range[1])

        self._parser.set_machines(self._machines)
        self._parser.set_aliases(defined_aliases, overriden_aliases)
        self._recipe = self._parser.parse()

        mreq = self._get_machine_requirements()
        sp.set_machine_requirements(mreq)

        modules_dirs = lnst_config.get_option('environment', 'module_dirs')
        tools_dirs = lnst_config.get_option('environment', 'tool_dirs')

        self._resource_table = {}
        self._resource_table["module"] = self._load_test_modules(modules_dirs)
        self._resource_table["tools"] = self._load_test_tools(tools_dirs)
Example #10
0
 def __init__(self, recipe_path):
     recipe_path = Path(None, recipe_path).abs_path()
     super(RecipeParser, self).__init__("schema-recipe.rng", recipe_path)