Best Python code snippet using tempest_python
test_security_groups_basic_ops.py
Source:test_security_groups_basic_ops.py
...224 )225 name = data_utils.rand_name(name)226 server = self._create_server(name, tenant)227 tenant.servers.append(server)228 def _set_access_point(self, tenant):229 """230 creates a server in a secgroup with rule allowing external ssh231 in order to access tenant internal network232 workaround ip namespace233 """234 secgroups = tenant.security_groups.values()235 name = 'server-{tenant}-access_point-'.format(236 tenant=tenant.creds.tenant_name)237 name = data_utils.rand_name(name)238 server = self._create_server(name, tenant,239 security_groups=secgroups)240 tenant.access_point = server241 self._assign_floating_ips(tenant, server)242 def _assign_floating_ips(self, tenant, server):243 public_network_id = CONF.network.public_network_id244 floating_ip = self._create_floating_ip(245 server, public_network_id,246 client=tenant.manager.network_client)247 self.floating_ips.setdefault(server['id'], floating_ip)248 def _create_tenant_network(self, tenant):249 network, subnet, router = self.create_networks(250 client=tenant.manager.network_client)251 tenant.set_network(network, subnet, router)252 def _set_compute_context(self, tenant):253 self.servers_client = tenant.manager.servers_client254 return self.servers_client255 def _deploy_tenant(self, tenant_or_id):256 """257 creates:258 network259 subnet260 router (if public not defined)261 access security group262 access-point server263 """264 if not isinstance(tenant_or_id, self.TenantProperties):265 tenant = self.tenants[tenant_or_id]266 else:267 tenant = tenant_or_id268 self._set_compute_context(tenant)269 self._create_tenant_keypairs(tenant)270 self._create_tenant_network(tenant)271 self._create_tenant_security_groups(tenant)272 self._set_access_point(tenant)273 def _get_server_ip(self, server, floating=False):274 """275 returns the ip (floating/internal) of a server276 """277 if floating:278 server_ip = self.floating_ips[server['id']].floating_ip_address279 else:280 server_ip = None281 network_name = self.tenants[server['tenant_id']].network.name282 if network_name in server['addresses']:283 server_ip = server['addresses'][network_name][0]['addr']284 return server_ip285 def _connect_to_access_point(self, tenant):286 """...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!