Fixes 1367 by preventing pyang discard repeated constituent-base-element-id
[osm/NBI.git] / osm_nbi / tests / test_pkg_descriptors.py
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 """Contains database content needed for tests"""
19
20 __author__ = "Pedro de la Cruz Ramos, pedro.delacruzramos@altran.com"
21 __date__ = "2019-11-20"
22
23 db_vnfds_text = """
24 ---
25 - _admin:
26 created: 1566823352.7154346
27 modified: 1566823352.7154346
28 onboardingState: ONBOARDED
29 operationalState: ENABLED
30 projects_read:
31 - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
32 projects_write:
33 - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
34 storage:
35 descriptor: hackfest_3charmed_vnfd/hackfest_3charmed_vnfd.yaml
36 folder: 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77
37 fs: local
38 path: /app/storage/
39 pkg-dir: hackfest_3charmed_vnfd
40 zipfile: package.tar.gz
41 type: vnfd
42 usageState: NOT_IN_USE
43 userDefinedData: {}
44 _id: 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77
45 id: hackfest3charmed-vnf
46 description: >-
47 A VNF consisting of 2 VDUs connected to an internal VL, and one VDU with
48 cloud-init
49 product-name: hackfest3charmed-vnf
50 version: '1.0'
51 mgmt-cp: vnf-mgmt-ext
52
53 virtual-compute-desc:
54 - id: mgmt-compute
55 virtual-cpu:
56 num-virtual-cpu: 2
57 virtual-memory:
58 size: '2'
59 - id: data-compute
60 virtual-cpu:
61 num-virtual-cpu: 2
62 virtual-memory:
63 size: '2'
64
65 virtual-storage-desc:
66 - id: mgmt-storage
67 size-of-storage: '20'
68 - id: data-storage
69 size-of-storage: '20'
70
71 sw-image-desc:
72 - id: hackfest3-mgmt
73 name: hackfest3-mgmt
74
75 vdu:
76 - id: mgmtVM
77 name: mgmtVM
78 cloud-init-file: cloud-config.txt
79 sw-image-desc: hackfest3-mgmt
80 virtual-compute-desc: mgmt-compute
81 virtual-storage-desc:
82 - mgmt-storage
83 int-cpd:
84 - id: vnf-mgmt
85 virtual-network-interface-requirement:
86 - name: mgmtVM-eth0
87 position: 1
88 virtual-interface:
89 type: VIRTIO
90 - id: mgmtVM-internal
91 int-virtual-link-desc: internal
92 virtual-network-interface-requirement:
93 - name: mgmtVM-eth1
94 position: 2
95 virtual-interface:
96 type: VIRTIO
97 - id: dataVM
98 name: dataVM
99 sw-image-desc: hackfest3-mgmt
100 virtual-compute-desc: data-compute
101 virtual-storage-desc:
102 - data-storage
103 int-cpd:
104 - id: dataVM-internal
105 int-virtual-link-desc: internal
106 virtual-network-interface-requirement:
107 - name: dataVM-eth1
108 position: 1
109 virtual-interface:
110 type: VIRTIO
111 - id: vnf-data
112 virtual-network-interface-requirement:
113 - name: dataVM-eth0
114 position: 2
115 virtual-interface:
116 type: VIRTIO
117 monitoring-parameter:
118 - id: dataVM_cpu_util
119 name: dataVM_cpu_util
120 performance-metric: cpu_utilization
121
122 int-virtual-link-desc:
123 - id: internal
124
125 ext-cpd:
126 - id: vnf-mgmt-ext
127 int-cpd: # Connection to int-cpd
128 vdu-id: mgmtVM
129 cpd: vnf-mgmt
130 - id: vnf-data-ext
131 int-cpd: # Connection to int-cpd
132 vdu-id: dataVM
133 cpd: vnf-data
134
135 df:
136 - id: hackfest_default
137 vnf-configuration-id: vnf-configuration-example
138 vdu-profile:
139 - id: mgmtVM
140 min-number-of-instances: 1
141 - id: dataVM
142 min-number-of-instances: 1
143 max-number-of-instances: 10
144 vdu-configuration-id: vdu-configuration-example
145 instantiation-level:
146 - id: default
147 vdu-level:
148 - vdu-id: mgmtVM
149 number-of-instances: 1
150 - vdu-id: dataVM
151 number-of-instances: 1
152 scaling-aspect:
153 - id: scale_dataVM
154 name: scale_dataVM
155 max-scale-level: 10
156 aspect-delta-details:
157 deltas:
158 - id: delta1
159 vdu-delta:
160 - id: vdudelta1
161 number-of-instances: 1
162 scaling-policy:
163 - name: auto_cpu_util_above_threshold
164 scaling-type: automatic
165 enabled: true
166 threshold-time: 0
167 cooldown-time: 60
168 scaling-criteria:
169 - name: cpu_util_above_threshold
170 scale-in-relational-operation: LE
171 scale-in-threshold: '15.0000000000'
172 scale-out-relational-operation: GE
173 scale-out-threshold: '60.0000000000'
174 vnf-monitoring-param-ref: dataVM_cpu_util
175 scaling-config-action:
176 - trigger: post-scale-out
177 vnf-config-primitive-name-ref: touch
178 - trigger: pre-scale-in
179 vnf-config-primitive-name-ref: touch
180
181 vnf-configuration:
182 - id: vnf-configuration-example
183 initial-config-primitive:
184 - seq: "1"
185 name: config
186 parameter:
187 - name: ssh-hostname
188 value: <rw_mgmt_ip>
189 - name: ssh-username
190 value: ubuntu
191 - name: ssh-password
192 value: osm4u
193 - seq: "2"
194 name: touch
195 parameter:
196 - name: filename
197 value: <touch_filename>
198 config-primitive:
199 - name: touch
200 parameter:
201 - data-type: STRING
202 default-value: <touch_filename2>
203 name: filename
204 juju:
205 charm: simple
206 """
207
208 db_nsds_text = """
209 ---
210 - _admin:
211 created: 1566823353.971486
212 modified: 1566823353.971486
213 onboardingState: ONBOARDED
214 operationalState: ENABLED
215 projects_read:
216 - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
217 projects_write:
218 - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
219 storage:
220 descriptor: hackfest_3charmed_nsd/hackfest_3charmed_nsd.yaml
221 folder: 8c2f8b95-bb1b-47ee-8001-36dc090678da
222 fs: local
223 path: /app/storage/
224 pkg-dir: hackfest_3charmed_nsd
225 zipfile: package.tar.gz
226 usageState: NOT_IN_USE
227 userDefinedData: {}
228 _id: 8c2f8b95-bb1b-47ee-8001-36dc090678da
229 id: hackfest3charmed-ns
230 name: hackfest3charmed-ns
231 description: NS with 2 VNFs hackfest3charmed-vnf connected by datanet and mgmtnet VLs
232 designer: OSM
233 version: '1.0'
234
235 vnfd-id:
236 - hackfest3charmed-vnf
237
238 virtual-link-desc:
239 - id: mgmt
240 mgmt-network: true
241 - id: datanet
242 mgmt-network: false
243
244 df:
245 - id: hackfest_charmed_DF
246 vnf-profile:
247 - id: hackfest_vnf1 # member-vnf-index-ref: 1
248 vnfd-id: hackfest3charmed-vnf
249 virtual-link-connectivity:
250 - virtual-link-profile-id: mgmt
251 constituent-cpd-id:
252 - constituent-base-element-id: hackfest_vnf1
253 constituent-cpd-id: vnf-mgmt-ext
254 - virtual-link-profile-id: datanet
255 constituent-cpd-id:
256 - constituent-base-element-id: hackfest_vnf1
257 constituent-cpd-id: vnf-data-ext
258 - id: hackfest_vnf2 # member-vnf-index-ref: 2
259 vnfd-id: hackfest3charmed-vnf
260 virtual-link-connectivity:
261 - virtual-link-profile-id: mgmt
262 constituent-cpd-id:
263 - constituent-base-element-id: hackfest_vnf2
264 constituent-cpd-id: vnf-mgmt-ext
265 - virtual-link-profile-id: datanet
266 constituent-cpd-id:
267 - constituent-base-element-id: hackfest_vnf2
268 constituent-cpd-id: vnf-data-ext
269 """