How to use remove_cfg_file method in avocado

Best Python code snippet using avocado_python

vrouter_netns.py

Source:vrouter_netns.py Github

copy

Full Screen

...127 lbaas_type = kvp.split('::::')[0]128 if (lbaas_type == 'haproxy_config'):129 break;130 return lbaas_type131 def remove_cfg_file(self, cfg_file):132 cmd = "rm " + cfg_file133 cmd_list = shlex.split(cmd)134 p = subprocess.Popen(cmd_list)135 p.communicate()136 def set_lbaas(self):137 if not self.ip_ns.netns.exists(self.namespace):138 self.create()139 if not (os.path.isfile(self.cfg_file)):140 msg = "%s is missing for "\141 "Loadbalancer-ID %s" %(self.cfg_file, self.loadbalancer_id)142 raise ValueError(msg)143 lbaas_type = self.find_lbaas_type(self.cfg_file)144 if (lbaas_type == ''):145 raise ValueError('LBAAS_TYPE does not exist %s' % self.cfg_file)146 if (lbaas_type == 'haproxy_config'):147 ret = haproxy_process.start_update_haproxy(148 self.loadbalancer_id, self.cfg_file,149 self.namespace, True)150 if (ret == False):151 self.remove_cfg_file(self.cfg_file)152 return False153 try:154 self.ip_ns.netns.execute(['route', 'add', 'default', 'gw', self.gw_ip])155 except RuntimeError:156 pass157 return True158 def release_lbaas(self, caller):159 if not self.ip_ns.netns.exists(self.namespace):160 raise ValueError('Need to create the network namespace before '161 'relasing lbaas')162 cfg_file = self.LBAAS_DIR + "/" + self.loadbalancer_id + ".conf"163 lbaas_type = self.find_lbaas_type(cfg_file)164 if (lbaas_type == ''):165 return166 elif (lbaas_type == 'haproxy_config'):167 haproxy_process.stop_haproxy(self.loadbalancer_id, True)168 try:169 self.ip_ns.netns.execute(['route', 'del', 'default'])170 except RuntimeError:171 pass172 if (caller == 'destroy'):173 self.remove_cfg_file(cfg_file)174 def destroy(self):175 if not self.ip_ns.netns.exists(self.namespace):176 raise ValueError('Namespace %s does not exist' % self.namespace)177 for device in self.ip_ns.get_devices(exclude_loopback=True):178 ip_lib.IPDevice(device.name,179 self.root_helper,180 self.namespace).link.delete()181 self.ip_ns.netns.delete(self.namespace)182 def plug_namespace_interface(self):183 for nic in self.nics:184 self._add_port_to_agent(nic,185 display_name='NetNS-%s-%s-interface'186 % (self.vm_uuid, nic['name']))187 def unplug_namespace_interface(self):...

Full Screen

Full Screen

bridge.py

Source:bridge.py Github

copy

Full Screen

...56 net_path = 'network-scripts'57 if detected_distro.name == "SuSE":58 net_path = 'network'59 if os.path.exists('/etc/sysconfig/%s/ifcfg-%s' % (net_path, self.bridge_interface)):60 self.networkinterface.remove_cfg_file()61 self.check_failure('ip link del %s' % self.bridge_interface)62 self.check_failure('ip link add dev %s type bridge'63 % self.bridge_interface)64 check_flag = False65 cmd = 'ip -d link show %s' % self.bridge_interface66 check_br = process.system_output(cmd, verbose=True,67 ignore_status=True).decode("utf-8")68 for line in check_br.splitlines():69 if line.find('bridge'):70 check_flag = True71 if not check_flag:72 self.fail('Bridge interface is not created')73 for host_interface in self.host_interfaces:74 self.check_failure('ip link set %s master %s'75 % (host_interface, self.bridge_interface))76 self.check_failure('ip addr flush dev %s' % host_interface)77 def test_bridge_run(self):78 '''79 run bridge test80 '''81 try:82 self.networkinterface.add_ipaddr(self.ipaddr, self.netmask)83 self.networkinterface.save(self.ipaddr, self.netmask)84 except Exception:85 self.networkinterface.save(self.ipaddr, self.netmask)86 self.networkinterface.bring_up()87 if self.networkinterface.ping_check(self.peer_ip, count=5) is not None:88 self.fail('Ping using bridge failed')89 self.networkinterface.remove_ipaddr(self.ipaddr, self.netmask)90 def test_bridge_delete(self):91 '''92 Set to original state93 '''94 self.check_failure('ip link del dev %s' % self.bridge_interface)95 try:96 self.networkinterface.restore_from_backup()97 except Exception:...

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 avocado 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