e85ce35e24b53ed7ecaf8492ea05e63f59e3d042
[osm/RO.git] / NG-RO / osm_ng_ro / tests / sample_data.py
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
17 # The variables that are used in the monitoring tests
18 db_vim_collection = "vim_accounts"
19 vim_type = "openstack"
20 ro_task_collection = "ro_tasks"
21 plugin_name = "rovim_openstack"
22 mac1_addr = "d0:94:66:ed:fc:e2"
23 mac2_addr = "fa:16:3e:0b:84:08"
24 ip1_addr = "192.168.22.13"
25 vm1_id = "ebd39f37-e607-4bce-9f10-ea4c5635f726"
26 vm2_id = "f4404a39-51d5-4cf8-9058-95001e69fdb3"
27 vim1_id = target_id = "55b2219a-7bb9-4644-9612-980dada84e83"
28 vim2_id = "77b2219a-8bb9-9644-9612-680dada84e83"
29 vim3_id = "33b2219a-7bb9-4644-9612-280dada84e83"
30 vim4_id = "f239ed93-756b-408e-89f8-fcbf47a9d8f7"
31 file_name = "/app/osm_ro/certs/55b2219a-7bb9-4644-9612-980dada84e83:23242"
32 net1_id = "21ea5d92-24f1-40ab-8d28-83230e277a49"
33 vnfr_id = "35c034cc-8c5b-48c4-bfa2-17a71577ef19"
34 db_vim_cacert = "/app/osm_ro/certs/55b2219a-7bb9-4644-9612-980dada84e83:23242/ca_cert"
35 vdur_path = "vdur.0"
36 vims_to_monitor = []
37 vim_info_path = "vdur.0.vim_info.vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7"
38 server_other_info = {
39 "admin_state_up": "true",
40 "binding:host_id": "nfvisrv11",
41 "binding:profile": {},
42 "binding:vif_type": "ovs",
43 "binding:vnic_type": "normal",
44 "created_at": "2023-02-22T05:35:46Z",
45 }
46 deleted_externally = {
47 "vim_status": "DELETED",
48 "vim_message": "Deleted externally",
49 "vim_id": None,
50 "vim_name": None,
51 "interfaces": None,
52 }
53 interface_with_binding = {
54 "binding:profile": {
55 "physical_network": "physnet1",
56 "pci_slot": "0000:86:17.4",
57 },
58 "binding:vif_details": {
59 "vlan": 400,
60 },
61 }
62 target_record = "vnfrs:35c034cc-8c5b-48c4-bfa2-17a71577ef19:vdur.0.vim_info.vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7"
63 target_record2 = "vnfrs:41e16909-a519-4897-b481-f386e5022425:vdur.0.vim_info.vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7"
64 serialized_server_info = "{admin_state_up: true, binding:host_id: nfvisrv11, binding:profile: {}, binding:vif_type: ovs, binding:vnic_type: normal, created_at: 2023-02-22T05:35:46Z}"
65 serialized_interface_info = "{fixed_ips: [{ip_address: 192.168.22.13}], mac_address: 'd0:94:66:ed:fc:e2', network_id: 21ea5d92-24f1-40ab-8d28-83230e277a49}"
66 config = {
67 "period": {
68 "refresh_active": 60,
69 "refresh_build": 15,
70 "refresh_image": "3600 * 10",
71 "refresh_error": 600,
72 "queue_size": 100,
73 },
74 "database": {"driver": "mongo", "uri": "mongodb://mongo:27017", "name": "osm"},
75 "storage": {"driver": "None", "path": "/app/storage", "loglevel": "DEBUG"},
76 }
77 old_interface = {
78 "vim_info": "{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': nfvisrv12, 'binding:profile': {}, 'binding:vif_details': {bridge_name: br-int, connectivity: l2, datapath_type: system, ovs_hybrid_plug: true, port_filter: true}, 'binding:vif_type': ovs, 'binding:vnic_type': normal,\n created_at: '2023-02-18T21:28:52Z', description: '', device_id: ebd39f37-e607-4bce-9f10-ea4c5635f726, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.251.15, subnet_id: bf950890-8d50-40cc-81ba-afa35db69a19}], id: 4d081f50-e13a-4306-a67e-1edb28d76013,\n mac_address: 'fa:16:3e:85:6c:02', name: vdu-eth0, network_id: 327f5e8e-a383-47c9-80a3-ed45b71d24ca, port_security_enabled: true, project_id: 71c7971a7cab4b72bd5c10dbe6617f1e, revision_number: 4, security_groups: [1de4b2c2-e4be-4e91-985c-d887e2715949], status: ACTIVE,\n tags: [], tenant_id: 71c7971a7cab4b72bd5c10dbe6617f1e, updated_at: '2023-02-18T21:28:59Z'}\n",
79 "mac_address": "fa:16:3e:85:6c:02",
80 "vim_net_id": "327f5e8e-a383-47c9-80a3-ed45b71d24ca",
81 "vim_interface_id": "4d081f50-e13a-4306-a67e-1edb28d76013",
82 "compute_node": "nfvisrv12",
83 "pci": None,
84 "vlan": None,
85 "ip_address": "192.168.251.15",
86 "mgmt_vnf_interface": True,
87 "mgmt_vdu_interface": True,
88 }
89 old_interface2 = {
90 "mgmt_vdu_interface": True,
91 "mgmt_vnf_interface": True,
92 }
93 interface_info2 = {
94 "fixed_ips": [{"ip_address": ip1_addr}],
95 "mac_address": mac2_addr,
96 "network_id": net1_id,
97 }
98 sample_vim_info = {
99 "interfaces": [
100 old_interface,
101 ],
102 "interfaces_backup": [
103 {
104 "vim_info": "{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': nfvisrv12, 'binding:profile': {}, 'binding:vif_details': {bridge_name: br-int, connectivity: l2, datapath_type: system, ovs_hybrid_plug: true, port_filter: true}, 'binding:vif_type': ovs, 'binding:vnic_type': normal,\n created_at: '2023-02-18T21:28:52Z', description: '', device_id: ebd39f37-e607-4bce-9f10-ea4c5635f726, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.251.15, subnet_id: bf950890-8d50-40cc-81ba-afa35db69a19}], id: 4d081f50-e13a-4306-a67e-1edb28d76013,\n mac_address: 'fa:16:3e:85:6c:02', name: vdu-eth0, network_id: 327f5e8e-a383-47c9-80a3-ed45b71d24ca, port_security_enabled: true, project_id: 71c7971a7cab4b72bd5c10dbe6617f1e, revision_number: 4, security_groups: [1de4b2c2-e4be-4e91-985c-d887e2715949], status: ACTIVE,\n tags: [], tenant_id: 71c7971a7cab4b72bd5c10dbe6617f1e, updated_at: '2023-02-18T21:28:59Z'}\n",
105 "mac_address": "fa:16:3e:85:6c:02",
106 "vim_net_id": "327f5e8e-a383-47c9-80a3-ed45b71d24ca",
107 "vim_interface_id": "4d081f50-e13a-4306-a67e-1edb28d76013",
108 "compute_node": "nfvisrv12",
109 "pci": None,
110 "vlan": None,
111 "ip_address": "192.168.251.15",
112 "mgmt_vnf_interface": True,
113 "mgmt_vdu_interface": True,
114 }
115 ],
116 "vim_details": "{'OS-DCF:diskConfig': MANUAL, 'OS-EXT-AZ:availability_zone': nova, 'OS-EXT-SRV-ATTR:host': nfvisrv12, 'OS-EXT-SRV-ATTR:hypervisor_hostname': nfvisrv12, 'OS-EXT-SRV-ATTR:instance_name': instance-000400a6, 'OS-EXT-STS:power_state': 1, 'OS-EXT-STS:task_state': null,\n 'OS-EXT-STS:vm_state': active, 'OS-SRV-USG:launched_at': '2023-02-18T21:28:59.000000', 'OS-SRV-USG:terminated_at': null, accessIPv4: '', accessIPv6: '', addresses: {mgmtnet: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:85:6c:02', 'OS-EXT-IPS:type': fixed, addr: 192.168.251.15,\n version: 4}]}, config_drive: '', created: '2023-02-18T21:28:54Z', flavor: {id: 367fc1eb-bd22-40f8-a519-ed2fb4e5976b, links: [{href: 'http://172.21.247.1:8774/flavors/367fc1eb-bd22-40f8-a519-ed2fb4e5976b', rel: bookmark}]}, hostId: e72dec159231b67a5d4fa37fae67e97051ce9aee003516dadb6a25e4,\n id: ebd39f37-e607-4bce-9f10-ea4c5635f726, image: {id: 919fc71a-6acd-4ee3-8123-739a9abbc2e7, links: [{href: 'http://172.21.247.1:8774/images/919fc71a-6acd-4ee3-8123-739a9abbc2e7', rel: bookmark}]}, key_name: null, links: [{href: 'http://172.21.247.1:8774/v2.1/servers/ebd39f37-e607-4bce-9f10-ea4c5635f726',\n rel: self}, {href: 'http://172.21.247.1:8774/servers/ebd39f37-e607-4bce-9f10-ea4c5635f726', rel: bookmark}], metadata: {}, name: test7-vnf-hackfest_basic-VM-000000, 'os-extended-volumes:volumes_attached': [], progress: 0, security_groups: [{name: default}],\n status: ACTIVE, tenant_id: 71c7971a7cab4b72bd5c10dbe6617f1e, updated: '2023-02-19T21:09:09Z', user_id: f043c84f940b4fc8a01a98714ea97c80}\n",
117 "vim_id": "ebd39f37-e607-4bce-9f10-ea4c5635f726",
118 "vim_message": "Interface 4d081f50-e13a-4306-a67e-1edb28d76013 status: DOWN",
119 "vim_status": "ACTIVE",
120 "vim_name": "test7-vnf-hackfest_basic-VM-000000",
121 }
122 sample_vnfr = {
123 "_id": "35c034cc-8c5b-48c4-bfa2-17a71577ef19",
124 "id": "35c034cc-8c5b-48c4-bfa2-17a71577ef19",
125 "nsr-id-ref": "ee46620f-cba3-4245-b8be-183ff483bb7e",
126 "created-time": 1676755692.20987,
127 "vnfd-ref": "hackfest_basic-vnf",
128 "vnfd-id": "f1401992-83f4-43cc-ac37-1ad7c1370d03",
129 "vim-account-id": vim4_id,
130 "vca-id": None,
131 "vdur": [
132 {
133 "_id": "faa21fc1-7f27-4a95-93dd-87535ce6b59c",
134 "additionalParams": {
135 "OSM": {
136 "count_index": 0,
137 "member_vnf_index": "vnf",
138 "ns_id": "ee46620f-cba3-4245-b8be-183ff483bb7e",
139 "vdu": {
140 "hackfest_basic-VM-0": {
141 "count_index": 0,
142 "interfaces": {"vdu-eth0": {"name": "vdu-eth0"}},
143 "vdu_id": "hackfest_basic-VM",
144 }
145 },
146 "vdu_id": "hackfest_basic-VM",
147 "vim_account_id": vim4_id,
148 "vnf_id": "35c034cc-8c5b-48c4-bfa2-17a71577ef19",
149 "vnfd_id": "f1401992-83f4-43cc-ac37-1ad7c1370d03",
150 "vnfd_ref": "hackfest_basic-vnf",
151 }
152 },
153 "affinity-or-anti-affinity-group-id": [],
154 "count-index": 0,
155 "id": "faa21fc1-7f27-4a95-93dd-87535ce6b59c",
156 "interfaces": [
157 {
158 "external-connection-point-ref": "vnf-cp0-ext",
159 "internal-connection-point-ref": "vdu-eth0-int",
160 "mgmt-interface": True,
161 "mgmt-vnf": True,
162 "name": "vdu-eth0",
163 "ns-vld-id": "mgmtnet",
164 "type": "PARAVIRT",
165 "compute_node": "nfvisrv12",
166 "ip-address": "192.168.251.15",
167 "mac-address": "fa:16:3e:85:6c:02",
168 "pci": None,
169 "vlan": None,
170 }
171 ],
172 "internal-connection-point": [
173 {
174 "connection-point-id": "vdu-eth0-int",
175 "id": "vdu-eth0-int",
176 "name": "vdu-eth0-int",
177 }
178 ],
179 "ip-address": "192.168.251.15",
180 "ns-flavor-id": "0",
181 "ns-image-id": "0",
182 "vdu-id-ref": "hackfest_basic-VM",
183 "vdu-name": "hackfest_basic-VM",
184 "vim_info": {"vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7": sample_vim_info},
185 "virtual-storages": [
186 {"id": "hackfest_basic-VM-storage", "size-of-storage": "10"}
187 ],
188 "status": "ACTIVE",
189 "vim-id": "ebd39f37-e607-4bce-9f10-ea4c5635f726",
190 "name": "test7-vnf-hackfest_basic-VM-000000",
191 }
192 ],
193 "connection-point": [
194 {
195 "name": "vnf-cp0-ext",
196 "connection-point-id": "vdu-eth0-int",
197 "connection-point-vdu-id": "hackfest_basic-VM",
198 "id": "vnf-cp0-ext",
199 }
200 ],
201 "ip-address": "192.168.251.15",
202 "revision": 1,
203 "_admin": {
204 "created": 1676755692.21059,
205 "modified": 1676755692.21059,
206 "projects_read": ["9a61dad6cbc744879344e5b84d842578"],
207 "projects_write": ["9a61dad6cbc744879344e5b84d842578"],
208 "nsState": "INSTANTIATED",
209 },
210 }
211 vims = [
212 {
213 "_id": vim1_id,
214 "name": "openstackETSI1",
215 "vim_type": "openstack",
216 },
217 {
218 "_id": vim2_id,
219 "name": "openstackETSI2",
220 "vim_type": "openstack",
221 },
222 ]
223 sample_vim = {
224 "_id": vim1_id,
225 "name": "openstackETSI1",
226 "vim_type": "openstack",
227 "description": None,
228 "vim_url": "http://172.21.223.1:5000/v3",
229 "vim_user": "myuser",
230 "vim_password": "mypassword",
231 "vim_tenant_name": "mytenant",
232 "_admin": {
233 "created": 1675758291.0110583,
234 "modified": 1675758291.0110583,
235 "operationalState": "ENABLED",
236 "current_operation": None,
237 "detailed-status": "",
238 },
239 "schema_version": "1.11",
240 "admin": {"current_operation": 0},
241 }
242 ro_task1 = {
243 "_id": "6659675b-b6a4-4c0c-ad40-47dae476a961:3",
244 "target_id": f"vim:{vim1_id}",
245 "vim_info": {
246 "created": True,
247 "created_items": {"port:4d081f50-e13a-4306-a67e-1edb28d76013": True},
248 "vim_id": vm1_id,
249 "vim_name": "test7-vnf-hackfest_basic-VM-0",
250 "vim_status": "ACTIVE",
251 "refresh_at": -1,
252 "interfaces": [
253 {
254 "mac_address": "fa:16:3e:85:6c:02",
255 "vim_net_id": "327f5e8e-a383-47c9-80a3-ed45b71d24ca",
256 "vim_interface_id": "4d081f50-e13a-4306-a67e-1edb28d76013",
257 "compute_node": "nfvisrv12",
258 "pci": None,
259 "vlan": None,
260 "ip_address": "192.168.251.15",
261 "mgmt_vnf_interface": True,
262 "mgmt_vdu_interface": True,
263 }
264 ],
265 "interfaces_vim_ids": ["4d081f50-e13a-4306-a67e-1edb28d76013"],
266 },
267 "modified_at": 1676755752.49715,
268 "created_at": 1676755693.91547,
269 "to_check_at": -1,
270 "tasks": [
271 {
272 "action_id": "6659675b-b6a4-4c0c-ad40-47dae476a961",
273 "nsr_id": "ee46620f-cba3-4245-b8be-183ff483bb7e",
274 "task_id": "6659675b-b6a4-4c0c-ad40-47dae476a961:3",
275 "status": "DONE",
276 "action": "CREATE",
277 "item": "vdu",
278 "target_record": target_record,
279 "mgmt_vnf_interface": 0,
280 }
281 ],
282 }
283 ro_task2 = {
284 "_id": "7b05fd30-f128-4486-a1ba-56fcf7387967:3",
285 "target_id": f"vim:{vim2_id}",
286 "vim_info": {
287 "created": True,
288 "created_items": {
289 "port:4d2faa64-3f10-42ec-a5db-0291600d0692": True,
290 },
291 "vim_id": vm2_id,
292 "vim_name": "test7-vnf-hackfest_basic-VM-0",
293 "vim_status": "ACTIVE",
294 "refresh_at": -1,
295 "interfaces": [
296 {
297 "mac_address": "fa:16:3e:2c:2d:21",
298 "vim_net_id": "327f5e8e-a383-47c9-80a3-ed45b71d24ca",
299 "vim_interface_id": "4d2faa64-3f10-42ec-a5db-0291600d0692",
300 "compute_node": "nfvisrv12",
301 "pci": None,
302 "vlan": None,
303 "ip_address": "192.168.251.197",
304 "mgmt_vnf_interface": True,
305 "mgmt_vdu_interface": True,
306 }
307 ],
308 "interfaces_vim_ids": ["4d2faa64-3f10-42ec-a5db-0291600d0692"],
309 },
310 "modified_at": 1676839542.4801,
311 "created_at": 1676839494.78525,
312 "to_check_at": -1,
313 "tasks": [
314 {
315 "action_id": "7b05fd30-f128-4486-a1ba-56fcf7387967",
316 "nsr_id": "ddf8c820-4cfa-47fb-8de3-e0afbe039efb",
317 "task_id": "7b05fd30-f128-4486-a1ba-56fcf7387967:3",
318 "status": "FAILED",
319 "action": "CREATE",
320 "item": "vdu",
321 "target_record": "vnfrs:41e16909-a519-4897-b481-f386e5022425:vdur.0.vim_info.vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7",
322 "mgmt_vnf_interface": 0,
323 }
324 ],
325 }
326 wrong_ro_task = {
327 "_id": "6659675b-b6a4-4c0c-ad40-47dae476a961:3",
328 "target_id": "vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7",
329 }
330 port1 = {
331 "id": "4d081f50-e13a-4306-a67e-1edb28d76013",
332 "network_id": net1_id,
333 "tenant_id": "34a71bb7d82f4ec691d8cc11045ae83e",
334 "mac_address": mac2_addr,
335 "admin_state_up": True,
336 "status": "ACTIVE",
337 "device_id": vm1_id,
338 "device_owner": "compute:nova",
339 "fixed_ips": [],
340 }
341 port2 = {
342 "id": "5d081f50-e13a-4306-a67e-1edb28d76013",
343 "network_id": net1_id,
344 "tenant_id": "34a71bb7d82f4ec691d8cc11045ae83e",
345 "mac_address": mac2_addr,
346 "admin_state_up": True,
347 "status": "ACTIVE",
348 "device_id": vm1_id,
349 "device_owner": "compute:nova",
350 "fixed_ips": [],
351 }