Esempio n. 1
0
	def _applyShare(self, data, callback):
		Log.d()
		if data['active']:
			mountpoint = AutoMount.MOUNT_BASE + data['sharename']
			Log.i("mountpoint: %s" %(mountpoint,))
			createDir(mountpoint)
			tmpsharedir = data['sharedir'].replace(" ", "\\040")

			if data['mounttype'] == 'nfs':
				opts = self.sanitizeOptions(data['options'].split(','))
				remote = '%s:%s' % (data['ip'], tmpsharedir)
				harddiskmanager.modifyFstabEntry(remote, mountpoint, mode="add_deactivated", extopts=opts, fstype="nfs")

			elif data['mounttype'] == 'cifs':
				opts = self.sanitizeOptions(data['options'].split(','), cifs=True)
				if data['password']:
					opts.extend([
						'username=%s' % (data['username']),
						'password=%s' % (data['password']),
						])
				else:
					opts.extend(['guest'])
				remote = "//%s/%s" % (data['ip'], tmpsharedir)
				harddiskmanager.modifyFstabEntry(remote, mountpoint, mode="add_deactivated", extopts=opts, fstype="cifs")
		else:
			mountpoint = AutoMount.MOUNT_BASE + data['sharename']
			self.removeMount(mountpoint)
		if callback:
			callback(True)
Esempio n. 2
0
	def _applyShare(self, data, callback):
		Log.i("activeMounts: %s" %(self._numActive,))
		if data['active']:
			mountpoint = AutoMount.MOUNT_BASE + data['sharename']
			if os_path.exists(mountpoint) is False:
				createDir(mountpoint)
			tmpsharedir = data['sharedir'].replace(" ", "\\ ").replace("$", "\\$")

			if data['mounttype'] == 'nfs':
				opts = self.sanitizeOptions(data['options'].split(','))
				remote = '%s:/%s' % (data['ip'], tmpsharedir)
				harddiskmanager.modifyFstabEntry(remote, mountpoint, mode="add_deactivated", extopts=opts, fstype="nfs")

			elif data['mounttype'] == 'cifs':
				opts = self.sanitizeOptions(data['options'].split(','), cifs=True)
				password = data['password']
				username = data['username'].replace(" ", "\\ ")
				if password:
					username = data['username'].replace(" ", "\\ ")
					opts.extend([
						'username=%s' % (data['username']),
						'password=%s' % (data['password']),
						])
				else:
					opts.extend(['guest'])
				opts.extend(['sec=ntlmv2'])
				remote = "//%s/%s" % (data['ip'], tmpsharedir)
				harddiskmanager.modifyFstabEntry(remote, mountpoint, mode="add_deactivated", extopts=opts, fstype="cifs")
		else:
			mountpoint = AutoMount.MOUNT_BASE + data['sharename']
			self.removeMount(mountpoint)
		if callback:
			callback(True)
Esempio n. 3
0
	def _applyShare(self, data, callback):
		Log.d()
		if data['active']:
			mountpoint = AutoMount.MOUNT_BASE + data['sharename']
			Log.i("mountpoint: %s" %(mountpoint,))
			createDir(mountpoint)
			tmpsharedir = data['sharedir'].replace(" ", "\\040")

			if data['mounttype'] == 'nfs':
				opts = self.sanitizeOptions(data['options'].split(','))
				remote = '%s:%s' % (data['ip'], tmpsharedir)
				harddiskmanager.modifyFstabEntry(remote, mountpoint, mode="add_deactivated", extopts=opts, fstype="nfs")

			elif data['mounttype'] == 'cifs':
				opts = self.sanitizeOptions(data['options'].split(','), cifs=True)
				if data['password']:
					opts.extend([
						'username=%s' % (data['username']),
						'password=%s' % (data['password']),
						])
				else:
					opts.extend(['guest'])
				remote = "//%s/%s" % (data['ip'], tmpsharedir)
				harddiskmanager.modifyFstabEntry(remote, mountpoint, mode="add_deactivated", extopts=opts, fstype="cifs")
		else:
			mountpoint = AutoMount.MOUNT_BASE + data['sharename']
			self.removeMount(mountpoint)
		if callback:
			callback(True)
Esempio n. 4
0
	def removeMount(self, mountpoint, callback=None):
		res = False
		entry = Util.findInFstab(src=None, dst=mountpoint)
		if entry:
			sharename=os_path.basename(mountpoint)
			if sharename in self._mounts:
				del self._mounts[sharename]
			self._unmount(mountpoint)
			harddiskmanager.modifyFstabEntry(entry['src'], entry['dst'], mode="remove")
			harddiskmanager.removeMountedPartition(mountpoint)
			res = True
		if callback is not None:
			callback(res)
Esempio n. 5
0
 def deactivateMount(self, mountpoint, callback=None):
     logger.debug("mountpoint: %s", mountpoint)
     res = False
     entry = Util.findInFstab(src=None, dst=mountpoint)
     if entry:
         self._unmount(mountpoint)
         harddiskmanager.modifyFstabEntry(entry["src"],
                                          entry["dst"],
                                          mode="remove")
         harddiskmanager.removeMountedPartition(mountpoint)
         res = True
     if callback is not None:
         callback(res)
Esempio n. 6
0
	def removeMount(self, mountpoint, callback=None):
		res = False
		entry = Util.findInFstab(src=None, dst=mountpoint)
		if entry:
			sharename=os_path.basename(mountpoint)
			if sharename in self._mounts:
				del self._mounts[sharename]
			self._unmount(mountpoint)
			harddiskmanager.modifyFstabEntry(entry['src'], entry['dst'], mode="remove")
			harddiskmanager.removeMountedPartition(mountpoint)
			res = True
		if callback is not None:
			callback(res)
Esempio n. 7
0
    def _applyShare(self, data, callback):
        Log.i("activeMounts: %s" % (self._numActive, ))
        if data['active']:
            mountpoint = AutoMount.MOUNT_BASE + data['sharename']
            if os_path.exists(mountpoint) is False:
                createDir(mountpoint)
            tmpsharedir = data['sharedir'].replace(" ",
                                                   "\\ ").replace("$", "\\$")

            if data['mounttype'] == 'nfs':
                opts = self.sanitizeOptions(data['options'].split(','))
                remote = '%s:/%s' % (data['ip'], tmpsharedir)
                harddiskmanager.modifyFstabEntry(remote,
                                                 mountpoint,
                                                 mode="add_deactivated",
                                                 extopts=opts,
                                                 fstype="nfs")

            elif data['mounttype'] == 'cifs':
                opts = self.sanitizeOptions(data['options'].split(','),
                                            cifs=True)
                password = data['password']
                username = data['username'].replace(" ", "\\ ")
                if password:
                    username = data['username'].replace(" ", "\\ ")
                    opts.extend([
                        'username=%s' % (data['username']),
                        'password=%s' % (data['password']),
                    ])
                else:
                    opts.extend(['guest'])
                opts.extend(['sec=ntlmv2'])
                remote = "//%s/%s" % (data['ip'], tmpsharedir)
                harddiskmanager.modifyFstabEntry(remote,
                                                 mountpoint,
                                                 mode="add_deactivated",
                                                 extopts=opts,
                                                 fstype="cifs")
        else:
            mountpoint = AutoMount.MOUNT_BASE + data['sharename']
            self.removeMount(mountpoint)
        if callback:
            callback(True)
Esempio n. 8
0
    def _applyShare(self, data, callback=None):
        logger.debug("...")
        if data["active"]:
            mountpoint = AutoMount.MOUNT_BASE + data["sharename"]
            logger.info("mountpoint: %s", mountpoint)
            createDir(mountpoint)
            tmpsharedir = data["sharedir"].replace(" ", "\\040")

            if data["mounttype"] == "nfs":
                opts = self.sanitizeOptions(data["options"].split(","))
                remote = "%s:%s" % (data["ip"], tmpsharedir)
                harddiskmanager.modifyFstabEntry(remote,
                                                 mountpoint,
                                                 mode="add_deactivated",
                                                 extopts=opts,
                                                 fstype="nfs")

            elif data["mounttype"] == "cifs":
                opts = self.sanitizeOptions(data["options"].split(","),
                                            cifs=True)
                if data["password"]:
                    opts.extend([
                        "username=%s" % (data["username"]),
                        "password=%s" % (data["password"])
                    ])
                else:
                    opts.extend(["guest"])
                remote = "//%s/%s" % (data["ip"], tmpsharedir)
                harddiskmanager.modifyFstabEntry(remote,
                                                 mountpoint,
                                                 mode="add_deactivated",
                                                 extopts=opts,
                                                 fstype="cifs")
        else:
            mountpoint = AutoMount.MOUNT_BASE + data["sharename"]
            self.deactivateMount(mountpoint)
        if callback:
            callback(True)