Example #1
0
    def clean_container_bridge_ovs(container_name, ip_destination, ovs_source):
        basic_cmd = "brctl delif br{0} veth{0}Ovs".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "ovs-vsctl del-port {} vethOvs{}".format(
            ovs_source, container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "ip link del dev veth{}Ovs".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "ifconfig br{} down".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "brctl delbr br{}".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)
Example #2
0
 def get_ovs(i, ip_destination):
     basic_cmd = 'ovs-vsctl list-br'
     stdin, stdout, stderr = system_driver.ssh_query(
         basic_cmd, ip_destination, True)
     result = stdout.read()
     stdin.flush()
     c = result.decode().split('\n')
     return str(c[i])
Example #3
0
    def friendly_ovs_name(self, device1, ip_destination):
        cmd = 'ovs-vsctl --columns=mac_in_use,name list Interface'
        stdin, stdout, stderr = system_driver.ssh_query(
            cmd, ip_destination, True)
        result = stdout.read()
        stdin.flush()
        device = result.decode().split('\n')
        device1 = device1.replace("of:0000", "")
        for j in range(int(len(device) / 3)):
            device.remove('')

        for i in range(len(device)):
            temp = device[i].split(":", 1)[1]
            reps = {'"': '', ':': '', ' ': ''}
            x = self.replace_all(temp, reps)
            if x == device1:
                temp = device[i + 1].split(":", 1)[1]
                reps = {'"': '', ' ': ''}
                print(self.replace_all(temp, reps))
                return self.replace_all(temp, reps)
Example #4
0
    def overlay_network(ip_source, ip_destination, ovs_source, ovs_destination,
                        interface_name, vxlan_port):

        cmd = []
        ip = []

        cmd1 = 'ovs-vsctl add-port ' + str(ovs_source) + '  ' + str(interface_name) + \
               ' -- set interface ' + str(interface_name) + ' type=' + 'vxlan' + ' options:remote_ip=' \
               + str(ip_destination) + ' ofport_request=' + str(vxlan_port)
        cmd.append(cmd1)
        ip.append(ip_source)

        cmd2 = 'ovs-vsctl add-port ' + str(ovs_destination) + '  ' + str(interface_name) \
               + ' -- set interface ' + str(interface_name) + ' type=' + 'vxlan' + \
               ' options:remote_ip=' + str(ip_source) + ' ofport_request=' \
               + str(vxlan_port)
        cmd.append(cmd2)
        ip.append(ip_destination)

        for i in range(len(cmd)):
            a, b, c = system_driver.ssh_query(cmd[i], ip[i], True)
Example #5
0
    def target_container_bridge_ovs(container_name, ip_destination,
                                    ovs_destination, server_port_number):
        basic_cmd = 'ip link add name veth{0}Ovs type veth peer name vethOvs{0}'.format(
            container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "ip link set vethOvs{} up".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "ip link set veth{}Ovs up".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "brctl addbr br{}".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "ifconfig br{} up".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "brctl addif br{0} veth{0}Ovs".format(container_name)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)

        basic_cmd = "sudo ovs-vsctl add-port {2} vethOvs{0} -- set Interface vethOvs{0} ofport_request={1}".format(
            container_name, server_port_number, ovs_destination)
        a, b, c = system_driver.ssh_query(basic_cmd, ip_destination, True)