Merge "Refactor VLAN intent tests to actually use VLAN selectors"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index d5777f9..7e5cb3c 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1115,11 +1115,13 @@
main.cleanup()
main.exit()
- def addHostIntent( self, hostIdOne, hostIdTwo ):
+ def addHostIntent( self, hostIdOne, hostIdTwo, vlanId="" ):
"""
Required:
* hostIdOne: ONOS host id for host1
* hostIdTwo: ONOS host id for host2
+ Optional:
+ * vlanId: specify a VLAN id for the intent
Description:
Adds a host-to-host intent ( bidirectional ) by
specifying the two hosts.
@@ -1127,8 +1129,10 @@
A string of the intent id or None on Error
"""
try:
- cmdStr = "add-host-intent " + str( hostIdOne ) +\
- " " + str( hostIdTwo )
+ cmdStr = "add-host-intent "
+ if vlanId:
+ cmdStr += "-v " + str( vlanId ) + " "
+ cmdStr += str( hostIdOne ) + " " + str( hostIdTwo )
handle = self.sendline( cmdStr )
assert "Command not found:" not in handle, handle
if re.search( "Error", handle ):
@@ -1224,7 +1228,8 @@
ipSrc="",
ipDst="",
tcpSrc="",
- tcpDst="" ):
+ tcpDst="",
+ vlanId="" ):
"""
Required:
* ingressDevice: device id of ingress device
@@ -1241,6 +1246,7 @@
* ipDst: specify ip destination address
* tcpSrc: specify tcp source port
* tcpDst: specify tcp destination port
+ * vlanId: specify vlan ID
Description:
Adds a point-to-point intent ( uni-directional ) by
specifying device id's and optional fields
@@ -1282,6 +1288,8 @@
cmd += " --tcpSrc " + str( tcpSrc )
if tcpDst:
cmd += " --tcpDst " + str( tcpDst )
+ if vlanId:
+ cmd += " -v " + str( vlanId )
# Check whether the user appended the port
# or provided it as an input
@@ -1360,7 +1368,8 @@
tcpSrc="",
tcpDst="",
setEthSrc="",
- setEthDst="" ):
+ setEthDst="",
+ vlanId="" ):
"""
Note:
This function assumes the format of all ingress devices
@@ -1385,6 +1394,7 @@
* tcpDst: specify tcp destination port
* setEthSrc: action to Rewrite Source MAC Address
* setEthDst: action to Rewrite Destination MAC Address
+ * vlanId: specify vlan Id
Description:
Adds a multipoint-to-singlepoint intent ( uni-directional ) by
specifying device id's and optional fields
@@ -1431,6 +1441,8 @@
cmd += " --setEthSrc " + str( setEthSrc )
if setEthDst:
cmd += " --setEthDst " + str( setEthDst )
+ if vlanId:
+ cmd += " -v " + str( vlanId )
# Check whether the user appended the port
# or provided it as an input
@@ -1513,7 +1525,8 @@
tcpSrc="",
tcpDst="",
setEthSrc="",
- setEthDst="" ):
+ setEthDst="",
+ vlanId="" ):
"""
Note:
This function assumes the format of all egress devices
@@ -1538,6 +1551,7 @@
* tcpDst: specify tcp destination port
* setEthSrc: action to Rewrite Source MAC Address
* setEthDst: action to Rewrite Destination MAC Address
+ * vlanId: specify vlan Id
Description:
Adds a singlepoint-to-multipoint intent ( uni-directional ) by
specifying device id's and optional fields
@@ -1584,6 +1598,8 @@
cmd += " --setEthSrc " + str( setEthSrc )
if setEthDst:
cmd += " --setEthDst " + str( setEthDst )
+ if vlanId:
+ cmd += " -v " + str( vlanId )
# Check whether the user appended the port
# or provided it as an input
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 080aa8f..1bff0f1 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -836,8 +836,8 @@
main.step( "VLAN1: Add vlan host intents between h4 and h12" )
main.assertReturnString = "Assertion Result vlan IPV4\n"
- host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
- host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
+ host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
+ host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
testResult = main.FALSE
installResult = main.FALSE
installResult = main.intentFunction.installHostIntent( main,
@@ -864,36 +864,6 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString)
- main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
- main.assertReturnString = "Assertion Result different VLAN negative test\n"
- host1 = { "name":"h13" }
- host2 = { "name":"h20" }
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installHostIntent( main,
- name='VLAN2',
- onosNode='0',
- host1=host1,
- host2=host2)
-
- if installResult:
- testResult = main.intentFunction.testHostIntent( main,
- name='VLAN2',
- intentId = installResult,
- onosNode='0',
- host1=host1,
- host2=host2,
- sw1='s5',
- sw2='s2',
- expectedLink = 18)
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString)
-
main.step( "Confirm that ONOS leadership is unchanged")
intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
main.intentFunction.checkLeaderChange( intentLeadersOld,
@@ -1184,25 +1154,24 @@
main.step( "VLAN: Add point intents between h5 and h21" )
main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
senders = [
- { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
+ { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
]
recipients = [
- { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
+ { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
]
testResult = main.FALSE
installResult = main.FALSE
installResult = main.intentFunction.installPointIntent(
main,
- name="DUALSTACK1",
+ name="VLAN",
senders=senders,
- recipients=recipients,
- ethType="IPV4" )
+ recipients=recipients)
if installResult:
testResult = main.intentFunction.testPointIntent(
main,
intentId=installResult,
- name="DUALSTACK1",
+ name="VLAN",
senders=senders,
recipients=recipients,
sw1="s5",
@@ -1434,11 +1403,11 @@
main.step( "VLAN: Add single point to multi point intents" )
main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses in the same VLAN\n"
senders = [
- { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
+ { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
]
recipients = [
- { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
- { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
+ { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
+ { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
]
badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
@@ -1446,10 +1415,9 @@
installResult = main.FALSE
installResult = main.intentFunction.installSingleToMultiIntent(
main,
- name="IPV4",
+ name="VLAN`",
senders=senders,
recipients=recipients,
- ethType="IPV4",
sw1="s5",
sw2="s2")
@@ -1457,7 +1425,7 @@
testResult = main.intentFunction.testPointIntent(
main,
intentId=installResult,
- name="IPV4",
+ name="VLAN",
senders=senders,
recipients=recipients,
badSenders=badSenders,
@@ -1658,11 +1626,11 @@
main.step( "VLAN: Add multi point to single point intents" )
main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses in the same VLAN\n"
senders = [
- { "name":"h13", "device":"of:0000000000000006/5" },
- { "name":"h21", "device":"of:0000000000000007/5" }
+ { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
+ { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
]
recipients = [
- { "name":"h5", "device":"of:0000000000000005/5" }
+ { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
]
badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
@@ -1673,7 +1641,6 @@
name="VLAN",
senders=senders,
recipients=recipients,
- ethType="IPV4",
sw1="s5",
sw2="s2")
@@ -1863,156 +1830,8 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
- main.step( "IPV4: Add multi point to single point intents" )
- main.assertReturnString = "Assertion results for IPV4 multi to single \
- point intent end point failure with IPV4 type and MAC addresses\n"
- senders = [
- { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
- { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
- ]
- recipients = [
- { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
- ]
- isolatedSenders = [
- { "name":"h24"}
- ]
- isolatedRecipients = []
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installMultiToSingleIntent(
- main,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
- main.step( "IPV4_2: Add multi point to single point intents" )
- main.assertReturnString = "Assertion results for IPV4 multi to single \
- point intent end point failure with IPV4 type and no MAC addresses\n"
- senders = [
- { "name":"h16", "device":"of:0000000000000006/8" },
- { "name":"h24", "device":"of:0000000000000007/8" }
- ]
- recipients = [
- { "name":"h8", "device":"of:0000000000000005/8" }
- ]
- isolatedSenders = [
- { "name":"h24"}
- ]
- isolatedRecipients = []
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installMultiToSingleIntent(
- main,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
- main.step( "VLAN: Add multi point to single point intents" )
- main.assertReturnString = "Assertion results for IPV4 multi to single \
- point intent end point failure with IPV4 type and no MAC addresses in the same VLAN\n"
- senders = [
- { "name":"h13", "device":"of:0000000000000006/5" },
- { "name":"h21", "device":"of:0000000000000007/5" }
- ]
- recipients = [
- { "name":"h5", "device":"of:0000000000000005/5" }
- ]
- isolatedSenders = [
- { "name":"h21"}
- ]
- isolatedRecipients = []
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installMultiToSingleIntent(
- main,
- name="VLAN",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="VLAN",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
main.step( "NOOPTION: Install and test single point to multi point intents" )
- main.assertReturnString = "Assertion results for IPV4 single to multi \
- point intent end point failure with no options set\n"
+ main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
senders = [
{ "name":"h8", "device":"of:0000000000000005/8" }
]
@@ -2020,9 +1839,8 @@
{ "name":"h16", "device":"of:0000000000000006/8" },
{ "name":"h24", "device":"of:0000000000000007/8" }
]
- isolatedSenders = []
- isolatedRecipients = [
- { "name":"h24" }
+ isolatedSenders = [
+ { "name":"h24"}
]
testResult = main.FALSE
installResult = main.FALSE
@@ -2058,151 +1876,4 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
- main.step( "IPV4: Install and test single point to multi point intents" )
- main.assertReturnString = "Assertion results for IPV4 single to multi \
- point intent end point failure with IPV4 type and no MAC addresses\n"
- senders = [
- { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
- ]
- recipients = [
- { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
- { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
- ]
- isolatedSenders = []
- isolatedRecipients = [
- { "name":"h24" }
- ]
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installSingleToMultiIntent(
- main,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
- main.step( "IPV4_2: Add single point to multi point intents" )
- main.assertReturnString = "Assertion results for IPV4 single to multi\
- point intent endpoint failure with IPV4 type and no MAC addresses\n"
- senders = [
- { "name":"h8", "device":"of:0000000000000005/8" }
- ]
- recipients = [
- { "name":"h16", "device":"of:0000000000000006/8" },
- { "name":"h24", "device":"of:0000000000000007/8" }
- ]
- isolatedSenders = []
- isolatedRecipients = [
- { "name":"h24" }
- ]
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installSingleToMultiIntent(
- main,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4_2",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
- main.step( "VLAN: Add single point to multi point intents" )
- main.assertReturnString = "Assertion results for IPV4 single to multi point\
- intent endpoint failure with IPV4 type and MAC addresses in the same VLAN\n"
- senders = [
- { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
- ]
- recipients = [
- { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
- { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
- ]
- isolatedSenders = []
- isolatedRecipients = [
- { "name":"h20" }
- ]
- testResult = main.FALSE
- installResult = main.FALSE
- installResult = main.intentFunction.installSingleToMultiIntent(
- main,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- ethType="IPV4",
- sw1="s5",
- sw2="s2")
-
- if installResult:
- testResult = main.intentFunction.testEndPointFail(
- main,
- intentId=installResult,
- name="IPV4",
- senders=senders,
- recipients=recipients,
- isolatedSenders=isolatedSenders,
- isolatedRecipients=isolatedRecipients,
- sw1="s6",
- sw2="s2",
- sw3="s4",
- sw4="s1",
- sw5="s3",
- expectedLink1=16,
- expectedLink2=14 )
- else:
- main.CLIs[ 0 ].removeAllIntents( purge=True )
-
- utilities.assert_equals( expect=main.TRUE,
- actual=testResult,
- onpass=main.assertReturnString,
- onfail=main.assertReturnString )
-
main.intentFunction.report( main )
\ No newline at end of file
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index 88a0cad..dede2c8 100644
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -22,7 +22,7 @@
ipAddresses="",
tcp="",
sw1="",
- sw2=""):
+ sw2="" ):
"""
Installs a Host Intent
@@ -75,8 +75,10 @@
host2[ "id" ] = main.hostsData.get( host2.get( "name" ) ).get( "id" )
# Adding point intent
+ vlanId = host1.get( "vlan" )
intentId = main.CLIs[ onosNode ].addHostIntent( hostIdOne=host1.get( "id" ),
- hostIdTwo=host2.get( "id" ) )
+ hostIdTwo=host2.get( "id" ),
+ vlanId=vlanId )
except (KeyError, TypeError):
errorMsg = "There was a problem loading the hosts data."
if intentId:
@@ -168,6 +170,7 @@
senderNames = [ host1.get( "name" ), host2.get( "name" ) ]
recipientNames = [ host1.get( "name" ), host2.get( "name" ) ]
+ vlanId = host1.get( "vlan" )
testResult = main.TRUE
except (KeyError, TypeError):
@@ -191,7 +194,7 @@
testResult = main.FALSE
# Check Connectivity
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Initial Ping Passed\n'
else:
main.assertReturnString += 'Initial Ping Failed\n'
@@ -228,7 +231,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Down Pingall Passed\n'
else:
main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -266,7 +269,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Up Pingall Passed\n'
else:
main.assertReturnString += 'Link Up Pingall Failed\n'
@@ -364,6 +367,8 @@
ipSrc = senders[ 0 ].get( "ip" )
ipDst = recipients[ 0 ].get( "ip" )
+ vlanId = senders[ 0 ].get( "vlan" )
+
# Adding point intent
intentId = main.CLIs[ onosNode ].addPointIntent(
ingressDevice=ingressDevice,
@@ -378,7 +383,8 @@
ipSrc=ipSrc,
ipDst=ipDst,
tcpSrc=tcpSrc,
- tcpDst=tcpDst )
+ tcpDst=tcpDst,
+ vlanId=vlanId )
except (KeyError, TypeError):
errorMsg = "There was a problem loading the hosts data."
if intentId:
@@ -758,6 +764,7 @@
portEgressList = None
srcMac = senders[ 0 ].get( "mac" )
+ vlanId = senders[ 0 ].get( "vlan" )
# Adding point intent
intentId = main.CLIs[ onosNode ].addSinglepointToMultipointIntent(
@@ -773,7 +780,8 @@
ipSrc="",
ipDst="",
tcpSrc="",
- tcpDst="" )
+ tcpDst="",
+ vlanId=vlanId )
except (KeyError, TypeError):
errorMsg = "There was a problem loading the hosts data."
if intentId:
@@ -869,6 +877,7 @@
portIngressList = None
dstMac = recipients[ 0 ].get( "mac" )
+ vlanId = senders[ 0 ].get( "vlan" )
# Adding point intent
intentId = main.CLIs[ onosNode ].addMultipointToSinglepointIntent(
@@ -884,7 +893,8 @@
ipSrc="",
ipDst="",
tcpSrc="",
- tcpDst="" )
+ tcpDst="",
+ vlanId=vlanId )
except (KeyError, TypeError):
errorMsg = "There was a problem loading the hosts data."
if intentId:
@@ -993,6 +1003,7 @@
if not recipient.get( "device" ):
main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) )
recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" )
+ vlanId = senders[ 0 ].get( "vlan" )
except (KeyError, TypeError):
main.log.error( "There was a problem loading the hosts data." )
return main.FALSE
@@ -1015,7 +1026,7 @@
testResult = main.FALSE
# Check Connectivity
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ), attempts=3, sleep=5 ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ), attempts=3, sleep=5 ):
main.assertReturnString += 'Initial Ping Passed\n'
else:
main.assertReturnString += 'Initial Ping Failed\n'
@@ -1069,7 +1080,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Down Pingall Passed\n'
else:
main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -1107,7 +1118,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
else:
main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
@@ -1292,7 +1303,7 @@
# Check Connectivity
# First check connectivity of any isolated senders to recipients
if isolatedSenderNames:
- if scapyCheckConnection( main, isolatedSenderNames, recipientNames, None, None, main.TRUE ):
+ if scapyCheckConnection( main, isolatedSenderNames, recipientNames, None, None, None, main.TRUE ):
main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
else:
main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
@@ -1300,7 +1311,7 @@
# Next check connectivity of senders to any isolated recipients
if isolatedRecipientNames:
- if scapyCheckConnection( main, senderNames, isolatedRecipientNames, None, None, main.TRUE ):
+ if scapyCheckConnection( main, senderNames, isolatedRecipientNames, None, None, None, main.TRUE ):
main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
else:
main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
@@ -1592,7 +1603,7 @@
linkResult = main.Mininet1.link( end1=sw1, end2=sw2, option=option )
return linkResult
-def scapyCheckConnection( main, senders, recipients, packet=None, packetFilter=None, expectFailure=False ):
+def scapyCheckConnection( main, senders, recipients, vlanId=None, packet=None, packetFilter=None, expectFailure=False ):
"""
Checks the connectivity between all given sender hosts and all given recipient hosts
Packet may be specified. Defaults to Ether/IP packet
@@ -1631,17 +1642,31 @@
connectionsFunctional = main.FALSE
continue
- recipientComp.startFilter( pktFilter = packetFilter.format( senderComp.hostMac ) )
+ if vlanId:
+ recipientComp.startFilter( pktFilter = ( "vlan {}".format( vlanId ) + " && " + packetFilter.format( senderComp.hostMac ) ) )
+ else:
+ recipientComp.startFilter( pktFilter = packetFilter.format( senderComp.hostMac ) )
if not packet:
- pkt = 'Ether( src="{0}", dst="{2}" )/IP( src="{1}", dst="{3}" )'.format(
- senderComp.hostMac,
- senderComp.hostIp,
- recipientComp.hostMac,
- recipientComp.hostIp )
+ if vlanId:
+ pkt = 'Ether( src="{0}", dst="{2}" )/Dot1Q(vlan={4})/IP( src="{1}", dst="{3}" )'.format(
+ senderComp.hostMac,
+ senderComp.hostIp,
+ recipientComp.hostMac,
+ recipientComp.hostIp,
+ vlanId )
+ else:
+ pkt = 'Ether( src="{0}", dst="{2}" )/IP( src="{1}", dst="{3}" )'.format(
+ senderComp.hostMac,
+ senderComp.hostIp,
+ recipientComp.hostMac,
+ recipientComp.hostIp )
else:
pkt = packet
- senderComp.sendPacket( packet = pkt )
+ if vlanId:
+ senderComp.sendPacket( iface=( "{0}-eth0.{1}".format( sender, vlanId ) ), packet = pkt )
+ else:
+ senderComp.sendPacket( packet = pkt )
if recipientComp.checkFilter( timeout ):
if expectFailure: