1 # Copyright ETSI Contributors and Others.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 import osmclient
.common
.utils
as utils
19 SOL004_TOSCA
= "SOL004_TOSCA"
21 SOL007_TOSCA
= "SOL007_TOSCA"
26 def get_package_type(package_folder
):
28 Detects the package's structure and returns the type:
34 package_files
= os
.listdir(package_folder
)
35 if "Definitions" in package_files
and "TOSCA-Metadata" in package_files
:
38 for definition
in os
.listdir(package_folder
+ "/Definitions")
39 if definition
.endswith(".yaml") or definition
.endswith(".yml")
41 if len(descriptors
) < 1:
43 "No descriptor found on this package, OSM was expecting at least 1"
45 pkg_type
= utils
.get_key_val_from_pkg(descriptors
[0])
51 manifests
= [afile
for afile
in package_files
if afile
.endswith(".mf")]
52 if len(manifests
) < 1:
53 # No manifest found, probably old OSM package structure
58 for definition
in package_files
59 if definition
.endswith(".yaml") or definition
.endswith(".yml")
61 if len(descriptors
) < 1:
63 "No descriptor found on this package, OSM was expecting at least 1"
65 with
open(os
.path
.join(package_folder
, descriptors
[0])) as descriptor
:
66 pkg_type
= utils
.get_key_val_from_descriptor(descriptor
)
67 if pkg_type
["type"] == "nsd":