diff options
-rw-r--r-- | conf/open-o.yml | 4 | ||||
-rw-r--r-- | conf/vnf.yml (renamed from conf/application.yml) | 5 | ||||
-rw-r--r-- | csar/clearwater/JUJU_clearwater.csar | bin | 1850996 -> 0 bytes | |||
-rw-r--r-- | csar/clearwater/pop_ns_juju.csar | bin | 58912 -> 0 bytes | |||
-rwxr-xr-x | juju/juju_connect.sh | 13 | ||||
-rwxr-xr-x | juju/vims_deploy.sh | 16 | ||||
-rwxr-xr-x | open-o/openo_docker.sh | 191 | ||||
-rw-r--r--[-rwxr-xr-x] | opera/deploy_vnf.py (renamed from juju/deploy_application.py) | 10 | ||||
-rwxr-xr-x | opera/openo_connect.py (renamed from juju/openo_connect.py) | 32 | ||||
-rwxr-xr-x | opera_launch.sh | 6 | ||||
-rwxr-xr-x | prepare.sh | 2 | ||||
-rw-r--r-- | process_conf.py | 34 | ||||
-rw-r--r-- | setup.py | 22 |
13 files changed, 197 insertions, 138 deletions
diff --git a/conf/open-o.yml b/conf/open-o.yml index 1281376..fb77eae 100644 --- a/conf/open-o.yml +++ b/conf/open-o.yml @@ -10,4 +10,6 @@ openo_docker_net: nfvo_driver_vnfm_juju_port: 8483 nfvo_driver_vnfm_juju_mysql_port: 3306 -application: +enable_sdno: false + +vnf_type: diff --git a/conf/application.yml b/conf/vnf.yml index 84f9eef..68f4492 100644 --- a/conf/application.yml +++ b/conf/vnf.yml @@ -6,7 +6,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -application: - - name: clearwater +vIMS: + - type: clearwater ns_pkg: pop_ns_juju.csar vnf_pkg: JUJU_clearwater.csar + nsdId: ns_cw_2016 diff --git a/csar/clearwater/JUJU_clearwater.csar b/csar/clearwater/JUJU_clearwater.csar Binary files differdeleted file mode 100644 index 7d11b9e..0000000 --- a/csar/clearwater/JUJU_clearwater.csar +++ /dev/null diff --git a/csar/clearwater/pop_ns_juju.csar b/csar/clearwater/pop_ns_juju.csar Binary files differdeleted file mode 100644 index a94f3c2..0000000 --- a/csar/clearwater/pop_ns_juju.csar +++ /dev/null diff --git a/juju/juju_connect.sh b/juju/juju_connect.sh index 43314b5..e4a94db 100755 --- a/juju/juju_connect.sh +++ b/juju/juju_connect.sh @@ -82,13 +82,20 @@ function start_tomcat() function openo_connect() { - python ${JUJU_DIR}/openo_connect.py --msb_ip $OPENO_IP:$COMMON_SERVICES_MSB_PORT \ + python ${OPERA_DIR}/opera/openo_connect.py --msb_ip $OPENO_IP:$COMMON_SERVICES_MSB_PORT \ --tosca_aria_ip $OPENO_IP \ --tosca_aria_port $COMMON_TOSCA_ARIA_PORT \ --juju_client_ip $juju_client_ip \ --auth_url $OS_AUTH_URL \ - --ns_pkg "${CSAR_DIR}/${APP_NS_PKG}" \ - --vnf_pkg "${CSAR_DIR}/${APP_VNF_PKG}" + --ns_pkg "${CSAR_DIR}/${NS_PKG}" \ + --vnf_pkg "${CSAR_DIR}/${VNF_PKG}" +} + +function deploy_vnf() +{ + python ${OPERA_DIR}/opera/deploy_vnf.py --msb_ip $OPENO_IP:$COMMON_SERVICES_MSB_PORT \ + --vnf $VNF_TYPE \ + --nsdId $NSDID } function fix_openo_containers() diff --git a/juju/vims_deploy.sh b/juju/vims_deploy.sh index 763a4f7..5fa86ac 100755 --- a/juju/vims_deploy.sh +++ b/juju/vims_deploy.sh @@ -10,9 +10,19 @@ juju_client_ip=$(openstack server list | grep juju-client-vm | awk '{print $9}') -function deploy_app() { - python ${JUJU_DIR}/deploy_application.py --msb_ip $OPENO_IP:$COMMON_SERVICES_MSB_PORT \ - --application $APP_NAME +function exec_cmd_on_client() +{ + local ssh_args="-o StrictHostKeyChecking=no" + + if [ ! $juju_client_ip ]; then + log_error "juju-client ip not found" + exit 1 + fi + ssh $ssh_args ubuntu@$juju_client_ip "$@" +} + +function log_error() { + echo -e "\033[31m$*\033[0m" } function check_clearwater() { diff --git a/open-o/openo_docker.sh b/open-o/openo_docker.sh index 8a4a382..7cd6eb6 100755 --- a/open-o/openo_docker.sh +++ b/open-o/openo_docker.sh @@ -9,10 +9,6 @@ ############################################################################## function docker_pull() { - until docker pull openoint/sdno-driver-ct-te:$OPENO_VERSION - do - echo "Try again" - done until docker pull openoint/common-services-auth:$OPENO_VERSION do echo "Try again" @@ -93,63 +89,7 @@ function docker_pull() do echo "Try again" done - until docker pull openoint/sdno-driver-huawei-l3vpn:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-driver-huawei-openstack:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-driver-huawei-overlay:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-driver-huawei-servicechain:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-driver-zte-sptn:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-brs:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-ipsec:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-l2vpn:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-l3vpn:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-mss:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-nslcm:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-overlayvpn:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-servicechain:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-vpc:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-service-vxlan:$OPENO_VERSION + until docker pull openoint/gso-gui-portal:$OPENO_VERSION do echo "Try again" done @@ -157,18 +97,80 @@ function docker_pull() do echo "Try again" done - until docker pull openoint/sdno-monitoring:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/sdno-vsitemgr:$OPENO_VERSION - do - echo "Try again" - done - until docker pull openoint/gso-gui-portal:$OPENO_VERSION - do - echo "Try again" - done + if [[ $ENABLE_SDNO == true ]]; then + until docker pull openoint/sdno-driver-ct-te:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-driver-huawei-l3vpn:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-driver-huawei-openstack:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-driver-huawei-overlay:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-driver-huawei-servicechain:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-driver-zte-sptn:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-brs:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-ipsec:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-l2vpn:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-l3vpn:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-mss:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-nslcm:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-overlayvpn:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-servicechain:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-vpc:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-service-vxlan:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-monitoring:$OPENO_VERSION + do + echo "Try again" + done + until docker pull openoint/sdno-vsitemgr:$OPENO_VERSION + do + echo "Try again" + done + fi } function docker_run() @@ -197,26 +199,29 @@ function docker_run() docker run -d -e MSB_ADDR=$msb_ip -e MYSQL_ADDR=$tosca_inventory_ip:3306 --name nfvo-lcm -p $OPENO_IP:8403:8403 openoint/nfvo-lcm:$OPENO_VERSION docker run -d -e MSB_ADDR=$msb_ip --name nfvo-resmanagement openoint/nfvo-resmanagement:$OPENO_VERSION docker run -d -e MSB_ADDR=$msb_ip --name nfvo-umc openoint/nfvo-umc:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-huawei-l3vpn openoint/sdno-driver-huawei-l3vpn:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-huawei-openstack openoint/sdno-driver-huawei-openstack:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-huawei-overlay openoint/sdno-driver-huawei-overlay:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-huawei-servicechain openoint/sdno-driver-huawei-servicechain:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-zte-sptn openoint/sdno-driver-zte-sptn:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-brs openoint/sdno-service-brs:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-ipsec openoint/sdno-service-ipsec:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-l2vpn openoint/sdno-service-l2vpn:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-l3vpn openoint/sdno-service-l3vpn:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-mss openoint/sdno-service-mss:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip -e MYSQL_ADDR=$tosca_inventory_ip:3306 --name sdno-service-nslcm openoint/sdno-service-nslcm:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-overlayvpn openoint/sdno-service-overlayvpn:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-servicechain openoint/sdno-service-servicechain:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-vpc openoint/sdno-service-vpc:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-vxlan openoint/sdno-service-vxlan:$OPENO_VERSION docker run -d -e MSB_ADDR=$msb_ip --name common-tosca-aria -p $OPENO_IP:$COMMON_TOSCA_ARIA_PORT:8204 openoint/common-tosca-aria:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-ct-te openoint/sdno-driver-ct-te:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-monitoring openoint/sdno-monitoring:$OPENO_VERSION - docker run -d -e MSB_ADDR=$msb_ip --name sdno-vsitemgr openoint/sdno-vsitemgr:$OPENO_VERSION docker run -d -e MSB_ADDR=$msb_ip --name gso-gui-portal openoint/gso-gui-portal:$OPENO_VERSION + + if [[ $ENABLE_SDNO == true ]]; then + docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-huawei-l3vpn openoint/sdno-driver-huawei-l3vpn:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-huawei-openstack openoint/sdno-driver-huawei-openstack:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-huawei-overlay openoint/sdno-driver-huawei-overlay:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-huawei-servicechain openoint/sdno-driver-huawei-servicechain:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-zte-sptn openoint/sdno-driver-zte-sptn:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-brs openoint/sdno-service-brs:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-ipsec openoint/sdno-service-ipsec:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-l2vpn openoint/sdno-service-l2vpn:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-l3vpn openoint/sdno-service-l3vpn:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-mss openoint/sdno-service-mss:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip -e MYSQL_ADDR=$tosca_inventory_ip:3306 --name sdno-service-nslcm openoint/sdno-service-nslcm:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-overlayvpn openoint/sdno-service-overlayvpn:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-servicechain openoint/sdno-service-servicechain:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-vpc openoint/sdno-service-vpc:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-service-vxlan openoint/sdno-service-vxlan:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-driver-ct-te openoint/sdno-driver-ct-te:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-monitoring openoint/sdno-monitoring:$OPENO_VERSION + docker run -d -e MSB_ADDR=$msb_ip --name sdno-vsitemgr openoint/sdno-vsitemgr:$OPENO_VERSION + fi } function clean() { @@ -231,8 +236,6 @@ function launch_openo() { clean docker_run - if [[ $(docker ps -q | grep openoint | wc -l) == 40 ]];then - echo -e "\n\033[32mOpen-O launch success\033[0m\n" - fi + echo -e "\n\033[32mOpen-O launch success\033[0m\n" } diff --git a/juju/deploy_application.py b/opera/deploy_vnf.py index 22c7d9d..b9703a0 100755..100644 --- a/juju/deploy_application.py +++ b/opera/deploy_vnf.py @@ -15,12 +15,14 @@ from openo_connect import create_service if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("--application", action='store', default='', help="app name") parser.add_argument("--msb_ip", action='store', help="common_services_msb ip") + parser.add_argument("--vnf", action='store', default='', help="vnf type") + parser.add_argument("--nsdId", action='store', default='', help="vnf nsdId") args = parser.parse_args() - application = args.application msb_ip = args.msb_ip + vnf = args.vnf + nsdId = args.nsdId - if application == 'clearwater': - create_service(msb_ip, application, 'vIMS', 'ns_cw_2016') + if vnf == 'clearwater': + create_service(msb_ip, vnf, vnf, nsdId) diff --git a/juju/openo_connect.py b/opera/openo_connect.py index 387ae98..4e9e4fb 100755 --- a/juju/openo_connect.py +++ b/opera/openo_connect.py @@ -14,6 +14,7 @@ import os import time import requests import json +from datetime import datetime from pprint import pprint @@ -136,15 +137,6 @@ def add_openo_vnfm(msb_ip, juju_client_ip): request_post(vnfm_url, data, headers) -def upload_csar(msb_ip, package): - csar_url = 'http://' + msb_ip + '/openoapi/catalog/v1/csars' - files = {'file': open(package, 'rb')} - res = requests.post(csar_url, files=files) - if res.status_code != 200: - pprint(res.json()) - raise Exception('Error with uploading csar package: %s' % package) - - def delete_csars(msb_ip): csar_url = 'http://' + msb_ip + '/openoapi/catalog/v1/csars/' csars = request_get(csar_url) @@ -154,6 +146,24 @@ def delete_csars(msb_ip): pprint("csar %s is deleted" % csarId) +def upload_csar(msb_ip, package): + csar_url = 'http://' + msb_ip + '/openoapi/catalog/v1/csars' + files = {'file': open(package, 'rb')} + res = requests.post(csar_url, files=files) + if res.status_code != 200: + retry = 5 + while retry != 0: + delete_csars(msb_ip) + retry_res = requests.post(csar_url, files=files) + if retry_res.status_code == 200: + break + else: + pprint(retry_res.json()) + retry -= 1 + if retry == 0: + raise Exception('Error with uploading csar package: %s' % package) + + def package_onboard(msb_ip): csar_url = 'http://' + msb_ip + '/openoapi/catalog/v1/csars' vnf_url = 'http://' + msb_ip + '/openoapi/nslcm/v1/vnfpackage' @@ -184,11 +194,11 @@ def package_onboard(msb_ip): raise RaiseError("csar onboard fail") -def create_service(msb_ip, ns_name, description, nsdId): +def create_service(msb_ip, ns_name, description, nsdId='ns_cw_2016'): service_url = 'http://' + msb_ip + '/openoapi/servicegateway/v1/services' headers = {'Content-Type': 'application/json'} data1 = {"nsdId": nsdId, - "nsName": ns_name, + "nsName": "{0}{1}".format(ns_name, datetime.now().strftime('%Y%m%d%H%M%S')), "description": description, "gatewayUri":"/openoapi/nslcm/v1/ns"} vimId = get_vim_id(msb_ip, "openstack") diff --git a/opera_launch.sh b/opera_launch.sh index 0af0718..18b0ca8 100755 --- a/opera_launch.sh +++ b/opera_launch.sh @@ -39,7 +39,7 @@ if [[ "$DEPLOY_FIRST_TIME" == "true" ]]; then fi source ${WORK_DIR}/scripts/open-o.conf -source ${WORK_DIR}/scripts/application.conf +source ${WORK_DIR}/scripts/vnf.conf if [[ "$DEPLOY_OPENO" == "true" ]]; then if ! launch_openo;then @@ -64,8 +64,8 @@ if [[ "$DEPLOY_JUJU" == "true" ]]; then connect_juju_and_openo fi -if [[ -n $APP_NAME ]]; then - deploy_app +if [[ -n $VNF_TYPE ]]; then + deploy_vnf fi figlet -ctf slant Open-O Installed @@ -14,7 +14,7 @@ function generate_conf() rm -rf ${SCRIPT_DIR} mkdir -p ${SCRIPT_DIR} python ${OPERA_DIR}/process_conf.py ${CONF_DIR}/open-o.yml \ - ${CONF_DIR}/application.yml + ${CONF_DIR}/vnf.yml } function package_prepare() diff --git a/process_conf.py b/process_conf.py index c8f4e9d..976cf19 100644 --- a/process_conf.py +++ b/process_conf.py @@ -24,16 +24,18 @@ def generate_openo_conf(openo_config, scripts_dir): fd.write('{0}={1}\n'.format(i.upper(), openo_config["openo_docker_net"][i])) fd.write('{0}={1}\n'.format('OPENO_VERSION', openo_config["openo_version"])) - - -def generate_app_conf(openo_config, app_config, scripts_dir): - """generate opera/work/scripts_dir/application.conf""" - with open(scripts_dir + "/application.conf", "w") as fd: - for i in app_config["application"]: - if i["name"] == openo_config["application"]: - fd.write('{0}={1}\n'.format('APP_NAME', i["name"])) - fd.write('{0}={1}\n'.format('APP_NS_PKG', i["ns_pkg"])) - fd.write('{0}={1}'.format('APP_VNF_PKG', i["vnf_pkg"])) + fd.write('{0}={1}'.format('ENABLE_SDNO', openo_config["enable_sdno"])) + + +def generate_app_conf(openo_config, vnf_config, scripts_dir): + """generate opera/work/scripts_dir/vnf.conf""" + with open(scripts_dir + "/vnf.conf", "w") as fd: + for i in vnf_config["vIMS"]: + if i["type"] == openo_config["vnf_type"]: + fd.write('{0}={1}\n'.format('VNF_TYPE', i["type"])) + fd.write('{0}={1}\n'.format('NS_PKG', i["ns_pkg"])) + fd.write('{0}={1}\n'.format('VNF_PKG', i["vnf_pkg"])) + fd.write('{0}={1}'.format('NSDID', i["nsdId"])) break @@ -42,13 +44,13 @@ if __name__ == "__main__": print("parameter wrong%d %s" % (len(sys.argv), sys.argv)) sys.exit(1) - _, openo_file, app_file = sys.argv + _, openo_file, vnf_file = sys.argv if not os.path.exists(openo_file): print("network.yml doesn't exit") sys.exit(1) - if not os.path.exists(app_file): + if not os.path.exists(vnf_file): print("application.yml doesn't exit") sys.exit(1) @@ -57,9 +59,9 @@ if __name__ == "__main__": print('format error in %s' % openo_file) sys.exit(1) - app_config = load_file(app_file) - if not app_config: - print('format error in %s' % app_file) + vnf_config = load_file(vnf_file) + if not vnf_config: + print('format error in %s' % vnf_file) sys.exit(1) opera_dir = os.getenv('OPERA_DIR') @@ -69,4 +71,4 @@ if __name__ == "__main__": sys.exit(1) generate_openo_conf(openo_config, scripts_dir) - generate_app_conf(openo_config, app_config, scripts_dir) + generate_app_conf(openo_config, vnf_config, scripts_dir) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..46bb5fb --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +############################################################################## +# Copyright (c) 2016-2017 HUAWEI TECHNOLOGIES CO.,LTD and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +from setuptools import setup, find_packages + + +setup( + name="opera", + version="master", + packages=find_packages(), + include_package_data=True, + package_data={ + }, + url="https://www.opnfv.org", + install_requires=["requests==2.9.1"] +) |