diff options
author | Yang Xu <yang.xu@futurewei.com> | 2019-06-26 01:50:15 -0400 |
---|---|---|
committer | Yang Xu <yang.xu@futurewei.com> | 2019-06-26 12:46:31 +0000 |
commit | 1b31a1d43b9be2938fde5639ab7aaea6262adc4f (patch) | |
tree | 9a4ac9b08801746e311a00c7673ac73c66036b9f /test/vcpe | |
parent | fdae148d303b3153e2dec38d830d3784491b6f65 (diff) |
Clean up vCPE script
Signed-off-by: Yang Xu <yang.xu@futurewei.com>
Issue-ID: INT-847
Change-Id: I1158442cd73c6e0d943e9cc111cb12dae1381d36
Diffstat (limited to 'test/vcpe')
-rwxr-xr-x | test/vcpe/bin/setup.sh | 1 | ||||
-rwxr-xr-x | test/vcpe/config_sdnc_so.py | 28 | ||||
-rwxr-xr-x | test/vcpe/healthcheck.py | 30 | ||||
-rwxr-xr-x | test/vcpe/preload.py | 1 | ||||
-rw-r--r-- | test/vcpe/preload_templates/operational.vcpe.json.txt | 4 | ||||
-rw-r--r-- | test/vcpe/preload_templates/operational.vcpe.pap.json.txt | 8 | ||||
-rwxr-xr-x | test/vcpe/vcpe.py | 13 | ||||
-rwxr-xr-x | test/vcpe/vcpecommon.py | 9 |
8 files changed, 23 insertions, 71 deletions
diff --git a/test/vcpe/bin/setup.sh b/test/vcpe/bin/setup.sh index a52e0222e..100190f05 100755 --- a/test/vcpe/bin/setup.sh +++ b/test/vcpe/bin/setup.sh @@ -16,5 +16,6 @@ pip install mysql-connector-python pip install progressbar2 pip install python-novaclient pip install python-openstackclient +pip install python-heatclient pip install netaddr pip install kubernetes diff --git a/test/vcpe/config_sdnc_so.py b/test/vcpe/config_sdnc_so.py index bce8fde81..e9d642ad1 100755 --- a/test/vcpe/config_sdnc_so.py +++ b/test/vcpe/config_sdnc_so.py @@ -66,8 +66,7 @@ def insert_customer_service_to_sdnc(vcpecommon): def insert_customer_service_to_so(vcpecommon): - logger = logging.getLogger('__name__') - logger.info('Inserting neutron HEAT template to SO DB and creating a recipe for customer service') + logger = logging.getLogger(__name__) cmds = [] if True: csar_file = vcpecommon.find_file('rescust', 'csar', 'csar') @@ -78,26 +77,7 @@ def insert_customer_service_to_so(vcpecommon): "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) - - cmds = [] - cmds.append("delete from `heat_template_params` where" - "`HEAT_TEMPLATE_ARTIFACT_UUID`='efee1d84-b8ec-11e7-abc4-cec278b6b50a';") - cmds.append("delete from `heat_template` where ARTIFACT_UUID='efee1d84-b8ec-11e7-abc4-cec278b6b50a';") - network_tempalte_file = vcpecommon.find_file('neutron', 'yaml', 'preload_templates') - with open(network_tempalte_file, 'r') as fin: - lines = fin.readlines() - longtext = '\n'.join(lines) - cmds.append("INSERT INTO `heat_template`(`ARTIFACT_UUID`, `NAME`, `VERSION`, `BODY`, `TIMEOUT_MINUTES`, " \ - "`DESCRIPTION`, `CREATION_TIMESTAMP`, `ARTIFACT_CHECKSUM`) VALUES(" \ - "'efee1d84-b8ec-11e7-abc4-cec278b6b50a', 'Generic NeutronNet', '1', '{0}', 10, " \ - "'Generic Neutron Template', NOW(), 'MANUAL RECORD');".format(longtext)) - - cmds.append("INSERT INTO `heat_template_params`(`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, " \ - "`PARAM_TYPE`, `PARAM_ALIAS`) VALUES('efee1d84-b8ec-11e7-abc4-cec278b6b50a', 'shared', 0, " \ - "'string', NULL);") - - print('\n'.join(cmds)) - vcpecommon.execute_cmds_so_db(cmds) - + #vcpecommon.execute_cmds_so_db(cmds) diff --git a/test/vcpe/healthcheck.py b/test/vcpe/healthcheck.py deleted file mode 100755 index b94848e13..000000000 --- a/test/vcpe/healthcheck.py +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/python - -import logging -import json -from vcpecommon import * -import commands - - -logging.basicConfig(level=logging.INFO, format='%(message)s') -common = VcpeCommon() - -print('Checking vGMUX REST API from SDNC') -cmd = 'curl -u admin:admin -X GET http://10.0.101.21:8183/restconf/config/ietf-interfaces:interfaces' -ret = commands.getstatusoutput("ssh -i onap_dev root@sdnc '{0}'".format(cmd)) -sz = ret[-1].split('\n')[-1] -print('\n') -print(sz) - -print('Checking vBRG REST API from SDNC') -cmd = 'curl -u admin:admin -X GET http://10.3.0.2:8183/restconf/config/ietf-interfaces:interfaces' -ret = commands.getstatusoutput("ssh -i onap_dev root@sdnc '{0}'".format(cmd)) -sz = ret[-1].split('\n')[-1] -print('\n') -print(sz) - -print('Checking SDNC DB for vBRG MAC address') -mac = common.get_brg_mac_from_sdnc() -print(mac) - - diff --git a/test/vcpe/preload.py b/test/vcpe/preload.py index 0108566da..f4aafbe8e 100755 --- a/test/vcpe/preload.py +++ b/test/vcpe/preload.py @@ -13,6 +13,7 @@ import base64 class Preload: def __init__(self, vcpecommon): self.logger = logging.getLogger(__name__) + self.logger.setLevel(logging.DEBUG) self.vcpecommon = vcpecommon def replace(self, sz, replace_dict): diff --git a/test/vcpe/preload_templates/operational.vcpe.json.txt b/test/vcpe/preload_templates/operational.vcpe.json.txt new file mode 100644 index 000000000..f5e9ead81 --- /dev/null +++ b/test/vcpe/preload_templates/operational.vcpe.json.txt @@ -0,0 +1,4 @@ +{ + "policy-id": "operational.vcpe", + "content": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0D%0A++trigger_policy%3A+unique-policy-id-1-restart%0D%0A++timeout%3A+3600%0D%0A++abatement%3A+true%0D%0A+%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-restart%0D%0A++++name%3A+Restart+the+VM%0D%0A++++description%3A%0D%0A++++actor%3A+APPC%0D%0A++++recipe%3A+Restart%0D%0A++++target%3A%0D%0A++++++type%3A+VM%0D%0A++++retry%3A+3%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard" +} diff --git a/test/vcpe/preload_templates/operational.vcpe.pap.json.txt b/test/vcpe/preload_templates/operational.vcpe.pap.json.txt new file mode 100644 index 000000000..22c50e7dd --- /dev/null +++ b/test/vcpe/preload_templates/operational.vcpe.pap.json.txt @@ -0,0 +1,8 @@ +{ + "policies": [ + { + "policy-id": "operational.vcpe", + "policy-version": 1 + } + ] +} diff --git a/test/vcpe/vcpe.py b/test/vcpe/vcpe.py index 375a04e12..3221d482a 100755 --- a/test/vcpe/vcpe.py +++ b/test/vcpe/vcpe.py @@ -1,6 +1,9 @@ #! /usr/bin/python -import sys + import logging +logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(name)s.%(funcName)s(): %(message)s') + +import sys from vcpecommon import * import sdcutils import soutils @@ -57,7 +60,6 @@ def create_one_service(vcpecommon, csar_file, vnf_template_file, preload_dict, s def deploy_brg_only(): - logging.basicConfig(level=logging.INFO, format='%(message)s') logger = logging.getLogger(__name__) vcpecommon = VcpeCommon() @@ -153,9 +155,6 @@ def deploy_custom_service(): def closed_loop(lossrate=0): - if lossrate > 0: - while 'y' != raw_input('Please enter docker container "drools" in Policy VM and type "policy stop". Then enter y here: ').lower(): - continue nodes = ['brg', 'mux'] logger = logging.getLogger('__name__') vcpecommon = VcpeCommon(nodes) @@ -172,7 +171,7 @@ def closed_loop(lossrate=0): time.sleep(2) vcpecommon.set_vgmux_packet_loss_rate(lossrate, vcpecommon.load_vgmux_vnf_name()) if lossrate > 0: - print('Please enter docker container "drools" in Policy VM and type "policy start". Then observe vGMUX being restarted.') + print('Now please observe vGMUX being restarted') def init_so_sdnc(): @@ -216,8 +215,6 @@ def test(): if __name__ == '__main__': - 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)') diff --git a/test/vcpe/vcpecommon.py b/test/vcpe/vcpecommon.py index 4f4613a59..b0a17bc2e 100755 --- a/test/vcpe/vcpecommon.py +++ b/test/vcpe/vcpecommon.py @@ -66,16 +66,7 @@ class VcpeCommon: owning_entity_name = 'OE-Demonstration1' def __init__(self, extra_host_names=None): - rootlogger = logging.getLogger() - handler = logging.StreamHandler() - formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s.%(funcName)s(): %(message)s') - handler.setFormatter(formatter) - rootlogger.addHandler(handler) - rootlogger.setLevel(logging.INFO) - self.logger = logging.getLogger(__name__) - self.logger.propagate = False - self.logger.addHandler(handler) self.logger.setLevel(logging.DEBUG) self.logger.info('Initializing configuration') |