def _startDev(self): host = self.host vmid = self.getVmid() state = vzctl.getState(host, vmid) if state == State.CREATED: self._prepareDev() state = vzctl.getState(host, vmid) for iface in self.interfaceSetAll(): bridge = self.getBridge(iface) assert bridge, "Interface has no bridge %s" % iface ifaceutil.bridgeCreate(self.host, bridge) ifaceutil.ifup(self.host, bridge) try: if state == State.PREPARED: vzctl.start(host, vmid) for iface in self.interfaceSetAll(): assert util.waitFor(lambda: ifaceutil.interfaceExists(host, self.interfaceDevice(iface))) self.connectToBridge(iface, self.getBridge(iface)) iface.upcast()._configureNetwork() self._startVnc() self.state = State.STARTED self.save() except: try: vzctl.stop(host, vmid) except: pass raise
def waitForInterface(host, vmid, iface): util.waitFor(lambda :interfaceDevice(host, vmid, iface, failSilent=True))