Changeset 16903 in vbox for trunk/src/libs/xpcom18a4/python/sample
- Timestamp:
- Feb 18, 2009 2:17:15 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43024
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/python/sample/shellcommon.py
r16366 r16903 145 145 return s.split() 146 146 147 def startVm(mgr,vb,mach,type,perf): 147 def createVm(ctx,name,kind,base): 148 mgr = ctx['mgr'] 149 vb = ctx['vb'] 150 session = mgr.getSessionObject(vb) 151 mach = vb.createMachine(name, kind, base, 152 "00000000-0000-0000-0000-000000000000") 153 mach.saveSettings() 154 print "created machine with UUID",mach.id 155 vb.registerMachine(mach) 156 157 def removeVm(ctx,mach): 158 mgr = ctx['mgr'] 159 vb = ctx['vb'] 160 print "removing machine ",mach.name,"with UUID",mach.id 161 mach = vb.unregisterMachine(mach.id) 162 if mach: 163 mach.deleteSettings() 164 165 def startVm(ctx,mach,type): 166 mgr = ctx['mgr'] 167 vb = ctx['vb'] 168 perf = ctx['perf'] 148 169 session = mgr.getSessionObject(vb) 149 170 uuid = mach.id … … 152 173 completed = progress.completed 153 174 rc = progress.resultCode 154 print "Completed:", completed, "rc:", rc175 print "Completed:", completed, "rc:",hex(rc&0xffffffff) 155 176 if int(rc) == 0: 156 177 # we ignore exceptions to allow starting VM even if … … 163 184 traceback.print_exc() 164 185 pass 165 session.close() 186 # if session not opened, close doesn't make sense 187 session.close() 188 else: 189 # Not yet implemented error string query API for remote API 190 if not ctx['remote']: 191 print session.QueryErrorObject(rc) 166 192 167 193 def getMachines(ctx): … … 282 308 else: 283 309 type = "gui" 284 startVm(ctx['mgr'], ctx['vb'], mach, type, ctx['perf']) 310 startVm(ctx, mach, type) 311 return 0 312 313 def createCmd(ctx, args): 314 if (len(args) < 3 or len(args) > 4): 315 print "usage: create name ostype <basefolder>" 316 return 0 317 name = args[1] 318 oskind = args[2] 319 if len(args) == 4: 320 base = args[3] 321 else: 322 base = '' 323 try: 324 ctx['vb'].getGuestOSType(oskind) 325 except Exception, e: 326 print 'Unknown OS type:',oskind 327 return 0 328 createVm(ctx, name, oskind, base) 329 return 0 330 331 def removeCmd(ctx, args): 332 mach = argsToMach(ctx,args) 333 if mach == None: 334 return 0 335 removeVm(ctx, mach) 285 336 return 0 286 337 … … 382 433 commands = {'help':['Prints help information', helpCmd], 383 434 'start':['Start virtual machine by name or uuid', startCmd], 435 'create':['Create virtual machine', createCmd], 436 'remove':['Remove virtual machine', removeCmd], 384 437 'pause':['Pause virtual machine', pauseCmd], 385 438 'resume':['Resume virtual machine', resumeCmd],
Note:
See TracChangeset
for help on using the changeset viewer.