How to use delete_interface method in tempest

Best Python code snippet using tempest_python

main.py

Source:main.py Github

copy

Full Screen

...14 @Service.create15 def cb_create(self, tctx, root, service, proplist):16 self.log.info('Service create(service=', service._path, ')')17 connections = dict()18 def delete_interface((device_name, interface_name)):19 if device_name in service.router:20 device = root.devices.device[device_name]21 ldp_interfaces = device.config.mpls_ldp_cfg__mpls_ldp.\22 default_vrf.interfaces.interface23 if interface_name in ldp_interfaces:24 del ldp_interfaces[interface_name]25 def get_interfaces(device_name):26 return root.devices.device[device_name].config.\27 ifmgr_cfg__interface_configurations.interface_configuration28 for current_service in root.services.disable_ldp__disable_ldp:29 for router in current_service.router:30 for interface in get_interfaces(router.device_name):31 entry = (router.device_name, interface.interface_name)32 ip_network = interface_to_ip_network(interface)33 if ip_network in connections:34 connections[ip_network].append(entry)35 else:36 connections[ip_network] = [entry]37 for connection in connections.values():38 if len(connection) == 2:39 delete_interface(connection[0])40 delete_interface(connection[1])41# ---------------------------------------------42# COMPONENT THREAD THAT WILL BE STARTED BY NCS.43# ---------------------------------------------44class Main(ncs.application.Application):45 def setup(self):46 # The application class sets up logging for us. It is accessible47 # through 'self.log' and is a ncs.log.Log instance.48 self.log.info('Main RUNNING')49 # Service callbacks require a registration for a 'service point',50 # as specified in the corresponding data model.51 #52 self.register_service('disable-ldp', ServiceCallbacks)53 # If we registered any callback(s) above, the Application class54 # took care of creating a daemon (related to the service/action point)....

Full Screen

Full Screen

20210416.py

Source:20210416.py Github

copy

Full Screen

...59 assert 'luoboovo' == content.json()['name']60 assert 5 > content.elapsed.total_seconds()61 print('POST没有错误..')62 return content.json()63def delete_interface(url):64 """65 删除66 :param url: 删除的地址67 :return: 返回空68 """69 content = requests.delete(70 url=url71 )72 return content.text73def put_interface(data, url):74 content = requests.put(75 url=url,76 data=data77 )78 return content.json()79def patch_interface(data, url):80 content = requests.put(81 url=url,82 data=data83 )84 return content.json()85if __name__ == '__main__':86 # get请求87 get_result = get_interface('https://reqres.in/api/users?page=2')88 get_result_01 = get_interface('https://reqres.in/api/users?delay=3')89 print(get_result_01)90 # post接口91 post_result = post_interface(data, 'https://reqres.in/api/users')92 #delete接口93 delete_result = delete_interface('https://reqres.in/api/users/2')94 # put接口95 put_result = put_interface(data, 'https://reqres.in/api/users/2')96 # patch接口...

Full Screen

Full Screen

routerinterfacespage.py

Source:routerinterfacespage.py Github

copy

Full Screen

...18 field_mappings=self.CREATE_INTERFACE_FORM_FIELDS19 )2021 @tables.bind_table_action('delete')22 def delete_interface(self, delete_button):23 delete_button.click()24 return forms.BaseFormRegion(self.driver)2526 @tables.bind_row_action('delete')27 def delete_interface_by_row(self, delete_button, row):28 delete_button.click()29 return forms.BaseFormRegion(self.driver)303132class RouterInterfacesPage(basepage.BasePage):3334 INTERFACES_TABLE_STATUS_COLUMN = 'Status'35 INTERFACES_TABLE_NAME_COLUMN = 'Name'36 DEFAULT_SUBNET = 'external-net0'3738 def _get_row_with_interface_name(self, name):39 return self.interfaces_table.get_row(40 self.INTERFACES_TABLE_NAME_COLUMN, name)4142 @property43 def interfaces_table(self):44 return InterfacesTable(self.driver)4546 @property47 def interfaces_names(self):48 return list(map(lambda row: row.cells[self.49 INTERFACES_TABLE_NAME_COLUMN].text,50 self.interfaces_table.rows))5152 def create_interface(self):53 interface_form = self.interfaces_table.create_interface()54 interface_form.subnet_id.text = self.DEFAULT_SUBNET55 # interface_form.ip_address.text = self.DEFAULT_IPv4_ADDRESS56 interface_form.submit()5758 def delete_interface(self, interface_name):59 row = self._get_row_with_interface_name(interface_name)60 row.mark()61 confirm_delete_interface_form = self.interfaces_table.\62 delete_interface()63 confirm_delete_interface_form.submit()6465 def delete_interface_by_row_action(self, interface_name):66 row = self._get_row_with_interface_name(interface_name)67 confirm_delete_interface = self.interfaces_table.\68 delete_interface_by_row_action(row)69 confirm_delete_interface.submit()7071 def is_interface_present(self, interface_name):72 return bool(self._get_row_with_interface_name(interface_name))7374 def is_interface_status(self, interface_name, status):75 row = self._get_row_with_interface_name(interface_name)76 return row.cells[self.INTERFACES_TABLE_STATUS_COLUMN].text == status

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