Changeset 20897 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jun 24, 2009 3:54:41 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/vboxapi.py
r20818 r20897 33 33 from VirtualBox_constants import VirtualBoxReflectionInfo 34 34 35 class PerfCollector: 36 """ This class provides a wrapper over IPerformanceCollector in order to 37 get more 'pythonic' interface. 38 39 To begin collection of metrics use setup() method. 40 41 To get collected data use query() method. 42 43 It is possible to disable metric collection without changing collection 44 parameters with disable() method. The enable() method resumes metric 45 collection. 46 """ 47 48 def __init__(self, vb): 49 """ Initializes the instance. 50 51 Pass an instance of IVirtualBox as parameter. 52 """ 53 self.collector = vb.performanceCollector 54 55 def setup(self, names, objects, period, nsamples): 56 """ Discards all previously collected values for the specified 57 metrics, sets the period of collection and the number of retained 58 samples, enables collection. 59 """ 60 self.collector.setupMetrics(names, objects, period, nsamples) 61 62 def enable(self, names, objects): 63 """ Resumes metric collection for the specified metrics. 64 """ 65 self.collector.enableMetrics(names, objects) 66 67 def disable(self, names, objects): 68 """ Suspends metric collection for the specified metrics. 69 """ 70 self.collector.disableMetrics(names, objects) 71 72 def query(self, names, objects): 73 """ Retrieves collected metric values as well as some auxiliary 74 information. Returns an array of dictionaries, one dictionary per 75 metric. Each dictionary contains the following entries: 76 'name': metric name 77 'object': managed object this metric associated with 78 'unit': unit of measurement 79 'scale': divide 'values' by this number to get float numbers 80 'values': collected data 81 'values_as_string': pre-processed values ready for 'print' statement 82 """ 83 (values, names_out, objects_out, units, scales, sequence_numbers, 84 indices, lengths) = self.collector.queryMetricsData(names, objects) 85 out = [] 86 for i in xrange(0, len(names_out)): 87 scale = int(scales[i]) 88 if scale != 1: 89 fmt = '%.2f%s' 90 else: 91 fmt = '%d %s' 92 out.append({ 93 'name':str(names_out[i]), 94 'object':str(objects_out[i]), 95 'unit':str(units[i]), 96 'scale':scale, 97 'values':[int(values[j]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))], 98 'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, units[i]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']' 99 }) 100 return out 101 35 102 class PlatformMSCOM: 36 103 # Class to fake access to constants in style of foo.bar.boo … … 191 258 if rc >= WAIT_OBJECT_0 and rc < WAIT_OBJECT_0+len(self.handles): 192 259 # is it possible? 193 print "how come?"194 260 pass 195 261 elif rc==WAIT_OBJECT_0 + len(self.handles): … … 210 276 pythoncom.CoUninitialize() 211 277 pass 278 279 def getPerfCollector(self, vbox): 280 # MS COM cannot invoke performance collector methods yet 281 return None 282 212 283 213 284 class PlatformXPCOM: … … 265 336 import xpcom 266 337 xpcom._xpcom.DeinitCOM() 338 339 def getPerfCollector(self, vbox): 340 return PerfCollector(vbox) 267 341 268 342 class PlatformWEBSERVICE: … … 286 360 287 361 def getVirtualBox(self): 288 returnself.wsmgr.logon(self.user, self.password)362 self.vbox = self.wsmgr.logon(self.user, self.password) 289 363 290 364 def getConstants(self): … … 310 384 311 385 def waitForEvents(self, timeout): 312 # Webservices cannot do that 386 # Webservices cannot do that yet 313 387 pass 314 388 315 389 def deinit(self): 316 # should we do something about it? 317 pass 390 try: 391 if self.vbox is not None: 392 self.wsmg.logoff(self.vbox) 393 self.vbox = None 394 except: 395 pass 396 397 def getPerfCollector(self, vbox): 398 return PerfCollector(vbox) 318 399 319 400 class SessionManager: … … 338 419 self.type = self.platform.getType() 339 420 self.remote = self.platform.getRemote() 421 self.style = style 340 422 except Exception,e: 341 423 print "init exception: ",e … … 350 432 351 433 def __del__(self): 352 deinit(self)434 self.deinit() 353 435 354 436 def deinit(self): 355 437 if hasattr(self, "vbox"): 356 438 del self.vbox 439 self.vbox = None 357 440 if hasattr(self, "platform"): 358 441 self.platform.deinit() 442 self.platform = None 359 443 360 444 def initPerThread(self): … … 377 461 def waitForEvents(self, timeout): 378 462 return self.platform.waitForEvents(timeout) 463 464 def getPerfCollector(self, vbox): 465 return self.platform.getPerfCollector(vbox) -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r20896 r20897 4326 4326 4327 4327 <attribute name="CPUCount" type="unsigned long"> 4328 <desc>Number of virtual CPUs in the VM. In the current version of the product, this is always 1.</desc>4328 <desc>Number of virtual CPUs in the VM.</desc> 4329 4329 </attribute> 4330 4330
Note:
See TracChangeset
for help on using the changeset viewer.