update vfc sfc version
[integration.git] / test / vcpe / vcpe.py
index 26f27fb..f9c1778 100755 (executable)
@@ -2,6 +2,7 @@
 import sys
 import logging
 from vcpecommon import *
+import sdcutils
 import soutils
 from datetime import datetime
 import preload
@@ -28,11 +29,15 @@ def config_sniro(vcpecommon, vgmux_svc_instance_uuid, vbrg_svc_instance_uuid):
     brg_ar_name = None
     vgw_name = None
     for model in parser.vnf_models:
-        if 'tunnel' in model['modelCustomizationName']:
+        logger.info('modelCustomizationName = %s', model['modelCustomizationName'])
+        if 'tunnel' in model['modelCustomizationName'].lower():
+            logger.info('tunnel is in %s', model['modelCustomizationName'])
             tunnelxconn_ar_name = model['modelCustomizationName']
-        elif 'brg' in model['modelCustomizationName']:
+        elif 'brg' in model['modelCustomizationName'].lower():
+            logger.info('brg is in %s', model['modelCustomizationName'])
             brg_ar_name = model['modelCustomizationName']
-        elif 'vgw' in model['modelCustomizationName']:
+        #elif 'vgw' in model['modelCustomizationName']:
+        else:
             vgw_name = model['modelCustomizationName']
 
     if not (tunnelxconn_ar_name and brg_ar_name and vgw_name):
@@ -142,8 +147,9 @@ def deploy_custom_service():
     # create new service
     csar_file = vcpecommon.find_file('rescust', 'csar', 'csar')
     vgw_template_file = vcpecommon.find_file('vgw', 'json', 'preload_templates')
+    vgw_gra_template_file = vcpecommon.find_file('gwgra', 'json', 'preload_templates')
     preload_dict = vcpecommon.load_preload_data()
-    custom_service.create_custom_service(csar_file, vgw_template_file, preload_dict)
+    custom_service.create_custom_service(csar_file, vgw_template_file, vgw_gra_template_file, preload_dict)
 
 
 def closed_loop(lossrate=0):
@@ -158,7 +164,7 @@ def closed_loop(lossrate=0):
     time.sleep(2)
     vcpecommon.del_vgmux_ves_collector()
 
-    logger.info('Staring vGMUX data reporting to DCAE')
+    logger.info('Starting vGMUX data reporting to DCAE')
     time.sleep(2)
     vcpecommon.set_vgmux_ves_collector()
 
@@ -173,8 +179,14 @@ def init_so_sdnc():
     logger = logging.getLogger('__name__')
     vcpecommon = VcpeCommon()
     config_sdnc_so.insert_customer_service_to_so(vcpecommon)
-    config_sdnc_so.insert_customer_service_to_sdnc(vcpecommon)
+    #config_sdnc_so.insert_customer_service_to_sdnc(vcpecommon)
+    vgw_vfmod_name_index=  0
+    vcpecommon.save_object(vgw_vfmod_name_index, vcpecommon.vgw_vfmod_name_index_file)
 
+def download_vcpe_service_templates():
+    vcpecommon = VcpeCommon()
+    sdc = sdcutils.SdcUtils(vcpecommon)
+    sdc.get_service_list()
 
 def tmp_sniro():
     logger = logging.getLogger(__name__)
@@ -185,14 +197,19 @@ def tmp_sniro():
     # Setting up SNIRO
     config_sniro(vcpecommon, svc_instance_uuid['gmux'], svc_instance_uuid['brg'])
 
+def test(): 
+    vcpecommon = VcpeCommon()
+    print("oom-k8s-04 public ip: %s" % (vcpecommon.get_vm_public_ip_by_nova('oom-k8s-04')))
+
 if __name__ == '__main__':
-    logging.basicConfig(level=logging.INFO, format='%(message)s')
+    logging.basicConfig(level=logging.DEBUG, format='%(message)s')
 
     print('----------------------------------------------------------------------------------------------------')
     print(' vcpe.py:            Brief info about this program')
 #    print(' vcpe.py sdc:        Onboard VNFs, design and distribute vCPE services (under development)')
     print(' vcpe.py init:       Add customer service data to SDNC and SO DBs.')
     print(' vcpe.py infra:      Deploy infrastructure, including DHCP, AAA, DNS, Web Server, vBNG, vGMUX, vBRG.')
+    print(' vcpe.py brg:        Deploy brg only (for testing after infra succeeds).')
     print(' vcpe.py customer:   Deploy customer service, including vGW and VxLANs')
     print(' vcpe.py loop:       Test closed loop control')
     print('----------------------------------------------------------------------------------------------------')
@@ -205,6 +222,7 @@ if __name__ == '__main__':
     elif sys.argv[1] == 'init':
         if 'y' == raw_input('Ready to add customer service data to SDNC and SO DBs? This is needed only once.'
                             'y/n: ').lower():
+            download_vcpe_service_templates()
             init_so_sdnc()
     elif sys.argv[1] == 'infra':
         if 'y' == raw_input('Ready to deploy infrastructure? y/n: ').lower():
@@ -218,4 +236,8 @@ if __name__ == '__main__':
         closed_loop(0)
     elif sys.argv[1] == 'brg':
         deploy_brg_only()
+    elif sys.argv[1] == 'sniro':
+        tmp_sniro()
+    elif sys.argv[1] == 'test':
+        test()