Modified vCD connector method with minor changes 26/5826/3
authorkasar <pkasar@vmware.com>
Thu, 25 Jan 2018 08:57:02 +0000 (00:57 -0800)
committerkasar <pkasar@vmware.com>
Thu, 1 Feb 2018 11:24:52 +0000 (03:24 -0800)
Change-Id: I871ced6dd2567b8ac6c99af5d027fb751113b771
Signed-off-by: kasar <pkasar@vmware.com>
osm_ro/vimconn_vmware.py

index 562cfcc..9c26574 100644 (file)
@@ -1684,7 +1684,11 @@ class vimconnector(vimconn.vimconnector):
                         if 'type' in net and net['type'] not in type_list:
                             # fetching nic type from vnf
                             if 'model' in net:
-                                nic_type = net['model']
+                                if net['model'].lower() == 'virtio':
+                                    nic_type = 'VMXNET3'
+                                else:
+                                    nic_type = net['model']
+
                                 self.logger.info("new_vminstance(): adding network adapter "\
                                                           "to a network {}".format(nets[0].name))
                                 self.add_network_adapter_to_vms(vapp, nets[0].name,
@@ -4018,39 +4022,31 @@ class vimconnector(vimconn.vimconnector):
                 return if True
         """
         try:
-            vm_moref_id , vm_vcenter_host , vm_vcenter_username, vm_vcenter_port = self.get_vcenter_info_rest(vmuuid)
-            if vm_moref_id and vm_vcenter_host and vm_vcenter_username:
-                context = None
-                if hasattr(ssl, '_create_unverified_context'):
-                    context = ssl._create_unverified_context()
-                    vcenter_conect = SmartConnect(host=vm_vcenter_host, user=vm_vcenter_username,
-                                  pwd=self.passwd, port=int(vm_vcenter_port),
-                                  sslContext=context)
-                    atexit.register(Disconnect, vcenter_conect)
-                    content = vcenter_conect.RetrieveContent()
-
-                    host_obj, vm_obj = self.get_vm_obj(content ,vm_moref_id)
-                    if vm_obj:
-                        config_spec = vim.vm.ConfigSpec()
-                        config_spec.extraConfig = []
-                        opt = vim.option.OptionValue()
-                        opt.key = 'numa.nodeAffinity'
-                        opt.value = str(paired_threads_id)
-                        config_spec.extraConfig.append(opt)
-                        task = vm_obj.ReconfigVM_Task(config_spec)
-                        if task:
-                            result = self.wait_for_vcenter_task(task, vcenter_conect)
-                            extra_config = vm_obj.config.extraConfig
-                            flag = False
-                            for opts in extra_config:
-                                if 'numa.nodeAffinity' in opts.key:
-                                    flag = True
-                                    self.logger.info("set_numa_affinity: Sucessfully assign numa affinity "\
-                                                             "value {} for vm {}".format(opt.value, vm_obj))
-                            if flag:
-                                return
-                    else:
-                        self.logger.error("set_numa_affinity: Failed to assign numa affinity")
+            vcenter_conect, content = self.get_vcenter_content()
+            vm_moref_id = self.get_vm_moref_id(vmuuid)
+
+            host_obj, vm_obj = self.get_vm_obj(content ,vm_moref_id)
+            if vm_obj:
+                config_spec = vim.vm.ConfigSpec()
+                config_spec.extraConfig = []
+                opt = vim.option.OptionValue()
+                opt.key = 'numa.nodeAffinity'
+                opt.value = str(paired_threads_id)
+                config_spec.extraConfig.append(opt)
+                task = vm_obj.ReconfigVM_Task(config_spec)
+                if task:
+                    result = self.wait_for_vcenter_task(task, vcenter_conect)
+                    extra_config = vm_obj.config.extraConfig
+                    flag = False
+                    for opts in extra_config:
+                        if 'numa.nodeAffinity' in opts.key:
+                            flag = True
+                            self.logger.info("set_numa_affinity: Sucessfully assign numa affinity "\
+                                                     "value {} for vm {}".format(opt.value, vm_obj))
+                        if flag:
+                            return
+            else:
+                self.logger.error("set_numa_affinity: Failed to assign numa affinity")
         except Exception as exp:
             self.logger.error("set_numa_affinity : exception occurred while setting numa affinity "\
                                                        "for VM {} : {}".format(vm_obj, vm_moref_id))