| Adam Israel | 6fd4622 | 2019-05-29 11:31:01 -0400 | [diff] [blame] | 1 | """ |
| 2 | Deploy a multi-vdu, multi-charm VNF |
| 3 | """ |
| 4 | |
| 5 | import asyncio |
| 6 | import logging |
| 7 | import pytest |
| 8 | from .. import base |
| 9 | |
| 10 | |
| 11 | # @pytest.mark.serial |
| 12 | class TestCharm(base.TestN2VC): |
| 13 | |
| 14 | NSD_YAML = """ |
| 15 | nsd:nsd-catalog: |
| 16 | nsd: |
| 17 | - id: hackfest-simplecharm-ns |
| 18 | name: hackfest-simplecharm-ns |
| 19 | short-name: hackfest-simplecharm-ns |
| 20 | description: NS with 2 VNFs hackfest-simplecharm-vnf connected by datanet and mgmtnet VLs |
| 21 | version: '1.0' |
| 22 | logo: osm.png |
| 23 | constituent-vnfd: |
| 24 | - vnfd-id-ref: hackfest-simplecharm-vnf |
| 25 | member-vnf-index: '1' |
| 26 | - vnfd-id-ref: hackfest-simplecharm-vnf |
| 27 | member-vnf-index: '2' |
| 28 | vld: |
| 29 | - id: mgmtnet |
| 30 | name: mgmtnet |
| 31 | short-name: mgmtnet |
| 32 | type: ELAN |
| 33 | mgmt-network: 'true' |
| 34 | vim-network-name: mgmt |
| 35 | vnfd-connection-point-ref: |
| 36 | - vnfd-id-ref: hackfest-simplecharm-vnf |
| 37 | member-vnf-index-ref: '1' |
| 38 | vnfd-connection-point-ref: vnf-mgmt |
| 39 | - vnfd-id-ref: hackfest-simplecharm-vnf |
| 40 | member-vnf-index-ref: '2' |
| 41 | vnfd-connection-point-ref: vnf-mgmt |
| 42 | - id: datanet |
| 43 | name: datanet |
| 44 | short-name: datanet |
| 45 | type: ELAN |
| 46 | vnfd-connection-point-ref: |
| 47 | - vnfd-id-ref: hackfest-simplecharm-vnf |
| 48 | member-vnf-index-ref: '1' |
| 49 | vnfd-connection-point-ref: vnf-data |
| 50 | - vnfd-id-ref: hackfest-simplecharm-vnf |
| 51 | member-vnf-index-ref: '2' |
| 52 | vnfd-connection-point-ref: vnf-data |
| 53 | """ |
| 54 | |
| 55 | VNFD_YAML = """ |
| 56 | vnfd:vnfd-catalog: |
| 57 | vnfd: |
| 58 | - id: hackfest-simplecharm-vnf |
| 59 | name: hackfest-simplecharm-vnf |
| 60 | short-name: hackfest-simplecharm-vnf |
| 61 | version: '1.0' |
| 62 | description: A VNF consisting of 2 VDUs connected to an internal VL, and one VDU with cloud-init |
| 63 | logo: osm.png |
| 64 | connection-point: |
| 65 | - id: vnf-mgmt |
| 66 | name: vnf-mgmt |
| 67 | short-name: vnf-mgmt |
| 68 | type: VPORT |
| 69 | - id: vnf-data |
| 70 | name: vnf-data |
| 71 | short-name: vnf-data |
| 72 | type: VPORT |
| 73 | mgmt-interface: |
| 74 | cp: vnf-mgmt |
| 75 | internal-vld: |
| 76 | - id: internal |
| 77 | name: internal |
| 78 | short-name: internal |
| 79 | type: ELAN |
| 80 | internal-connection-point: |
| 81 | - id-ref: mgmtVM-internal |
| 82 | - id-ref: dataVM-internal |
| 83 | vdu: |
| 84 | - id: mgmtVM |
| 85 | name: mgmtVM |
| 86 | image: hackfest3-mgmt |
| 87 | count: '1' |
| 88 | vm-flavor: |
| 89 | vcpu-count: '1' |
| 90 | memory-mb: '1024' |
| 91 | storage-gb: '10' |
| 92 | interface: |
| 93 | - name: mgmtVM-eth0 |
| 94 | position: '1' |
| 95 | type: EXTERNAL |
| 96 | virtual-interface: |
| 97 | type: PARAVIRT |
| 98 | external-connection-point-ref: vnf-mgmt |
| 99 | - name: mgmtVM-eth1 |
| 100 | position: '2' |
| 101 | type: INTERNAL |
| 102 | virtual-interface: |
| 103 | type: PARAVIRT |
| 104 | internal-connection-point-ref: mgmtVM-internal |
| 105 | internal-connection-point: |
| 106 | - id: mgmtVM-internal |
| 107 | name: mgmtVM-internal |
| 108 | short-name: mgmtVM-internal |
| 109 | type: VPORT |
| 110 | cloud-init-file: cloud-config.txt |
| 111 | - id: dataVM |
| 112 | name: dataVM |
| 113 | image: hackfest3-mgmt |
| 114 | count: '1' |
| 115 | vm-flavor: |
| 116 | vcpu-count: '1' |
| 117 | memory-mb: '1024' |
| 118 | storage-gb: '10' |
| 119 | interface: |
| 120 | - name: dataVM-eth0 |
| 121 | position: '1' |
| 122 | type: INTERNAL |
| 123 | virtual-interface: |
| 124 | type: PARAVIRT |
| 125 | internal-connection-point-ref: dataVM-internal |
| 126 | - name: dataVM-xe0 |
| 127 | position: '2' |
| 128 | type: EXTERNAL |
| 129 | virtual-interface: |
| 130 | type: PARAVIRT |
| 131 | external-connection-point-ref: vnf-data |
| 132 | internal-connection-point: |
| 133 | - id: dataVM-internal |
| 134 | name: dataVM-internal |
| 135 | short-name: dataVM-internal |
| 136 | type: VPORT |
| 137 | vnf-configuration: |
| 138 | juju: |
| 139 | charm: simple |
| 140 | initial-config-primitive: |
| 141 | - seq: '1' |
| 142 | name: config |
| 143 | parameter: |
| 144 | - name: ssh-hostname |
| 145 | value: <rw_mgmt_ip> |
| 146 | - name: ssh-username |
| 147 | value: ubuntu |
| 148 | - name: ssh-password |
| 149 | value: osm4u |
| 150 | - seq: '2' |
| 151 | name: touch |
| 152 | parameter: |
| 153 | - name: filename |
| 154 | value: '/home/ubuntu/first-touch' |
| 155 | config-primitive: |
| 156 | - name: touch |
| 157 | parameter: |
| 158 | - name: filename |
| 159 | data-type: STRING |
| 160 | default-value: '/home/ubuntu/touched' |
| 161 | """ |
| 162 | |
| 163 | # @pytest.mark.serial |
| 164 | @pytest.mark.asyncio |
| 165 | async def test_multivdu_multicharm(self, event_loop): |
| 166 | """Deploy and execute the initial-config-primitive of a VNF.""" |
| 167 | |
| 168 | if self.nsd and self.vnfd: |
| 169 | vnf_index = 0 |
| 170 | |
| 171 | for config in self.get_config(): |
| 172 | juju = config['juju'] |
| 173 | charm = juju['charm'] |
| 174 | |
| 175 | await self.deploy( |
| 176 | vnf_index, |
| 177 | charm, |
| 178 | config, |
| 179 | event_loop, |
| 180 | ) |
| 181 | vnf_index += 1 |
| 182 | |
| 183 | while await self.running(): |
| 184 | logging.debug("Waiting for test to finish...") |
| 185 | await asyncio.sleep(15) |
| 186 | # assert False |
| 187 | logging.debug("test_multivdu_multicharm stopped") |
| 188 | |
| 189 | return 'ok' |