aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md37
-rw-r--r--conf/download.conf5
-rw-r--r--conf/network.yml60
-rw-r--r--conf/openo-vm.yml14
-rw-r--r--conf/test.py6
-rwxr-xr-xjuju/adapter.sh28
-rwxr-xr-xjuju/juju_launch.sh167
-rwxr-xr-xjuju/juju_setup.sh89
-rwxr-xr-xopen-o/openo_docker.sh229
-rwxr-xr-xopen-o/openo_vm.sh206
-rwxr-xr-xopera_launch.sh69
-rwxr-xr-xprepare.sh53
-rw-r--r--process_conf.py73
-rw-r--r--util/external-net.xml7
-rw-r--r--util/isolinux.cfg120
-rw-r--r--util/ks.cfg228
-rw-r--r--util/libvirt.xml64
-rwxr-xr-xutil/log.sh24
18 files changed, 1479 insertions, 0 deletions
diff --git a/README.md b/README.md
index d95d989..9b07192 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,38 @@
OPNFV OPEN-O Integration Source Codes
+
+Code Structure:
+opera/
+├── ci
+│   └── deploy.sh
+├── conf
+│   ├── admin-openrc.sh # compass openrc file
+│   ├── juju.conf # juju config
+│   ├── openo-docker.conf # open-o docker config
+│   └── openo-vm.conf # open-o vm config
+├── INFO
+├── juju
+│   ├── juju_launch.sh # launch juju vms
+│   └── juju_setup.sh # juju prepare
+├── LICENSE
+├── model
+│   ├── bind.csar
+│   ├── bono.csar
+│   ├── ellis.csar
+│   ├── homer.csar
+│   ├── homestead.csar
+│   ├── proxy_node.csar
+│   ├── ralf.csar
+│   ├── sprout.csar
+│   └── vIMS_NS.csar
+├── open-o
+│   ├── openo_docker.sh # launch open-o docker inside open-o vm
+│   └── openo_vm.sh # launch open-o vm
+├── opera_launch.sh # opera deploy entrance
+├── prepare.sh # prepare work for opera
+├── README.md
+└── util
+ ├── isolinux.cfg # kickstart open-o vm
+ ├── ks.cfg # kickstart open-o vm
+ ├── libvirt.xml # define open-o vm
+ └── log.sh # different log print
+
diff --git a/conf/download.conf b/conf/download.conf
new file mode 100644
index 0000000..1012601
--- /dev/null
+++ b/conf/download.conf
@@ -0,0 +1,5 @@
+# iso and img conifg
+OPENO_VM_ISO_URL=http://205.177.226.237:9999/CentOS-7-x86_64-Minimal-1511.iso
+JUJU_IMG_NAME=(xenial_x86_64 trusty_x86_x64)
+JUJU_IMG_URL=(http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img \
+ http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img)
diff --git a/conf/network.yml b/conf/network.yml
new file mode 100644
index 0000000..e587b2d
--- /dev/null
+++ b/conf/network.yml
@@ -0,0 +1,60 @@
+##############################################################################
+# 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
+##############################################################################
+---
+openo_net:
+ openo_vm_ip: 192.168.57.50
+ openo_vm_mask: 255.255.255.0
+ openo_external_gw: 192.168.57.250
+ openo_external_cidr: 192.168.57.0/24
+
+openo_docker_net:
+ common_services_auth_ip: 192.168.57.51
+ common_services_drivermanager_ip: 192.168.57.52
+ common_services_extsys_ip: 192.168.57.53
+ common_services_msb_ip: 192.168.57.54
+ common_services_protocolstack_ip: 192.168.57.55
+ common_services_wso2ext_ip: 192.168.57.56
+ common_tosca_catalog_ip: 192.168.57.57
+ common_tosca_inventory_ip: 192.168.57.58
+ common_tosca_modeldesigner_ip: 192.168.57.59
+ gso_service_gateway_ip: 192.168.57.60
+ gso_service_manager_ip: 192.168.57.61
+ nfvo_dac_ip: 192.168.57.62
+ nfvo_driver_sdnc_zte_ip: 192.168.57.63
+ nfvo_driver_vim_ip: 192.168.57.64
+ nfvo_driver_vnfm_huawei_ip: 192.168.57.65
+ nfvo_driver_vnfm_juju_ip: 192.168.57.66
+ nfvo_driver_vnfm_zte_ip: 192.168.57.67
+ nfvo_lcm_ip: 192.168.57.68
+ nfvo_resmanagement_ip: 192.168.57.69
+ nfvo_umc_ip: 192.168.57.70
+ sdno_driver_huawei_l3vpn_ip: 192.168.57.71
+ sdno_driver_huawei_openstack_ip: 192.168.57.72
+ sdno_driver_huawei_overlay_ip: 192.168.57.73
+ sdno_driver_huawei_servicechain_ip: 192.168.57.74
+ sdno_driver_zte_sptn_ip: 192.168.57.75
+ sdno_service_brs_ip: 192.168.57.76
+ sdno_service_ipsec_ip: 192.168.57.77
+ sdno_service_l2vpn_ip: 192.168.57.78
+ sdno_service_l3vpn_ip: 192.168.57.79
+ sdno_service_mss_ip: 192.168.57.80
+ sdno_service_nslcm_ip: 192.168.57.81
+ sdno_service_overlayvpn_ip: 192.168.57.82
+ sdno_service_servicechain_ip: 192.168.57.83
+ sdno_service_vpc_ip: 192.168.57.84
+ sdno_service_vxlan_ip: 192.168.57.85
+ common_tosca_aria_ip: 192.168.57.86
+ sdno_driver_ct_te_ip: 192.168.57.87
+ sdno_monitoring_ip: 192.168.57.88
+ sdno_vsitemgr_ip: 192.168.57.89
+ gso_gui_portal_ip: 192.168.57.90
+
+juju_net:
+ juju_net_cidr: 12.1.1.0/24
+ juju_net_gw: 12.1.1.1
diff --git a/conf/openo-vm.yml b/conf/openo-vm.yml
new file mode 100644
index 0000000..0ce2152
--- /dev/null
+++ b/conf/openo-vm.yml
@@ -0,0 +1,14 @@
+##############################################################################
+# 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
+##############################################################################
+---
+openo:
+ cpu: 4
+ memory: 64
+ disk: 100
+ vnet: external
diff --git a/conf/test.py b/conf/test.py
new file mode 100644
index 0000000..0a45a94
--- /dev/null
+++ b/conf/test.py
@@ -0,0 +1,6 @@
+
+a={'a':'1.2','b':'1.1','c':'1.0'}
+b=sorted(a.items(),key=lambda i:i[1])
+c=[i[0] for i in b]
+#sorted(b, cmp=lambda x,y: cmp(a[x],a[y]))
+print c
diff --git a/juju/adapter.sh b/juju/adapter.sh
new file mode 100755
index 0000000..f4c2d52
--- /dev/null
+++ b/juju/adapter.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 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 generate_compass_openrc()
+{
+ ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
+ MGMT_IP=192.168.200.2
+ exec_command="sshpass -p root ssh $ssh_options root@$MGMT_IP"
+
+ RUN_DIR=$(eval "$exec_command ls /var/ansible/run")
+
+ cmd="cat /var/ansible/run/$RUN_DIR/group_vars/all | grep -A 3 public_vip: | sed -n '2p' | sed -e 's/ ip: //g'"
+ PUBLIC_VIP=$(eval "$exec_command $cmd")
+
+ echo -e "export OS_PASSWORD=console \n\
+export OS_TENANT_NAME=admin \n\
+export OS_AUTH_URL=http://$PUBLIC_VIP:35357/v2.0 \n\
+export OS_USERNAME=admin \n\
+export OS_VOLUME_API_VERSION=2 \n\
+export OS_REGION_NAME=RegionOne " > $WORK_DIR/admin-openrc.sh
+
+}
diff --git a/juju/juju_launch.sh b/juju/juju_launch.sh
new file mode 100755
index 0000000..10a35bb
--- /dev/null
+++ b/juju/juju_launch.sh
@@ -0,0 +1,167 @@
+#!/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
+##############################################################################
+
+ssh_options="-o StrictHostKeyChecking=no"
+
+function launch_juju_vm()
+{
+ NET_ID=$(neutron net-list | grep juju-net | awk '{print $2}')
+
+ if [[ ! $(nova list | grep juju-client-vm) ]]; then
+ nova boot --flavor m1.small --image Xenial_x86_64 --nic net-id=$NET_ID \
+ --key-name jump-key --security-group juju-default juju-client-vm
+ fi
+
+ if [[ ! $(nova list | grep juju-metadata-vm) ]]; then
+ nova boot --flavor m1.small --image Xenial_x86_64 --nic net-id=$NET_ID \
+ --key-name jump-key --security-group juju-default juju-metadata-vm
+ fi
+
+ set +x
+ until [[ $(nova list | grep juju-metadata-vm | grep ACTIVE) ]]
+ do
+ sleep 1
+ done
+ set -x
+
+ if [ ! $(nova list | grep juju-client-vm | awk '{print $14}') ]; then
+ floating_ip_client=$(neutron floatingip-create ext-net | grep floating_ip_address | awk '{print $4}')
+ nova floating-ip-associate juju-client-vm $floating_ip_client
+ else
+ floating_ip_client=$(nova list | grep juju-client-vm | awk '{print $13}')
+ fi
+
+ if [ ! $(nova list | grep juju-metadata-vm | awk '{print $14}') ]; then
+ floating_ip_metadata=$(neutron floatingip-create ext-net | grep floating_ip_address | awk '{print $4}')
+ nova floating-ip-associate juju-metadata-vm $floating_ip_metadata
+ else
+ floating_ip_metadata=$(nova list | grep juju-metadata-vm | awk '{print $13}')
+ fi
+
+ sleep 60
+
+ export floating_ip_client=$floating_ip_client
+ export floating_ip_metadata=$floating_ip_metadata
+}
+
+function exec_cmd_on_client()
+{
+ ssh $ssh_options ubuntu@$floating_ip_client "$@"
+}
+
+function exec_cmd_on_metadata()
+{
+ ssh $ssh_options ubuntu@$floating_ip_metadata "$@"
+}
+
+function juju_metadata_prepare()
+{
+ cmd="sudo apt update -y; \
+ sudo apt-get install nginx -y"
+ exec_cmd_on_metadata $cmd
+
+ if [ ! $(exec_cmd_on_metadata sudo ps -aux | grep nginx) ]; then
+ log_error "juju-metadata nginx error"
+ exit 1
+ fi
+}
+
+function juju_client_prepare()
+{
+ cmd1="sudo add-apt-repository ppa:juju/stable; \
+ sudo apt update -y; \
+ sudo apt install juju zfsutils-linux -y"
+ exec_cmd_on_client $cmd1
+
+ exec_cmd_on_client "echo 'clouds:
+ openstack:
+ type: openstack
+ auth-types: [access-key, userpass]
+ regions:
+ $OS_REGION_NAME:
+ endpoint: $OS_AUTH_URL' > clouds.yaml"
+
+ cmd2="juju add-cloud openstack clouds.yaml --replace"
+ exec_cmd_on_client $cmd2
+
+ if [[ ! $(exec_cmd_on_client "juju list-clouds | grep openstack") ]]; then
+ log_error "juju-client add cloud error"
+ exit 1
+ fi
+
+ cmd3='ssh-keygen -q -t rsa -f /home/ubuntu/.ssh/id_rsa -N ""'
+ exec_cmd_on_client $cmd3
+
+ client_key=`exec_cmd_on_client sudo cat /home/ubuntu/.ssh/id_rsa.pub`
+ cmd4="echo $client_key >> /home/ubuntu/.ssh/authorized_keys"
+ exec_cmd_on_metadata $cmd4
+
+ exec_cmd_on_client "echo 'credentials:
+ openstack:
+ openstack:
+ auth-type: userpass
+ password: $OS_PASSWORD
+ tenant-name: $OS_TENANT_NAME
+ username: $OS_USERNAME' > os-creds.yaml"
+
+ # credential uses keystone url V3
+ cmd3="juju add-credential openstack -f os-creds.yaml --replace"
+ exec_cmd_on_client $cmd3
+}
+
+function juju_generate_metadata()
+{
+ exec_cmd_on_client mkdir -p mt
+
+ for((i=0;i<${#JUJU_IMG_NAME[@]};i++))
+ do
+ IMAGE_ID=$(glance image-list | grep ${JUJU_IMG_NAME[i]} | awk '{print $2}')
+ cmd="juju metadata generate-image -s ${JUJU_IMG_NAME[i]%%_*} -i $IMAGE_ID \
+ -r $OS_REGION_NAME -d mt -u $OS_AUTH_URL"
+ exec_cmd_on_client $cmd
+ done
+
+ cmd1="juju metadata generate-tools -d mt"
+ exec_cmd_on_client $cmd1
+
+ cmd2="rsync -e 'ssh $ssh_options' -av mt ubuntu@$floating_ip_metadata:~/"
+ exec_cmd_on_client $cmd2
+
+ cmd3="sudo cp -a mt/tools/ /var/www/html; \
+ sudo cp -a mt/images/ /var/www/html; \
+ sudo chmod a+rx /var/www/html/ -R"
+ exec_cmd_on_metadata $cmd3
+
+ wget -O - http://$floating_ip_metadata/images/streams/v1/index.json
+ if [ $? -ne 0 ]; then
+ log_error "juju metadata generate error"
+ exit 1
+ fi
+}
+
+function bootstrap_juju_controller()
+{
+ cmd="juju bootstrap openstack openstack \
+ --config image-metadata-url=http://$floating_ip_metadata/images \
+ --config network=juju-net \
+ --verbose --debug"
+ exec_cmd_on_client $cmd
+}
+
+function launch_juju()
+{
+ log_info "launch_juju enter"
+
+ launch_juju_vm
+ juju_metadata_prepare
+ juju_client_prepare
+ juju_generate_metadata
+ bootstrap_juju_controller
+}
diff --git a/juju/juju_setup.sh b/juju/juju_setup.sh
new file mode 100755
index 0000000..61e0152
--- /dev/null
+++ b/juju/juju_setup.sh
@@ -0,0 +1,89 @@
+#!/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
+##############################################################################
+
+IMG_DIR=${WORK_DIR}/img
+
+function juju_env_prepare()
+{
+ mkdir -p ${WORK_DIR}/venv
+ sudo pip install --upgrade virtualenv
+ virtualenv ${WORK_DIR}/venv
+
+ source ${WORK_DIR}/venv/bin/activate
+ pip install --upgrade python-openstackclient python-neutronclient
+}
+
+function juju_download_img()
+{
+ if [ ! -e ${IMG_DIR}/${1##*/} ];then
+ wget -O ${IMG_DIR}/${1##*/} $1
+ fi
+}
+
+function juju_prepare()
+{
+ log_info "juju_prepare enter"
+
+ mkdir -p $IMG_DIR
+
+ for((i=0;i<${#JUJU_IMG_NAME[@]};i++))
+ do
+ juju_download_img ${JUJU_IMG_URL[i]}
+ if [[ ! $(glance image-list | grep ${JUJU_IMG_NAME[i]}) ]]; then
+ glance image-create --name=${JUJU_IMG_NAME[i]} \
+ --disk-format qcow2 --container-format=bare \
+ --visibility=public --file ${IMG_DIR}/${JUJU_IMG_URL[i]##*/}
+ fi
+ done
+
+ if [[ ! $(neutron net-list | grep juju-net) ]]; then
+ neutron net-create juju-net
+ fi
+
+ if [[ ! $(neutron subnet-list | grep juju-subnet) ]]; then
+ neutron subnet-create juju-net $JUJU_NET_CIDR --name juju-subnet --gateway $JUJU_NET_GW \
+ --dns_nameservers list=true 8.8.8.8
+ fi
+
+ if [[ ! $(neutron router-list | grep juju-router) ]]; then
+ neutron router-create juju-router
+ neutron router-interface-add juju-router juju-subnet
+ neutron router-gateway-set juju-router ext-net
+ fi
+
+ if [[ ! $(neutron security-group-rule-list | grep "juju-default") ]]; then
+ neutron security-group-create juju-default --description "juju default security group"
+ fi
+
+ if [[ ! $(neutron security-group-rule-list | grep juju-default | grep "icmp") ]]; then
+ neutron security-group-rule-create --direction ingress --protocol icmp \
+ --remote-ip-prefix 0.0.0.0/0 juju-default
+ fi
+
+ if [[ ! $(neutron security-group-rule-list | grep juju-default | grep "22/tcp") ]]; then
+ neutron security-group-rule-create --direction ingress --protocol tcp \
+ --port_range_min 22 --port_range_max 22 \
+ --remote-ip-prefix 0.0.0.0/0 juju-default
+ fi
+
+ if [[ ! $(neutron security-group-rule-list | grep juju-default | grep "80/tcp") ]]; then
+ neutron security-group-rule-create --direction ingress --protocol tcp \
+ --port_range_min 80 --port_range_max 80 \
+ --remote-ip-prefix 0.0.0.0/0 juju-default
+ fi
+
+ openstack keypair list | grep jump-key || openstack keypair create --public-key ~/.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
+ openstack flavor show m1.medium || openstack flavor create --ram 2048 --disk 10 --vcpus 2 --public m1.medium
+ openstack flavor show m1.large || openstack flavor create --ram 3072 --disk 10 --vcpus 2 --public m1.large
+ openstack flavor show m1.xlarge || openstack flavor create --ram 8096 --disk 30 --vcpus 4 --public m1.xlarge
+}
diff --git a/open-o/openo_docker.sh b/open-o/openo_docker.sh
new file mode 100755
index 0000000..aa79a9d
--- /dev/null
+++ b/open-o/openo_docker.sh
@@ -0,0 +1,229 @@
+#!/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 docker_pull()
+{
+ until docker pull openoint/sdno-driver-ct-te
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-services-auth
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-services-drivermanager
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-services-extsys
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-services-msb
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-services-protocolstack
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-services-wso2ext
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-tosca-catalog
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-tosca-inventory
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-tosca-modeldesigner
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/gso-service-gateway
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/gso-service-manager
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-dac
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-driver-sdnc-zte
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-driver-vim
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-driver-vnfm-huawei
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-driver-vnfm-juju
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-driver-vnfm-zte
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-lcm
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-resmanagement
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/nfvo-umc
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-driver-huawei-l3vpn
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-driver-huawei-openstack
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-driver-huawei-overlay
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-driver-huawei-servicechain
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-driver-zte-sptn
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-brs
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-ipsec
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-l2vpn
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-l3vpn
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-mss
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-nslcm
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-overlayvpn
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-servicechain
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-vpc
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-service-vxlan
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/common-tosca-aria
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-monitoring
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/sdno-vsitemgr
+ do
+ echo "Try again"
+ done
+ until docker pull openoint/gso-gui-portal
+ do
+ echo "Try again"
+ done
+}
+
+function docker_run()
+{
+ docker run -d -e MODEL_DESIGNER_IP=COMMON_TOSCA_MODELDESIGNER_IP --network lab_net --ip COMMON_SERVICES_MSB_IP --name common-services-msb openoint/common-services-msb
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --add-host controller:127.0.0.1 --network lab_net --ip COMMON_SERVICES_AUTH_IP --name common-services-auth openoint/common-services-auth
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip COMMON_SERVICES_DRIVERMANAGER_IP --name common-services-drivermanager openoint/common-services-drivermanager
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip COMMON_SERVICES_EXTSYS_IP --name common-services-extsys openoint/common-services-extsys
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip COMMON_SERVICES_PROTOCOLSTACK_IP --name common-services-protocolstack openoint/common-services-protocolstack
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip COMMON_SERVICES_WSO2EXT_IP --name common-services-wso2ext openoint/common-services-wso2ext
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip COMMON_TOSCA_CATALOG_IP --name common-tosca-catalog openoint/common-tosca-catalog
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip COMMON_TOSCA_INVENTORY_IP --name common-tosca-inventory openoint/common-tosca-inventory
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip COMMON_TOSCA_MODELDESIGNER_IP --name common-tosca-modeldesigner openoint/common-tosca-modeldesigner
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip GSO_SERVICE_GATEWAY_IP --name gso-service-gateway openoint/gso-service-gateway
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 -e MYSQL_ADDR=COMMON_TOSCA_INVENTORY_IP:3306 --network lab_net --ip GSO_SERVICE_MANAGER_IP --name gso-service-manager openoint/gso-service-manager
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_DAC_IP --name nfvo-dac openoint/nfvo-dac
+ 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
+ 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
+ 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
+ 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
+ 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
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_RESMANAGEMENT_IP --name nfvo-resmanagement openoint/nfvo-resmanagement
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip NFVO_UMC_IP --name nfvo-umc openoint/nfvo-umc
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_DRIVER_HUAWEI_L3VPN_IP --name sdno-driver-huawei-l3vpn openoint/sdno-driver-huawei-l3vpn
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_DRIVER_HUAWEI_OPENSTACK_IP --name sdno-driver-huawei-openstack openoint/sdno-driver-huawei-openstack
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_DRIVER_HUAWEI_OVERLAY_IP --name sdno-driver-huawei-overlay openoint/sdno-driver-huawei-overlay
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_DRIVER_HUAWEI_SERVICECHAIN_IP --name sdno-driver-huawei-servicechain openoint/sdno-driver-huawei-servicechain
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_DRIVER_ZTE_SPTN_IP --name sdno-driver-zte-sptn openoint/sdno-driver-zte-sptn
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_BRS_IP --name sdno-service-brs openoint/sdno-service-brs
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_IPSEC_IP --name sdno-service-ipsec openoint/sdno-service-ipsec
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_L2VPN_IP --name sdno-service-l2vpn openoint/sdno-service-l2vpn
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_L3VPN_IP --name sdno-service-l3vpn openoint/sdno-service-l3vpn
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_MSS_IP --name sdno-service-mss openoint/sdno-service-mss
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 -e MYSQL_ADDR=COMMON_TOSCA_INVENTORY_IP:3306 --network lab_net --ip SDNO_SERVICE_NSLCM_IP --name sdno-service-nslcm openoint/sdno-service-nslcm
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_OVERLAYVPN_IP --name sdno-service-overlayvpn openoint/sdno-service-overlayvpn
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_SERVICECHAIN_IP --name sdno-service-servicechain openoint/sdno-service-servicechain
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_VPC_IP --name sdno-service-vpc openoint/sdno-service-vpc
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_SERVICE_VXLAN_IP --name sdno-service-vxlan openoint/sdno-service-vxlan
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip COMMON_TOSCA_ARIA_IP --name common-tosca-aria openoint/common-tosca-aria
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_DRIVER_CT_TE_IP --name sdno-driver-ct-te openoint/sdno-driver-ct-te
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_MONITORING_IP --name sdno-monitoring openoint/sdno-monitoring
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip SDNO_VSITEMGR_IP --name sdno-vsitemgr openoint/sdno-vsitemgr
+ docker run -d -e MSB_ADDR=COMMON_SERVICES_MSB_IP:80 --network lab_net --ip GSO_GUI_PORTAL_IP --name gso-gui-portal openoint/gso-gui-portal
+}
+
+yum update -y
+yum install -y curl net-tools
+curl -sSL https://experimental.docker.com/ | sh
+service docker start
+
+docker network create -d macvlan --subnet=OPENO_EXTERNAL_CIDR --gateway=OPENO_EXTERNAL_GW -o parent=eth0 lab_net
+docker_pull
+docker_run
+
+if [[ $(docker ps -aq | wc -l) == 40 ]];then
+ echo -e "\n\033[32mOpen-O Installed!\033[0m\n"
+fi
diff --git a/open-o/openo_vm.sh b/open-o/openo_vm.sh
new file mode 100755
index 0000000..0d7d289
--- /dev/null
+++ b/open-o/openo_vm.sh
@@ -0,0 +1,206 @@
+#!/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
+##############################################################################
+set -ex
+OPENO_VM_DIR=${WORK_DIR}/openo_vm
+OPENO_VM_ISO=${OPENO_VM_ISO_URL##*/}
+rsa_file=${OPENO_VM_DIR}/boot.rsa
+ssh_args="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $rsa_file"
+
+function openo_download_iso()
+{
+ local ISO_DIR=${WORK_DIR}/iso
+ mkdir -p $ISO_DIR
+ if [ ! -e ${ISO_DIR}/${OPENO_VM_ISO} ];then
+ wget -O ${ISO_DIR}/${OPENO_VM_ISO} $OPENO_VM_ISO_URL
+ fi
+}
+
+function openo_docker_prepare()
+{
+ cp $OPENO_DIR/openo_docker.sh ${OPENO_VM_DIR}/
+ sed -i -e "s#OPENO_EXTERNAL_CIDR#$OPENO_EXTERNAL_CIDR#g" \
+ -e "s/OPENO_EXTERNAL_GW/$OPENO_EXTERNAL_GW/g" \
+ -e "s/COMMON_SERVICES_AUTH_IP/$COMMON_SERVICES_AUTH_IP/g" \
+ -e "s/COMMON_SERVICES_DRIVERMANAGER_IP/$COMMON_SERVICES_DRIVERMANAGER_IP/g" \
+ -e "s/COMMON_SERVICES_EXTSYS_IP/$COMMON_SERVICES_EXTSYS_IP/g" \
+ -e "s/COMMON_SERVICES_MSB_IP/$COMMON_SERVICES_MSB_IP/g" \
+ -e "s/COMMON_SERVICES_PROTOCOLSTACK_IP/$COMMON_SERVICES_PROTOCOLSTACK_IP/g" \
+ -e "s/COMMON_SERVICES_WSO2EXT_IP/$COMMON_SERVICES_WSO2EXT_IP/g" \
+ -e "s/COMMON_TOSCA_CATALOG_IP/$COMMON_TOSCA_CATALOG_IP/g" \
+ -e "s/COMMON_TOSCA_INVENTORY_IP/$COMMON_TOSCA_INVENTORY_IP/g" \
+ -e "s/COMMON_TOSCA_MODELDESIGNER_IP/$COMMON_TOSCA_MODELDESIGNER_IP/g" \
+ -e "s/GSO_SERVICE_GATEWAY_IP/$GSO_SERVICE_GATEWAY_IP/g" \
+ -e "s/GSO_SERVICE_MANAGER_IP/$GSO_SERVICE_MANAGER_IP/g" \
+ -e "s/NFVO_DAC_IP/$NFVO_DAC_IP/g" \
+ -e "s/NFVO_DRIVER_SDNC_ZTE_IP/$NFVO_DRIVER_SDNC_ZTE_IP/g" \
+ -e "s/NFVO_DRIVER_VIM_IP/$NFVO_DRIVER_VIM_IP/g" \
+ -e "s/NFVO_DRIVER_VNFM_HUAWEI_IP/$NFVO_DRIVER_VNFM_HUAWEI_IP/g" \
+ -e "s/NFVO_DRIVER_VNFM_JUJU_IP/$NFVO_DRIVER_VNFM_JUJU_IP/g" \
+ -e "s/NFVO_DRIVER_VNFM_ZTE_IP/$NFVO_DRIVER_VNFM_ZTE_IP/g" \
+ -e "s/NFVO_LCM_IP/$NFVO_LCM_IP/g" \
+ -e "s/NFVO_RESMANAGEMENT_IP/$NFVO_RESMANAGEMENT_IP/g" \
+ -e "s/NFVO_UMC_IP/$NFVO_UMC_IP/g" \
+ -e "s/SDNO_DRIVER_HUAWEI_L3VPN_IP/$SDNO_DRIVER_HUAWEI_L3VPN_IP/g" \
+ -e "s/SDNO_DRIVER_HUAWEI_OPENSTACK_IP/$SDNO_DRIVER_HUAWEI_OPENSTACK_IP/g" \
+ -e "s/SDNO_DRIVER_HUAWEI_OVERLAY_IP/$SDNO_DRIVER_HUAWEI_OVERLAY_IP/g" \
+ -e "s/SDNO_DRIVER_HUAWEI_SERVICECHAIN_IP/$SDNO_DRIVER_HUAWEI_SERVICECHAIN_IP/g" \
+ -e "s/SDNO_DRIVER_ZTE_SPTN_IP/$SDNO_DRIVER_ZTE_SPTN_IP/g" \
+ -e "s/SDNO_SERVICE_BRS_IP/$SDNO_SERVICE_BRS_IP/g" \
+ -e "s/SDNO_SERVICE_IPSEC_IP/$SDNO_SERVICE_IPSEC_IP/g" \
+ -e "s/SDNO_SERVICE_L2VPN_IP/$SDNO_SERVICE_L2VPN_IP/g" \
+ -e "s/SDNO_SERVICE_L3VPN_IP/$SDNO_SERVICE_L3VPN_IP/g" \
+ -e "s/SDNO_SERVICE_MSS_IP/$SDNO_SERVICE_MSS_IP/g" \
+ -e "s/SDNO_SERVICE_NSLCM_IP/$SDNO_SERVICE_NSLCM_IP/g" \
+ -e "s/SDNO_SERVICE_OVERLAYVPN_IP/$SDNO_SERVICE_OVERLAYVPN_IP/g" \
+ -e "s/SDNO_SERVICE_SERVICECHAIN_IP/$SDNO_SERVICE_SERVICECHAIN_IP/g" \
+ -e "s/SDNO_SERVICE_VPC_IP/$SDNO_SERVICE_VPC_IP/g" \
+ -e "s/SDNO_SERVICE_VXLAN_IP/$SDNO_SERVICE_VXLAN_IP/g" \
+ -e "s/COMMON_TOSCA_ARIA_IP/$COMMON_TOSCA_ARIA_IP/g" \
+ -e "s/SDNO_DRIVER_CT_TE_IP/$SDNO_DRIVER_CT_TE_IP/g" \
+ -e "s/SDNO_MONITORING_IP/$SDNO_MONITORING_IP/g" \
+ -e "s/SDNO_VSITEMGR_IP/$SDNO_VSITEMGR_IP/g" \
+ -e "s/GSO_GUI_PORTAL_IP/$GSO_GUI_PORTAL_IP/g" \
+ ${OPENO_VM_DIR}/openo_docker.sh
+
+ scp $ssh_args ${OPENO_VM_DIR}/openo_docker.sh root@${OPENO_VM_IP}:/home
+}
+
+function exec_cmd_on_openo()
+{
+ ssh $ssh_args root@$OPENO_VM_IP "$@"
+}
+
+function launch_openo_docker()
+{
+ openo_docker_prepare
+ cmd="/home/openo_docker.sh"
+ exec_cmd_on_openo $cmd
+}
+
+function tear_down_openo()
+{
+ sudo virsh destroy open-o > /dev/null 2>&1
+ sudo virsh undefine open-o > /dev/null 2>&1
+
+ sudo umount $OPENO_VM_DIR/old > /dev/null 2>&1
+ sudo umount $OPENO_VM_DIR/new > /dev/null 2>&1
+
+ sudo rm -rf $OPENO_VM_DIR
+
+ log_info "tear_down_openo success!!!"
+}
+
+function wait_openo_ok()
+{
+ set +x
+ log_info "wait_openo_ok enter"
+ ssh-keygen -f "/root/.ssh/known_hosts" -R $OPENO_VM_IP >/dev/null 2>&1
+ retry=0
+ until timeout 1s ssh $ssh_args root@$OPENO_VM_IP "exit" >/dev/null 2>&1
+ do
+ log_progress "os install time used: $((retry*100/$1))%"
+ sleep 1
+ let retry+=1
+ if [[ $retry -ge $1 ]];then
+ # first try
+ ssh $ssh_args root@$OPENO_VM_IP "exit"
+ # second try
+ ssh $ssh_args root@$OPENO_VM_IP "exit"
+ exit_status=$?
+ if [[ $exit_status == 0 ]]; then
+ log_warn "final ssh login open-o success !!!"
+ break
+ fi
+ log_error "final ssh retry failed with status: " $exit_status
+ log_error "os install time out"
+ exit 1
+ fi
+ done
+ set -x
+ log_warn "os install time used: 100%"
+ log_info "wait_openo_ok exit"
+}
+
+function launch_openo_vm() {
+ set -x
+
+ local old_mnt=${OPENO_VM_DIR}/old
+ local new_mnt=${OPENO_VM_DIR}/new
+ local old_iso=${WORK_DIR}/iso/${OPENO_VM_ISO}
+ local new_iso=${OPENO_VM_DIR}/centos.iso
+
+ sudo virsh net-destroy external
+ sudo virsh net-undefine external
+
+ if [[ ! $(virsh net-list | grep external) ]]; then
+ sudo virsh net-define ${UTIL_DIR}/external-net.xml
+ sudo virsh net-start external
+ fi
+
+ log_info "launch_openo enter"
+
+ tear_down_openo
+
+ mkdir -p $OPENO_VM_DIR $old_mnt
+ sudo mount -o loop $old_iso $old_mnt
+ cd $old_mnt;find .|cpio -pd $new_mnt;cd -
+
+ sudo umount $old_mnt
+
+ chmod 755 -R $new_mnt
+
+ cp ${UTIL_DIR}/isolinux.cfg $new_mnt/isolinux/ -f
+ cp ${UTIL_DIR}/ks.cfg $new_mnt/isolinux/ -f
+
+ sed -i -e "s/REPLACE_EXTERNAL_IP/$OPENO_VM_IP/g" \
+ -e "s/REPLACE_EXTERNAL_NETMASK/$OPENO_VM_MASK/g" \
+ -e "s/REPLACE_EXTERNAL_GW/$OPENO_EXTERNAL_GW/g" \
+ $new_mnt/isolinux/isolinux.cfg
+
+ mkdir -p $new_mnt/bootstrap
+ ssh-keygen -f $new_mnt/bootstrap/boot.rsa -t rsa -N ''
+ cp $new_mnt/bootstrap/boot.rsa $rsa_file
+
+ rm -rf $new_mnt/.rr_moved $new_mnt/rr_moved
+ sudo mkisofs -quiet -r -J -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -hide-rr-moved -x "lost+found:" -o $new_iso $new_mnt
+
+ rm -rf $old_mnt $new_mnt
+
+ qemu-img create -f qcow2 ${OPENO_VM_DIR}/disk.img ${OPENO_VIRT_DISK}G
+
+ let OPENO_VIRT_MEM*=1024
+ # create vm xml
+ sed -e "s/REPLACE_MEM/$OPENO_VIRT_MEM/g" \
+ -e "s/REPLACE_CPU/$OPENO_VIRT_CPUS/g" \
+ -e "s#REPLACE_IMAGE#$OPENO_VM_DIR/disk.img#g" \
+ -e "s#REPLACE_ISO#$OPENO_VM_DIR/centos.iso#g" \
+ -e "s/REPLACE_NET_EXTERNAL/$OPENO_VM_NET/g" \
+ ${UTIL_DIR}/libvirt.xml \
+ > ${OPENO_VM_DIR}/open-o.xml
+
+ sudo virsh define ${OPENO_VM_DIR}/open-o.xml
+ sudo virsh start open-o
+
+ exit_status=$?
+ if [ $exit_status != 0 ];then
+ log_error "virsh start open-o failed"
+ exit 1
+ fi
+
+ if ! wait_openo_ok 300;then
+ log_error "install os timeout"
+ exit 1
+ fi
+
+ set +x
+ log_info "launch_openo exit"
+}
+
+set +ex
diff --git a/opera_launch.sh b/opera_launch.sh
new file mode 100755
index 0000000..ae86dee
--- /dev/null
+++ b/opera_launch.sh
@@ -0,0 +1,69 @@
+#!/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
+##############################################################################
+set -ex
+export OPERA_DIR=`cd ${BASH_SOURCE[0]%/*}/;pwd`
+CONF_DIR=${OPERA_DIR}/conf
+OPENO_DIR=${OPERA_DIR}/open-o
+JUJU_DIR=${OPERA_DIR}/juju
+WORK_DIR=${OPERA_DIR}/work
+UTIL_DIR=${OPERA_DIR}/util
+
+export DEPLOY_FIRST_TIME=${DEPLOY_FIRST_TIME:-"true"}
+source ${OPERA_DIR}/prepare.sh
+generate_conf
+source ${OPERA_DIR}/conf/download.conf
+source ${WORK_DIR}/scripts/openo-vm.conf
+source ${WORK_DIR}/scripts/network.conf
+
+source ${UTIL_DIR}/log.sh
+source ${OPENO_DIR}/openo_vm.sh
+source ${JUJU_DIR}/adapter.sh
+source ${JUJU_DIR}/juju_setup.sh
+source ${JUJU_DIR}/juju_launch.sh
+
+mkdir -p $WORK_DIR
+
+if [[ "$DEPLOY_FIRST_TIME" == "true" ]]; then
+ package_prepare
+ network_prepare
+ generate_compass_openrc
+fi
+
+source $WORK_DIR/admin-openrc.sh
+
+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_docker; then
+ log_error "launch_openo_docker failed"
+ exit 1
+fi
+
+juju_env_prepare
+
+if ! juju_prepare; then
+ log_error "launch_openo_docker failed"
+ exit 1
+fi
+
+if ! launch_juju; then
+ log_error "launch_juju failed"
+ exit 1
+fi
+
+figlet -ctf slant Open-O Installed!
+set +ex
diff --git a/prepare.sh b/prepare.sh
new file mode 100755
index 0000000..1b07679
--- /dev/null
+++ b/prepare.sh
@@ -0,0 +1,53 @@
+#!/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 generate_conf()
+{
+ rm -rf ${WORK_DIR}/scripts
+ mkdir -p ${WORK_DIR}/scripts
+ python ${OPERA_DIR}/process_conf.py ${CONF_DIR}/openo-vm.yml ${CONF_DIR}/network.yml
+}
+
+function package_prepare()
+{
+ if [[ $(grep Ubuntu /etc/issue) ]]; then
+ sudo apt-get update -y
+ sudo apt-get install -y wget mkisofs qemu-utils qemu-kvm libvirt-bin openvswitch-switch python-pip sshpass figlet
+ else
+ # not test with redhat server yet
+ sudo yum update -y
+ sudo yum install -y wget mkisofs qemu-kvm libvirt-bin openvswitch-switch python-pip sshpass figlet
+ fi
+ service openvswitch-switch start
+}
+
+function network_prepare()
+{
+ sudo ovs-vsctl list-br |grep br-external
+ br_exist=$?
+ external_nic=`ip route |grep '^default'|awk '{print $5F}'`
+ route_info=`ip route |grep -Eo '^default via [^ ]+'`
+ ip_info=`ip addr show $external_nic|grep -Eo '[^ ]+ brd [^ ]+ '`
+ if [ $br_exist -eq 0 ]; then
+ if [ "$external_nic" != "br-external" ]; then
+ sudo ovs-vsctl --may-exist add-port br-external $external_nic
+ sudo ip addr flush $external_nic
+ sudo ip addr add $ip_info dev br-external
+ sudo ip route add $route_info dev br-external
+ fi
+ else
+ sudo ovs-vsctl add-br br-external
+ sudo ifconfig br-external up
+ sudo ovs-vsctl add-port br-external $external_nic
+ sudo ip addr flush $external_nic
+ sudo ip addr add $ip_info dev br-external
+ sudo ip route add $route_info dev br-external
+ fi
+}
diff --git a/process_conf.py b/process_conf.py
new file mode 100644
index 0000000..7693396
--- /dev/null
+++ b/process_conf.py
@@ -0,0 +1,73 @@
+import os
+import yaml
+import sys
+import subprocess
+import traceback
+
+
+def load_file(file):
+ with open(file) as fd:
+ try:
+ return yaml.load(fd)
+ except:
+ traceback.print_exc()
+ return None
+
+
+def generate_vm_conf(vm_config, scripts_dir):
+ """generate opera/work/scripts_dir/openo-vm.conf"""
+ print vm_config["openo"]["cpu"]
+ with open(scripts_dir + "/openo-vm.conf", "w") as fd:
+ fd.write("OPENO_VIRT_CPUS=" + str(vm_config["openo"]["cpu"]) + "\n")
+ fd.write("OPENO_VIRT_MEM=" + str(vm_config["openo"]["memory"]) + "\n")
+ fd.write("OPENO_VIRT_DISK=" + str(vm_config["openo"]["disk"]) + "\n")
+ fd.write("OPENO_VM_NET=" + vm_config["openo"]["vnet"] + "\n")
+
+
+def generate_net_conf(net_config, scripts_dir):
+ """generate opera/work/scripts_dir/network.conf"""
+ with open(scripts_dir + "/network.conf", "w") as fd:
+ for i in net_config["openo_net"].keys():
+ fd.write(i.upper() + "=" + net_config["openo_net"][i])
+ fd.write("\n")
+
+ for i in net_config["openo_docker_net"].keys():
+ fd.write(i.upper() + "=" + net_config["openo_docker_net"][i])
+ fd.write("\n")
+
+ for i in net_config["juju_net"].keys():
+ fd.write(i.upper() + "=" + net_config["juju_net"][i])
+ fd.write("\n")
+
+
+if __name__ == "__main__":
+ if len(sys.argv) != 3:
+ print("parameter wrong%d %s" % (len(sys.argv), sys.argv))
+ sys.exit(1)
+
+ _, vm_file, net_file = sys.argv
+
+ if not os.path.exists(vm_file):
+ print("openo-vm.yml doesn't exit")
+ sys.exit(1)
+ if not os.path.exists(net_file):
+ print("network.yml doesn't exit")
+ sys.exit(1)
+
+ vm_config = load_file(vm_file)
+ net_config = load_file(net_file)
+ if not vm_config:
+ print('format error in %s' % vm_file)
+ sys.exit(1)
+ if not net_config:
+ print('format error in %s' % net_file)
+ sys.exit(1)
+
+ opera_dir = os.getenv('OPERA_DIR')
+ scripts_dir = os.path.join(opera_dir, 'work/scripts')
+ if not os.path.exists(scripts_dir):
+ print("dir opera/work/scripts doesn't exit")
+ sys.exit(1)
+
+ generate_vm_conf(vm_config, scripts_dir)
+ generate_net_conf(net_config, scripts_dir)
diff --git a/util/external-net.xml b/util/external-net.xml
new file mode 100644
index 0000000..40c2336
--- /dev/null
+++ b/util/external-net.xml
@@ -0,0 +1,7 @@
+ <network ipv6='no'>
+ <name>external</name>
+ <bridge name='br-external'/>
+ <forward mode='bridge'/>
+ <virtualport type='openvswitch'/>
+ </network>
+
diff --git a/util/isolinux.cfg b/util/isolinux.cfg
new file mode 100644
index 0000000..f468818
--- /dev/null
+++ b/util/isolinux.cfg
@@ -0,0 +1,120 @@
+default vesamenu.c32
+timeout 1
+
+display boot.msg
+
+# Clear the screen when exiting the menu, instead of leaving the menu displayed.
+# For vesamenu, this means the graphical background is still displayed without
+# the menu itself for as long as the screen remains in graphics mode.
+menu clear
+menu background splash.png
+menu title CentOS 7
+menu vshift 8
+menu rows 18
+menu margin 8
+#menu hidden
+menu helpmsgrow 15
+menu tabmsgrow 13
+
+# Border Area
+menu color border * #00000000 #00000000 none
+
+# Selected item
+menu color sel 0 #ffffffff #00000000 none
+
+# Title bar
+menu color title 0 #ff7ba3d0 #00000000 none
+
+# Press [Tab] message
+menu color tabmsg 0 #ff3a6496 #00000000 none
+
+# Unselected menu item
+menu color unsel 0 #84b8ffff #00000000 none
+
+# Selected hotkey
+menu color hotsel 0 #84b8ffff #00000000 none
+
+# Unselected hotkey
+menu color hotkey 0 #ffffffff #00000000 none
+
+# Help text
+menu color help 0 #ffffffff #00000000 none
+
+# A scrollbar of some type? Not sure.
+menu color scrollbar 0 #ffffffff #ff355594 none
+
+# Timeout msg
+menu color timeout 0 #ffffffff #00000000 none
+menu color timeout_msg 0 #ffffffff #00000000 none
+
+# Command prompt text
+menu color cmdmark 0 #84b8ffff #00000000 none
+menu color cmdline 0 #ffffffff #00000000 none
+
+# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
+
+menu tabmsg Press Tab for full configuration options on menu items.
+
+menu separator # insert an empty line
+menu separator # insert an empty line
+
+label linux
+ menu label ^Install CentOS 7
+ menu default
+ kernel vmlinuz
+ append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img external_ip=REPLACE_EXTERNAL_IP external_netmask=REPLACE_EXTERNAL_NETMASK external_gw=REPLACE_EXTERNAL_GW dns1=8.8.8.8
+
+label check
+ menu label Test this ^media & install CentOS 7
+ kernel vmlinuz
+ append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet
+
+menu separator # insert an empty line
+
+# utilities submenu
+menu begin ^Troubleshooting
+ menu title Troubleshooting
+
+label vesa
+ menu indent count 5
+ menu label Install CentOS 7 in ^basic graphics mode
+ text help
+ Try this option out if you're having trouble installing
+ CentOS 7.
+ endtext
+ kernel vmlinuz
+ append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet
+
+label rescue
+ menu indent count 5
+ menu label ^Rescue a CentOS system
+ text help
+ If the system will not boot, this lets you access files
+ and edit config files to try to get it booting again.
+ endtext
+ kernel vmlinuz
+ append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet
+
+label memtest
+ menu label Run a ^memory test
+ text help
+ If your system is having issues, a problem with your
+ system's memory may be the cause. Use this utility to
+ see if the memory is working correctly.
+ endtext
+ kernel memtest
+
+menu separator # insert an empty line
+
+label local
+ menu label Boot from ^local drive
+ localboot 0xffff
+
+menu separator # insert an empty line
+menu separator # insert an empty line
+
+label returntomain
+ menu label Return to ^main menu
+ menu exit
+
+menu end
diff --git a/util/ks.cfg b/util/ks.cfg
new file mode 100644
index 0000000..8955e0c
--- /dev/null
+++ b/util/ks.cfg
@@ -0,0 +1,228 @@
+##############################################################################
+# 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
+##############################################################################
+#version=DEVEL
+# System authorization information
+auth --useshadow --enablemd5
+# Install OS instead of upgrade
+install
+# License agreement
+eula --agreed
+# Use text mode install
+text
+# Firewall configuration
+firewall --disabled
+firstboot --disable
+# Keyboard layouts
+# old format: keyboard us
+# new format:
+keyboard --vckeymap=us --xlayouts='us'
+network --onboot no --device eth0 --bootproto dhcp --noipv6
+network --onboot no --device eth1 --bootproto dhcp --noipv6
+network --onboot no --device eth2 --bootproto dhcp --noipv6
+# System language
+lang en_US.UTF-8
+# Installation logging level
+logging --level=info
+# Reboot after installation
+reboot
+# Root password
+rootpw root
+# SELinux configuration
+selinux --disabled
+# System services
+services --enabled="NetworkManager,sshd"
+# Do not configure the X Window System
+skipx
+# System timezone
+timezone America/Los_Angeles --isUtc
+
+# System bootloader configuration
+%include /tmp/bootloader.ks
+
+# Clear the Master Boot Record
+zerombr
+# Partition clearing information
+clearpart --all --initlabel
+
+# Disk partitioning information
+%include /tmp/partition.ks
+
+%pre
+#!/bin/sh
+
+set -x -v
+exec 1>/tmp/ks-pre.log 2>&1
+# Once root's homedir is there, copy over the log.
+while : ; do
+ sleep 10
+ if [ -d /mnt/sysimage/root ]; then
+ cp /tmp/ks-pre.log /mnt/sysimage/root/
+ logger "Copied %pre section log to system"
+ break
+ fi
+done &
+
+# hard drivedd
+drives=(`ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`)
+default_drive=${drives[0]}
+
+for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
+
+tgtdrive=$default_drive
+format_confirmed="no"
+
+if [ ${#drives[@]} -lt 1 ]; then
+ exec < /dev/tty3 > /dev/tty3 2>&1
+ chvt 3
+ clear
+ echo
+ echo '********************************************************************'
+ echo '* E R R O R *'
+ echo '* *'
+ echo '* There is no suitable media available for installation. *'
+ echo '* Please attach a drive and try again. *'
+ echo '* *'
+ echo '********************************************************************'
+ echo
+ read -p "Press Enter to shut down the system: " _
+ poweroff
+fi
+
+# verify tgtdrive is at least 30GB
+tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 ))
+if [ $tgtdrivesize -lt 30720 ]; then
+ exec < /dev/tty3 > /dev/tty3 2>&1
+ chvt 3
+ clear
+ echo
+ echo '********************************************************************'
+ echo '* E R R O R *'
+ echo '* *'
+ echo '* Your disk is under 30GB in size. Installation cannot continue. *'
+ echo '* Restart installation with a larger disk. *'
+ echo '* *'
+ echo '********************************************************************'
+ echo
+ read -p "Press Enter to restart: " _
+ reboot
+fi
+
+vgremove -ff os
+dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10
+sleep 3
+
+hdparm -z /dev/${tgtdrive}
+parted -s /dev/${tgtdrive} mklabel gpt
+parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24
+parted -s /dev/${tgtdrive} set 1 bios_grub on
+parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224
+parted -s /dev/${tgtdrive} set 2 boot on
+parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424
+sleep 3
+hdparm -z /dev/${tgtdrive}
+
+# partition
+cat << EOF > /tmp/partition.ks
+part swap --asprimary --fstype="swap" --ondisk=sda --size=4096
+part /boot --asprimary --fstype="ext3" --ondisk=sda --size=500
+part pv.64 --fstype="lvmpv" --ondisk=sda --grow
+volgroup os --pesize=4096 pv.64
+logvol /var --fstype="ext3" --grow --percent=40 --name=varvol --vgname=os
+logvol /tmp --fstype="ext3" --grow --percent=5 --name=tmpvol --vgname=os
+logvol / --fstype="ext3" --grow --percent=50 --name=rootvol --vgname=os
+logvol /home --fstype="ext3" --grow --percent=5 --name=homevol --vgname=os
+EOF
+
+# bootloader setting
+echo "bootloader --location=mbr --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks
+%end
+
+%post
+echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules
+chmod +x /etc/rc.modules
+echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf
+mkdir -p /var/log/coredump
+echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf
+
+chmod 777 /var/log/coredump
+echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf
+%end
+
+%post --nochroot --log=/root/anaconda-post-before-chroot.log
+#!/bin/sh
+set -x
+SOURCE="/mnt/sysimage/tmp/source"
+for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
+
+mkdir -p "${SOURCE}"
+mount -o bind "/mnt/install/source" "${SOURCE}"
+%end
+
+%post --logfile /var/log/post_install.log
+set -x -v
+exec 1>/root/ks-post.log 2>&1
+
+function save_nic_cfg() {
+ scrFile="/etc/sysconfig/network-scripts/ifcfg-$1"
+ sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network
+ grep -q "^\s*$2\s+$hostname" /etc/hosts || echo "$2 $hostname" >> /etc/hosts
+
+ echo DEVICE=$1> $scrFile
+ echo ONBOOT=yes >> $scrFile
+ echo NM_CONTROLLED=no >> $scrFile
+ echo HWADDR=$4 >> $scrFile
+ echo USERCTL=no >> $scrFile
+ echo PEERDNS=no >> $scrFile
+ echo BOOTPROTO=static >> $scrFile
+ echo IPADDR=$2 >> $scrFile
+ echo NETMASK=$3 >> $scrFile
+}
+
+function save_gateway() {
+ echo GATEWAY=$external_gw >> /etc/sysconfig/network
+ search="domain $domain\nsearch $domain"
+ echo -e "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf
+ [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf
+ [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream
+ [ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf
+ [ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream
+
+ if [[ -z "$dns1" && -z "$dns2" ]]; then
+ if [[ -z $external_gw ]]; then
+ echo "nameserver $gw" >> /etc/resolv.conf
+ else
+ echo "nameserver $external_gw" >> /etc/resolv.conf
+ fi
+ fi
+}
+# Default FQDN
+hostname="open-o"
+
+for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
+domain=$hostname
+
+external_ip=$external_ip
+external_netmask=$external_mask
+external_intf="eth0"
+#external_hwaddr=`ifconfig $external_intf | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
+
+save_nic_cfg $external_intf $external_ip $external_netmask $external_hwaddr
+
+save_gateway
+
+SOURCE=/tmp/source
+mkdir -p /root/.ssh
+chmod 700 /root/.ssh
+cat ${SOURCE}/bootstrap/boot.rsa.pub >> /root/.ssh/authorized_keys
+
+%end
+
+%packages --nobase
+@core
+%end
diff --git a/util/libvirt.xml b/util/libvirt.xml
new file mode 100644
index 0000000..e208223
--- /dev/null
+++ b/util/libvirt.xml
@@ -0,0 +1,64 @@
+<domain type='kvm'>
+ <name>open-o</name>
+ <memory unit='MiB'>REPLACE_MEM</memory>
+ <currentMemory unit='MiB'>REPLACE_MEM</currentMemory>
+ <vcpu placement='static'>REPLACE_CPU</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
+ <boot dev='hd'/>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <cpu mode='host-model'>
+ <model fallback='allow'/>
+ <feature policy='optional' name='vmx'/>
+ <feature policy='optional' name='svm'/>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/kvm-spice</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2'/>
+ <source file='REPLACE_IMAGE'/>
+ <target dev='vda' bus='ide'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='REPLACE_ISO'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <interface type='network'>
+ <source network='REPLACE_NET_EXTERNAL'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </interface>
+ <interface type='network'>
+ <source network='default'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='en-us'>
+ <listen type='address' address='0.0.0.0'/>
+ </graphics>
+ <video>
+ <model type='cirrus' vram='9216' heads='1'/>
+ </video>
+ </devices>
+</domain>
diff --git a/util/log.sh b/util/log.sh
new file mode 100755
index 0000000..c19f563
--- /dev/null
+++ b/util/log.sh
@@ -0,0 +1,24 @@
+#!/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 log_info() {
+ echo -e "\033[32m$*\033[0m"
+}
+
+function log_warn() {
+ echo -e "\033[33m$*\033[0m"
+}
+
+function log_error() {
+ echo -e "\033[31m$*\033[0m"
+}
+
+function log_progress() {
+ echo -en "\033[33m$*\r\033[0m"
+}