aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcommand.sh4
-rwxr-xr-xjuju/juju_connect.sh87
-rwxr-xr-xjuju/juju_launch.sh1
-rwxr-xr-xjuju/juju_setup.sh3
-rw-r--r--juju/openo_connect.py108
-rwxr-xr-xopen-o/openo_docker.sh4
-rwxr-xr-xopera_launch.sh48
7 files changed, 231 insertions, 24 deletions
diff --git a/command.sh b/command.sh
index 2f6b76c..513bc94 100755
--- a/command.sh
+++ b/command.sh
@@ -50,7 +50,7 @@ function exec_cmd_on_client()
log_error "juju-client ip not found"
exit 1
fi
- ssh $ssh_options ubuntu@$floating_ip_client "$@"
+ ssh $ssh_args ubuntu@$floating_ip_client "$@"
}
function exec_cmd_on_metadata()
@@ -61,5 +61,5 @@ function exec_cmd_on_metadata()
log_error "juju-metadata ip not found"
exit 1
fi
- ssh $ssh_options ubuntu@$floating_ip_metadata "$@"
+ ssh $ssh_args ubuntu@$floating_ip_metadata "$@"
}
diff --git a/juju/juju_connect.sh b/juju/juju_connect.sh
new file mode 100755
index 0000000..0bc4ef9
--- /dev/null
+++ b/juju/juju_connect.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+##############################################################################
+# 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
+##############################################################################
+
+function connect_prepare()
+{
+ local cmd1="yum install -y rsync"
+ exec_cmd_on_openo $cmd1
+
+ local cmd2="if [[ ! -f /root/.ssh/id_rsa.pub ]]; then \
+ sudo ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ''; \
+ fi"
+ exec_cmd_on_openo $cmd2
+
+ local openo_key=`exec_cmd_on_openo cat /root/.ssh/id_rsa.pub`
+ local cmd3="echo $openo_key >> /home/ubuntu/.ssh/authorized_keys"
+ exec_cmd_on_client $cmd3
+
+ local cmd4="sudo apt-get install -y default-jdk; \
+ wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.9/bin/apache-tomcat-8.5.9.tar.gz; \
+ tar -zxvf apache-tomcat-8.5.9.tar.gz; \
+ rm -rf tomcat8; \
+ mv apache-tomcat-8.5.9 tomcat8; \
+ rm -rf tomcat8/webapps/*; \
+ mkdir csar"
+ exec_cmd_on_client $cmd4
+}
+
+function sync_juju_driver_file()
+{
+ connect_prepare
+
+ local cmd1="docker cp nfvo-driver-vnfm-juju:/service/webapps/ROOT /home/; \
+ docker cp nfvo-driver-vnfm-juju:/service/etc /home/;"
+ exec_cmd_on_openo $cmd1
+
+ scp_to_openo ${UTIL_DIR}/modify_file.sh /home
+ local cmd2="sed -i s/REPLACE_JUJU_DRIVER_IP/$NFVO_DRIVER_VNFM_JUJU_IP/ /home/modify_file.sh; \
+ chmod +x /home/modify_file.sh; \
+ /home/modify_file.sh"
+ exec_cmd_on_openo $cmd2
+
+ local cmd3="rsync -e 'ssh -o StrictHostKeyChecking=no' --rsync-path='sudo rsync' \
+ -av /home/etc ubuntu@$floating_ip_client:/home/ubuntu/tomcat8/; \
+ rsync -e 'ssh -o StrictHostKeyChecking=no' --rsync-path='sudo rsync' \
+ -av /home/ROOT ubuntu@$floating_ip_client:/home/ubuntu/tomcat8/webapps"
+ exec_cmd_on_openo $cmd3
+
+ local cmd4="docker cp /home/etc nfvo-driver-vnfm-juju:/service/; \
+ docker cp /home/ROOT nfvo-driver-vnfm-juju:/service/webapps/"
+ exec_cmd_on_openo $cmd4
+}
+
+function start_tomcat()
+{
+ local cmd1="mysql -uroot -p'rootpass' << EOF
+ GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'rootpass' WITH GRANT OPTION;
+ FLUSH PRIVILEGES;
+ EOF"
+
+ local cmd2="sed -i s/port=\"8080\"/port=\"8483\"/ /home/ubuntu/tomcat8/conf/server.xml; \
+ ps aux | grep java | awk '{print \"$2\"}' | xargs kill -9; \
+ /home/ubuntu/tomcat8/bin/catalina.sh start"
+ exec_cmd_on_client $cmd2
+}
+
+function add_vim_and_vnfm()
+{
+ python ${JUJU_DIR}/openo_connect.py $COMMON_SERVICES_MSB_IP $NFVO_DRIVER_VNFM_JUJU_IP
+
+ local cmd3="docker stop nfvo-driver-vnfm-juju; \
+ docker start nfvo-driver-vnfm-juju"
+ exec_cmd_on_openo $cmd3
+}
+
+function connect_juju_and_openo()
+{
+ sync_juju_driver_file
+ start_tomcat
+ add_vim_and_vnfm
+}
diff --git a/juju/juju_launch.sh b/juju/juju_launch.sh
index 558fa5d..3653660 100755
--- a/juju/juju_launch.sh
+++ b/juju/juju_launch.sh
@@ -158,7 +158,6 @@ function bootstrap_juju_controller()
--constraints 'mem=4G root-disk=40G' \
--verbose --debug"
exec_cmd_on_client $cmd
-
}
function launch_juju()
diff --git a/juju/juju_setup.sh b/juju/juju_setup.sh
index 30df1b2..d52b47f 100755
--- a/juju/juju_setup.sh
+++ b/juju/juju_setup.sh
@@ -89,7 +89,8 @@ function juju_prepare()
ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""
fi
- openstack keypair list | grep jump-key || openstack keypair create --public-key ~/.ssh/id_rsa.pub jump-key
+ openstack keypair list | grep jump-key || openstack keypair create --public-key \
+ /root/.ssh/id_rsa.pub jump-key
openstack flavor show m1.tiny || openstack flavor create --ram 512 --disk 5 --vcpus 1 --public m1.tiny
openstack flavor show m1.small || openstack flavor create --ram 1024 --disk 10 --vcpus 1 --public m1.small
diff --git a/juju/openo_connect.py b/juju/openo_connect.py
new file mode 100644
index 0000000..782c7cb
--- /dev/null
+++ b/juju/openo_connect.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+##############################################################################
+# 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
+##############################################################################
+
+import sys
+import os
+import requests
+import json
+
+class RaiseError(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __str__(self):
+ return repr(self.msg)
+
+def add_common_tosca_aria(msb_ip, tosca_aria_ip):
+ url = 'http://' + msb_ip + '/openoapi/microservices/v1/apiRoute'
+ headers = {'Content-Type': 'application/json'}
+ data = {"serviceName":"tosca",
+ "version":"v1",
+ "url":"/openoapi/tosca/v1",
+ "metricsUrl":"/admin/metrics",
+ "apiJson":"/swagger.json",
+ "apiJsonType":"1",
+ "control":"0",
+ "status":"1",
+ "servers":[{"ip":tosca_aria_ip,"port":"8204","weight":0}]}
+ try:
+ resp = requests.post(url, data=json.dumps(data), headers=headers)
+ if resp.status_code not in (200,201):
+ raise RaiseError('add common_tosca_aria service failed')
+
+ except Exception:
+ raise
+
+def add_openo_vim(msb_ip):
+ url = 'http://' + msb_ip + '/openoapi/extsys/v1/vims/'
+ headers = {'Content-Type': 'application/json'}
+ if os.getenv('OS_AUTH_URL') is None:
+ raise RaiseError('env OS_AUTH_URL not found')
+ else:
+ auth_url = os.getenv('OS_AUTH_URL')
+ data = {"name":"openstack",
+ "url":auth_url,
+ "userName":"admin",
+ "password":"console",
+ "tenant":"admin",
+ "domain":"",
+ "vendor":"openstack",
+ "version":"newton",
+ "description":"",
+ "type":"openstack"}
+ try:
+ resp = requests.post(url, data=json.dumps(data), headers=headers)
+ if resp.status_code not in (200,201):
+ raise RaiseError('add open-o vim failed')
+
+ except Exception:
+ raise
+
+def add_openo_vnfm(msb_ip):
+ vnfm_url = 'http://' + msb_ip + '/openoapi/extsys/v1/vnfms'
+ vim_url = 'http://' + msb_ip + '/openoapi/extsys/v1/vims'
+ headers = {'Content-Type': 'application/json'}
+ if os.getenv('floating_ip_client') is None:
+ raise RaiseError('env floating_ip_client not found')
+ else:
+ juju_client_ip = os.getenv('floating_ip_client')
+ try:
+ resp = requests.get(vim_url)
+ if resp.status_code not in (200,201):
+ raise RaiseError('add open-o vnfm failed')
+
+ vimInfo = resp.json()
+ vimId = vimInfo[0]['vimId']
+ data = {"name":"Juju-VNFM",
+ "vimId":vimId,
+ "vendor":"jujuvnfm",
+ "version":"jujuvnfm",
+ "type":"jujuvnfm",
+ "description":"",
+ "certificateUrl":"",
+ "url":"http://" + juju_client_ip + ":8483",
+ "userName":"",
+ "password":""}
+ resp = requests.post(vnfm_url, data=json.dumps(data), headers=headers)
+ if resp.status_code not in (200,201):
+ raise RaiseError('add open-o vnfm failed')
+
+ except Exception:
+ raise
+
+if __name__ == "__main__":
+
+ if len(sys.argv) != 3:
+ raise RaiseError('input open-o ip error')
+
+ _, msb_ip, tosca_aria_ip = sys.argv
+ add_common_tosca_aria(msb_ip, tosca_aria_ip)
+ add_openo_vim(msb_ip)
+ add_openo_vnfm(msb_ip)
diff --git a/open-o/openo_docker.sh b/open-o/openo_docker.sh
index 8639110..d61edf7 100755
--- a/open-o/openo_docker.sh
+++ b/open-o/openo_docker.sh
@@ -73,7 +73,7 @@ function docker_pull()
do
echo "Try again"
done
- until docker pull openoint/nfvo-driver-vnfm-juju:REPLACE_OPENO_TAG
+ until docker pull openoint/nfvo-driver-vnfm-jujud
do
echo "Try again"
done
@@ -188,7 +188,7 @@ function docker_run()
docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_DRIVER_SDNC_ZTE_IP --name nfvo-driver-sdnc-zte openoint/nfvo-driver-sdnc-zte:REPLACE_OPENO_TAG
docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_DRIVER_VIM_IP --name nfvo-driver-vim openoint/nfvo-driver-vim:REPLACE_OPENO_TAG
docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_DRIVER_VNFM_HUAWEI_IP --name nfvo-driver-vnfm-huawei openoint/nfvo-driver-vnfm-huawei:REPLACE_OPENO_TAG
- docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_DRIVER_VNFM_JUJU_IP --name nfvo-driver-vnfm-juju openoint/nfvo-driver-vnfm-juju:REPLACE_OPENO_TAG
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_DRIVER_VNFM_JUJU_IP --name nfvo-driver-vnfm-juju openoint/nfvo-driver-vnfm-juju
docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_DRIVER_VNFM_ZTE_IP --name nfvo-driver-vnfm-zte openoint/nfvo-driver-vnfm-zte:REPLACE_OPENO_TAG
docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 -e MYSQL_ADDR=COMMON_TOSCA_INVENTORY_IP:3306 --network lab_net --ip NFVO_LCM_IP --name nfvo-lcm openoint/nfvo-lcm:REPLACE_OPENO_TAG
docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_RESMANAGEMENT_IP --name nfvo-resmanagement openoint/nfvo-resmanagement:REPLACE_OPENO_TAG
diff --git a/opera_launch.sh b/opera_launch.sh
index 001d7d1..ebbe63d 100755
--- a/opera_launch.sh
+++ b/opera_launch.sh
@@ -16,6 +16,9 @@ WORK_DIR=${OPERA_DIR}/work
UTIL_DIR=${OPERA_DIR}/util
export DEPLOY_FIRST_TIME=${DEPLOY_FIRST_TIME:-"true"}
+export DEPLOY_OPENO=${DEPLOY_OPENO:-"true"}
+export DEPLOY_JUJU=${DEPLOY_JUJU:-"true"}
+
source ${OPERA_DIR}/prepare.sh
generate_conf
source ${OPERA_DIR}/conf/download.conf
@@ -28,6 +31,7 @@ source ${OPERA_DIR}/command.sh
source ${JUJU_DIR}/adapter.sh
source ${JUJU_DIR}/juju_setup.sh
source ${JUJU_DIR}/juju_launch.sh
+source ${JUJU_DIR}/juju_connect.sh
mkdir -p $WORK_DIR
@@ -39,31 +43,39 @@ fi
source $WORK_DIR/admin-openrc.sh
-if ! openo_download_iso; then
- log_error "openo_download_iso failed"
- exit 1
-fi
+if [[ "$DEPLOY_OPENO" == "true" ]]; then
+ if ! openo_download_iso; then
+ log_error "openo_download_iso failed"
+ exit 1
+ fi
-if ! launch_openo_vm; then
- log_error "launch_openo_vm failed"
- exit 1
-fi
+ if ! launch_openo_vm; then
+ log_error "launch_openo_vm failed"
+ exit 1
+ fi
-if ! launch_openo_docker; then
- log_error "launch_openo_docker failed"
- exit 1
+ if ! launch_openo_docker; then
+ log_error "launch_openo_docker failed"
+ exit 1
+ fi
fi
-juju_env_prepare
+if [[ "$DEPLOY_JUJU" == "true" ]]; then
+ juju_env_prepare
+
+ if ! juju_prepare; then
+ log_error "juju_prepare failed"
+ exit 1
+ fi
-if ! juju_prepare; then
- log_error "launch_openo_docker failed"
- exit 1
+ if ! launch_juju; then
+ log_error "launch_juju failed"
+ exit 1
+ fi
fi
-if ! launch_juju; then
- log_error "launch_juju failed"
- exit 1
+if [[ "$DEPLOY_OPENO" == "true" && "$DEPLOY_JUJU" == "true" ]]; then
+ connect_juju_and_openo
fi
figlet -ctf slant Open-O Installed!