How to use _get_network_id method in tempest

Best Python code snippet using tempest_python

network.py

Source:network.py Github

copy

Full Screen

...28 def get_resource_type(self):29 return self._SUPPORT_RESOURCE_TYPE30 def get_parent_resource_types(self):31 return (constants.PROJECT_RESOURCE_TYPE)32 def _get_network_id(self):33 """Set network_id as project_id34 Cause the network plugin include the ports, networks,35 subnets, routes, securitygroups, So make the id for36 the whole plugin-package info, not just like the server37 plugin which have the real server-id for the server.38 """39 network_id = self._context.project_id40 return network_id41 def list_resources(self, context, parameters=None):42 try:43 netclient = self._neutron_client(context)44 networks = netclient.list_networks(45 project_id=context.project_id).get('networks')46 except Exception as e:47 LOG.exception("List all summary networks from neutron failed.")48 raise exception.ListProtectableResourceFailed(49 type=self._SUPPORT_RESOURCE_TYPE,50 reason=six.text_type(e))51 else:52 if networks:53 return [resource.Resource(type=self._SUPPORT_RESOURCE_TYPE,54 id=self._get_network_id(),55 name="Network Topology")]56 return []57 def show_resource(self, context, resource_id, parameters=None):58 try:59 if resource_id != self._get_network_id():60 return None61 netclient = self._neutron_client(context)62 networks = netclient.list_networks(63 project_id=resource_id).get('networks')64 except Exception as e:65 LOG.exception("List all summary networks from neutron failed.")66 raise exception.ListProtectableResourceFailed(67 type=self._SUPPORT_RESOURCE_TYPE,68 reason=six.text_type(e))69 else:70 if networks:71 return resource.Resource(type=self._SUPPORT_RESOURCE_TYPE,72 id=self._get_network_id(),73 name="Network Topology")74 return None75 def _get_dependent_resources_by_project(self,76 context,77 parent_resource):78 try:79 project_id = parent_resource.id80 netclient = self._neutron_client(context)81 networks = netclient.list_networks(82 project_id=project_id).get('networks')83 if networks:84 return [resource.Resource(type=self._SUPPORT_RESOURCE_TYPE,85 id=self._get_network_id(),86 name="Network Topology")]87 else:88 return []89 except Exception as e:90 LOG.exception("List all summary networks from neutron failed.")91 raise exception.ListProtectableResourceFailed(92 type=self._SUPPORT_RESOURCE_TYPE,93 reason=six.text_type(e))94 def get_dependent_resources(self, context, parent_resource):95 return self._get_dependent_resources_by_project(...

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