aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xjuju/juju_connect.sh5
-rwxr-xr-xjuju/juju_setup.sh3
-rw-r--r--juju/openo_connect.py94
-rwxr-xr-xopera_launch.sh2
-rw-r--r--util/modify_file.sh2
6 files changed, 66 insertions, 41 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ccf6a49
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/work
diff --git a/juju/juju_connect.sh b/juju/juju_connect.sh
index 6d1b3e4..7ff803e 100755
--- a/juju/juju_connect.sh
+++ b/juju/juju_connect.sh
@@ -64,6 +64,7 @@ function start_tomcat()
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'rootpass' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EOF"
+ exec_cmd_on_client $cmd1
local cmd2='sed -i s/port=\"8080\"/port=\"8483\"/g /home/ubuntu/tomcat8/conf/server.xml'
exec_cmd_on_client $cmd2
@@ -80,9 +81,9 @@ function add_vim_and_vnfm()
--juju_client_ip $floating_ip_client \
--auth_url $OS_AUTH_URL
- local cmd3="docker stop nfvo-driver-vnfm-juju; \
+ local cmd1="docker stop nfvo-driver-vnfm-juju; \
docker start nfvo-driver-vnfm-juju"
- exec_cmd_on_openo $cmd3
+ exec_cmd_on_openo $cmd1
}
function connect_juju_and_openo()
diff --git a/juju/juju_setup.sh b/juju/juju_setup.sh
index e37eb1f..4fd5cbc 100755
--- a/juju/juju_setup.sh
+++ b/juju/juju_setup.sh
@@ -12,6 +12,9 @@ IMG_DIR=${WORK_DIR}/img
function juju_env_prepare()
{
+ sudo rm -f /root/.ssh/known_hosts
+ sudo rm -f /root/.ssh/known_hosts.old
+
mkdir -p ${WORK_DIR}/venv
sudo pip install --upgrade virtualenv
virtualenv ${WORK_DIR}/venv
diff --git a/juju/openo_connect.py b/juju/openo_connect.py
index 7792082..caae216 100644
--- a/juju/openo_connect.py
+++ b/juju/openo_connect.py
@@ -21,6 +21,32 @@ class RaiseError(Exception):
def __str__(self):
return repr(self.msg)
+def request_get(url):
+ try:
+ resp = requests.get(url)
+ if resp.status_code not in (200,201):
+ raise RaiseError('get url: %s fail %d' % (url, resp.status_code))
+ except Exception:
+ raise
+
+ return resp.json()
+
+def request_post(url, data, headers):
+ try:
+ resp = requests.post(url, data=json.dumps(data), headers=headers)
+ if resp.status_code not in (200,201):
+ raise RaiseError('post url: %s fail %d' % (url, resp.status_code))
+ except Exception:
+ raise
+
+def request_delete(url):
+ try:
+ resp = requests.delete(url)
+ if resp.status_code not in (200,201,204):
+ raise RaiseError('delete url: %s fail %d' % (url, resp.status_code))
+ except Exception:
+ raise
+
def add_common_tosca_aria(msb_ip, tosca_aria_ip):
url = 'http://' + msb_ip + '/openoapi/microservices/v1/apiRoute'
headers = {'Content-Type': 'application/json'}
@@ -33,13 +59,7 @@ def add_common_tosca_aria(msb_ip, tosca_aria_ip):
"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
+ request_post(url, data, headers)
def add_openo_vim(msb_ip, auth_url):
url = 'http://' + msb_ip + '/openoapi/extsys/v1/vims/'
@@ -54,41 +74,43 @@ def add_openo_vim(msb_ip, auth_url):
"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')
+ get = request_get(url)
+ for i in get:
+ if i["type"] == "openstack":
+ request_delete(url + i["vimId"])
- except Exception:
- raise
+ request_post(url, data, headers)
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'
+ vnfm_url = 'http://' + msb_ip + '/openoapi/extsys/v1/vnfms'
headers = {'Content-Type': 'application/json'}
- 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')
+ get_vim = request_get(vim_url)
+ vimId = ''
+ for i in get_vim:
+ if i["type"] == "openstack":
+ vimId = i['vimId']
+ break
- except Exception:
- raise
+ if vimId is None:
+ raise RaiseError("vim openstack not found")
+
+ get_vnfm = request_get(vnfm_url)
+ for i in get_vnfm:
+ if i["vimId"] == vimId:
+ request_delete(vnfm_url + i["vnfmId"])
+
+ data = {"name":"Juju-VNFM",
+ "vimId":vimId,
+ "vendor":"jujuvnfm",
+ "version":"jujuvnfm",
+ "type":"jujuvnfm",
+ "description":"",
+ "certificateUrl":"",
+ "url":"http://" + juju_client_ip + ":8483",
+ "userName":"",
+ "password":""}
+ request_post(vnfm_url, data, headers)
if __name__ == "__main__":
diff --git a/opera_launch.sh b/opera_launch.sh
index 750ace2..c48fcb3 100755
--- a/opera_launch.sh
+++ b/opera_launch.sh
@@ -36,8 +36,6 @@ source ${JUJU_DIR}/juju_connect.sh
mkdir -p $WORK_DIR
if [[ "$DEPLOY_FIRST_TIME" == "true" ]]; then
- sudo rm -f /root/.ssh/known_hosts
- sudo rm -f /root/.ssh/known_hosts.old
package_prepare
network_prepare
generate_compass_openrc
diff --git a/util/modify_file.sh b/util/modify_file.sh
index c33a2eb..607c6cd 100644
--- a/util/modify_file.sh
+++ b/util/modify_file.sh
@@ -10,7 +10,7 @@
file1=/home/etc/conf/juju_conf.json
sed -i 's/^\(.*"image-metadata-url":\).*/\1 "http:\/\/REPLACE_JUJU_METADATA_IP\/images"\,/g' $file1
sed -i 's/^\(.*"network":\).*/\1 "juju-net"\,/g' $file1
-#sed -i 's/^\(.*"use-floating-ip":\).*/\1 "False"\,/g' $file
+sed -i 's/^\(.*"use-floating-ip":\).*/\1 "True"\,/g' $file
file2=/home/etc/csarInfo/csarinfo.json
sed -i 's/^\(.*"csar_file_path":\).*/\1 "\/home\/ubuntu\/csar\/"\,/g' $file2