1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
12 scp -q $deafile root@${fuelIp}:. || error_exit "Could not copy DEA file to Fuel"
13 echo "Uploading build tools to Fuel server"
14 ssh root@${fuelIp} rm -rf tools || error_exit "Error cleaning old tools structure"
15 scp -qrp $topdir/tools root@${fuelIp}:. || error_exit "Error copying tools"
17 # Refuse to run if environment already present
18 envcnt=`fuel env | tail -n +3 | grep -v '^$' | wc -l`
19 if [ $envcnt -ne 0 ]; then
20 error_exit "Environment count is $envcnt"
23 # Refuse to run if any nodes are up
24 nodeCnt=`numberOfNodesUp`
25 if [ $nodeCnt -ne 0 ]; then
26 error_exit "Nodes are up (node count: $nodeCnt)"
29 # FIXME: Add support for CentOS creation here
30 # Extract release ID for Ubuntu environment
31 ubuntucnt=`fuel release | grep Ubuntu | wc -l`
32 if [ $ubuntucnt -ne 1 ]; then
33 error_exit "Not exacly one Ubuntu release found"
36 # FIXME: Make release a property in the dea.yaml and use that instead!
37 ubuntuid=`fuel release | grep Ubuntu | awk '{ print $1 }'`
40 envName=`dea getProperty environment_name` || error_exit "Could not get environment name"
41 envMode=`dea getProperty environment_mode` || error_exit "Could not get environment mode"
43 fuel env create --name $envName \
46 --network-mode neutron \
47 --net-segment-type vlan \
48 || error_exit "Error creating environment"
50 envId=`ssh root@${fuelIp} fuel env | tail -n +3 | awk '{ print $1 }'` \
51 || error_exit "Could not get environment id"
53 echo "Running transplant #1"
54 ssh root@${fuelIp} "cd tools; ./transplant1.sh ../`basename $deafile`" \
55 || error_exit "Error running transplant sequence #1"
58 strategy=`dha getPowerOnStrategy` || error_exit "Could not get power on strategy"
59 if [ $strategy == "all" ]; then
60 echo "Starting all nodes at once"
62 for id in `dha getAllNodeIds`
64 if [ $id -ne $fuelNodeId ]; then
65 echo "Setting boot order pxe disk for node $id"
66 dha nodeSetBootOrder $id "pxe disk" || "Could not set boot order for node"
67 echo "Powering on node $id"
68 dha nodePowerOn $id || error_exit "Could not power on node"
69 poweredOn=$[poweredOn + 1]
72 # Wait for all nodes to be accounted for
73 echo "Waiting for $poweredOn nodes to come up"
76 nodesUp=`numberOfNodesUp`
77 echo -n "[${nodesUp}]"
78 if [ $nodesUp -eq $poweredOn ]; then
85 # Refuse to run if any nodes are defined
86 totalNodeCnt=`numberOfNodes`
87 if [ $totalNodeCnt -ne 0 ]; then
88 error_exit "There are already ${totalNodeCnt} defined nodes, can not run power on in sequence!"
90 echo "Starting nodes sequentially, waiting for Fuel detection until proceeding"
91 for id in `dha getAllNodeIds`
93 if [ $id -ne $fuelNodeId ]; then
94 echo "Setting boot order pxe disk for node $id"
95 dha nodeSetBootOrder $id "pxe disk" || "Could not set boot order for node"
96 echo "Powering on node $id"
97 dha nodePowerOn $id || error_exit "Could not power on node"
98 # Wait for node count to increase
104 # Set roles for detected hosts
105 for id in `dha getAllNodeIds`
108 if [ $fuelNodeId -ne $id ]; then
109 longMac=`dha getNodePxeMac $id` || \
110 error_exit "Could not get MAC address for node $id from DHA"
111 shortMac=`dea convertMacToShortMac $longMac`
112 role="`dea getNodeRole $id`"
113 echo "Setting role $role for Fuel node $shortMac (DEA node $id)"
114 fuel node set --node-id $shortMac --role $role --env $envId \
115 || error_exit "Could not set role for $node"
119 # Run pre-deploy with default input
120 # Need to set terminal as script does "clear" and needs curses support
121 ssh root@${fuelIp} "TERM=vt100 /opt/opnfv/pre-deploy.sh < /dev/null" \
122 || error_exit "Pre-deploy failed"
124 # Inject node network config (will override pre-deploy Astute settings but we
125 # want to catch pre-deploy provisioning changes)
126 # TODO: There needs to be a function to adjust the NTP settings for clients
127 # TODO: to that of the actual set of controllers in this deployment.
128 echo "Running transplant #2"
129 ssh root@${fuelIp} "cd tools; ./transplant2.sh ../`basename $deafile`" \
130 || error_exit "Error running transplant sequence #2"
135 ssh root@${fuelIp} "fuel deploy-changes --env $envId" >/dev/null 2>&1 || error_exit "Deploy failed"
136 echo "Deployment completed"