1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
15 | Library | resources.libraries.python.InterfaceUtil
16 | ... | WITH NAME | interfaceCLI
17 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
18 | ... | WITH NAME | InterfaceAPI
19 | Documentation | Keywords used to manipulate vhost-user unterfaces.
22 | Honeycomb creates vhost-user interface
23 | | [Documentation] | Create a vhost-user interface using Honeycomb API.
25 | | ... | *Arguments:*
26 | | ... | - node - information about a DUT node. Type: dictionary
27 | | ... | - interface - name of an interface on the specified node. Type: string
28 | | ... | - settings - Configuration data for vhost-user interface.\
29 | | ... | Type: dictionary
32 | | ... | \| Honeycomb creates vhost-user interface\
33 | | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
35 | | [Arguments] | ${node} | ${interface} | ${settings}
36 | | interfaceAPI.Create vhost user interface | ${node} | ${interface}
39 | Honeycomb removes vhost-user interface
40 | | [Documentation] | Remove a vhost-user interface using Honeycomb API.
42 | | ... | *Arguments:*
43 | | ... | - node - information about a DUT node. Type: dictionary
44 | | ... | - interface - name of an interface on the specified node. Type: string
47 | | ... | \| Honeycomb removes vhost-user interface\
48 | | ... | \| ${nodes['DUT1']} \| vhost_test \|
50 | | [Arguments] | ${node} | ${interface}
51 | | interfaceAPI.Delete interface | ${node} | ${interface}
53 | Honeycomb configures vhost-user interface
54 | | [Documentation] | Configure a vhost-user interface using Honeycomb API.
56 | | ... | *Arguments:*
57 | | ... | - node - information about a DUT node. Type: dictionary
58 | | ... | - interface - name of an interface on the specified node. Type: string
59 | | ... | - settings - Configuration data for vhost-user interface.\
60 | | ... | Type: dictionary
63 | | ... | \| Honeycomb configures vhost-user interface\
64 | | ... | \| ${nodes['DUT1']} \| vhost_test \| ${new_vhost_user_settings} \|
66 | | [Arguments] | ${node} | ${interface} | ${settings}
67 | | interfaceAPI.Configure interface vhost user | ${node} | ${interface}
70 | Vhost-user configuration from Honeycomb should be
71 | | [Documentation] | Retrieves interface vhost-user configuration through\
72 | | ... | Honeycomb and compares it with settings supplied in argument.
74 | | ... | *Arguments:*
75 | | ... | - node - information about a DUT node. Type: dictionary
76 | | ... | - interface - name of an interface on the specified node. Type: string
77 | | ... | - settings - Configuration data for vhost-user interface.\
78 | | ... | Type: dictionary
81 | | ... | \| Vhost-user configuration from Honeycomb should be\
82 | | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
84 | | [Arguments] | ${node} | ${interface} | ${settings}
85 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
86 | | ${api_vhost}= | Set Variable | ${api_data['v3po:vhost-user']}
87 | | :FOR | ${key} | IN | @{settings.keys()}
88 | | | Should be equal | ${api_vhost['${key}']} | ${settings['${key}']}
90 | Vhost-user configuration from VAT should be
91 | | [Documentation] | Retrieves interface vhost-user configuration through VAT\
92 | | ... | and compares it with settings supplied in argument.
94 | | ... | *Arguments:*
95 | | ... | - node - information about a DUT node. Type: dictionary
96 | | ... | - settings - Configuration data for vhost-user interface.\
97 | | ... | Type: dictionary
100 | | ... | \| Vhost-user configuration from VAT should be\
101 | | ... | \| ${nodes['DUT1']} \| vhost_test \|
104 | | ... | Due to the difficulty of identifying newly created interfaces by name\
105 | | ... | or by sw_index, this keyword assumes there is only one vhost-user\
106 | | ... | interface present on the specified node.
108 | | [Arguments] | ${node} | ${settings}
109 | | &{translate}= | Create dictionary | server=1 | client=0
110 | | ${vat_data}= | vhost user Dump | ${node}
111 | | ${vat_data}= | Set Variable | ${vat_data[0]}
112 | | Should be equal | ${vat_data['sock_filename']} | ${settings['socket']}
113 | | should be equal as strings | ${vat_data['is_server']}
114 | | ... | ${translate['${settings['role']}']}
116 | Vhost-user configuration from Honeycomb should be empty
117 | | [Documentation] | Attempts to retrieve interface vhost-user configuration\
118 | | ... | through Honeycomb and expects to recieve an empty dictionary.
120 | | ... | *Arguments:*
121 | | ... | - node - information about a DUT node. Type: dictionary
122 | | ... | - interface - name of an interface on the specified node. Type: string
125 | | ... | \| Vhost-user configuration from Honeycomb should be empty\
126 | | ... | \| ${nodes['DUT1']} \| vhost_test \|
128 | | [Arguments] | ${node} | ${interface}
129 | | ${api_data}= | interfaceAPI.Get interface oper data | ${node} | ${interface}
130 | | Run keyword and expect error | *KeyError: 'v3po:vhost-user'
131 | | ... | Should be empty | ${api_data['v3po:vhost-user']}
133 | Vhost-user configuration from VAT should be empty
134 | | [Documentation] | Attempts to retrieve interface vhost-user configuration\
135 | | ... | through VAT and expects a "no data" error.
137 | | ... | *Arguments:*
138 | | ... | - node - information about a DUT node. Type: dictionary
141 | | ... | \| Vhost-user configuration from VAT should be empty\
142 | | ... | \| ${nodes['DUT1']} \|
144 | | [Arguments] | ${node}
145 | | Run Keyword And Expect Error | ValueError: No JSON object could be decoded
146 | | ... | vhost user Dump | ${node}
148 | Honeycomb fails setting vhost-user on different interface type
149 | | [Documentation] | Attempts to set vhost-user settings on an ethernet\
150 | | ... | type interface and expects to fail.
152 | | ... | *Arguments:*
153 | | ... | - node - information about a DUT node. Type: dictionary
154 | | ... | - interface - name of an interface on the specified node. Type: string
155 | | ... | - settings - Configuration data for vhost-user. Type: dictionary
158 | | ... | \| Honeycomb fails setting vhost-user on different interface type\
159 | | ... | \| ${nodes['DUT1']} \| ${interface} \| ${vhost_user_settings} \|
161 | | [Arguments] | ${node} | ${interface} | ${settings}
162 | | Run Keyword And Expect Error | HoneycombError: * Status code: 500.
163 | | ... | interfaceAPI.Configure interface vhost user | ${node} | ${interface}
164 | | ... | &{settings}
166 | Honeycomb fails setting invalid vhost-user configuration
167 | | [Documentation] | Attempts to create a vhost-user interface with invalid\
168 | | ... | configuration and expects to fail.
170 | | ... | *Arguments:*
171 | | ... | - node - information about a DUT node. Type: dictionary
172 | | ... | - interface - name of an interface on the specified node. Type: string
173 | | ... | - settings_list - Bad configuration data for vhost-user. Type: list
176 | | ... | \| Honeycomb fails setting invalid vhost-user configuration\
177 | | ... | \| ${nodes['DUT1']} \| vhost_test \| ${vhost_user_settings} \|
179 | | [Arguments] | ${node} | ${interface} | ${settings}
180 | | Run Keyword And Expect Error | HoneycombError: * Status code: 400.
181 | | ... | interfaceAPI.Configure interface vhost user | ${node} | ${interface}
182 | | ... | &{settings}