X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fvimconn_vmware.py;h=fe118926753ef06752f5e2a29846de50f57fb625;hb=41840091ca1e25c895dd9d38a94d37da78763c63;hp=20ff822760f7309f658f3e08437a0c48a681254a;hpb=b0ab2c088608015a68fb0332da927f07a73450a4;p=osm%2FRO.git diff --git a/osm_ro/vimconn_vmware.py b/osm_ro/vimconn_vmware.py index 20ff8227..fe118926 100644 --- a/osm_ro/vimconn_vmware.py +++ b/osm_ro/vimconn_vmware.py @@ -1523,7 +1523,7 @@ class vimconnector(vimconn.vimconnector): vmname_andid = ''.join(new_vm_name) for net in net_list: - if net['type'] == "SR-IOV" or net['type'] == "PCI-PASSTHROUGH": + if net['type'] == "PCI-PASSTHROUGH": raise vimconn.vimconnNotSupportedException( "Current vCD version does not support type : {}".format(net['type'])) @@ -1554,7 +1554,6 @@ class vimconnector(vimconn.vimconnector): raise vimconn.vimconnNotFoundException("new_vminstance(): Failed create vApp {}: " "(Failed retrieve catalog information {})".format(name, image_id)) - # Set vCPU and Memory based on flavor. vm_cpus = None vm_memory = None @@ -1798,14 +1797,13 @@ class vimconnector(vimconn.vimconnector): #Add PCI passthrough/SRIOV configrations vm_obj = None pci_devices_info = [] - sriov_net_info = [] reserve_memory = False for net in net_list: if net["type"] == "PF" or net["type"] == "PCI-PASSTHROUGH": pci_devices_info.append(net) elif (net["type"] == "VF" or net["type"] == "SR-IOV" or net["type"] == "VFnotShared") and 'net_id'in net: - sriov_net_info.append(net) + reserve_memory = True #Add PCI if len(pci_devices_info) > 0: @@ -1918,7 +1916,8 @@ class vimconnector(vimconn.vimconnector): self.logger.info("new_vminstance(): Attaching net {} to vapp".format(interface_net_name)) self.connect_vapp_to_org_vdc_network(vapp_id, nets[0].get('name')) - type_list = ('PF', 'PCI-PASSTHROUGH', 'VF', 'SR-IOV', 'VFnotShared') + type_list = ('PF', 'PCI-PASSTHROUGH', 'VFnotShared') + nic_type = 'VMXNET3' if 'type' in net and net['type'] not in type_list: # fetching nic type from vnf if 'model' in net: @@ -1938,49 +1937,22 @@ class vimconnector(vimconn.vimconnector): else: self.logger.info("new_vminstance(): adding network adapter "\ "to a network {}".format(nets[0].get('name'))) + if net['type'] in ['SR-IOV', 'VF']: + nic_type = net['type'] self.add_network_adapter_to_vms(vapp, nets[0].get('name'), primary_nic_index, nicIndex, - net) + net, + nic_type=nic_type) nicIndex += 1 # cloud-init for ssh-key injection if cloud_config: self.cloud_init(vapp,cloud_config) - # ############# Stub code for SRIOV ################# - #Add SRIOV -# if len(sriov_net_info) > 0: -# self.logger.info("Need to add SRIOV adapters {} into VM {}".format(sriov_net_info, -# vmname_andid )) -# sriov_status, vm_obj, vcenter_conect = self.add_sriov(vapp_uuid, -# sriov_net_info, -# vmname_andid) -# if sriov_status: -# self.logger.info("Added SRIOV {} to VM {}".format( -# sriov_net_info, -# vmname_andid) -# ) -# reserve_memory = True -# else: -# self.logger.info("Fail to add SRIOV {} to VM {}".format( -# sriov_net_info, -# vmname_andid) -# ) - # If VM has PCI devices or SRIOV reserve memory for VM if reserve_memory: - memReserve = vm_obj.config.hardware.memoryMB - spec = vim.vm.ConfigSpec() - spec.memoryAllocation = vim.ResourceAllocationInfo(reservation=memReserve) - task = vm_obj.ReconfigVM_Task(spec=spec) - if task: - result = self.wait_for_vcenter_task(task, vcenter_conect) - self.logger.info("Reserved memory {} MB for " - "VM VM status: {}".format(str(memReserve), result)) - else: - self.logger.info("Fail to reserved memory {} to VM {}".format( - str(memReserve), str(vm_obj))) + self.reserve_memory_for_all_vms(vapp, memory_mb) self.logger.debug("new_vminstance(): starting power on vApp {} ".format(vmname_andid)) @@ -2638,13 +2610,12 @@ class vimconnector(vimconn.vimconnector): try: vapp_name = self.get_namebyvappid(vm__vim_uuid) - vapp_resource = vdc_obj.get_vapp(vapp_name) - vapp = VApp(self.client, resource=vapp_resource) if vapp_name is None: self.logger.debug("delete_vminstance(): Failed to get vm by given {} vm uuid".format(vm__vim_uuid)) return -1, "delete_vminstance(): Failed to get vm by given {} vm uuid".format(vm__vim_uuid) - else: - self.logger.info("Deleting vApp {} and UUID {}".format(vapp_name, vm__vim_uuid)) + self.logger.info("Deleting vApp {} and UUID {}".format(vapp_name, vm__vim_uuid)) + vapp_resource = vdc_obj.get_vapp(vapp_name) + vapp = VApp(self.client, resource=vapp_resource) # Delete vApp and wait for status change if task executed and vApp is None. @@ -5028,6 +4999,10 @@ class vimconnector(vimconn.vimconnector): "network connection section") data = response.content data = data.split('' not in data: self.logger.debug("add_network_adapter PrimaryNIC not in data nic_type {}".format(nic_type)) item = """{} @@ -5037,7 +5012,7 @@ class vimconnector(vimconn.vimconnector): {} {} """.format(primary_nic_index, network_name, nicIndex, - allocation_mode, nic_type) + allocation_mode, vcd_netadapter_type) # Stub for ip_address feature if ip_address: ip_tag = '{}'.format(ip_address) @@ -5056,7 +5031,7 @@ class vimconnector(vimconn.vimconnector): {} {} """.format(network_name, nicIndex, - allocation_mode, nic_type) + allocation_mode, vcd_netadapter_type) # Stub for ip_address feature if ip_address: ip_tag = '{}'.format(ip_address) @@ -6323,12 +6298,18 @@ class vimconnector(vimconn.vimconnector): Returns org and vdc object """ - org = Org(self.client, resource=self.client.get_org()) - vdc = org.get_vdc(self.tenant_name) + vdc = None + try: + org = Org(self.client, resource=self.client.get_org()) + vdc = org.get_vdc(self.tenant_name) + except Exception as e: + # pyvcloud not giving a specific exception, Refresh nevertheless + self.logger.debug("Received exception {}, refreshing token ".format(str(e))) #Retry once, if failed by refreshing token if vdc is None: self.get_token() + org = Org(self.client, resource=self.client.get_org()) vdc = org.get_vdc(self.tenant_name) return org, vdc