command = 'sudo ip link set dev ovim-{} down'.format(str(vlan))
self.run_command(command)
- command = 'sudo ifconfig {} down && sudo brctl delbr {}'.format(port_name, port_name)
+ command = 'sudo ip link delete {} && sudo brctl delbr {}'.format(port_name, port_name)
self.run_command(command)
return True
except RunCommandException as e:
# Delete ovs veth pair
command = 'sudo ip link set dev {} down'.format(br_ovs_name)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
command = 'sudo ovs-vsctl del-port br-int {}'.format(br_ovs_name)
self.run_command(command)
# Delete br veth pair
command = 'sudo ip link set dev {} down'.format(br_tap_name)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
# Delete br veth interface form bridge
command = 'sudo brctl delif {} {}'.format(link, br_tap_name)
# Delete br veth pair
command = 'sudo ip link set dev {} down'.format(link)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
return True
except RunCommandException as e:
command = 'sudo ip link set dev {} down'.format(ovs_veth_name)
self.run_command(command, ignore_exit_status=True) # to end session
+ command = 'sudo ip link delete {} '.format(ovs_veth_name)
+ self.run_command(command, ignore_exit_status=True)
+
command = 'sudo ip netns exec {} ip link set dev {} down'.format(dhcp_namespace, br_veth_name)
self.run_command(command, ignore_exit_status=True)
qrouter_ns_router_veth = '{}-vethQB'.format(str(vlan))
command = 'sudo ovs-vsctl del-port br-int {}'.format(qrouter_ovs_veth)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
# down ns veth
command = 'sudo ip netns exec {} ip link set dev {} down'.format(ns_qouter, qrouter_ns_veth)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
+
+ command = 'sudo ip netns exec {} ip link delete {} '.format(ns_qouter, qrouter_ns_veth)
+ self.run_command(command, ignore_exit_status=True)
command = 'sudo ip netns del ' + ns_qouter
self.run_command(command)
# down ovs veth interface
command = 'sudo ip link set dev {} down'.format(qrouter_br_veth)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
# down br veth interface
command = 'sudo ip link set dev {} down'.format(qrouter_ovs_veth)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
+
+ # delete veth interface
+ command = 'sudo ip link delete {} '.format(link, qrouter_ovs_veth)
+ self.run_command(command, ignore_exit_status=True)
# down br veth interface
command = 'sudo ip link set dev {} down'.format(qrouter_ns_router_veth)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
+
+ # delete veth interface
+ command = 'sudo ip link delete {} '.format(link, qrouter_ns_router_veth)
+ self.run_command(command, ignore_exit_status=True)
# down br veth interface
command = 'sudo brctl delif {} {}'.format(link, qrouter_br_veth)
# Create pait veth
command = 'sudo ip link add {} type veth peer name {}'.format(qrouter_ns_veth, qrouter_ovs_veth)
- self.run_command(command)
+ self.run_command(command, ignore_exit_status=True)
# up ovs veth interface
command = 'sudo ip link set dev {} up'.format(qrouter_ovs_veth)
links = net.get('links')
if links:
links = yaml.safe_load(net.get('links'))
- self.launch_dhcp_server(net.get('vlan'),
- net.get('dhcp_first_ip'),
- net.get('dhcp_last_ip'),
- net.get('cidr'),
- net.get('gateway_ip'),
- dns,
- routes)
+ if net.get('enable_dhcp'):
+ self.launch_dhcp_server(net.get('vlan'),
+ net.get('dhcp_first_ip'),
+ net.get('dhcp_last_ip'),
+ net.get('cidr'),
+ net.get('gateway_ip'),
+ dns,
+ routes)
self.launch_link_bridge_to_ovs(net['vlan'], net.get('gateway_ip'), net.get('cidr'), links, routes)
if net["status"] == "ERROR":
self.db.update_rows("nets", UPDATE={"status": "ACTIVE", "last_error": None},
network['routes'] = yaml.safe_dump(network['routes'], default_flow_style=True, width=256)
result, content = self.db.new_row('nets', network, True, True)
-
if result >= 0 and dhcp_integrity:
if bridge_net:
bridge_net[3] = content
- if self.config.get("dhcp_server") and self.config['network_type'] == 'bridge':
+ if self.config.get("dhcp_server") and self.config['network_type'] == 'bridge': # \
if network["name"] in self.config["dhcp_server"].get("nets", ()):
self.config["dhcp_nets"].append(content)
self.logger.debug("dhcp_server: add new net", content)
:param network_id: network id
:return:
"""
+ net_data = self.show_network(network_id)
# delete from the data base
result, content = self.db.delete_row('nets', network_id)
break
if self.config.get("dhcp_server") and network_id in self.config["dhcp_nets"]:
self.config["dhcp_nets"].remove(network_id)
- return content
+
+ if net_data.get('enable_dhcp'):
+ dhcp_path = self.config['ovs_controller_file_path']
+ dhcp_controller = self.get_dhcp_controller()
+ dhcp_controller.delete_dhcp_server(net_data['vlan'], network_id, dhcp_path)
+ dhcp_controller.delete_dhcp_port(net_data['vlan'], network_id, dhcp_path)
+ links = yaml.load(net_data.get('links'))
+ if links:
+ links = yaml.load(net_data.get('links'))
+ self.delete_link_bridge_to_ovs(net_data['vlan'], links)
+
+ return content
else:
raise ovimException("Error deleting network '{}': {}".format(network_id, content), -result)