Exemplo n.º 1
0
Arquivo: vpn.py Projeto: m3z/ToMaTo
	def destroyBridge(self):
		if self.connector.state == State.STARTED:
			return
		if not self.getBridgeId():
			return
		if self.interface.device.state != State.CREATED and ifaceutil.bridgeInterfaces(self.getBridgeHost(), self.getBridge()):
			return
		ifaceutil.bridgeRemove(self.getBridgeHost(), self.getBridge(), disconnectAll=True, setIfdown=True)
		self._unassignBridgeId()
Exemplo n.º 2
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()
Exemplo n.º 3
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()
Exemplo n.º 4
0
	def _freeId(self, type, id):
		if type == "vmid":
			if qm.getState(self, id) == State.STARTED:
				qm.stop(self, id)
			if qm.getState(self, id) == State.PREPARED:
				qm.destroy(self, id)
			if vzctl.getState(self, id) == State.STARTED:
				vzctl.stop(self, id)
			if vzctl.getState(self, id) == State.PREPARED:
				vzctl.destroy(self, id)
		elif type == "port":
			process.killPortUser(self, id)
		elif type == "bridge":
			ifaceutil.bridgeRemove(self, "gbr_%d" % id, True, True)