Coverage for manila/tests/share/drivers/infortrend/fake_infortrend_nas_data.py: 87%

26 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright (c) 2019 Infortrend Technology, Inc. 

2# All Rights Reserved. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); you may 

5# not use this file except in compliance with the License. You may obtain 

6# a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

13# License for the specific language governing permissions and limitations 

14# under the License. 

15 

16 

17class InfortrendNASTestData(object): 

18 

19 fake_share_id = ['5a0aa06e-1c57-4996-be46-b81e360e8866', # NFS 

20 'aac4fe64-7a9c-472a-b156-9adbb50b4d29'] # CIFS 

21 

22 fake_share_name = [fake_share_id[0].replace('-', ''), 

23 fake_share_id[1].replace('-', '')] 

24 

25 fake_channel_ip = ['172.27.112.223', '172.27.113.209'] 

26 

27 fake_service_status_data = ('(64175, 1234, 272, 0)\n\n' 

28 '{"cliCode": ' 

29 '[{"Return": "0x0000", "CLI": "Successful"}], ' 

30 '"returnCode": [], ' 

31 '"data": ' 

32 '[{"A": ' 

33 '{"NFS": ' 

34 '{"displayName": "NFS", ' 

35 '"state_time": "2017-05-04 14:19:53", ' 

36 '"enabled": true, ' 

37 '"cpu_rate": "0.0", ' 

38 '"mem_rate": "0.0", ' 

39 '"state": "exited", ' 

40 '"type": "share"}}}]}\n\n') 

41 

42 fake_folder_status_data = ('(64175, 1234, 1017, 0)\n\n' 

43 '{"cliCode": ' 

44 '[{"Return": "0x0000", "CLI": "Successful"}], ' 

45 '"returnCode": [], ' 

46 '"data": ' 

47 '[{"utility": "1.00", ' 

48 '"used": "33886208", ' 

49 '"subshare": true, ' 

50 '"share": false, ' 

51 '"worm": "", ' 

52 '"free": "321931374592", ' 

53 '"fsType": "xfs", ' 

54 '"owner": "A", ' 

55 '"readOnly": false, ' 

56 '"modifyTime": "2017-04-27 16:16", ' 

57 '"directory": "/share-pool-01/LV-1", ' 

58 '"volumeId": "6541BAFB2E6C57B6", ' 

59 '"mounted": true, ' 

60 '"size": "321965260800"}, ' 

61 '{"utility": "1.00", ' 

62 '"used": "33779712", ' 

63 '"subshare": false, ' 

64 '"share": false, ' 

65 '"worm": "", ' 

66 '"free": "107287973888", ' 

67 '"fsType": "xfs", ' 

68 '"owner": "A", ' 

69 '"readOnly": false, ' 

70 '"modifyTime": "2017-04-27 15:45", ' 

71 '"directory": "/share-pool-02/LV-1", ' 

72 '"volumeId": "147A8FB67DA39914", ' 

73 '"mounted": true, ' 

74 '"size": "107321753600"}]}\n\n') 

75 

76 fake_nfs_status_off = [{ 

77 'A': { 

78 'NFS': { 

79 'displayName': 'NFS', 

80 'state_time': '2017-05-04 14:19:53', 

81 'enabled': False, 

82 'cpu_rate': '0.0', 

83 'mem_rate': '0.0', 

84 'state': 'exited', 

85 'type': 'share', 

86 } 

87 } 

88 }] 

89 

90 fake_folder_status = [{ 

91 'utility': '1.00', 

92 'used': '33886208', 

93 'subshare': True, 

94 'share': False, 

95 'worm': '', 

96 'free': '321931374592', 

97 'fsType': 'xfs', 

98 'owner': 'A', 

99 'readOnly': False, 

100 'modifyTime': '2017-04-27 16:16', 

101 'directory': '/share-pool-01/LV-1', 

102 'volumeId': '6541BAFB2E6C57B6', 

103 'mounted': True, 

104 'size': '321965260800'}, { 

105 'utility': '1.00', 

106 'used': '33779712', 

107 'subshare': False, 

108 'share': False, 

109 'worm': '', 

110 'free': '107287973888', 

111 'fsType': 'xfs', 

112 'owner': 'A', 

113 'readOnly': False, 

114 'modifyTime': '2017-04-27 15:45', 

115 'directory': '/share-pool-02/LV-1', 

116 'volumeId': '147A8FB67DA39914', 

117 'mounted': True, 

118 'size': '107321753600', 

119 }] 

120 

121 def fake_get_channel_status(self, ch1_status='UP'): 

122 return [{ 

123 'datalink': 'mgmt0', 

124 'status': 'UP', 

125 'typeConfig': 'DHCP', 

126 'IP': '172.27.112.125', 

127 'MAC': '00:d0:23:00:15:a6', 

128 'netmask': '255.255.240.0', 

129 'type': 'dhcp', 

130 'gateway': '172.27.127.254'}, { 

131 'datalink': 'CH0', 

132 'status': 'UP', 

133 'typeConfig': 'DHCP', 

134 'IP': self.fake_channel_ip[0], 

135 'MAC': '00:d0:23:80:15:a6', 

136 'netmask': '255.255.240.0', 

137 'type': 'dhcp', 

138 'gateway': '172.27.127.254'}, { 

139 'datalink': 'CH1', 

140 'status': ch1_status, 

141 'typeConfig': 'DHCP', 

142 'IP': self.fake_channel_ip[1], 

143 'MAC': '00:d0:23:40:15:a6', 

144 'netmask': '255.255.240.0', 

145 'type': 'dhcp', 

146 'gateway': '172.27.127.254'}, { 

147 'datalink': 'CH2', 

148 'status': 'DOWN', 

149 'typeConfig': 'DHCP', 

150 'IP': '', 

151 'MAC': '00:d0:23:c0:15:a6', 

152 'netmask': '', 

153 'type': '', 

154 'gateway': ''}, { 

155 'datalink': 'CH3', 

156 'status': 'DOWN', 

157 'typeConfig': 'DHCP', 

158 'IP': '', 

159 'MAC': '00:d0:23:20:15:a6', 

160 'netmask': '', 

161 'type': '', 

162 'gateway': '', 

163 }] 

164 

165 fake_fquota_status = [{ 

166 'quota': '21474836480', 

167 'used': '0', 

168 'name': 'test-folder', 

169 'type': 'subfolder', 

170 'id': '537178178'}, { 

171 'quota': '32212254720', 

172 'used': '0', 

173 'name': fake_share_name[0], 

174 'type': 'subfolder', 

175 'id': '805306752'}, { 

176 'quota': '53687091200', 

177 'used': '21474836480', 

178 'name': fake_share_name[1], 

179 'type': 'subfolder', 

180 'id': '69'}, { 

181 'quota': '94091997184', 

182 'used': '0', 

183 'type': 'subfolder', 

184 'id': '70', 

185 "name": 'test-folder-02' 

186 }] 

187 

188 fake_fquota_status_with_no_settings = [] 

189 

190 def fake_get_share_status_nfs(self, status=False): 

191 fake_share_status_nfs = [{ 

192 'ftp': False, 

193 'cifs': False, 

194 'oss': False, 

195 'sftp': False, 

196 'nfs': status, 

197 'directory': '/LV-1/share-pool-01/' + self.fake_share_name[0], 

198 'exist': True, 

199 'afp': False, 

200 'webdav': False 

201 }] 

202 if status: 202 ↛ 203line 202 didn't jump to line 203 because the condition on line 202 was never true

203 fake_share_status_nfs[0]['nfs_detail'] = { 

204 'hostList': [{ 

205 'uid': '65534', 

206 'insecure': 'insecure', 

207 'squash': 'all', 

208 'access': 'ro', 

209 'host': '*', 

210 'gid': '65534', 

211 'mode': 'async', 

212 'no_subtree_check': 'no_subtree_check', 

213 }] 

214 } 

215 return fake_share_status_nfs 

216 

217 def fake_get_share_status_cifs(self, status=False): 

218 fake_share_status_cifs = [{ 

219 'ftp': False, 

220 'cifs': status, 

221 'oss': False, 

222 'sftp': False, 

223 'nfs': False, 

224 'directory': '/share-pool-01/LV-1/' + self.fake_share_name[1], 

225 'exist': True, 

226 'afp': False, 

227 'webdav': False 

228 }] 

229 if status: 229 ↛ 230line 229 didn't jump to line 230 because the condition on line 229 was never true

230 fake_share_status_cifs[0]['cifs_detail'] = { 

231 'available': True, 

232 'encrypt': False, 

233 'description': '', 

234 'sharename': 'cifs-01', 

235 'failover': '', 

236 'AIO': True, 

237 'priv': 'None', 

238 'recycle_bin': False, 

239 'ABE': True, 

240 } 

241 return fake_share_status_cifs 

242 

243 fake_subfolder_data = [{ 

244 'size': '6', 

245 'index': '34', 

246 'description': '', 

247 'encryption': '', 

248 'isEnd': False, 

249 'share': False, 

250 'volumeId': '6541BAFB2E6C57B6', 

251 'quota': '', 

252 'modifyTime': '2017-04-06 11:35', 

253 'owner': 'A', 

254 'path': '/share-pool-01/LV-1/UserHome', 

255 'subshare': True, 

256 'type': 'subfolder', 

257 'empty': False, 

258 'name': 'UserHome'}, { 

259 'size': '6', 

260 'index': '39', 

261 'description': '', 

262 'encryption': '', 

263 'isEnd': False, 

264 'share': False, 

265 'volumeId': '6541BAFB2E6C57B6', 

266 'quota': '21474836480', 

267 'modifyTime': '2017-04-27 15:44', 

268 'owner': 'A', 

269 'path': '/share-pool-01/LV-1/test-folder', 

270 'subshare': False, 

271 'type': 'subfolder', 

272 'empty': True, 

273 'name': 'test-folder'}, { 

274 'size': '6', 

275 'index': '45', 

276 'description': '', 

277 'encryption': '', 

278 'isEnd': False, 

279 'share': True, 

280 'volumeId': '6541BAFB2E6C57B6', 

281 'quota': '32212254720', 

282 'modifyTime': '2017-04-27 16:15', 

283 'owner': 'A', 

284 'path': '/share-pool-01/LV-1/' + fake_share_name[0], 

285 'subshare': False, 

286 'type': 'subfolder', 

287 'empty': True, 

288 'name': fake_share_name[0]}, { 

289 'size': '6', 

290 'index': '512', 

291 'description': '', 

292 'encryption': '', 

293 'isEnd': True, 

294 'share': True, 

295 'volumeId': '6541BAFB2E6C57B6', 

296 'quota': '53687091200', 

297 'modifyTime': '2017-04-27 16:16', 

298 'owner': 'A', 

299 'path': '/share-pool-01/LV-1/' + fake_share_name[1], 

300 'subshare': False, 

301 'type': 'subfolder', 

302 'empty': True, 

303 'name': fake_share_name[1]}, { 

304 'size': '6', 

305 'index': '777', 

306 'description': '', 

307 'encryption': '', 

308 'isEnd': False, 

309 'share': False, 

310 'volumeId': '6541BAFB2E6C57B6', 

311 'quota': '94091997184', 

312 'modifyTime': '2017-04-28 15:44', 

313 'owner': 'A', 

314 'path': '/share-pool-01/LV-1/test-folder-02', 

315 'subshare': False, 

316 'type': 'subfolder', 

317 'empty': True, 

318 'name': 'test-folder-02' 

319 }] 

320 

321 fake_cifs_user_list = [{ 

322 'Superuser': 'No', 

323 'Group': 'users', 

324 'Description': '', 

325 'Quota': 'none', 

326 'PWD Expiry Date': '2291-01-19', 

327 'Home Directory': '/share-pool-01/LV-1/UserHome/user01', 

328 'UID': '100001', 

329 'Type': 'Local', 

330 'Name': 'user01'}, { 

331 'Superuser': 'No', 

332 'Group': 'users', 

333 'Description': '', 

334 'Quota': 'none', 

335 'PWD Expiry Date': '2017-08-07', 

336 'Home Directory': '/share-pool-01/LV-1/UserHome/user02', 

337 'UID': '100002', 

338 'Type': 'Local', 

339 'Name': 'user02' 

340 }] 

341 

342 fake_share_status_nfs_with_rules = [{ 

343 'ftp': False, 

344 'cifs': False, 

345 'oss': False, 

346 'sftp': False, 

347 'nfs': True, 

348 'directory': '/share-pool-01/LV-1/' + fake_share_name[0], 

349 'exist': True, 

350 'nfs_detail': { 

351 'hostList': [{ 

352 'uid': '65534', 

353 'insecure': 'insecure', 

354 'squash': 'all', 

355 'access': 'ro', 

356 'host': '*', 

357 'gid': '65534', 

358 'mode': 'async', 

359 'no_subtree_check': 

360 'no_subtree_check'}, { 

361 'uid': '65534', 

362 'insecure': 'insecure', 

363 'squash': 'all', 

364 'access': 'rw', 

365 'host': '172.27.1.1', 

366 'gid': '65534', 

367 'mode': 'async', 

368 'no_subtree_check': 'no_subtree_check'}, { 

369 'uid': '65534', 

370 'insecure': 'insecure', 

371 'squash': 'all', 

372 'access': 'rw', 

373 'host': '172.27.1.2', 

374 'gid': '65534', 

375 'mode': 'async', 

376 'no_subtree_check': 'no_subtree_check'}] 

377 }, 

378 'afp': False, 

379 'webdav': False, 

380 }] 

381 

382 fake_share_status_cifs_with_rules = [ 

383 { 

384 'permission': { 

385 'Read': True, 

386 'Write': True, 

387 'Execute': True}, 

388 'type': 'user', 

389 'id': '100001', 

390 'name': 'user01' 

391 }, { 

392 'permission': { 

393 'Read': True, 

394 'Write': False, 

395 'Execute': True}, 

396 'type': 'user', 

397 'id': '100002', 

398 'name': 'user02' 

399 }, { 

400 'permission': { 

401 'Read': True, 

402 'Write': False, 

403 'Execute': True}, 

404 'type': 'group@', 

405 'id': '100', 

406 'name': 'users' 

407 }, { 

408 'permission': { 

409 'Read': True, 

410 'Write': False, 

411 'Execute': True}, 

412 'type': 'other@', 

413 'id': '', 

414 'name': '' 

415 } 

416 ]