Пример #1
0
	def configure(self, properties):
		if self.state != State.CREATED:
			fault.check(not "network_type" in properties, "Cannot change type of external network with prepared connections: %s", self.name)
			fault.check(not "network_group" in properties, "Cannot change group of external network with prepared connections: %s", self.name)
		Connector.configure(self, properties)
		if self.getNetworkGroup() == "auto":
			self.setNetworkGroup(None)
		self.save()		
Пример #2
0
	def getPrepareTasks(self):
		taskset = Connector.getPrepareTasks(self)
		assign_resources = tasks.Task("assign-resources", self._assignResources)
		tinc_tasks = tinc.getPrepareNetworkTasks(self._endpoints(), self.type)
		tinc_tasks.after(assign_resources)
		taskset.add([assign_resources, tinc_tasks])
		return self._adaptTaskset(taskset)
Пример #3
0
Файл: vpn.py Проект: m3z/ToMaTo
	def getDestroyTasks(self):
		taskset = Connector.getDestroyTasks(self)
		tinc_tasks = tinc.getDestroyNetworkTasks(self._endpoints(), self.mode)
		unassign_resources = tasks.Task("destroy-bridges", self._unassignResources, after=tinc_tasks)
		taskset.add([tinc_tasks, unassign_resources])
		taskset.add(tasks.Task("destroy-external-access", self._destroyExternalAccess))
		return self._adaptTaskset(taskset)
Пример #4
0
Файл: vpn.py Проект: m3z/ToMaTo
	def getStopTasks(self):
		taskset = Connector.getStopTasks(self)
		taskset.add(tinc.getStopNetworkTasks(self._endpoints(), self.mode))
		for con in self.connectionSetAll():
			taskset.add(con.upcast().getStopTasks().prefix(con))
		taskset.add(tasks.Task("stop-external-access", self._stopExternalAccess))
		return self._adaptTaskset(taskset)
Пример #5
0
	def getCapabilities(self, user):
		capabilities = Connector.getCapabilities(self, user)
		capabilities["configure"].update({
			"network_type": self.state == State.CREATED,
			"network_group": self.state == State.CREATED,
		})
		return capabilities
Пример #6
0
Файл: vpn.py Проект: m3z/ToMaTo
	def getPrepareTasks(self):
		taskset = Connector.getPrepareTasks(self)
		assign_resources = tasks.Task("assign-resources", self._assignResources)
		tinc_tasks = tinc.getPrepareNetworkTasks(self._endpoints(), self.mode)
		tinc_tasks.after(assign_resources)
		taskset.add([assign_resources, tinc_tasks])
		taskset.add(tasks.Task("prepare-external-access", self._prepareExternalAccess))
		return self._adaptTaskset(taskset)
Пример #7
0
	def _runAction(self, action, attrs, direct):
		if action == "download_capture":
			interface = self.topology.interfacesGet(attrs["iface"])
			fault.check(interface, "No such interface: %s", attrs["iface"])
			con = interface.connection.upcast()
			assert con.connector.id == self.id
			return con.downloadCaptureUri()
		else:
			return Connector._runAction(self, action, attrs, direct)			
Пример #8
0
Файл: vpn.py Проект: m3z/ToMaTo
	def _runAction(self, action, attrs, direct):
		if action == "download_capture":
			interface = self.topology.interfacesGet(attrs["iface"])
			fault.check(interface, "No such interface: %s", attrs["iface"])
			con = interface.connection.upcast()
			assert con.connector.id == self.id
			return tasks.runTask(tasks.Task("%s-download-capture-uri" % self, con.downloadCaptureUri, kwargs={"onlyLatest": "onlyLatest" in attrs and attrs["onlyLatest"]}))		
		else:
			return Connector._runAction(self, action, attrs, direct)			
Пример #9
0
	def getStartTasks(self):
		taskset = Connector.getStartTasks(self)
		tinc_tasks = tinc.getStartNetworkTasks(self._endpoints(), self.type)
		taskset.add(tinc_tasks)		
		for con in self.connectionSetAll():
			ts = con.upcast().getStartTasks()
			ts.prefix(con).after(tinc_tasks)
			taskset.add(ts)
		return self._adaptTaskset(taskset)
Пример #10
0
Файл: vpn.py Проект: m3z/ToMaTo
	def toDict(self, auth):
		res = Connector.toDict(self, auth)
		res["attrs"].update(external_access=self.getExternalAccess(), mode=self.mode)
		if auth:
			if self.getExternalAccess():
				if self.getExternalAccessPort():
					res["attrs"]["external_access_host"] = self.getExternalAccessHost().name
					res["attrs"]["external_access_port"] = self.getExternalAccessPort()
					res["attrs"]["external_access_password"] = self.getExternalAccessPassword()
		return res
Пример #11
0
	def getCapabilities(self, user):
		capabilities = Connector.getCapabilities(self, user)
		capabilities["configure"].update({
			"external_access": self.state == State.CREATED,
		})
		capabilities["action"].update({
			"download_capture": self.state != State.CREATED,
		})
		capabilities.update(other={
			"external_access": self.state == State.STARTED and self.getExternalAccess()
		})
		return capabilities
Пример #12
0
Файл: vpn.py Проект: m3z/ToMaTo
	def getStartTasks(self):
		taskset = Connector.getStartTasks(self)
		tinc_tasks = tinc.getStartNetworkTasks(self._endpoints(), self.mode)
		taskset.add(tinc_tasks)
		tinc_tasks_dummy = tasks.Task("tinc_started")
		tinc_tasks_dummy.after(tinc_tasks)
		taskset.add(tinc_tasks_dummy)
		for con in self.connectionSetAll():
			ts = con.upcast().getStartTasks()
			ts.prefix(con).after(tinc_tasks_dummy)
			taskset.add(ts)
		taskset.add(tasks.Task("start-external-access", self._startExternalAccess))
		return self._adaptTaskset(taskset)
Пример #13
0
	def getPrepareTasks(self):
		taskset = Connector.getPrepareTasks(self)
		taskset.add(tasks.Task("select-network", self._selectUsedNetwork))
		return self._adaptTaskset(taskset)
Пример #14
0
	def getCapabilities(self, user):
		capabilities = Connector.getCapabilities(self, user)
		capabilities["action"].update({
			"download_capture": self.state != State.CREATED,
		})
		return capabilities
Пример #15
0
	def getDestroyTasks(self):
		taskset = Connector.getDestroyTasks(self)
		tinc_tasks = tinc.getDestroyNetworkTasks(self._endpoints(), self.type)
		unassign_resources = tasks.Task("unassign-resources", self._unassignResources, after=tinc_tasks)
		taskset.add([tinc_tasks, unassign_resources])
		return self._adaptTaskset(taskset)
Пример #16
0
	def configure(self, properties):
		Connector.configure(self, properties)
Пример #17
0
Файл: vpn.py Проект: m3z/ToMaTo
	def configure(self, properties):
		Connector.configure(self, properties)
		if "external_access" in properties:
			self.setExternalAccess(properties["external_access"])
		if "mode" in properties:
			self.setMode(properties["mode"])
Пример #18
0
	def getStopTasks(self):
		taskset = Connector.getStopTasks(self)
		taskset.add(tinc.getStopNetworkTasks(self._endpoints(), self.type))
		for con in self.connectionSetAll():
			taskset.add(con.upcast().getStopTasks().prefix(con))
		return self._adaptTaskset(taskset)
Пример #19
0
	def toDict(self, auth):
		res = Connector.toDict(self, auth)
		res["attrs"].update(network_type=self.network_type, network_group=self.network_group)
		return res
Пример #20
0
	def getIdUsage(self, host):
		ids = Connector.getIdUsage(self, host)
		if self.getExternalAccessHost() == host:
			ids["port"] = ids.get("port", set()) | set((self.getExternalAccessPort(),))
		return ids
Пример #21
0
	def getDestroyTasks(self):
		taskset = Connector.getDestroyTasks(self)
		taskset.add(tasks.Task("unselect-network", self._unselectUsedNetwork))
		return self._adaptTaskset(taskset)