def get_process_args(self): task_path = self.scenario_helper.task_path options = self.scenario_helper.options prox_args = options['prox_args'] prox_path = options['prox_path'] config_path = options['prox_config'] config_file = os.path.basename(config_path) config_path = find_relative_file(config_path, task_path) try: prox_file_config_path = options['prox_files'] prox_file_file = os.path.basename(prox_file_config_path) prox_file_config_path = find_relative_file(prox_file_config_path, task_path) self.remote_prox_file_name = self.copy_to_target( prox_file_config_path, prox_file_file) self.additional_file = True except: self.additional_file = False self.prox_config_dict = self.generate_prox_config_file(config_path) remote_path = self.upload_prox_config(config_file, self.prox_config_dict) return prox_args, prox_path, remote_path
def _start_vnf(self): yang_model_path = find_relative_file( self.scenario_helper.options['rules'], self.scenario_helper.task_path) yang_model = YangModel(yang_model_path) self.vfw_rules = yang_model.get_rules() super(FWApproxVnf, self)._start_vnf()
def run_traffic(self, traffic_profile): min_tol = self.rfc_helper.tolerance_low max_tol = self.rfc_helper.tolerance_high self._build_ports() self._connect() # we don't know client_file_name until runtime as instantiate client_file_name = \ find_relative_file(self.scenario_helper.scenario_cfg['ixia_profile'], self.scenario_helper.scenario_cfg["task_path"]) self.client.ix_load_config(client_file_name) time.sleep(WAIT_AFTER_CFG_LOAD) self.client.ix_assign_ports() mac = {} for index, interface in enumerate(self.vnfd_helper.interfaces, 1): virt_intf = interface["virtual-interface"] mac.update({ "src_mac_{}".format(index): virt_intf["local_mac"], "dst_mac_{}".format(index): virt_intf["dst_mac"], }) samples = {} ixia_file = find_relative_file( "ixia_traffic.cfg", self.scenario_helper.scenario_cfg["task_path"]) # Generate ixia traffic config... while not self._terminated.value: traffic_profile.execute(self, self.client, mac, ixia_file) self.client_started.value = 1 time.sleep(WAIT_FOR_TRAFFIC) self.client.ix_stop_traffic() samples = self.generate_samples() self._queue.put(samples) status, samples = traffic_profile.get_drop_percentage( self, samples, min_tol, max_tol, self.client, mac, ixia_file) current = samples['CurrentDropPercentage'] if min_tol <= current <= max_tol or status == 'Completed': self._terminated.value = 1 self.client.ix_stop_traffic() self._queue.put(samples)
def build_config_file(self): task_path = self.scenario_helper.task_path options = self.scenario_helper.options config_path = options['prox_config'] config_file = os.path.basename(config_path) config_path = find_relative_file(config_path, task_path) self.additional_files = {} prox_files = options.get('prox_files', []) if isinstance(prox_files, six.string_types): prox_files = [prox_files] for key_prox_file in prox_files: base_prox_file = os.path.basename(key_prox_file) key_prox_path = find_relative_file(key_prox_file, task_path) remote_prox_file = self.copy_to_target(key_prox_path, base_prox_file) self.additional_files[base_prox_file] = remote_prox_file self._prox_config_data = self.generate_prox_config_file(config_path) # copy config to queue so we can read it from traffic_runner process self.config_queue.put(self._prox_config_data) self.remote_path = self.upload_prox_config(config_file, self._prox_config_data)
def setup(self): # TODO: fixupt scenario_helper to hanlde ixia self.resource_file_name = \ find_relative_file(self.scenario_helper.scenario_cfg['ixia_profile'], self.scenario_helper.scenario_cfg["task_path"]) makedirs(self.RESULTS_MOUNT) cmd = MOUNT_CMD.format(self.vnfd_helper.mgmt_interface, self) LOG.debug(cmd) if not os.path.ismount(self.RESULTS_MOUNT): call(cmd, shell=True) shutil.rmtree(self.RESULTS_MOUNT, ignore_errors=True) makedirs(self.RESULTS_MOUNT) shutil.copy(self.resource_file_name, self.RESULTS_MOUNT)
def build_config(self): vnf_cfg = self.scenario_helper.vnf_cfg task_path = self.scenario_helper.task_path lb_count = vnf_cfg.get('lb_count', 3) lb_config = vnf_cfg.get('lb_config', 'SW') worker_config = vnf_cfg.get('worker_config', '1C/1T') worker_threads = vnf_cfg.get('worker_threads', 3) traffic_type = self.scenario_helper.all_options.get('traffic_type', 4) traffic_options = { 'traffic_type': traffic_type, 'pkt_type': 'ipv%s' % traffic_type, 'vnf_type': self.VNF_TYPE, } config_tpl_cfg = find_relative_file(self.DEFAULT_CONFIG_TPL_CFG, task_path) config_basename = posixpath.basename(self.CFG_CONFIG) script_basename = posixpath.basename(self.CFG_SCRIPT) multiport = MultiPortConfig(self.scenario_helper.topology, config_tpl_cfg, config_basename, self.vnfd_helper.interfaces, self.VNF_TYPE, lb_count, worker_threads, worker_config, lb_config, self.socket) multiport.generate_config() with open(self.CFG_CONFIG) as handle: new_config = handle.read() new_config = self._update_traffic_type(new_config, traffic_options) new_config = self._update_packet_type(new_config, traffic_options) self.ssh_helper.upload_config_file(config_basename, new_config) self.ssh_helper.upload_config_file(script_basename, multiport.generate_script(self.vnfd_helper)) self.all_ports = multiport.port_pair_list LOG.info("Provision and start the %s", self.APP_NAME) self._build_pipeline_kwargs() return self.PIPELINE_COMMAND.format(**self.pipeline_kwargs)
def build_config_file(self): task_path = self.scenario_helper.task_path options = self.scenario_helper.options config_path = options['prox_config'] config_file = os.path.basename(config_path) config_path = find_relative_file(config_path, task_path) self.additional_files = {} prox_files = options.get('prox_files', []) if isinstance(prox_files, six.string_types): prox_files = [prox_files] for key_prox_file in prox_files: base_prox_file = os.path.basename(key_prox_file) remote_prox_file = self.copy_to_target(key_prox_file, base_prox_file) self.additional_files[base_prox_file] = remote_prox_file self.prox_config_dict = self.generate_prox_config_file(config_path) self.remote_path = self.upload_prox_config(config_file, self.prox_config_dict)
def run_traffic(self, traffic_profile): if self._terminated.value: return min_tol = self.rfc_helper.tolerance_low max_tol = self.rfc_helper.tolerance_high default = "00:00:00:00:00:00" self._build_ports() # we don't know client_file_name until runtime as instantiate client_file_name = \ find_relative_file(self.scenario_helper.scenario_cfg['ixia_profile'], self.scenario_helper.scenario_cfg["task_path"]) self.client.ix_load_config(client_file_name) time.sleep(WAIT_AFTER_CFG_LOAD) self.client.ix_assign_ports() mac = {} for port_name in self.vnfd_helper.port_pairs.all_ports: intf = self.vnfd_helper.find_interface(name=port_name) virt_intf = intf["virtual-interface"] # we only know static traffic id by reading the json # this is used by _get_ixia_trafficrofile port_num = self.vnfd_helper.port_num(intf) mac["src_mac_{}".format(port_num)] = virt_intf.get( "local_mac", default) mac["dst_mac_{}".format(port_num)] = virt_intf.get( "dst_mac", default) samples = {} # Generate ixia traffic config... try: while not self._terminated.value: traffic_profile.execute_traffic(self, self.client, mac) self.client_started.value = 1 time.sleep(WAIT_FOR_TRAFFIC) self.client.ix_stop_traffic() samples = self.generate_samples(traffic_profile.ports) self._queue.put(samples) status, samples = traffic_profile.get_drop_percentage( self, samples, min_tol, max_tol, self.client, mac) current = samples['CurrentDropPercentage'] if min_tol <= current <= max_tol or status == 'Completed': self._terminated.value = 1 self.client.ix_stop_traffic() self._queue.put(samples) if not self.rfc_helper.is_done(): self._terminated.value = 1 return traffic_profile.execute_traffic(self, self.client, mac) for _ in range(5): time.sleep(self.LATENCY_TIME_SLEEP) self.client.ix_stop_traffic() samples = self.generate_samples(traffic_profile.ports, 'latency', {}) self._queue.put(samples) traffic_profile.start_ixia_latency(self, self.client, mac) if self._terminated.value: break self.client.ix_stop_traffic() except Exception: # pylint: disable=broad-except LOG.exception("Run Traffic terminated") self._terminated.value = 1
def run_traffic(self, traffic_profile): if self._terminated.value: return min_tol = self.rfc_helper.tolerance_low max_tol = self.rfc_helper.tolerance_high default = "00:00:00:00:00:00" self._build_ports() # we don't know client_file_name until runtime as instantiate client_file_name = \ find_relative_file(self.scenario_helper.scenario_cfg['ixia_profile'], self.scenario_helper.scenario_cfg["task_path"]) self.client.ix_load_config(client_file_name) time.sleep(WAIT_AFTER_CFG_LOAD) self.client.ix_assign_ports() mac = {} # TODO: shouldn't this index map to port number we used to generate the profile for index, interface in enumerate(self.vnfd_helper.interfaces, 1): virt_intf = interface["virtual-interface"] mac.update({ "src_mac_{}".format(index): virt_intf.get("local_mac", default), "dst_mac_{}".format(index): virt_intf.get("dst_mac", default), }) samples = {} ixia_file = find_relative_file( "ixia_traffic.cfg", self.scenario_helper.scenario_cfg["task_path"]) # Generate ixia traffic config... try: while not self._terminated.value: traffic_profile.execute(self, self.client, mac, ixia_file) self.client_started.value = 1 time.sleep(WAIT_FOR_TRAFFIC) self.client.ix_stop_traffic() samples = self.generate_samples() self._queue.put(samples) status, samples = traffic_profile.get_drop_percentage( self, samples, min_tol, max_tol, self.client, mac, ixia_file) current = samples['CurrentDropPercentage'] if min_tol <= current <= max_tol or status == 'Completed': self._terminated.value = 1 self.client.ix_stop_traffic() self._queue.put(samples) except Exception: LOG.info("Run Traffic terminated") pass if not self.rfc_helper.is_done(): self._terminated.value = 1 return traffic_profile.execute_traffic(self, self.client, mac, ixia_file) for _ in range(5): time.sleep(self.LATENCY_TIME_SLEEP) self.client.ix_stop_traffic() samples = self.generate_samples(traffic_profile.ports, 'latency', {}) self._queue.put(samples) traffic_profile.start_ixia_latency(self, self.client, mac, ixia_file) if self._terminated.value: break self.client.ix_stop_traffic() self._terminated.value = 1
def run_traffic(self, traffic_profile): if self._terminated.value: return min_tol = self.rfc_helper.tolerance_low max_tol = self.rfc_helper.tolerance_high default = "00:00:00:00:00:00" self._build_ports() # we don't know client_file_name until runtime as instantiate client_file_name = \ find_relative_file(self.scenario_helper.scenario_cfg['ixia_profile'], self.scenario_helper.scenario_cfg["task_path"]) self.client.ix_load_config(client_file_name) time.sleep(WAIT_AFTER_CFG_LOAD) self.client.ix_assign_ports() ixia_file = find_relative_file("ixia_traffic.cfg", self.scenario_helper.scenario_cfg["task_path"]) static_traffic = {} with open(ixia_file) as stream: try: static_traffic = json.load(stream) except Exception: LOG.exception("") mac = {} for vld_id, traffic in static_traffic.items(): intfs = self.vnfd_helper.port_pairs.networks.get(vld_id, []) interface = next(iter(intfs), None) if interface: virt_intf = self.vnfd_helper.find_interface(name=interface)["virtual-interface"] # we only know static traffic id by reading the json # this is used by _get_ixia_traffic_profile mac["src_mac_{}".format(traffic["id"])] = virt_intf.get("local_mac", default) mac["dst_mac_{}".format(traffic["id"])] = virt_intf.get("dst_mac", default) samples = {} # Generate ixia traffic config... try: while not self._terminated.value: traffic_profile.execute_traffic(self, self.client, mac, ixia_file) self.client_started.value = 1 time.sleep(WAIT_FOR_TRAFFIC) self.client.ix_stop_traffic() samples = self.generate_samples(traffic_profile.ports) self._queue.put(samples) status, samples = traffic_profile.get_drop_percentage(self, samples, min_tol, max_tol, self.client, mac, ixia_file) current = samples['CurrentDropPercentage'] if min_tol <= current <= max_tol or status == 'Completed': self._terminated.value = 1 self.client.ix_stop_traffic() self._queue.put(samples) except Exception: LOG.exception("Run Traffic terminated") if not self.rfc_helper.is_done(): self._terminated.value = 1 return traffic_profile.execute_traffic(self, self.client, mac, ixia_file) for _ in range(5): time.sleep(self.LATENCY_TIME_SLEEP) self.client.ix_stop_traffic() samples = self.generate_samples(traffic_profile.ports, 'latency', {}) self._queue.put(samples) traffic_profile.start_ixia_latency(self, self.client, mac, ixia_file) if self._terminated.value: break self.client.ix_stop_traffic() self._terminated.value = 1