2 Documentation Utils for Restconf operations for GBP
4 Library RequestsLibrary
5 Library OperatingSystem
7 Variables ../../variables/Variables.py
8 Resource ../../variables/gbp/Constants.robot
9 Resource ../Utils.robot
10 Resource RestconfUtils.robot
15 [Documentation] Checks name and ip prefix of given subnet and returns parent ID
16 [Arguments] ${subnet_to_check} ${subnet_name} ${ip_prefix_to_check}
17 ${parent} Assert Forwarding Domain ${subnet_to_check} ${subnet_name} return_parent=TRUE
18 ${ip_prefix} Get Ip Prefix of Subnet ${subnet_to_check}
19 Should Be Equal As Strings ${ip_prefix} ${ip_prefix_to_check}
22 Assert L2-Flood-Domain
23 [Documentation] Checks name of given l2-flood-domain and returns parent ID
24 [Arguments] ${l2_flood_domain_to_check} ${l2_flood_domain_name}
25 ${parent} Assert Forwarding Domain
26 ... ${l2_flood_domain_to_check}
27 ... ${l2_flood_domain_name}
28 ... return_parent=TRUE
31 Assert L2-Bridge-Domain
32 [Documentation] Checks name of given l2-bridge-domain and returns parent ID
33 [Arguments] ${l2_bridge_domain_to_check} ${l2_bridge_domain_name}
34 ${parent} Assert Forwarding Domain
35 ... ${l2_bridge_domain_to_check}
36 ... ${l2_bridge_domain_name}
37 ... return_parent=TRUE
41 [Documentation] Checks name of given l3-context
42 [Arguments] ${l3_context_to_check} ${l3_context_name}
43 ${parent} Assert Forwarding Domain ${l3_context_to_check} ${l3_context_name}
46 Assert Forwarding Domain
47 [Documentation] Checks name of given l3-context
48 [Arguments] ${domain_to_check} ${domain_name} ${return_parent}=FALSE
49 Check Name ${domain_to_check} ${domain_name}
50 IF "${return_parent}" == "FALSE" RETURN
51 ${parent} Get Parent ${domain_to_check}
55 [Documentation] Checks correct format of a name field in JSON data
56 [Arguments] ${data} ${name}
57 Should Not Be Empty ${data}
58 Should Match Regexp ${data} \"name\":\"${NAME_PATTERN}\"
61 [Documentation] Veriefies min and max values of range-value of classifier-instance in JSON format
62 [Arguments] ${range_value_json} ${min} ${max}
63 Should Be Equal As Numbers ${min} ${range_value_json['min']}
64 Should Be Equal As Numbers ${max} ${range_value_json['max']}
67 [Documentation] Returns 'parent' value of an JSON object. Can be applied to Subnet, L2-Flood-Domain or L2-Bridge-Domain
69 Should Not Be Empty ${data}
70 ${parent_line} Should Match Regexp ${data} \"parent\":\"${UUID_PATTERN}\"
71 ${parent_uuid} Should Match Regexp ${parent_line} ${UUID_PATTERN}
75 [Documentation] Verifies parameters of given endpoint in JSON format
76 [Arguments] ${endpoint} ${ip_address} ${epg} ${l3-context} ${network-containment} ${tenant}
77 Should Contain ${endpoint} ofoverlay:port-name
78 @{ep_l3-addresses} Get L3-Addresses of Endpoint ${endpoint}
79 @{ep_endpoint_groups} Get Groups of Endpoint ${endpoint}
80 ${ep_network-containment} Get Network Containment of Endpoint ${endpoint}
81 ${ep_tenant} Get Tenant of Endpoint ${endpoint}
82 @{ep_endpoint_groups} Get Groups of Endpoint ${endpoint}
83 Should Be Equal As Strings ${ep_network-containment} ${network-containment}
84 Should Be Equal As Strings ${ep_tenant} ${tenant}
85 Check Group References ${epg} @{ep_endpoint_groups}
86 LOG ${ep_l3-addresses}
87 FOR ${l3} IN @{ep_l3-addresses}
90 LOG ${l3['l3-context']}
91 LOG ${l3['ip-address']}
92 IF "${l3['l3-context']}" == "${l3-context}" and "${l3['ip-address']}" == "${ip_address}"
99 [Documentation] Verifies parameters of registerd endpoint-l3 in JSON format
100 [Arguments] ${endpoint-l3} ${mac_address} ${epg} ${l2-context} ${network-containment} ${tenant}
101 Should Contain ${endpoint-l3} ofoverlay:port-name
102 ${ep_l2-context} Get L2 Context of Endpoint-L3 ${endpoint-l3}
103 ${ep_mac_address} Get Mac Address of Endpoint-L3 ${endpoint-l3}
104 ${ep_network-containment} Get Network Containment of Endpoint-L3 ${endpoint-l3}
105 ${ep_tenant} Get Tenant of Endpoint-L3 ${endpoint-l3}
106 @{ep_endpoint_groups} Get Groups of Endpoint-L3 ${endpoint-l3}
107 Should Be Equal As Strings ${ep_mac_address} ${mac_address}
108 Should Be Equal As Strings ${ep_l2-context} ${l2-context}
109 Should Be Equal As Strings ${network-containment} ${network-containment}
110 Should Be Equal As Strings ${tenant} ${tenant}
111 Check Group References ${epg} @{ep_endpoint_groups}
113 Check Group References
114 [Documentation] Verifies presence of endpoint group to which endpoint belongs and presence of network_client group
115 ... among given endpoint groups
116 [Arguments] ${epg_to_look_for} @{endpoint_groups}
117 Should Not Be Empty ${epg_to_look_for}
118 Should Not Be Empty ${endpoint_groups}
119 FOR ${epg} IN @{endpoint_groups}
120 IF "${epg}" == "${epg_to_look_for}" CONTINUE
121 IF "${epg}" == "${NETWORK_CLIENT_GROUP}" CONTINUE
125 Check Endpoint Group Name and Selector
126 [Documentation] Verifies data generated by security group and security group rules
127 [Arguments] ${epg_id} ${epg_name} ${tenant_id} ${contract_id} ${named-selector}
128 ${epg_path} Get Endpoint Group Path ${tenant_id} ${epg_id}
129 ${endpoint_group} Get Data From URI session ${epg_path} headers=${headers}
130 Should Not Be Empty ${endpoint_group}
131 Check Name ${endpoint_group} ${epg_name}
132 ${endpoint_group_json} To Json ${endpoint_group}
133 ${named_selectors} Set Variable ${endpoint_group_json['endpoint-group'][0]['${named-selector}']}
134 ${selector_found} Set Variable FALSE
135 FOR ${selector} IN @{named_selectors}
136 IF "${selector['contract'][0]}" == "${contract_id}" RETURN