Feature 10960 Performance optimizations for the polling of VM status in RO
[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_details": None,
50 "vim_id": None,
51 "vim_name": None,
52 "interfaces": None,
53 }
54 interface_with_binding = {
55 "binding:profile": {
56 "physical_network": "physnet1",
57 "pci_slot": "0000:86:17.4",
58 },
59 "binding:vif_details": {
60 "vlan": 400,
61 },
62 }
63 target_record = "vnfrs:35c034cc-8c5b-48c4-bfa2-17a71577ef19:vdur.0.vim_info.vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7"
64 target_record2 = "vnfrs:41e16909-a519-4897-b481-f386e5022425:vdur.0.vim_info.vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7"
65 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}"
66 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}"
67 config = {
68 "period": {
69 "refresh_active": 60,
70 "refresh_build": 15,
71 "refresh_image": "3600 * 10",
72 "refresh_error": 600,
73 "queue_size": 100,
74 },
75 "database": {"driver": "mongo", "uri": "mongodb://mongo:27017", "name": "osm"},
76 "storage": {"driver": "None", "path": "/app/storage", "loglevel": "DEBUG"},
77 }
78 old_interface = {
79 "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",
80 "mac_address": "fa:16:3e:85:6c:02",
81 "vim_net_id": "327f5e8e-a383-47c9-80a3-ed45b71d24ca",
82 "vim_interface_id": "4d081f50-e13a-4306-a67e-1edb28d76013",
83 "compute_node": "nfvisrv12",
84 "pci": None,
85 "vlan": None,
86 "ip_address": "192.168.251.15",
87 "mgmt_vnf_interface": True,
88 "mgmt_vdu_interface": True,
89 }
90 old_interface2 = {
91 "mgmt_vdu_interface": True,
92 "mgmt_vnf_interface": True,
93 }
94 interface_info2 = {
95 "fixed_ips": [{"ip_address": ip1_addr}],
96 "mac_address": mac2_addr,
97 "network_id": net1_id,
98 }
99 sample_vim_info = {
100 "interfaces": [
101 old_interface,
102 ],
103 "interfaces_backup": [
104 {
105 "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",
106 "mac_address": "fa:16:3e:85:6c:02",
107 "vim_net_id": "327f5e8e-a383-47c9-80a3-ed45b71d24ca",
108 "vim_interface_id": "4d081f50-e13a-4306-a67e-1edb28d76013",
109 "compute_node": "nfvisrv12",
110 "pci": None,
111 "vlan": None,
112 "ip_address": "192.168.251.15",
113 "mgmt_vnf_interface": True,
114 "mgmt_vdu_interface": True,
115 }
116 ],
117 "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",
118 "vim_id": "ebd39f37-e607-4bce-9f10-ea4c5635f726",
119 "vim_message": "Interface 4d081f50-e13a-4306-a67e-1edb28d76013 status: DOWN",
120 "vim_status": "ACTIVE",
121 "vim_name": "test7-vnf-hackfest_basic-VM-000000",
122 }
123 sample_vnfr = {
124 "_id": "35c034cc-8c5b-48c4-bfa2-17a71577ef19",
125 "id": "35c034cc-8c5b-48c4-bfa2-17a71577ef19",
126 "nsr-id-ref": "ee46620f-cba3-4245-b8be-183ff483bb7e",
127 "created-time": 1676755692.20987,
128 "vnfd-ref": "hackfest_basic-vnf",
129 "vnfd-id": "f1401992-83f4-43cc-ac37-1ad7c1370d03",
130 "vim-account-id": vim4_id,
131 "vca-id": None,
132 "vdur": [
133 {
134 "_id": "faa21fc1-7f27-4a95-93dd-87535ce6b59c",
135 "additionalParams": {
136 "OSM": {
137 "count_index": 0,
138 "member_vnf_index": "vnf",
139 "ns_id": "ee46620f-cba3-4245-b8be-183ff483bb7e",
140 "vdu": {
141 "hackfest_basic-VM-0": {
142 "count_index": 0,
143 "interfaces": {"vdu-eth0": {"name": "vdu-eth0"}},
144 "vdu_id": "hackfest_basic-VM",
145 }
146 },
147 "vdu_id": "hackfest_basic-VM",
148 "vim_account_id": vim4_id,
149 "vnf_id": "35c034cc-8c5b-48c4-bfa2-17a71577ef19",
150 "vnfd_id": "f1401992-83f4-43cc-ac37-1ad7c1370d03",
151 "vnfd_ref": "hackfest_basic-vnf",
152 }
153 },
154 "affinity-or-anti-affinity-group-id": [],
155 "count-index": 0,
156 "id": "faa21fc1-7f27-4a95-93dd-87535ce6b59c",
157 "interfaces": [
158 {
159 "external-connection-point-ref": "vnf-cp0-ext",
160 "internal-connection-point-ref": "vdu-eth0-int",
161 "mgmt-interface": True,
162 "mgmt-vnf": True,
163 "name": "vdu-eth0",
164 "ns-vld-id": "mgmtnet",
165 "type": "PARAVIRT",
166 "compute_node": "nfvisrv12",
167 "ip-address": "192.168.251.15",
168 "mac-address": "fa:16:3e:85:6c:02",
169 "pci": None,
170 "vlan": None,
171 }
172 ],
173 "internal-connection-point": [
174 {
175 "connection-point-id": "vdu-eth0-int",
176 "id": "vdu-eth0-int",
177 "name": "vdu-eth0-int",
178 }
179 ],
180 "ip-address": "192.168.251.15",
181 "ns-flavor-id": "0",
182 "ns-image-id": "0",
183 "vdu-id-ref": "hackfest_basic-VM",
184 "vdu-name": "hackfest_basic-VM",
185 "vim_info": {"vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7": sample_vim_info},
186 "virtual-storages": [
187 {"id": "hackfest_basic-VM-storage", "size-of-storage": "10"}
188 ],
189 "status": "ACTIVE",
190 "vim-id": "ebd39f37-e607-4bce-9f10-ea4c5635f726",
191 "name": "test7-vnf-hackfest_basic-VM-000000",
192 }
193 ],
194 "connection-point": [
195 {
196 "name": "vnf-cp0-ext",
197 "connection-point-id": "vdu-eth0-int",
198 "connection-point-vdu-id": "hackfest_basic-VM",
199 "id": "vnf-cp0-ext",
200 }
201 ],
202 "ip-address": "192.168.251.15",
203 "revision": 1,
204 "_admin": {
205 "created": 1676755692.21059,
206 "modified": 1676755692.21059,
207 "projects_read": ["9a61dad6cbc744879344e5b84d842578"],
208 "projects_write": ["9a61dad6cbc744879344e5b84d842578"],
209 "nsState": "INSTANTIATED",
210 },
211 }
212 vims = [
213 {
214 "_id": vim1_id,
215 "name": "openstackETSI1",
216 "vim_type": "openstack",
217 },
218 {
219 "_id": vim2_id,
220 "name": "openstackETSI2",
221 "vim_type": "openstack",
222 },
223 ]
224 sample_vim = {
225 "_id": vim1_id,
226 "name": "openstackETSI1",
227 "vim_type": "openstack",
228 "description": None,
229 "vim_url": "http://172.21.223.1:5000/v3",
230 "vim_user": "myuser",
231 "vim_password": "mypassword",
232 "vim_tenant_name": "mytenant",
233 "_admin": {
234 "created": 1675758291.0110583,
235 "modified": 1675758291.0110583,
236 "operationalState": "ENABLED",
237 "current_operation": None,
238 "detailed-status": "",
239 },
240 "schema_version": "1.11",
241 "admin": {"current_operation": 0},
242 }
243 ro_task1 = {
244 "_id": "6659675b-b6a4-4c0c-ad40-47dae476a961:3",
245 "target_id": f"vim:{vim1_id}",
246 "vim_info": {
247 "created": True,
248 "created_items": {"port:4d081f50-e13a-4306-a67e-1edb28d76013": True},
249 "vim_id": vm1_id,
250 "vim_name": "test7-vnf-hackfest_basic-VM-0",
251 "vim_status": "ACTIVE",
252 "refresh_at": -1,
253 "interfaces": [
254 {
255 "mac_address": "fa:16:3e:85:6c:02",
256 "vim_net_id": "327f5e8e-a383-47c9-80a3-ed45b71d24ca",
257 "vim_interface_id": "4d081f50-e13a-4306-a67e-1edb28d76013",
258 "compute_node": "nfvisrv12",
259 "pci": None,
260 "vlan": None,
261 "ip_address": "192.168.251.15",
262 "mgmt_vnf_interface": True,
263 "mgmt_vdu_interface": True,
264 }
265 ],
266 "interfaces_vim_ids": ["4d081f50-e13a-4306-a67e-1edb28d76013"],
267 },
268 "modified_at": 1676755752.49715,
269 "created_at": 1676755693.91547,
270 "to_check_at": -1,
271 "tasks": [
272 {
273 "action_id": "6659675b-b6a4-4c0c-ad40-47dae476a961",
274 "nsr_id": "ee46620f-cba3-4245-b8be-183ff483bb7e",
275 "task_id": "6659675b-b6a4-4c0c-ad40-47dae476a961:3",
276 "status": "DONE",
277 "action": "CREATE",
278 "item": "vdu",
279 "target_record": target_record,
280 "mgmt_vnf_interface": 0,
281 }
282 ],
283 }
284 ro_task2 = {
285 "_id": "7b05fd30-f128-4486-a1ba-56fcf7387967:3",
286 "target_id": f"vim:{vim2_id}",
287 "vim_info": {
288 "created": True,
289 "created_items": {
290 "port:4d2faa64-3f10-42ec-a5db-0291600d0692": True,
291 },
292 "vim_id": vm2_id,
293 "vim_name": "test7-vnf-hackfest_basic-VM-0",
294 "vim_status": "ACTIVE",
295 "refresh_at": -1,
296 "interfaces": [
297 {
298 "mac_address": "fa:16:3e:2c:2d:21",
299 "vim_net_id": "327f5e8e-a383-47c9-80a3-ed45b71d24ca",
300 "vim_interface_id": "4d2faa64-3f10-42ec-a5db-0291600d0692",
301 "compute_node": "nfvisrv12",
302 "pci": None,
303 "vlan": None,
304 "ip_address": "192.168.251.197",
305 "mgmt_vnf_interface": True,
306 "mgmt_vdu_interface": True,
307 }
308 ],
309 "interfaces_vim_ids": ["4d2faa64-3f10-42ec-a5db-0291600d0692"],
310 },
311 "modified_at": 1676839542.4801,
312 "created_at": 1676839494.78525,
313 "to_check_at": -1,
314 "tasks": [
315 {
316 "action_id": "7b05fd30-f128-4486-a1ba-56fcf7387967",
317 "nsr_id": "ddf8c820-4cfa-47fb-8de3-e0afbe039efb",
318 "task_id": "7b05fd30-f128-4486-a1ba-56fcf7387967:3",
319 "status": "FAILED",
320 "action": "CREATE",
321 "item": "vdu",
322 "target_record": "vnfrs:41e16909-a519-4897-b481-f386e5022425:vdur.0.vim_info.vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7",
323 "mgmt_vnf_interface": 0,
324 }
325 ],
326 }
327 wrong_ro_task = {
328 "_id": "6659675b-b6a4-4c0c-ad40-47dae476a961:3",
329 "target_id": "vim:f239ed93-756b-408e-89f8-fcbf47a9d8f7",
330 }
331 port1 = {
332 "id": "4d081f50-e13a-4306-a67e-1edb28d76013",
333 "network_id": net1_id,
334 "tenant_id": "34a71bb7d82f4ec691d8cc11045ae83e",
335 "mac_address": mac2_addr,
336 "admin_state_up": True,
337 "status": "ACTIVE",
338 "device_id": vm1_id,
339 "device_owner": "compute:nova",
340 "fixed_ips": [],
341 }
342 port2 = {
343 "id": "5d081f50-e13a-4306-a67e-1edb28d76013",
344 "network_id": net1_id,
345 "tenant_id": "34a71bb7d82f4ec691d8cc11045ae83e",
346 "mac_address": mac2_addr,
347 "admin_state_up": True,
348 "status": "ACTIVE",
349 "device_id": vm1_id,
350 "device_owner": "compute:nova",
351 "fixed_ips": [],
352 }