import constants import os import re import sys import types class Menu: def __init__(self): self.vmList=[] self.procedure="" self.numVMs=0 self.strippedList=[] def printHF(self): print "------------------------------------------\n" def getNumVMS(self): return self.numVMs def __getAllRegisteredVMs(self): vmListFH=os.popen(constants.vmwarecmd + " -l") self.vmList=vmListFH.readlines() vmListFH.close() for eachvm in self.vmList: self.strippedList.append(eachvm.strip()) return self.strippedList def displayMenu(self): """ calls __getAllRegisteredVMS private function """ self.vmList=self.__getAllRegisteredVMs() if not self.vmList: print "error no Virtual Machines found on this host\n" sys.exit() i=0 self.printHF(); for eachvm in self.vmList: print i,") "+ eachvm.strip("\\n") i+=1 self.printHF() self.numVMs=i def getvmList(self): return self.vmList