Coverage for drivers/LVHDoFCoESR.py : 69%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/python3
2#
3# Copyright (C) Citrix Systems Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published
7# by the Free Software Foundation; version 2.1 only.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17#
18# LVHDoFCoESR: LVHD over Fibre Channel over Ethernet driver
19#
21import SR
22import LVHDoHBASR
23import LVHDSR
24import SRCommand
25import sys
26import xs_errors
27import util
29CAPABILITIES = ["SR_PROBE", "SR_UPDATE", "SR_METADATA", "SR_TRIM",
30 "VDI_CREATE", "VDI_DELETE", "VDI_ATTACH", "VDI_DETACH",
31 "VDI_GENERATE_CONFIG", "VDI_SNAPSHOT", "VDI_CLONE",
32 "VDI_RESIZE", "ATOMIC_PAUSE", "VDI_RESET_ON_BOOT/2",
33 "VDI_UPDATE", "VDI_MIRROR", "VDI_CONFIG_CBT", "VDI_ACTIVATE",
34 "VDI_DEACTIVATE"]
36CONFIGURATION = [['SCSIid', 'The scsi_id of the destination LUN'],
37 ['allocation', 'Valid values are thick or thin(optional,\
38 defaults to thick)']]
40DRIVER_INFO = {
41 'name': 'LVHD over FCoE',
42 'description': 'SR plugin which represents disks as VHDs on Logical \
43 Volumes within a Volume Group created on a FCoE LUN',
44 'vendor': 'Citrix Systems Inc',
45 'copyright': '(C) 2015 Citrix Systems Inc',
46 'driver_version': '1.0',
47 'required_api_version': '1.0',
48 'capabilities': CAPABILITIES,
49 'configuration': CONFIGURATION
50}
53class LVHDoFCoESR(LVHDoHBASR.LVHDoHBASR):
55 """LVHD over FCoE storage repository"""
57 def handles(type):
58 if __name__ == '__main__':
59 name = sys.argv[0]
60 else:
61 name = __name__
62 if name.endswith("LVMoFCoESR"):
63 return type == "lvmofcoe" # for the initial switch from LVM
64 if type == "lvhdofcoe":
65 return True
66 return False
67 handles = staticmethod(handles)
69 def load(self, sr_uuid):
70 driver = SR.driver('hba')
71 if 'type' not in self.original_srcmd.params['device_config'] or \ 71 ↛ 75line 71 didn't jump to line 75, because the condition on line 71 was never false
72 'type' in self.original_srcmd.params['device_config'] and \
73 self.original_srcmd.dconf['type'] == "any":
74 self.original_srcmd.dconf['type'] = "fcoe"
75 self.hbasr = driver(self.original_srcmd, sr_uuid)
76 pbd = None
77 try:
78 pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
79 except:
80 pass
82 if 'SCSIid' not in self.dconf or not self.dconf['SCSIid']:
83 print(self.hbasr.print_devs(), file=sys.stderr)
84 raise xs_errors.XenError('ConfigSCSIid')
86 self.SCSIid = self.dconf['SCSIid']
87 LVHDSR.LVHDSR.load(self, sr_uuid)
89 def vdi(self, uuid):
90 return LVHDoFCoEVDI(self, uuid)
93class LVHDoFCoEVDI(LVHDoHBASR.LVHDoHBAVDI):
94 pass
96if __name__ == '__main__': 96 ↛ 97line 96 didn't jump to line 97, because the condition on line 96 was never true
97 SRCommand.run(LVHDoFCoESR, DRIVER_INFO)
98else:
99 SR.registerSR(LVHDoFCoESR)