7 #need to put multiple cases here where decide this bundle to deploy by default use the odl bundle.
8 # Below parameters are the default and we can according the release
23 jujuver=`juju --version`
25 usage() { echo "Usage: $0
26 [-s|--sdn <nosdn|odl|opencontrail>]
27 [-t|--type <noha|ha|tip>]
28 [-o|--openstack <ocata>]
29 [-l|--lab <default|custom>]
30 [-f|--feature <ipv6,dpdk,lxd,dvr,openbaton>]
31 [-d|--distro <xenial>]
32 [-a|--arch <amd64|ppc64el|aarch64>]
33 [-m|--model <openstack|kubernetes>]
34 [-i|--virtinstall <0|1>]
36 [--labfile <labvonfig.yaml file>]
37 [-r|--release <e>]" 1>&2 exit 1;
40 #A string with command options
43 # An array with all the arguments
49 for argument in $options
52 index=`expr $index + 1`
60 if ([ "arguments[index]" != "" ]); then
61 opnfvsdn=${arguments[index]}
65 if ([ "arguments[index]" != "" ]); then
66 opnfvtype=${arguments[index]}
70 if ([ "arguments[index]" != "" ]); then
71 openstack=${arguments[index]}
76 if ([ "arguments[index]" != "" ]); then
77 opnfvlab=${arguments[index]}
82 if ([ "arguments[index]" != "" ]); then
83 opnfvrel=${arguments[index]}
88 if ([ "arguments[index]" != "" ]); then
89 opnfvfeature=${arguments[index]}
94 if ([ "arguments[index]" != "" ]); then
95 opnfdistro=${arguments[index]}
100 if ([ "arguments[index]" != "" ]); then
101 opnfvarch=${arguments[index]}
106 if ([ "arguments[index]" != "" ]); then
107 opnfvmodel=${arguments[index]}
112 if ([ "arguments[index]" != "" ]); then
113 virtinstall=${arguments[index]}
117 if ([ "arguments[index]" != "" ]); then
118 maasinstall=${arguments[index]}
122 if ([ "arguments[index]" != "" ]); then
123 labfile=${arguments[index]}
130 #by default maas creates two VMs in case of three more VM needed.
132 # TODO: make sure this function run with the same parameters used in 03-maasdeploy.sh
133 PROFILE=${PROFILE:-ubuntu}
134 MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
135 API_SERVER="http://$MAAS_IP:5240/MAAS/api/2.0"
136 API_KEY=`sudo maas-region apikey --username=ubuntu`
137 maas login $PROFILE $API_SERVER $API_KEY
139 # if we have a virshurl configuration we use it, else we use local
140 VIRSHURL=$(cat labconfig.json | jq -r '.opnfv.virshurl')
141 if ([ $VIRSHURL == "" ] || [ "$VIRSHURL" == "null" ]); then
143 VIRSHURL="qemu+ssh://$USER@$VIRSHIP/system "
146 VIRSHHOST=$(echo $VIRSHURL| cut -d\/ -f 3 | cut -d@ -f2)
147 VIRSHIP="" # TODO: parse from $VIRSHURL if needed
150 for node in node3-control node4-control
152 node_id=$(maas $PROFILE machines read | \
153 jq -r ".[] | select(.hostname == \"$node\").system_id")
154 if [[ -z "$node_id" ]]; then
155 sudo virt-install --connect qemu:///system --name $node \
156 --ram 8192 --cpu host --vcpus 4 \
157 --disk size=120,format=qcow2,bus=virtio,cache=directsync,io=native,pool=default \
158 --network bridge=virbr0,model=virtio \
159 --network bridge=virbr0,model=virtio \
160 --boot network,hd,menu=off \
161 --noautoconsole --vnc --print-xml | tee _node.xml
162 node_mac=$(grep "mac address" _node.xml | head -1 | cut -d "'" -f 2)
163 sudo virsh -c $VIRSHURL define --file _node.xml
166 maas $PROFILE nodes new autodetect_nodegroup='yes' name=$node \
167 tags='control' hostname=$name power_type='virsh' \
168 mac_addresses=$node3controlmac \
169 power_parameters_power_address="qemu+ssh://$USER@192.168.122.1/system" \
170 architecture='amd64/generic' power_parameters_power_id='node3-control'
171 sudo virsh -c $VIRSHURL autostart $node
172 node_id=$(maas $PROFILE machines read | \
173 jq -r ".[] | select(.hostname == \"$node\").system_id")
175 if [[ -z "$node_id" ]]; then
176 echo_error "Error: failed to create node $node ."
179 maas $PROFILE tag update-nodes control add=$node_id || true
183 #copy the files and create extra resources needed for HA deployment
184 # in case of default VM labs.
186 if [ ! -f ./labconfig.yaml ] && [ -e ~/joid_config/labconfig.yaml ]; then
187 cp ~/joid_config/labconfig.yaml ./labconfig.yaml
189 if [ ! -f ./deployconfig.yaml ] && [ -e ~/joid_config/deployconfig.yaml ]; then
190 cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml
192 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
195 if [ -e ./labconfig.yaml ]; then
196 if [ ! -f ./deployconfig.yaml ] && [ -e ~/joid_config/deployconfig.yaml ]; then
197 cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml
199 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
202 echo_error "MAAS not deployed please deploy MAAS first."
206 #create json file which is missing in case of new deployment after maas and git tree cloned freshly.
207 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < labconfig.yaml > labconfig.json
208 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < deployconfig.yaml > deployconfig.json
210 # Install MAAS and expecting the labconfig.yaml at local directory.
212 if [ "$maasinstall" -eq 1 ]; then
214 PROFILE=${PROFILE:-ubuntu}
215 MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
216 API_SERVER="http://$MAAS_IP:5240/MAAS/api/2.0"
217 if which maas > /dev/null; then
218 API_KEY=`sudo maas-region apikey --username=ubuntu`
219 maas login $PROFILE $API_SERVER $API_KEY
221 # make sure there is no machine entry in maas
222 for m in $(maas $PROFILE machines read | jq -r '.[].system_id')
224 maas $PROFILE machine delete $m || true
226 podno=$(maas $PROFILE pods read | jq -r ".[]".id)
227 maas $PROFILE pod delete $podno || true
231 if [ "$virtinstall" -eq 1 ]; then
232 ./00-maasdeploy.sh virtual
234 if [ -z "$labfile" ]; then
235 if [ ! -e ./labconfig.yaml ]; then
236 echo_error "Labconfig file must be specified when using custom"
238 echo_warning "Labconfig was not specified, using ./labconfig.yaml instead"
240 elif [ ! -e "$labfile" ]; then
241 echo_warning "Labconfig not found locally, trying download"
242 wget $labfile -t 3 -T 10 -O ./labconfig.yaml || true
243 count=`wc -l labconfig.yaml | cut -d " " -f 1`
244 if [ $count -lt 10 ]; then
245 echo_error "Unable to download labconfig"
249 echo_info "Using $labfile to setup deployment"
250 cp $labfile ./labconfig.yaml
253 ./00-maasdeploy.sh custom
257 if [[ "$opnfvtype" = "ha" && "$opnfvlab" = "default" ]]; then
264 juju model-config default-series=$opnfvdistro enable-os-refresh-update=false enable-os-upgrade=false
266 # case default deploy the opnfv platform:
267 ./02-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro $opnfvmodel
270 #check whether charms are still executing the code even juju-deployer says installed.
276 echo_info "Executing the relationships within charms..."
277 while [ $retval -eq 0 ]; do
278 if juju status | grep -q $waitstatus; then
279 echo_info "Still waiting for $waitstatus units"
280 if [ $timeoutiter -ge 180 ]; then
281 echo_error 'Timed out'
286 timeoutiter=$((timeoutiter+1))
288 echo_info 'Done executing the relationships'
293 if [[ "$opnfvmodel" = "openstack" ]]; then
294 juju expose ceph-radosgw || true
295 #juju ssh ceph/0 \ 'sudo radosgw-admin user create --uid="ubuntu" --display-name="Ubuntu Ceph"'
298 echo_info "Deployment finishing..."
302 # In the case of a virtual deployment
303 if [ "$virtinstall" -eq 1 ]; then
307 echo_info "Deployment started"
310 check_status executing
312 echo_info "Deployment finished"
313 juju status --format=tabular
315 # translate bundle.yaml to json
316 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < bundles.yaml > bundles.json
318 # Configuring deployment
319 if ([ $opnfvmodel == "openstack" ]); then
320 echo_info "Configuring OpenStack deployment"
322 ./openstack.sh "$opnfvsdn" "$opnfvlab" "$opnfvdistro" "$openstack" || true
324 # creating heat domain after pushing the public API into /etc/hosts
325 if [[ "$jujuver" > "2" ]]; then
326 status=`juju run-action heat/0 domain-setup`
329 status=`juju action do heat/0 domain-setup`
333 sudo ../juju/get-cloud-images || true
334 ../juju/joid-configure-openstack || true
336 if grep -q 'openbaton' bundles.yaml; then
337 juju add-relation openbaton keystone
340 elif ([ $opnfvmodel == "kubernetes" ]); then
341 #Workarounf for master chanrm as it takes 5 minutes to run properly
343 check_status executing
344 echo_info "Configuring Kubernetes deployment"
349 # expose the juju gui-url to login into juju gui
351 echo_info "Juju GUI can be accessed using the following URL and credentials:"
352 juju gui --show-credentials --no-browser
354 echo "Finished deployment and configuration"