From 1f7c57414533b9886962ede7b19a29669fe7a59a Mon Sep 17 00:00:00 2001 From: mojahidi Date: Fri, 1 Mar 2019 17:50:15 +0530 Subject: Requirement and capabilities feature 1. Enhance Service/VF/PNF to support Req & Cap 2. Added Type fetch APIs to fetch types from global types Change-Id: I2b749ec9da34e488421b8ebe311ccf03c4b7c0fd Issue-ID: SDC-2142 Signed-off-by: mojahidi --- .../scripts/import/tosca/importNormativeAll.py | 4 ++ .../import/tosca/importNormativeRelationships.py | 83 ++++++++++++++++++++++ .../scripts/import/tosca/importONAPNormativeAll.py | 8 ++- .../scripts/import/tosca/upgradeNormative.py | 4 ++ .../scripts/import/tosca/upgradeONAPNormative.py | 4 ++ 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py (limited to 'catalog-be/src/main/resources/scripts/import') diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeAll.py b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeAll.py index 8a8329027f..19ffc1762f 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeAll.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeAll.py @@ -8,6 +8,7 @@ from importNormativeElements import * from importNormativeTypes import importNormativeTypes from importHeatTypes import importHeatTypes from importNormativeCapabilities import importNormativeCapabilities +from importNormativeRelationships import importNormativeRelationships from importCategoryTypes import importCategories from importNormativeInterfaceLifecycleTypes import importNormativeInterfaceLifecycleType from importDataTypes import importDataTypes @@ -116,6 +117,9 @@ def main(argv): fileLocation = baseFileLocation + "capability-types/" importNormativeCapabilities(scheme, beHost, bePort, adminUser, False, fileLocation) + fileLocation = baseFileLocation + "relationship-types/" + importNormativeRelationships(scheme, beHost, bePort, adminUser, False, fileLocation) + fileLocation = baseFileLocation + "interface-lifecycle-types/" importNormativeInterfaceLifecycleType(scheme, beHost, bePort, adminUser, False, fileLocation) diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py new file mode 100644 index 0000000000..a86e520558 --- /dev/null +++ b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeRelationships.py @@ -0,0 +1,83 @@ +import pycurl +import sys, getopt +from StringIO import StringIO +import json +import copy +from importNormativeElements import createNormativeElement +from importCommon import * +import importCommon + +################################################################################################################################################################################################# +# # +# Import normative relationships +# # +# # +# activation : # +# python importNormativeRelationships.py [-s | --scheme= ] [-i | --ip=] [-p +# | --port= ] [-f | --ifile= ] # +# # +# shortest activation (be host = localhost, be port = 8080): # +# python importNormativeRelationships.py [-f | --ifile= ] +# # +# # +################################################################################################################################################################################################# + + +def usage(): + print sys.argv[0], '[optional -s | --scheme=, default http] [-i | --ip=] [-p | --port= ] [-u | --user= ]' + + +def importNormativeRelationships(scheme, beHost, bePort, adminUser, exitOnSuccess, fileDir): + result = createNormativeElement(scheme, beHost, bePort, adminUser, fileDir, "/sdc2/rest/v1/catalog/uploadType/relationship", "relationshipTypes", "relationshipTypeZip") + + print_frame_line() + print_name_and_return_code(result[0], result[1]) + print_frame_line() + + if ( result[1] == None or result[1] not in [200, 201, 409] ): + importCommon.error_and_exit(1, None) + else: + if (exitOnSuccess == True): + importCommon.error_and_exit(0, None) + + +def main(argv): + print 'Number of arguments:', len(sys.argv), 'arguments.' + + beHost = 'localhost' + bePort = '8080' + adminUser = 'jh0003' + scheme = 'http' + + try: + opts, args = getopt.getopt(argv,"i:p:u:h:s:",["ip=","port=","user=","scheme="]) + except getopt.GetoptError: + usage() + importCommon.error_and_exit(2, 'Invalid input') + + for opt, arg in opts: + #print opt, arg + if opt == '-h': + usage() + sys.exit(3) + elif opt in ("-i", "--ip"): + beHost = arg + elif opt in ("-p", "--port"): + bePort = arg + elif opt in ("-u", "--user"): + adminUser = arg + elif opt in ("-s", "--scheme"): + scheme = arg + + print 'scheme =',scheme,', be host =',beHost,', be port =', bePort,', user =', adminUser + + if ( beHost == None ): + usage() + sys.exit(3) + + importNormativeRelationships(scheme, beHost, bePort, adminUser, True, "../../../import/tosca/relationship-types/") + + +if __name__ == "__main__": + main(sys.argv[1:]) + diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py b/catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py index ef1fe4d3b9..30b5a5435d 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/importONAPNormativeAll.py @@ -12,6 +12,7 @@ from importNfvTypes import importNfvTypes from importOnapTypes import importOnapTypes from importSolTypes import importSolTypes from importNormativeCapabilities import importNormativeCapabilities +from importNormativeRelationships import importNormativeRelationships from importCategoryTypes import importCategories from importNormativeInterfaceLifecycleTypes import importNormativeInterfaceLifecycleType from importDataTypes import importDataTypes @@ -111,12 +112,15 @@ def main(argv): print 'sleep until data type cache is updated' time.sleep( 70 ) - + fileLocation = baseFileLocation + "capability-types/" importNormativeCapabilities(scheme, beHost, bePort, adminUser, False, fileLocation) + + fileLocation = baseFileLocation + "relationship-types/" + importNormativeRelationships(scheme, beHost, bePort, adminUser, False, fileLocation) fileLocation = baseFileLocation + "interface-lifecycle-types/" - importNormativeInterfaceLifecycleType(scheme, beHost, bePort, adminUser, False, fileLocation) + importNormativeInterfaceLifecycleType(scheme, beHost, bePort, adminUser, False, fileLocation) fileLocation = baseFileLocation + "categories/" importCategories(scheme, beHost, bePort, adminUser, False, fileLocation) diff --git a/catalog-be/src/main/resources/scripts/import/tosca/upgradeNormative.py b/catalog-be/src/main/resources/scripts/import/tosca/upgradeNormative.py index bbeb3d6972..36a5d1181a 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/upgradeNormative.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeNormative.py @@ -10,6 +10,7 @@ from importDataTypes import importDataTypes from importPolicyTypes import importPolicyTypes from importGroupTypes import importGroupTypes from importNormativeCapabilities import importNormativeCapabilities +from importNormativeRelationships import importNormativeRelationships from importNormativeInterfaceLifecycleTypes import importNormativeInterfaceLifecycleType from importAnnotationTypes import import_annotation_types @@ -96,6 +97,9 @@ def main(argv): fileLocation = baseFileLocation + "categories/" importCategories(scheme, beHost, bePort, adminUser, False, fileLocation) + fileLocation = baseFileLocation + "relationship-types/" + importNormativeRelationships(scheme, beHost, bePort, adminUser, False, fileLocation) + fileLocation = baseFileLocation + "data-types/" importDataTypes(scheme, beHost, bePort, adminUser, False, fileLocation) diff --git a/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py b/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py index bebba6c2cb..c6d217f986 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeONAPNormative.py @@ -10,6 +10,7 @@ from importDataTypes import importDataTypes from importPolicyTypes import importPolicyTypes from importGroupTypes import importGroupTypes from importNormativeCapabilities import importNormativeCapabilities +from importNormativeRelationships import importNormativeRelationships from importNormativeInterfaceLifecycleTypes import importNormativeInterfaceLifecycleType from upgradeNfvTypes import upgradeNfvTypesPerConfigFile from upgradeONAPTypes import upgradeOnapTypesPerConfigFile @@ -101,6 +102,9 @@ def main(argv): fileLocation = baseFileLocation + "categories/" importCategories(scheme, beHost, bePort, adminUser, False, fileLocation) + fileLocation = baseFileLocation + "relationship-types/" + importNormativeRelationships(scheme, beHost, bePort, adminUser, False, fileLocation) + fileLocation = baseFileLocation + "data-types/" importDataTypes(scheme, beHost, bePort, adminUser, False, fileLocation) -- cgit 1.2.3-korg