Coverage for drivers/LVHDoFCoESR.py : 72%

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#
21from sm_typing import override
23import SR
24import VDI
25import LVHDoHBASR
26import LVHDSR
27import SRCommand
28import sys
29import xs_errors
30import util
32CAPABILITIES = ["SR_PROBE", "SR_UPDATE", "SR_METADATA", "SR_TRIM",
33 "VDI_CREATE", "VDI_DELETE", "VDI_ATTACH", "VDI_DETACH",
34 "VDI_GENERATE_CONFIG", "VDI_SNAPSHOT", "VDI_CLONE",
35 "VDI_RESIZE", "ATOMIC_PAUSE", "VDI_RESET_ON_BOOT/2",
36 "VDI_UPDATE", "VDI_MIRROR", "VDI_CONFIG_CBT", "VDI_ACTIVATE",
37 "VDI_DEACTIVATE"]
39CONFIGURATION = [['SCSIid', 'The scsi_id of the destination LUN'],
40 ['allocation', 'Valid values are thick or thin(optional,\
41 defaults to thick)']]
43DRIVER_INFO = {
44 'name': 'LVHD over FCoE',
45 'description': 'SR plugin which represents disks as VHDs on Logical \
46 Volumes within a Volume Group created on a FCoE LUN',
47 'vendor': 'Citrix Systems Inc',
48 'copyright': '(C) 2015 Citrix Systems Inc',
49 'driver_version': '1.0',
50 'required_api_version': '1.0',
51 'capabilities': CAPABILITIES,
52 'configuration': CONFIGURATION
53}
56class LVHDoFCoESR(LVHDoHBASR.LVHDoHBASR):
58 """LVHD over FCoE storage repository"""
60 @override
61 @staticmethod
62 def handles(type) -> bool:
63 if __name__ == '__main__':
64 name = sys.argv[0]
65 else:
66 name = __name__
67 if name.endswith("LVMoFCoESR"):
68 return type == "lvmofcoe" # for the initial switch from LVM
69 if type == "lvhdofcoe":
70 return True
71 return False
73 @override
74 def load(self, sr_uuid) -> None:
75 driver = SR.driver('hba')
76 if 'type' not in self.original_srcmd.params['device_config'] or \ 76 ↛ 80line 76 didn't jump to line 80, because the condition on line 76 was never false
77 'type' in self.original_srcmd.params['device_config'] and \
78 self.original_srcmd.dconf['type'] == "any":
79 self.original_srcmd.dconf['type'] = "fcoe"
80 self.hbasr = driver(self.original_srcmd, sr_uuid)
81 pbd = None
82 try:
83 pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
84 except:
85 pass
87 if 'SCSIid' not in self.dconf or not self.dconf['SCSIid']:
88 print(self.hbasr.print_devs(), file=sys.stderr)
89 raise xs_errors.XenError('ConfigSCSIid')
91 self.SCSIid = self.dconf['SCSIid']
92 LVHDSR.LVHDSR.load(self, sr_uuid)
94 @override
95 def vdi(self, uuid) -> VDI.VDI:
96 return LVHDoFCoEVDI(self, uuid)
99class LVHDoFCoEVDI(LVHDoHBASR.LVHDoHBAVDI):
100 pass
102if __name__ == '__main__': 102 ↛ 103line 102 didn't jump to line 103, because the condition on line 102 was never true
103 SRCommand.run(LVHDoFCoESR, DRIVER_INFO)
104else:
105 SR.registerSR(LVHDoFCoESR)