How to loop through a python class -


There are problems for the first time in my class in Python, yet it will return the correct value, although the second pass when it gets It is: vm_return.vmPerf ()

All things that are defined in the init class have been completely erased and whatever remains is:

pass_vm_mor < / P>

The object can not be found there because it is no longer present when I call it the second time it does not make any sense The possibility is just a misunderstanding on my part. import from import pyVim.connect Import SmartConnect, PIVMOM Import Vim importing system import timing off #globals passed_vm_mor = '' class getVM (object) ): Def __init__ (self, passed_vm_mor): self.passed_vm_mor = pass_vm_mor vcenter_connection = smartconnect (host = hostname, user = username, pwd = password) atexit.register (disconnect, vcenter_connection) content = vcenter_connection.RetrieveContent () perf_dict = {} PerfList = content.perfManager.perf in perfList for Counter: counter_full = "{} creating vcenter counters for # objects. {} {} ". Format (counter.groupInfo.key, counter.nameInfo.key, counter.rollupType) perf_dict [counter_full] = counter.key viewType = [vim.VirtualMachine] Theater content = ['name', 'runtime.powerState 'datastore'] specType = vim.VirtualMachine objView = content.viewManager.CreateContainerView (content.rootFolder, viewType, True) Tispiisi = VIM. property Colector. Trawarsl Spek (name = "T APS Sinam, PA th = 'view' drop = false, type = vim.view.ContainerView) pSpec = vim.PropertyCollector.PropertySpec (all = false, PathSet = Sahara, type = specType) oSpec = vim.PropertyCollector.ObjectSpec (obj = objView, SelectSet = [TSpec], skip = False) pfSpec = vim.PropertyCollector.FilterSpec (Objects Destroy (=) for vm_property in t = [oSpec], propSet = [pSpec], Reporting MissingObjectsInResults = False) vm_properties = content.propertyCollector.RetrieveProperties (specSet = [pfSpec]) objView Vm_property: via the list #lop vcenter and build instructions. property_dic = {} for Prop vm_property.propSet: property_dic [prop.name] = prop.val VM = vm_property.obj vm_mor = vm._moId if self.passed_vm_mor == vm_mor: self.vm = vm_property.obj rest: VmPerf (itself) to continue def: self.vm_mor = self.vm._moId self.bootOptions has supported = self.vm.capability.bootOptionsSupported self.bootRetryOptionsSupported = self.vm.capability. BootRetryOptionsSupported self.changeTrackingSuppo rted = self.vm.capability.changeTrackingSupported self.consolePreferencesSupported = self.vm.capability.consolePreferencesSupported cursor = db.cursor () CUSTOMER_ID = 24 sql = ( '' 'a.vm_mor select a VMS, vm_groups b, c customers where c.customer_id =% d and c.customer_id = b .customer_id and b.vm_group_id = a.vm_group_id '' ')% CUSTOMER_ID cursor.execute (SQL) to vm_mor cursor: vm_return = getVM (vm_mor [0]) Vm_return.vmPerf ()

Unless you do so: < Pre> self.vm_mor = self.vm. _moId

You will always fail on the next call because now there is only one id ( _moId ) in self.vm_mor .

I'm not sure what you want to accomplish by doing so, but will be more intuitive:

  self._moId = self.vm._moId   

If you want "direct access" to the inner variables of self.vm_mor

Next, note that in the following loop:

  for cursor in vm_mor: vm_return = getVM (vm_mor [0]) vm_return.vmPerf ()   

Overriding keep vm_return again and again different v_mor s. With

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -