[CORD-3154] Adding support for host-learning config in fabric ports
Change-Id: Ic7f00d625ecd6fc6e0085a01bfccd3dd5fc64d7b
diff --git a/Dockerfile.synchronizer b/Dockerfile.synchronizer
index f985a4e..3147ae4 100644
--- a/Dockerfile.synchronizer
+++ b/Dockerfile.synchronizer
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# docker build -t xosproject/fabric-synchronizer:candidate -f Dockerfile.synchronizer .
+
# xosproject/fabric-synchronizer
FROM xosproject/xos-synchronizer-base:candidate
diff --git a/samples/fabric.yaml b/samples/fabric.yaml
index 838c800..f61a3b7 100644
--- a/samples/fabric.yaml
+++ b/samples/fabric.yaml
@@ -32,7 +32,6 @@
name: leaf1
ofId: of:0000000000000001
routerMac: 00:00:02:01:06:01
-
# Setup a fabric switch port
port#port1:
@@ -54,3 +53,14 @@
- port:
node: port#port1
relationship: tosca.relationships.BelongsToOne
+
+ # Setup a fabric switch port with host_learning disabled
+ port#port2:
+ type: tosca.nodes.SwitchPort
+ properties:
+ portId: 2
+ host_learning: false
+ requirements:
+ - switch:
+ node: switch#leaf1
+ relationship: tosca.relationships.BelongsToOne
\ No newline at end of file
diff --git a/xos/synchronizer/models/fabric.xproto b/xos/synchronizer/models/fabric.xproto
index ac617be..71ad3ee 100644
--- a/xos/synchronizer/models/fabric.xproto
+++ b/xos/synchronizer/models/fabric.xproto
@@ -24,6 +24,7 @@
required manytoone switch->Switch:ports = 1 [help_text = "The fabric switch the port belongs to", db_index = True, null = False, blank = False, tosca_key=True];
required int32 portId = 2 [help_text = "The unique port OpenFlow port ID", null = False, db_index = False, blank = False, tosca_key=True];
+ required bool host_learning = 3 [help_text = "whether or not to enable autodiscovery", default = True, null = False, db_index = False, blank = False];
}
message PortInterface(XOSBase) {
diff --git a/xos/synchronizer/steps/sync_fabric_port.py b/xos/synchronizer/steps/sync_fabric_port.py
index 793bfd2..bfac5b9 100644
--- a/xos/synchronizer/steps/sync_fabric_port.py
+++ b/xos/synchronizer/steps/sync_fabric_port.py
@@ -43,13 +43,18 @@
# Send port config to onos-fabric netcfg
data = {
- "ports": {
- "%s/%s" % (model.switch.ofId, model.portId) : {
- "interfaces" : interfaces
+ "ports": {
+ "%s/%s" % (model.switch.ofId, model.portId) : {
+ "interfaces": interfaces,
+ "hostLearning": {
+ "enabled": model.host_learning
+ }
+ }
}
- }
}
+ log.debug("Port %s/%s data" % (model.switch.ofId, model.portId), data=data)
+
onos = Helpers.get_onos_fabric_service()
url = 'http://%s:%s/onos/v1/network/configuration/' % (onos.rest_hostname, onos.rest_port)
@@ -61,9 +66,9 @@
raise Exception("Failed to add port %s into ONOS" % model.name)
else:
try:
- print r.json()
+ log.info("Port %s/%s response" % (model.switch.ofId, model.portId), json=r.json())
except Exception:
- print r.text
+ log.info("Port %s/%s response" % (model.switch.ofId, model.portId), text=r.text)
def delete_record(self, model):
log.info("Removing port %s/%s from onos-fabric" % (model.switch.ofId, model.portId))
diff --git a/xos/synchronizer/steps/test_sync_fabric_port.py b/xos/synchronizer/steps/test_sync_fabric_port.py
index 00aded5..696a6a7 100644
--- a/xos/synchronizer/steps/test_sync_fabric_port.py
+++ b/xos/synchronizer/steps/test_sync_fabric_port.py
@@ -100,6 +100,7 @@
self.o = Mock()
self.o.id = 1
self.o.tologdict.return_value = {}
+ self.o.host_learning = True
@@ -127,7 +128,10 @@
"name": intf1.name,
"ips": [ intf1.ips ]
}
- ]
+ ],
+ "hostLearning": {
+ "enabled": self.o.host_learning
+ }
}
}
}
@@ -153,6 +157,7 @@
self.o.interfaces.all.return_value = [intf1]
self.o.switch.ofId = "of:1234"
self.o.portId = "1"
+ self.o.host_learning = False
expected_conf = {
"ports": {
@@ -163,7 +168,10 @@
"ips": [intf1.ips],
"vlan-untagged": intf1.vlanUntagged
}
- ]
+ ],
+ "hostLearning": {
+ "enabled": self.o.host_learning
+ }
}
}
}