def mount(self, mountpoint, remotepath, timeout = 0): try: nfs.soft_mount( mountpoint, self.remoteserver, remotepath, self.transport, timeout=timeout, nfsversion=self.nfsversion) except nfs.NfsException, exc: raise xs_errors.XenError('NFSMount', opterr=exc.errstr)
def test_soft_mount(self, pread, check_server_service, makedirs): nfs.soft_mount('mountpoint', 'remoteserver', 'remotepath', 'transport', timeout=None) check_server_service.assert_called_once_with('remoteserver') pread.assert_called_once_with(self.get_soft_mount_pread('mount.nfs', '3'))
def mount(self, mountpoint, remotepath, timeout=None, retrans=None): try: nfs.soft_mount( mountpoint, self.remoteserver, remotepath, self.transport, useroptions=self.options, timeout=timeout, nfsversion=self.nfsversion, retrans=retrans) except nfs.NfsException, exc: raise xs_errors.XenError('NFSMount', opterr=exc.errstr)
def test_soft_mount(self, pread, makedirs): nfs.soft_mount('mountpoint', 'remoteserver', 'remotepath', 'transport', timeout=0) pread.assert_called_once_with( self.get_soft_mount_pread('mount.nfs', '3'))
def test_soft_mount_ipv6(self, pread, check_server_service, makedirs): nfs.soft_mount('mountpoint', 'remoteserver', 'remotepath', 'tcp6', timeout=None) check_server_service.assert_called_once_with('remoteserver') pread.assert_called_once_with( self.get_soft_mount_pread('mount.nfs', '3', True))
def test_soft_mount_nfsversion_4(self, pread, check_server_service, makedirs): nfs.soft_mount('mountpoint', 'remoteserver', 'remotepath', 'transport', timeout=None, nfsversion='4') check_server_service.assert_called_once_with('remoteserver') pread.assert_called_with(self.get_soft_mount_pread('mount.nfs4', '4'))
def mount(self, mountpoint, remotepath, timeout = 0): try: if self.dconf.has_key(PROBEVERSION): nfs.soft_mount( mountpoint, self.remoteserver, remotepath, self.transport, timeout=timeout) else: nfs.soft_mount( mountpoint, self.remoteserver, remotepath, self.transport, timeout=timeout, nfsversion=self.nfsversion) except nfs.NfsException, exc: raise xs_errors.XenError('NFSMount', opterr=exc.errstr)
def mount(self, mountpoint, remotepath): try: nfs.soft_mount(mountpoint, self.remoteserver, remotepath, self.transport) except nfs.NfsException, exc: raise xs_errors.XenError('NFSMount', opterr=exc.errstr)
def attach(self, sr_uuid): """Std. attach""" # Very-Legacy mode means the ISOs are in the local fs - so no need to attach. if 'legacy_mode' in self.dconf: # Verify path exists if not os.path.exists(self.mountpoint): raise xs_errors.XenError('ISOLocalPath') return # Check whether we're already mounted if self._checkmount(): return # Create the mountpoint if it's not already there if not util.isdir(self.mountpoint): util.makedirs(self.mountpoint) mountcmd = [] location = util.to_plain_string(self.dconf['location']) # TODO: Have XC standardise iso type string protocol = 'nfs_iso' options = '' if 'type' in self.dconf: protocol = self.dconf['type'] elif ":/" not in location: protocol = 'cifs' if 'options' in self.dconf: options = self.dconf['options'].split(' ') if protocol == 'cifs': options = filter(lambda x: x != "", options) else: options = self.getNFSOptions(options) # SMB options are passed differently for create via # XC/xe sr-create and create via xe-mount-iso-sr # In both cases check if SMB version is passed are not. # If not use self.smbversion. if protocol == 'cifs': if 'type' in self.dconf: # Create via XC or sr-create # Check for username and password mountcmd = ["mount.cifs", location, self.mountpoint] if 'vers' in self.dconf: self.is_smbversion_specified = True self.smbversion = self.dconf['vers'] util.SMlog("self.dconf['vers'] = %s" % self.dconf['vers']) self.appendCIFSMountOptions(mountcmd) else: # Creation via xe-mount-iso-sr try: mountcmd = ["mount", location, self.mountpoint] if options and options[0] == '-o': pos = options[1].find('vers=') if pos == -1: options[1] += ',' + self.getSMBVersion() else: self.smbversion = self.getSMBVersionFromOptions( options[1]) self.is_smbversion_specified = True else: raise ValueError mountcmd.extend(options) except ValueError: raise xs_errors.XenError('ISOInvalidXeMountOptions') # Check the validity of 'smbversion'. # Raise an exception for any invalid version. if self.smbversion not in [SMB_VERSION_1, SMB_VERSION_3]: raise xs_errors.XenError('ISOInvalidSMBversion') # Attempt mounting try: if protocol == 'nfs_iso': # For NFS, do a soft mount with tcp as protocol. Since ISO SR is # going to be r-only, a failure in nfs link can be reported back # to the process waiting. serv_path = location.split(':') util._testHost(serv_path[0], NFSPORT, 'NFSTarget') nfs.soft_mount(self.mountpoint, serv_path[0], serv_path[1], 'tcp', useroptions=options, nfsversion=self.nfsversion) else: smb3_fail_reason = None if self.smbversion in SMB_VERSION_3: util.SMlog('ISOSR mount over smb 3.0') try: self.mountOverSMB(mountcmd) except util.CommandException as inst: if not self.is_smbversion_specified: util.SMlog('Retrying ISOSR mount over smb 1.0') smb3_fail_reason = inst.reason # mountcmd is constructed such that the last two # items will contain -o argument and its value. del mountcmd[-2:] self.smbversion = SMB_VERSION_1 if not options: self.appendCIFSMountOptions(mountcmd) else: if options[0] == '-o': # regex can be used here since we have # already validated version entry options[1] = re.sub( 'vers=3.0', 'vers=1.0', options[1]) mountcmd.extend(options) self.mountOverSMB(mountcmd) else: raise xs_errors.XenError('ISOMountFailure', opterr=inst.reason) else: util.SMlog('ISOSR mount over smb 1.0') self.mountOverSMB(mountcmd) except util.CommandException as inst: if not self.is_smbversion_specified: raise xs_errors.XenError('ISOMountFailure', opterr=smb3_fail_reason) else: raise xs_errors.XenError('ISOMountFailure', opterr=inst.reason) # Check the iso_path is accessible if not self._checkmount(): self.detach(sr_uuid) raise xs_errors.XenError('ISOSharenameFailure')
def test_soft_mount_nfsversion_4(self, pread, makedirs): nfs.soft_mount('mountpoint', 'remoteserver', 'remotepath', 'transport', timeout=0, nfsversion='4') pread.assert_called_once_with(self.get_soft_mount_pread('mount.nfs4', '4'))