Add Flow Condition RestConfig for Vtn Manager
[integration/test.git] / csit / libraries / VtnMaKeywords.robot
index af73b55ced5dd3fcd13ae6c54ff96e503995a9da..d8b38f4fdff8a413ae980f72f7959dcd4715e4eb 100644 (file)
@@ -31,6 +31,10 @@ ${pathpolicy_topo_10}    sudo mn --controller=remote,ip=${CONTROLLER} --custom t
 ${policy_id}      1
 @{PATHPOLICY_ATTR}    "id":"1"    "type":"OF"    "name":"s4-eth2"
 ${custom}         ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
+${in_port}        1
+${out_before_pathpolicy}    output:2
+${out_after_pathpolicy}    output:3
+${flowcond_restconfigdata}    {"input":{"operation":"SET","present":"false","name":"cond_1","vtn-flow-match":[{"vtn-ether-match":{"destination-address":"ba:bd:0f:e3:a8:c8","ether-type":"2048","source-address":"ca:9e:58:0c:1e:f0","vlan-id": "1"},"vtn-inet-match":{"source-network":"10.0.0.1/32","protocol":1,"destination-network":"10.0.0.2/32"},"index":"1"}]}}
 
 *** Keywords ***
 Start SuiteVtnMa
@@ -48,6 +52,10 @@ Start SuiteVtnMaTest
     [Documentation]    Start VTN Manager Test Suite
     Create Session    session    http://${CONTROLLER}:${RESTPORT}    auth=${AUTH}    headers=${HEADERS}
 
+Start SuiteVtnMaRestConfTest
+    [Documentation]    Start VTN Manager Rest Config Api Test Suite
+    Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
+
 Stop SuiteVtnMaTest
     [Documentation]    Stop VTN Manager Test Suite
     Delete All Sessions
@@ -135,25 +143,13 @@ Get a pathpolicy
     : FOR    ${pathpolicyElement}    IN    @{PATHPOLICY_ATTR}
     \    should Contain    ${resp.content}    ${pathpolicyElement}
 
-Verify flowEntryBeforePathPolicy
-    [Arguments]    ${OF_VERSION}
-    [Documentation]    Checking Flows on switch S1 and switch S3 before applying path policy
-    ${DUMPFLOWS}=    Set Variable If    "${OF_VERSION}"=="OF10"    ${DUMPFLOWS_OF10}    ${DUMPFLOWS_OF13}
-    write    ${DUMPFLOWS}
-    ${result}    Read Until    mininet>
-    @{list_to_verify}    Create List    in_port=1    actions=output:2    actions=output:3
-    : FOR    ${flowverifyElement}    IN    @{list_to_verify}
-    \    should Contain    ${result}    ${flowverifyElement}
-
-Verify flowEntryAfterPathPolicy
-    [Arguments]    ${OF_VERSION}
+Verify flowEntryPathPolicy
+    [Arguments]    ${of_version}    ${port}    ${output}
     [Documentation]    Checking Flows on switch S1 and switch S3 after applying path policy
-    ${DUMPFLOWS}=    Set Variable If    "${OF_VERSION}"=="OF10"    ${DUMPFLOWS_OF10}    ${DUMPFLOWS_OF13}
+    ${DUMPFLOWS}=    Set Variable If    "${of_version}"=="OF10"    ${DUMPFLOWS_OF10}    ${DUMPFLOWS_OF13}
     write    ${DUMPFLOWS}
     ${result}    Read Until    mininet>
-    @{list_to_verify}    Create List    in_port=1    actions=output:3    in_port=2
-    : FOR    ${flowverifyElement}    IN    @{list_to_verify}
-    \    should Contain    ${result}    ${flowverifyElement}
+    Should Contain    ${result}    in_port=${port}    actions=${output}
 
 Start PathSuiteVtnMaTest
     [Documentation]    Start VTN Manager Test Suite and Mininet
@@ -267,26 +263,31 @@ Remove a portmap
 
 Verify FlowMacAddress
     [Arguments]    ${host1}    ${host2}    ${OF_VERSION}
-    Run Keyword If    '${OF_VERSION}' == 'OF10'    VerifyFlowsOnOpenFlow    ${host1}    ${host2}    ${DUMPFLOWS_OF10}
+    [Documentation]    Verify the source and destination mac address.
+    Run Keyword If    '${OF_VERSION}' == 'OF10'    Verify Flows On OpenFlow    ${host1}    ${host2}    ${DUMPFLOWS_OF10}
     ...    ELSE    VerifyFlowsOnOpenFlow    ${host1}    ${host2}    ${DUMPFLOWS_OF13}
 
-VerifyFlowsOnOpenFlow
+Verify Flows On OpenFlow
     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
+    [Documentation]    Verify the mac addresses on the specified open flow.
     ${booleanValue}=    Run Keyword And Return Status    Verify macaddress    ${host1}    ${host2}    ${DUMPFLOWS}
     Should Be Equal As Strings    ${booleanValue}    True
 
 Verify RemovedFlowMacAddress
     [Arguments]    ${host1}    ${host2}    ${OF_VERSION}
-    Run Keyword If    '${OF_VERSION}' == 'OF10'    VerifyRemovedFlowsOnOpenFlow    ${host1}    ${host2}    ${DUMPFLOWS_OF10}
+    [Documentation]    Verify the removed source and destination mac address.
+    Run Keyword If    '${OF_VERSION}' == 'OF10'    Verify Removed Flows On OpenFlow    ${host1}    ${host2}    ${DUMPFLOWS_OF10}
     ...    ELSE    VerifyRemovedFlowsOnOpenFlow    ${host1}    ${host2}    ${DUMPFLOWS_OF13}
 
-VerifyRemovedFlowsOnOpenFlow
+Verify Removed Flows On OpenFlow
     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
+    [Documentation]    Verify the removed mac addresses on the specified open flow.
     ${booleanValue}=    Run Keyword And Return Status    Verify macaddress    ${host1}    ${host2}    ${DUMPFLOWS}
     Should Not Be Equal As Strings    ${booleanValue}    True
 
 Verify macaddress
     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
+    [Documentation]    Verify the source and destination mac address after ping in the dumpflows
     write    ${host1} ifconfig -a | grep HWaddr
     ${sourcemacaddr}    Read Until    mininet>
     ${macaddress}=    Split String    ${sourcemacaddr}    ${SPACE}
@@ -360,3 +361,26 @@ Verify Actions on Flow Entry
     ${result}    Read Until    mininet>
     : FOR    ${flowElement}    IN    @{FLOWELMENTS}
     \    should Contain    ${result}    ${flowElement}
+
+Add a flowcondition In Restconfig
+    [Documentation]    Create a flowcondition using Restconfig Api
+    ${resp}=    RequestsLibrary.Post    session    restconf/operations/vtn-flow-condition:set-flow-condition    data=${flowcond_restconfigdata}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Get flowconditions In Restconfig
+    [Documentation]    Retrieve the list of flowconditions created
+    ${resp}=    RequestsLibrary.Get    session    restconf/operational/vtn-flow-condition:vtn-flow-conditions
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Get flowcondition In Restconfig
+    [Arguments]    ${flowcond_name}    ${retrieve}
+    [Documentation]    Retrieve the flowcondition by name
+    ${resp}=    RequestsLibrary.Get    session    restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
+    Run Keyword If    '${retrieve}' == 'retrieve'    Should Be Equal As Strings    ${resp.status_code}    200
+    ...    ELSE    Should Not Be Equal As Strings    ${resp.status_code}    200
+
+Remove flowcondition In Restconfig
+    [Arguments]    ${flowcond_name}
+    [Documentation]    Remove the flowcondition by name
+    ${resp}=    RequestsLibrary.Post    session    restconf/operations/vtn-flow-condition:remove-flow-condition    {"input": {"name": "${flowcond_name}"}}
+    Should Be Equal As Strings    ${resp.status_code}    200