Insert vcpe customer service workflow into SO catalogdb 59/98759/4
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Fri, 22 Nov 2019 14:02:21 +0000 (15:02 +0100)
committerMorgan Richomme <morgan.richomme@orange.com>
Fri, 6 Dec 2019 10:22:10 +0000 (10:22 +0000)
Customer service workflow entry will be automatically
inserted into catalogdb database if running with
oom_mode set to True.

So database endpoint properties were updated to
reflect current catalogdb location.

vCPE doc updated to reflect the changes made.

Change-Id: I54ef0bf94ccf2d38501c1b854cafe4d388a4b35d
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Issue-ID: TEST-205

docs/docs_vCPE.rst
test/vcpe/config_sdnc_so.py
test/vcpe/vcpe.py
test/vcpe/vcpecommon.py

index f3a2be1..12320d9 100644 (file)
@@ -77,11 +77,7 @@ Here are the main steps to run the use case in Integration lab environment, wher
    
    vcpe.py init
 
-6. Run a command from Rancher node to insert vcpe customer service workflow entry in SO catalogdb. You should be able to see a sql command printed out from the above step output at the end, and use that sql command to replace the sample sql command below (inside the double quote) and run it from Rancher node:
-
-::
-
-   kubectl exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword catalogdb -e "INSERT INTO service_recipe (ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, SERVICE_PARAM_XSD, RECIPE_TIMEOUT, SERVICE_TIMEOUT_INTERIM, CREATION_TIMESTAMP, SERVICE_MODEL_UUID) VALUES ('createInstance','1','vCPEResCust 2019-06-03 _04ba','/mso/async/services/CreateVcpeResCustService',NULL,181,NULL, NOW(),'6c4a469d-ca2c-4b02-8cf1-bd02e9c5a7ce')"
+6. If running with oom_mode=False run a command printed at the end of the above step from k8s control node to insert vcpe customer service workflow entry in SO catalogdb. It will be done automatically otherwise.
 
 7. Run Robot to create and distribute for vCPE customer service. This step assumes step 1 has successfully distributed all vcpe models except customer service model
 
index b19c93a..375c7aa 100755 (executable)
@@ -68,19 +68,24 @@ def insert_customer_service_to_sdnc(vcpecommon):
 def insert_customer_service_to_so(vcpecommon):
     logger = logging.getLogger(__name__)
     cmds = []
-    if True:
-        csar_file = vcpecommon.find_file('rescust', 'csar', 'csar')
-        parser = csar_parser.CsarParser()
-        parser.parse_csar(csar_file)
-        cmds.append("INSERT INTO service_recipe (ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, " \
-                    "SERVICE_PARAM_XSD, RECIPE_TIMEOUT, SERVICE_TIMEOUT_INTERIM, CREATION_TIMESTAMP, " \
-                    "SERVICE_MODEL_UUID) VALUES ('createInstance','1','{0}'," \
-                    "'/mso/async/services/CreateVcpeResCustService',NULL,181,NULL, NOW()," \
-                    "'{1}');".format(parser.svc_model['modelName'], parser.svc_model['modelVersionId']))
-        logger.info(
-            'Please manually run the following sql command in SO catalogdb database to insert customer service recipe')
-        logger.info('\n'.join(cmds))
-        #vcpecommon.execute_cmds_so_db(cmds)
+    csar_file = vcpecommon.find_file('rescust', 'csar', 'csar')
+    parser = csar_parser.CsarParser()
+    parser.parse_csar(csar_file)
+    cmds.append("INSERT IGNORE INTO service_recipe (ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, " \
+                "SERVICE_PARAM_XSD, RECIPE_TIMEOUT, SERVICE_TIMEOUT_INTERIM, CREATION_TIMESTAMP, " \
+                "SERVICE_MODEL_UUID) VALUES ('createInstance','1','{0}'," \
+                "'/mso/async/services/CreateVcpeResCustService',NULL,181,NULL, NOW()," \
+                "'{1}');".format(parser.svc_model['modelName'], parser.svc_model['modelVersionId']))
+    if vcpecommon.oom_mode:
+        logger.info('Inserting vcpe customer service workflow entry into SO catalogdb')
+        vcpecommon.execute_cmds_so_db(cmds)
+    else:
+        logger.info('\n\nManually run a command from Rancher node to insert vcpe'
+                    'customer service workflow entry in SO catalogdb:\n'
+                    '\nkubectl -n {0} exec {1}-mariadb-galera-mariadb-galera-0'
+                    ' -- mysql -uroot -psecretpassword catalogdb -e '
+                    '"'.format(vcpecommon.onap_namespace,
+                    vcpecommon.onap_environment) + '\n'.join(cmds) + '"')
 
 def insert_sdnc_ip_pool(vcpecommon):
     logger = logging.getLogger(__name__)
index 2b167a2..c58b60a 100755 (executable)
@@ -215,7 +215,7 @@ def closed_loop(lossrate=0):
 def init_so_sdnc():
     logger = logging.getLogger('__name__')
     vcpecommon = VcpeCommon()
-    #config_sdnc_so.insert_sdnc_ip_pool(vcpecommon)
+    config_sdnc_so.insert_sdnc_ip_pool(vcpecommon)
     config_sdnc_so.insert_customer_service_to_so(vcpecommon)
     #config_sdnc_so.insert_customer_service_to_sdnc(vcpecommon)
     vgw_vfmod_name_index=  0
index ddbce4b..ffc6334 100755 (executable)
@@ -190,6 +190,11 @@ class VcpeCommon:
         self.sdnc_ar_cleanup_url = 'https://' + self.hosts['sdnc'] + ':' + self.sdnc_preloading_port + \
                                    '/restconf/config/GENERIC-RESOURCE-API:'
 
+        #############################################################################################
+        # MARIADB-GALERA settings
+        self.mariadb_galera_endpoint_ip = self.get_k8s_service_endpoint_info('mariadb-galera','ip')
+        self.mariadb_galera_endpoint_port = self.get_k8s_service_endpoint_info('mariadb-galera','port')
+
         #############################################################################################
         # SO urls, note: do NOT add a '/' at the end of the url
         self.so_req_api_url = {'v4': 'http://' + self.hosts['so'] + ':' + self.so_nbi_port + '/onap/so/infra/serviceInstantiation/v7/serviceInstances',
@@ -200,7 +205,8 @@ class VcpeCommon:
         self.so_db_name = 'catalogdb'
         self.so_db_user = 'root'
         self.so_db_pass = 'secretpassword'
-        self.so_db_port = '30252' if self.oom_mode else '32769'
+        self.so_db_host = self.mariadb_galera_endpoint_ip if self.oom_mode else self.hosts['so']
+        self.so_db_port = self.mariadb_galera_endpoint_port if self.oom_mode else '3306'
 
         self.vpp_inf_url = 'http://{0}:8183/restconf/config/ietf-interfaces:interfaces'
         self.vpp_api_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
@@ -218,11 +224,6 @@ class VcpeCommon:
         self.policy_api_service_name = 'policy-api'
         self.policy_pap_service_name = 'policy-pap'
 
-        #############################################################################################
-        # MARIADB-GALERA settings
-        self.mariadb_galera_endpoint_ip = self.get_k8s_service_endpoint_info('mariadb-galera','ip')
-        self.mariadb_galera_endpoint_port = self.get_k8s_service_endpoint_info('mariadb-galera','port')
-
         #############################################################################################
         # AAI urls
         self.aai_region_query_url = 'https://' + self.oom_so_sdnc_aai_ip + ':' +\
@@ -299,7 +300,7 @@ class VcpeCommon:
 
     def execute_cmds_so_db(self, cmds):
         self.execute_cmds_db(cmds, self.so_db_user, self.so_db_pass, self.so_db_name,
-                             self.hosts['so'], self.so_db_port)
+                             self.so_db_host, self.so_db_port)
 
     def execute_cmds_db(self, cmds, dbuser, dbpass, dbname, host, port):
         cnx = mysql.connector.connect(user=dbuser, password=dbpass, database=dbname, host=host, port=port)