How to use delete_security_group_rule method in tempest

Best Python code snippet using tempest_python

test_neutron_security_group.py

Source:test_neutron_security_group.py Github

copy

Full Screen

...326 }],327 'id': 'aaaa'328 }329 })330 neutronclient.Client.delete_security_group_rule('aaaa-1').AndReturn(331 None)332 neutronclient.Client.delete_security_group_rule('aaaa-2').AndReturn(333 None)334 neutronclient.Client.create_security_group_rule({335 'security_group_rule': {336 'direction': 'egress',337 'remote_group_id': None,338 'remote_ip_prefix': '10.0.1.0/24',339 'port_range_min': '22',340 'ethertype': 'IPv4',341 'port_range_max': '22',342 'protocol': 'tcp',343 'security_group_id': 'aaaa'344 }345 }).AndReturn({346 'security_group_rule': {347 'direction': 'egress',348 'remote_group_id': None,349 'remote_ip_prefix': '10.0.1.0/24',350 'port_range_min': '22',351 'ethertype': 'IPv4',352 'port_range_max': '22',353 'protocol': 'tcp',354 'security_group_id': 'aaaa',355 'id': 'eeee'356 }357 })358 neutronclient.Client.create_security_group_rule({359 'security_group_rule': {360 'direction': 'egress',361 'remote_group_id': 'xxxx',362 'remote_ip_prefix': None,363 'port_range_min': None,364 'ethertype': 'IPv4',365 'port_range_max': None,366 'protocol': None,367 'security_group_id': 'aaaa'368 }369 }).AndReturn({370 'security_group_rule': {371 'direction': 'egress',372 'remote_group_id': 'xxxx',373 'remote_ip_prefix': None,374 'port_range_min': None,375 'ethertype': 'IPv4',376 'port_range_max': None,377 'protocol': None,378 'security_group_id': 'aaaa',379 'id': 'ffff'380 }381 })382 neutronclient.Client.create_security_group_rule({383 'security_group_rule': {384 'direction': 'egress',385 'remote_group_id': 'aaaa',386 'remote_ip_prefix': None,387 'port_range_min': None,388 'ethertype': 'IPv4',389 'port_range_max': None,390 'protocol': None,391 'security_group_id': 'aaaa'392 }393 }).AndReturn({394 'security_group_rule': {395 'direction': 'egress',396 'remote_group_id': 'aaaa',397 'remote_ip_prefix': None,398 'port_range_min': None,399 'ethertype': 'IPv4',400 'port_range_max': None,401 'protocol': None,402 'security_group_id': 'aaaa',403 'id': 'gggg'404 }405 })406 # update script407 neutronclient.Client.update_security_group(408 'aaaa',409 {'security_group': {410 'description': 'SSH access for private network',411 'name': 'myrules'}}412 ).AndReturn({413 'security_group': {414 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',415 'name': 'myrules',416 'description': 'SSH access for private network',417 'security_group_rules': [],418 'id': 'aaaa'419 }420 })421 neutronclient.Client.show_security_group('aaaa').AndReturn(422 show_created)423 neutronclient.Client.delete_security_group_rule('bbbb').AndReturn(None)424 neutronclient.Client.delete_security_group_rule('cccc').AndReturn(None)425 neutronclient.Client.delete_security_group_rule('dddd').AndReturn(None)426 neutronclient.Client.delete_security_group_rule('eeee').AndReturn(None)427 neutronclient.Client.delete_security_group_rule('ffff').AndReturn(None)428 neutronclient.Client.delete_security_group_rule('gggg').AndReturn(None)429 neutronclient.Client.show_security_group('aaaa').AndReturn({430 'security_group': {431 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',432 'name': 'sc1',433 'description': '',434 'security_group_rules': [],435 'id': 'aaaa'436 }437 })438 neutronclient.Client.create_security_group_rule({439 'security_group_rule': {440 'direction': 'egress',441 'ethertype': 'IPv4',442 'security_group_id': 'aaaa',443 }444 }).AndReturn({445 'security_group_rule': {446 'direction': 'egress',447 'remote_group_id': None,448 'remote_ip_prefix': None,449 'port_range_min': None,450 'ethertype': 'IPv4',451 'port_range_max': None,452 'protocol': None,453 'security_group_id': 'aaaa',454 'id': 'hhhh'455 }456 })457 neutronclient.Client.create_security_group_rule({458 'security_group_rule': {459 'direction': 'egress',460 'ethertype': 'IPv6',461 'security_group_id': 'aaaa',462 }463 }).AndReturn({464 'security_group_rule': {465 'direction': 'egress',466 'remote_group_id': None,467 'remote_ip_prefix': None,468 'port_range_min': None,469 'ethertype': 'IPv6',470 'port_range_max': None,471 'protocol': None,472 'security_group_id': 'aaaa',473 'id': 'iiii'474 }475 })476 neutronclient.Client.create_security_group_rule({477 'security_group_rule': {478 'direction': 'ingress',479 'remote_group_id': None,480 'remote_ip_prefix': '10.0.0.10/24',481 'port_range_min': '22',482 'ethertype': 'IPv4',483 'port_range_max': '22',484 'protocol': 'tcp',485 'security_group_id': 'aaaa'486 }487 }).AndReturn({488 'security_group_rule': {489 'direction': 'ingress',490 'remote_group_id': None,491 'remote_ip_prefix': '10.0.0.10/24',492 'port_range_min': '22',493 'ethertype': 'IPv4',494 'port_range_max': '22',495 'protocol': 'tcp',496 'security_group_id': 'aaaa',497 'id': 'jjjj'498 }499 })500 # delete script501 neutronclient.Client.show_security_group('aaaa').AndReturn(502 show_created)503 neutronclient.Client.delete_security_group_rule('bbbb').AndReturn(None)504 neutronclient.Client.delete_security_group_rule('cccc').AndReturn(None)505 neutronclient.Client.delete_security_group_rule('dddd').AndReturn(None)506 neutronclient.Client.delete_security_group_rule('eeee').AndReturn(None)507 neutronclient.Client.delete_security_group_rule('ffff').AndReturn(None)508 neutronclient.Client.delete_security_group_rule('gggg').AndReturn(None)509 neutronclient.Client.delete_security_group('aaaa').AndReturn(None)510 self.m.ReplayAll()511 stack = self.create_stack(self.test_template)512 sg = stack['the_sg']513 self.assertResourceState(sg, 'aaaa')514 updated_tmpl = template_format.parse(self.test_template_update)515 updated_stack = utils.parse_stack(updated_tmpl)516 stack.update(updated_stack)517 stack.delete()518 self.m.VerifyAll()519 def test_security_group_exception(self):520 # create script521 sg_name = utils.PhysName('test_stack', 'the_sg')522 neutronclient.Client.create_security_group({523 'security_group': {524 'name': sg_name,525 'description': 'HTTP and SSH access'526 }527 }).AndReturn({528 'security_group': {529 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',530 'name': sg_name,531 'description': 'HTTP and SSH access',532 'security_group_rules': [],533 'id': 'aaaa'534 }535 })536 neutronclient.Client.create_security_group_rule({537 'security_group_rule': {538 'direction': 'ingress',539 'remote_group_id': None,540 'remote_ip_prefix': '0.0.0.0/0',541 'port_range_min': '22',542 'ethertype': 'IPv4',543 'port_range_max': '22',544 'protocol': 'tcp',545 'security_group_id': 'aaaa'546 }547 }).AndRaise(548 neutron_exc.Conflict())549 neutronclient.Client.create_security_group_rule({550 'security_group_rule': {551 'direction': 'ingress',552 'remote_group_id': None,553 'remote_ip_prefix': '0.0.0.0/0',554 'port_range_min': '80',555 'ethertype': 'IPv4',556 'port_range_max': '80',557 'protocol': 'tcp',558 'security_group_id': 'aaaa'559 }560 }).AndRaise(561 neutron_exc.Conflict())562 neutronclient.Client.create_security_group_rule({563 'security_group_rule': {564 'direction': 'ingress',565 'remote_group_id': 'wwww',566 'remote_ip_prefix': None,567 'port_range_min': None,568 'ethertype': 'IPv4',569 'port_range_max': None,570 'protocol': 'tcp',571 'security_group_id': 'aaaa'572 }573 }).AndRaise(574 neutron_exc.Conflict())575 neutronclient.Client.show_security_group('aaaa').AndReturn({576 'security_group': {577 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',578 'name': sg_name,579 'description': 'HTTP and SSH access',580 'security_group_rules': [],581 'id': 'aaaa'582 }583 })584 neutronclient.Client.create_security_group_rule({585 'security_group_rule': {586 'direction': 'egress',587 'remote_group_id': None,588 'remote_ip_prefix': '10.0.1.0/24',589 'port_range_min': '22',590 'ethertype': 'IPv4',591 'port_range_max': '22',592 'protocol': 'tcp',593 'security_group_id': 'aaaa'594 }595 }).AndRaise(596 neutron_exc.Conflict())597 neutronclient.Client.create_security_group_rule({598 'security_group_rule': {599 'direction': 'egress',600 'remote_group_id': 'xxxx',601 'remote_ip_prefix': None,602 'port_range_min': None,603 'ethertype': 'IPv4',604 'port_range_max': None,605 'protocol': None,606 'security_group_id': 'aaaa'607 }608 }).AndRaise(609 neutron_exc.Conflict())610 neutronclient.Client.create_security_group_rule({611 'security_group_rule': {612 'direction': 'egress',613 'remote_group_id': 'aaaa',614 'remote_ip_prefix': None,615 'port_range_min': None,616 'ethertype': 'IPv4',617 'port_range_max': None,618 'protocol': None,619 'security_group_id': 'aaaa'620 }621 }).AndRaise(622 neutron_exc.Conflict())623 # delete script624 neutronclient.Client.show_security_group('aaaa').AndReturn({625 'security_group': {626 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',627 'name': 'sc1',628 'description': '',629 'security_group_rules': [{630 'direction': 'ingress',631 'protocol': 'tcp',632 'port_range_max': '22',633 'id': 'bbbb',634 'ethertype': 'IPv4',635 'security_group_id': 'aaaa',636 'remote_group_id': None,637 'remote_ip_prefix': '0.0.0.0/0',638 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',639 'port_range_min': '22'640 }, {641 'direction': 'ingress',642 'protocol': 'tcp',643 'port_range_max': '80',644 'id': 'cccc',645 'ethertype': 'IPv4',646 'security_group_id': 'aaaa',647 'remote_group_id': None,648 'remote_ip_prefix': '0.0.0.0/0',649 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',650 'port_range_min': '80'651 }, {652 'direction': 'ingress',653 'protocol': 'tcp',654 'port_range_max': None,655 'id': 'dddd',656 'ethertype': 'IPv4',657 'security_group_id': 'aaaa',658 'remote_group_id': 'wwww',659 'remote_ip_prefix': None,660 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',661 'port_range_min': None662 }, {663 'direction': 'egress',664 'protocol': 'tcp',665 'port_range_max': '22',666 'id': 'eeee',667 'ethertype': 'IPv4',668 'security_group_id': 'aaaa',669 'remote_group_id': None,670 'remote_ip_prefix': '10.0.1.0/24',671 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',672 'port_range_min': '22'673 }, {674 'direction': 'egress',675 'protocol': None,676 'port_range_max': None,677 'id': 'ffff',678 'ethertype': 'IPv4',679 'security_group_id': 'aaaa',680 'remote_group_id': None,681 'remote_ip_prefix': 'xxxx',682 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',683 'port_range_min': None684 }, {685 'direction': 'egress',686 'protocol': None,687 'port_range_max': None,688 'id': 'gggg',689 'ethertype': 'IPv4',690 'security_group_id': 'aaaa',691 'remote_group_id': None,692 'remote_ip_prefix': 'aaaa',693 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',694 'port_range_min': None695 }],696 'id': 'aaaa'}})697 neutronclient.Client.delete_security_group_rule('bbbb').AndRaise(698 neutron_exc.NeutronClientException(status_code=404))699 neutronclient.Client.delete_security_group_rule('cccc').AndRaise(700 neutron_exc.NeutronClientException(status_code=404))701 neutronclient.Client.delete_security_group_rule('dddd').AndRaise(702 neutron_exc.NeutronClientException(status_code=404))703 neutronclient.Client.delete_security_group_rule('eeee').AndRaise(704 neutron_exc.NeutronClientException(status_code=404))705 neutronclient.Client.delete_security_group_rule('ffff').AndRaise(706 neutron_exc.NeutronClientException(status_code=404))707 neutronclient.Client.delete_security_group_rule('gggg').AndRaise(708 neutron_exc.NeutronClientException(status_code=404))709 neutronclient.Client.delete_security_group('aaaa').AndRaise(710 neutron_exc.NeutronClientException(status_code=404))711 neutronclient.Client.show_security_group('aaaa').AndRaise(712 neutron_exc.NeutronClientException(status_code=404))713 self.m.ReplayAll()714 stack = self.create_stack(self.test_template)715 sg = stack['the_sg']716 self.assertResourceState(sg, 'aaaa')717 scheduler.TaskRunner(sg.delete)()718 sg.state_set(sg.CREATE, sg.COMPLETE, 'to delete again')719 sg.resource_id = 'aaaa'720 stack.delete()721 self.m.VerifyAll()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful