summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts/sdcBePy/tosca/run.py
blob: 955acff9301b0eb7722841ba73b26fccd92170d9 (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
import json

from sdcBePy import properties
from sdcBePy.common.logger import print_and_exit

from sdcBePy.tosca.imports.run import main as import_main
from sdcBePy.tosca.main import parse_and_create_proxy
from sdcBePy.tosca.upgrade.run import main as upgrade_main


def run():
    sdc_be_proxy, update_version = parse_and_create_proxy()

    response = sdc_be_proxy.get_normatives()

    resources = []
    if response == 200:
        resources = json.loads(sdc_be_proxy.get_response_from_buffer())["resources"]
    else:
        print_and_exit(response, "Can't get normatives!")

    if len(resources) < properties.resource_len:
        import_main(sdc_be_proxy, update_version)
    else:
        upgrade_main(sdc_be_proxy)


if __name__ == '__main__':
    run()