aboutsummaryrefslogtreecommitdiffstats
path: root/juju
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2017-03-01 12:49:09 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2017-03-01 14:35:26 +0800
commitbd9c1aff4191019efe05cd0fabbade624bb2229d (patch)
tree80bd6d9f4905ae9b04ec8ed6a7ee43e8577fe8b9 /juju
parent51451b626187ae1b6db3015174792fadc3428968 (diff)
juju connect fix
use argparse to explicitly pass args Change-Id: Id729d6897be6511c8bd2de8aa31cf37dfada1caf Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
Diffstat (limited to 'juju')
-rwxr-xr-xjuju/juju_connect.sh13
-rw-r--r--juju/openo_connect.py38
2 files changed, 32 insertions, 19 deletions
diff --git a/juju/juju_connect.sh b/juju/juju_connect.sh
index 0bc4ef9..2bc742b 100755
--- a/juju/juju_connect.sh
+++ b/juju/juju_connect.sh
@@ -64,15 +64,20 @@ function start_tomcat()
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"
+ local cmd2='sed -i s/port=\"8080\"/port=\"8483\"/g /home/ubuntu/tomcat8/conf/server.xml'
exec_cmd_on_client $cmd2
+
+ local cmd3="ps aux | grep java | awk '{print \"$2\"}' | xargs kill -9; \
+ /home/ubuntu/tomcat8/bin/catalina.sh start"
+ exec_cmd_on_client $cmd3
}
function add_vim_and_vnfm()
{
- python ${JUJU_DIR}/openo_connect.py $COMMON_SERVICES_MSB_IP $NFVO_DRIVER_VNFM_JUJU_IP
+ python ${JUJU_DIR}/openo_connect.py --msb_ip $COMMON_SERVICES_MSB_IP \
+ --tosca_aria_ip $COMMON_TOSCA_ARIA_IP \
+ --juju_client_ip $floating_ip_client \
+ --auth_url $OS_AUTH_URL
local cmd3="docker stop nfvo-driver-vnfm-juju; \
docker start nfvo-driver-vnfm-juju"
diff --git a/juju/openo_connect.py b/juju/openo_connect.py
index 782c7cb..7792082 100644
--- a/juju/openo_connect.py
+++ b/juju/openo_connect.py
@@ -8,6 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import argparse
import sys
import os
import requests
@@ -40,13 +41,9 @@ def add_common_tosca_aria(msb_ip, tosca_aria_ip):
except Exception:
raise
-def add_openo_vim(msb_ip):
+def add_openo_vim(msb_ip, auth_url):
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",
@@ -65,14 +62,10 @@ def add_openo_vim(msb_ip):
except Exception:
raise
-def add_openo_vnfm(msb_ip):
+def add_openo_vnfm(msb_ip, juju_client_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):
@@ -99,10 +92,25 @@ def add_openo_vnfm(msb_ip):
if __name__ == "__main__":
- if len(sys.argv) != 3:
- raise RaiseError('input open-o ip error')
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--msb_ip", action='store', help="common_services_msb ip")
+ parser.add_argument("--tosca_aria_ip", action='store', help="common_tosca_aria ip")
+ parser.add_argument("--juju_client_ip", action='store', help="juju client ip")
+ parser.add_argument("--auth_url", action='store', help="openstack auth url")
+
+ args = parser.parse_args()
+ msb_ip = args.msb_ip
+ tosca_aria_ip = args.tosca_aria_ip
+ juju_client_ip = args.juju_client_ip
+ auth_url = args.auth_url
+
+ if None in (msb_ip, tosca_aria_ip, juju_client_ip, auth_url):
+ missing = []
+ for i in (msb_ip, tosca_aria_ip, juju_client_ip, auth_url):
+ if i is None:
+ missing.append(i)
+ raise RaiseError('missing parameter: %s' % missing)
- _, 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)
+ add_openo_vim(msb_ip, auth_url)
+ add_openo_vnfm(msb_ip, juju_client_ip)