2 Documentation Basic Tests for NIC Console Commands.
4 ... Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
9 Suite Setup Setup NIC Console Environment
12 Library OperatingSystem
13 Library ../../../libraries/Common.py
14 Resource ../../../libraries/KarafKeywords.robot
15 Resource ../../../libraries/Utils.robot
16 Variables ../../../variables/Variables.py
19 @{intent1} 10.0.0.5 10.0.0.2,10.0.0.3 ALLOW
20 @{intent2} 10.0.0.5 10.0.0.2,10.0.0.10 BLOCK
21 @{intent3} 10.0.0.1,10.0.0.4 10.0.0.2 ALLOW
22 @{all_intents} ${intent1} ${intent2} ${intent3}
24 ${intent_validation1} from [10.0.0.1, 10.0.0.4] to [10.0.0.2]
25 ${intent_validation2} from [10.0.0.5] to [10.0.0.2]
26 ${intent_validation3} from [10.0.0.5] to [10.0.0.3]
27 ${intent_validation4} from [10.0.0.5] to [10.0.0.10]
28 ${intent_validation_policy1} ALLOW
29 ${intent_validation_policy2} BLOCK
30 ${intent_validation_policy3} ALLOW
31 ${intent_validation_policy4} BLOCK
32 @{all_intent_validations} ${intent_validation1} ${intent_validation2} ${intent_validation3} ${intent_validation4}
33 @{all_intent_validations_policies} ${intent_validation_policy1} ${intent_validation_policy2} ${intent_validation_policy3} ${intent_validation_policy4}
36 Verify NIC Command Add and Remove
37 [Documentation] Verification of NIC Console command add and remove. It first creates the intents
38 ... and stores the intent ids, then verifies that the intents were added. Finally, it compiles the intents
39 ... to verify that intents were properly merged and also validates intents were removed at the end per the cleanup procedure.
41 Wait Until Keyword Succeeds 10 min 5 sec Verify Intent:Add Command is Availible
42 : FOR ${intent} IN @{all_intents}
43 \ ${id}= Add Intent @{intent}
44 \ Append To List ${all_intents_ids} ${id}
45 ${size}= Get Length ${all_intents}
46 : FOR ${index} IN RANGE ${size}
47 \ ${intent}= Get From List ${all_intents} ${index}
48 \ ${intent_id}= Get From List ${all_intents_ids} ${index}
49 \ Verify Intent Added ${intent_id} ${intent}
50 ${output}= Issue Command On Karaf Console intent:compile
51 ${size}= Get Length ${all_intent_validations}
52 : FOR ${index} IN RANGE ${size}
53 \ ${compiled_intent_validation}= Get From List ${all_intent_validations} ${index}
54 \ ${intent_validation_line}= Get Lines Containing String ${output} ${compiled_intent_validation}
55 \ ${policy}= Get From List ${all_intent_validations_policies} ${index}
56 \ Should Contain ${intent_validation_line} ${policy}
57 : FOR ${intent_id} IN @{all_intents_ids}
58 \ Remove Intent ${intent_id}
59 ${output}= Issue Command On Karaf Console intent:list -c
60 : FOR ${intent_id} IN @{all_intents_ids}
61 \ Should Not Contain ${output} ${id}
64 Setup NIC Console Environment
65 [Documentation] Installing NIC Console related features (odl-nic-core, odl-nic-console)
66 Install a Feature odl-nic-core
67 Install a Feature odl-nic-console
69 Verify Feature Is Installed odl-nic-core
70 Verify Feature Is Installed odl-nic-console
73 [Arguments] ${intent_from} ${intent_to} ${intent_permission}
74 [Documentation] Adds an intent to the controller, and returns the id of the intent created.
75 ${output}= Issue Command On Karaf Console intent:add -f ${intent_from} -t ${intent_to} -a ${intent_permission}
76 Should Contain ${output} Intent created
77 ${output}= Fetch From Left ${output} )
78 ${output_split}= Split String ${output} ${SPACE}
79 ${id}= Get From List ${output_split} 3
82 Verify Intent:Add Command is Availible
83 [Documentation] Verifies that odl-nic-console is up and intent:add command is available to be used.
84 ... Should be used with the command "Wait Until Keyword Succeeds" to poll until command is availible.
85 ${output}= Issue Command On Karaf Console intent:add
86 Should Not Contain ${output} Command not found
90 [Arguments] ${id} ${intent}
91 [Documentation] This will check if the id exists via intent:list -c, then compares intent details with arguments passed in with Add Intent
92 ${output}= Issue Command On Karaf Console intent:list -c
93 Should Contain ${output} ${id}
94 ${output}= Issue Command On Karaf Console intent:show ${id}
95 ${out}= Get Lines Containing String ${output} Value:
96 ${out_intent_from}= Get Line ${out} 0
97 ${out_intent_to}= Get Line ${out} 1
98 ${out_intent_permission}= Get Line ${out} 2
99 ${intent_from}= Get From List ${intent} 0
100 ${intent_to}= Get From List ${intent} 1
101 ${intent_permission}= Get From List ${intent} 2
102 Should Contain ${out_intent_from} ${intent_from}
103 Should Contain ${out_intent_to} ${intent_to}
104 Should Contain ${out_intent_permission} ${intent_permission}
108 [Documentation] Removes an intent from the controller via the provided intent id.
109 ${output}= Issue Command On Karaf Console intent:remove ${id}
110 Should Contain ${output} Intent successfully removed