| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 1 | # |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 3 | # not use this file except in compliance with the License. You may obtain |
| 4 | # a copy of the License at |
| 5 | # |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # |
| 8 | # Unless required by applicable law or agreed to in writing, software |
| 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 11 | # License for the specific language governing permissions and limitations |
| 12 | # under the License. |
| 13 | # |
| 14 | # For those usages not covered by the Apache License, Version 2.0 please |
| 15 | # contact: esousa@whitestack.com or alfonso.tiernosepulveda@telefonica.com |
| 16 | ## |
| 17 | |
| 18 | |
| 19 | import asynctest # pip3 install asynctest --user |
| 20 | import asyncio |
| 21 | import yaml |
| 22 | # import logging |
| 23 | from os import getenv |
| 24 | from osm_lcm.ns import NsLcm |
| 25 | from osm_common.dbmongo import DbMongo |
| 26 | from osm_common.msgkafka import MsgKafka |
| 27 | from osm_common.fslocal import FsLocal |
| 28 | from osm_lcm.lcm_utils import TaskRegistry |
| 29 | from n2vc.vnf import N2VC |
| 30 | from uuid import uuid4 |
| 31 | |
| 32 | __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>" |
| 33 | |
| tierno | 7ab529a | 2019-08-30 12:10:17 +0000 | [diff] [blame] | 34 | """ Perform unittests using asynctest of osm_lcm.ns module |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 35 | It allows, if some testing ENV are supplied, testing without mocking some external libraries for debugging: |
| 36 | OSMLCMTEST_NS_PUBKEY: public ssh-key returned by N2VC to inject to VMs |
| tierno | e64f7fb | 2019-09-11 08:55:52 +0000 | [diff] [blame] | 37 | OSMLCMTEST_NS_NAME: change name of NS |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 38 | OSMLCMTEST_PACKAGES_PATH: path where the vnf-packages are stored (de-compressed), each one on a 'vnfd_id' folder |
| 39 | OSMLCMTEST_NS_IPADDRESS: IP address where emulated VMs are reached. Comma separate list |
| tierno | e64f7fb | 2019-09-11 08:55:52 +0000 | [diff] [blame] | 40 | OSMLCMTEST_RO_VIMID: VIM id of RO target vim IP. Obtain it with openmano datcenter-list on RO container |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 41 | OSMLCMTEST_VCA_NOMOCK: Do no mock the VCA, N2VC library, for debugging it |
| 42 | OSMLCMTEST_RO_NOMOCK: Do no mock the ROClient library, for debugging it |
| 43 | OSMLCMTEST_DB_NOMOCK: Do no mock the database library, for debugging it |
| tierno | 7ab529a | 2019-08-30 12:10:17 +0000 | [diff] [blame] | 44 | OSMLCMTEST_FS_NOMOCK: Do no mock the File Storage library, for debugging it |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 45 | OSMLCMTEST_LOGGING_NOMOCK: Do no mock the logging |
| 46 | OSMLCM_VCA_XXX: configuration of N2VC |
| 47 | OSMLCM_RO_XXX: configuration of RO |
| 48 | """ |
| 49 | |
| 50 | |
| 51 | vca_config = { # TODO replace with os.get_env to get other configurations |
| 52 | "host": getenv("OSMLCM_VCA_HOST", "vca"), |
| tierno | 7ab529a | 2019-08-30 12:10:17 +0000 | [diff] [blame] | 53 | "port": getenv("OSMLCM_VCA_PORT", 17070), |
| 54 | "user": getenv("OSMLCM_VCA_USER", "admin"), |
| 55 | "secret": getenv("OSMLCM_VCA_SECRET", "vca"), |
| 56 | "pubkey": getenv("OSMLCM_VCA_PUBKEY", None), |
| 57 | 'cacert': getenv("OSMLCM_VCA_CACERT", None) |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | ro_config = { |
| 61 | "endpoint_url": "http://{}:{}/openmano".format(getenv("OSMLCM_RO_HOST", "ro"), getenv("OSMLCM_RO_PORT", "9090")), |
| 62 | "tenant": getenv("OSMLCM_RO_TENANT", "osm"), |
| 63 | "logger_name": "lcm.ROclient", |
| 64 | "loglevel": "DEBUG", |
| 65 | } |
| 66 | |
| 67 | db_vim_accounts_text = """ |
| 68 | --- |
| 69 | - _admin: |
| 70 | created: 1566818150.3024442 |
| 71 | current_operation: 0 |
| 72 | deployed: |
| 73 | RO: dc51ce6c-c7f2-11e9-b9c0-02420aff0004 |
| 74 | RO-account: dc5c67fa-c7f2-11e9-b9c0-02420aff0004 |
| 75 | detailed-status: Done |
| 76 | modified: 1566818150.3024442 |
| 77 | operationalState: ENABLED |
| 78 | operations: |
| 79 | - detailed-status: Done |
| 80 | lcmOperationType: create |
| 81 | operationParams: null |
| 82 | operationState: COMPLETED |
| 83 | startTime: 1566818150.3025382 |
| 84 | statusEnteredTime: 1566818150.3025382 |
| 85 | worker: 86434c2948e2 |
| 86 | projects_read: |
| 87 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 88 | projects_write: |
| 89 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 90 | _id: ea958ba5-4e58-4405-bf42-6e3be15d4c3a |
| 91 | description: Openstack site 2, based on Mirantis, also called DSS9000-1, with |
| 92 | tenant tid |
| 93 | name: ost2-mrt-tid |
| 94 | schema_version: '1.1' |
| 95 | vim_password: 5g0yGX86qIhprX86YTMcpg== |
| 96 | vim_tenant_name: osm |
| 97 | vim_type: openstack |
| 98 | vim_url: http://10.95.87.162:5000/v2.0 |
| 99 | vim_user: osm |
| 100 | """ |
| 101 | |
| 102 | db_vnfds_text = """ |
| 103 | --- |
| 104 | - _admin: |
| 105 | created: 1566823352.7154346 |
| 106 | modified: 1566823353.9295402 |
| 107 | onboardingState: ONBOARDED |
| 108 | operationalState: ENABLED |
| 109 | projects_read: |
| 110 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 111 | projects_write: |
| 112 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 113 | storage: |
| 114 | descriptor: hackfest_3charmed_vnfd/hackfest_3charmed_vnfd.yaml |
| 115 | folder: 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77 |
| 116 | fs: local |
| 117 | path: /app/storage/ |
| 118 | pkg-dir: hackfest_3charmed_vnfd |
| 119 | zipfile: package.tar.gz |
| 120 | type: vnfd |
| 121 | usageState: NOT_IN_USE |
| 122 | userDefinedData: {} |
| 123 | _id: 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77 |
| 124 | connection-point: |
| 125 | - id: vnf-mgmt |
| 126 | name: vnf-mgmt |
| 127 | short-name: vnf-mgmt |
| 128 | type: VPORT |
| 129 | - id: vnf-data |
| 130 | name: vnf-data |
| 131 | short-name: vnf-data |
| 132 | type: VPORT |
| 133 | description: A VNF consisting of 2 VDUs connected to an internal VL, and one VDU |
| 134 | with cloud-init |
| 135 | id: hackfest3charmed-vnf |
| 136 | internal-vld: |
| 137 | - id: internal |
| 138 | internal-connection-point: |
| 139 | - id-ref: mgmtVM-internal |
| 140 | - id-ref: dataVM-internal |
| 141 | name: internal |
| 142 | short-name: internal |
| 143 | type: ELAN |
| 144 | logo: osm.png |
| 145 | mgmt-interface: |
| 146 | cp: vnf-mgmt |
| 147 | monitoring-param: |
| 148 | - aggregation-type: AVERAGE |
| 149 | id: monitor1 |
| 150 | name: monitor1 |
| 151 | vdu-monitoring-param: |
| 152 | vdu-monitoring-param-ref: dataVM_cpu_util |
| 153 | vdu-ref: dataVM |
| 154 | name: hackfest3charmed-vnf |
| 155 | scaling-group-descriptor: |
| 156 | - max-instance-count: 10 |
| 157 | name: scale_dataVM |
| 158 | scaling-config-action: |
| 159 | - trigger: post-scale-out |
| 160 | vnf-config-primitive-name-ref: touch |
| 161 | - trigger: pre-scale-in |
| 162 | vnf-config-primitive-name-ref: touch |
| 163 | scaling-policy: |
| 164 | - cooldown-time: 60 |
| 165 | name: auto_cpu_util_above_threshold |
| 166 | scaling-criteria: |
| 167 | - name: cpu_util_above_threshold |
| 168 | scale-in-relational-operation: LE |
| 169 | scale-in-threshold: '15.0000000000' |
| 170 | scale-out-relational-operation: GE |
| 171 | scale-out-threshold: '60.0000000000' |
| 172 | vnf-monitoring-param-ref: monitor1 |
| 173 | scaling-type: automatic |
| 174 | threshold-time: 0 |
| 175 | vdu: |
| 176 | - count: 1 |
| 177 | vdu-id-ref: dataVM |
| 178 | short-name: hackfest3charmed-vnf |
| 179 | vdu: |
| 180 | - count: '1' |
| 181 | cloud-init-file: cloud-config.txt |
| 182 | id: mgmtVM |
| 183 | image: hackfest3-mgmt |
| 184 | interface: |
| 185 | - external-connection-point-ref: vnf-mgmt |
| 186 | name: mgmtVM-eth0 |
| 187 | position: 1 |
| 188 | type: EXTERNAL |
| 189 | virtual-interface: |
| 190 | type: VIRTIO |
| 191 | - internal-connection-point-ref: mgmtVM-internal |
| 192 | name: mgmtVM-eth1 |
| 193 | position: 2 |
| 194 | type: INTERNAL |
| 195 | virtual-interface: |
| 196 | type: VIRTIO |
| 197 | internal-connection-point: |
| 198 | - id: mgmtVM-internal |
| 199 | name: mgmtVM-internal |
| 200 | short-name: mgmtVM-internal |
| 201 | type: VPORT |
| 202 | name: mgmtVM |
| 203 | vm-flavor: |
| 204 | memory-mb: '1024' |
| 205 | storage-gb: '10' |
| 206 | vcpu-count: 1 |
| 207 | - count: '1' |
| 208 | id: dataVM |
| 209 | image: hackfest3-mgmt |
| 210 | interface: |
| 211 | - internal-connection-point-ref: dataVM-internal |
| 212 | name: dataVM-eth0 |
| 213 | position: 1 |
| 214 | type: INTERNAL |
| 215 | virtual-interface: |
| 216 | type: VIRTIO |
| 217 | - external-connection-point-ref: vnf-data |
| 218 | name: dataVM-xe0 |
| 219 | position: 2 |
| 220 | type: EXTERNAL |
| 221 | virtual-interface: |
| 222 | type: VIRTIO |
| 223 | internal-connection-point: |
| 224 | - id: dataVM-internal |
| 225 | name: dataVM-internal |
| 226 | short-name: dataVM-internal |
| 227 | type: VPORT |
| 228 | monitoring-param: |
| 229 | - id: dataVM_cpu_util |
| 230 | nfvi-metric: cpu_utilization |
| 231 | name: dataVM |
| 232 | vm-flavor: |
| 233 | memory-mb: '1024' |
| 234 | storage-gb: '10' |
| 235 | vcpu-count: 1 |
| 236 | version: '1.0' |
| 237 | vnf-configuration: |
| tierno | e64f7fb | 2019-09-11 08:55:52 +0000 | [diff] [blame] | 238 | config-access: |
| 239 | ssh-access: |
| 240 | required: True |
| 241 | default-user: ubuntu |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 242 | config-primitive: |
| 243 | - name: touch |
| 244 | parameter: |
| 245 | - data-type: STRING |
| 246 | default-value: <touch_filename2> |
| 247 | name: filename |
| 248 | initial-config-primitive: |
| 249 | - name: config |
| 250 | parameter: |
| 251 | - name: ssh-hostname |
| 252 | value: <rw_mgmt_ip> |
| 253 | - name: ssh-username |
| 254 | value: ubuntu |
| 255 | - name: ssh-password |
| 256 | value: osm4u |
| 257 | seq: '1' |
| 258 | - name: touch |
| 259 | parameter: |
| 260 | - name: filename |
| 261 | value: <touch_filename> |
| 262 | seq: '2' |
| 263 | juju: |
| 264 | charm: simple |
| 265 | """ |
| 266 | |
| 267 | db_nsds_text = """ |
| 268 | --- |
| 269 | - _admin: |
| 270 | created: 1566823353.971486 |
| 271 | modified: 1566823353.971486 |
| 272 | onboardingState: ONBOARDED |
| 273 | operationalState: ENABLED |
| 274 | projects_read: |
| 275 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 276 | projects_write: |
| 277 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 278 | storage: |
| 279 | descriptor: hackfest_3charmed_nsd/hackfest_3charmed_nsd.yaml |
| 280 | folder: 8c2f8b95-bb1b-47ee-8001-36dc090678da |
| 281 | fs: local |
| 282 | path: /app/storage/ |
| 283 | pkg-dir: hackfest_3charmed_nsd |
| 284 | zipfile: package.tar.gz |
| 285 | usageState: NOT_IN_USE |
| 286 | userDefinedData: {} |
| 287 | _id: 8c2f8b95-bb1b-47ee-8001-36dc090678da |
| 288 | constituent-vnfd: |
| 289 | - member-vnf-index: '1' |
| 290 | vnfd-id-ref: hackfest3charmed-vnf |
| 291 | - member-vnf-index: '2' |
| 292 | vnfd-id-ref: hackfest3charmed-vnf |
| 293 | description: NS with 2 VNFs hackfest3charmed-vnf connected by datanet and mgmtnet |
| 294 | VLs |
| 295 | id: hackfest3charmed-ns |
| 296 | logo: osm.png |
| 297 | name: hackfest3charmed-ns |
| 298 | short-name: hackfest3charmed-ns |
| 299 | version: '1.0' |
| 300 | vld: |
| 301 | - id: mgmt |
| 302 | mgmt-network: true |
| 303 | name: mgmt |
| 304 | short-name: mgmt |
| 305 | type: ELAN |
| 306 | vim-network-name: mgmt |
| 307 | vnfd-connection-point-ref: |
| 308 | - member-vnf-index-ref: '1' |
| 309 | vnfd-connection-point-ref: vnf-mgmt |
| 310 | vnfd-id-ref: hackfest3charmed-vnf |
| 311 | - member-vnf-index-ref: '2' |
| 312 | vnfd-connection-point-ref: vnf-mgmt |
| 313 | vnfd-id-ref: hackfest3charmed-vnf |
| 314 | - id: datanet |
| 315 | name: datanet |
| 316 | short-name: datanet |
| 317 | type: ELAN |
| 318 | vnfd-connection-point-ref: |
| 319 | - member-vnf-index-ref: '1' |
| 320 | vnfd-connection-point-ref: vnf-data |
| 321 | vnfd-id-ref: hackfest3charmed-vnf |
| 322 | - member-vnf-index-ref: '2' |
| 323 | vnfd-connection-point-ref: vnf-data |
| 324 | vnfd-id-ref: hackfest3charmed-vnf |
| 325 | """ |
| 326 | |
| 327 | db_nsrs_text = """ |
| 328 | --- |
| 329 | - _admin: |
| 330 | created: 1566823354.3716335 |
| 331 | deployed: |
| 332 | RO: |
| 333 | nsd_id: 876573b5-968d-40b9-b52b-91bf5c5844f7 |
| 334 | nsr_id: c9fe9908-3180-430d-b633-fca2f68db008 |
| 335 | nsr_status: ACTIVE |
| 336 | vnfd: |
| 337 | - id: 1ab2a418-9fe3-4358-bf17-411e5155535f |
| 338 | member-vnf-index: '1' |
| 339 | - id: 0de348e3-c201-4f6a-91cc-7f957e2d5504 |
| 340 | member-vnf-index: '2' |
| 341 | VCA: |
| 342 | - application: alf-b-aa |
| 343 | detailed-status: Ready! |
| 344 | member-vnf-index: '1' |
| 345 | model: f48163a6-c807-47bc-9682-f72caef5af85 |
| 346 | operational-status: active |
| 347 | primitive_id: null |
| 348 | ssh-public-key: ssh-rsa pub-key root@juju-145d3e-0 |
| 349 | step: ssh-public-key-obtained |
| 350 | vdu_count_index: null |
| 351 | vdu_id: null |
| 352 | vdu_name: null |
| 353 | vnfd_id: hackfest3charmed-vnf |
| 354 | - application: alf-c-ab |
| 355 | detailed-status: Ready! |
| 356 | member-vnf-index: '2' |
| 357 | model: f48163a6-c807-47bc-9682-f72caef5af85 |
| 358 | operational-status: active |
| 359 | primitive_id: null |
| 360 | ssh-public-key: ssh-rsa pub-key root@juju-145d3e-0 |
| 361 | step: ssh-public-key-obtained |
| 362 | vdu_count_index: null |
| 363 | vdu_id: null |
| 364 | vdu_name: null |
| 365 | vnfd_id: hackfest3charmed-vnf |
| 366 | VCA-model-name: f48163a6-c807-47bc-9682-f72caef5af85 |
| 367 | modified: 1566823354.3716335 |
| 368 | nsState: INSTANTIATED |
| 369 | nslcmop: null |
| 370 | projects_read: |
| 371 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 372 | projects_write: |
| 373 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 374 | _id: f48163a6-c807-47bc-9682-f72caef5af85 |
| 375 | additionalParamsForNs: null |
| 376 | admin-status: ENABLED |
| 377 | config-status: init |
| 378 | constituent-vnfr-ref: |
| 379 | - 88d90b0c-faff-4b9f-bccd-017f33985984 |
| 380 | - 1ca3bb1a-b29b-49fe-bed6-5f3076d77434 |
| 381 | create-time: 1566823354.36234 |
| 382 | datacenter: ea958ba5-4e58-4405-bf42-6e3be15d4c3a |
| 383 | description: default description |
| 384 | detailed-status: 'ERROR executing proxy charm initial primitives for member_vnf_index=1 |
| 385 | vdu_id=None: charm error executing primitive verify-ssh-credentials for member_vnf_index=1 |
| 386 | vdu_id=None: ''timeout after 600 seconds''' |
| 387 | id: f48163a6-c807-47bc-9682-f72caef5af85 |
| 388 | instantiate_params: |
| 389 | nsDescription: default description |
| 390 | nsName: ALF |
| 391 | nsdId: 8c2f8b95-bb1b-47ee-8001-36dc090678da |
| 392 | vimAccountId: ea958ba5-4e58-4405-bf42-6e3be15d4c3a |
| 393 | name: ALF |
| 394 | name-ref: ALF |
| 395 | ns-instance-config-ref: f48163a6-c807-47bc-9682-f72caef5af85 |
| 396 | nsd: |
| 397 | _admin: |
| 398 | created: 1566823353.971486 |
| 399 | modified: 1566823353.971486 |
| 400 | onboardingState: ONBOARDED |
| 401 | operationalState: ENABLED |
| 402 | projects_read: |
| 403 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 404 | projects_write: |
| 405 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 406 | storage: |
| 407 | descriptor: hackfest_3charmed_nsd/hackfest_3charmed_nsd.yaml |
| 408 | folder: 8c2f8b95-bb1b-47ee-8001-36dc090678da |
| 409 | fs: local |
| 410 | path: /app/storage/ |
| 411 | pkg-dir: hackfest_3charmed_nsd |
| 412 | zipfile: package.tar.gz |
| 413 | usageState: NOT_IN_USE |
| 414 | userDefinedData: {} |
| 415 | _id: 8c2f8b95-bb1b-47ee-8001-36dc090678da |
| 416 | constituent-vnfd: |
| 417 | - member-vnf-index: '1' |
| 418 | vnfd-id-ref: hackfest3charmed-vnf |
| 419 | - member-vnf-index: '2' |
| 420 | vnfd-id-ref: hackfest3charmed-vnf |
| 421 | description: NS with 2 VNFs hackfest3charmed-vnf connected by datanet and |
| 422 | mgmtnet VLs |
| 423 | id: hackfest3charmed-ns |
| 424 | logo: osm.png |
| 425 | name: hackfest3charmed-ns |
| 426 | short-name: hackfest3charmed-ns |
| 427 | version: '1.0' |
| 428 | vld: |
| 429 | - id: mgmt |
| 430 | mgmt-network: true |
| 431 | name: mgmt |
| 432 | short-name: mgmt |
| 433 | type: ELAN |
| 434 | vim-network-name: mgmt |
| 435 | vnfd-connection-point-ref: |
| 436 | - member-vnf-index-ref: '1' |
| 437 | vnfd-connection-point-ref: vnf-mgmt |
| 438 | vnfd-id-ref: hackfest3charmed-vnf |
| 439 | - member-vnf-index-ref: '2' |
| 440 | vnfd-connection-point-ref: vnf-mgmt |
| 441 | vnfd-id-ref: hackfest3charmed-vnf |
| 442 | - id: datanet |
| 443 | name: datanet |
| 444 | short-name: datanet |
| 445 | type: ELAN |
| 446 | vnfd-connection-point-ref: |
| 447 | - member-vnf-index-ref: '1' |
| 448 | vnfd-connection-point-ref: vnf-data |
| 449 | vnfd-id-ref: hackfest3charmed-vnf |
| 450 | - member-vnf-index-ref: '2' |
| 451 | vnfd-connection-point-ref: vnf-data |
| 452 | vnfd-id-ref: hackfest3charmed-vnf |
| 453 | nsd-id: 8c2f8b95-bb1b-47ee-8001-36dc090678da |
| 454 | nsd-name-ref: hackfest3charmed-ns |
| 455 | nsd-ref: hackfest3charmed-ns |
| 456 | operational-events: [] |
| 457 | operational-status: failed |
| 458 | orchestration-progress: {} |
| 459 | resource-orchestrator: osmopenmano |
| 460 | short-name: ALF |
| 461 | ssh-authorized-key: null |
| 462 | vld: |
| 463 | - id: mgmt |
| 464 | name: null |
| 465 | status: ACTIVE |
| 466 | status-detailed: null |
| 467 | vim-id: f99ae780-0e2f-4985-af41-574eae6919c0 |
| 468 | vim-network-name: mgmt |
| 469 | - id: datanet |
| 470 | name: ALF-datanet |
| 471 | status: ACTIVE |
| 472 | status-detailed: null |
| 473 | vim-id: c31364ba-f573-4ab6-bf1a-fed30ede39a8 |
| 474 | vnfd-id: |
| 475 | - 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77 |
| 476 | """ |
| 477 | |
| 478 | db_nslcmops_text = """ |
| 479 | --- |
| 480 | - _admin: |
| 481 | created: 1566823354.4148262 |
| 482 | modified: 1566823354.4148262 |
| 483 | projects_read: |
| 484 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 485 | projects_write: |
| 486 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 487 | worker: 86434c2948e2 |
| 488 | _id: a639fac7-e0bb-4225-8ecb-c1f8efcc125e |
| 489 | detailed-status: 'FAILED executing proxy charm initial primitives for member_vnf_index=1 |
| 490 | vdu_id=None: charm error executing primitive verify-ssh-credentials for member_vnf_index=1 |
| 491 | vdu_id=None: ''timeout after 600 seconds''' |
| 492 | id: a639fac7-e0bb-4225-8ecb-c1f8efcc125e |
| 493 | isAutomaticInvocation: false |
| 494 | isCancelPending: false |
| 495 | lcmOperationType: instantiate |
| 496 | links: |
| 497 | nsInstance: /osm/nslcm/v1/ns_instances/f48163a6-c807-47bc-9682-f72caef5af85 |
| 498 | self: /osm/nslcm/v1/ns_lcm_op_occs/a639fac7-e0bb-4225-8ecb-c1f8efcc125e |
| 499 | nsInstanceId: f48163a6-c807-47bc-9682-f72caef5af85 |
| 500 | operationParams: |
| 501 | additionalParamsForVnf: |
| 502 | - additionalParams: |
| 503 | touch_filename: /home/ubuntu/first-touch-1 |
| 504 | touch_filename2: /home/ubuntu/second-touch-1 |
| 505 | member-vnf-index: '1' |
| 506 | - additionalParams: |
| 507 | touch_filename: /home/ubuntu/first-touch-2 |
| 508 | touch_filename2: /home/ubuntu/second-touch-2 |
| 509 | member-vnf-index: '2' |
| 510 | lcmOperationType: instantiate |
| 511 | nsDescription: default description |
| 512 | nsInstanceId: f48163a6-c807-47bc-9682-f72caef5af85 |
| 513 | nsName: ALF |
| 514 | nsdId: 8c2f8b95-bb1b-47ee-8001-36dc090678da |
| 515 | vimAccountId: ea958ba5-4e58-4405-bf42-6e3be15d4c3a |
| 516 | operationState: FAILED |
| 517 | startTime: 1566823354.414689 |
| 518 | statusEnteredTime: 1566824534.5112448 |
| 519 | """ |
| 520 | |
| 521 | db_vnfrs_text = """ |
| 522 | --- |
| 523 | - _admin: |
| 524 | created: 1566823354.3668208 |
| 525 | modified: 1566823354.3668208 |
| 526 | nsState: NOT_INSTANTIATED |
| 527 | projects_read: |
| 528 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 529 | projects_write: |
| 530 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 531 | _id: 88d90b0c-faff-4b9f-bccd-017f33985984 |
| 532 | additionalParamsForVnf: |
| 533 | touch_filename: /home/ubuntu/first-touch-1 |
| 534 | touch_filename2: /home/ubuntu/second-touch-1 |
| 535 | connection-point: |
| 536 | - connection-point-id: vnf-mgmt |
| 537 | id: vnf-mgmt |
| 538 | name: vnf-mgmt |
| 539 | - connection-point-id: vnf-data |
| 540 | id: vnf-data |
| 541 | name: vnf-data |
| 542 | created-time: 1566823354.36234 |
| 543 | id: 88d90b0c-faff-4b9f-bccd-017f33985984 |
| 544 | ip-address: 10.205.1.46 |
| 545 | member-vnf-index-ref: '1' |
| 546 | nsr-id-ref: f48163a6-c807-47bc-9682-f72caef5af85 |
| 547 | vdur: |
| 548 | - _id: f0e7d7ce-2443-4dcb-ad0b-5ab9f3b13d37 |
| 549 | count-index: 0 |
| 550 | interfaces: |
| 551 | - ip-address: 10.205.1.46 |
| 552 | mac-address: fa:16:3e:b4:3e:b1 |
| 553 | mgmt-vnf: true |
| 554 | name: mgmtVM-eth0 |
| 555 | ns-vld-id: mgmt |
| 556 | - ip-address: 192.168.54.2 |
| 557 | mac-address: fa:16:3e:6e:7e:78 |
| 558 | name: mgmtVM-eth1 |
| 559 | vnf-vld-id: internal |
| 560 | internal-connection-point: |
| 561 | - connection-point-id: mgmtVM-internal |
| 562 | id: mgmtVM-internal |
| 563 | name: mgmtVM-internal |
| 564 | ip-address: 10.205.1.46 |
| 565 | name: ALF-1-mgmtVM-1 |
| 566 | status: ACTIVE |
| 567 | status-detailed: null |
| 568 | vdu-id-ref: mgmtVM |
| 569 | vim-id: c2538499-4c30-41c0-acd5-80cb92f48061 |
| 570 | - _id: ab453219-2d9a-45c2-864d-2c0788385028 |
| 571 | count-index: 0 |
| 572 | interfaces: |
| 573 | - ip-address: 192.168.54.3 |
| 574 | mac-address: fa:16:3e:d9:7a:5d |
| 575 | name: dataVM-eth0 |
| 576 | vnf-vld-id: internal |
| 577 | - ip-address: 192.168.24.3 |
| 578 | mac-address: fa:16:3e:d1:6c:0d |
| 579 | name: dataVM-xe0 |
| 580 | ns-vld-id: datanet |
| 581 | internal-connection-point: |
| 582 | - connection-point-id: dataVM-internal |
| 583 | id: dataVM-internal |
| 584 | name: dataVM-internal |
| 585 | ip-address: null |
| 586 | name: ALF-1-dataVM-1 |
| 587 | status: ACTIVE |
| 588 | status-detailed: null |
| 589 | vdu-id-ref: dataVM |
| 590 | vim-id: 87973c3f-365d-4227-95c2-7a8abc74349c |
| 591 | vim-account-id: ea958ba5-4e58-4405-bf42-6e3be15d4c3a |
| 592 | vld: |
| 593 | - id: internal |
| 594 | name: ALF-internal |
| 595 | status: ACTIVE |
| 596 | status-detailed: null |
| 597 | vim-id: ff181e6d-2597-4244-b40b-bb0174bdfeb6 |
| 598 | vnfd-id: 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77 |
| 599 | vnfd-ref: hackfest3charmed-vnf |
| 600 | - _admin: |
| 601 | created: 1566823354.3703845 |
| 602 | modified: 1566823354.3703845 |
| 603 | nsState: NOT_INSTANTIATED |
| 604 | projects_read: |
| 605 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 606 | projects_write: |
| 607 | - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 |
| 608 | _id: 1ca3bb1a-b29b-49fe-bed6-5f3076d77434 |
| 609 | additionalParamsForVnf: |
| 610 | touch_filename: /home/ubuntu/first-touch-2 |
| 611 | touch_filename2: /home/ubuntu/second-touch-2 |
| 612 | connection-point: |
| 613 | - connection-point-id: vnf-mgmt |
| 614 | id: vnf-mgmt |
| 615 | name: vnf-mgmt |
| 616 | - connection-point-id: vnf-data |
| 617 | id: vnf-data |
| 618 | name: vnf-data |
| 619 | created-time: 1566823354.36234 |
| 620 | id: 1ca3bb1a-b29b-49fe-bed6-5f3076d77434 |
| 621 | ip-address: 10.205.1.47 |
| 622 | member-vnf-index-ref: '2' |
| 623 | nsr-id-ref: f48163a6-c807-47bc-9682-f72caef5af85 |
| 624 | vdur: |
| 625 | - _id: 190b4a2c-4f85-4cfe-9406-4cef7ffb1e67 |
| 626 | count-index: 0 |
| 627 | interfaces: |
| 628 | - ip-address: 10.205.1.47 |
| 629 | mac-address: fa:16:3e:cb:9f:c7 |
| 630 | mgmt-vnf: true |
| 631 | name: mgmtVM-eth0 |
| 632 | ns-vld-id: mgmt |
| 633 | - ip-address: 192.168.231.1 |
| 634 | mac-address: fa:16:3e:1a:89:24 |
| 635 | name: mgmtVM-eth1 |
| 636 | vnf-vld-id: internal |
| 637 | internal-connection-point: |
| 638 | - connection-point-id: mgmtVM-internal |
| 639 | id: mgmtVM-internal |
| 640 | name: mgmtVM-internal |
| 641 | ip-address: 10.205.1.47 |
| 642 | name: ALF-2-mgmtVM-1 |
| 643 | status: ACTIVE |
| 644 | status-detailed: null |
| 645 | vdu-id-ref: mgmtVM |
| 646 | vim-id: 248077b2-e3b8-4a37-8b72-575abb8ed912 |
| 647 | - _id: 889b874d-e1c3-4e75-aa45-53a9b0ddabd9 |
| 648 | count-index: 0 |
| 649 | interfaces: |
| 650 | - ip-address: 192.168.231.3 |
| 651 | mac-address: fa:16:3e:7e:ba:8c |
| 652 | name: dataVM-eth0 |
| 653 | vnf-vld-id: internal |
| 654 | - ip-address: 192.168.24.4 |
| 655 | mac-address: fa:16:3e:d2:e1:f5 |
| 656 | name: dataVM-xe0 |
| 657 | ns-vld-id: datanet |
| 658 | internal-connection-point: |
| 659 | - connection-point-id: dataVM-internal |
| 660 | id: dataVM-internal |
| 661 | name: dataVM-internal |
| 662 | ip-address: null |
| 663 | name: ALF-2-dataVM-1 |
| 664 | status: ACTIVE |
| 665 | status-detailed: null |
| 666 | vdu-id-ref: dataVM |
| 667 | vim-id: a4ce4372-e0ad-4ae3-8f9f-1c969f32e77b |
| 668 | vim-account-id: ea958ba5-4e58-4405-bf42-6e3be15d4c3a |
| 669 | vld: |
| 670 | - id: internal |
| 671 | name: ALF-internal |
| 672 | status: ACTIVE |
| 673 | status-detailed: null |
| 674 | vim-id: ff181e6d-2597-4244-b40b-bb0174bdfeb6 |
| 675 | vnfd-id: 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77 |
| 676 | vnfd-ref: hackfest3charmed-vnf |
| 677 | """ |
| 678 | |
| 679 | ro_ns_text = """ |
| 680 | datacenter_tenant_id: dc5c67fa-c7f2-11e9-b9c0-02420aff0004 |
| 681 | description: null |
| 682 | name: ALF |
| 683 | nets: |
| 684 | - created: false |
| 685 | datacenter_id: dc51ce6c-c7f2-11e9-b9c0-02420aff0004 |
| 686 | datacenter_tenant_id: dc5c67fa-c7f2-11e9-b9c0-02420aff0004 |
| 687 | error_msg: null |
| 688 | ns_net_osm_id: mgmt |
| 689 | related: c6bac394-fa27-4c43-bb34-42f621a9d343 |
| 690 | sce_net_id: 8f215bab-c35e-41e6-a035-42bfaa07af9f |
| 691 | sdn_net_id: null |
| 692 | status: ACTIVE |
| 693 | uuid: c6bac394-fa27-4c43-bb34-42f621a9d343 |
| 694 | vim_info: "{vim_info: null}" |
| 695 | vim_name: null |
| 696 | vim_net_id: f99ae780-0e2f-4985-af41-574eae6919c0 |
| 697 | vnf_net_id: null |
| 698 | vnf_net_osm_id: null |
| 699 | - created: true |
| 700 | datacenter_id: dc51ce6c-c7f2-11e9-b9c0-02420aff0004 |
| 701 | datacenter_tenant_id: dc5c67fa-c7f2-11e9-b9c0-02420aff0004 |
| 702 | error_msg: null |
| 703 | ns_net_osm_id: datanet |
| 704 | related: 509d576c-120f-493a-99a1-5fea99dfe041 |
| 705 | sce_net_id: 3d766bbc-33a8-41aa-a986-2f35e8d25c16 |
| 706 | sdn_net_id: null |
| 707 | status: ACTIVE |
| 708 | uuid: 509d576c-120f-493a-99a1-5fea99dfe041 |
| 709 | vim_info: "{vim_info: null}" |
| 710 | vim_name: ALF-datanet |
| 711 | vim_net_id: c31364ba-f573-4ab6-bf1a-fed30ede39a8 |
| 712 | vnf_net_id: null |
| 713 | vnf_net_osm_id: null |
| 714 | - created: true |
| 715 | datacenter_id: dc51ce6c-c7f2-11e9-b9c0-02420aff0004 |
| 716 | datacenter_tenant_id: dc5c67fa-c7f2-11e9-b9c0-02420aff0004 |
| 717 | error_msg: null |
| 718 | ns_net_osm_id: null |
| 719 | related: 277fed09-3220-4bfd-9052-b96b21a32daf |
| 720 | sce_net_id: null |
| 721 | sdn_net_id: null |
| 722 | status: ACTIVE |
| 723 | uuid: 277fed09-3220-4bfd-9052-b96b21a32daf |
| 724 | vim_info: "{vim_info: null}" |
| 725 | vim_name: ALF-internal |
| 726 | vim_net_id: ff181e6d-2597-4244-b40b-bb0174bdfeb6 |
| 727 | vnf_net_id: 62e62fae-c12b-4ebc-9a9b-30031c6c16fa |
| 728 | vnf_net_osm_id: internal |
| 729 | - created: true |
| 730 | datacenter_id: dc51ce6c-c7f2-11e9-b9c0-02420aff0004 |
| 731 | datacenter_tenant_id: dc5c67fa-c7f2-11e9-b9c0-02420aff0004 |
| 732 | error_msg: null |
| 733 | ns_net_osm_id: null |
| 734 | related: 92534d1a-e697-4372-a84d-aa0aa643b68a |
| 735 | sce_net_id: null |
| 736 | sdn_net_id: null |
| 737 | status: ACTIVE |
| 738 | uuid: 92534d1a-e697-4372-a84d-aa0aa643b68a |
| 739 | vim_info: "{vim_info: null}" |
| 740 | vim_name: ALF-internal |
| 741 | vim_net_id: 09655387-b639-421a-b5f6-72b26d685fb4 |
| 742 | vnf_net_id: 13c6c77d-86a5-4914-832c-990d4ec7b54e |
| 743 | vnf_net_osm_id: internal |
| 744 | nsd_osm_id: f48163a6-c807-47bc-9682-f72caef5af85.2.hackfest3charmed-ns |
| 745 | scenario_id: 876573b5-968d-40b9-b52b-91bf5c5844f7 |
| 746 | scenario_name: hackfest3charmed-ns |
| 747 | sfis: [] |
| 748 | sfps: [] |
| 749 | sfs: [] |
| 750 | tenant_id: 0ea38bd0-2729-47a9-ae07-c6ce76115eb2 |
| 751 | uuid: c9fe9908-3180-430d-b633-fca2f68db008 |
| 752 | vnfs: |
| 753 | - datacenter_id: dc51ce6c-c7f2-11e9-b9c0-02420aff0004 |
| 754 | datacenter_tenant_id: dc5c67fa-c7f2-11e9-b9c0-02420aff0004 |
| 755 | ip_address: 10.205.1.46 |
| 756 | member_vnf_index: '1' |
| 757 | mgmt_access: '{interface_id: 61549ee3-cd6c-4930-8b90-eaad97fe345b, required: ''False'', |
| 758 | vm_id: 6cf4a48f-3b6c-4395-8221-119fa37de24a} |
| 759 | |
| 760 | ' |
| 761 | sce_vnf_id: 83be04a8-c513-42ba-9908-22728f686d31 |
| 762 | uuid: 94724042-7576-4fb0-82ec-6a7ab642741c |
| 763 | vms: |
| 764 | - created_at: '2019-08-26T12:50:38' |
| 765 | error_msg: null |
| 766 | interfaces: |
| 767 | - external_name: vnf-mgmt |
| 768 | instance_net_id: c6bac394-fa27-4c43-bb34-42f621a9d343 |
| 769 | internal_name: mgmtVM-eth0 |
| 770 | ip_address: 10.205.1.46 |
| 771 | mac_address: fa:16:3e:b4:3e:b1 |
| 772 | sdn_port_id: null |
| 773 | type: mgmt |
| 774 | vim_info: "{vim_info: null}" |
| 775 | vim_interface_id: 4d3cb8fd-7040-4169-a0ad-2486d2b006a1 |
| 776 | - external_name: null |
| 777 | instance_net_id: 277fed09-3220-4bfd-9052-b96b21a32daf |
| 778 | internal_name: mgmtVM-eth1 |
| 779 | ip_address: 192.168.54.2 |
| 780 | mac_address: fa:16:3e:6e:7e:78 |
| 781 | sdn_port_id: null |
| 782 | type: bridge |
| 783 | vim_info: "{vim_info: null}" |
| 784 | vim_interface_id: 54ed68e2-9802-4dfe-b68a-280b3fc6e02d |
| 785 | ip_address: 10.205.1.46 |
| 786 | name: mgmtVM |
| 787 | related: d0b91293-a91d-4f08-b15f-0bf841216dfe |
| 788 | status: ACTIVE |
| 789 | uuid: d0b91293-a91d-4f08-b15f-0bf841216dfe |
| 790 | vdu_osm_id: mgmtVM |
| 791 | vim_info: "{vim_info: null}" |
| 792 | vim_name: ALF-1-mgmtVM-1 |
| 793 | vim_vm_id: c2538499-4c30-41c0-acd5-80cb92f48061 |
| 794 | - created_at: '2019-08-26T12:50:38' |
| 795 | error_msg: null |
| 796 | interfaces: |
| 797 | - external_name: null |
| 798 | instance_net_id: 277fed09-3220-4bfd-9052-b96b21a32daf |
| 799 | internal_name: dataVM-eth0 |
| 800 | ip_address: 192.168.54.3 |
| 801 | mac_address: fa:16:3e:d9:7a:5d |
| 802 | sdn_port_id: null |
| 803 | type: bridge |
| 804 | vim_info: "{vim_info: null}" |
| 805 | vim_interface_id: 1637f350-8840-4241-8ed0-4616bdcecfcf |
| 806 | - external_name: vnf-data |
| 807 | instance_net_id: 509d576c-120f-493a-99a1-5fea99dfe041 |
| 808 | internal_name: dataVM-xe0 |
| 809 | ip_address: 192.168.24.3 |
| 810 | mac_address: fa:16:3e:d1:6c:0d |
| 811 | sdn_port_id: null |
| 812 | type: bridge |
| 813 | vim_info: "{vim_info: null}" |
| 814 | vim_interface_id: 54c73e83-7059-41fe-83a9-4c4ae997b481 |
| 815 | name: dataVM |
| 816 | related: 5c08253d-8a35-474f-b0d3-c5297d174c13 |
| 817 | status: ACTIVE |
| 818 | uuid: 5c08253d-8a35-474f-b0d3-c5297d174c13 |
| 819 | vdu_osm_id: dataVM |
| 820 | vim_info: "{vim_info: null}" |
| 821 | vim_name: ALF-1-dataVM-1 |
| 822 | vim_vm_id: 87973c3f-365d-4227-95c2-7a8abc74349c |
| 823 | - created_at: '2019-08-26T13:40:54' |
| 824 | error_msg: null |
| 825 | interfaces: |
| 826 | - external_name: null |
| 827 | instance_net_id: 277fed09-3220-4bfd-9052-b96b21a32daf |
| 828 | internal_name: dataVM-eth0 |
| 829 | ip_address: 192.168.54.5 |
| 830 | mac_address: fa:16:3e:e4:17:45 |
| 831 | sdn_port_id: null |
| 832 | type: bridge |
| 833 | vim_info: "{vim_info: null}" |
| 834 | vim_interface_id: 7e246e40-8710-4c33-9c95-78fc3c02bc5b |
| 835 | - external_name: vnf-data |
| 836 | instance_net_id: 509d576c-120f-493a-99a1-5fea99dfe041 |
| 837 | internal_name: dataVM-xe0 |
| 838 | ip_address: 192.168.24.5 |
| 839 | mac_address: fa:16:3e:29:6f:a6 |
| 840 | sdn_port_id: null |
| 841 | type: bridge |
| 842 | vim_info: "{vim_info: null}" |
| 843 | vim_interface_id: ce81af7a-9adf-494b-950e-6581fd04ecc4 |
| 844 | name: dataVM |
| 845 | related: 1ae5a0a2-c15a-49a4-a77c-2991d97f6dbe |
| 846 | status: ACTIVE |
| 847 | uuid: 1ae5a0a2-c15a-49a4-a77c-2991d97f6dbe |
| 848 | vdu_osm_id: dataVM |
| 849 | vim_info: "{vim_info: null}" |
| 850 | vim_name: ALF-1-dataVM-2 |
| 851 | vim_vm_id: 4916533e-36c6-4861-9fe3-366a8fb0a5f8 |
| 852 | vnf_id: 1ab2a418-9fe3-4358-bf17-411e5155535f |
| 853 | vnf_name: hackfest3charmed-vnf.1 |
| 854 | vnfd_osm_id: f48163a6-c807-47bc-9682-f72caef5af85.0.1 |
| 855 | - datacenter_id: dc51ce6c-c7f2-11e9-b9c0-02420aff0004 |
| 856 | datacenter_tenant_id: dc5c67fa-c7f2-11e9-b9c0-02420aff0004 |
| 857 | ip_address: 10.205.1.47 |
| 858 | member_vnf_index: '2' |
| 859 | mgmt_access: '{interface_id: 538604c3-5c5e-41eb-8f84-c0239c7fabcd, required: ''False'', |
| 860 | vm_id: dd04d792-05c9-4ecc-bf28-f77384d00311} |
| 861 | |
| 862 | ' |
| 863 | sce_vnf_id: c4f3607a-08ff-4f75-893c-fce507e2f240 |
| 864 | uuid: 00020403-e80f-4ef2-bb7e-b29669643035 |
| 865 | vms: |
| 866 | - created_at: '2019-08-26T12:50:38' |
| 867 | error_msg: null |
| 868 | interfaces: |
| 869 | - external_name: vnf-mgmt |
| 870 | instance_net_id: c6bac394-fa27-4c43-bb34-42f621a9d343 |
| 871 | internal_name: mgmtVM-eth0 |
| 872 | ip_address: 10.205.1.47 |
| 873 | mac_address: fa:16:3e:cb:9f:c7 |
| 874 | sdn_port_id: null |
| 875 | type: mgmt |
| 876 | vim_info: "{vim_info: null}" |
| 877 | vim_interface_id: dcd6d2de-3c68-481c-883e-e9d38c671dc4 |
| 878 | - external_name: null |
| 879 | instance_net_id: 92534d1a-e697-4372-a84d-aa0aa643b68a |
| 880 | internal_name: mgmtVM-eth1 |
| 881 | ip_address: 192.168.231.1 |
| 882 | mac_address: fa:16:3e:1a:89:24 |
| 883 | sdn_port_id: null |
| 884 | type: bridge |
| 885 | vim_info: "{vim_info: null}" |
| 886 | vim_interface_id: 50e538e3-aba0-4652-93bb-20487f3f28e1 |
| 887 | ip_address: 10.205.1.47 |
| 888 | name: mgmtVM |
| 889 | related: 4543ab5d-578c-427c-9df2-affd17e21b66 |
| 890 | status: ACTIVE |
| 891 | uuid: 4543ab5d-578c-427c-9df2-affd17e21b66 |
| 892 | vdu_osm_id: mgmtVM |
| 893 | vim_info: "{vim_info: null}" |
| 894 | vim_name: ALF-2-mgmtVM-1 |
| 895 | vim_vm_id: 248077b2-e3b8-4a37-8b72-575abb8ed912 |
| 896 | - created_at: '2019-08-26T12:50:38' |
| 897 | error_msg: null |
| 898 | interfaces: |
| 899 | - external_name: null |
| 900 | instance_net_id: 92534d1a-e697-4372-a84d-aa0aa643b68a |
| 901 | internal_name: dataVM-eth0 |
| 902 | ip_address: 192.168.231.3 |
| 903 | mac_address: fa:16:3e:7e:ba:8c |
| 904 | sdn_port_id: null |
| 905 | type: bridge |
| 906 | vim_info: "{vim_info: null}" |
| 907 | vim_interface_id: 15274862-14ea-4527-b405-101cae8bc1a0 |
| 908 | - external_name: vnf-data |
| 909 | instance_net_id: 509d576c-120f-493a-99a1-5fea99dfe041 |
| 910 | internal_name: dataVM-xe0 |
| 911 | ip_address: 192.168.24.4 |
| 912 | mac_address: fa:16:3e:d2:e1:f5 |
| 913 | sdn_port_id: null |
| 914 | type: bridge |
| 915 | vim_info: "{vim_info: null}" |
| 916 | vim_interface_id: 253ebe4e-38d5-46be-8777-dbb57510a2ec |
| 917 | name: dataVM |
| 918 | related: 6f03f16b-295a-47a1-9a69-2d069d574a33 |
| 919 | status: ACTIVE |
| 920 | uuid: 6f03f16b-295a-47a1-9a69-2d069d574a33 |
| 921 | vdu_osm_id: dataVM |
| 922 | vim_info: "{vim_info: null}" |
| 923 | vim_name: ALF-2-dataVM-1 |
| 924 | vim_vm_id: a4ce4372-e0ad-4ae3-8f9f-1c969f32e77b |
| 925 | vnf_id: 0de348e3-c201-4f6a-91cc-7f957e2d5504 |
| 926 | vnf_name: hackfest3charmed-vnf.2 |
| 927 | vnfd_osm_id: f48163a6-c807-47bc-9682-f72caef5af85.1.2 |
| 928 | """ |
| 929 | |
| 930 | |
| 931 | class TestMyNS(asynctest.TestCase): |
| 932 | |
| 933 | def _db_get_one(self, table, q_filter=None, fail_on_empty=True, fail_on_more=True): |
| 934 | if table not in self.db_content: |
| 935 | self.assertTrue(False, "db.get_one called with table={}".format(table)) |
| 936 | for db_item in self.db_content[table]: |
| 937 | if db_item["_id"] == q_filter["_id"]: |
| 938 | return db_item |
| 939 | else: |
| 940 | self.assertTrue(False, "db.get_one, table={}, not found _id={}".format(table, q_filter["_id"])) |
| 941 | |
| 942 | def _db_get_list(self, table, q_filter=None): |
| 943 | if table not in self.db_content: |
| 944 | self.assertTrue(False, "db.get_list called with table={} not found".format(table)) |
| 945 | return self.db_content[table] |
| 946 | |
| 947 | def _db_set_one(self, table, q_filter, update_dict, fail_on_empty=True, unset=None, pull=None, push=None): |
| 948 | db_item = self._db_get_one(table, q_filter, fail_on_empty=fail_on_empty) |
| 949 | for k, v in update_dict.items(): |
| 950 | db_nested = db_item |
| 951 | k_list = k.split(".") |
| 952 | for k_nested in k_list[0:-1]: |
| 953 | if isinstance(db_nested, list): |
| 954 | db_nested = db_nested[int(k_nested)] |
| 955 | else: |
| 956 | if k_nested not in db_nested: |
| 957 | db_nested[k_nested] = {} |
| 958 | db_nested = db_nested[k_nested] |
| 959 | k_nested = k_list[-1] |
| 960 | if isinstance(db_nested, list): |
| 961 | if int(k_nested) < len(db_nested): |
| 962 | db_nested[int(k_nested)] = v |
| 963 | else: |
| 964 | db_nested.insert(int(k_nested), v) |
| 965 | else: |
| 966 | db_nested[k_nested] = v |
| 967 | |
| 968 | async def _n2vc_DeployCharms(self, model_name, application_name, vnfd, charm_path, params={}, machine_spec={}, |
| 969 | callback=None, *callback_args): |
| 970 | if callback: |
| 971 | for status, message in (("maintenance", "installing sofwware"), ("active", "Ready!")): |
| 972 | # call callback after some time |
| 973 | asyncio.sleep(5, loop=self.loop) |
| 974 | callback(model_name, application_name, status, message, *callback_args) |
| 975 | |
| 976 | @staticmethod |
| 977 | def _n2vc_FormatApplicationName(*args): |
| 978 | num_calls = 0 |
| 979 | while True: |
| 980 | yield "app_name-{}".format(num_calls) |
| 981 | num_calls += 1 |
| 982 | |
| tierno | 73d8bd0 | 2019-11-18 17:33:27 +0000 | [diff] [blame^] | 983 | def _n2vc_CreateExecutionEnvironment(self, namespace, reuse_ee_id, db_dict): |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 984 | k_list = namespace.split(".") |
| 985 | ee_id = k_list[1] + "." |
| 986 | if len(k_list) >= 2: |
| 987 | for k in k_list[2:4]: |
| 988 | ee_id += k[:8] |
| 989 | else: |
| 990 | ee_id += "_NS_" |
| tierno | 73d8bd0 | 2019-11-18 17:33:27 +0000 | [diff] [blame^] | 991 | return ee_id, {} |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 992 | |
| 993 | def _ro_show(self, *args, **kwargs): |
| 994 | ro_ns_desc = yaml.load(ro_ns_text) |
| 995 | |
| 996 | # if ip address provided, replace descriptor |
| 997 | ip_addresses = getenv("OSMLCMTEST_NS_IPADDRESS", "") |
| 998 | if ip_addresses: |
| 999 | ip_addresses_list = ip_addresses.split(",") |
| 1000 | for vnf in ro_ns_desc["vnfs"]: |
| 1001 | if not ip_addresses_list: |
| 1002 | break |
| 1003 | vnf["ip_address"] = ip_addresses_list[0] |
| 1004 | for vm in vnf["vms"]: |
| 1005 | if not ip_addresses_list: |
| 1006 | break |
| 1007 | vm["ip_address"] = ip_addresses_list.pop(0) |
| 1008 | |
| 1009 | while True: |
| 1010 | yield ro_ns_desc |
| 1011 | for net in ro_ns_desc["nets"]: |
| 1012 | if net["status"] != "ACTIVE": |
| 1013 | net["status"] = "ACTIVE" |
| 1014 | break |
| 1015 | else: |
| 1016 | for vnf in ro_ns_desc["vnfs"]: |
| 1017 | for vm in vnf["vms"]: |
| 1018 | if vm["status"] != "ACTIVE": |
| 1019 | vm["status"] = "ACTIVE" |
| 1020 | break |
| 1021 | |
| 1022 | def _ro_create(self, *args, **kwargs): |
| 1023 | while True: |
| 1024 | yield {"uuid": str(uuid4())} |
| 1025 | |
| 1026 | def _return_uuid(self, *args, **kwargs): |
| 1027 | return str(uuid4()) |
| 1028 | |
| 1029 | async def setUp(self): |
| 1030 | # Mock DB |
| 1031 | if not getenv("OSMLCMTEST_DB_NOMOCK"): |
| 1032 | self.db = asynctest.Mock(DbMongo()) |
| 1033 | self.db.get_one.side_effect = self._db_get_one |
| 1034 | self.db.get_list.side_effect = self._db_get_list |
| 1035 | self.db.set_one.side_effect = self._db_set_one |
| 1036 | self.db_content = { |
| 1037 | "nsrs": yaml.load(db_nsrs_text), |
| 1038 | "nslcmops": yaml.load(db_nslcmops_text), |
| 1039 | "vnfrs": yaml.load(db_vnfrs_text), |
| 1040 | "vnfds": yaml.load(db_vnfds_text), |
| 1041 | "vim_accounts": yaml.load(db_vim_accounts_text), |
| 1042 | } |
| 1043 | self.db_vim_accounts = yaml.load(db_vim_accounts_text) |
| 1044 | |
| 1045 | # Mock kafka |
| 1046 | self.msg = asynctest.Mock(MsgKafka()) |
| 1047 | |
| 1048 | # Mock filesystem |
| 1049 | if not getenv("OSMLCMTEST_FS_NOMOCK"): |
| 1050 | self.fs = asynctest.Mock(FsLocal()) |
| 1051 | self.fs.get_params.return_value = {"path": getenv("OSMLCMTEST_PACKAGES_PATH", "./test/temp/packages")} |
| 1052 | self.fs.file_open = asynctest.mock_open() |
| 1053 | # self.fs.file_open.return_value.__enter__.return_value = asynctest.MagicMock() # called on a python "with" |
| 1054 | # self.fs.file_open.return_value.__enter__.return_value.read.return_value = "" # empty file |
| 1055 | |
| 1056 | # Mock TaskRegistry |
| 1057 | self.lcm_tasks = asynctest.Mock(TaskRegistry()) |
| 1058 | self.lcm_tasks.lock_HA.return_value = True |
| 1059 | self.lcm_tasks.waitfor_related_HA.return_value = None |
| 1060 | self.lcm_tasks.lookfor_related.return_value = ("", []) |
| 1061 | |
| 1062 | # Create NsLCM class |
| 1063 | self.my_ns = NsLcm(self.db, self.msg, self.fs, self.lcm_tasks, ro_config, vca_config, self.loop) |
| 1064 | |
| 1065 | # Mock logging |
| 1066 | if not getenv("OSMLCMTEST_LOGGING_NOMOCK"): |
| 1067 | self.my_ns.logger = asynctest.Mock(self.my_ns.logger) |
| 1068 | |
| 1069 | # Mock VCA - N2VC |
| 1070 | if not getenv("OSMLCMTEST_VCA_NOMOCK"): |
| 1071 | pub_key = getenv("OSMLCMTEST_NS_PUBKEY", "ssh-rsa test-pub-key t@osm.com") |
| 1072 | self.my_ns.n2vc = asynctest.Mock(N2VC()) |
| 1073 | self.my_ns.n2vc.GetPublicKey.return_value = getenv("OSMLCM_VCA_PUBKEY", "public_key") |
| 1074 | # allow several versions of n2vc |
| 1075 | self.my_ns.n2vc.FormatApplicationName = asynctest.Mock(side_effect=self._n2vc_FormatApplicationName()) |
| 1076 | self.my_ns.n2vc.DeployCharms = asynctest.CoroutineMock(side_effect=self._n2vc_DeployCharms) |
| tierno | 73d8bd0 | 2019-11-18 17:33:27 +0000 | [diff] [blame^] | 1077 | self.my_ns.n2vc.create_execution_environment = asynctest.CoroutineMock( |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 1078 | side_effect=self._n2vc_CreateExecutionEnvironment) |
| tierno | 73d8bd0 | 2019-11-18 17:33:27 +0000 | [diff] [blame^] | 1079 | self.my_ns.n2vc.install_configuration_sw = asynctest.CoroutineMock(return_value=pub_key) |
| 1080 | self.my_ns.n2vc.get_ee_ssh_public__key = asynctest.CoroutineMock(return_value=pub_key) |
| 1081 | self.my_ns.n2vc.exec_primitive = asynctest.CoroutineMock(side_effect=self._return_uuid) |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 1082 | self.my_ns.n2vc.GetPrimitiveStatus = asynctest.CoroutineMock(return_value="completed") |
| 1083 | self.my_ns.n2vc.GetPrimitiveOutput = asynctest.CoroutineMock(return_value={"result": "ok", |
| 1084 | "pubkey": pub_key}) |
| tierno | 73d8bd0 | 2019-11-18 17:33:27 +0000 | [diff] [blame^] | 1085 | self.my_ns.n2vc.get_public_key = asynctest.CoroutineMock( |
| 1086 | return_value=getenv("OSMLCM_VCA_PUBKEY", "public_key")) |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 1087 | |
| 1088 | # Mock RO |
| 1089 | if not getenv("OSMLCMTEST_RO_NOMOCK"): |
| 1090 | # self.my_ns.RO = asynctest.Mock(ROclient.ROClient(self.loop, **ro_config)) |
| 1091 | # TODO first time should be empty list, following should return a dict |
| 1092 | self.my_ns.RO.get_list = asynctest.CoroutineMock(self.my_ns.RO.get_list, return_value=[]) |
| 1093 | self.my_ns.RO.create = asynctest.CoroutineMock(self.my_ns.RO.create, side_effect=self._ro_create()) |
| 1094 | self.my_ns.RO.show = asynctest.CoroutineMock(self.my_ns.RO.show, side_effect=self._ro_show()) |
| tierno | d832304 | 2019-08-09 11:32:23 +0000 | [diff] [blame] | 1095 | self.my_ns.RO.create_action = asynctest.CoroutineMock(self.my_ns.RO.create_action, |
| 1096 | return_value={"vm-id": {"vim_result": 200, |
| 1097 | "description": "done"}}) |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 1098 | |
| 1099 | @asynctest.fail_on(active_handles=True) # all async tasks must be completed |
| 1100 | async def test_instantiate(self): |
| 1101 | nsr_id = self.db_content["nsrs"][0]["_id"] |
| 1102 | nslcmop_id = self.db_content["nslcmops"][0]["_id"] |
| 1103 | print("Test instantiate started") |
| 1104 | |
| 1105 | # delete deployed information of database |
| 1106 | if not getenv("OSMLCMTEST_DB_NOMOCK"): |
| 1107 | if self.db_content["nsrs"][0]["_admin"].get("deployed"): |
| 1108 | del self.db_content["nsrs"][0]["_admin"]["deployed"] |
| 1109 | for db_vnfr in self.db_content["vnfrs"]: |
| 1110 | db_vnfr.pop("ip_address", None) |
| 1111 | for db_vdur in db_vnfr["vdur"]: |
| 1112 | db_vdur.pop("ip_address", None) |
| 1113 | db_vdur.pop("mac_address", None) |
| tierno | e64f7fb | 2019-09-11 08:55:52 +0000 | [diff] [blame] | 1114 | if getenv("OSMLCMTEST_RO_VIMID"): |
| 1115 | self.db_content["vim_accounts"][0]["_admin"]["deployed"]["RO"] = getenv("OSMLCMTEST_RO_VIMID") |
| 1116 | if getenv("OSMLCMTEST_RO_VIMID"): |
| 1117 | self.db_content["nsrs"][0]["_admin"]["deployed"]["RO"] = getenv("OSMLCMTEST_RO_VIMID") |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 1118 | |
| 1119 | await self.my_ns.instantiate(nsr_id, nslcmop_id) |
| 1120 | |
| 1121 | print("instantiate_result: {}".format(self._db_get_one("nslcmops", {"_id": nslcmop_id}).get("detailed-status"))) |
| 1122 | |
| 1123 | self.msg.aiowrite.assert_called_once_with("ns", "instantiated", |
| 1124 | {"nsr_id": nsr_id, "nslcmop_id": nslcmop_id, |
| 1125 | "operationState": "COMPLETED"}, |
| 1126 | loop=self.loop) |
| 1127 | self.lcm_tasks.lock_HA.assert_called_once_with('ns', 'nslcmops', nslcmop_id) |
| 1128 | if not getenv("OSMLCMTEST_LOGGING_NOMOCK"): |
| 1129 | self.assertTrue(self.my_ns.logger.debug.called, "Debug method not called") |
| 1130 | self.my_ns.logger.error.assert_not_called() |
| 1131 | self.my_ns.logger.exception().assert_not_called() |
| 1132 | |
| 1133 | if not getenv("OSMLCMTEST_DB_NOMOCK"): |
| 1134 | self.assertTrue(self.db.set_one.called, "db.set_one not called") |
| 1135 | |
| 1136 | # TODO add more checks of called methods |
| 1137 | # TODO add a terminate |
| 1138 | |
| tierno | 6cf25f5 | 2019-09-12 09:33:40 +0000 | [diff] [blame] | 1139 | def test_ns_params_2_RO(self): |
| 1140 | vim = self._db_get_list("vim_accounts")[0] |
| 1141 | vim_id = vim["_id"] |
| 1142 | ro_vim_id = vim["_admin"]["deployed"]["RO"] |
| 1143 | ns_params = {"vimAccountId": vim_id} |
| 1144 | mgmt_interface = {"cp": "cp"} |
| 1145 | vdu = [{"id": "vdu_id", "interface": [{"external-connection-point-ref": "cp"}]}] |
| 1146 | vnfd_dict = { |
| 1147 | "1": {"vdu": vdu, "mgmt-interface": mgmt_interface}, |
| 1148 | "2": {"vdu": vdu, "mgmt-interface": mgmt_interface, "vnf-configuration": None}, |
| 1149 | "3": {"vdu": vdu, "mgmt-interface": mgmt_interface, "vnf-configuration": {"config-access": None}}, |
| 1150 | "4": {"vdu": vdu, "mgmt-interface": mgmt_interface, |
| 1151 | "vnf-configuration": {"config-access": {"ssh-access": None}}}, |
| 1152 | "5": {"vdu": vdu, "mgmt-interface": mgmt_interface, |
| 1153 | "vnf-configuration": {"config-access": {"ssh-access": {"required": True, "default_user": "U"}}}}, |
| 1154 | } |
| 1155 | nsd = {"constituent-vnfd": []} |
| 1156 | for k in vnfd_dict.keys(): |
| 1157 | nsd["constituent-vnfd"].append({"vnfd-id-ref": k, "member-vnf-index": k}) |
| 1158 | |
| 1159 | n2vc_key_list = ["key"] |
| 1160 | ro_ns_params = self.my_ns.ns_params_2_RO(ns_params, nsd, vnfd_dict, n2vc_key_list) |
| 1161 | ro_params_expected = {'wim_account': None, "datacenter": ro_vim_id, |
| 1162 | "vnfs": {"5": {"vdus": {"vdu_id": {"mgmt_keys": n2vc_key_list}}}}} |
| 1163 | self.assertEqual(ro_ns_params, ro_params_expected) |
| 1164 | |
| tierno | 51d065c | 2019-08-26 16:48:23 +0000 | [diff] [blame] | 1165 | @asynctest.fail_on(active_handles=True) # all async tasks must be completed |
| 1166 | async def test_scale(self): |
| 1167 | pass |
| 1168 | |
| 1169 | |
| 1170 | if __name__ == '__main__': |
| 1171 | asynctest.main() |