Пример #1
0
 def _collect_vnf_commands(self, ec):
     """
     Get the start/stop commands for all VNFs.
     Returns: {"vnf0": "./start.sh"}, {"vnf0": "./stop.sh"}
     """
     vnf_cmd_start_dict = dict()
     vnf_cmd_stop_dict = dict()
     for k, v in ec.parameter.items():
         if MP_IN_KEY in k or MP_OUT_KEY in k:
             continue  # skip MPs
         kd = parse_ec_parameter_key(k)
         if kd.get("type") != "function":
             continue  # skip non functions
         if kd.get("parameter_name") == "cmd_start":
             # add to dict
             vnf_cmd_start_dict[self.get_cname_by_parameter(
                 ec, kd.get("function_name"), kd.get("unit_name"))] = v
         elif kd.get("parameter_name") == "cmd_stop":
             # add to dict
             vnf_cmd_stop_dict[self.get_cname_by_parameter(
                 ec, kd.get("function_name"), kd.get("unit_name"))] = v
     LOG.debug(
         "Collected VNF start commands: {}".format(vnf_cmd_start_dict))
     LOG.debug("Collected VNF stop commands: {}".format(vnf_cmd_stop_dict))
     return vnf_cmd_start_dict, vnf_cmd_stop_dict
Пример #2
0
 def _apply_parameters_to_vnfds(self, ec, vnfd):
     applied = False
     vnfd_uid = "{}.{}.{}".format(
         vnfd.get("vendor"), vnfd.get("name"), vnfd.get("version"))
     # iterate over all parameters to be applied
     for pname, pvalue in ec.parameter.items():
         ep_uid = parse_ec_parameter_key(pname).get("function_name")
         unit_name = parse_ec_parameter_key(pname).get("unit_name")
         field_name = parse_ec_parameter_key(pname).get("parameter_name")
         if ep_uid not in vnfd_uid:
             continue  # not the right VNFD -> skip
         # parameter should be applied to given VNF
         self._apply_parameter_to_vnfd(field_name, unit_name, pvalue, vnfd)
         applied = True
     if not applied:
         raise BaseException(
             "Couln't find any experiment parameters for VNFD: {}"
             .format(vnfd_uid))
Пример #3
0
 def _configure_vnfd_params(self, vnfd_yaml, output_vnfd_pkg, service_ex,
                            ec_index):
     """
     Update the YAML VNFD contents
     """
     vnfd_yaml['vnfd:vnfd-catalog']['vnfd'][0][
         'name'] = service_ex.experiment_configurations[ec_index].name
     for pname, pvalue in service_ex.experiment_configurations[
             ec_index].parameter.items():
         function_type = parse_ec_parameter_key(pname).get("type")
         vnf_type = parse_ec_parameter_key(pname).get("function_name")
         field_name = parse_ec_parameter_key(pname).get("parameter_name")
         if function_type == "function" and 'mp.' not in vnf_type:
             if field_name == 'cpu_cores':
                 # Single VNFD single VDU for now
                 vnfd_yaml['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0][
                     'vm-flavor']['vcpu-count'] = pvalue
             if field_name == 'mem_max':
                 # Single VNFD single VDU for now
                 vnfd_yaml['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0][
                     'vm-flavor']['memory-mb'] = pvalue