+ special_ow_string = ''
+ if override_epa or override_nonepa or override_paravirt:
+ # If override for EPA, non-EPA or paravirt is required, get the descriptor data
+ descriptor_data = None
+ if mime_type in ['application/yaml', 'text/plain', 'application/json']:
+ with open(filename) as df:
+ descriptor_data = df.read()
+ elif mime_type in ['application/gzip', 'application/x-gzip']:
+ tar_object = tarfile.open(filename, "r:gz")
+ descriptor_list = []
+ for member in tar_object:
+ if member.isreg():
+ if '/' not in os.path.dirname(member.name) and member.name.endswith('.yaml'):
+ descriptor_list.append(member.name)
+ if len(descriptor_list) > 1:
+ raise ClientException('Found more than one potential descriptor in the tar.gz file')
+ elif len(descriptor_list) == 0:
+ raise ClientException('No descriptor was found in the tar.gz file')
+ with tar_object.extractfile(descriptor_list[0]) as df:
+ descriptor_data = df.read()
+ tar_object.close()
+ if not descriptor_data:
+ raise ClientException('Descriptor could not be read')
+ desc_type, vnfd = validation_im.yaml_validation(self, descriptor_data)
+ validation_im.pyangbind_validation(self, desc_type, vnfd)
+ vnfd = yaml.safe_load(descriptor_data)
+ vdu_list = []
+ for k in vnfd:
+ # Get only the first descriptor in case there are many in the yaml file
+ # k can be vnfd:vnfd-catalog or vnfd-catalog. This check is skipped
+ first_vnfd = vnfd[k]['vnfd'][0]
+ vdu_list = first_vnfd.get('vdu',[])
+ break;
+ for vdu_number, vdu in enumerate(vdu_list):
+ if override_epa:
+ guest_epa = {}
+ guest_epa["mempage-size"] = "LARGE"
+ guest_epa["cpu-pinning-policy"] = "DEDICATED"
+ guest_epa["cpu-thread-pinning-policy"] = "PREFER"
+ guest_epa["numa-node-policy"] = {}
+ guest_epa["numa-node-policy"]["node-cnt"] = 1
+ guest_epa["numa-node-policy"]["mem-policy"] = "STRICT"
+ #guest_epa["numa-node-policy"]["node"] = []
+ #guest_epa["numa-node-policy"]["node"].append({"id": "0", "paired-threads": {"num-paired-threads": 1} })
+ special_ow_string = "{}vdu.{}.guest-epa={};".format(special_ow_string,vdu_number,quote(yaml.safe_dump(guest_epa)))
+ headers['Query-String-Format'] = 'yaml'
+ if override_nonepa:
+ special_ow_string = "{}vdu.{}.guest-epa=;".format(special_ow_string,vdu_number)
+ if override_paravirt:
+ for iface_number in range(len(vdu['interface'])):
+ special_ow_string = "{}vdu.{}.interface.{}.virtual-interface.type=PARAVIRT;".format(
+ special_ow_string,vdu_number,iface_number)
+ special_ow_string = special_ow_string.rstrip(";")
+