How to use create_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

...223 }],224 'id': 'aaaa'225 }226 })227 neutronclient.Client.create_security_group_rule({228 'security_group_rule': {229 'direction': 'ingress',230 'remote_group_id': None,231 'remote_ip_prefix': '0.0.0.0/​0',232 'port_range_min': '22',233 'ethertype': 'IPv4',234 'port_range_max': '22',235 'protocol': 'tcp',236 'security_group_id': 'aaaa'237 }238 }).AndReturn({239 'security_group_rule': {240 'direction': 'ingress',241 'remote_group_id': None,242 'remote_ip_prefix': '0.0.0.0/​0',243 'port_range_min': '22',244 'ethertype': 'IPv4',245 'port_range_max': '22',246 'protocol': 'tcp',247 'security_group_id': 'aaaa',248 'id': 'bbbb'249 }250 })251 neutronclient.Client.create_security_group_rule({252 'security_group_rule': {253 'direction': 'ingress',254 'remote_group_id': None,255 'remote_ip_prefix': '0.0.0.0/​0',256 'port_range_min': '80',257 'ethertype': 'IPv4',258 'port_range_max': '80',259 'protocol': 'tcp',260 'security_group_id': 'aaaa'261 }262 }).AndReturn({263 'security_group_rule': {264 'direction': 'ingress',265 'remote_group_id': None,266 'remote_ip_prefix': '0.0.0.0/​0',267 'port_range_min': '80',268 'ethertype': 'IPv4',269 'port_range_max': '80',270 'protocol': 'tcp',271 'security_group_id': 'aaaa',272 'id': 'cccc'273 }274 })275 neutronclient.Client.create_security_group_rule({276 'security_group_rule': {277 'direction': 'ingress',278 'remote_group_id': 'wwww',279 'remote_ip_prefix': None,280 'port_range_min': None,281 'ethertype': 'IPv4',282 'port_range_max': None,283 'protocol': 'tcp',284 'security_group_id': 'aaaa'285 }286 }).AndReturn({287 'security_group_rule': {288 'direction': 'ingress',289 'remote_group_id': 'wwww',290 'remote_ip_prefix': None,291 'port_range_min': None,292 'ethertype': 'IPv4',293 'port_range_max': None,294 'protocol': 'tcp',295 'security_group_id': 'aaaa',296 'id': 'dddd'297 }298 })299 neutronclient.Client.show_security_group('aaaa').AndReturn({300 'security_group': {301 'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',302 'name': sg_name,303 'description': 'HTTP and SSH access',304 'security_group_rules': [{305 "direction": "egress",306 "ethertype": "IPv4",307 "id": "aaaa-1",308 "port_range_max": None,309 "port_range_min": None,310 "protocol": None,311 "remote_group_id": None,312 "remote_ip_prefix": None,313 "security_group_id": "aaaa",314 "tenant_id": "f18ca530cc05425e8bac0a5ff92f7e88"315 }, {316 "direction": "egress",317 "ethertype": "IPv6",318 "id": "aaaa-2",319 "port_range_max": None,320 "port_range_min": None,321 "protocol": None,322 "remote_group_id": None,323 "remote_ip_prefix": None,324 "security_group_id": "aaaa",325 "tenant_id": "f18ca530cc05425e8bac0a5ff92f7e88"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({...

Full Screen

Full Screen

test_security_groups_negative.py

Source: test_security_groups_negative.py Github

copy

Full Screen

...149 body, _ = self._create_security_group()150 min_port = 66151 max_port = 67152 # Create a rule with valid params153 self.client.create_security_group_rule(154 security_group_id=body['security_group']['id'],155 direction='ingress',156 ethertype=self.ethertype,157 protocol='tcp',158 port_range_min=min_port,159 port_range_max=max_port160 )161 # Try creating the same security group rule, it should fail162 self.assertRaises(163 lib_exc.Conflict, self.client.create_security_group_rule,164 security_group_id=body['security_group']['id'],165 protocol='tcp', direction='ingress', ethertype=self.ethertype,166 port_range_min=min_port, port_range_max=max_port)167 @test.attr(type=['negative', 'smoke'])...

Full Screen

Full Screen

security_group_rule.py

Source: security_group_rule.py Github

copy

Full Screen

...24 """25 connection = connect(session["token"], session["project_id"])26 load = SecurityGroupRuleSchema().load(request.json)27 if load["type"] == "ssh":28 new_rule = connection.network.create_security_group_rule(29 direction="ingress",30 protocol="tcp",31 port_range_max=22,32 port_range_min=22,33 security_group_id=security_group_id,34 ether_type="IPv4",35 )36 if load["type"] == "all_icmp":37 new_rule = connection.network.create_security_group_rule(38 direction="ingress",39 protocol="ICMP",40 security_group_id=security_group_id,41 ether_type="IPv4",42 remote_ip_prefix="0.0.0.0/​0")43 if load["type"] == "http":44 new_rule = connection.network.create_security_group_rule(45 direction="ingress",46 protocol="tcp",47 security_group_id=security_group_id,48 ether_type="IPv4",49 port_range_min="80",50 port_range_max="80",51 remote_ip_prefix="0.0.0.0/​0")52 if load["type"] == "https":53 new_rule = connection.network.create_security_group_rule(54 direction="ingress",55 protocol="tcp",56 port_range_min="443",57 port_range_max="443",58 security_group_id=security_group_id,59 ether_type="IPv4",60 remote_ip_prefix="0.0.0.0/​0")61 if load["type"] == "rdp":62 new_rule = connection.network.create_security_group_rule(63 direction="ingress",64 protocol="tcp",65 port_range_min="3389",66 port_range_max="3389",67 security_group_id=security_group_id,68 ether_type="IPv4",69 remote_ip_prefix="0.0.0.0/​0")...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Rebuild Confidence in Your Test Automation

These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.

What will come after “agile”?

I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

Do you possess the necessary characteristics to adopt an Agile testing mindset?

To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.

How To Refresh Page Using Selenium C# [Complete Tutorial]

When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.

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