diff --git a/apps/circuitpusher/circuitpusher.py b/apps/circuitpusher/circuitpusher.py index 344ecd96029ab9494d9672257affa358c58519d6..49bbcfaccc481dcbc48501733439fe49af80b0b1 100755 --- a/apps/circuitpusher/circuitpusher.py +++ b/apps/circuitpusher/circuitpusher.py @@ -94,12 +94,12 @@ if args.action=='add': result = os.popen(command).read() parsedResult = json.loads(result) print command+"\n" - + try: - sourceSwitch = parsedResult[0]['attachmentPoint'][0]['switchDPID'] + sourceSwitch = parsedResult[0]['attachmentPoint'][0]['switchDPID'] except IndexError: - print "ERROR : the specified end point (%s) must already been known to the controller (i.e., already have sent packets on the network, easy way to assure this is to do a ping (to any target) from the two hosts." % (args.srcAddress) - sys.exit() + print "ERROR : the specified end point (%s) must already been known to the controller (i.e., already have sent packets on the network, easy way to assure this is to do a ping (to any target) from the two hosts." % (args.srcAddress) + sys.exit() sourcePort = parsedResult[0]['attachmentPoint'][0]['port'] @@ -113,7 +113,7 @@ if args.action=='add': except IndexError: print "ERROR : the specified end point (%s) must already been known to the controller (i.e., already have sent packets on the network, easy way to assure this is to do a ping (to any target) from the two hosts." % (args.dstAddress) sys.exit() - + destPort = parsedResult[0]['attachmentPoint'][0]['port'] print "Creating circuit:" @@ -123,13 +123,11 @@ if args.action=='add': # retrieving route from source to destination # using Routing rest API - command = "curl -s http://%s/wm/topology/route/%s/%s/%s/%s/json" % (controllerRestIp, sourceSwitch, sourcePort, destSwitch, destPort) - + command = "curl -s http://%s/wm/topology/route/%s/%s/%s/%s/json" % (controllerRestIp, sourceSwitch, sourcePort['shortPortNumber'], destSwitch, destPort['shortPortNumber']) result = os.popen(command).read() - parsedResult = json.loads(result) - - print command+"\n" print result+"\n" + print command+"\n" + parsedResult = json.loads(result) for i in range(len(parsedResult)): if i % 2 == 0: @@ -151,26 +149,26 @@ if args.action=='add': # encode each flow entry's name with both switch dpid, user # specified name, and flow type (f: forward, r: reverse, farp/rarp: arp) - command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"src-ip\":\"%s\", \"dst-ip\":\"%s\", \"ether-type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress-port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".f", args.srcAddress, args.dstAddress, "0x800", ap1Port, ap2Port, controllerRestIp) + command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"nw_src\":\"%s\", \"nw_dst\":\"%s\", \"dl_type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress_port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".f", args.srcAddress, args.dstAddress, "0x800", ap1Port['shortPortNumber'], ap2Port['shortPortNumber'], controllerRestIp) result = os.popen(command).read() print command - command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"ether-type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress-port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".farp", "0x806", ap1Port, ap2Port, controllerRestIp) + command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"arp_spa\":\"%s\", \"arp_dpa\":\"%s\", \"dl_type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress_port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".farp", args.srcAddress, args.dstAddress, "0x806", ap1Port['shortPortNumber'], ap2Port['shortPortNumber'], controllerRestIp) result = os.popen(command).read() print command - command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"src-ip\":\"%s\", \"dst-ip\":\"%s\", \"ether-type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress-port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".r", args.dstAddress, args.srcAddress, "0x800", ap2Port, ap1Port, controllerRestIp) + command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"nw_src\":\"%s\", \"nw_dst\":\"%s\", \"dl_type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress_port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".r", args.dstAddress, args.srcAddress, "0x800", ap2Port['shortPortNumber'], ap1Port['shortPortNumber'], controllerRestIp) result = os.popen(command).read() print command - command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"ether-type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress-port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".rarp", "0x806", ap2Port, ap1Port, controllerRestIp) + command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"arp_spa\":\"%s\", \"arp_dpa\":\"%s\", \"dl_type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress_port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".rarp",args.dstAddress, args.srcAddress, "0x806", ap2Port['shortPortNumber'], ap1Port['shortPortNumber'], controllerRestIp) result = os.popen(command).read() print command - + # store created circuit attributes in local ./circuits.json datetime = time.asctime() - circuitParams = {'name':args.circuitName, 'Dpid':ap1Dpid, 'inPort':ap1Port, 'outPort':ap2Port, 'datetime':datetime} + circuitParams = {'name':args.circuitName, 'Dpid':ap1Dpid, 'inPort':ap1Port['shortPortNumber'], 'outPort':ap2Port['shortPortNumber'], 'datetime':datetime} str = json.dumps(circuitParams) circuitDb.write(str+"\n") diff --git a/src/main/java/net/floodlightcontroller/devicemanager/web/DeviceSerializer.java b/src/main/java/net/floodlightcontroller/devicemanager/web/DeviceSerializer.java index 0cd43e245ac822fcb46a88cbf5d8cf59c3a29d0f..e45e438056ea2b6c55e982fbaff106fb57efa9b8 100644 --- a/src/main/java/net/floodlightcontroller/devicemanager/web/DeviceSerializer.java +++ b/src/main/java/net/floodlightcontroller/devicemanager/web/DeviceSerializer.java @@ -55,7 +55,7 @@ public class DeviceSerializer extends JsonSerializer<Device> { jGen.writeArrayFieldStart("vlan"); for (VlanVid vlan : device.getVlanId()) if (vlan.getVlan() >= 0) - jGen.writeNumber(vlan.toString()); + jGen.writeString(vlan.toString()); jGen.writeEndArray(); jGen.writeArrayFieldStart("attachmentPoint"); for (SwitchPort ap : device.getAttachmentPoints(true)) { diff --git a/src/main/java/net/floodlightcontroller/topology/Cluster.java b/src/main/java/net/floodlightcontroller/topology/Cluster.java index 914740f10246698c95c7cf0085cb09465c79a709..f896410fdc9a30c9bb8a8d9cd5ede71d06b9c86f 100644 --- a/src/main/java/net/floodlightcontroller/topology/Cluster.java +++ b/src/main/java/net/floodlightcontroller/topology/Cluster.java @@ -53,7 +53,8 @@ public class Cluster { void add(DatapathId n) { if (links.containsKey(n) == false) { links.put(n, new HashSet<Link>()); - if (n.getLong() < id.getLong()) id = n; + if (id == DatapathId.NONE || n.getLong() < id.getLong()) + id = n ; } } diff --git a/src/main/java/net/floodlightcontroller/topology/NodePortTuple.java b/src/main/java/net/floodlightcontroller/topology/NodePortTuple.java index 8df5bcb83e8b8ed11d2dac7cdbf7556d82ce8192..2e336c3b8ef270b105bdc5f40a580721b25896ea 100644 --- a/src/main/java/net/floodlightcontroller/topology/NodePortTuple.java +++ b/src/main/java/net/floodlightcontroller/topology/NodePortTuple.java @@ -55,7 +55,6 @@ public class NodePortTuple implements Comparable<NodePortTuple> { this.nodeId = nodeId; } @JsonProperty("port") - @JsonSerialize(using=UShortSerializer.class) public OFPort getPortId() { return portId; }