0 Replies Latest reply on Mar 5, 2017 10:13 PM by dpinjun

    Schedule VM Hardware Upgrade using pyvmomi

    dpinjun Lurker

      Need help in scheduling hardware upgrade using pyvmomi, i am using ESXi6.5, my script look as follows, not sure what is missing. Please help.

       

      def get_obj(content,vimtype,name):

          obj = None

          container=content.viewManager.CreateContainerView(content.rootFolder,vimtype,True)

          for c in container.view:

              if c.name == name:

                  obj = c

                  break

          print(obj)

          return obj

       

       

       

       

      si = connect.Connect()

      content = si.RetrieveContent()

      vm = get_obj(content, [vim.VirtualMachine], "VM2")

       

      scheduled_hardware_upgrade = vim.vm.ScheduledHardwareUpgradeInfo()

      scheduled_hardware_upgrade.upgradePolicy = "always"

      scheduled_hardware_upgrade.versionKey = "vmx-13"

      config_spec = vim.vm.ConfigSpec()

      config_spec.scheduledHardwareUpgradeInfo = scheduled_hardware_upgrade

      vm.ReconfigVM_Task(config_spec)