Beispiel #1
0
def detach(brname, ifname):
    BrctlError.check(net.bridgeExists(brname), BrctlError.CODE_NO_SUCH_BRIDGE,
                     "No such bridge", {"bridge": brname})
    BrctlError.check(net.ifaceExists(ifname), BrctlError.CODE_NO_SUCH_IFACE,
                     "No such interface", {"interface": ifname})
    if ifname in net.bridgeInterfaces(brname):
        run(["brctl", "delif", brname, ifname])
Beispiel #2
0
Datei: qm.py Projekt: GLab/ToMaTo
def start(vmid, detachInterfaces=True):
	vmid = params.convert(vmid, convert=int, gte=1)
	if not net.bridgeExists("dummy"):
		brctl.create("dummy")
	with locks[vmid]:
		_checkStatus(vmid, Status.Stopped)
		_qm(vmid, ActionName.START)
		_checkStatus(vmid, Status.Running)
		try:
			for ifname in _getNicNames(vmid).values():
				wait.waitFor(lambda :net.ifaceExists(ifname), failCond=lambda :_status(vmid) != Status.Running)
				bridge = net.ifaceBridge(ifname)
				if bridge and detachInterfaces:
					brctl.detach(bridge, ifname)
		except:
			stop(vmid)
			raise
Beispiel #3
0
	def start(self, vmid, detachInterfaces=True):
		vmid = params.convert(vmid, convert=int, gte=1)
		if not net.bridgeExists("dummy"):
			brctl.create("dummy")
		with locks[vmid]:
			self._checkStatus(vmid,[StateName.PREPARED])
			self._virsh("start", ["vm_%s" % vmid])
			self._checkStatus(vmid,[StateName.STARTED])
			try:
				for ifname in self._getNicNames(vmid).values():
					wait.waitFor(lambda :net.ifaceExists(ifname), failCond=lambda :self.getState(vmid) != StateName.STARTED)
					bridge = net.ifaceBridge(ifname)
					if bridge and detachInterfaces:
						brctl.detach(bridge, ifname)
			except:
				self._virsh("destroy", ["vm_%s" % vmid])
				raise
Beispiel #4
0
def start(vmid, detachInterfaces=True):
    vmid = params.convert(vmid, convert=int, gte=1)
    if not net.bridgeExists("dummy"):
        brctl.create("dummy")
    with locks[vmid]:
        _checkStatus(vmid, Status.Stopped)
        _qm(vmid, ActionName.START)
        _checkStatus(vmid, Status.Running)
        try:
            for ifname in _getNicNames(vmid).values():
                wait.waitFor(lambda: net.ifaceExists(ifname),
                             failCond=lambda: _status(vmid) != Status.Running)
                bridge = net.ifaceBridge(ifname)
                if bridge and detachInterfaces:
                    brctl.detach(bridge, ifname)
        except:
            stop(vmid)
            raise
Beispiel #5
0
 def start(self, vmid, detachInterfaces=True):
     vmid = params.convert(vmid, convert=int, gte=1)
     if not net.bridgeExists("dummy"):
         brctl.create("dummy")
     with locks[vmid]:
         self._checkStatus(vmid, [StateName.PREPARED])
         self._virsh("start", ["vm_%s" % vmid])
         self._checkStatus(vmid, [StateName.STARTED])
         try:
             for ifname in self._getNicNames(vmid).values():
                 wait.waitFor(lambda: net.ifaceExists(ifname),
                              failCond=lambda: self.getState(vmid) !=
                              StateName.STARTED)
                 bridge = net.ifaceBridge(ifname)
                 if bridge and detachInterfaces:
                     brctl.detach(bridge, ifname)
         except:
             self._virsh("destroy", ["vm_%s" % vmid])
             raise
Beispiel #6
0
def attach(brname, ifname):
    BrctlError.check(net.bridgeExists(brname), BrctlError.CODE_NO_SUCH_BRIDGE,
                     "No such bridge", {"bridge": brname})
    BrctlError.check(net.ifaceExists(ifname), BrctlError.CODE_NO_SUCH_IFACE,
                     "No such interface", {"interface": ifname})
    run(["brctl", "addif", brname, ifname])
Beispiel #7
0
def remove(brname):
    BrctlError.check(net.bridgeExists(brname), BrctlError.CODE_NO_SUCH_BRIDGE,
                     "No such bridge", {"bridge": brname})
    run(["brctl", "delbr", brname])
Beispiel #8
0
def detach(brname, ifname):
	BrctlError.check(net.bridgeExists(brname), BrctlError.CODE_NO_SUCH_BRIDGE, "No such bridge", {"bridge": brname})
	BrctlError.check(net.ifaceExists(ifname), BrctlError.CODE_NO_SUCH_IFACE, "No such interface", {"interface": ifname})
	if ifname in net.bridgeInterfaces(brname):
		run(["brctl", "delif", brname, ifname])
Beispiel #9
0
def attach(brname, ifname):
	BrctlError.check(net.bridgeExists(brname), BrctlError.CODE_NO_SUCH_BRIDGE, "No such bridge", {"bridge": brname})
	BrctlError.check(net.ifaceExists(ifname), BrctlError.CODE_NO_SUCH_IFACE, "No such interface", {"interface": ifname})
	run(["brctl", "addif", brname, ifname])
Beispiel #10
0
def remove(brname):
	BrctlError.check(net.bridgeExists(brname), BrctlError.CODE_NO_SUCH_BRIDGE, "No such bridge", {"bridge": brname})
	run(["brctl", "delbr", brname])