5 #need to put mutiple cases here where decide this bundle to deploy by default use the odl bundle.
6 # Below parameters are the default and we can according the release
18 jujuver=`juju --version`
21 opnfvrel=`grep release: deploy.yaml | cut -d ":" -f2`
22 openstack=`grep openstack: deploy.yaml | cut -d ":" -f2`
23 opnfvtype=`grep type: deploy.yaml | cut -d ":" -f2`
24 opnfvlab=`grep lab: deploy.yaml | cut -d ":" -f2`
25 opnfvsdn=`grep sdn: deploy.yaml | cut -d ":" -f2`
28 usage() { echo "Usage: $0 [-s <nosdn|odl|opencontrail>]
31 [-l <default|intelpod5>]
32 [-f <ipv6,dpdk,lxd,dvr>]
35 [-m <openstack|kubernetes>]
36 [-r <a|b>]" 1>&2 exit 1; }
38 while getopts ":s:t:o:l:h:r:f:d:a:m:" opt; do
56 opnfvfeature=${OPTARG}
75 #by default maas creates two VMs in case of three more VM needed.
77 # TODO: make sure this function run with the same parameters used in 03-maasdeploy.sh
78 PROFILE=${PROFILE:-ubuntu}
79 MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
80 API_SERVER="http://$MAAS_IP/MAAS/api/2.0"
81 API_KEY=`sudo maas-region apikey --username=ubuntu`
82 maas login $PROFILE $API_SERVER $API_KEY
84 for node in node3-control node4-control
86 node_id=$(maas $PROFILE machines read | \
87 jq -r ".[] | select(.hostname == \"$node\").system_id")
88 if [[ -z "$node_id" ]]; then
89 sudo virt-install --connect qemu:///system --name $node \
90 --ram 8192 --cpu host --vcpus 4 \
91 --disk size=120,format=qcow2,bus=virtio,cache=directsync,io=native,pool=default \
92 --network bridge=virbr0,model=virtio \
93 --network bridge=virbr0,model=virtio \
94 --boot network,hd,menu=off \
95 --noautoconsole --vnc --print-xml | tee _node.xml
96 node_mac=$(grep "mac address" _node.xml | head -1 | cut -d "'" -f 2)
97 sudo virsh -c qemu:///system define --file _node.xml
100 maas $PROFILE nodes new autodetect_nodegroup='yes' name=$node \
101 tags='control' hostname=$name power_type='virsh' \
102 mac_addresses=$node3controlmac \
103 power_parameters_power_address="qemu+ssh://$USER@192.168.122.1/system" \
104 architecture='amd64/generic' power_parameters_power_id='node3-control'
105 node_id=$(maas $PROFILE machines read | \
106 jq -r ".[] | select(.hostname == \"$node\").system_id")
108 if [[ -z "$node_id" ]]; then
109 echo "Error: failed to create node $node ."
112 maas $PROFILE tag update-nodes control add=$node_id || true
116 #copy the files and create extra resources needed for HA deployment
117 # in case of default VM labs.
119 if [[ "$jujuver" > "2" ]]; then
120 if [ ! -f ./labconfig.yaml ] && [ -e ~/joid_config/labconfig.yaml ]; then
121 cp ~/joid_config/labconfig.yaml ./labconfig.yaml
123 if [ ! -f ./deployconfig.yaml ] && [ -e ~/joid_config/deployconfig.yaml ]; then
124 cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml
126 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
129 if [ -e ./labconfig.yaml ]; then
130 if [ ! -f ./deployconfig.yaml ] && [ -e ~/joid_config/deployconfig.yaml ]; then
131 cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml
133 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
136 echo " MAAS not deployed please deploy MAAS first."
139 #create json file which is missing in case of new deployment after maas and git tree cloned freshly.
141 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < labconfig.yaml > labconfig.json
142 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < deployconfig.yaml > deployconfig.json
145 if [ ! -f ./environments.yaml ] && [ -e ~/.juju/environments.yaml ]; then
146 cp ~/.juju/environments.yaml ./environments.yaml
147 elif [ ! -f ./environments.yaml ] && [ -e ~/joid_config/environments.yaml ]; then
148 cp ~/joid_config/environments.yaml ./environments.yaml
150 #copy the script which needs to get deployed as part of ofnfv release
151 echo "...... deploying now ......"
152 echo " " >> environments.yaml
153 echo " enable-os-refresh-update: false" >> environments.yaml
154 echo " enable-os-upgrade: false" >> environments.yaml
155 echo " admin-secret: admin" >> environments.yaml
156 echo " default-series: $opnfvdistro" >> environments.yaml
157 cp environments.yaml ~/.juju/
158 cp environments.yaml ~/joid_config/
161 if [[ "$opnfvtype" = "ha" && "$opnfvlab" = "default" ]]; then
168 if [[ "$jujuver" > "2" ]]; then
169 juju model-config default-series=$opnfvdistro enable-os-refresh-update=false enable-os-upgrade=false
172 #case default deploy the opnfv platform:
173 ./02-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro $opnfvmodel
176 #check whether charms are still executing the code even juju-deployer says installed.
181 echo -n "executing the reltionship within charms ."
182 while [ $retval -eq 0 ]; do
184 if juju status | grep -q "executing"; then
186 if [ $timeoutiter -ge 120 ]; then
190 timeoutiter=$((timeoutiter+1))
197 if [[ "$opnfvmodel" = "openstack" ]]; then
198 juju expose ceph-radosgw || true
199 #juju ssh ceph/0 \ 'sudo radosgw-admin user create --uid="ubuntu" --display-name="Ubuntu Ceph"'
201 echo "...... deployment finishing ......."
204 echo "...... deployment started ......"
209 echo "...... deployment finished ......."
212 echo "...... configuring public access ......."
214 # translate bundle.yaml to json
215 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < bundles.yaml > bundles.json
216 # get services list having a public interface
217 srv_list=$(cat bundles.json | jq -r ".services | to_entries[] | {\"key\": .key, \"value\": .value[\"bindings\"]} | select (.value!=null) | select(.value[] | contains(\"public-api\"))".key)
218 # get cnt list from service list
219 cnt_list=$(for cnt in $srv_list; do juju status $cnt --format=json | jq -r ".machines[].containers | to_entries[]".key; done)
220 # get public network gateway (supposing it is the first ip of the network)
221 public_api_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"public\")".gateway)
222 admin_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"admin\")".gateway)
224 if ([ $admin_gw ] && [ $admin_gw != "null" ]); then
225 # set default gateway to public api gateway
226 for cnt in $cnt_list; do
227 echo "changing default gw on $cnt"
228 if ([ $public_api_gw ] && [ $public_api_gw != "null" ]); then
229 juju ssh $cnt "sudo ip r d default && sudo ip r a default via $public_api_gw";
230 juju ssh $cnt "gw_dev=\$(ip r l | grep 'via $public_api_gw' | cut -d \ -f5) &&\
231 sudo cp /etc/network/interfaces /etc/network/interfaces.bak &&\
232 echo 'removing old default gateway' &&\
233 sudo perl -i -pe 's/^\ *gateway $admin_gw\n$//' /etc/network/interfaces &&\
234 sudo perl -i -pe \"s/iface \$gw_dev inet static/iface \$gw_dev inet static\\n gateway $public_api_gw/\" /etc/network/interfaces \
240 echo "...... configure ......."
242 if ([ $opnfvmodel == "openstack" ]); then
243 ./openstack.sh "$opnfvsdn" "$opnfvlab" "$opnfvdistro" "$openstack" || true
245 # creating heat domain after puching the public API into /etc/hosts
246 if [[ "$jujuver" > "2" ]]; then
247 status=`juju run-action heat/0 domain-setup`
250 status=`juju action do heat/0 domain-setup`
254 sudo ../juju/get-cloud-images || true
255 ../juju/joid-configure-openstack || true
257 elif ([ $opnfvmodel == "kubernetes" ]); then
261 # expose the juju gui-url to login into juju gui
263 echo " ...... JUJU GUI can be access using the below URL ...... "
264 juju gui --show-credentials --no-browser
266 echo "...... finished ......."