示例#1
0
文件: rpcserver.py 项目: 0day-ci/ovs
    def cleanup(self):
        """
        Delete all remaining bridges and ports if ovs-test client did not had
        a chance to remove them. It is necessary to call this function if
        ovs-test server is abruptly terminated when doing the tests.
        """
        for port in self.ports:
            # Remove ports that were added to existing bridges
            vswitch.ovs_vsctl_del_port_from_bridge(port)

        for bridge in self.bridges:
            # Remove bridges that were added for L3 tests
            vswitch.ovs_vsctl_del_bridge(bridge)

        for pbridge in self.pbridges:
            # Remove bridges that were added for VLAN tests
            vswitch.ovs_vsctl_del_pbridge(pbridge[0], pbridge[1])
示例#2
0
文件: rpcserver.py 项目: 0day-ci/ovs
 def xmlrpc_del_port_from_bridge(self, port):
     """
     Removes a port from OVS bridge.
     """
     ret = vswitch.ovs_vsctl_del_port_from_bridge(port)
     if ret == 0:
         self.ports.discard(port)
     return ret
示例#3
0
文件: rpcserver.py 项目: imadam33/ovs
 def xmlrpc_del_port_from_bridge(self, port):
     """
     Removes a port from OVS bridge.
     """
     ret = vswitch.ovs_vsctl_del_port_from_bridge(port)
     if ret == 0:
         self.ports.discard(port)
     return ret
示例#4
0
文件: rpcserver.py 项目: imadam33/ovs
    def cleanup(self):
        """
        Delete all remaining bridges and ports if ovs-test client did not had
        a chance to remove them. It is necessary to call this function if
        ovs-test server is abruptly terminated when doing the tests.
        """
        for port in self.ports:
            # Remove ports that were added to existing bridges
            vswitch.ovs_vsctl_del_port_from_bridge(port)

        for bridge in self.bridges:
            # Remove bridges that were added for L3 tests
            vswitch.ovs_vsctl_del_bridge(bridge)

        for pbridge in self.pbridges:
            # Remove bridges that were added for VLAN tests
            vswitch.ovs_vsctl_del_pbridge(pbridge[0], pbridge[1])
示例#5
0
    def run(self, line):
        args = line.split()
        check = False
        if (len(args) > 1):
            argument = args[0:][1]
            if (argument == "vlan"):
                if (common.get_console().prompt == "(config)"):
                    if (len(args[1:]) == 2):
                        vlan_id_to_delete = args[0:][2]
                        if (self.testing_no_vlan(vlan_id_to_delete)):
                            if (common.get_len_vlan_id() > 0):
                                for i in range(0, common.get_len_vlan_id()):
                                    if (vlan_id_to_delete ==
                                            common.get_item_vlan_id(i)):
                                        check = True
                                        for j in range(
                                                0,
                                                len(
                                                    common.
                                                    get_item_by_mini_vector(
                                                        i))):
                                            vswitch.ovs_vsctl_del_port_from_bridge(
                                                common.get_item_by_mini_vector(
                                                    i)[j])
                                            vswitch.ovs_vsctl_add_port_to_bridge(
                                                "br0",
                                                common.get_item_by_mini_vector(
                                                    i)[j])
                                        common.remove_item_vlan_id(
                                            common.get_item_vlan_id(i))
                                        common.remove_item_vlan_name(
                                            common.get_item_vlan_name(i))
                                        common.append_array_history(line)
                                        break
                                if (check == False):
                                    print(Colors.FAIL + "[ERROR] " +
                                          Colors.ENDC + "VLAN doesnt exist")
                            else:
                                print(Colors.FAIL + "[ERROR] " + Colors.ENDC +
                                      "No VLAN's created")
                        else:
                            print(Colors.FAIL + "[ERROR] " + Colors.ENDC +
                                  "Usage: no vlan [vlan id]")
                    else:
                        print(Colors.FAIL + "[ERROR] " + Colors.ENDC +
                              "Usage: no vlan [vlan id]")
                else:
                    print(Colors.FAIL + "[ERROR] " + Colors.ENDC +
                          "Bad command use")

            else:
                if (argument == "shutdown"):
                    if (common.get_console().prompt == "(config-if)"):
                        if (common.get_multi() == True):
                            common.append_array_multi(line)
                        else:
                            try:
                                subprocess.call([
                                    'ifconfig',
                                    '%s' % connecting_interfaces.get_connect(),
                                    'up'
                                ])
                                common.append_array_history(line)
                                for i in range(0, common.get_len_interfaces()):
                                    if (connecting_interfaces.get_connect(
                                    ) == common.get_item_array_interfaces(i)):
                                        common.set_up_down_interface(i)
                            except KeyboardInterrupt:
                                print(Colors.FAIL + "[ERROR] " + Colors.ENDC +
                                      "Bad command use")
                                return
                    else:
                        print(Colors.FAIL + "[ERROR] " + Colors.ENDC +
                              "Bad command use")
        else:
            print(Colors.FAIL + "[ERROR] " + Colors.ENDC + "Bad command use")