Beispiel #1
0
	def _realIdState(self, type, id):
		if type == "vmid":
			return qm.getState(self, id) != State.CREATED or vzctl.getState(self, id) != State.CREATED
		elif type == "port":
			return not process.portFree(self, id)
		elif type == "bridge":
			return ifaceutil.bridgeExists(self, "gbr_%d" % id) 
Beispiel #2
0
	def connectToBridge(self):
		dev = self.device.upcast()
		bridge = dev.getBridge(self)
		if self.isConnected():
			if not ifaceutil.bridgeExists(dev.host, bridge):
				ifaceutil.bridgeCreate(dev.host, bridge)
			ifaceutil.bridgeConnect(dev.host, bridge, self.interfaceName())
			ifaceutil.ifup(dev.host, self.interfaceName())
Beispiel #3
0
	def _unassignBridgeId(self):
		if self.bridge_id:
			if self.connector.state != State.STARTED and self.interface.device.state != State.STARTED:
				host = self.getHost()
				bridge = self.getBridge(assign=False, create=False)
				if ifaceutil.bridgeExists(host, bridge):
					attachedInterfaces = ifaceutil.bridgeInterfaces(host, bridge)
					assert not attachedInterfaces, "Bridge %s still has interfaces connected: %s" % (bridge, attachedInterfaces) 
					ifaceutil.bridgeRemove(host, bridge)			
				host.giveId("bridge", self.bridge_id)
				self.bridge_id = None
				self.save()
Beispiel #4
0
	def _unassignBridgeId(self):
		if self.bridge_id:
			host = self.getHost()
			if host:
				bridge = self.getBridge(create=False)
				if ifaceutil.bridgeExists(host, bridge):
					attachedInterfaces = ifaceutil.bridgeInterfaces(host, bridge)
					assert not attachedInterfaces, "Bridge %s still has interfaces connected: %s" % (bridge, attachedInterfaces) 
					ifaceutil.bridgeRemove(host, bridge)			
				host.giveId("bridge", self.bridge_id)
			self.bridge_id = None
			self.save()