def getDomainInfo(self, domain): dom = Driver.getDomainByID(domain) name = dom.name() id = domain host = hostname type = "silver" if name.lower().startswith("g"): type = "gold" vm = VirtualMachine.VirtualMachine(domain, name, id, host, type) return vm
def get_vm_by_name(self, name): content = self.instance.RetrieveContent() virtual_machine = None container = content.viewManager.CreateContainerView(content.rootFolder, [vim.VirtualMachine], True) for item in container.view: if item.name.lower() == name.lower(): virtual_machine = item break container.Destroy() if virtual_machine is not None: return VirtualMachine(virtual_machine, self.instance) return None
def printQuads(self): counter = 1 for quad in self.Quads: #print(counter, quad.Operador, quad.OperandoI, quad.OperandoD, quad.Resultado) counter += 1 tables = { "functions": namesTable.functionsT, "globals": namesTable.globalsT, "constants": namesTable.constantsT } namesTable.globalsT["vars"] = self.countVarByTypeScope( "Global") #Obtener el conteo de memoria global virtualMachine = VirtualMachine(self.Quads, tables, Memory.MemSize) virtualMachine.run()
def scanForExisting(self): configFiles = self.scanForFiles() vmArray = [] xml = XmlDriver.XmlDriver() for i in range(len(configFiles)): fileLocation = configFiles[i] name = xml.getName(fileLocation) ostype = xml.getOsType(fileLocation) harddrive = xml.getHardDrive(fileLocation) mem = xml.getMemory(fileLocation) cpu = xml.getCpuCount(fileLocation) mac = xml.getMac(fileLocation) network = xml.getNetworkAdapter(fileLocation) cddrive = xml.getCdDrive(fileLocation) harddrivesize = self.getFileSize(harddrive, name) vmstate = self.getVmState(name) newVm = VirtualMachine.VirtualMachine(name, vmstate, ostype, mem, cpu, harddrive, harddrivesize, cddrive, network, mac) vmArray.append(newVm) return vmArray
# para testear con un file import os fileDir = os.path.dirname(os.path.realpath('__file__')) programa = 'advListFunctions.txt' filename = os.path.join(fileDir, 'tomate/tests/FinalTest/' + programa) #filename = os.path.join(fileDir, 'tests/' + programa ) f = open(filename, "r") input = f.read() yacc.parse(input) print("stackListComplete: " + str(stackListsAuxComplete)) print("stackListAux: " + str(stackListsAux)) print("stackOperandos: " + str(stackOperandos)) print("stackTypes: " + str(stackTypes)) print("stackScope: " + str(stackScope)) print("Const Table: " + str(constTable)) print("Address: " + str(address)) print("DirFunctions: " + str(dirFunctions)) quadruples.print() globalVariables() #print(globalMemory) print("======= Output =======") createOvejota() ## VM vm = VirtualMachine() vm.loadOvejota() vm.pointerSomething()
################# # # Joe # # Cloud Controller # ################### from VirtualMachine import * vm1 = VirtualMachine() vm1.printVMDetails()
# строка с кодом, который в последствии будет распознаваться парсером. prog = ''' var i = 5; do { if(i >= 7) logprint(i); i++; } while(i < 10) ''' # вызов конструктора класса Parser. parser = Parser() # вызов конструктора класса Analyzer. analyzer = Analyzer() # в переменной res хранится корень графа, описывающего структуру кода из переменной prog. res = parser.parse(prog) print(*res.tree, sep=os.linesep) # вызов метода analyze, который производит семантический анализ analyzer.analyze(res) if len(analyzer.errors) > 0: for e in analyzer.errors: print("Ошибка: {}".format(e.message)) else: print("Ошибок не обнаружено.") generator = CodeGenerator(res) generator.print_bytecode() vm = VirtualMachine(generator.lines)
def get_vm_by_ip(self, ip): content = self.instance.RetrieveContent() virtual_machine = content.searchIndex.FindByIp(None, ip, True) if virtual_machine is not None: return VirtualMachine(virtual_machine, self.instance) return None
def get_vm_by_dns_name(self, name): content = self.instance.RetrieveContent() virtual_machine = content.searchIndex.FindByDnsName(None, name, True) if virtual_machine is not None: return VirtualMachine(virtual_machine, self.instance) return None
def get_vm_by_uuid(self, uuid): content = self.instance.RetrieveContent() virtual_machine = content.searchIndex.FindByUuid(None, uuid, True) if virtual_machine is not None: return VirtualMachine(virtual_machine, self.instance) return None
def machine(self): """Return VirtualMachine object associated wit this snapshot""" import VirtualMachine return VirtualMachine(self.machine)