def load(self, sr_uuid): self.ops_exclusive = FileSR.OPS_EXCLUSIVE self.lock = Lock(vhdutil.LOCK_TYPE_SR, self.uuid) self.sr_vditype = SR.DEFAULT_TAP self.driver_config = DRIVER_CONFIG if not self.dconf.has_key('server'): raise xs_errors.XenError('ConfigServerMissing') self.remoteserver = self.dconf['server'] self.nosubdir = False if self.sr_ref and self.session is not None: self.sm_config = self.session.xenapi.SR.get_sm_config(self.sr_ref) else: self.sm_config = self.srcmd.params.get('sr_sm_config') or {} self.nosubdir = self.sm_config.get('nosubdir') == "true" if self.dconf.has_key('serverpath'): self.remotepath = os.path.join(self.dconf['serverpath'], not self.nosubdir and sr_uuid or "").encode('utf-8') self.path = os.path.join(SR.MOUNT_BASE, sr_uuid) # Handle optional dconf attributes self.transport = DEFAULT_TRANSPORT if self.dconf.has_key('useUDP') and self.dconf['useUDP'] == 'true': self.transport = "udp" self.nfsversion = nfs.validate_nfsversion(self.dconf.get('nfsversion')) if 'options' in self.dconf: self.options = self.dconf['options'] else: self.options = ''
def load(self, sr_uuid): self.ops_exclusive = FileSR.OPS_EXCLUSIVE self.lock = Lock(vhdutil.LOCK_TYPE_SR, self.uuid) self.sr_vditype = SR.DEFAULT_TAP self.driver_config = DRIVER_CONFIG if not self.dconf.has_key('server'): raise xs_errors.XenError('ConfigServerMissing') self.remoteserver = self.dconf['server'] self.nosubdir = False if self.sr_ref and self.session is not None : self.sm_config = self.session.xenapi.SR.get_sm_config(self.sr_ref) else: self.sm_config = self.srcmd.params.get('sr_sm_config') or {} self.nosubdir = self.sm_config.get('nosubdir') == "true" if self.dconf.has_key('serverpath'): self.remotepath = os.path.join(self.dconf['serverpath'], not self.nosubdir and sr_uuid or "").encode('utf-8') self.path = os.path.join(SR.MOUNT_BASE, sr_uuid) # Handle optional dconf attributes self.transport = DEFAULT_TRANSPORT if self.dconf.has_key('useUDP') and self.dconf['useUDP'] == 'true': self.transport = "udp" self.nfsversion = nfs.validate_nfsversion(self.dconf.get('nfsversion')) self._check_o_direct()
def load(self, sr_uuid): """Initialises the SR""" # First of all, check we've got the correct keys in dconf if 'location' not in self.dconf: raise xs_errors.XenError('ConfigLocationMissing') # Construct the path we're going to mount under: if "legacy_mode" in self.dconf: self.mountpoint = util.to_plain_string(self.dconf['location']) else: # Verify the target address self._checkTargetStr(self.dconf['location']) self.mountpoint = os.path.join(SR.MOUNT_BASE, sr_uuid) # Add on the iso_path value if there is one if "iso_path" in self.dconf: iso_path = util.to_plain_string(self.dconf['iso_path']) if iso_path.startswith("/"): iso_path = iso_path[1:] self.path = os.path.join(self.mountpoint, iso_path) else: self.path = self.mountpoint # Handle optional dconf attributes self.nfsversion = nfs.validate_nfsversion(self.dconf.get('nfsversion')) # Fill the required SMB version self.smbversion = SMB_VERSION_3 # Check if smb version is specified from client self.is_smbversion_specified = False # Some info we need: self.sr_vditype = 'phy'
def test_validate_nfsversion_valid(self): for thenfsversion in ['3', '4']: self.assertEquals(nfs.validate_nfsversion(thenfsversion), thenfsversion)
def test_validate_nfsversion_default(self): for thenfsversion in ['', None]: self.assertEquals(nfs.validate_nfsversion(thenfsversion), '3')