示例#1
0
def main(argc, argv):
    try:
        opts, args = getopt.getopt(argv, "b:a:ds:m:l:hS")
    except getopt.getOptError:
        usage()

    for opt, arg in opts:
        if opt == "-S":
            ovs_path = "/usr/bin"
        else:
            ovs_sb = os.environ['ovs_sb']
            OVS_DIR = home + "/Linux/src/sandbox/" + ovs_sb + "/VCA"
            ovs_path = OVS_DIR + "/utilities"

    hostname = os.uname()[1]
    logfile = home + "/Downloads/logs/" + progname + "." + hostname + ".log"
    logfd = logger.open_log(logfile)
    flow = ovs_flows.Flows(ovs_path, logfd)
    ofproto = ovs_ofproto.OFProto(ovs_path)

    bridge = ofproto.get_bridge()

    for opt, arg in opts:
        if opt == "-h":
            usage()
        elif opt == "-b":
            port_1, port_2 = arg.split(',', 1)
            flow.set_b2b_flows(bridge, port_1, port_2)
        elif opt == "-a":
            port_1, port_2 = arg.split(',', 1)
            flow.set_arp_flows(bridge, port_1, port_2)
        elif opt == "-m":
            port_1, mac_2, port_2 = arg.split(',', 2)
            flow.set_dst_mac_flow(bridge, port_1, mac_2, port_2)
        elif opt == "-s":
            port_1, port_2 = arg.split(',', 1)
            flow.set_flow(bridge, port_1, port_2)
        elif opt == "-l":
            port, dst_mac, src_mac, dst_ip, src_ip = arg.split(',', 4)
            flow.set_dst_mac_flow(bridge, port, dst_mac, src_mac, dst_ip,
                                  src_ip)
        elif opt == "-d":
            flow.reset(bridge)
示例#2
0
 def get_ofp_port(self):
     ofproto = ovs_ofproto.OFProto(self.ovs_path)
     return ofproto.ofp_port(self.br, self.iface)
示例#3
0
 def __init__(self, ovs_path, logfd):
     self.logfd = logfd
     self.ofctl_path = ovs_path + "/ovs-ofctl"
     self.appctl_path = ovs_path + "/ovs-appctl"
     self.ofproto = ovs_ofproto.OFProto(ovs_path)
示例#4
0
 def __init__(self, ovs_path, br, logfd):
     self.appctl_path = ovs_path + "/ovs-appctl"
     self.br = br
     self.logfd = logfd
     self.flow = ovs_flows.Flows(ovs_path, self.logfd)
     self.ofproto = ovs_ofproto.OFProto(ovs_path)