-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRBDSR7.patch
87 lines (78 loc) · 4.11 KB
/
RBDSR7.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
--- a/RBDSR.py 2016-05-30 14:36:09.000000000 +1000
+++ b/RBDSR.py 2016-05-30 14:38:14.000000000 +1000
@@ -1,12 +1,12 @@
#!/usr/bin/python
-# Following ISCSISR.py as an example, RBDSR provides LVHD SR over rbd block device.
+# Following BaseISCSI.py as an example, RBDSR provides LVHD SR over rbd block device.
# created by Mark Starikov(mr.mark.starikov@gmail.com)
-import ISCSISR, VDI, scsiutil, SR, SRCommand, util, xs_errors, xmlrpclib, LUNperVDI
+import BaseISCSI, VDI, scsiutil, SR, SRCommand, util, xs_errors, xmlrpclib, LUNperVDI
import socket, os, copy, sys, pxssh
from xml.dom.minidom import parseString
-''' start of modified parameters, pretty much direct copy from ISCSISR.py '''
+''' start of modified parameters, pretty much direct copy from BaseISCSI.py '''
CAPABILITIES = ["SR_PROBE","VDI_CREATE","VDI_DELETE","VDI_ATTACH",
"VDI_DETACH", "VDI_INTRODUCE"]
@@ -42,9 +42,9 @@
ISCSI_PROCNAME = "iscsi_tcp"
# changing default port to monitor port
DEFAULT_PORT = 6789
-''' end of modified definitions of paramters like in ISCSISR.py '''
+''' end of modified definitions of paramters like in BaseISCSI.py '''
-class RBDSR(ISCSISR.ISCSISR):
+class RBDSR(BaseISCSI.BaseISCSISR):
def handles(type):
if type == "rbd":
return True
@@ -108,7 +108,7 @@
pool = "*"
map.append((real_address+":"+self.dconf['port'],"0",pool))
util.SMlog(map)
- # Recycling code here and calling print_entries from ISCSISR.py
+ # Recycling code here and calling print_entries from BaseISCSI.py
super(RBDSR, self).print_entries(map)
# User hasn't selected targetIQN yet, so throwing xs_error like in its iSCSI counterpart
raise xs_errors.XenError('ConfigTargetIQNMissing')
@@ -221,6 +221,10 @@
def attach(self, sr_uuid):
+ # LVHDoISCSI likes to call attach to get target information. if we have block device already attached, we don't need to do it again
+ if self.dconf.has_key('SCSIid') and self.dconf['SCSIid'] and os.path.exists('/dev/rbd%s' % self._getRBD_index(self.dconf['SCSIid'])):
+ self.attached = True
+ return
### Getting MON list using admin key above
ceph_mon_list_xml = self._getCEPH_response('sudo ceph mon_status -f xml')
ceph_mon_list = self._formatMON_list(ceph_mon_list_xml)
@@ -262,7 +266,7 @@
os.symlink('../../../rbd%s' % rbd_image_index, '%s/rbd%s' % (rbd_scsi_path,rbd_image_index))
self.attached = True
except IOError, e:
- util.SMlog('the error is %s' % e)
+ util.SMlog('Attach thrown exception and the error is %s' % e)
self.attached = False
else:
'''in iSCSI sr we need to attach target to interrogate LUN for size, scsi_id etc etc.
@@ -282,15 +286,21 @@
if os.path.exists(rbd_scsi_path):
self._cleanCEPH_folder(rbd_scsi_path)
if os.path.exists('/dev/rbd%s' % rbd_image_index):
- rbd_remove = open('/sys/bus/rbd/remove','w')
- rbd_remove.write(rbd_image_index)
- rbd_remove.close()
- self.attached = False
+ try:
+ util.time.sleep(MAX_TIMEOUT)
+ with open('/sys/bus/rbd/remove','w') as rem:
+ util.SMlog("Writing %s into rbd/remove" % rbd_image_index)
+ rem.write(rbd_image_index)
+ self.attached = False
+ except IOError, e:
+ util.SMlog('Detach thrown exception and the error is %s' % e)
+ self.attached = True
def refresh(self):
- # Unlike iSCSI SR we don't need to refresh paths or rescan sessions
- pass
+ # Unlike iSCSI SR we don't need to refresh paths or rescan sessions,
+ # but if disk hasn't been attached already(like when creating SR) we can do it now
+ self.attach('temp_mount')
def print_LUNs(self):
self.LUNs = {}