Skip to content

Commit f28700b

Browse files
committed
update script with missing method in built in scripts SR.py and make it py3 compatible
1 parent 35a30f2 commit f28700b

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

  • scripts/vm/hypervisor/xenserver/xcpserver83

scripts/vm/hypervisor/xenserver/xcpserver83/NFSSR.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@ def load(self, sr_uuid):
6666
self.ops_exclusive = FileSR.OPS_EXCLUSIVE
6767
self.lock = Lock(vhdutil.LOCK_TYPE_SR, self.uuid)
6868
self.sr_vditype = SR.DEFAULT_TAP
69-
if not self.dconf.has_key('server'):
69+
if 'server' not in self.dconf:
7070
raise xs_errors.XenError('ConfigServerMissing')
7171
self.remoteserver = self.dconf['server']
7272
self.path = os.path.join(SR.MOUNT_BASE, sr_uuid)
7373

7474
# Test for the optional 'nfsoptions' dconf attribute
7575
self.transport = DEFAULT_TRANSPORT
76-
if self.dconf.has_key('useUDP') and self.dconf['useUDP'] == 'true':
76+
if 'useUDP' in self.dconf and self.dconf['useUDP'] == 'true':
7777
self.transport = "udp"
7878

7979

8080
def validate_remotepath(self, scan):
81-
if not self.dconf.has_key('serverpath'):
81+
if 'serverpath' not in self.dconf:
8282
if scan:
8383
try:
8484
self.scan_exports(self.dconf['server'])
@@ -255,6 +255,22 @@ def clone(self, sr_uuid, vdi_uuid):
255255
os.utime(self.sr.path, (timestamp_after, timestamp_after))
256256
return ret
257257

258+
def _isvalidpathstring(self, path):
259+
if not path.startswith("/"):
260+
return False
261+
l = self._splitstring(path)
262+
for char in l:
263+
if char.isalpha():
264+
continue
265+
elif char.isdigit():
266+
continue
267+
elif char in ['/','-','_','.',':']:
268+
continue
269+
else:
270+
return False
271+
return True
272+
273+
258274

259275
if __name__ == '__main__':
260276
SRCommand.run(NFSSR, DRIVER_INFO)

0 commit comments

Comments
 (0)