Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Mate Lakat | 0b3804b | 2013-05-07 16:58:17 +0100 | [diff] [blame] | 3 | # This script must be run on a XenServer or XCP machine |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 4 | # |
| 5 | # It creates a DomU VM that runs OpenStack services |
| 6 | # |
| 7 | # For more details see: README.md |
| 8 | |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 9 | set -o errexit |
Mate Lakat | 0b3804b | 2013-05-07 16:58:17 +0100 | [diff] [blame] | 10 | set -o nounset |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 11 | set -o xtrace |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 12 | |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 13 | # Abort if localrc is not set |
| 14 | if [ ! -e ../../localrc ]; then |
| 15 | echo "You must have a localrc with ALL necessary passwords defined before proceeding." |
| 16 | echo "See the xen README for required passwords." |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
Anthony Young | af6ed6b | 2011-11-02 07:50:27 -0500 | [diff] [blame] | 20 | # This directory |
Mate Lakat | a8bf0f2 | 2013-03-07 18:37:31 +0000 | [diff] [blame] | 21 | THIS_DIR=$(cd $(dirname "$0") && pwd) |
Anthony Young | af6ed6b | 2011-11-02 07:50:27 -0500 | [diff] [blame] | 22 | |
Anthony Young | b3e2f33 | 2012-03-16 17:01:49 -0700 | [diff] [blame] | 23 | # Source lower level functions |
Mate Lakat | a8bf0f2 | 2013-03-07 18:37:31 +0000 | [diff] [blame] | 24 | . $THIS_DIR/../../functions |
Anthony Young | b3e2f33 | 2012-03-16 17:01:49 -0700 | [diff] [blame] | 25 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 26 | # Include onexit commands |
Mate Lakat | a8bf0f2 | 2013-03-07 18:37:31 +0000 | [diff] [blame] | 27 | . $THIS_DIR/scripts/on_exit.sh |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 28 | |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 29 | # xapi functions |
| 30 | . $THIS_DIR/functions |
| 31 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 32 | # |
| 33 | # Get Settings |
| 34 | # |
| 35 | |
Anthony Young | b3e2f33 | 2012-03-16 17:01:49 -0700 | [diff] [blame] | 36 | # Source params - override xenrc params in your localrc to suit your taste |
Mate Lakat | 0b3804b | 2013-05-07 16:58:17 +0100 | [diff] [blame] | 37 | source $THIS_DIR/xenrc |
Anthony Young | af6ed6b | 2011-11-02 07:50:27 -0500 | [diff] [blame] | 38 | |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 39 | xe_min() |
| 40 | { |
| 41 | local cmd="$1" |
| 42 | shift |
| 43 | xe "$cmd" --minimal "$@" |
| 44 | } |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 45 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 46 | # |
| 47 | # Prepare Dom0 |
| 48 | # including installing XenAPI plugins |
| 49 | # |
| 50 | |
Mate Lakat | a8bf0f2 | 2013-03-07 18:37:31 +0000 | [diff] [blame] | 51 | cd $THIS_DIR |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 52 | |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 53 | # Install plugins |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 54 | |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 55 | ## Nova plugins |
| 56 | NOVA_ZIPBALL_URL=${NOVA_ZIPBALL_URL:-$(zip_snapshot_location $NOVA_REPO $NOVA_BRANCH)} |
| 57 | install_xapi_plugins_from_zipball $NOVA_ZIPBALL_URL |
Maru Newby | 2298ca4 | 2012-10-25 23:46:42 +0000 | [diff] [blame] | 58 | |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 59 | ## Install the netwrap xapi plugin to support agent control of dom0 networking |
Maru Newby | 2298ca4 | 2012-10-25 23:46:42 +0000 | [diff] [blame] | 60 | if [[ "$ENABLED_SERVICES" =~ "q-agt" && "$Q_PLUGIN" = "openvswitch" ]]; then |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 61 | QUANTUM_ZIPBALL_URL=${QUANTUM_ZIPBALL_URL:-$(zip_snapshot_location $QUANTUM_REPO $QUANTUM_BRANCH)} |
| 62 | install_xapi_plugins_from_zipball $QUANTUM_ZIPBALL_URL |
Maru Newby | 2298ca4 | 2012-10-25 23:46:42 +0000 | [diff] [blame] | 63 | fi |
| 64 | |
Mate Lakat | 57e3da9 | 2013-03-22 16:34:05 +0000 | [diff] [blame] | 65 | create_directory_for_kernels |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 66 | |
| 67 | # |
| 68 | # Configure Networking |
| 69 | # |
Mate Lakat | 9e32677 | 2013-05-08 16:42:22 +0100 | [diff] [blame] | 70 | setup_network "$VM_BRIDGE_OR_NET_NAME" |
| 71 | setup_network "$MGT_BRIDGE_OR_NET_NAME" |
| 72 | setup_network "$PUB_BRIDGE_OR_NET_NAME" |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 73 | |
Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 74 | # With quantum, one more network is required, which is internal to the |
| 75 | # hypervisor, and used by the VMs |
| 76 | if is_service_enabled quantum; then |
| 77 | setup_network "$XEN_INT_BRIDGE_OR_NET_NAME" |
| 78 | fi |
| 79 | |
Mate Lakat | 9e32677 | 2013-05-08 16:42:22 +0100 | [diff] [blame] | 80 | if parameter_is_specified "FLAT_NETWORK_BRIDGE"; then |
| 81 | cat >&2 << EOF |
| 82 | ERROR: FLAT_NETWORK_BRIDGE is specified in localrc file |
| 83 | This is considered as an error, as its value will be derived from the |
| 84 | VM_BRIDGE_OR_NET_NAME variable's value. |
| 85 | EOF |
| 86 | exit 1 |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 87 | fi |
| 88 | |
Mate Lakat | 9e32677 | 2013-05-08 16:42:22 +0100 | [diff] [blame] | 89 | if ! xenapi_is_listening_on "$MGT_BRIDGE_OR_NET_NAME"; then |
| 90 | cat >&2 << EOF |
| 91 | ERROR: XenAPI does not have an assigned IP address on the management network. |
| 92 | please review your XenServer network configuration / localrc file. |
| 93 | EOF |
| 94 | exit 1 |
| 95 | fi |
| 96 | |
| 97 | HOST_IP=$(xenapi_ip_on "$MGT_BRIDGE_OR_NET_NAME") |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 98 | |
| 99 | # Set up ip forwarding, but skip on xcp-xapi |
John Garbutt | d8f1a87 | 2012-06-26 11:16:38 +0100 | [diff] [blame] | 100 | if [ -a /etc/sysconfig/network ]; then |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 101 | if ! grep -q "FORWARD_IPV4=YES" /etc/sysconfig/network; then |
| 102 | # FIXME: This doesn't work on reboot! |
| 103 | echo "FORWARD_IPV4=YES" >> /etc/sysconfig/network |
| 104 | fi |
| 105 | fi |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 106 | # Also, enable ip forwarding in rc.local, since the above trick isn't working |
| 107 | if ! grep -q "echo 1 >/proc/sys/net/ipv4/ip_forward" /etc/rc.local; then |
| 108 | echo "echo 1 >/proc/sys/net/ipv4/ip_forward" >> /etc/rc.local |
| 109 | fi |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 110 | # Enable ip forwarding at runtime as well |
| 111 | echo 1 > /proc/sys/net/ipv4/ip_forward |
| 112 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 113 | |
| 114 | # |
Anthony Young | 346e491 | 2011-11-05 00:22:47 -0500 | [diff] [blame] | 115 | # Shutdown previous runs |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 116 | # |
| 117 | |
Anthony Young | 346e491 | 2011-11-05 00:22:47 -0500 | [diff] [blame] | 118 | DO_SHUTDOWN=${DO_SHUTDOWN:-1} |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 119 | CLEAN_TEMPLATES=${CLEAN_TEMPLATES:-false} |
Anthony Young | 346e491 | 2011-11-05 00:22:47 -0500 | [diff] [blame] | 120 | if [ "$DO_SHUTDOWN" = "1" ]; then |
Anthony Young | 40b5737 | 2011-11-05 00:30:07 -0500 | [diff] [blame] | 121 | # Shutdown all domU's that created previously |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 122 | clean_templates_arg="" |
| 123 | if $CLEAN_TEMPLATES; then |
| 124 | clean_templates_arg="--remove-templates" |
| 125 | fi |
| 126 | ./scripts/uninstall-os-vpx.sh $clean_templates_arg |
Anthony Young | 346e491 | 2011-11-05 00:22:47 -0500 | [diff] [blame] | 127 | |
| 128 | # Destroy any instances that were launched |
| 129 | for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do |
| 130 | echo "Shutting down nova instance $uuid" |
| 131 | xe vm-unpause uuid=$uuid || true |
Armando Migliaccio | 7a5f7f2 | 2012-04-20 22:58:00 +0100 | [diff] [blame] | 132 | xe vm-shutdown uuid=$uuid || true |
Anthony Young | 346e491 | 2011-11-05 00:22:47 -0500 | [diff] [blame] | 133 | xe vm-destroy uuid=$uuid |
| 134 | done |
Anthony Young | fa4ecc6 | 2011-11-11 10:23:22 -0800 | [diff] [blame] | 135 | |
| 136 | # Destroy orphaned vdis |
| 137 | for uuid in `xe vdi-list | grep -1 Glance | grep uuid | sed "s/.*\: //g"`; do |
| 138 | xe vdi-destroy uuid=$uuid |
| 139 | done |
Anthony Young | 346e491 | 2011-11-05 00:22:47 -0500 | [diff] [blame] | 140 | fi |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 141 | |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 142 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 143 | # |
| 144 | # Create Ubuntu VM template |
| 145 | # and/or create VM from template |
| 146 | # |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 147 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 148 | GUEST_NAME=${GUEST_NAME:-"DevStackOSDomU"} |
John Garbutt | d8f1a87 | 2012-06-26 11:16:38 +0100 | [diff] [blame] | 149 | TNAME="devstack_template" |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 150 | SNAME_PREPARED="template_prepared" |
| 151 | SNAME_FIRST_BOOT="before_first_boot" |
| 152 | |
| 153 | function wait_for_VM_to_halt() { |
Bob Ball | 63c6c2b | 2013-01-24 13:13:51 +0000 | [diff] [blame] | 154 | set +x |
| 155 | echo "Waiting for the VM to halt. Progress in-VM can be checked with vncviewer:" |
| 156 | mgmt_ip=$(echo $XENAPI_CONNECTION_URL | tr -d -c '1234567890.') |
| 157 | domid=$(xe vm-list name-label="$GUEST_NAME" params=dom-id minimal=true) |
| 158 | port=$(xenstore-read /local/domain/$domid/console/vnc-port) |
| 159 | echo "vncviewer -via $mgmt_ip localhost:${port:2}" |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 160 | while true |
| 161 | do |
| 162 | state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted) |
| 163 | if [ -n "$state" ] |
| 164 | then |
| 165 | break |
| 166 | else |
Bob Ball | 63c6c2b | 2013-01-24 13:13:51 +0000 | [diff] [blame] | 167 | echo -n "." |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 168 | sleep 20 |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 169 | fi |
| 170 | done |
Bob Ball | 63c6c2b | 2013-01-24 13:13:51 +0000 | [diff] [blame] | 171 | set -x |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 172 | } |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 173 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 174 | templateuuid=$(xe template-list name-label="$TNAME") |
| 175 | if [ -z "$templateuuid" ]; then |
| 176 | # |
| 177 | # Install Ubuntu over network |
| 178 | # |
| 179 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 180 | # always update the preseed file, incase we have a newer one |
| 181 | PRESEED_URL=${PRESEED_URL:-""} |
| 182 | if [ -z "$PRESEED_URL" ]; then |
| 183 | PRESEED_URL="${HOST_IP}/devstackubuntupreseed.cfg" |
| 184 | HTTP_SERVER_LOCATION="/opt/xensource/www" |
| 185 | if [ ! -e $HTTP_SERVER_LOCATION ]; then |
| 186 | HTTP_SERVER_LOCATION="/var/www/html" |
| 187 | mkdir -p $HTTP_SERVER_LOCATION |
| 188 | fi |
Mate Lakat | a8bf0f2 | 2013-03-07 18:37:31 +0000 | [diff] [blame] | 189 | cp -f $THIS_DIR/devstackubuntupreseed.cfg $HTTP_SERVER_LOCATION |
Mate Lakat | d3740f7 | 2013-05-09 15:02:21 +0100 | [diff] [blame] | 190 | |
| 191 | sed \ |
| 192 | -e "s,\(d-i mirror/http/hostname string\).*,\1 $UBUNTU_INST_HTTP_HOSTNAME,g" \ |
| 193 | -e "s,\(d-i mirror/http/directory string\).*,\1 $UBUNTU_INST_HTTP_DIRECTORY,g" \ |
| 194 | -e "s,\(d-i mirror/http/proxy string\).*,\1 $UBUNTU_INST_HTTP_PROXY,g" \ |
| 195 | -i "${HTTP_SERVER_LOCATION}/devstackubuntupreseed.cfg" |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 196 | fi |
| 197 | |
John Garbutt | d8f1a87 | 2012-06-26 11:16:38 +0100 | [diff] [blame] | 198 | # Update the template |
Mate Lakat | a8bf0f2 | 2013-03-07 18:37:31 +0000 | [diff] [blame] | 199 | $THIS_DIR/scripts/install_ubuntu_template.sh $PRESEED_URL |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 200 | |
| 201 | # create a new VM with the given template |
| 202 | # creating the correct VIFs and metadata |
Mate Lakat | 9e32677 | 2013-05-08 16:42:22 +0100 | [diff] [blame] | 203 | $THIS_DIR/scripts/install-os-vpx.sh \ |
| 204 | -t "$UBUNTU_INST_TEMPLATE_NAME" \ |
| 205 | -v "$VM_BRIDGE_OR_NET_NAME" \ |
| 206 | -m "$MGT_BRIDGE_OR_NET_NAME" \ |
| 207 | -p "$PUB_BRIDGE_OR_NET_NAME" \ |
| 208 | -l "$GUEST_NAME" \ |
Mate Lakat | 8ff33ce | 2013-05-30 13:26:58 +0100 | [diff] [blame] | 209 | -r "$OSDOMU_MEM_MB" |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 210 | |
| 211 | # wait for install to finish |
| 212 | wait_for_VM_to_halt |
| 213 | |
| 214 | # set VM to restart after a reboot |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 215 | vm_uuid=$(xe_min vm-list name-label="$GUEST_NAME") |
| 216 | xe vm-param-set actions-after-reboot=Restart uuid="$vm_uuid" |
| 217 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 218 | # |
| 219 | # Prepare VM for DevStack |
| 220 | # |
| 221 | |
| 222 | # Install XenServer tools, and other such things |
Mate Lakat | a8bf0f2 | 2013-03-07 18:37:31 +0000 | [diff] [blame] | 223 | $THIS_DIR/prepare_guest_template.sh "$GUEST_NAME" |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 224 | |
| 225 | # start the VM to run the prepare steps |
| 226 | xe vm-start vm="$GUEST_NAME" |
| 227 | |
| 228 | # Wait for prep script to finish and shutdown system |
| 229 | wait_for_VM_to_halt |
| 230 | |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 231 | # Make template from VM |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 232 | snuuid=$(xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_PREPARED") |
| 233 | xe snapshot-clone uuid=$snuuid new-name-label="$TNAME" |
| 234 | else |
| 235 | # |
| 236 | # Template already installed, create VM from template |
| 237 | # |
| 238 | vm_uuid=$(xe vm-install template="$TNAME" new-name-label="$GUEST_NAME") |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 239 | fi |
| 240 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 241 | |
| 242 | # |
| 243 | # Inject DevStack inside VM disk |
| 244 | # |
Mate Lakat | a8bf0f2 | 2013-03-07 18:37:31 +0000 | [diff] [blame] | 245 | $THIS_DIR/build_xva.sh "$GUEST_NAME" |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 246 | |
Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 247 | # Attach a network interface for the integration network (so that the bridge |
Mate Lakat | 8ff33ce | 2013-05-30 13:26:58 +0100 | [diff] [blame] | 248 | # is created by XenServer). This is required for Quantum. Also pass that as a |
| 249 | # kernel parameter for DomU |
Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 250 | if is_service_enabled quantum; then |
| 251 | add_interface "$GUEST_NAME" "$XEN_INT_BRIDGE_OR_NET_NAME" "4" |
Mate Lakat | 8ff33ce | 2013-05-30 13:26:58 +0100 | [diff] [blame] | 252 | |
| 253 | XEN_INTEGRATION_BRIDGE=$(bridge_for "$XEN_INT_BRIDGE_OR_NET_NAME") |
| 254 | append_kernel_cmdline \ |
| 255 | "$GUEST_NAME" \ |
| 256 | "xen_integration_bridge=${XEN_INTEGRATION_BRIDGE}" |
Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 257 | fi |
| 258 | |
Mate Lakat | 8ff33ce | 2013-05-30 13:26:58 +0100 | [diff] [blame] | 259 | FLAT_NETWORK_BRIDGE=$(bridge_for "$VM_BRIDGE_OR_NET_NAME") |
| 260 | append_kernel_cmdline "$GUEST_NAME" "flat_network_bridge=${FLAT_NETWORK_BRIDGE}" |
| 261 | |
Mate Lakat | 68ac03c | 2013-06-06 16:22:34 +0100 | [diff] [blame^] | 262 | # Add a separate xvdb, if it was requested |
| 263 | if [[ "0" != "$XEN_XVDB_SIZE_GB" ]]; then |
| 264 | vm=$(xe vm-list name-label="$GUEST_NAME" --minimal) |
| 265 | |
| 266 | # Add a new disk |
| 267 | localsr=$(get_local_sr) |
| 268 | extra_vdi=$(xe vdi-create \ |
| 269 | name-label=xvdb-added-by-devstack \ |
| 270 | virtual-size="${XEN_XVDB_SIZE_GB}GiB" \ |
| 271 | sr-uuid=$localsr type=user) |
| 272 | xe vbd-create vm-uuid=$vm vdi-uuid=$extra_vdi device=1 |
| 273 | fi |
| 274 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 275 | # create a snapshot before the first boot |
| 276 | # to allow a quick re-run with the same settings |
| 277 | xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_FIRST_BOOT" |
| 278 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 279 | # |
| 280 | # Run DevStack VM |
| 281 | # |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 282 | xe vm-start vm="$GUEST_NAME" |
Anthony Young | 3eb8f59 | 2011-10-26 23:11:52 -0700 | [diff] [blame] | 283 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 284 | function ssh_no_check() { |
| 285 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@" |
| 286 | } |
| 287 | |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 288 | # Get hold of the Management IP of OpenStack VM |
| 289 | OS_VM_MANAGEMENT_ADDRESS=$MGT_IP |
| 290 | if [ $OS_VM_MANAGEMENT_ADDRESS == "dhcp" ]; then |
| 291 | OS_VM_MANAGEMENT_ADDRESS=$(find_ip_by_name $GUEST_NAME 2) |
| 292 | fi |
| 293 | |
| 294 | # Get hold of the Service IP of OpenStack VM |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 295 | if [ $HOST_IP_IFACE == "eth2" ]; then |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 296 | OS_VM_SERVICES_ADDRESS=$MGT_IP |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 297 | if [ $MGT_IP == "dhcp" ]; then |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 298 | OS_VM_SERVICES_ADDRESS=$(find_ip_by_name $GUEST_NAME 2) |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 299 | fi |
| 300 | else |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 301 | OS_VM_SERVICES_ADDRESS=$PUB_IP |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 302 | if [ $PUB_IP == "dhcp" ]; then |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 303 | OS_VM_SERVICES_ADDRESS=$(find_ip_by_name $GUEST_NAME 3) |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 304 | fi |
Renuka Apte | c56885a | 2012-02-29 16:09:26 -0800 | [diff] [blame] | 305 | fi |
| 306 | |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 307 | # If we have copied our ssh credentials, use ssh to monitor while the installation runs |
| 308 | WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1} |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 309 | COPYENV=${COPYENV:-1} |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 310 | if [ "$WAIT_TILL_LAUNCH" = "1" ] && [ -e ~/.ssh/id_rsa.pub ] && [ "$COPYENV" = "1" ]; then |
Bob Ball | 7fcc157 | 2013-02-20 15:56:25 +0000 | [diff] [blame] | 311 | set +x |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 312 | |
Bob Ball | 7fcc157 | 2013-02-20 15:56:25 +0000 | [diff] [blame] | 313 | echo "VM Launched - Waiting for startup script" |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 314 | # wait for log to appear |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 315 | while ! ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "[ -e run.sh.log ]"; do |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 316 | sleep 10 |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 317 | done |
Bob Ball | 7fcc157 | 2013-02-20 15:56:25 +0000 | [diff] [blame] | 318 | echo -n "Running" |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 319 | while [ `ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS pgrep -c run.sh` -ge 1 ] |
Mate Lakat | 9efcf60 | 2012-12-19 10:23:06 +0000 | [diff] [blame] | 320 | do |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 321 | sleep 10 |
Mate Lakat | 9efcf60 | 2012-12-19 10:23:06 +0000 | [diff] [blame] | 322 | echo -n "." |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 323 | done |
Mate Lakat | 9efcf60 | 2012-12-19 10:23:06 +0000 | [diff] [blame] | 324 | echo "done!" |
| 325 | set -x |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 326 | |
Mate Lakat | 9efcf60 | 2012-12-19 10:23:06 +0000 | [diff] [blame] | 327 | # output the run.sh.log |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 328 | ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS 'cat run.sh.log' |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 329 | |
Mate Lakat | 9efcf60 | 2012-12-19 10:23:06 +0000 | [diff] [blame] | 330 | # Fail if the expected text is not found |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 331 | ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS 'cat run.sh.log' | grep -q 'stack.sh completed in' |
Mate Lakat | 9efcf60 | 2012-12-19 10:23:06 +0000 | [diff] [blame] | 332 | |
Bob Ball | 63c6c2b | 2013-01-24 13:13:51 +0000 | [diff] [blame] | 333 | set +x |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 334 | echo "################################################################################" |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 335 | echo "" |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 336 | echo "All Finished!" |
| 337 | echo "You can visit the OpenStack Dashboard" |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 338 | echo "at http://$OS_VM_SERVICES_ADDRESS, and contact other services at the usual ports." |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 339 | else |
Bob Ball | 63c6c2b | 2013-01-24 13:13:51 +0000 | [diff] [blame] | 340 | set +x |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 341 | echo "################################################################################" |
| 342 | echo "" |
| 343 | echo "All Finished!" |
| 344 | echo "Now, you can monitor the progress of the stack.sh installation by " |
| 345 | echo "tailing /opt/stack/run.sh.log from within your domU." |
| 346 | echo "" |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 347 | echo "ssh into your domU now: 'ssh stack@$OS_VM_MANAGEMENT_ADDRESS' using your password" |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 348 | echo "and then do: 'tail -f /opt/stack/run.sh.log'" |
| 349 | echo "" |
| 350 | echo "When the script completes, you can then visit the OpenStack Dashboard" |
Mate Lakat | 8644676 | 2013-05-12 18:34:29 +0100 | [diff] [blame] | 351 | echo "at http://$OS_VM_SERVICES_ADDRESS, and contact other services at the usual ports." |
Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 352 | fi |