aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py
blob: 6537b1cdd0f411ec6f3fa38fc900b0c7292a6e73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import json

from sdcBePy.tosca.models.normativeTypeCandidate import NormativeTypeCandidate


class TypesToUpdate:

    def __init__(self, files):
        self.types_list = {}
        self.load_files(files)

    def load_files(self, files):
        for file in files:
            with open(file, 'r') as stream:
                _types = json.load(stream)
                for type_key, type_value in _types.items():
                    self.types_list[type_key] = type_value

    def get_type(self, key):
        return self.types_list[key]


def get_heat_and_normative_to_update_list(types, base_file_location):
    return [
        get_heat(types, base_file_location),
        get_normative(types, base_file_location)
    ]


def get_onap_sol_to_update_list(types, base_file_location):
    return [
        get_onap(types, base_file_location),
        get_sol(types, base_file_location)
    ]

def get_nfv_to_update_list(types, base_file_location):
    return [
        get_nfv(types, base_file_location),
        get_nfv_2_7_1(types, base_file_location),
        get_nfv_3_3_1(types, base_file_location),
        get_nfv_4_1_1(types, base_file_location),
    ]


def get_heat(types, base_location="/"):
    return NormativeTypeCandidate(base_location + "heat-types/",
                                  types.get_type("heat"))


def get_normative(types, base_location="/"):
    return NormativeTypeCandidate(base_location + "normative-types/",
                                  types.get_type("normative"))


def get_nfv(types, base_location="/"):
    return NormativeTypeCandidate(base_location + "nfv-types/",
                                  types.get_type("nfv"))
                                  
def get_nfv_2_7_1(types, base_location="/"):
    return NormativeTypeCandidate(base_location + "nfv-types/2.7.1/",
                                  types.get_type("nfv_2_7_1"))

def get_nfv_3_3_1(types, base_location="/"):
    return NormativeTypeCandidate(base_location + "nfv-types/3.3.1/",
                                  types.get_type("nfv_3_3_1"))

def get_nfv_4_1_1(types, base_location="/"):
    return NormativeTypeCandidate(base_location + "nfv-types/4.1.1/",
                                  types.get_type("nfv_4_1_1"))

def get_onap(types, base_location="/"):
    return NormativeTypeCandidate(base_location + "onap-types/",
                                  types.get_type("onap"))


def get_sol(types, base_location="/"):
    return NormativeTypeCandidate(base_location + "sol-types/",
                                  types.get_type("sol"))