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 _unassignResources(self):
		for con in self.connectionSetAll():
			con.upcast()._unassignTincPort()
			host = con.interface.device.host
			if con.bridge_id and not ifaceutil.bridgeInterfaces(host, con.getBridge()):
				con.upcast()._unassignBridgeId()