Merge tag '2.6.0' into debian/wallaby
python-manilaclient 2.6.0 release
meta:version: 2.6.0
meta:diff-start: -
meta:series: wallaby
meta:release-type: release
meta:pypi: yes
meta:first: no
meta:release:Author: Goutham Pacha Ravi <gouthampravi@gmail.com>
meta:release:Commit: Goutham Pacha Ravi <gouthampravi@gmail.com>
meta:release:Change-Id: I521f01fd2ca0cb378d034913e3da24c8e60cb24d
meta:release:Code-Review+2: Hervé Beraud <herveberaud.pro@gmail.com>
meta:release:Code-Review+2: Thierry Carrez <thierry@openstack.org>
meta:release:Workflow+1: Thierry Carrez <thierry@openstack.org>
Thomas Goirand
3 years ago
26 | 26 | |
27 | 27 | LOG = logging.getLogger(__name__) |
28 | 28 | |
29 | MAX_VERSION = '2.57' | |
29 | MAX_VERSION = '2.63' | |
30 | 30 | MIN_VERSION = '2.0' |
31 | 31 | DEPRECATED_VERSION = '1.0' |
32 | 32 | _VERSIONED_METHOD_MAP = {} |
585 | 585 | share_networks_raw = self.manila(cmd, microversion=microversion) |
586 | 586 | share_networks = utils.listing(share_networks_raw) |
587 | 587 | return share_networks |
588 | ||
589 | def share_network_reset_state(self, id=None, state=None, | |
590 | microversion=None): | |
591 | cmd = 'share-network-reset-state %s ' % id | |
592 | if state: | |
593 | cmd += '--state %s' % state | |
594 | share_network_raw = self.manila(cmd, microversion=microversion) | |
595 | share_network = utils.listing(share_network_raw) | |
596 | return share_network | |
597 | ||
598 | def share_network_security_service_add( | |
599 | self, share_network_id, security_service_id, microversion=None): | |
600 | cmd = ('share-network-security-service-add %(network_id)s ' | |
601 | '%(service_id)s' % {'network_id': share_network_id, | |
602 | 'service_id': security_service_id}) | |
603 | self.manila(cmd, microversion=microversion) | |
604 | ||
605 | def share_network_security_service_update( | |
606 | self, share_network_id, current_security_service_id, | |
607 | new_security_service_id, microversion=None): | |
608 | cmd = ( | |
609 | 'share-network-security-service-update %(network_id)s ' | |
610 | '%(current_service_id)s %(new_security_service_id)s' % { | |
611 | 'network_id': share_network_id, | |
612 | 'current_service_id': current_security_service_id, | |
613 | 'new_security_service_id': new_security_service_id}) | |
614 | self.manila(cmd, microversion=microversion) | |
615 | ||
616 | def share_network_security_service_add_check( | |
617 | self, share_network_id, security_service_id, | |
618 | reset=False, microversion=None): | |
619 | cmd = ( | |
620 | 'share-network-security-service-add-check %(network_id)s ' | |
621 | '%(security_service_id)s' % { | |
622 | 'network_id': share_network_id, | |
623 | 'security_service_id': security_service_id}) | |
624 | ||
625 | if reset: | |
626 | cmd += '--reset %s' % reset | |
627 | ||
628 | return output_parser.details( | |
629 | self.manila(cmd, microversion=microversion)) | |
630 | ||
631 | def share_network_security_service_update_check( | |
632 | self, share_network_id, current_security_service_id, | |
633 | new_security_service_id, reset=False, microversion=None): | |
634 | cmd = ( | |
635 | 'share-network-security-service-update-check %(network_id)s ' | |
636 | '%(current_security_service_id)s %(new_security_service_id)s ' % { | |
637 | 'network_id': share_network_id, | |
638 | 'current_security_service_id': current_security_service_id, | |
639 | 'new_security_service_id': new_security_service_id}) | |
640 | ||
641 | if reset: | |
642 | cmd += '--reset %s' % reset | |
643 | ||
644 | return output_parser.details( | |
645 | self.manila(cmd, microversion=microversion)) | |
646 | ||
647 | def share_network_security_service_list( | |
648 | self, share_network_id, microversion=None): | |
649 | cmd = ('share-network-security-service-list %s' % share_network_id) | |
650 | share_networks_raw = self.manila(cmd, microversion=microversion) | |
651 | network_services = utils.listing(share_networks_raw) | |
652 | return network_services | |
588 | 653 | |
589 | 654 | def is_share_network_deleted(self, share_network, microversion=None): |
590 | 655 | """Says whether share network is deleted or not. |
17 | 17 | import ddt |
18 | 18 | from tempest.lib.common.utils import data_utils |
19 | 19 | from tempest.lib import exceptions as tempest_lib_exc |
20 | ||
20 | import time | |
21 | ||
22 | from manilaclient import config | |
23 | from manilaclient import exceptions | |
21 | 24 | from manilaclient.tests.functional import base |
22 | 25 | from manilaclient.tests.functional import utils |
26 | ||
27 | SECURITY_SERVICE_UPDATE_VERSION = '2.63' | |
28 | CONF = config.CONF | |
23 | 29 | |
24 | 30 | |
25 | 31 | @ddt.ddt |
292 | 298 | filters=filters) |
293 | 299 | |
294 | 300 | self.assertGreater(len(share_networks), 0) |
301 | ||
302 | def test_share_network_reset_status(self): | |
303 | share_network = self.create_share_network( | |
304 | client=self.user_client, | |
305 | name='cool_net_name', | |
306 | description='fakedescription', | |
307 | neutron_net_id='fake_neutron_net_id', | |
308 | neutron_subnet_id='fake_neutron_subnet_id', | |
309 | ) | |
310 | ||
311 | # Admin operation | |
312 | self.admin_client.share_network_reset_state( | |
313 | share_network['id'], 'error', | |
314 | microversion=SECURITY_SERVICE_UPDATE_VERSION) | |
315 | ||
316 | self.user_client.wait_for_resource_status( | |
317 | share_network['id'], 'error', | |
318 | microversion=SECURITY_SERVICE_UPDATE_VERSION, | |
319 | resource_type="share_network") | |
320 | ||
321 | def test_share_network_security_service_add(self): | |
322 | share_network = self.create_share_network( | |
323 | client=self.user_client, | |
324 | name='cool_net_name', | |
325 | description='fakedescription', | |
326 | neutron_net_id='fake_neutron_net_id', | |
327 | neutron_subnet_id='fake_neutron_subnet_id', | |
328 | ) | |
329 | new_security_service = self.create_security_service( | |
330 | client=self.user_client) | |
331 | ||
332 | check_result = ( | |
333 | self.user_client.share_network_security_service_add_check( | |
334 | share_network['id'], | |
335 | security_service_id=new_security_service['id'])) | |
336 | ||
337 | self.assertEqual(check_result['compatible'], 'True') | |
338 | ||
339 | self.user_client.share_network_security_service_add( | |
340 | share_network['id'], new_security_service['id']) | |
341 | ||
342 | network_services = ( | |
343 | self.user_client.share_network_security_service_list( | |
344 | share_network['id'])) | |
345 | ||
346 | self.assertEqual(len(network_services), 1) | |
347 | self.assertEqual( | |
348 | network_services[0]['id'], new_security_service['id']) | |
349 | ||
350 | def test_share_network_security_service_update(self): | |
351 | share_network = self.create_share_network( | |
352 | client=self.user_client, | |
353 | name='cool_net_name', | |
354 | description='fakedescription', | |
355 | neutron_net_id='fake_neutron_net_id', | |
356 | neutron_subnet_id='fake_neutron_subnet_id', | |
357 | ) | |
358 | current_name = 'current' | |
359 | new_name = 'new' | |
360 | current_security_service = self.create_security_service( | |
361 | client=self.user_client, name=current_name) | |
362 | new_security_service = self.create_security_service( | |
363 | client=self.user_client, name=new_name) | |
364 | ||
365 | check_result = ( | |
366 | self.user_client.share_network_security_service_add_check( | |
367 | share_network['id'], current_security_service['id'])) | |
368 | ||
369 | self.assertEqual(check_result['compatible'], 'True') | |
370 | ||
371 | self.user_client.share_network_security_service_add( | |
372 | share_network['id'], current_security_service['id']) | |
373 | ||
374 | network_services = ( | |
375 | self.user_client.share_network_security_service_list( | |
376 | share_network['id'])) | |
377 | ||
378 | self.assertEqual(len(network_services), 1) | |
379 | self.assertEqual(network_services[0]['name'], current_name) | |
380 | ||
381 | check_result = ( | |
382 | self.user_client.share_network_security_service_update_check( | |
383 | share_network['id'], current_security_service['id'], | |
384 | new_security_service['id'])) | |
385 | ||
386 | self.assertEqual(check_result['compatible'], 'True') | |
387 | ||
388 | self.user_client.share_network_security_service_update( | |
389 | share_network['id'], current_security_service['id'], | |
390 | new_security_service['id']) | |
391 | ||
392 | network_services = ( | |
393 | self.user_client.share_network_security_service_list( | |
394 | share_network['id'])) | |
395 | ||
396 | self.assertEqual(len(network_services), 1) | |
397 | self.assertEqual(network_services[0]['name'], new_name) | |
398 | ||
399 | ||
400 | class ShareNetworkSecurityServiceCheckReadWriteTests(base.BaseTestCase): | |
401 | protocol = None | |
402 | ||
403 | def setUp(self): | |
404 | super(ShareNetworkSecurityServiceCheckReadWriteTests, self).setUp() | |
405 | if self.protocol not in CONF.enable_protocols: | |
406 | message = "%s tests are disabled." % self.protocol | |
407 | raise self.skipException(message) | |
408 | self.client = self.get_user_client() | |
409 | if not self.client.share_network: | |
410 | message = "Can run only with DHSS=True mode" | |
411 | raise self.skipException(message) | |
412 | ||
413 | def _wait_for_update_security_service_compatible_result( | |
414 | self, share_network, current_security_service, | |
415 | new_security_service=None): | |
416 | compatible_expected_result = 'True' | |
417 | check_is_compatible = 'None' | |
418 | tentatives = 0 | |
419 | ||
420 | # There might be a delay from the time the check is requested until | |
421 | # the backend has performed all checks | |
422 | while check_is_compatible != compatible_expected_result: | |
423 | tentatives += 1 | |
424 | if not new_security_service: | |
425 | check_is_compatible = ( | |
426 | self.user_client.share_network_security_service_add_check( | |
427 | share_network['id'], | |
428 | current_security_service['id']))['compatible'] | |
429 | else: | |
430 | check_is_compatible = ( | |
431 | (self.user_client. | |
432 | share_network_security_service_update_check( | |
433 | share_network['id'], | |
434 | current_security_service['id'], | |
435 | new_security_service['id'])))['compatible'] | |
436 | if tentatives > 3: | |
437 | timeout_message = ( | |
438 | "Share network security service add/update check did not " | |
439 | "reach 'compatible=True' within 15 seconds.") | |
440 | raise exceptions.TimeoutException(message=timeout_message) | |
441 | time.sleep(5) | |
442 | ||
443 | def test_check_if_security_service_can_be_added_to_share_network_in_use( | |
444 | self): | |
445 | share_network = self.create_share_network( | |
446 | client=self.user_client, | |
447 | description='fakedescription', | |
448 | neutron_net_id='fake_neutron_net_id', | |
449 | neutron_subnet_id='fake_neutron_subnet_id', | |
450 | ) | |
451 | # Create a share so we can be sure that a share server will exist and | |
452 | # the check will be performed in the backends | |
453 | self.create_share( | |
454 | self.protocol, client=self.user_client, | |
455 | share_network=share_network['id']) | |
456 | ||
457 | current_security_service = self.create_security_service( | |
458 | client=self.user_client) | |
459 | ||
460 | check_result = ( | |
461 | self.user_client.share_network_security_service_add_check( | |
462 | share_network['id'], | |
463 | current_security_service['id'])) | |
464 | ||
465 | self.assertEqual(check_result['compatible'], 'None') | |
466 | ||
467 | self._wait_for_update_security_service_compatible_result( | |
468 | share_network, current_security_service) | |
469 | ||
470 | def test_add_and_update_security_service_when_share_network_is_in_use( | |
471 | self): | |
472 | share_network = self.create_share_network( | |
473 | client=self.user_client, | |
474 | name='cool_net_name', | |
475 | description='fakedescription', | |
476 | neutron_net_id='fake_neutron_net_id', | |
477 | neutron_subnet_id='fake_neutron_subnet_id', | |
478 | ) | |
479 | ||
480 | # Create a share so we can be sure that a share server will exist and | |
481 | # the check will be performed in the backends | |
482 | self.create_share( | |
483 | self.protocol, name='fake_share_name', | |
484 | share_network=share_network['id'], client=self.user_client) | |
485 | ||
486 | current_security_service = self.create_security_service( | |
487 | client=self.user_client, name='current_security_service') | |
488 | new_security_service = self.create_security_service( | |
489 | client=self.user_client, name='new_security_service') | |
490 | ||
491 | check_result = ( | |
492 | self.user_client.share_network_security_service_add_check( | |
493 | share_network['id'], current_security_service['id'])) | |
494 | ||
495 | self.assertEqual(check_result['compatible'], 'None') | |
496 | ||
497 | self._wait_for_update_security_service_compatible_result( | |
498 | share_network, current_security_service) | |
499 | ||
500 | self.user_client.share_network_security_service_add( | |
501 | share_network['id'], current_security_service['id']) | |
502 | ||
503 | network_services = ( | |
504 | self.user_client.share_network_security_service_list( | |
505 | share_network['id'])) | |
506 | ||
507 | self.assertEqual(len(network_services), 1) | |
508 | self.assertEqual( | |
509 | network_services[0]['name'], current_security_service['name']) | |
510 | ||
511 | self.user_client.wait_for_resource_status( | |
512 | share_network['id'], 'active', | |
513 | microversion=SECURITY_SERVICE_UPDATE_VERSION, | |
514 | resource_type="share_network") | |
515 | ||
516 | check_result = ( | |
517 | self.user_client.share_network_security_service_update_check( | |
518 | share_network['id'], current_security_service['id'], | |
519 | new_security_service['id'])) | |
520 | ||
521 | self.assertEqual(check_result['compatible'], 'None') | |
522 | ||
523 | self._wait_for_update_security_service_compatible_result( | |
524 | share_network, current_security_service, | |
525 | new_security_service=new_security_service) | |
526 | ||
527 | self.user_client.share_network_security_service_update( | |
528 | share_network['id'], current_security_service['id'], | |
529 | new_security_service['id']) | |
530 | ||
531 | network_services = ( | |
532 | self.user_client.share_network_security_service_list( | |
533 | share_network['id'])) | |
534 | ||
535 | self.assertEqual(len(network_services), 1) | |
536 | self.assertEqual( | |
537 | network_services[0]['name'], new_security_service['name']) | |
538 | ||
539 | self.user_client.wait_for_resource_status( | |
540 | share_network['id'], 'active', | |
541 | microversion=SECURITY_SERVICE_UPDATE_VERSION, | |
542 | resource_type="share_network") | |
543 | ||
544 | ||
545 | base_security_service_check = ShareNetworkSecurityServiceCheckReadWriteTests | |
546 | ||
547 | ||
548 | class ShareNetworkSecServiceCheckRWNFSTest(base_security_service_check): | |
549 | protocol = 'nfs' | |
550 | ||
551 | ||
552 | class ShareNetworkSecServiceCheckRWTestsCIFSTest(base_security_service_check): | |
553 | protocol = 'cifs' |
144 | 144 | def test_add_security_service(self): |
145 | 145 | security_service = 'fake security service' |
146 | 146 | share_nw = 'fake share nw' |
147 | expected_path = (share_networks.RESOURCE_PATH + '/action') % share_nw | |
148 | expected_body = { | |
149 | 'add_security_service': { | |
150 | 'security_service_id': security_service, | |
151 | }, | |
152 | } | |
153 | with mock.patch.object(self.manager, '_create', mock.Mock()): | |
147 | expected_path = 'add_security_service' | |
148 | expected_body = { | |
149 | 'security_service_id': security_service, | |
150 | } | |
151 | with mock.patch.object(self.manager, '_action', mock.Mock()): | |
154 | 152 | self.manager.add_security_service(share_nw, security_service) |
155 | self.manager._create.assert_called_once_with( | |
156 | expected_path, | |
157 | expected_body, | |
158 | share_networks.RESOURCE_NAME) | |
153 | self.manager._action.assert_called_once_with( | |
154 | expected_path, | |
155 | share_nw, | |
156 | expected_body) | |
159 | 157 | |
160 | 158 | def test_add_security_service_to_share_nw_object(self): |
161 | 159 | security_service = self._FakeSecurityService() |
162 | 160 | share_nw = self._FakeShareNetwork() |
163 | expected_path = ((share_networks.RESOURCE_PATH + | |
164 | '/action') % share_nw.id) | |
165 | expected_body = { | |
166 | 'add_security_service': { | |
167 | 'security_service_id': security_service.id, | |
168 | }, | |
169 | } | |
170 | with mock.patch.object(self.manager, '_create', mock.Mock()): | |
161 | expected_path = 'add_security_service' | |
162 | expected_body = { | |
163 | 'security_service_id': security_service.id, | |
164 | } | |
165 | with mock.patch.object(self.manager, '_action', mock.Mock()): | |
171 | 166 | self.manager.add_security_service(share_nw, security_service) |
172 | self.manager._create.assert_called_once_with( | |
173 | expected_path, | |
174 | expected_body, | |
175 | share_networks.RESOURCE_NAME) | |
167 | self.manager._action.assert_called_once_with( | |
168 | expected_path, | |
169 | share_nw, | |
170 | expected_body) | |
176 | 171 | |
177 | 172 | def test_remove_security_service(self): |
178 | 173 | security_service = 'fake security service' |
206 | 201 | expected_path, |
207 | 202 | expected_body, |
208 | 203 | share_networks.RESOURCE_NAME) |
204 | ||
205 | def test_update_share_network_security_service(self): | |
206 | current_security_service = self._FakeSecurityService() | |
207 | new_security_service = self._FakeSecurityService() | |
208 | share_nw = self._FakeShareNetwork() | |
209 | ||
210 | expected_path = 'update_security_service' | |
211 | ||
212 | expected_body = { | |
213 | 'current_service_id': current_security_service.id, | |
214 | 'new_service_id': new_security_service.id | |
215 | } | |
216 | ||
217 | with mock.patch.object(self.manager, '_action', mock.Mock()): | |
218 | self.manager.update_share_network_security_service( | |
219 | share_nw, current_security_service, new_security_service) | |
220 | self.manager._action.assert_called_once_with( | |
221 | expected_path, | |
222 | share_nw, | |
223 | expected_body) | |
224 | ||
225 | def test_share_network_reset_state(self): | |
226 | share_nw = self._FakeShareNetwork() | |
227 | state = 'active' | |
228 | ||
229 | expected_path = 'reset_status' | |
230 | expected_body = { | |
231 | 'status': state, | |
232 | } | |
233 | ||
234 | with mock.patch.object(self.manager, '_action', mock.Mock()): | |
235 | self.manager.reset_state( | |
236 | share_nw, state) | |
237 | self.manager._action.assert_called_once_with( | |
238 | expected_path, | |
239 | share_nw, | |
240 | expected_body) | |
241 | ||
242 | def test_share_network_security_service_update_check(self): | |
243 | current_security_service = self._FakeSecurityService() | |
244 | new_security_service = self._FakeSecurityService() | |
245 | share_nw = self._FakeShareNetwork() | |
246 | ||
247 | expected_path = 'update_security_service_check' | |
248 | ||
249 | expected_body = { | |
250 | 'current_service_id': current_security_service.id, | |
251 | 'new_service_id': new_security_service.id, | |
252 | 'reset_operation': False | |
253 | } | |
254 | ||
255 | with mock.patch.object(self.manager, '_action', mock.Mock()): | |
256 | self.manager.update_share_network_security_service_check( | |
257 | share_nw, current_security_service, new_security_service) | |
258 | self.manager._action.assert_called_once_with( | |
259 | expected_path, | |
260 | share_nw, | |
261 | expected_body) | |
262 | ||
263 | def test_add_security_service_check(self): | |
264 | current_security_service = self._FakeSecurityService() | |
265 | share_nw = self._FakeShareNetwork() | |
266 | ||
267 | expected_path = 'add_security_service_check' | |
268 | ||
269 | expected_body = { | |
270 | 'security_service_id': current_security_service.id, | |
271 | 'reset_operation': False | |
272 | } | |
273 | ||
274 | with mock.patch.object(self.manager, '_action', mock.Mock()): | |
275 | self.manager.add_security_service_check( | |
276 | share_nw, current_security_service, False) | |
277 | self.manager._action.assert_called_once_with( | |
278 | expected_path, | |
279 | share_nw, | |
280 | expected_body) |
21 | 21 | RESOURCE_PATH = "/share-networks/%s" |
22 | 22 | RESOURCE_NAME = 'share_network' |
23 | 23 | RESOURCES_NAME = 'share_networks' |
24 | ACTION_PATH = RESOURCE_PATH + '/action' | |
24 | 25 | |
25 | 26 | |
26 | 27 | class ShareNetwork(common_base.Resource): |
113 | 114 | body = {RESOURCE_NAME: values} |
114 | 115 | |
115 | 116 | return self._create(RESOURCES_PATH, body, RESOURCE_NAME) |
116 | ||
117 | def add_security_service(self, share_network, security_service): | |
118 | """Associate given security service with a share network. | |
119 | ||
120 | :param share_network: share network name, id or ShareNetwork instance | |
121 | :param security_service: name, id or SecurityService instance | |
122 | :rtype: :class:`ShareNetwork` | |
123 | """ | |
124 | body = { | |
125 | 'add_security_service': { | |
126 | 'security_service_id': common_base.getid(security_service), | |
127 | }, | |
128 | } | |
129 | return self._create( | |
130 | RESOURCE_PATH % common_base.getid(share_network) + '/action', | |
131 | body, | |
132 | RESOURCE_NAME, | |
133 | ) | |
134 | 117 | |
135 | 118 | def remove_security_service(self, share_network, security_service): |
136 | 119 | """Dissociate security service from a share network. |
245 | 228 | path = RESOURCES_PATH + query_string |
246 | 229 | |
247 | 230 | return self._list(path, RESOURCES_NAME) |
231 | ||
232 | def _action(self, action, share_network, info=None): | |
233 | """Perform a share network 'action'. | |
234 | ||
235 | :param action: text with action name. | |
236 | :param share_network: either share_network object or text with its ID. | |
237 | :param info: dict with data for specified 'action'. | |
238 | """ | |
239 | body = {action: info} | |
240 | self.run_hooks('modify_body_for_action', body) | |
241 | url = ACTION_PATH % common_base.getid(share_network) | |
242 | return self.api.client.post(url, body=body) | |
243 | ||
244 | def add_security_service(self, share_network, security_service): | |
245 | """Associate given security service with a share network. | |
246 | ||
247 | :param share_network: share network name, id or ShareNetwork instance | |
248 | :param security_service: name, id or SecurityService instance | |
249 | :rtype: :class:`ShareNetwork` | |
250 | """ | |
251 | info = { | |
252 | 'security_service_id': common_base.getid(security_service), | |
253 | } | |
254 | return self._action('add_security_service', share_network, info) | |
255 | ||
256 | @api_versions.wraps("2.63") | |
257 | def add_security_service_check(self, share_network, security_service, | |
258 | reset_operation=False): | |
259 | """Associate given security service with a share network. | |
260 | ||
261 | :param share_network: share network name, id or ShareNetwork instance | |
262 | :param security_service: name, id or SecurityService instance | |
263 | :param reset_operation: start over the check operation | |
264 | :rtype: :class:`ShareNetwork` | |
265 | """ | |
266 | info = { | |
267 | 'security_service_id': common_base.getid(security_service), | |
268 | 'reset_operation': reset_operation, | |
269 | } | |
270 | return self._action('add_security_service_check', share_network, info) | |
271 | ||
272 | @api_versions.wraps("2.63") | |
273 | def update_share_network_security_service(self, share_network, | |
274 | current_security_service, | |
275 | new_security_service): | |
276 | """Update current security service to new one of a given share network. | |
277 | ||
278 | :param share_network: share network name, id or ShareNetwork instance | |
279 | :param current_security_service: current name, id or | |
280 | SecurityService instance that will be changed | |
281 | :param new_security_service: new name, id or | |
282 | SecurityService instance that will be updated | |
283 | :rtype: :class:`ShareNetwork` | |
284 | """ | |
285 | info = { | |
286 | 'current_service_id': common_base.getid(current_security_service), | |
287 | 'new_service_id': common_base.getid(new_security_service)} | |
288 | ||
289 | return self._action('update_security_service', share_network, info) | |
290 | ||
291 | @api_versions.wraps("2.63") | |
292 | def update_share_network_security_service_check( | |
293 | self, share_network, current_security_service, | |
294 | new_security_service, reset_operation=False): | |
295 | """Validates if the security service update is supported by all hosts. | |
296 | ||
297 | :param share_network: share network name, id or ShareNetwork instance | |
298 | :param current_security_service: current name, id or | |
299 | SecurityService instance that will be changed | |
300 | :param new_security_service: new name, id or | |
301 | :param reset_operation: start over the check operation | |
302 | SecurityService instance that will be updated | |
303 | :rtype: :class:`ShareNetwork` | |
304 | """ | |
305 | info = { | |
306 | 'current_service_id': common_base.getid(current_security_service), | |
307 | 'new_service_id': common_base.getid(new_security_service), | |
308 | 'reset_operation': reset_operation | |
309 | } | |
310 | ||
311 | return self._action('update_security_service_check', | |
312 | share_network, info) | |
313 | ||
314 | @api_versions.wraps("2.63") | |
315 | def reset_state(self, share_network, state): | |
316 | """Reset state of a share network. | |
317 | ||
318 | :param share_network: either share_network object or text with its ID | |
319 | or name. | |
320 | :param state: text with new state to set for share network. | |
321 | """ | |
322 | return self._action('reset_status', share_network, | |
323 | {"status": state}) |
3559 | 3559 | @cliutils.arg( |
3560 | 3560 | 'security_service', |
3561 | 3561 | metavar='<security-service>', |
3562 | help='Security service name or ID to associate with.') | |
3563 | @cliutils.arg( | |
3564 | '--reset', | |
3565 | metavar='<True|False>', | |
3566 | choices=['True', 'False'], | |
3567 | required=False, | |
3568 | default=False, | |
3569 | help='Reset and restart the check operation.' | |
3570 | '(Optional, Default=False)') | |
3571 | @api_versions.wraps("2.63") | |
3572 | def do_share_network_security_service_add_check(cs, args): | |
3573 | """Associate security service with share network.""" | |
3574 | share_network = _find_share_network(cs, args.share_network) | |
3575 | security_service = _find_security_service(cs, args.security_service) | |
3576 | add_sec_service_result = cs.share_networks.add_security_service_check( | |
3577 | share_network, security_service, reset_operation=args.reset) | |
3578 | # result[0] is response code, result[1] is dict body | |
3579 | cliutils.print_dict(add_sec_service_result[1]) | |
3580 | ||
3581 | ||
3582 | @cliutils.arg( | |
3583 | 'share_network', | |
3584 | metavar='<share-network>', | |
3585 | help='Share network name or ID.') | |
3586 | @cliutils.arg( | |
3587 | 'security_service', | |
3588 | metavar='<security-service>', | |
3562 | 3589 | help='Security service name or ID to dissociate.') |
3563 | 3590 | def do_share_network_security_service_remove(cs, args): |
3564 | 3591 | """Dissociate security service from share network.""" |
3591 | 3618 | fields = _split_columns(columns=args.columns) |
3592 | 3619 | |
3593 | 3620 | cliutils.print_list(security_services, fields=fields) |
3621 | ||
3622 | ||
3623 | @cliutils.arg( | |
3624 | 'share_network', | |
3625 | metavar='<share-network>', | |
3626 | help='Share network name or ID.') | |
3627 | @cliutils.arg( | |
3628 | 'current_security_service', | |
3629 | metavar='<current-security-service>', | |
3630 | help='Current security service name or ID.') | |
3631 | @cliutils.arg( | |
3632 | 'new_security_service', | |
3633 | metavar='<new-security-service>', | |
3634 | help='New security service name or ID.') | |
3635 | @api_versions.wraps("2.63") | |
3636 | def do_share_network_security_service_update(cs, args): | |
3637 | """Update a current security service to a new security service.""" | |
3638 | share_network = _find_share_network(cs, args.share_network) | |
3639 | current_security_service = _find_security_service( | |
3640 | cs, args.current_security_service) | |
3641 | new_security_service = _find_security_service( | |
3642 | cs, args.new_security_service) | |
3643 | cs.share_networks.update_share_network_security_service( | |
3644 | share_network, current_security_service, new_security_service) | |
3645 | ||
3646 | ||
3647 | @cliutils.arg( | |
3648 | 'share_network', | |
3649 | metavar='<share-network>', | |
3650 | help='Share network name or ID.') | |
3651 | @cliutils.arg( | |
3652 | 'current_security_service', | |
3653 | metavar='<current-security-service>', | |
3654 | help='Current security service name or ID.') | |
3655 | @cliutils.arg( | |
3656 | 'new_security_service', | |
3657 | metavar='<new-security-service>', | |
3658 | help='New security service name or ID.') | |
3659 | @cliutils.arg( | |
3660 | '--reset', | |
3661 | metavar='<True|False>', | |
3662 | choices=['True', 'False'], | |
3663 | required=False, | |
3664 | default=False, | |
3665 | help='Reset and start again the check operation.' | |
3666 | '(Optional, Default=False)') | |
3667 | @api_versions.wraps("2.63") | |
3668 | def do_share_network_security_service_update_check(cs, args): | |
3669 | """Check if a security service update on the share network is supported. | |
3670 | ||
3671 | This call can be repeated until a successful result is obtained. | |
3672 | """ | |
3673 | share_network = _find_share_network(cs, args.share_network) | |
3674 | current_security_service = _find_security_service( | |
3675 | cs, args.current_security_service) | |
3676 | new_security_service = _find_security_service( | |
3677 | cs, args.new_security_service) | |
3678 | share_network_update_check = ( | |
3679 | cs.share_networks.update_share_network_security_service_check( | |
3680 | share_network, current_security_service, new_security_service, | |
3681 | reset_operation=args.reset)) | |
3682 | # result[0] is response code, result[1] is dict body | |
3683 | cliutils.print_dict(share_network_update_check[1]) | |
3684 | ||
3685 | ||
3686 | @cliutils.arg( | |
3687 | 'share_network', | |
3688 | metavar='<share-network>', | |
3689 | help='Share network name or ID.') | |
3690 | @cliutils.arg( | |
3691 | '--state', | |
3692 | metavar='<state>', | |
3693 | default=constants.STATUS_ACTIVE, | |
3694 | help=('Indicate which state to assign the share network. Options include ' | |
3695 | 'active, error, network change. If no state is provided, active ' | |
3696 | 'will be used.')) | |
3697 | @api_versions.wraps("2.63") | |
3698 | def do_share_network_reset_state(cs, args): | |
3699 | """Explicitly update the state of a share network (Admin only).""" | |
3700 | share_network = _find_share_network(cs, args.share_network) | |
3701 | cs.share_networks.reset_state(share_network, args.state) | |
3594 | 3702 | |
3595 | 3703 | |
3596 | 3704 | @cliutils.arg( |
+14
-0
0 | --- | |
1 | features: | |
2 | - | | |
3 | Added support for updating and adding security services to in use share | |
4 | networks. The command ``share-network-security-service-update`` was | |
5 | added to the client. Before each of these commands is executed, make | |
6 | sure to run the correspondent check command, being either | |
7 | ``share-network-security-service-add-check`` or | |
8 | ``share-network-security-service-update-check``. These commands will | |
9 | check if the desired share network can have security services added or | |
10 | updated, based on the cloud support. Also, these commands can be used | |
11 | for both to request a check and to check the outcome. | |
12 | The command ``share-network-reset-state`` was also implemented in case | |
13 | there is need to update the share network ``status`` field. |