コード例 #1
0
ファイル: NET.py プロジェクト: lprot/e2openplugin-OpenWebif
	def removeCallback(self, data):
		if data is True:
			iAutoMount.writeMountsConfig()
			self.result["result"] = True
			self.result["message"] = "mount removed"
		if self.callback is not None:
			self.callback()
コード例 #2
0
ファイル: NET.py プロジェクト: zozman21/OpenWebif
	def P_renamemount(self):
		param = self.buildCommand('sharename,newsharename')
		sharename = param["sharename"]
		if sharename is None:
			return self.failed("No sharename given!")
		newsharename = param["newsharename"]
		if newsharename is None:
			return self.failed("No newsharename given!")

		mounts = iAutoMount.getMountsList()

		if newsharename in mounts:
			return self.failed("newsharename already exists")

		if sharename in mounts:
			try:
				iAutoMount.setMountsAttribute(sharename, "sharename", newsharename)
				iAutoMount.writeMountsConfig()
				self.result["result"] = True
				self.result["message"] = "mount changed"
			except Exception as error:
				self.result["message"] = "mount not changed"
				self.result["error"] = error
		else:
			return self.failed("sharename not exists")
コード例 #3
0
	def removeCallback(self, data):
		if data is True:
			iAutoMount.writeMountsConfig()
			self.result["result"] = True
			self.result["message"] = "mount removed"
		if self.callback is not None:
			self.callback()
コード例 #4
0
	def P_renamemount(self):
		param = self.buildCommand('sharename,newsharename')
		sharename = param["sharename"]
		if sharename is None:
			return self.failed("No sharename given!")
		newsharename = param["newsharename"]
		if newsharename is None:
			return self.failed("No newsharename given!")

		mounts = iAutoMount.getMountsList()

		if newsharename in mounts:
			return self.failed("newsharename already exists")

		if sharename in mounts:
			try:
				iAutoMount.setMountsAttribute(sharename, "sharename", newsharename)
				iAutoMount.writeMountsConfig()
				self.result["result"] = True
				self.result["message"] = "mount changed"
			except Exception, error:
				self.result["message"] = "mount not changed"
				self.result["error"] = error
コード例 #5
0
ファイル: NET.py プロジェクト: lprot/e2openplugin-OpenWebif
	def insertupdatemount(self, addnew):

		param = self.buildCommand('sharedir,sharename,mounttype,ip,username,active,username,password,hdd_replacement,options,mountusing')
		ip = param["ip"]
		if ip is None:
			return self.failed("No ip given!")
		sharedir = param["sharedir"]
		if sharedir is None:
			return self.failed("No sharedir given!")
		sharename = param["sharename"]
		if sharename is None:
			return self.failed("No sharename given!")
		mounttype = param["mounttype"]
		if mounttype is None:
			mounttype = "nfs"
		if mounttype not in ('cifs', 'nfs'):
			return self.failed("wrong mounttype given!")

		options = param["options"]
		if options is None:
			if mounttype == "nfs":
				options = "rw,nolock,soft"
			else:
				options = "rw,utf8"
		mountusing = param["mountusing"]
		if mountusing is None:
			mountusing = "autofs"
		hdd_replacement = param["hdd_replacement"]
		if hdd_replacement is None:
			hdd_replacement = False
		if hdd_replacement == 'True':
			hdd_replacement = True
		active = param["active"]
		if active is None:
			active = False
		username = param["username"]
		if username is None:
			username = ""
		password = param["password"]
		if password is None:
			password = ""

		mounts = iAutoMount.getMountsList()

		if addnew is True:
			if sharename in mounts:
				return self.failed("sharename already exists")
			else:
				try:
					data = {'isMounted': False}
					data['active'] = active
					data['ip'] = ip
					data['sharename'] = re_sub("\W", "", sharename)
					if sharedir.startswith("/"):
						data['sharedir'] = sharedir[1:]
					else:
						data['sharedir'] = sharedir
					data['options'] = options
					data['mounttype'] = mounttype
					data['username'] = username
					data['password'] = password
					data['hdd_replacement'] = hdd_replacement
					data['mountusing'] = mountusing
					iAutoMount.automounts[sharename] = data
					iAutoMount.writeMountsConfig()
					self.result["result"] = True
					self.result["message"] = "mount added"
				except Exception, error:
					self.result["message"] = "mount not added"
					self.result["error"] = error
コード例 #6
0
ファイル: NET.py プロジェクト: lprot/e2openplugin-OpenWebif
					data['password'] = password
					data['hdd_replacement'] = hdd_replacement
					data['mountusing'] = mountusing
					iAutoMount.automounts[sharename] = data
					iAutoMount.writeMountsConfig()
					self.result["result"] = True
					self.result["message"] = "mount added"
				except Exception, error:
					self.result["message"] = "mount not added"
					self.result["error"] = error
		else:
			if sharename in mounts:
				try:
					iAutoMount.setMountsAttribute(sharename, "active", active)
					iAutoMount.setMountsAttribute(sharename, "ip", ip)
					iAutoMount.setMountsAttribute(sharename, "sharedir", sharedir)
					iAutoMount.setMountsAttribute(sharename, "mounttype", mounttype)
					iAutoMount.setMountsAttribute(sharename, "options", options)
					iAutoMount.setMountsAttribute(sharename, "username", username)
					iAutoMount.setMountsAttribute(sharename, "password", password)
					iAutoMount.setMountsAttribute(sharename, "hdd_replacement", hdd_replacement)
					iAutoMount.setMountsAttribute(sharename, "mountusing", mountusing)
					iAutoMount.writeMountsConfig()
					self.result["result"] = True
					self.result["message"] = "mount changed"
				except Exception, error:
					self.result["message"] = "mount not changed"
					self.result["error"] = error
			else:
				return self.failed("sharename not exists")
コード例 #7
0
	def insertupdatemount(self, addnew):

		param = self.buildCommand('sharedir,sharename,mounttype,ip,username,active,username,password,hdd_replacement,options,mountusing')
		ip = param["ip"]
		if ip is None:
			return self.failed("No ip given!")
		sharedir = param["sharedir"]
		if sharedir is None:
			return self.failed("No sharedir given!")
		sharename = param["sharename"]
		if sharename is None:
			return self.failed("No sharename given!")
		mounttype = param["mounttype"]
		if mounttype is None:
			mounttype = "nfs"
		if mounttype not in ('cifs', 'nfs'):
			return self.failed("wrong mounttype given!")

		options = param["options"]
		if options is None:
			if mounttype == "nfs":
				options = "rw,nolock,soft"
			else:
				options = "rw,utf8"
		mountusing = param["mountusing"]
		if mountusing is None:
			mountusing = "autofs"
		hdd_replacement = param["hdd_replacement"]
		if hdd_replacement is None:
			hdd_replacement = False
		if hdd_replacement == 'True':
			hdd_replacement = True
		active = param["active"]
		if active is None:
			active = False
		username = param["username"]
		if username is None:
			username = ""
		password = param["password"]
		if password is None:
			password = ""

		mounts = iAutoMount.getMountsList()

		if addnew is True:
			if sharename in mounts:
				return self.failed("sharename already exists")
			else:
				try:
					data = {'isMounted': False}
					data['active'] = active
					data['ip'] = ip
					data['sharename'] = re_sub("\W", "", sharename)
					if sharedir.startswith("/"):
						data['sharedir'] = sharedir[1:]
					else:
						data['sharedir'] = sharedir
					data['options'] = options
					data['mounttype'] = mounttype
					data['username'] = username
					data['password'] = password
					data['hdd_replacement'] = hdd_replacement
					data['mountusing'] = mountusing
					iAutoMount.automounts[sharename] = data
					iAutoMount.writeMountsConfig()
					self.result["result"] = True
					self.result["message"] = "mount added"
				except Exception, error:
					self.result["message"] = "mount not added"
					self.result["error"] = error
コード例 #8
0
					data['password'] = password
					data['hdd_replacement'] = hdd_replacement
					data['mountusing'] = mountusing
					iAutoMount.automounts[sharename] = data
					iAutoMount.writeMountsConfig()
					self.result["result"] = True
					self.result["message"] = "mount added"
				except Exception, error:
					self.result["message"] = "mount not added"
					self.result["error"] = error
		else:
			if sharename in mounts:
				try:
					iAutoMount.setMountsAttribute(sharename, "active", active)
					iAutoMount.setMountsAttribute(sharename, "ip", ip)
					iAutoMount.setMountsAttribute(sharename, "sharedir", sharedir)
					iAutoMount.setMountsAttribute(sharename, "mounttype", mounttype)
					iAutoMount.setMountsAttribute(sharename, "options", options)
					iAutoMount.setMountsAttribute(sharename, "username", username)
					iAutoMount.setMountsAttribute(sharename, "password", password)
					iAutoMount.setMountsAttribute(sharename, "hdd_replacement", hdd_replacement)
					iAutoMount.setMountsAttribute(sharename, "mountusing", mountusing)
					iAutoMount.writeMountsConfig()
					self.result["result"] = True
					self.result["message"] = "mount changed"
				except Exception, error:
					self.result["message"] = "mount not changed"
					self.result["error"] = error
			else:
				return self.failed("sharename not exists")