5 #need to put multiple 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
19 jujuver=`juju --version`
22 opnfvrel=`grep release: deploy.yaml | cut -d ":" -f2`
23 openstack=`grep openstack: deploy.yaml | cut -d ":" -f2`
24 opnfvtype=`grep type: deploy.yaml | cut -d ":" -f2`
25 opnfvlab=`grep lab: deploy.yaml | cut -d ":" -f2`
26 opnfvsdn=`grep sdn: deploy.yaml | cut -d ":" -f2`
29 usage() { echo "Usage: $0 [-s <nosdn|odl|opencontrail>]
32 [-l <default|intelpod5>]
33 [-f <ipv6,dpdk,lxd,dvr>]
36 [-m <openstack|kubernetes>]
38 [-r <a|b>]" 1>&2 exit 1; }
40 while getopts ":s:t:o:l:h:r:f:d:a:m:i:" opt; do
58 opnfvfeature=${OPTARG}
80 #by default maas creates two VMs in case of three more VM needed.
82 # TODO: make sure this function run with the same parameters used in 03-maasdeploy.sh
83 PROFILE=${PROFILE:-ubuntu}
84 MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
85 API_SERVER="http://$MAAS_IP:5240/MAAS/api/2.0"
86 API_KEY=`sudo maas-region apikey --username=ubuntu`
87 maas login $PROFILE $API_SERVER $API_KEY
89 for node in node3-control node4-control
91 node_id=$(maas $PROFILE machines read | \
92 jq -r ".[] | select(.hostname == \"$node\").system_id")
93 if [[ -z "$node_id" ]]; then
94 sudo virt-install --connect qemu:///system --name $node \
95 --ram 8192 --cpu host --vcpus 4 \
96 --disk size=120,format=qcow2,bus=virtio,cache=directsync,io=native,pool=default \
97 --network bridge=virbr0,model=virtio \
98 --network bridge=virbr0,model=virtio \
99 --boot network,hd,menu=off \
100 --noautoconsole --vnc --print-xml | tee _node.xml
101 node_mac=$(grep "mac address" _node.xml | head -1 | cut -d "'" -f 2)
102 sudo virsh -c qemu:///system define --file _node.xml
105 maas $PROFILE nodes new autodetect_nodegroup='yes' name=$node \
106 tags='control' hostname=$name power_type='virsh' \
107 mac_addresses=$node3controlmac \
108 power_parameters_power_address="qemu+ssh://$USER@192.168.122.1/system" \
109 architecture='amd64/generic' power_parameters_power_id='node3-control'
110 node_id=$(maas $PROFILE machines read | \
111 jq -r ".[] | select(.hostname == \"$node\").system_id")
113 if [[ -z "$node_id" ]]; then
114 echo "Error: failed to create node $node ."
117 maas $PROFILE tag update-nodes control add=$node_id || true
121 #copy the files and create extra resources needed for HA deployment
122 # in case of default VM labs.
124 if [[ "$jujuver" > "2" ]]; then
125 if [ ! -f ./labconfig.yaml ] && [ -e ~/joid_config/labconfig.yaml ]; then
126 cp ~/joid_config/labconfig.yaml ./labconfig.yaml
128 if [ ! -f ./deployconfig.yaml ] && [ -e ~/joid_config/deployconfig.yaml ]; then
129 cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml
131 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
134 if [ -e ./labconfig.yaml ]; then
135 if [ ! -f ./deployconfig.yaml ] && [ -e ~/joid_config/deployconfig.yaml ]; then
136 cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml
138 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
141 echo " MAAS not deployed please deploy MAAS first."
145 #create json file which is missing in case of new deployment after maas and git tree cloned freshly.
146 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < labconfig.yaml > labconfig.json
147 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < deployconfig.yaml > deployconfig.json
150 if [ ! -f ./environments.yaml ] && [ -e ~/.juju/environments.yaml ]; then
151 cp ~/.juju/environments.yaml ./environments.yaml
152 elif [ ! -f ./environments.yaml ] && [ -e ~/joid_config/environments.yaml ]; then
153 cp ~/joid_config/environments.yaml ./environments.yaml
155 #copy the script which needs to get deployed as part of ofnfv release
156 echo "...... deploying now ......"
157 echo " " >> environments.yaml
158 echo " enable-os-refresh-update: false" >> environments.yaml
159 echo " enable-os-upgrade: false" >> environments.yaml
160 echo " admin-secret: admin" >> environments.yaml
161 echo " default-series: $opnfvdistro" >> environments.yaml
162 cp environments.yaml ~/.juju/
163 cp environments.yaml ~/joid_config/
166 if [[ "$opnfvtype" = "ha" && "$opnfvlab" = "default" ]]; then
173 if [[ "$jujuver" > "2" ]]; then
174 juju model-config default-series=$opnfvdistro enable-os-refresh-update=false enable-os-upgrade=false
177 #case default deploy the opnfv platform:
178 ./02-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro $opnfvmodel
181 #check whether charms are still executing the code even juju-deployer says installed.
187 echo -n "executing the relationship within charms ."
188 while [ $retval -eq 0 ]; do
189 if juju status | grep -q $waitstatus; then
191 if [ $timeoutiter -ge 180 ]; then
197 timeoutiter=$((timeoutiter+1))
204 if [[ "$opnfvmodel" = "openstack" ]]; then
205 juju expose ceph-radosgw || true
206 #juju ssh ceph/0 \ 'sudo radosgw-admin user create --uid="ubuntu" --display-name="Ubuntu Ceph"'
209 echo "...... deployment finishing ......."
212 # In the case of a virtual deployment
213 if [ "$virtinstall" -eq 1 ]; then
217 echo "...... deployment started ......"
220 check_status executing
222 echo "...... deployment finished ......."
225 echo "...... configuring public access ......."
227 # translate bundle.yaml to json
228 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < bundles.yaml > bundles.json
229 # get services list having a public interface
230 srv_list=$(cat bundles.json | jq -r ".services | to_entries[] | {\"key\": .key, \"value\": .value[\"bindings\"]} | select (.value!=null) | select(.value[] | contains(\"public-api\"))".key)
231 # get cnt list from service list
232 cnt_list=$(for cnt in $srv_list; do juju status $cnt --format=json | jq -r ".machines[].containers | to_entries[]".key; done)
233 # get public network gateway (supposing it is the first ip of the network)
234 public_api_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"public\")".gateway)
235 admin_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"admin\")".gateway)
237 if ([ $admin_gw ] && [ $admin_gw != "null" ]); then
238 # set default gateway to public api gateway
239 for cnt in $cnt_list; do
240 echo "changing default gw on $cnt"
241 if ([ $public_api_gw ] && [ $public_api_gw != "null" ]); then
242 juju ssh $cnt "sudo ip r d default && sudo ip r a default via $public_api_gw";
243 juju ssh $cnt "gw_dev=\$(ip r l | grep 'via $public_api_gw' | cut -d \ -f5) &&\
244 sudo cp /etc/network/interfaces /etc/network/interfaces.bak &&\
245 echo 'removing old default gateway' &&\
246 sudo perl -i -pe 's/^\ *gateway $admin_gw\n$//' /etc/network/interfaces &&\
247 sudo perl -i -pe \"s/iface \$gw_dev inet static/iface \$gw_dev inet static\\n gateway $public_api_gw/\" /etc/network/interfaces \
253 echo "...... configure ......."
255 if ([ $opnfvmodel == "openstack" ]); then
256 ./openstack.sh "$opnfvsdn" "$opnfvlab" "$opnfvdistro" "$openstack" || true
258 # creating heat domain after pushing the public API into /etc/hosts
259 if [[ "$jujuver" > "2" ]]; then
260 status=`juju run-action heat/0 domain-setup`
263 status=`juju action do heat/0 domain-setup`
267 sudo ../juju/get-cloud-images || true
268 ../juju/joid-configure-openstack || true
270 if grep -q 'openbaton' bundles.yaml; then
271 juju add-relation openbaton keystone
274 elif ([ $opnfvmodel == "kubernetes" ]); then
278 # expose the juju gui-url to login into juju gui
280 echo " ...... JUJU GUI can be access using the below URL ...... "
281 juju gui --show-credentials --no-browser
283 echo "...... finished ......."