From 4e6cebcf2f15e9c9370d5af6b725629a70ac9b1a Mon Sep 17 00:00:00 2001 From: KIRAN KASHALKAR Date: Sun, 25 Sep 2016 21:16:59 -0400 Subject: [PATCH] Bug 58 fixed. Signed-off-by: KIRAN KASHALKAR --- models/plugins/yang/mano-types.yang | 9 ++-- .../vala/rwcal_openstack/rwcal_openstack.py | 50 +++++++++---------- .../tasklets/rwnsmtasklet/openmano_nsm.py | 36 ++++++------- 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/models/plugins/yang/mano-types.yang b/models/plugins/yang/mano-types.yang index cd5d446d..3c723f4c 100644 --- a/models/plugins/yang/mano-types.yang +++ b/models/plugins/yang/mano-types.yang @@ -1936,9 +1936,12 @@ module mano-types type string; } - leaf-list dns-server { - description "List of DNS Servers associated with IP Profile"; - type inet:ip-address; + list dns-server { + key "address"; + leaf address { + description "List of DNS Servers associated with IP Profile"; + type inet:ip-address; + } } container dhcp-params { diff --git a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py index eecd077b..f0095f1f 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py +++ b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py @@ -1,5 +1,5 @@ -# +# # Copyright 2016 RIFT.IO Inc # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -1296,11 +1296,11 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): except Exception as e: self.log.error("Encountered exceptions during network creation. Exception: %s", str(e)) raise - + kwargs = {'network_id' : network_id, 'dhcp_params': {'enable_dhcp': True}, 'gateway_ip' : None,} - + if link_params.ip_profile_params.has_field('ip_version'): kwargs['ip_version'] = 6 if link_params.ip_profile_params.ip_version == 'ipv6' else 4 else: @@ -1315,7 +1315,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): link_params.ip_profile_params.subnet_prefix_pool, link_params.name) raise NeutronException.NotFound("SubnetPool with name %s not found"%(link_params.ip_profile_params.subnet_prefix_pool)) - + kwargs['subnetpool_id'] = subnet_pool['id'] elif link_params.has_field('subnet'): kwargs['cidr'] = link_params.subnet @@ -1329,17 +1329,17 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): kwargs['dhcp_params']['start_address'] = link_params.ip_profile_params.dhcp_params.start_address if link_params.ip_profile_params.dhcp_params.has_field('count'): kwargs['dhcp_params']['count'] = link_params.ip_profile_params.dhcp_params.count - + if link_params.ip_profile_params.has_field('dns_server'): kwargs['dns_server'] = [] for server in link_params.ip_profile_params.dns_server: - kwargs['dns_server'].append(server) + kwargs['dns_server'].append(server.address) if link_params.ip_profile_params.has_field('gateway_address'): kwargs['gateway_ip'] = link_params.ip_profile_params.gateway_address - + drv.neutron_subnet_create(**kwargs) - + return network_id @@ -1504,8 +1504,8 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('pcie_device'): self.log.debug("Rejecting available flavor because pcie_device not required but available") return False - - + + if required.has_field('mempage_size'): self.log.debug("Matching mempage_size") if available.has_field('mempage_size') == False: @@ -1518,7 +1518,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('mempage_size'): self.log.debug("Rejecting available flavor because mempage_size not required but available") return False - + if required.has_field('cpu_pinning_policy'): self.log.debug("Matching cpu_pinning_policy") if required.cpu_pinning_policy != 'ANY': @@ -1532,7 +1532,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('cpu_pinning_policy'): self.log.debug("Rejecting available flavor because cpu_pinning_policy not required but available") return False - + if required.has_field('cpu_thread_pinning_policy'): self.log.debug("Matching cpu_thread_pinning_policy") if available.has_field('cpu_thread_pinning_policy') == False: @@ -1559,7 +1559,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('trusted_execution'): self.log.debug("Rejecting available flavor because trusted_execution not required but available") return False - + if required.has_field('numa_node_policy'): self.log.debug("Matching numa_node_policy") if available.has_field('numa_node_policy') == False: @@ -1578,7 +1578,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.numa_node_policy.has_field('node_cnt'): self.log.debug("Rejecting available flavor because numa node count not required but available") return False - + if required.numa_node_policy.has_field('mem_policy'): self.log.debug("Matching numa_node_policy mem_policy") if available.numa_node_policy.has_field('mem_policy') == False: @@ -1645,7 +1645,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('cpu_model'): self.log.debug("Rejecting available flavor because cpu_model not required but available") return False - + if required.has_field('cpu_arch'): self.log.debug("Matching CPU architecture") if available.has_field('cpu_arch') == False: @@ -1659,7 +1659,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('cpu_arch'): self.log.debug("Rejecting available flavor because cpu_arch not required but available") return False - + if required.has_field('cpu_vendor'): self.log.debug("Matching CPU vendor") if available.has_field('cpu_vendor') == False: @@ -1686,7 +1686,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('cpu_socket_count'): self.log.debug("Rejecting available flavor because cpu_socket_count not required but available") return False - + if required.has_field('cpu_core_count'): self.log.debug("Matching CPU core count") if available.has_field('cpu_core_count') == False: @@ -1699,7 +1699,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('cpu_core_count'): self.log.debug("Rejecting available flavor because cpu_core_count not required but available") return False - + if required.has_field('cpu_core_thread_count'): self.log.debug("Matching CPU core thread count") if available.has_field('cpu_core_thread_count') == False: @@ -1712,7 +1712,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('cpu_core_thread_count'): self.log.debug("Rejecting available flavor because cpu_core_thread_count not required but available") return False - + if required.has_field('cpu_feature'): self.log.debug("Matching CPU feature list") if available.has_field('cpu_feature') == False: @@ -1726,13 +1726,13 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): elif available.has_field('cpu_feature'): self.log.debug("Rejecting available flavor because cpu_feature not required but available") return False - self.log.info("Successful match for Host EPA attributes") + self.log.info("Successful match for Host EPA attributes") return True def _match_placement_group_inputs(self, required, available): self.log.info("Matching Host aggregate attributes") - + if not required and not available: # Host aggregate not required and not available => success self.log.info("Successful match for Host Aggregate attributes") @@ -1753,7 +1753,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): # - Host aggregate not required but available self.log.debug("Rejecting available flavor because host Aggregate mismatch. Required: %s, Available: %s ", required, available) return False - + def match_epa_params(self, resource_info, request_params): result = self._match_vm_flavor(getattr(request_params, 'vm_flavor'), getattr(resource_info, 'vm_flavor')) @@ -1791,11 +1791,11 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): if result == False: self.log.debug("Host Aggregate mismatched") return False - + return True def _select_resource_flavor(self, account, vdu_init): - """ + """ Select a existing flavor if it matches the request or create new flavor """ flavor = RwcalYang.FlavorInfoItem() @@ -1803,7 +1803,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): epa_types = ['vm_flavor', 'guest_epa', 'host_epa', 'host_aggregate', 'hypervisor_epa', 'vswitch_epa'] epa_dict = {k: v for k, v in vdu_init.as_dict().items() if k in epa_types} flavor.from_dict(epa_dict) - + rc, response = self.do_get_flavor_list(account) if rc != RwTypes.RwStatus.SUCCESS: self.log.error("Get-flavor-info-list operation failed for cloud account: %s", diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py index 94206d57..bdd5b321 100644 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py @@ -1,5 +1,5 @@ -# +# # Copyright 2016 RIFT.IO Inc # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -129,7 +129,7 @@ class VnfrConsoleOperdataDtsHandler(object): vdur_console = RwVnfrYang.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur() vdur_console.id = self._vdur_id vdur_console.console_url = 'none' - + xact_info.respond_xpath(rsp_code=rwdts.XactRspCode.ACK, xpath=self.vnfr_vdu_console_xpath, msg=vdur_console) @@ -137,7 +137,7 @@ class VnfrConsoleOperdataDtsHandler(object): #raise VnfRecordError("Not supported operation %s" % action) self._log.error("Not supported operation %s" % action) xact_info.respond_xpath(rsp_code=rwdts.XactRspCode.ACK) - return + return self._log.debug("Registering for VNFR VDU using xpath: %s", self.vnfr_vdu_console_xpath) @@ -300,14 +300,14 @@ class OpenmanoNsr(object): self._log.debug("Key pair NSD is %s",authorized_key) key_pairs.append(authorized_key.key) - if key_pairs: - cloud_config["key-pairs"] = key_pairs - + if key_pairs: + cloud_config["key-pairs"] = key_pairs + users = list() for user_entry in self._nsr_config_msg.user: self._log.debug("User present is %s",user_entry) user = {} - user["name"] = user_entry.name + user["name"] = user_entry.name user["key-pairs"] = list() for ssh_key in user_entry.key_pair: user["key-pairs"].append(ssh_key.key) @@ -316,7 +316,7 @@ class OpenmanoNsr(object): for user_entry in self._nsd_msg.user: self._log.debug("User present in NSD is %s",user_entry) user = {} - user["name"] = user_entry.name + user["name"] = user_entry.name user["key-pairs"] = list() for ssh_key in user_entry.key_pair: user["key-pairs"].append(ssh_key.key) @@ -327,7 +327,7 @@ class OpenmanoNsr(object): self._log.debug("Cloud config formed is %s",cloud_config) return cloud_config - + @property def openmano_instance_create_yaml(self): @@ -346,7 +346,7 @@ class OpenmanoNsr(object): for vnfr in self._vnfrs: if "om_datacenter" in vnfr.vnfr.vnfr_msg: vnfr_name = vnfr.vnfr.vnfd.name + "__" + str(vnfr.vnfr.vnfr_msg.member_vnf_index_ref) - openmano_instance_create["vnfs"][vnfr_name] = {"datacenter": vnfr.vnfr.vnfr_msg.om_datacenter} + openmano_instance_create["vnfs"][vnfr_name] = {"datacenter": vnfr.vnfr.vnfr_msg.om_datacenter} openmano_instance_create["networks"] = {} for vld_msg in self._nsd_msg.vld: openmano_instance_create["networks"][vld_msg.name] = {} @@ -371,7 +371,7 @@ class OpenmanoNsr(object): if ip_profile_params.has_field('gateway_address'): ip_profile['gateway-address'] = ip_profile_params.gateway_address if ip_profile_params.has_field('dns_server') and len(ip_profile_params.dns_server) > 0: - ip_profile['dns-address'] = ip_profile_params.dns_server[0] + ip_profile['dns-address'] = ip_profile_params.dns_server[0].address if ip_profile_params.has_field('dhcp_params'): ip_profile['dhcp'] = {} ip_profile['dhcp']['enabled'] = ip_profile_params.dhcp_params.enabled @@ -386,11 +386,11 @@ class OpenmanoNsr(object): elif "datacenter" in openmano_instance_create: network["datacenter"] = openmano_instance_create["datacenter"] if network: - openmano_instance_create["networks"][vld_msg.name]["sites"].append(network) + openmano_instance_create["networks"][vld_msg.name]["sites"].append(network) if ip_profile: - openmano_instance_create["networks"][vld_msg.name]['ip-profile'] = ip_profile - - + openmano_instance_create["networks"][vld_msg.name]['ip-profile'] = ip_profile + + return yaml.safe_dump(openmano_instance_create, default_flow_style=False) @asyncio.coroutine @@ -596,11 +596,11 @@ class OpenmanoNsr(object): for vm in vnf_status["vms"]: if vm["uuid"] not in self._vdur_console_handler: - vdur_console_handler = VnfrConsoleOperdataDtsHandler(self._dts, self._log, self._loop, + vdur_console_handler = VnfrConsoleOperdataDtsHandler(self._dts, self._log, self._loop, self, vnfr_msg.id,vm["uuid"],vm["name"]) yield from vdur_console_handler.register() self._vdur_console_handler[vm["uuid"]] = vdur_console_handler - + vdur_msg = vnfr_msg.vdur.add() vdur_msg.vim_id = vm["vim_vm_id"] vdur_msg.id = vm["uuid"] @@ -670,7 +670,7 @@ class OpenmanoNsr(object): for _,handler in self._vdur_console_handler.items(): handler._regh.deregister() - + if self._nsr_uuid is None: self._log.warning("Cannot terminate an un-instantiated nsr") return -- 2.25.1