From dc0a6d4bdbd4671338aa4acf2575e57baa97cecd Mon Sep 17 00:00:00 2001 From: Pranav Salunke Date: Fri, 27 Nov 2015 15:31:09 +0100 Subject: [PATCH] labs: Remove labs section * Deletes content in labs section since the code is located in the new repository under training-labs. * Also update the Readme's. Change-Id: I5eef76349a1b1e245c4ae9d7e2c38a3fa81d1a21 Implements: blueprint training-labs --- labs/ChangeLog | 0 labs/HACKING.rst | 129 -- labs/README.md | 198 +- labs/autostart/README.rst | 2 - labs/config/README.rst | 2 - labs/config/admin-openstackrc.sh | 15 - labs/config/config.base | 4 - labs/config/config.compute | 18 - labs/config/config.controller | 21 - labs/config/config.network | 20 - labs/config/credentials | 48 - labs/config/demo-openstackrc.sh | 15 - labs/config/deploy.osbash | 20 - labs/config/hosts.multi | 9 - labs/config/localrc | 17 - labs/config/openstack | 34 - labs/config/paths | 33 - labs/config/provider.virtualbox | 21 - labs/config/scripts.fedora_base | 2 - labs/config/scripts.ubuntu_base | 5 - labs/config/scripts.ubuntu_cluster | 103 -- labs/getting-started.rst | 1 - labs/img/README.rst | 26 - labs/lib/README.rst | 9 - labs/lib/functions-common-devstack | 1630 ----------------- labs/lib/functions.guest | 441 ----- labs/lib/functions.sh | 91 - labs/lib/osbash-ssh-keys/README.rst | 2 - labs/lib/osbash-ssh-keys/osbash_key | 27 - labs/lib/osbash-ssh-keys/osbash_key.pub | 1 - labs/lib/osbash/functions-host.sh | 460 ----- labs/lib/osbash/lib-color.sh | 54 - labs/lib/osbash/lib.fedora-20-x86_64 | 43 - .../osbash/lib.ubuntu-12.04.4-server-amd64 | 53 - labs/lib/osbash/lib.ubuntu-14.04-server-amd64 | 53 - labs/lib/osbash/netboot/ks-all-v2.cfg | 75 - labs/lib/osbash/netboot/ks-all.cfg | 75 - labs/lib/osbash/netboot/ks-ssh-v2.cfg | 58 - labs/lib/osbash/netboot/ks-ssh.cfg | 58 - labs/lib/osbash/netboot/ks-vbadd.cfg | 64 - labs/lib/osbash/netboot/preseed-all-v2.cfg | 120 -- labs/lib/osbash/netboot/preseed-all.cfg | 120 -- labs/lib/osbash/netboot/preseed-ssh-v2.cfg | 120 -- labs/lib/osbash/netboot/preseed-ssh.cfg | 120 -- labs/lib/osbash/netboot/preseed-vbadd.cfg | 120 -- labs/lib/osbash/scanlib.sh | 302 --- .../templates/template-fedora-ifcfg-hostonly | 5 - .../templates/template-fedora-ifcfg-nat | 4 - .../template-ubuntu-interfaces-hostonly | 4 - .../template-ubuntu-interfaces-loopback | 3 - .../templates/template-ubuntu-interfaces-nat | 3 - labs/lib/osbash/virtualbox-functions.sh | 738 -------- labs/lib/osbash/virtualbox-install_base.sh | 145 -- labs/lib/osbash/virtualbox-install_nodes.sh | 86 - labs/lib/wbatch/README.rst | 2 - labs/lib/wbatch/batch_for_windows.sh | 298 --- labs/lib/wbatch/template-begin_base_bat | 37 - labs/lib/wbatch/template-begin_node_bat | 23 - labs/lib/wbatch/template-create_hostnet_bat | 31 - labs/lib/wbatch/template-elevate_privs_bat | 26 - labs/lib/wbatch/template-end_file_bat | 59 - labs/lib/wbatch/template-file_header_bat | 16 - labs/lib/wbatch/template-find_vbm_bat | 30 - labs/lib/wbatch/template-mkdirs_bat | 20 - labs/log/README.rst | 5 - labs/osbash.sh | 245 --- labs/scripts/README.rst | 7 - labs/scripts/config_external_network.sh | 36 - labs/scripts/config_tenant_network.sh | 41 - labs/scripts/etc_hosts.sh | 26 - labs/scripts/osbash/activate_autostart.sh | 77 - labs/scripts/osbash/base_fixups.sh | 16 - labs/scripts/osbash/enable_osbash_ssh_keys.sh | 50 - labs/scripts/osbash/init_xxx_node.sh | 31 - labs/scripts/osbash/shutdown.sh | 1 - labs/scripts/osbash/template-osbashauto | 58 - labs/scripts/osbash/wait_debug.sh | 12 - labs/scripts/shutdown.sh | 14 - labs/scripts/shutdown_controller.sh | 32 - labs/scripts/test/README.rst | 1 - labs/scripts/test/launch_instance.sh | 793 -------- labs/scripts/ubuntu/apt_init.sh | 69 - labs/scripts/ubuntu/apt_install_mysql.sh | 50 - labs/scripts/ubuntu/apt_pre-download.sh | 94 - labs/scripts/ubuntu/apt_upgrade.sh | 42 - labs/scripts/ubuntu/install_rabbitmq.sh | 19 - .../scripts/ubuntu/setup_cinder_controller.sh | 108 -- labs/scripts/ubuntu/setup_cinder_volumes.sh | 195 -- labs/scripts/ubuntu/setup_glance.sh | 122 -- labs/scripts/ubuntu/setup_heat_controller.sh | 122 -- labs/scripts/ubuntu/setup_heat_network.sh | 83 - labs/scripts/ubuntu/setup_horizon.sh | 74 - labs/scripts/ubuntu/setup_keystone.sh | 170 -- labs/scripts/ubuntu/setup_lbaas_controller.sh | 58 - labs/scripts/ubuntu/setup_lbaas_network.sh | 57 - labs/scripts/ubuntu/setup_neutron_compute.sh | 105 -- .../ubuntu/setup_neutron_controller.sh | 156 -- labs/scripts/ubuntu/setup_neutron_network.sh | 248 --- labs/scripts/ubuntu/setup_nova_compute.sh | 70 - labs/scripts/ubuntu/setup_nova_controller.sh | 116 -- .../scripts/ubuntu/setup_telemetry_compute.sh | 104 -- .../ubuntu/setup_telemetry_controller.sh | 173 -- labs/scripts/yum_init.sh | 30 - labs/scripts/yum_update.sh | 13 - labs/scripts/zero_empty.sh | 13 - labs/tools/README.rst | 2 - labs/tools/downloader.js | 13 - labs/tools/get_upstart_logs.sh | 37 - labs/tools/repeat-test.sh | 129 -- labs/tools/restore-cluster.sh | 155 -- labs/tools/test-once.sh | 56 - labs/wbatch/README.rst | 7 - 112 files changed, 3 insertions(+), 10501 deletions(-) delete mode 100644 labs/ChangeLog delete mode 100644 labs/HACKING.rst delete mode 100644 labs/autostart/README.rst delete mode 100644 labs/config/README.rst delete mode 100644 labs/config/admin-openstackrc.sh delete mode 100644 labs/config/config.base delete mode 100644 labs/config/config.compute delete mode 100644 labs/config/config.controller delete mode 100644 labs/config/config.network delete mode 100644 labs/config/credentials delete mode 100644 labs/config/demo-openstackrc.sh delete mode 100644 labs/config/deploy.osbash delete mode 100644 labs/config/hosts.multi delete mode 100644 labs/config/localrc delete mode 100644 labs/config/openstack delete mode 100644 labs/config/paths delete mode 100644 labs/config/provider.virtualbox delete mode 100644 labs/config/scripts.fedora_base delete mode 100644 labs/config/scripts.ubuntu_base delete mode 100644 labs/config/scripts.ubuntu_cluster delete mode 100644 labs/getting-started.rst delete mode 100644 labs/img/README.rst delete mode 100644 labs/lib/README.rst delete mode 100644 labs/lib/functions-common-devstack delete mode 100644 labs/lib/functions.guest delete mode 100644 labs/lib/functions.sh delete mode 100644 labs/lib/osbash-ssh-keys/README.rst delete mode 100644 labs/lib/osbash-ssh-keys/osbash_key delete mode 100644 labs/lib/osbash-ssh-keys/osbash_key.pub delete mode 100644 labs/lib/osbash/functions-host.sh delete mode 100644 labs/lib/osbash/lib-color.sh delete mode 100644 labs/lib/osbash/lib.fedora-20-x86_64 delete mode 100644 labs/lib/osbash/lib.ubuntu-12.04.4-server-amd64 delete mode 100644 labs/lib/osbash/lib.ubuntu-14.04-server-amd64 delete mode 100644 labs/lib/osbash/netboot/ks-all-v2.cfg delete mode 100644 labs/lib/osbash/netboot/ks-all.cfg delete mode 100644 labs/lib/osbash/netboot/ks-ssh-v2.cfg delete mode 100644 labs/lib/osbash/netboot/ks-ssh.cfg delete mode 100644 labs/lib/osbash/netboot/ks-vbadd.cfg delete mode 100644 labs/lib/osbash/netboot/preseed-all-v2.cfg delete mode 100644 labs/lib/osbash/netboot/preseed-all.cfg delete mode 100644 labs/lib/osbash/netboot/preseed-ssh-v2.cfg delete mode 100644 labs/lib/osbash/netboot/preseed-ssh.cfg delete mode 100644 labs/lib/osbash/netboot/preseed-vbadd.cfg delete mode 100644 labs/lib/osbash/scanlib.sh delete mode 100644 labs/lib/osbash/templates/template-fedora-ifcfg-hostonly delete mode 100644 labs/lib/osbash/templates/template-fedora-ifcfg-nat delete mode 100644 labs/lib/osbash/templates/template-ubuntu-interfaces-hostonly delete mode 100644 labs/lib/osbash/templates/template-ubuntu-interfaces-loopback delete mode 100644 labs/lib/osbash/templates/template-ubuntu-interfaces-nat delete mode 100644 labs/lib/osbash/virtualbox-functions.sh delete mode 100644 labs/lib/osbash/virtualbox-install_base.sh delete mode 100644 labs/lib/osbash/virtualbox-install_nodes.sh delete mode 100644 labs/lib/wbatch/README.rst delete mode 100644 labs/lib/wbatch/batch_for_windows.sh delete mode 100644 labs/lib/wbatch/template-begin_base_bat delete mode 100644 labs/lib/wbatch/template-begin_node_bat delete mode 100644 labs/lib/wbatch/template-create_hostnet_bat delete mode 100644 labs/lib/wbatch/template-elevate_privs_bat delete mode 100644 labs/lib/wbatch/template-end_file_bat delete mode 100644 labs/lib/wbatch/template-file_header_bat delete mode 100644 labs/lib/wbatch/template-find_vbm_bat delete mode 100644 labs/lib/wbatch/template-mkdirs_bat delete mode 100644 labs/log/README.rst delete mode 100755 labs/osbash.sh delete mode 100644 labs/scripts/README.rst delete mode 100755 labs/scripts/config_external_network.sh delete mode 100755 labs/scripts/config_tenant_network.sh delete mode 100755 labs/scripts/etc_hosts.sh delete mode 100755 labs/scripts/osbash/activate_autostart.sh delete mode 100755 labs/scripts/osbash/base_fixups.sh delete mode 100755 labs/scripts/osbash/enable_osbash_ssh_keys.sh delete mode 100755 labs/scripts/osbash/init_xxx_node.sh delete mode 120000 labs/scripts/osbash/shutdown.sh delete mode 100644 labs/scripts/osbash/template-osbashauto delete mode 100755 labs/scripts/osbash/wait_debug.sh delete mode 100755 labs/scripts/shutdown.sh delete mode 100755 labs/scripts/shutdown_controller.sh delete mode 100644 labs/scripts/test/README.rst delete mode 100755 labs/scripts/test/launch_instance.sh delete mode 100755 labs/scripts/ubuntu/apt_init.sh delete mode 100755 labs/scripts/ubuntu/apt_install_mysql.sh delete mode 100755 labs/scripts/ubuntu/apt_pre-download.sh delete mode 100755 labs/scripts/ubuntu/apt_upgrade.sh delete mode 100755 labs/scripts/ubuntu/install_rabbitmq.sh delete mode 100755 labs/scripts/ubuntu/setup_cinder_controller.sh delete mode 100755 labs/scripts/ubuntu/setup_cinder_volumes.sh delete mode 100755 labs/scripts/ubuntu/setup_glance.sh delete mode 100755 labs/scripts/ubuntu/setup_heat_controller.sh delete mode 100755 labs/scripts/ubuntu/setup_heat_network.sh delete mode 100755 labs/scripts/ubuntu/setup_horizon.sh delete mode 100755 labs/scripts/ubuntu/setup_keystone.sh delete mode 100755 labs/scripts/ubuntu/setup_lbaas_controller.sh delete mode 100755 labs/scripts/ubuntu/setup_lbaas_network.sh delete mode 100755 labs/scripts/ubuntu/setup_neutron_compute.sh delete mode 100755 labs/scripts/ubuntu/setup_neutron_controller.sh delete mode 100755 labs/scripts/ubuntu/setup_neutron_network.sh delete mode 100755 labs/scripts/ubuntu/setup_nova_compute.sh delete mode 100755 labs/scripts/ubuntu/setup_nova_controller.sh delete mode 100755 labs/scripts/ubuntu/setup_telemetry_compute.sh delete mode 100755 labs/scripts/ubuntu/setup_telemetry_controller.sh delete mode 100755 labs/scripts/yum_init.sh delete mode 100755 labs/scripts/yum_update.sh delete mode 100755 labs/scripts/zero_empty.sh delete mode 100644 labs/tools/README.rst delete mode 100644 labs/tools/downloader.js delete mode 100755 labs/tools/get_upstart_logs.sh delete mode 100755 labs/tools/repeat-test.sh delete mode 100755 labs/tools/restore-cluster.sh delete mode 100755 labs/tools/test-once.sh delete mode 100644 labs/wbatch/README.rst diff --git a/labs/ChangeLog b/labs/ChangeLog deleted file mode 100644 index e69de29b..00000000 diff --git a/labs/HACKING.rst b/labs/HACKING.rst deleted file mode 100644 index 16e0881c..00000000 --- a/labs/HACKING.rst +++ /dev/null @@ -1,129 +0,0 @@ -Contributing to training-labs scripts -===================================== - -General -------- - -Contributing code to training-labs scripts follows the usual OpenStack process -as described in `How To Contribute`__ in the OpenStack wiki. -Our `main blueprint`__ contains the usual links for blueprints, bugs, etc. - -__ contribute_ -.. _contribute: http://docs.openstack.org/infra/manual/developers.html - -__ lp_ -.. _lp: https://blueprints.launchpad.net/openstack-training-guides/+spec/openstack-training-labs - -Getting started ---------------- - -The main script is osbash.sh. It will call libraries and other scripts to build -the training-labs setup. The setup can be customized in labs/config where all -scripts keep their configuration files. - -Prerequisites -------------- - -The labs scripts are designed to have minimal dependencies: bash and -`VirtualBox `_. To support OS X, we keep the -host-side scripts compatible with bash 3.2 (don't use features not present in -that somewhat dated version). - -For testing the generated Windows batch scripts, any supported version of -Windows (Vista and later) will do. After having created the batch files using -osbash.sh, just copy the whole labs directory to Windows. If you don't have -access to that operating system, comparing the output in labs/wbatch will tell -you how your changes affect behavior on that platform. - -Coding style ------------- - -We follow the conventions of other OpenStack projects. Since labs scripts are -currently all written in bash, the examples to follow are this project and -`devstack `_. - -DevStack bash style guidelines can be found at the bottom of: -https://git.openstack.org/cgit/openstack-dev/devstack/blob/master/HACKING.rst - -Structure ---------- - -**autostart** - -osbash/wbatch copy shell scripts (\*.sh) into this directory to have them -automatically executed (and removed) upon boot. - -**config** - -Contains the configuration files for all the scripts. The setup can be customized here. - -**img** - -By default osbash will put into this directory its base disk images -(base-\*-.vdi), the VM export images (oslabs-.ova), -and all installation ISO images it may download. - -**lib** - -This directory contains bash libraries used by scripts. - -**log** - -Contains the log files written (and removed) by osbash/wbatch and -the scripts running within the VMs. - -**scripts** - -All scripts in this directory run within the VMs. - -**wbatch** - -Files in this directory are Windows batch files generated by osbash to -configure host-only networks, produce a base disk, and build OpenStack -training-labs VMs as configured when osbash created them. - -Testing -------- - -The labs scripts don't have automated tests yet. Patch submitters should be -aware of their responsibility for ensuring that their code works and can be -tested by reviewers. - -Useful tools for checking scripts: - -- `bashate `_ (must pass) -- `shellcheck `_ (optional) - -Submitting patches ------------------- - -These documents will help you submit patches to OpenStack projects (including -this one): - -- http://docs.openstack.org/infra/manual/developers.html#development-workflow -- https://wiki.openstack.org/wiki/GitCommitMessages - -If you change the behavior of the scripts as documented in the training-guides, -add a DocImpact flag to alert the documentation team. For instance, add a line -like this to your commit message: - -DocImpact new option added to osbash.sh - -- https://wiki.openstack.org/wiki/Documentation/DocImpact - -Reviewing ---------- - -Learn how to review (or what to expect when having your patches reviewed) here: -- http://docs.openstack.org/infra/manual/developers.html#development-workflow - -TODO ----- -Etherpad: -- https://etherpad.openstack.org/p/training-guides-developing-topics - -Anything not covered here -------------------------- - -Check README.md and get in touch with other scripts developers. - diff --git a/labs/README.md b/labs/README.md index 13ff2914..d30fbeef 100644 --- a/labs/README.md +++ b/labs/README.md @@ -1,200 +1,8 @@ - Training Labs ============= -About ------ +Training labs has its own repository. -Training Labs will provide scripts to automate the creation of the Training -Environment. -**Note:** Training Labs are specifically meant for OpenStack Training and are -specifically tuned as per Training Manuals repo. - - -Pre-requisite -------------- - -* Download and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads). - - -How to run the scripts ----------------------- - -1. Clone the training-guides repo which contains scripts in the labs section that will install multi-node OpenStack automatically. - - $ git clone git://git.openstack.org/openstack/training-guides - -2. Go to the labs folder - - $ cd training-guides/labs - -3. Run the script: - - $ ./osbash -b cluster - -This will do the complete installation for all the nodes - Controller, Compute and Network. - -For more help you can check - - $ ./osbash --help - - -This will take some time to run the first time. - - -What the script installs ------------------------- - -Running this will automatically spin up 3 virtual machines in VirtualBox: - -* Controller node -* Network node -* Compute node - -Now you have a multi-node deployment of OpenStack running with the below services installed. - -OpenStack services installed on Controller node: - -* Keystone -* Horizon -* Glance -* Nova - - * nova-api - * nova-scheduler - * nova-consoleauth - * nova-cert - * nova-novncproxy - * python-novaclient - -* Neutron - - * neutron-server - -* Cinder - -Openstack services installed on Network node: - -* Neutron - - * neutron-plugin-openvswitch-agent - * neutron-l3-agent - * neutron-dhcp-agent - * neutron-metadata-agent - -Openstack Services installed on Compute node: - -* Nova - - * nova-compute - -* Neutron - - * neutron-plugin-openvswitch-agent - - -How to access the services --------------------------- - -There are two ways to access the services: - -* OpenStack Dashboard (horizon) - -You can access the dashboard at: http://192.168.100.51/horizon - -Admin Login: - -*Username:* `admin` - -*Password:* `admin_pass` - -*Demo User Login:* - -*Username:* `demo` - -*Password:* `demo_pass` - -* SSH - -You can ssh to each of the nodes by: - - # Controller node - $ ssh osbash@10.10.10.51 - - # Network node - $ ssh osbash@10.10.10.52 - - # Compute node - $ ssh osbash@10.10.10.53 - -Credentials for all nodes: - -*Username:* `osbash` - -*Password:* `osbash` - -After you have ssh access, you need to source the OpenStack credentials in order to access the services. - -Two credential files are present on each of the nodes: - demo-openstackrc.sh - admin-openstackrc.sh - -Source the following credential files - -For Admin user privileges: - - $ source admin-openstackrc.sh - -For Demo user privileges: - - $ source demo-openstackrc.sh - -Now you can access the OpenStack services via CLI. - - -BluePrints ----------- - -* Training Manuals : https://blueprints.launchpad.net/openstack-manuals/+spec/training-manuals -* Training Labs : https://blueprints.launchpad.net/openstack-training-guides/+spec/openstack-training-labs - -Mailing Lists, IRC ------------------- - -* To contribute please hop on to IRC on the channel `#openstack-doc` on IRC freenode - or write an e-mail to the OpenStack Manuals mailing list - `openstack-docs@lists.openstack.org`. - -**NOTE:** You might consider registering on the OpenStack Manuals mailing list if - you want to post your e-mail instantly. It may take some time for - unregistered users, as it requires admin's approval. - -Sub-team leads --------------- - -Feel free to ping Roger or Pranav on the IRC channel `#openstack-doc` regarding -any queries about the Labs section. - -* Roger Luethi -** Email: `rl@patchworkscience.org` -** IRC: `rluethi` - -* Pranav Salunke -** Email: `dguitarbite@gmail.com` -** IRC: `dguitarbite` - -Meetings --------- - -To follow the weekly meetings for OpenStack Training, please refer -to the following link. - -For IRC meetings, refer to the wiki page on training manuals. -https://wiki.openstack.org/wiki/Meetings/training-manual - -Wiki ----- - -Follow various links on OpenStack Training Manuals here: -https://wiki.openstack.org/wiki/Training-guides +Repository: https://git.openstack.org/cgit/openstack/training-labs +Wiki: https://wiki.openstack.org/wiki/Documentation/training-labs diff --git a/labs/autostart/README.rst b/labs/autostart/README.rst deleted file mode 100644 index eff56aca..00000000 --- a/labs/autostart/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -osbash/wbatch copy shell scripts (*.sh) into this directory to have them -automatically executed (and removed) upon boot. diff --git a/labs/config/README.rst b/labs/config/README.rst deleted file mode 100644 index 7251284c..00000000 --- a/labs/config/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -The configuration files in this directory are used by osbash/wbatch and -by scripts running inside the VMs (scripts directory). diff --git a/labs/config/admin-openstackrc.sh b/labs/config/admin-openstackrc.sh deleted file mode 100644 index dfd8ba6b..00000000 --- a/labs/config/admin-openstackrc.sh +++ /dev/null @@ -1,15 +0,0 @@ -# The variables in this file are exported for use by OpenStack client -# applications. - -# Unlike a regular openstackrc.sh file, this file gets its variable values -# from other configuration files (to limit redundancy). - -# Use BASH_SOURCE so the file works when sourced from a shell, too -CONFIG_DIR=$(dirname "$BASH_SOURCE") -source "$CONFIG_DIR/openstack" -source "$CONFIG_DIR/credentials" - -export OS_USERNAME=$ADMIN_USER_NAME -export OS_PASSWORD=$ADMIN_PASSWORD -export OS_TENANT_NAME=$ADMIN_TENANT_NAME -export OS_AUTH_URL="http://controller-mgmt:35357/v2.0" diff --git a/labs/config/config.base b/labs/config/config.base deleted file mode 100644 index 44ee0811..00000000 --- a/labs/config/config.base +++ /dev/null @@ -1,4 +0,0 @@ -# Base disk VM configuration. Used by osbash/wbatch (host and guest). - -# Port forwarding -VM_SSH_PORT=2229 diff --git a/labs/config/config.compute b/labs/config/config.compute deleted file mode 100644 index eaf6ec47..00000000 --- a/labs/config/config.compute +++ /dev/null @@ -1,18 +0,0 @@ -# Node VM configuration. Used by osbash/wbatch (host and guest). - -# Port forwarding -VM_SSH_PORT=2232 - -# Last octet of IP addresses -FOURTH_OCTET=53 - -# Assign network interfaces to networks -NET_IF_0=nat -NET_IF_1=MGMT_NET -NET_IF_2=DATA_NET - -# A default instance within compute uses 512 MB RAM -VM_MEM=1024 - -# Override number of virtual CPUs (default is 1) -VM_CPUS=2 diff --git a/labs/config/config.controller b/labs/config/config.controller deleted file mode 100644 index 384e7aec..00000000 --- a/labs/config/config.controller +++ /dev/null @@ -1,21 +0,0 @@ -# Node VM configuration. Used by osbash/wbatch (host and guest). - -# Port forwarding -VM_SSH_PORT=2230 -VM_WWW_PORT=8888 - -# Last octet of IP addresses -FOURTH_OCTET=51 - -# Assign network interfaces to networks -NET_IF_0=nat -NET_IF_1=MGMT_NET -NET_IF_2=API_NET - -# Controller node is running many services. It needs 1 GB RAM for better -# performance. -VM_MEM=1024 - -# Override number of virtual CPUs (default is 1) -# To edit uncomment the line below -# VM_CPUS=1 diff --git a/labs/config/config.network b/labs/config/config.network deleted file mode 100644 index 5e15c4fa..00000000 --- a/labs/config/config.network +++ /dev/null @@ -1,20 +0,0 @@ -# Node VM configuration. Used by osbash/wbatch (host and guest). - -# Port forwarding -VM_SSH_PORT=2231 - -# Last octet of IP addresses -FOURTH_OCTET=52 - -# Assign network interfaces to networks -NET_IF_0=nat -NET_IF_1=MGMT_NET -NET_IF_2=DATA_NET -NET_IF_3=API_NET - -# A default instance within network uses 512 MB RAM -# VM_MEM=512 - -# Override number of virtual CPUs (default is 1) -# Uncomment and edit the line below to change number of vCPUs used -# VM_CPUS=1 diff --git a/labs/config/credentials b/labs/config/credentials deleted file mode 100644 index ee2c8666..00000000 --- a/labs/config/credentials +++ /dev/null @@ -1,48 +0,0 @@ -# This file contains user names, passwords, and tokens that are set and used -# by OpenStack applications and related software running in the VMs. - -# Note that the VM shell user and its password are not set here. By default, -# those are hard-coded in the preseed/kickstart files. The scripts get the -# shell user name from deploy.{osbash} and don't need a password -# (they use password-less sudo and -- if configured -- ssh keys). - -# Used for MySQL or whatever other DBMS is configured -: ${DATABASE_PASSWORD:=secrete} - -# Used for MySQL or whatever other DBMS is configured -: ${RABBIT_PASSWORD:=rabbitPass} - -# Tenant and role for admin accounts -: ${ADMIN_ROLE_NAME:=admin} -: ${ADMIN_TENANT_NAME:=admin} - -# Member role for generic use -: ${MEMBER_ROLE_NAME:=_member_} - -# User name and password for administrator -: ${ADMIN_USER_NAME:=admin} -: ${ADMIN_PASSWORD:=admin_pass} - -# Tenant name, user name and password for normal (demo) user -: ${DEMO_TENANT_NAME:=demo} -: ${DEMO_USER_NAME:=demo} -: ${DEMO_PASSWORD:=demo_pass} - -# OpenStack Services needs to be affiliated with a tenant to provide -# authentication to other OpenStack services. We create a "service" tenant for -# the OpenStack services. All the OpenStack services will be registered via -# service tenant. - -# Tenant and role for service accounts. -: ${SERVICE_TENANT_NAME:=service} - -# Domain to use for email addresses (e.g. admin@example.com) -: ${MAIL_DOMAIN:=example.com} - -# Metadata secret used by neutron and nova. -: ${METADATA_SECRET:=osbash_training} - -# Metering secret used by ceilometer. -: ${METERING_SECRET:=osbash_training} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/config/demo-openstackrc.sh b/labs/config/demo-openstackrc.sh deleted file mode 100644 index ffa1218b..00000000 --- a/labs/config/demo-openstackrc.sh +++ /dev/null @@ -1,15 +0,0 @@ -# The variables in this file are exported for use by OpenStack client -# applications. - -# Unlike a regular openstackrc.sh file, this file gets its variable values -# from other configuration files (to limit redundancy). - -# Use BASH_SOURCE so the file works when sourced from a shell, too -CONFIG_DIR=$(dirname "$BASH_SOURCE") -source "$CONFIG_DIR/openstack" -source "$CONFIG_DIR/credentials" - -export OS_USERNAME=$DEMO_USER_NAME -export OS_PASSWORD=$DEMO_PASSWORD -export OS_TENANT_NAME=$DEMO_TENANT_NAME -export OS_AUTH_URL="http://controller-mgmt:5000/v2.0" diff --git a/labs/config/deploy.osbash b/labs/config/deploy.osbash deleted file mode 100644 index dbc0fa11..00000000 --- a/labs/config/deploy.osbash +++ /dev/null @@ -1,20 +0,0 @@ -# Used by osbash.sh and guest scripts - -# Port used for ssh forwarding when building base disk -: ${VM_BASE_SSH_PORT:=2229} - -: ${OSBASH_LIB_DIR:=$LIB_DIR/osbash} -: ${OSBASH_SCRIPTS_DIR:=$SCRIPTS_DIR/osbash} - -: ${TEMPLATE_DIR:=$LIB_DIR/osbash/templates} - -# Name of VirtualBox shared folder -: ${SHARE_NAME:=osbash} - -# Note: shell user name and password are set in preseed.cfg -VM_SHELL_USER=osbash - -# Override disk size in MB (default is 10000 MB, inherited by node VMs) -# BASE_DISK_SIZE=10000 - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/config/hosts.multi b/labs/config/hosts.multi deleted file mode 100644 index 05d959d9..00000000 --- a/labs/config/hosts.multi +++ /dev/null @@ -1,9 +0,0 @@ -10.10.10.51 controller-mgmt -192.168.100.51 controller-api - -10.10.10.52 network-mgmt -10.20.20.52 network-data -192.168.100.52 network-api - -10.10.10.53 compute-mgmt -10.20.20.53 compute-data diff --git a/labs/config/localrc b/labs/config/localrc deleted file mode 100644 index 454dcea2..00000000 --- a/labs/config/localrc +++ /dev/null @@ -1,17 +0,0 @@ -# Set this if you already have the install ISO, but in a location other -# than IMG_DIR (which defaults to TOP_DIR/img) -#INSTALL_ISO=/data/iso/ubuntu/ubuntu-12.04.4-server-amd64.iso - -# VM_PROXY will be used by apt/yum once the operating system is -# installed (i.e. for software updates and installation). It is only -# used to speed up the process. If you have to use a proxy to connect -# to the Internet, this is not sufficient. -#VM_PROXY="http://192.168.178.20:3128" - -# Options: ubuntu-12.04.4-server-amd64 -# ubuntu-14.04-server-amd64 (default) -# fedora-20-x86_64 -#DISTRO=ubuntu-12.04.4-server-amd64 -#DISTRO=fedora-20-x86_64 - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/config/openstack b/labs/config/openstack deleted file mode 100644 index 4feeb49e..00000000 --- a/labs/config/openstack +++ /dev/null @@ -1,34 +0,0 @@ -# This file contains OpenStack configuration data. It is used by both -# host (osbash, Windows batch) and VM guest scripts. - -# one of: icehouse, juno -: ${OPENSTACK_RELEASE:=juno} - -# CirrOS image URL -CIRROS_URL="http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img" - -# Networks used by OpenStack training-labs setup -: ${MGMT_NET:=10.10.10.1} -: ${DATA_NET:=10.20.20.1} -: ${API_NET:=192.168.100.1} -# FIXME API_NET and EXT_NET should be different networks as soon as our -# setup allows it. -: ${EXT_NET:=192.168.100.1} - -# EXT_NET -: ${FLOATING_IP_START:=192.168.100.101} -: ${FLOATING_IP_END:=192.168.100.200} -: ${EXTERNAL_NETWORK_GATEWAY:=192.168.100.1} -: ${EXTERNAL_NETWORK_CIDR:=192.168.100.0/24} - -# DEMO_NET -: ${TENANT_NETWORK_GATEWAY:=172.16.0.1} -: ${TENANT_NETWORK_CIDR:=172.16.0.0/24} -# Comma-separated list of DNS name servers used by dnsmasq to serve instance -# VMs in neutron subnets with dns_nameservers unset. -# Default is Google Public DNS (8.8.8.8); to disable, set to "". -: ${TENANT_VM_DNS_SERVER:=8.8.8.8} - -: ${REGION:=regionOne} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/config/paths b/labs/config/paths deleted file mode 100644 index 58d0285d..00000000 --- a/labs/config/paths +++ /dev/null @@ -1,33 +0,0 @@ -# This file is used by all scripts to find the directories for the files they -# read or write. They find this file as "$TOP_DIR/config/paths". - -# Configuration files -: ${CONFIG_DIR:=$TOP_DIR/config} - -# Installation ISO images, basedisk images, exported VM cluster images, etc. -# -# TODO(rluethi): merge these directories in the code, the option to have them -# in separate directories doesn't seem very useful -: ${DISK_DIR:=$TOP_DIR/img} -: ${IMG_DIR:=$TOP_DIR/img} -: ${ISO_DIR:=$TOP_DIR/img} - -# Code libraries, templates, preseed/kickstart files -: ${LIB_DIR:=$TOP_DIR/lib} - -# Log files -: ${LOG_DIR:=$TOP_DIR/log} - -# Status files (progress indicator for running scripts) -: ${STATUS_DIR:=$LOG_DIR/status} - -# Scripts that run within the basedisk and node VMs -: ${SCRIPTS_DIR:=$TOP_DIR/scripts} - -# Directory shared with VM guest -: ${SHARE_DIR:=$TOP_DIR} - -# Autostart directory; files placed here are executed within the VM -: ${AUTOSTART_DIR:=$SHARE_DIR/autostart} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/config/provider.virtualbox b/labs/config/provider.virtualbox deleted file mode 100644 index ff948a85..00000000 --- a/labs/config/provider.virtualbox +++ /dev/null @@ -1,21 +0,0 @@ -# VirtualBox specific settings; used by osbash - -# Type of NIC to use for network interfaces, one of: -# 82540EM for Intel PRO/1000 MT Desktop -# 82543GC for Intel PRO/1000 T Server -# 82545EM for Intel PRO/1000 MT Server -# Am79C970A for PCnet-PCI II -# Am79C973 for PCnet-FAST III -# virtio for Paravirtualized network -: ${NICTYPE:=virtio} - -# Location of VBoxManage binary -: ${VBM_EXE:=$(which VBoxManage)} - -# VirtualBox VM group -: ${VM_GROUP:=oslabs} - -# VirtualBox VM GUI type -: ${VM_UI:=headless} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/config/scripts.fedora_base b/labs/config/scripts.fedora_base deleted file mode 100644 index dabefdd8..00000000 --- a/labs/config/scripts.fedora_base +++ /dev/null @@ -1,2 +0,0 @@ -# Scripts for Fedora installations -cmd queue yum_init.sh diff --git a/labs/config/scripts.ubuntu_base b/labs/config/scripts.ubuntu_base deleted file mode 100644 index 9743a7c0..00000000 --- a/labs/config/scripts.ubuntu_base +++ /dev/null @@ -1,5 +0,0 @@ -# Scripts for Ubuntu installations -cmd queue ubuntu/apt_init.sh -cmd queue ubuntu/apt_upgrade.sh -cmd queue ubuntu/apt_pre-download.sh -cmd queue osbash/enable_osbash_ssh_keys.sh diff --git a/labs/config/scripts.ubuntu_cluster b/labs/config/scripts.ubuntu_cluster deleted file mode 100644 index 71555783..00000000 --- a/labs/config/scripts.ubuntu_cluster +++ /dev/null @@ -1,103 +0,0 @@ -#============================================================================== -# Scripts for controller node -cmd init_node -n controller - -cmd queue etc_hosts.sh -cmd queue osbash/enable_osbash_ssh_keys.sh -cmd snapshot_cycle -n controller controller_node_init - -cmd queue ubuntu/apt_install_mysql.sh -cmd queue ubuntu/install_rabbitmq.sh -cmd snapshot_cycle -n controller pre-openstack_installed - -cmd queue ubuntu/setup_keystone.sh -cmd snapshot_cycle -n controller keystone_installed - -cmd queue ubuntu/setup_glance.sh -cmd snapshot_cycle -n controller glance_installed - -cmd queue ubuntu/setup_nova_controller.sh -cmd snapshot_cycle -n controller nova-controller_installed - -cmd queue ubuntu/setup_neutron_controller.sh -cmd snapshot_cycle -n controller neutron-controller_installed - -cmd queue ubuntu/setup_cinder_controller.sh -cmd snapshot_cycle -n controller cinder_installed - -cmd queue ubuntu/setup_horizon.sh -cmd snapshot_cycle -n controller horizon_installed - -cmd queue config_external_network.sh -cmd queue config_tenant_network.sh -cmd snapshot_cycle -n controller openstack_networks_configured - -cmd queue ubuntu/setup_lbaas_controller.sh -cmd snapshot_cycle -n controller lbaas-controller_installed - -# Telemetry service is disabled for the time being as it overloads -# the cluster. For enabling the same, please uncomment the following. -# Warning: Use higher configuration (Disk space). The default -# configuration is optimized for 4GB i3/i5 based machine. -# cmd queue ubuntu/setup_telemetry_controller.sh -# cmd snapshot_cycle -n controller telemetry-controller_installed - -cmd queue ubuntu/setup_heat_controller.sh -cmd snapshot_cycle -n controller heat_controller_installed - -cmd boot -n controller -#============================================================================== -# Scripts for compute node -cmd init_node -n compute - -cmd queue etc_hosts.sh -cmd queue osbash/enable_osbash_ssh_keys.sh -cmd snapshot_cycle -n compute compute_node_init - -cmd queue ubuntu/setup_nova_compute.sh -cmd snapshot_cycle -n compute nova-compute_installed - -cmd queue ubuntu/setup_neutron_compute.sh -cmd queue ubuntu/setup_cinder_volumes.sh -cmd snapshot_cycle -n compute cinder-volume_installed - -# Telemetry service is disabled for the time being as it overloads -# the cluster. For enabling the same, please uncomment the following. -# Warning: Use higher configuration (RAM, CPU's). The default -# configuration is optimized for 4GB i3/i5 based machine. -# cmd queue ubuntu/setup_telemetry_compute.sh -# cmd snapshot_cycle -n compute telemetry-compute_installed - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Take snapshot of database changes on controller VM, too -cmd queue shutdown_controller.sh -cmd boot -n compute - -cmd wait_for_shutdown -n controller -cmd snapshot -n controller controller_-_compute_node_installed -cmd boot -n controller -#============================================================================== -# Scripts for network node -cmd init_node -n network - -cmd queue etc_hosts.sh -cmd queue osbash/enable_osbash_ssh_keys.sh -cmd snapshot_cycle -n network network_node_init - -cmd queue ubuntu/setup_neutron_network.sh -cmd snapshot_cycle -n network neutron_configured - -cmd queue ubuntu/setup_lbaas_network.sh -cmd snapshot_cycle -n network lbaas-network_installed - -cmd queue ubuntu/setup_heat_network.sh -cmd snapshot_cycle -n network heat_network_installed -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Take snapshot of database changes on controller VM, too -cmd queue shutdown_controller.sh -cmd boot -n network - -cmd wait_for_shutdown -n controller -cmd snapshot -n controller controller_-_network_node_installed -cmd boot -n controller -#============================================================================== diff --git a/labs/getting-started.rst b/labs/getting-started.rst deleted file mode 100644 index 5457c61d..00000000 --- a/labs/getting-started.rst +++ /dev/null @@ -1 +0,0 @@ -TODO: Getting started section will lie in this section. diff --git a/labs/img/README.rst b/labs/img/README.rst deleted file mode 100644 index b7688637..00000000 --- a/labs/img/README.rst +++ /dev/null @@ -1,26 +0,0 @@ -OsBash ------- - -About ------ - -By default, osbash will put into this directory its base disk images -(base-*-.vdi), the VM export images (oslabs-.ova), -and all installation ISO images it may download. - - - 'img' folder stores all the base disk and ISO images. - - To find individual virtualbox disk images, please look into the - virtualbox default machine folder. - - For Linux: "~/VirtualBox/oslabs/" - - In case your default folder is at another location (manually set) - please get the location by opening the VirtualBox GUI at this location - "File>Preferences>General>Default Machine Folder" - -Windows ------ - -For people using windows, you might have to download the iso image for the -required distro and version manually. - -- Ubuntu 14.04 ISO - - http://releases.ubuntu.com/14.04/ubuntu-14.04.2-server-amd64.iso diff --git a/labs/lib/README.rst b/labs/lib/README.rst deleted file mode 100644 index a72fc822..00000000 --- a/labs/lib/README.rst +++ /dev/null @@ -1,9 +0,0 @@ -This directory contains bash libraries used by scripts. - -Configuration files for kickstart (Fedora) and preseed (Ubuntu) are in -osbash/netboot. - -The osbash-ssh-keys can be automatically installed into osbash -VMs to make them accessible. - -The templates used to build Windows batch files are in the wbatch subdirectory. diff --git a/labs/lib/functions-common-devstack b/labs/lib/functions-common-devstack deleted file mode 100644 index cc90c073..00000000 --- a/labs/lib/functions-common-devstack +++ /dev/null @@ -1,1630 +0,0 @@ -# functions-common - Common functions used by DevStack components -# -# The canonical copy of this file is maintained in the DevStack repo. -# All modifications should be made there and then sync'ed to other repos -# as required. -# -# This file is sorted alphabetically within the function groups. -# -# - Config Functions -# - Control Functions -# - Distro Functions -# - Git Functions -# - OpenStack Functions -# - Package Functions -# - Process Functions -# - Python Functions -# - Service Functions -# - System Functions -# -# The following variables are assumed to be defined by certain functions: -# -# - ``ENABLED_SERVICES`` -# - ``ERROR_ON_CLONE`` -# - ``FILES`` -# - ``OFFLINE`` -# - ``PIP_DOWNLOAD_CACHE`` -# - ``PIP_USE_MIRRORS`` -# - ``RECLONE`` -# - ``REQUIREMENTS_DIR`` -# - ``STACK_USER`` -# - ``TRACK_DEPENDS`` -# - ``UNDO_REQUIREMENTS`` -# - ``http_proxy``, ``https_proxy``, ``no_proxy`` - -# Save trace setting -XTRACE=$(set +o | grep xtrace) -set +o xtrace - - -# Config Functions -# ================ - -# Append a new option in an ini file without replacing the old value -# iniadd config-file section option value1 value2 value3 ... -function iniadd { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local section=$2 - local option=$3 - shift 3 - local values="$(iniget_multiline $file $section $option) $@" - iniset_multiline $file $section $option $values - $xtrace -} - -# Comment an option in an INI file -# inicomment config-file section option -function inicomment { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local section=$2 - local option=$3 - sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=.*$\)|#\1|" "$file" - $xtrace -} - -# Get an option from an INI file -# iniget config-file section option -function iniget { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local section=$2 - local option=$3 - local line - line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file") - echo ${line#*=} - $xtrace -} - -# Get a multiple line option from an INI file -# iniget_multiline config-file section option -function iniget_multiline { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local section=$2 - local option=$3 - local values - values=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { s/^$option[ \t]*=[ \t]*//gp; }" "$file") - echo ${values} - $xtrace -} - -# Determinate is the given option present in the INI file -# ini_has_option config-file section option -function ini_has_option { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local section=$2 - local option=$3 - local line - line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file") - $xtrace - [ -n "$line" ] -} - -# Set an option in an INI file -# iniset config-file section option value -function iniset { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local section=$2 - local option=$3 - local value=$4 - - [[ -z $section || -z $option ]] && return - - if ! grep -q "^\[$section\]" "$file" 2>/dev/null; then - # Add section at the end - echo -e "\n[$section]" >>"$file" - fi - if ! ini_has_option "$file" "$section" "$option"; then - # Add it - sed -i -e "/^\[$section\]/ a\\ -$option = $value -" "$file" - else - local sep=$(echo -ne "\x01") - # Replace it - sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file" - fi - $xtrace -} - -# Set a multiple line option in an INI file -# iniset_multiline config-file section option value1 value2 valu3 ... -function iniset_multiline { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local section=$2 - local option=$3 - shift 3 - local values - for v in $@; do - # The later sed command inserts each new value in the line next to - # the section identifier, which causes the values to be inserted in - # the reverse order. Do a reverse here to keep the original order. - values="$v ${values}" - done - if ! grep -q "^\[$section\]" "$file"; then - # Add section at the end - echo -e "\n[$section]" >>"$file" - else - # Remove old values - sed -i -e "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ d; }" "$file" - fi - # Add new ones - for v in $values; do - sed -i -e "/^\[$section\]/ a\\ -$option = $v -" "$file" - done - $xtrace -} - -# Uncomment an option in an INI file -# iniuncomment config-file section option -function iniuncomment { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local section=$2 - local option=$3 - sed -i -e "/^\[$section\]/,/^\[.*\]/ s|[^ \t]*#[ \t]*\($option[ \t]*=.*$\)|\1|" "$file" - $xtrace -} - -# Normalize config values to True or False -# Accepts as False: 0 no No NO false False FALSE -# Accepts as True: 1 yes Yes YES true True TRUE -# VAR=$(trueorfalse default-value test-value) -function trueorfalse { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local default=$1 - local testval=$2 - - [[ -z "$testval" ]] && { echo "$default"; return; } - [[ "0 no No NO false False FALSE" =~ "$testval" ]] && { echo "False"; return; } - [[ "1 yes Yes YES true True TRUE" =~ "$testval" ]] && { echo "True"; return; } - echo "$default" - $xtrace -} - - -# Control Functions -# ================= - -# Prints backtrace info -# filename:lineno:function -# backtrace level -function backtrace { - local level=$1 - local deep=$((${#BASH_SOURCE[@]} - 1)) - echo "[Call Trace]" - while [ $level -le $deep ]; do - echo "${BASH_SOURCE[$deep]}:${BASH_LINENO[$deep-1]}:${FUNCNAME[$deep-1]}" - deep=$((deep - 1)) - done -} - -# Prints line number and "message" then exits -# die $LINENO "message" -function die { - local exitcode=$? - set +o xtrace - local line=$1; shift - if [ $exitcode == 0 ]; then - exitcode=1 - fi - backtrace 2 - err $line "$*" - # Give buffers a second to flush - sleep 1 - exit $exitcode -} - -# Checks an environment variable is not set or has length 0 OR if the -# exit code is non-zero and prints "message" and exits -# NOTE: env-var is the variable name without a '$' -# die_if_not_set $LINENO env-var "message" -function die_if_not_set { - local exitcode=$? - FXTRACE=$(set +o | grep xtrace) - set +o xtrace - local line=$1; shift - local evar=$1; shift - if ! is_set $evar || [ $exitcode != 0 ]; then - die $line "$*" - fi - $FXTRACE -} - -# Prints line number and "message" in error format -# err $LINENO "message" -function err { - local exitcode=$? - errXTRACE=$(set +o | grep xtrace) - set +o xtrace - local msg="[ERROR] ${BASH_SOURCE[2]}:$1 $2" - echo $msg 1>&2; - if [[ -n ${SCREEN_LOGDIR} ]]; then - echo $msg >> "${SCREEN_LOGDIR}/error.log" - fi - $errXTRACE - return $exitcode -} - -# Checks an environment variable is not set or has length 0 OR if the -# exit code is non-zero and prints "message" -# NOTE: env-var is the variable name without a '$' -# err_if_not_set $LINENO env-var "message" -function err_if_not_set { - local exitcode=$? - errinsXTRACE=$(set +o | grep xtrace) - set +o xtrace - local line=$1; shift - local evar=$1; shift - if ! is_set $evar || [ $exitcode != 0 ]; then - err $line "$*" - fi - $errinsXTRACE - return $exitcode -} - -# Exit after outputting a message about the distribution not being supported. -# exit_distro_not_supported [optional-string-telling-what-is-missing] -function exit_distro_not_supported { - if [[ -z "$DISTRO" ]]; then - GetDistro - fi - - if [ $# -gt 0 ]; then - die $LINENO "Support for $DISTRO is incomplete: no support for $@" - else - die $LINENO "Support for $DISTRO is incomplete." - fi -} - -# Test if the named environment variable is set and not zero length -# is_set env-var -function is_set { - local var=\$"$1" - eval "[ -n \"$var\" ]" # For ex.: sh -c "[ -n \"$var\" ]" would be better, but several exercises depends on this -} - -# Prints line number and "message" in warning format -# warn $LINENO "message" -function warn { - local exitcode=$? - errXTRACE=$(set +o | grep xtrace) - set +o xtrace - local msg="[WARNING] ${BASH_SOURCE[2]}:$1 $2" - echo $msg 1>&2; - if [[ -n ${SCREEN_LOGDIR} ]]; then - echo $msg >> "${SCREEN_LOGDIR}/error.log" - fi - $errXTRACE - return $exitcode -} - - -# Distro Functions -# ================ - -# Determine OS Vendor, Release and Update -# Tested with OS/X, Ubuntu, RedHat, CentOS, Fedora -# Returns results in global variables: -# os_VENDOR - vendor name -# os_RELEASE - release -# os_UPDATE - update -# os_PACKAGE - package type -# os_CODENAME - vendor's codename for release -# GetOSVersion -function GetOSVersion { - # Figure out which vendor we are - if [[ -x "`which sw_vers 2>/dev/null`" ]]; then - # OS/X - os_VENDOR=`sw_vers -productName` - os_RELEASE=`sw_vers -productVersion` - os_UPDATE=${os_RELEASE##*.} - os_RELEASE=${os_RELEASE%.*} - os_PACKAGE="" - if [[ "$os_RELEASE" =~ "10.7" ]]; then - os_CODENAME="lion" - elif [[ "$os_RELEASE" =~ "10.6" ]]; then - os_CODENAME="snow leopard" - elif [[ "$os_RELEASE" =~ "10.5" ]]; then - os_CODENAME="leopard" - elif [[ "$os_RELEASE" =~ "10.4" ]]; then - os_CODENAME="tiger" - elif [[ "$os_RELEASE" =~ "10.3" ]]; then - os_CODENAME="panther" - else - os_CODENAME="" - fi - elif [[ -x $(which lsb_release 2>/dev/null) ]]; then - os_VENDOR=$(lsb_release -i -s) - os_RELEASE=$(lsb_release -r -s) - os_UPDATE="" - os_PACKAGE="rpm" - if [[ "Debian,Ubuntu,LinuxMint" =~ $os_VENDOR ]]; then - os_PACKAGE="deb" - elif [[ "SUSE LINUX" =~ $os_VENDOR ]]; then - lsb_release -d -s | grep -q openSUSE - if [[ $? -eq 0 ]]; then - os_VENDOR="openSUSE" - fi - elif [[ $os_VENDOR == "openSUSE project" ]]; then - os_VENDOR="openSUSE" - elif [[ $os_VENDOR =~ Red.*Hat ]]; then - os_VENDOR="Red Hat" - fi - os_CODENAME=$(lsb_release -c -s) - elif [[ -r /etc/redhat-release ]]; then - # Red Hat Enterprise Linux Server release 5.5 (Tikanga) - # Red Hat Enterprise Linux Server release 7.0 Beta (Maipo) - # CentOS release 5.5 (Final) - # CentOS Linux release 6.0 (Final) - # Fedora release 16 (Verne) - # XenServer release 6.2.0-70446c (xenenterprise) - os_CODENAME="" - for r in "Red Hat" CentOS Fedora XenServer; do - os_VENDOR=$r - if [[ -n "`grep \"$r\" /etc/redhat-release`" ]]; then - ver=`sed -e 's/^.* \([0-9].*\) (\(.*\)).*$/\1\|\2/' /etc/redhat-release` - os_CODENAME=${ver#*|} - os_RELEASE=${ver%|*} - os_UPDATE=${os_RELEASE##*.} - os_RELEASE=${os_RELEASE%.*} - break - fi - os_VENDOR="" - done - os_PACKAGE="rpm" - elif [[ -r /etc/SuSE-release ]]; then - for r in openSUSE "SUSE Linux"; do - if [[ "$r" = "SUSE Linux" ]]; then - os_VENDOR="SUSE LINUX" - else - os_VENDOR=$r - fi - - if [[ -n "`grep \"$r\" /etc/SuSE-release`" ]]; then - os_CODENAME=`grep "CODENAME = " /etc/SuSE-release | sed 's:.* = ::g'` - os_RELEASE=`grep "VERSION = " /etc/SuSE-release | sed 's:.* = ::g'` - os_UPDATE=`grep "PATCHLEVEL = " /etc/SuSE-release | sed 's:.* = ::g'` - break - fi - os_VENDOR="" - done - os_PACKAGE="rpm" - # If lsb_release is not installed, we should be able to detect Debian OS - elif [[ -f /etc/debian_version ]] && [[ $(cat /proc/version) =~ "Debian" ]]; then - os_VENDOR="Debian" - os_PACKAGE="deb" - os_CODENAME=$(awk '/VERSION=/' /etc/os-release | sed 's/VERSION=//' | sed -r 's/\"|\(|\)//g' | awk '{print $2}') - os_RELEASE=$(awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' | sed 's/\"//g') - fi - export os_VENDOR os_RELEASE os_UPDATE os_PACKAGE os_CODENAME -} - -# Translate the OS version values into common nomenclature -# Sets global ``DISTRO`` from the ``os_*`` values -function GetDistro { - GetOSVersion - if [[ "$os_VENDOR" =~ (Ubuntu) || "$os_VENDOR" =~ (Debian) ]]; then - # 'Everyone' refers to Ubuntu / Debian releases by the code name adjective - DISTRO=$os_CODENAME - elif [[ "$os_VENDOR" =~ (Fedora) ]]; then - # For Fedora, just use 'f' and the release - DISTRO="f$os_RELEASE" - elif [[ "$os_VENDOR" =~ (openSUSE) ]]; then - DISTRO="opensuse-$os_RELEASE" - elif [[ "$os_VENDOR" =~ (SUSE LINUX) ]]; then - # For SLE, also use the service pack - if [[ -z "$os_UPDATE" ]]; then - DISTRO="sle${os_RELEASE}" - else - DISTRO="sle${os_RELEASE}sp${os_UPDATE}" - fi - elif [[ "$os_VENDOR" =~ (Red Hat) || "$os_VENDOR" =~ (CentOS) ]]; then - # Drop the . release as we assume it's compatible - DISTRO="rhel${os_RELEASE::1}" - elif [[ "$os_VENDOR" =~ (XenServer) ]]; then - DISTRO="xs$os_RELEASE" - else - # Catch-all for now is Vendor + Release + Update - DISTRO="$os_VENDOR-$os_RELEASE.$os_UPDATE" - fi - export DISTRO -} - -# Utility function for checking machine architecture -# is_arch arch-type -function is_arch { - ARCH_TYPE=$1 - - [[ "$(uname -m)" == "$ARCH_TYPE" ]] -} - -# Determine if current distribution is a Fedora-based distribution -# (Fedora, RHEL, CentOS, etc). -# is_fedora -function is_fedora { - if [[ -z "$os_VENDOR" ]]; then - GetOSVersion - fi - - [ "$os_VENDOR" = "Fedora" ] || [ "$os_VENDOR" = "Red Hat" ] || [ "$os_VENDOR" = "CentOS" ] -} - - -# Determine if current distribution is a SUSE-based distribution -# (openSUSE, SLE). -# is_suse -function is_suse { - if [[ -z "$os_VENDOR" ]]; then - GetOSVersion - fi - - [ "$os_VENDOR" = "openSUSE" ] || [ "$os_VENDOR" = "SUSE LINUX" ] -} - - -# Determine if current distribution is an Ubuntu-based distribution -# It will also detect non-Ubuntu but Debian-based distros -# is_ubuntu -function is_ubuntu { - if [[ -z "$os_PACKAGE" ]]; then - GetOSVersion - fi - [ "$os_PACKAGE" = "deb" ] -} - - -# Git Functions -# ============= - -# Returns openstack release name for a given branch name -# ``get_release_name_from_branch branch-name`` -function get_release_name_from_branch { - local branch=$1 - if [[ $branch =~ "stable/" ]]; then - echo ${branch#*/} - else - echo "master" - fi -} - -# git clone only if directory doesn't exist already. Since ``DEST`` might not -# be owned by the installation user, we create the directory and change the -# ownership to the proper user. -# Set global RECLONE=yes to simulate a clone when dest-dir exists -# Set global ERROR_ON_CLONE=True to abort execution with an error if the git repo -# does not exist (default is False, meaning the repo will be cloned). -# Uses global ``OFFLINE`` -# git_clone remote dest-dir branch -function git_clone { - GIT_REMOTE=$1 - GIT_DEST=$2 - GIT_REF=$3 - RECLONE=$(trueorfalse False $RECLONE) - local orig_dir=`pwd` - - if [[ "$OFFLINE" = "True" ]]; then - echo "Running in offline mode, clones already exist" - # print out the results so we know what change was used in the logs - cd $GIT_DEST - git show --oneline | head -1 - cd $orig_dir - return - fi - - if echo $GIT_REF | egrep -q "^refs"; then - # If our branch name is a gerrit style refs/changes/... - if [[ ! -d $GIT_DEST ]]; then - [[ "$ERROR_ON_CLONE" = "True" ]] && \ - die $LINENO "Cloning not allowed in this configuration" - git_timed clone $GIT_REMOTE $GIT_DEST - fi - cd $GIT_DEST - git_timed fetch $GIT_REMOTE $GIT_REF && git checkout FETCH_HEAD - else - # do a full clone only if the directory doesn't exist - if [[ ! -d $GIT_DEST ]]; then - [[ "$ERROR_ON_CLONE" = "True" ]] && \ - die $LINENO "Cloning not allowed in this configuration" - git_timed clone $GIT_REMOTE $GIT_DEST - cd $GIT_DEST - # This checkout syntax works for both branches and tags - git checkout $GIT_REF - elif [[ "$RECLONE" = "True" ]]; then - # if it does exist then simulate what clone does if asked to RECLONE - cd $GIT_DEST - # set the url to pull from and fetch - git remote set-url origin $GIT_REMOTE - git_timed fetch origin - # remove the existing ignored files (like pyc) as they cause breakage - # (due to the py files having older timestamps than our pyc, so python - # thinks the pyc files are correct using them) - find $GIT_DEST -name '*.pyc' -delete - - # handle GIT_REF accordingly to type (tag, branch) - if [[ -n "`git show-ref refs/tags/$GIT_REF`" ]]; then - git_update_tag $GIT_REF - elif [[ -n "`git show-ref refs/heads/$GIT_REF`" ]]; then - git_update_branch $GIT_REF - elif [[ -n "`git show-ref refs/remotes/origin/$GIT_REF`" ]]; then - git_update_remote_branch $GIT_REF - else - die $LINENO "$GIT_REF is neither branch nor tag" - fi - - fi - fi - - # print out the results so we know what change was used in the logs - cd $GIT_DEST - git show --oneline | head -1 - cd $orig_dir -} - -# git can sometimes get itself infinitely stuck with transient network -# errors or other issues with the remote end. This wraps git in a -# timeout/retry loop and is intended to watch over non-local git -# processes that might hang. GIT_TIMEOUT, if set, is passed directly -# to timeout(1); otherwise the default value of 0 maintains the status -# quo of waiting forever. -# usage: git_timed -function git_timed { - local count=0 - local timeout=0 - - if [[ -n "${GIT_TIMEOUT}" ]]; then - timeout=${GIT_TIMEOUT} - fi - - until timeout -s SIGINT ${timeout} git "$@"; do - # 124 is timeout(1)'s special return code when it reached the - # timeout; otherwise assume fatal failure - if [[ $? -ne 124 ]]; then - die $LINENO "git call failed: [git $@]" - fi - - count=$(($count + 1)) - warn "timeout ${count} for git call: [git $@]" - if [ $count -eq 3 ]; then - die $LINENO "Maximum of 3 git retries reached" - fi - sleep 5 - done -} - -# git update using reference as a branch. -# git_update_branch ref -function git_update_branch { - - GIT_BRANCH=$1 - - git checkout -f origin/$GIT_BRANCH - # a local branch might not exist - git branch -D $GIT_BRANCH || true - git checkout -b $GIT_BRANCH -} - -# git update using reference as a branch. -# git_update_remote_branch ref -function git_update_remote_branch { - - GIT_BRANCH=$1 - - git checkout -b $GIT_BRANCH -t origin/$GIT_BRANCH -} - -# git update using reference as a tag. Be careful editing source at that repo -# as working copy will be in a detached mode -# git_update_tag ref -function git_update_tag { - - GIT_TAG=$1 - - git tag -d $GIT_TAG - # fetching given tag only - git_timed fetch origin tag $GIT_TAG - git checkout -f $GIT_TAG -} - - -# OpenStack Functions -# =================== - -# Get the default value for HOST_IP -# get_default_host_ip fixed_range floating_range host_ip_iface host_ip -function get_default_host_ip { - local fixed_range=$1 - local floating_range=$2 - local host_ip_iface=$3 - local host_ip=$4 - - # Find the interface used for the default route - host_ip_iface=${host_ip_iface:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }' | head -1)} - # Search for an IP unless an explicit is set by ``HOST_IP`` environment variable - if [ -z "$host_ip" -o "$host_ip" == "dhcp" ]; then - host_ip="" - host_ips=`LC_ALL=C ip -f inet addr show ${host_ip_iface} | awk '/inet/ {split($2,parts,"/"); print parts[1]}'` - for IP in $host_ips; do - # Attempt to filter out IP addresses that are part of the fixed and - # floating range. Note that this method only works if the ``netaddr`` - # python library is installed. If it is not installed, an error - # will be printed and the first IP from the interface will be used. - # If that is not correct set ``HOST_IP`` in ``localrc`` to the correct - # address. - if ! (address_in_net $IP $fixed_range || address_in_net $IP $floating_range); then - host_ip=$IP - break; - fi - done - fi - echo $host_ip -} - -# Grab a numbered field from python prettytable output -# Fields are numbered starting with 1 -# Reverse syntax is supported: -1 is the last field, -2 is second to last, etc. -# get_field field-number -function get_field { - while read data; do - if [ "$1" -lt 0 ]; then - field="(\$(NF$1))" - else - field="\$$(($1 + 1))" - fi - echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}" - done -} - -# Add a policy to a policy.json file -# Do nothing if the policy already exists -# ``policy_add policy_file policy_name policy_permissions`` -function policy_add { - local policy_file=$1 - local policy_name=$2 - local policy_perm=$3 - - if grep -q ${policy_name} ${policy_file}; then - echo "Policy ${policy_name} already exists in ${policy_file}" - return - fi - - # Add a terminating comma to policy lines without one - # Remove the closing '}' and all lines following to the end-of-file - local tmpfile=$(mktemp) - uniq ${policy_file} | sed -e ' - s/]$/],/ - /^[}]/,$d - ' > ${tmpfile} - - # Append policy and closing brace - echo " \"${policy_name}\": ${policy_perm}" >>${tmpfile} - echo "}" >>${tmpfile} - - mv ${tmpfile} ${policy_file} -} - - -# Package Functions -# ================= - -# _get_package_dir -function _get_package_dir { - local pkg_dir - if is_ubuntu; then - pkg_dir=$FILES/apts - elif is_fedora; then - pkg_dir=$FILES/rpms - elif is_suse; then - pkg_dir=$FILES/rpms-suse - else - exit_distro_not_supported "list of packages" - fi - echo "$pkg_dir" -} - -# Wrapper for ``apt-get`` to set cache and proxy environment variables -# Uses globals ``OFFLINE``, ``*_proxy`` -# apt_get operation package [package ...] -function apt_get { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - - [[ "$OFFLINE" = "True" || -z "$@" ]] && return - local sudo="sudo" - [[ "$(id -u)" = "0" ]] && sudo="env" - - $xtrace - $sudo DEBIAN_FRONTEND=noninteractive \ - http_proxy=$http_proxy https_proxy=$https_proxy \ - no_proxy=$no_proxy \ - apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@" -} - -# get_packages() collects a list of package names of any type from the -# prerequisite files in ``files/{apts|rpms}``. The list is intended -# to be passed to a package installer such as apt or yum. -# -# Only packages required for the services in 1st argument will be -# included. Two bits of metadata are recognized in the prerequisite files: -# -# - ``# NOPRIME`` defers installation to be performed later in `stack.sh` -# - ``# dist:DISTRO`` or ``dist:DISTRO1,DISTRO2`` limits the selection -# of the package to the distros listed. The distro names are case insensitive. -function get_packages { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local services=$@ - local package_dir=$(_get_package_dir) - local file_to_parse - local service - - if [[ -z "$package_dir" ]]; then - echo "No package directory supplied" - return 1 - fi - if [[ -z "$DISTRO" ]]; then - GetDistro - echo "Found Distro $DISTRO" - fi - for service in ${services//,/ }; do - # Allow individual services to specify dependencies - if [[ -e ${package_dir}/${service} ]]; then - file_to_parse="${file_to_parse} $service" - fi - # NOTE(sdague) n-api needs glance for now because that's where - # glance client is - if [[ $service == n-api ]]; then - if [[ ! $file_to_parse =~ nova ]]; then - file_to_parse="${file_to_parse} nova" - fi - if [[ ! $file_to_parse =~ glance ]]; then - file_to_parse="${file_to_parse} glance" - fi - elif [[ $service == c-* ]]; then - if [[ ! $file_to_parse =~ cinder ]]; then - file_to_parse="${file_to_parse} cinder" - fi - elif [[ $service == ceilometer-* ]]; then - if [[ ! $file_to_parse =~ ceilometer ]]; then - file_to_parse="${file_to_parse} ceilometer" - fi - elif [[ $service == s-* ]]; then - if [[ ! $file_to_parse =~ swift ]]; then - file_to_parse="${file_to_parse} swift" - fi - elif [[ $service == n-* ]]; then - if [[ ! $file_to_parse =~ nova ]]; then - file_to_parse="${file_to_parse} nova" - fi - elif [[ $service == g-* ]]; then - if [[ ! $file_to_parse =~ glance ]]; then - file_to_parse="${file_to_parse} glance" - fi - elif [[ $service == key* ]]; then - if [[ ! $file_to_parse =~ keystone ]]; then - file_to_parse="${file_to_parse} keystone" - fi - elif [[ $service == q-* ]]; then - if [[ ! $file_to_parse =~ neutron ]]; then - file_to_parse="${file_to_parse} neutron" - fi - elif [[ $service == ir-* ]]; then - if [[ ! $file_to_parse =~ ironic ]]; then - file_to_parse="${file_to_parse} ironic" - fi - fi - done - - for file in ${file_to_parse}; do - local fname=${package_dir}/${file} - local OIFS line package distros distro - [[ -e $fname ]] || continue - - OIFS=$IFS - IFS=$'\n' - for line in $(<${fname}); do - if [[ $line =~ "NOPRIME" ]]; then - continue - fi - - # Assume we want this package - package=${line%#*} - inst_pkg=1 - - # Look for # dist:xxx in comment - if [[ $line =~ (.*)#.*dist:([^ ]*) ]]; then - # We are using BASH regexp matching feature. - package=${BASH_REMATCH[1]} - distros=${BASH_REMATCH[2]} - # In bash ${VAR,,} will lowecase VAR - # Look for a match in the distro list - if [[ ! ${distros,,} =~ ${DISTRO,,} ]]; then - # If no match then skip this package - inst_pkg=0 - fi - fi - - # Look for # testonly in comment - if [[ $line =~ (.*)#.*testonly.* ]]; then - package=${BASH_REMATCH[1]} - # Are we installing test packages? (test for the default value) - if [[ $INSTALL_TESTONLY_PACKAGES = "False" ]]; then - # If not installing test packages the skip this package - inst_pkg=0 - fi - fi - - if [[ $inst_pkg = 1 ]]; then - echo $package - fi - done - IFS=$OIFS - done - $xtrace -} - -# Distro-agnostic package installer -# install_package package [package ...] -function install_package { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - if is_ubuntu; then - # if there are transient errors pulling the updates, that's fine. It may - # be secondary repositories that we don't really care about. - [[ "$NO_UPDATE_REPOS" = "True" ]] || apt_get update || /bin/true - NO_UPDATE_REPOS=True - - $xtrace - apt_get install "$@" - elif is_fedora; then - $xtrace - yum_install "$@" - elif is_suse; then - $xtrace - zypper_install "$@" - else - $xtrace - exit_distro_not_supported "installing packages" - fi -} - -# Distro-agnostic function to tell if a package is installed -# is_package_installed package [package ...] -function is_package_installed { - if [[ -z "$@" ]]; then - return 1 - fi - - if [[ -z "$os_PACKAGE" ]]; then - GetOSVersion - fi - - if [[ "$os_PACKAGE" = "deb" ]]; then - dpkg -s "$@" > /dev/null 2> /dev/null - elif [[ "$os_PACKAGE" = "rpm" ]]; then - rpm --quiet -q "$@" - else - exit_distro_not_supported "finding if a package is installed" - fi -} - -# Distro-agnostic package uninstaller -# uninstall_package package [package ...] -function uninstall_package { - if is_ubuntu; then - apt_get purge "$@" - elif is_fedora; then - sudo yum remove -y "$@" - elif is_suse; then - sudo zypper rm "$@" - else - exit_distro_not_supported "uninstalling packages" - fi -} - -# Wrapper for ``yum`` to set proxy environment variables -# Uses globals ``OFFLINE``, ``*_proxy`` -# yum_install package [package ...] -function yum_install { - [[ "$OFFLINE" = "True" ]] && return - local sudo="sudo" - [[ "$(id -u)" = "0" ]] && sudo="env" - - # The manual check for missing packages is because yum -y assumes - # missing packages are OK. See - # https://bugzilla.redhat.com/show_bug.cgi?id=965567 - $sudo http_proxy=$http_proxy https_proxy=$https_proxy \ - no_proxy=$no_proxy \ - yum install -y "$@" 2>&1 | \ - awk ' - BEGIN { fail=0 } - /No package/ { fail=1 } - { print } - END { exit fail }' || \ - die $LINENO "Missing packages detected" - - # also ensure we catch a yum failure - if [[ ${PIPESTATUS[0]} != 0 ]]; then - die $LINENO "Yum install failure" - fi -} - -# zypper wrapper to set arguments correctly -# zypper_install package [package ...] -function zypper_install { - [[ "$OFFLINE" = "True" ]] && return - local sudo="sudo" - [[ "$(id -u)" = "0" ]] && sudo="env" - $sudo http_proxy=$http_proxy https_proxy=$https_proxy \ - zypper --non-interactive install --auto-agree-with-licenses "$@" -} - - -# Process Functions -# ================= - -# _run_process() is designed to be backgrounded by run_process() to simulate a -# fork. It includes the dirty work of closing extra filehandles and preparing log -# files to produce the same logs as screen_it(). The log filename is derived -# from the service name and global-and-now-misnamed SCREEN_LOGDIR -# _run_process service "command-line" -function _run_process { - local service=$1 - local command="$2" - - # Undo logging redirections and close the extra descriptors - exec 1>&3 - exec 2>&3 - exec 3>&- - exec 6>&- - - if [[ -n ${SCREEN_LOGDIR} ]]; then - exec 1>&${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log 2>&1 - ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log - - # TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs. - export PYTHONUNBUFFERED=1 - fi - - exec /bin/bash -c "$command" - die "$service exec failure: $command" -} - -# Helper to remove the ``*.failure`` files under ``$SERVICE_DIR/$SCREEN_NAME``. -# This is used for ``service_check`` when all the ``screen_it`` are called finished -# init_service_check -function init_service_check { - SCREEN_NAME=${SCREEN_NAME:-stack} - SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} - - if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then - mkdir -p "$SERVICE_DIR/$SCREEN_NAME" - fi - - rm -f "$SERVICE_DIR/$SCREEN_NAME"/*.failure -} - -# Find out if a process exists by partial name. -# is_running name -function is_running { - local name=$1 - ps auxw | grep -v grep | grep ${name} > /dev/null - RC=$? - # some times I really hate bash reverse binary logic - return $RC -} - -# run_process() launches a child process that closes all file descriptors and -# then exec's the passed in command. This is meant to duplicate the semantics -# of screen_it() without screen. PIDs are written to -# $SERVICE_DIR/$SCREEN_NAME/$service.pid -# run_process service "command-line" -function run_process { - local service=$1 - local command="$2" - - # Spawn the child process - _run_process "$service" "$command" & - echo $! -} - -# Helper to launch a service in a named screen -# screen_it service "command-line" -function screen_it { - SCREEN_NAME=${SCREEN_NAME:-stack} - SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} - USE_SCREEN=$(trueorfalse True $USE_SCREEN) - - if is_service_enabled $1; then - # Append the service to the screen rc file - screen_rc "$1" "$2" - - if [[ "$USE_SCREEN" = "True" ]]; then - screen -S $SCREEN_NAME -X screen -t $1 - - if [[ -n ${SCREEN_LOGDIR} ]]; then - screen -S $SCREEN_NAME -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log - screen -S $SCREEN_NAME -p $1 -X log on - ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log - fi - - # sleep to allow bash to be ready to be send the command - we are - # creating a new window in screen and then sends characters, so if - # bash isn't running by the time we send the command, nothing happens - sleep 1.5 - - NL=`echo -ne '\015'` - # This fun command does the following: - # - the passed server command is backgrounded - # - the pid of the background process is saved in the usual place - # - the server process is brought back to the foreground - # - if the server process exits prematurely the fg command errors - # and a message is written to stdout and the service failure file - # The pid saved can be used in screen_stop() as a process group - # id to kill off all child processes - screen -S $SCREEN_NAME -p $1 -X stuff "$2 & echo \$! >$SERVICE_DIR/$SCREEN_NAME/$1.pid; fg || echo \"$1 failed to start\" | tee \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL" - else - # Spawn directly without screen - run_process "$1" "$2" >$SERVICE_DIR/$SCREEN_NAME/$1.pid - fi - fi -} - -# Screen rc file builder -# screen_rc service "command-line" -function screen_rc { - SCREEN_NAME=${SCREEN_NAME:-stack} - SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc - if [[ ! -e $SCREENRC ]]; then - # Name the screen session - echo "sessionname $SCREEN_NAME" > $SCREENRC - # Set a reasonable statusbar - echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC - # Some distributions override PROMPT_COMMAND for the screen terminal type - turn that off - echo "setenv PROMPT_COMMAND /bin/true" >> $SCREENRC - echo "screen -t shell bash" >> $SCREENRC - fi - # If this service doesn't already exist in the screenrc file - if ! grep $1 $SCREENRC 2>&1 > /dev/null; then - NL=`echo -ne '\015'` - echo "screen -t $1 bash" >> $SCREENRC - echo "stuff \"$2$NL\"" >> $SCREENRC - - if [[ -n ${SCREEN_LOGDIR} ]]; then - echo "logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log" >>$SCREENRC - echo "log on" >>$SCREENRC - fi - fi -} - -# Stop a service in screen -# If a PID is available use it, kill the whole process group via TERM -# If screen is being used kill the screen window; this will catch processes -# that did not leave a PID behind -# screen_stop service -function screen_stop { - SCREEN_NAME=${SCREEN_NAME:-stack} - SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} - USE_SCREEN=$(trueorfalse True $USE_SCREEN) - - if is_service_enabled $1; then - # Kill via pid if we have one available - if [[ -r $SERVICE_DIR/$SCREEN_NAME/$1.pid ]]; then - pkill -TERM -P -$(cat $SERVICE_DIR/$SCREEN_NAME/$1.pid) - rm $SERVICE_DIR/$SCREEN_NAME/$1.pid - fi - if [[ "$USE_SCREEN" = "True" ]]; then - # Clean up the screen window - screen -S $SCREEN_NAME -p $1 -X kill - fi - fi -} - -# Helper to get the status of each running service -# service_check -function service_check { - local service - local failures - SCREEN_NAME=${SCREEN_NAME:-stack} - SERVICE_DIR=${SERVICE_DIR:-${DEST}/status} - - - if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then - echo "No service status directory found" - return - fi - - # Check if there is any falure flag file under $SERVICE_DIR/$SCREEN_NAME - # make this -o errexit safe - failures=`ls "$SERVICE_DIR/$SCREEN_NAME"/*.failure 2>/dev/null || /bin/true` - - for service in $failures; do - service=`basename $service` - service=${service%.failure} - echo "Error: Service $service is not running" - done - - if [ -n "$failures" ]; then - die $LINENO "More details about the above errors can be found with screen, with ./rejoin-stack.sh" - fi -} - - -# Python Functions -# ================ - -# Get the path to the pip command. -# get_pip_command -function get_pip_command { - which pip || which pip-python - - if [ $? -ne 0 ]; then - die $LINENO "Unable to find pip; cannot continue" - fi -} - -# Get the path to the direcotry where python executables are installed. -# get_python_exec_prefix -function get_python_exec_prefix { - if is_fedora || is_suse; then - echo "/usr/bin" - else - echo "/usr/local/bin" - fi -} - -# Wrapper for ``pip install`` to set cache and proxy environment variables -# Uses globals ``OFFLINE``, ``PIP_DOWNLOAD_CACHE``, ``PIP_USE_MIRRORS``, -# ``TRACK_DEPENDS``, ``*_proxy`` -# pip_install package [package ...] -function pip_install { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - if [[ "$OFFLINE" = "True" || -z "$@" ]]; then - $xtrace - return - fi - - if [[ -z "$os_PACKAGE" ]]; then - GetOSVersion - fi - if [[ $TRACK_DEPENDS = True ]]; then - source $DEST/.venv/bin/activate - CMD_PIP=$DEST/.venv/bin/pip - SUDO_PIP="env" - else - SUDO_PIP="sudo" - CMD_PIP=$(get_pip_command) - fi - - # Mirror option not needed anymore because pypi has CDN available, - # but it's useful in certain circumstances - PIP_USE_MIRRORS=${PIP_USE_MIRRORS:-False} - if [[ "$PIP_USE_MIRRORS" != "False" ]]; then - PIP_MIRROR_OPT="--use-mirrors" - fi - - # pip < 1.4 has a bug where it will use an already existing build - # directory unconditionally. Say an earlier component installs - # foo v1.1; pip will have built foo's source in - # /tmp/$USER-pip-build. Even if a later component specifies foo < - # 1.1, the existing extracted build will be used and cause - # confusing errors. By creating unique build directories we avoid - # this problem. See https://github.com/pypa/pip/issues/709 - local pip_build_tmp=$(mktemp --tmpdir -d pip-build.XXXXX) - - $xtrace - $SUDO_PIP PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE:-/var/cache/pip} \ - http_proxy=$http_proxy \ - https_proxy=$https_proxy \ - no_proxy=$no_proxy \ - $CMD_PIP install --build=${pip_build_tmp} \ - $PIP_MIRROR_OPT $@ \ - && $SUDO_PIP rm -rf ${pip_build_tmp} -} - -# this should be used if you want to install globally, all libraries should -# use this, especially *oslo* ones -function setup_install { - local project_dir=$1 - setup_package_with_req_sync $project_dir -} - -# this should be used for projects which run services, like all services -function setup_develop { - local project_dir=$1 - setup_package_with_req_sync $project_dir -e -} - -# ``pip install -e`` the package, which processes the dependencies -# using pip before running `setup.py develop` -# -# Updates the dependencies in project_dir from the -# openstack/requirements global list before installing anything. -# -# Uses globals ``TRACK_DEPENDS``, ``REQUIREMENTS_DIR``, ``UNDO_REQUIREMENTS`` -# setup_develop directory -function setup_package_with_req_sync { - local project_dir=$1 - local flags=$2 - - # Don't update repo if local changes exist - # Don't use buggy "git diff --quiet" - # ``errexit`` requires us to trap the exit code when the repo is changed - local update_requirements=$(cd $project_dir && git diff --exit-code >/dev/null || echo "changed") - - if [[ $update_requirements != "changed" ]]; then - (cd $REQUIREMENTS_DIR; \ - $SUDO_CMD python update.py $project_dir) - fi - - setup_package $project_dir $flags - - # We've just gone and possibly modified the user's source tree in an - # automated way, which is considered bad form if it's a development - # tree because we've screwed up their next git checkin. So undo it. - # - # However... there are some circumstances, like running in the gate - # where we really really want the overridden version to stick. So provide - # a variable that tells us whether or not we should UNDO the requirements - # changes (this will be set to False in the OpenStack ci gate) - if [ $UNDO_REQUIREMENTS = "True" ]; then - if [[ $update_requirements != "changed" ]]; then - (cd $project_dir && git reset --hard) - fi - fi -} - -# ``pip install -e`` the package, which processes the dependencies -# using pip before running `setup.py develop` -# Uses globals ``STACK_USER`` -# setup_develop_no_requirements_update directory -function setup_package { - local project_dir=$1 - local flags=$2 - - pip_install $flags $project_dir - # ensure that further actions can do things like setup.py sdist - if [[ "$flags" == "-e" ]]; then - safe_chown -R $STACK_USER $1/*.egg-info - fi -} - - -# Service Functions -# ================= - -# remove extra commas from the input string (i.e. ``ENABLED_SERVICES``) -# _cleanup_service_list service-list -function _cleanup_service_list { - echo "$1" | sed -e ' - s/,,/,/g; - s/^,//; - s/,$// - ' -} - -# disable_all_services() removes all current services -# from ``ENABLED_SERVICES`` to reset the configuration -# before a minimal installation -# Uses global ``ENABLED_SERVICES`` -# disable_all_services -function disable_all_services { - ENABLED_SERVICES="" -} - -# Remove all services starting with '-'. For example, to install all default -# services except rabbit (rabbit) set in ``localrc``: -# ENABLED_SERVICES+=",-rabbit" -# Uses global ``ENABLED_SERVICES`` -# disable_negated_services -function disable_negated_services { - local tmpsvcs="${ENABLED_SERVICES}" - local service - for service in ${tmpsvcs//,/ }; do - if [[ ${service} == -* ]]; then - tmpsvcs=$(echo ${tmpsvcs}|sed -r "s/(,)?(-)?${service#-}(,)?/,/g") - fi - done - ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs") -} - -# disable_service() removes the services passed as argument to the -# ``ENABLED_SERVICES`` list, if they are present. -# -# For example: -# disable_service rabbit -# -# This function does not know about the special cases -# for nova, glance, and neutron built into is_service_enabled(). -# Uses global ``ENABLED_SERVICES`` -# disable_service service [service ...] -function disable_service { - local tmpsvcs=",${ENABLED_SERVICES}," - local service - for service in $@; do - if is_service_enabled $service; then - tmpsvcs=${tmpsvcs//,$service,/,} - fi - done - ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs") -} - -# enable_service() adds the services passed as argument to the -# ``ENABLED_SERVICES`` list, if they are not already present. -# -# For example: -# enable_service qpid -# -# This function does not know about the special cases -# for nova, glance, and neutron built into is_service_enabled(). -# Uses global ``ENABLED_SERVICES`` -# enable_service service [service ...] -function enable_service { - local tmpsvcs="${ENABLED_SERVICES}" - for service in $@; do - if ! is_service_enabled $service; then - tmpsvcs+=",$service" - fi - done - ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs") - disable_negated_services -} - -# is_service_enabled() checks if the service(s) specified as arguments are -# enabled by the user in ``ENABLED_SERVICES``. -# -# Multiple services specified as arguments are ``OR``'ed together; the test -# is a short-circuit boolean, i.e it returns on the first match. -# -# There are special cases for some 'catch-all' services:: -# **nova** returns true if any service enabled start with **n-** -# **cinder** returns true if any service enabled start with **c-** -# **ceilometer** returns true if any service enabled start with **ceilometer** -# **glance** returns true if any service enabled start with **g-** -# **neutron** returns true if any service enabled start with **q-** -# **swift** returns true if any service enabled start with **s-** -# **trove** returns true if any service enabled start with **tr-** -# For backward compatibility if we have **swift** in ENABLED_SERVICES all the -# **s-** services will be enabled. This will be deprecated in the future. -# -# Cells within nova is enabled if **n-cell** is in ``ENABLED_SERVICES``. -# We also need to make sure to treat **n-cell-region** and **n-cell-child** -# as enabled in this case. -# -# Uses global ``ENABLED_SERVICES`` -# is_service_enabled service [service ...] -function is_service_enabled { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local enabled=1 - services=$@ - for service in ${services}; do - [[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && enabled=0 - - # Look for top-level 'enabled' function for this service - if type is_${service}_enabled >/dev/null 2>&1; then - # A function exists for this service, use it - is_${service}_enabled - enabled=$? - fi - - # TODO(dtroyer): Remove these legacy special-cases after the is_XXX_enabled() - # are implemented - - [[ ${service} == n-cell-* && ${ENABLED_SERVICES} =~ "n-cell" ]] && enabled=0 - [[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && enabled=0 - [[ ${service} == "cinder" && ${ENABLED_SERVICES} =~ "c-" ]] && enabled=0 - [[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && enabled=0 - [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && enabled=0 - [[ ${service} == "ironic" && ${ENABLED_SERVICES} =~ "ir-" ]] && enabled=0 - [[ ${service} == "neutron" && ${ENABLED_SERVICES} =~ "q-" ]] && enabled=0 - [[ ${service} == "trove" && ${ENABLED_SERVICES} =~ "tr-" ]] && enabled=0 - [[ ${service} == "swift" && ${ENABLED_SERVICES} =~ "s-" ]] && enabled=0 - [[ ${service} == s-* && ${ENABLED_SERVICES} =~ "swift" ]] && enabled=0 - done - $xtrace - return $enabled -} - -# Toggle enable/disable_service for services that must run exclusive of each other -# $1 The name of a variable containing a space-separated list of services -# $2 The name of a variable in which to store the enabled service's name -# $3 The name of the service to enable -function use_exclusive_service { - local options=${!1} - local selection=$3 - out=$2 - [ -z $selection ] || [[ ! "$options" =~ "$selection" ]] && return 1 - for opt in $options;do - [[ "$opt" = "$selection" ]] && enable_service $opt || disable_service $opt - done - eval "$out=$selection" - return 0 -} - - -# System Functions -# ================ - -# Only run the command if the target file (the last arg) is not on an -# NFS filesystem. -function _safe_permission_operation { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local args=( $@ ) - local last - local sudo_cmd - local dir_to_check - - let last="${#args[*]} - 1" - - dir_to_check=${args[$last]} - if [ ! -d "$dir_to_check" ]; then - dir_to_check=`dirname "$dir_to_check"` - fi - - if is_nfs_directory "$dir_to_check" ; then - $xtrace - return 0 - fi - - if [[ $TRACK_DEPENDS = True ]]; then - sudo_cmd="env" - else - sudo_cmd="sudo" - fi - - $xtrace - $sudo_cmd $@ -} - -# Exit 0 if address is in network or 1 if address is not in network -# ip-range is in CIDR notation: 1.2.3.4/20 -# address_in_net ip-address ip-range -function address_in_net { - local ip=$1 - local range=$2 - local masklen=${range#*/} - local network=$(maskip ${range%/*} $(cidr2netmask $masklen)) - local subnet=$(maskip $ip $(cidr2netmask $masklen)) - [[ $network == $subnet ]] -} - -# Add a user to a group. -# add_user_to_group user group -function add_user_to_group { - local user=$1 - local group=$2 - - if [[ -z "$os_VENDOR" ]]; then - GetOSVersion - fi - - # SLE11 and openSUSE 12.2 don't have the usual usermod - if ! is_suse || [[ "$os_VENDOR" = "openSUSE" && "$os_RELEASE" != "12.2" ]]; then - sudo usermod -a -G "$group" "$user" - else - sudo usermod -A "$group" "$user" - fi -} - -# Convert CIDR notation to a IPv4 netmask -# cidr2netmask cidr-bits -function cidr2netmask { - local maskpat="255 255 255 255" - local maskdgt="254 252 248 240 224 192 128" - set -- ${maskpat:0:$(( ($1 / 8) * 4 ))}${maskdgt:$(( (7 - ($1 % 8)) * 4 )):3} - echo ${1-0}.${2-0}.${3-0}.${4-0} -} - -# Gracefully cp only if source file/dir exists -# cp_it source destination -function cp_it { - if [ -e $1 ] || [ -d $1 ]; then - cp -pRL $1 $2 - fi -} - -# HTTP and HTTPS proxy servers are supported via the usual environment variables [1] -# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in -# ``localrc`` or on the command line if necessary:: -# -# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html -# -# http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh - -function export_proxy_variables { - if [[ -n "$http_proxy" ]]; then - export http_proxy=$http_proxy - fi - if [[ -n "$https_proxy" ]]; then - export https_proxy=$https_proxy - fi - if [[ -n "$no_proxy" ]]; then - export no_proxy=$no_proxy - fi -} - -# Returns true if the directory is on a filesystem mounted via NFS. -function is_nfs_directory { - local mount_type=`stat -f -L -c %T $1` - test "$mount_type" == "nfs" -} - -# Return the network portion of the given IP address using netmask -# netmask is in the traditional dotted-quad format -# maskip ip-address netmask -function maskip { - local ip=$1 - local mask=$2 - local l="${ip%.*}"; local r="${ip#*.}"; local n="${mask%.*}"; local m="${mask#*.}" - local subnet=$((${ip%%.*}&${mask%%.*})).$((${r%%.*}&${m%%.*})).$((${l##*.}&${n##*.})).$((${ip##*.}&${mask##*.})) - echo $subnet -} - -# Service wrapper to restart services -# restart_service service-name -function restart_service { - if is_ubuntu; then - sudo /usr/sbin/service $1 restart - else - sudo /sbin/service $1 restart - fi -} - -# Only change permissions of a file or directory if it is not on an -# NFS filesystem. -function safe_chmod { - _safe_permission_operation chmod $@ -} - -# Only change ownership of a file or directory if it is not on an NFS -# filesystem. -function safe_chown { - _safe_permission_operation chown $@ -} - -# Service wrapper to start services -# start_service service-name -function start_service { - if is_ubuntu; then - sudo /usr/sbin/service $1 start - else - sudo /sbin/service $1 start - fi -} - -# Service wrapper to stop services -# stop_service service-name -function stop_service { - if is_ubuntu; then - sudo /usr/sbin/service $1 stop - else - sudo /sbin/service $1 stop - fi -} - - -# Restore xtrace -$XTRACE - -# Local variables: -# mode: shell-script -# End: diff --git a/labs/lib/functions.guest b/labs/lib/functions.guest deleted file mode 100644 index 953a5353..00000000 --- a/labs/lib/functions.guest +++ /dev/null @@ -1,441 +0,0 @@ -# This file contains bash functions that may be used by guest systems (VMs). - -# Sourcing this file calls functions fix_path_env and source_deploy. - -source "$LIB_DIR/functions.sh" -source "$LIB_DIR/functions-common-devstack" - -# Make devstack's operating system identification work with nounset -function init_os_ident { - if [[ -z "${os_PACKAGE:-""}" ]]; then - GetOSVersion - fi -} - -function source_deploy { - if [ -n "${VM_SHELL_USER:-}" ]; then - # Already sourced - return 0 - fi - if mountpoint -q /vagrant; then - source "$CONFIG_DIR/deploy.vagrant" - else - source "$CONFIG_DIR/deploy.osbash" - fi -} -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# If our sudo user's PATH is preserved (and does not contain sbin dirs), -# some commands won't be found. Observed with Vagrant shell provisioner -# scripts using sudo after "su - vagrant". -# Adding to the path seems preferable to messing with the vagrant user's -# sudoers environment (or working with a separate Vagrant user). - -function fix_path_env { - if is_root; then return 0; fi - if echo 'echo $PATH'|sudo sh|grep -q '/sbin'; then return 0; fi - export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin -} -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function zero_empty_space { - echo "Filling empty disk space with zeros" - sudo dd if=/dev/zero of=/filler bs=1M 2>/dev/null || true - sudo rm /filler -} -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# For guest scripts to let osbash know they are running; used when osbashauto -# runs scripts inside of the VM (STATUS_DIR directory must be shared between -# host and VM). - -function indicate_current_auto { - if [ "${VM_SHELL_USER:-}" = "osbash" ]; then - local scr_name=${1:-$(basename "$0")} - local fpath=${2:-"/$STATUS_DIR/$scr_name.begin"} - mkdir -p "$STATUS_DIR" - touch "$fpath" - fi -} -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Debug function to make a script halt execution until a tmp file is removed - -function wait_for_file { - # If no argument is passed, use empty string (to pass nounset option) - local msg=${1-""} - local wait_file=remove_to_continue - [ -n "$msg" ] && wait_file=${wait_file}_${msg} - touch "/tmp/$wait_file" - while [ -e "/tmp/$wait_file" ]; do - sleep 1 - done -} -#------------------------------------------------------------------------------- -# Copy stdin/stderr to log file -#------------------------------------------------------------------------------- - -function exec_logpath { - local log_path=$1 - - # Append all stdin and stderr to log file - exec > >(tee -a "$log_path") 2>&1 -} - -function exec_logfile { - local log_dir=${1:-/home/$VM_SHELL_USER/log} - - # Default extension is log - local ext=${2:-log} - - mkdir -p "$log_dir" - - # Log name based on name of running script - local base_name=$(basename "$0" .sh) - - local prefix=$(get_next_prefix "$log_dir" "$ext") - local log_name="${prefix}_$base_name.$ext" - - exec_logpath "$log_dir/$log_name" -} - -#------------------------------------------------------------------------------- -# Functions that need to run as root -#------------------------------------------------------------------------------- - -function as_root_fix_mount_vboxsf_link { - local file=/sbin/mount.vboxsf - if [ -L $file -a ! -e $file ]; then - echo "$file is a broken symlink. Trying to fix it." - shopt -s nullglob - local new=(/opt/VBoxGuestAdditions*/lib/VBoxGuestAdditions) - if [ -n "$new" ]; then - ln -sv "$new" /usr/lib/VBoxGuestAdditions - else - return 1 - fi - fi -} - -function as_root_inject_sudoer { - if grep -q "${VM_SHELL_USER}" /etc/sudoers; then - echo "${VM_SHELL_USER} already in /etc/sudoers" - else - echo "${VM_SHELL_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers - echo "Defaults:${VM_SHELL_USER} !requiretty" >> /etc/sudoers - fi -} - -# Change to a regular user to execute a guest script (and log its output) - -function as_root_exec_script { - local script_path=$1 - local script_name="$(basename "$script_path" .sh)" - - echo "$(date) start $script_path" - - local prefix=$(get_next_prefix "$LOG_DIR" "auto") - local log_path=$LOG_DIR/${prefix}_$script_name.auto - - su - "$VM_SHELL_USER" -c "bash $script_path" >"$log_path" 2>&1 - local rc=$? - if [ $rc -ne 0 ]; then - echo "$(date) ERROR: status $rc for $script_path" | - tee >&2 -a "$LOG_DIR/error.log" - else - echo "$(date) done" - fi - return $rc -} - -#------------------------------------------------------------------------------- -# Root wrapper around devstack function for manipulating config files -#------------------------------------------------------------------------------- - -function iniset_sudo { - local file=$1 - shift - local tmpfile=$(mktemp) - # Create a temporary copy, work on it, and copy it back into place - sudo cp -fv "$file" "$tmpfile" - iniset "$tmpfile" "$@" - cat "$tmpfile" | sudo tee "$file" >/dev/null -} - -#------------------------------------------------------------------------------- -# Functions for manipulating config files without section -#------------------------------------------------------------------------------- - -function iniset_sudo_no_section { - local file=$1 - shift - local tmpfile=$(mktemp) - # Create a temporary copy, work on it, and copy it back into place - sudo cp -fv "$file" "$tmpfile" - iniset_no_section "$tmpfile" "$@" - cat "$tmpfile" | sudo tee "$file" >/dev/null -} - -# ini_has_option_no_section config-file option -function ini_has_option_no_section { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local option=$2 - local line - line=$(sed -ne "/^$option[ \t]*=/ p;" "$file") - $xtrace - [ -n "$line" ] -} - -# Set an option in an INI file -# iniset_no_section config-file option value -function iniset_no_section { - local xtrace=$(set +o | grep xtrace) - set +o xtrace - local file=$1 - local option=$2 - local value=$3 - - [[ -z $option ]] && return - - if ! ini_has_option_no_section "$file" "$option"; then - # Add it - sed -i -e "1 i\ -$option = $value -" "$file" - else - local sep=$(echo -ne "\x01") - # Replace it - sed -i -e "/$option/ c\ -$option = $value -" "$file" - fi - $xtrace -} - - -#------------------------------------------------------------------------------- -# OpenStack helpers -#------------------------------------------------------------------------------- - -function mysql_exe { - local cmd="$1" - echo "MySQL cmd: $cmd." - mysql -u "root" -p"$DATABASE_PASSWORD" -e "$cmd" -} - -function setup_database { - local service=$1 - local db_user=$(service_to_db_user $service) - local db_password=$(service_to_db_password $service) - mysql_exe "CREATE DATABASE $service" - mysql_exe "GRANT ALL ON ${service}.* TO '$db_user'@'%' IDENTIFIED BY '$db_password';" - mysql_exe "GRANT ALL ON ${service}.* TO '$db_user'@'localhost' IDENTIFIED BY '$db_password';" -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Users for service-specific MySQL databases - -function service_to_db_user { - local service_name=$1 - echo "${service_name}User" -} - -function service_to_db_password { - local service_name=$1 - echo "${service_name}Pass" -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Service-specific users in keystone - -function service_to_user_name { - local service_name=$1 - echo "${service_name}" -} - -function service_to_user_password { - local service_name=$1 - echo "${service_name}_pass" -} - -#------------------------------------------------------------------------------- -# Network configuration -#------------------------------------------------------------------------------- - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Fedora /etc/sysconfig/network-scripts/ifcfg-* configuration -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function _ifnum_to_ifname_fedora { - local if_num=$1 - local -a if_names=('p2p1' 'p7p1' 'p8p1' 'p9p1') - - echo "${if_names[$if_num]}" -} - -function _config_sysconfig_nat { - local if_num=$1 - - local if_name="$(_ifnum_to_ifname_fedora "$if_num")" - - local if_file=/etc/sysconfig/network-scripts/ifcfg-$if_name - - sed -e " - s,%IF_NAME%,$if_name,g; - " "$TEMPLATE_DIR/template-fedora-ifcfg-nat" | sudo tee "$if_file" -} - -function _config_sysconfig_hostonly { - local if_num=$1 - local ip_address=$2 - - local if_name="$(_ifnum_to_ifname_fedora "$if_num")" - - local if_file=/etc/sysconfig/network-scripts/ifcfg-$if_name - - sed -e " - s,%IF_NAME%,$if_name,g; - s,%IP_ADDRESS%,$ip_address,g; - " "$TEMPLATE_DIR/template-fedora-ifcfg-hostonly" | sudo tee "$if_file" -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Ubuntu /etc/network/interfaces configuration -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -readonly UBUNTU_IF_FILE=/etc/network/interfaces - -function _ifnum_to_ifname_ubuntu { - local if_num=$1 - local -a if_names=('eth0' 'eth1' 'eth2' 'eth3') - - echo "${if_names[$if_num]}" -} - - -function _config_interfaces_nat { - local if_num=$1 - - local if_name="$(_ifnum_to_ifname_ubuntu "$if_num")" - - # Empty line before this entry - echo | sudo tee -a "$UBUNTU_IF_FILE" - - sed -e " - s,%IF_NAME%,$if_name,g; - " "$TEMPLATE_DIR/template-ubuntu-interfaces-nat" | sudo tee -a "$UBUNTU_IF_FILE" -} - -function _config_interfaces_hostonly { - local if_num=$1 - local ip_address=$2 - - local if_name="$(_ifnum_to_ifname_ubuntu "$if_num")" - - # Empty line before this entry - echo | sudo tee -a "$UBUNTU_IF_FILE" - - sed -e " - s,%IF_NAME%,$if_name,g; - s,%IP_ADDRESS%,$ip_address,g; - " "$TEMPLATE_DIR/template-ubuntu-interfaces-hostonly" | sudo tee -a "$UBUNTU_IF_FILE" -} -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function config_nat { - local if_num=$1 - - init_os_ident - if is_fedora; then - echo _config_sysconfig_nat "$if_num" - _config_sysconfig_nat "$if_num" - else - echo _config_interfaces_nat "$if_num" - _config_interfaces_nat "$if_num" - fi -} - -function config_hostonly { - local if_num=$1 - local ip_address=$2 - - init_os_ident - if is_fedora; then - echo _config_sysconfig_hostonly "$if_num" "$ip_address" - _config_sysconfig_hostonly "$if_num" "$ip_address" - else - echo _config_interfaces_hostonly "$if_num" "$ip_address" - _config_interfaces_hostonly "$if_num" "$ip_address" - fi -} - -function get_ip_from_net_and_fourth { - local net_name=$1 - local net="${!net_name}" - local fourth_octet=$2 - - echo "${net%.*}.$fourth_octet" -} - -function hostname_to_ip { - local host_name=$1 - getent hosts "$host_name"|awk '{print $1}' -} - -function config_network { - init_os_ident - if is_ubuntu; then - # Configuration functions will append to this file - sudo cp -v "$TEMPLATE_DIR/template-ubuntu-interfaces-loopback" \ - "$UBUNTU_IF_FILE" - fi - - # Get FOURTH_OCTET and network interfaces (NET_IF_?) for this node - unset -v NET_IF_0 NET_IF_1 NET_IF_2 NET_IF_3 - source "$CONFIG_DIR/config.$(hostname)" - - # Get API_NET, DATA_NET, MGMT_NET - source "$CONFIG_DIR/openstack" - - # Iterate over all NET_IF_? variables - local net_ifs=( "${!NET_IF_@}" ) - local net_if="" - for net_if in "${net_ifs[@]}"; do - echo >&2 -n "${net_if} ${!net_if}" - local if_num=${net_if##*_} - if [ "${!net_if}" = "nat" ]; then - echo >&2 - config_nat "$if_num" - else - # Host-only network: net_if is net name (e.g. API_NET) - # Use corresponding value (e.g. 192.168.100.1) - IP="$(get_ip_from_net_and_fourth "${!net_if}" "$FOURTH_OCTET")" - echo >&2 " $IP" - - config_hostonly "$if_num" "$IP" - fi - done -} - -#------------------------------------------------------------------------------- -# ssh wrapper functions -#------------------------------------------------------------------------------- - -function no_chk_ssh { - echo >&2 "ssh $@" - # Options set to disable strict host key checking and related messages. - ssh \ - -o "UserKnownHostsFile /dev/null" \ - -o "StrictHostKeyChecking no" \ - -o LogLevel=error \ - "$@" -} - -# ssh from one node VM to another node in the cluster -function node_ssh { - no_chk_ssh -i "$HOME/.ssh/osbash_key" "$@" -} - -#------------------------------------------------------------------------------- -fix_path_env -source_deploy -#------------------------------------------------------------------------------- - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/functions.sh b/labs/lib/functions.sh deleted file mode 100644 index d9e4b5cb..00000000 --- a/labs/lib/functions.sh +++ /dev/null @@ -1,91 +0,0 @@ -# This file contains bash functions that may be used by both guest and host -# systems. - -# Non-recursive removal of all files except README.* -function clean_dir { - local target_dir=$1 - if [ ! -e "$target_dir" ]; then - mkdir -pv "$target_dir" - elif [ ! -d "$target_dir" ]; then - echo >&2 "Not a directory: $target_dir" - return 1 - fi - shopt -s nullglob - local entries=("$target_dir"/*) - if [ -n "${entries[0]-}" ]; then - for f in "${entries[@]}"; do - # Skip directories - if [ ! -f "$f" ]; then - continue - fi - - # Skip README.* - if [[ $f =~ /README\. ]]; then - continue - fi - - rm -f "$f" - done - fi -} - -function is_root { - if [ $EUID -eq 0 ]; then - return 0 - else - return 1 - fi -} - -function yes_or_no { - local prompt=$1 - local input="" - while [ : ]; do - read -p "$prompt (Y/n): " input - case "$input" in - N|n) - return 1 - ;; - ""|Y|y) - return 0 - ;; - *) - echo -e "${CError:-}Invalid input: ${CData:-}$input${CReset:-}" - ;; - esac - done -} - -#------------------------------------------------------------------------------- -# Helpers to incrementally number files via name prefixes -#------------------------------------------------------------------------------- - -function get_next_file_number { - local dir=$1 - local ext=${2:-""} - - # Get number of *.log files in directory - shopt -s nullglob - if [ -n "$ext" ]; then - # Count files with specific extension - local files=("$dir/"*".$ext") - else - # Count all files - local files=("$dir/"*) - fi - echo "${#files[*]}" -} - -function get_next_prefix { - local dir=$1 - local ext=$2 - # Number of digits in prefix string (default 3) - local digits=${3:-3} - - # Get number of *.$ext files in $dir - local cnt=$(get_next_file_number "$dir" "$ext") - - printf "%0${digits}d" "$cnt" -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/osbash-ssh-keys/README.rst b/labs/lib/osbash-ssh-keys/README.rst deleted file mode 100644 index 7f2dbcfd..00000000 --- a/labs/lib/osbash-ssh-keys/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains the insecure ssh keys used by osbash for logging into -the node VMs. diff --git a/labs/lib/osbash-ssh-keys/osbash_key b/labs/lib/osbash-ssh-keys/osbash_key deleted file mode 100644 index 26c6434e..00000000 --- a/labs/lib/osbash-ssh-keys/osbash_key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEA0pxig+FU4OyoaJjYRcYzvFX70h2Sc7hUr7YSvYyHh9vjOOUE -0eG2rWPuKjravQ8xoI7ElaeoT9kEn3FW2bUi9444d7I0jdxK0+FCnqkXoTV/2wip -nR4NHiuZtRGz6SZWPn80mI+Kg8OcfKw3haB1R8nYdo8kRXXd/fzHGjUDmLkEZmW0 -fX+yCEh/fYrCMZqLGJ9z3gHyFQHC6k/TnGD4DyifrbE72xZGBNoTokuxHpNAvdCj -lWyT9NVc92/3HBGEOVhZS9KKhZHrFUOSOHLYdcDBtuoJW2TuUlU9BgJXTML5vh/8 -J1YUPwIxeTZriBBp+OSuP3NHLKCM1nCnbjxMnwIDAQABAoIBAAkrH6rIE27bPpWX -GcsnzrbDM3w5J1f8TUt87KHtzTSf4OtoJOaSIea4c/TIrR8P20Q3Et3E97HKK8ZZ -I8PEe+o0+cZULq+CSIuiwciwacPt1UwOu3uIhF+s3DsisydSMOz1kq+ViB0mVdij -kqMxkgl3AwJeRuDzOZ/F8lD0v9xVFVggqA5DLJhrXtPXrkMZYDlI9RtA3qvD1/RN -/0QFiZNvbG9DpH/us5SWhI8FAtLgVBeylx5rLBebY59WGl2plyitGGOjtmTc7060 -bBWOZzT6PfruXvLj9O7dQwcEb0QNtAeNKHnyllYPNRHK8+WWP9JMg+h0JmV3r/UW -ArGUvAECgYEA9pBDiTPdHKEdJW/Aic4ZGWMNbkCbxN6tHNXPfUQrOiyWtpShUjzI -l4A9k6KTuWhsNQuLV2Cthdoa9WvEx9do/KXGuiXOhSkBm0ictsEeJMH50LbnQ6bX -qMx7EPdyxmKQjcblUkB2Q+0TovPTPI61U9KYRFsj4iDXDftlrf/+Jp8CgYEA2qve -2uWQvXWHe4EMKZpc/BqAIWmJiXzP9o4AD9ClOP9InNr2RVxVcTTVG0YEEqQDbPYi -lq5k65QAA7NaojvHaawhz+VPqRFAKtzqzUpsDZPh9Db737Qclh3WacQiEecmHwtP -1mYEIQTlCKTKfZ5yM0NASBD9kwWtjSSf2zpuGgECgYAEFfPojCF33fubqTRplC66 -SvfoAc4S/xWjSq+7hauptR9yOxhJQpSYXhmnHqSQB/jzEBPpCMMXWrvjoTuLjDhD -J4QZhZLchgduyU8/gAe92DEJkl5WsqcUNv87Er6mJu/6SXd3W3YaPg17P8saT8sV -boHzcAcyMhUeODJBJeLSRQKBgQDVOdygNFPz+oO20XoroyLijXC9o+yCTVt4PrUe -tsQ1lPCYSwbzUXrbXboj0x0rlBTnDgdiSQGNmY5+DUjmg0YK69c4opEP+gtJAIxQ -zC4a+0XMXkUyuK1bUBMApUjXjj7k7KHYHTgPfnda+12cKoGPLRekbjTlRRcbV0gt -fIdaAQKBgGE1nzOZtA0z1cEVcucfy9yHjZqic1JN0os1H52CzsPUwCjpAwTMct9J -7aLusbHBKQZgoOBuC0O/erV02oQIzTLWcjf45Uj52r0Rgt2kJpOKy8aPMZ9cpbq4 -tfMrBy/mZc7joHtfwtexLMm5EotkvHEzGXDIRZuyzOSTmlpSzEz3 ------END RSA PRIVATE KEY----- diff --git a/labs/lib/osbash-ssh-keys/osbash_key.pub b/labs/lib/osbash-ssh-keys/osbash_key.pub deleted file mode 100644 index e4c98a3d..00000000 --- a/labs/lib/osbash-ssh-keys/osbash_key.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSnGKD4VTg7KhomNhFxjO8VfvSHZJzuFSvthK9jIeH2+M45QTR4batY+4qOtq9DzGgjsSVp6hP2QSfcVbZtSL3jjh3sjSN3ErT4UKeqRehNX/bCKmdHg0eK5m1EbPpJlY+fzSYj4qDw5x8rDeFoHVHydh2jyRFdd39/McaNQOYuQRmZbR9f7IISH99isIxmosYn3PeAfIVAcLqT9OcYPgPKJ+tsTvbFkYE2hOiS7Eek0C90KOVbJP01Vz3b/ccEYQ5WFlL0oqFkesVQ5I4cth1wMG26glbZO5SVT0GAldMwvm+H/wnVhQ/AjF5NmuIEGn45K4/c0csoIzWcKduPEyf osbash insecure public key diff --git a/labs/lib/osbash/functions-host.sh b/labs/lib/osbash/functions-host.sh deleted file mode 100644 index 62337ba3..00000000 --- a/labs/lib/osbash/functions-host.sh +++ /dev/null @@ -1,460 +0,0 @@ -# This file contains bash functions that are used by osbash on the host. - -source "$LIB_DIR/functions.sh" - -#------------------------------------------------------------------------------- -# Conditional execution -#------------------------------------------------------------------------------- -# TODO: Create a help function and display it under help by default or with -# option --help (-h). -# exec_cmd is used for conditional execution: -# -# OSBASH=exec_cmd -# -# Execute command only if OSBASH is set: -# ${OSBASH:-:} cmd args -# -# Execute command only if OSBASH is not set: -# ${OSBASH:+:} cmd args -# -# Disable actual call to VBoxManage (selectively override configuration): -# OSBASH= cmd args -# -# Enable call to VBoxManage (selectively override configuration): -# OSBASH=exec_cmd cmd args - -function exec_cmd { - local cmd=$1 - shift - $cmd "$@" -} - -#------------------------------------------------------------------------------- -function get_base_disk_name { - echo "base-$VM_ACCESS-$DISTRO.vdi" -} - -function get_base_disk_path { - echo "$DISK_DIR/$(get_base_disk_name)" -} - -# From DISTRO string (e.g., ubuntu-14.04-server-amd64), get first component -function get_distro_name { - # Match up to first dash - local re='([^-]*)' - - if [[ $DISTRO =~ $re ]]; then - echo "${BASH_REMATCH[1]}" - fi -} - -#------------------------------------------------------------------------------- -# ssh -#------------------------------------------------------------------------------- - -# Check permission for osbash insecure private key -function check_osbash_private_key { - local key_name="osbash_key" - local osbash_key_dir=$LIB_DIR/osbash-ssh-keys - local osbash_key_path=$osbash_key_dir/$key_name - - if ! ls -l "$osbash_key_path"|grep -q "^-r--------"; then - echo "Adjusting permissions for $osbash_key_path" - chmod 400 "$osbash_key_path" - fi -} - -function strip_top_dir { - local full_path=$1 - echo "${full_path/$TOP_DIR\//}" -} - -# Copy files or directories to VM (incl. implied directories; HOME is TOP_DIR) -function vm_scp_to_vm { - local ssh_port=$1 - shift - - check_osbash_private_key - - while (($#)); do - local src_path=$1 - shift - local target_path=$(strip_top_dir "$src_path") - local target_dir=$(dirname "$target_path") - vm_ssh "$ssh_port" "mkdir -p $target_dir" - scp -q -r \ - -i "$LIB_DIR/osbash-ssh-keys/osbash_key" \ - -o "UserKnownHostsFile /dev/null" \ - -o "StrictHostKeyChecking no" \ - -P "$ssh_port" \ - "$src_path" "$VM_SHELL_USER@localhost:$target_path" - done -} - -# Execute commands via ssh -function vm_ssh { - local ssh_port=$1 - shift - - check_osbash_private_key - - # Some operating systems (e.g., Mac OS X) export locale settings to the - # target that cause some Python clients to fail. Override with a standard - # setting (LC_ALL=C). - LC_ALL=C ssh -q \ - -i "$LIB_DIR/osbash-ssh-keys/osbash_key" \ - -o "UserKnownHostsFile /dev/null" \ - -o "StrictHostKeyChecking no" \ - -p "$ssh_port" \ - "$VM_SHELL_USER@localhost" "$@" -} - -function wait_for_ssh { - local ssh_port=$1 - - echo -e -n "${CStatus:-}Waiting for ssh server to respond on local port ${CData:-}$ssh_port.${CReset:-}" - while [ : ]; do - if vm_ssh "$ssh_port" exit ; then - break - else - echo -n . - sleep 1 - fi - done - echo -} - -# Copy one script to VM and execute it via ssh; log output to separate file -function ssh_exec_script { - local ssh_port=$1 - local script_path=$2 - - vm_scp_to_vm "$ssh_port" "$script_path" - - local remote_path=$(strip_top_dir "$script_path") - - echo -en "\n$(date) start $remote_path" - - local script_name=$(basename "$script_path" .sh) - local prefix=$(get_next_prefix "$LOG_DIR" "auto") - local log_path=$LOG_DIR/${prefix}_${script_name}.auto - - local rc=0 - vm_ssh "$ssh_port" "bash $remote_path && rm -vf $remote_path" \ - > "$log_path" 2>&1 || rc=$? - if [ $rc -ne 0 ]; then - echo >&2 - echo -e "${CError:-}ERROR: ssh returned status ${CData:-}$rc${CError:-} for${CData:-} $remote_path${CReset:-}" | - tee >&2 -a "$LOG_DIR/error.log" - # kill osbash host scripts - kill -- -$$ - fi - - echo -en "\n$(date) done" -} - -# Wait for sshd, prepare autostart dirs, and execute autostart scripts on VM -function ssh_process_autostart { - # Run this function in sub-shell to protect our caller's environment - # (which might be _our_ enviroment if we get called again) - ( - - source "$CONFIG_DIR/config.$vm_name" - - local ssh_port=$VM_SSH_PORT - - wait_for_ssh "$ssh_port" - vm_ssh "$ssh_port" "rm -rf lib config autostart" - vm_scp_to_vm "$ssh_port" "$TOP_DIR/lib" "$TOP_DIR/config" - - local script_path="" - for script_path in "$AUTOSTART_DIR/"*.sh; do - ssh_exec_script "$ssh_port" "$script_path" - rm -f "$script_path" >&2 - done - touch "$STATUS_DIR/done" - - ) -} - -#------------------------------------------------------------------------------- -# Autostart mechanism -#------------------------------------------------------------------------------- - -function autostart_reset { - clean_dir "$AUTOSTART_DIR" - clean_dir "$STATUS_DIR" -} - -function process_begin_files { - local processing=("$STATUS_DIR"/*.sh.begin) - if [ -n "${processing[0]-}" ]; then - local file - for file in "${processing[@]}"; do - echo >&2 -en "\nVM processing $(basename "$file" .begin)" - rm "$file" - done - fi -} - -# Wait until all autofiles are processed (indicated by a "$STATUS_DIR/done" -# file created either by osbashauto or ssh_process_autostart) -function wait_for_autofiles { - shopt -s nullglob - - ${WBATCH:-:} wbatch_wait_auto - # Remove autostart files and return if we are just faking it for wbatch - ${OSBASH:+:} autostart_reset - ${OSBASH:+:} return 0 - - until [ -f "$STATUS_DIR/done" -o -f "$STATUS_DIR/error" ]; do - # Note: begin files (created by indicate_current_auto) are only visible - # if the STATUS_DIR directory is shared between host and VM - ${WBATCH:-:} process_begin_files - echo >&2 -n . - sleep 1 - done - # Check for remaining *.sh.begin files - ${WBATCH:-:} process_begin_files - if [ -f "$STATUS_DIR/done" ]; then - rm "$STATUS_DIR/done" - else - echo -e >&2 "${CError:-}\nERROR occured. Exiting.${CReset:-}" - kill -- -$$ - fi - echo -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Prepending numbers ensures scripts will be executed in the order they -# were added to the queue. - -function _autostart_queue { - local src_path=$SCRIPTS_DIR/$1 - local src_name=${1##*/} - - # If we get a target name, file will be renamed - local target_name=${2:-$src_name} - - if [[ $target_name = *.sh ]]; then - # Create target file name like 01_apt_init.sh - local prefix=$(get_next_prefix "$AUTOSTART_DIR" "sh" 2) - target_name="${prefix}_$target_name" - fi - - if [ "$src_name" = "$target_name" ]; then - echo >&2 -e "\t$src_name" - else - echo >&2 -e "\t$src_name -> $target_name" - fi - - cp -- "$src_path" "$AUTOSTART_DIR/$target_name" - ${WBATCH:-:} wbatch_cp_auto "$src_path" "$AUTOSTART_DIR/$target_name" -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Print to the console which file requested guest scripts to run -function log_autostart_source { - # If the caller doesn't provide a config file, log the caller's source file - local src_file=${1:-${BASH_SOURCE[1]##*/}} - echo >&2 "Copying autostart files set in $src_file" -} - -# autostart -# e.g. autostart osbash init_xxx_node.sh init_controller_node.sh -function autostart_and_rename { - local src_dir=$1 - local src_file=$2 - local target_file=$3 - - # Don't log this file -- log our caller's source file - log_autostart_source "${BASH_SOURCE[1]##*/}" - - _autostart_queue "$src_dir/$src_file" "$target_file" -} - -# autostart [ ...] -# e.g. autostart zero_empty.sh osbash/base_fixups.sh -function autostart { - # Don't log this file -- log our caller's source file - log_autostart_source "${BASH_SOURCE[1]##*/}" - - while (($#)); do - local src_file=$1 - shift - _autostart_queue "$src_file" - done -} - -# Parse options given to configuration commands. Return parsed values by -# setting variables to be used by caller. -function get_cmd_options { - local OPTIND - local opt - - while getopts :g:n: opt; do - case $opt in - g) - vm_ui=$OPTARG - ;; - n) - vm_name=$OPTARG - ;; - *) - echo -e >&2 "${CError:-}Error: bad option ${CData:-}$OPTARG.${CReset:-}" - exit 1 - ;; - esac - done - shift $((OPTIND-1)) - - # Assign the remaining arguments back to args - args=$@ -} - -# Parse command and arguments after a "cmd" token in config/scripts.* -function command_from_config { - local cmd=$1 - shift - - # Local variables that may be changed by get_cmd_options - local vm_name=${NODE_NAME:-""} - local vm_ui=${VM_UI:-""} - - local args=$@ - case "$cmd" in - boot) - # Format: boot [-g ] [-n ] - # Boot with queued autostart files now, wait for end of scripts - # processing - get_cmd_options $args - echo >&2 "VM_UI=$vm_ui _vbox_boot_with_autostart $vm_name" - VM_UI=$vm_ui _vbox_boot_with_autostart "$vm_name" - ;; - snapshot) - # Format: snapshot [-n ] - get_cmd_options $args - local shot_name=$args - echo >&2 vm_snapshot "$vm_name" "$shot_name" - vm_snapshot "$vm_name" "$shot_name" - ;; - wait_for_shutdown) - # Format: wait_for_shutdown [-n ] - get_cmd_options $args - echo >&2 vm_wait_for_shutdown "$vm_name" - vm_wait_for_shutdown "$vm_name" - ;; - snapshot_cycle) - # Format: snapshot_cycle [-g ] [-n ] - # comprises shutdown, boot, wait_for_shutdown, snapshot - get_cmd_options $args - local shot_name=$args - echo >&2 snapshot_cycle "$vm_name" "$shot_name" - _autostart_queue "osbash/shutdown.sh" - _vbox_boot_with_autostart "$vm_name" - vm_wait_for_shutdown "$vm_name" - vm_snapshot "$vm_name" "$shot_name" - ;; - init_node) - # Format: init_node [-n ] - get_cmd_options $args - echo >&2 vm_init_node "$vm_name" - vm_init_node "$vm_name" - ;; - queue) - # Queue a script for autostart - # Format: queue - local script_rel_path=$args - echo >&2 _autostart_queue "$script_rel_path" - _autostart_queue "$script_rel_path" - ;; - *) - echo -e >&2 "${CError:-}Error: invalid cmd: ${CData:-}$cmd${CReset:-}" - exit 1 - ;; - esac -} - -# Parse config/scripts.* configuration files -function autostart_from_config { - local config_file=$1 - local config_path=$CONFIG_DIR/$config_file - - if [ ! -f "$config_path" ]; then - echo -e >&2 "${CMissing:-}Config file not found: ${CData:-}$config_file${CReset:-}" - return 1 - fi - - log_autostart_source "$config_file" - - # Open file on file descriptor 3 so programs we call in this loop (ssh) - # are free to mess with the standard file descriptors. - exec 3< "$config_path" - while read -r field_1 field_2 <&3; do - if [[ $field_1 =~ (^$|^#) ]]; then - # Skip empty lines and lines that are commented out - continue - elif [ "$field_1" == "cmd" ]; then - if [ -n "${JUMP_SNAPSHOT:-""}" ]; then - if [[ $field_2 =~ ^snapshot.*${JUMP_SNAPSHOT} ]]; then - echo >&2 "Skipped forward to snapshot $JUMP_SNAPSHOT." - unset JUMP_SNAPSHOT - fi - else - command_from_config $field_2 - fi - else - # Syntax error - echo -e -n >&2 "${CError:-}ERROR in ${CInfo:-}$config_file: ${CData:-}'$field_1${CReset:-}" - if [ -n "$field_2" ]; then - echo >&2 " $field_2'" - else - echo >&2 "'" - fi - exit 1 - fi - done -} - -#------------------------------------------------------------------------------- -# Functions to get install ISO images -#------------------------------------------------------------------------------- - -function download { - local url=$1 - local dest_dir=$2 - local dest_file=$3 - local rc=0 - - local wget_exe=$(which wget) - mkdir -pv "$dest_dir" - if [ -n "$wget_exe" ]; then - $wget_exe --output-document "$dest_dir/$dest_file" "$url"||rc=$? - else - # Mac OS X has curl instead of wget - local curl_exe=$(which curl) - if [ -n "$curl_exe" ]; then - $curl_exe "$url" -o "$dest_dir/$dest_file"||rc=$? - fi - fi - if [ $rc -ne 0 ]; then - echo -e >&2 "${CError:-}Unable to download ${CData:-}$url${CError:-}, quitting.${CReset:-}" - exit 1 - fi -} - -function get_iso_name { - basename "${ISO_URL:-}" -} - -function find_install-iso { - local iso_name=$1 - if [ ! -f "$ISO_DIR/$iso_name" ]; then - echo >&2 "$iso_name not in $ISO_DIR; downloading" - download "$ISO_URL" "$ISO_DIR" "$iso_name" - fi -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/osbash/lib-color.sh b/labs/lib/osbash/lib-color.sh deleted file mode 100644 index d69a61c8..00000000 --- a/labs/lib/osbash/lib-color.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# Colors and decorations - -function colorizer { - - # Text Reset - local Reset_Color='\x1b[0m' - - # Regular - local Black='\x1b[0;30m' - local Red='\x1b[0;31m' - local Green='\x1b[0;32m' - local Yellow='\x1b[0;33m' - local Blue='\x1b[0;34m' - local Purple='\x1b[0;35m' - local Cyan='\x1b[0;36m' - local White='\x1b[0;37m' - - # Bold - local Bold_Black='\x1b[1;30m' - local Bold_Red='\x1b[1;31m' - local Bold_Green='\x1b[1;32m' - local Bold_Yellow='\x1b[1;33m' - local Bold_Blue='\x1b[1;34m' - local Bold_Purple='\x1b[1;35m' - local Bold_Cyan='\x1b[1;36m' - local Bold_White='\x1b[1;37m' - - # Underline - local Underline_Black='\x1b[4;30m' - local Underline_Red='\x1b[4;31m' - local Underline_Green='\x1b[4;32m' - local Underline_Yellow='\x1b[4;33m' - local Underline_Blue='\x1b[4;34m' - local Underline_Purple='\x1b[1;35m' - local Underline_Cyan='\x1b[4;36m' - local Underline_White='\x1b[4;37m' - - # Background - local On_Black='\x1b[40m' - local On_Blue='\x1b[44m' - local On_White='\x1b[47m' - - # Color codes - CError=$Red - CStatus=$Bold_Purple - CInfo=$Bold_Yellow - CProcess=$Bold_Blue - CData=$Bold_Cyan - CMissing=$Bold_Red - CReset=$Reset_Color -} -colorizer -unset colorizer diff --git a/labs/lib/osbash/lib.fedora-20-x86_64 b/labs/lib/osbash/lib.fedora-20-x86_64 deleted file mode 100644 index 7a38ab24..00000000 --- a/labs/lib/osbash/lib.fedora-20-x86_64 +++ /dev/null @@ -1,43 +0,0 @@ -# Fedora 20 x86_64 - -# Default scripts for all Fedora base disks -: ${BASE_INSTALL_SCRIPTS:=scripts.fedora_base} - -# Give Fedora 20 installer sufficient RAM -VM_BASE_MEM=1024 - -#------------------------------------------------------------------------------- -# Booting the operating system installer -#------------------------------------------------------------------------------- - -readonly ISO_URL=http://mirror.switch.ch/ftp/mirror/fedora/linux/releases/20/Fedora/x86_64/iso/Fedora-20-x86_64-DVD.iso -readonly ISO_MD5=9a190c8b2bd382c2d046dbc855cd2f2b - -readonly _KS_ssh=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/ks-ssh-v2.cfg -readonly _KS_vbadd=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/ks-vbadd.cfg -readonly _KS_all=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/ks-all-v2.cfg - -readonly _BOOT_ARGS="linux ks=%s" - -function vbox_distro_start_installer { - local vm_name=$1 - - # pick a _KS_* file - local kickstart=_KS_$VM_ACCESS - - echo "Using $kickstart ${!kickstart}" - - local boot_args=$(printf "$_BOOT_ARGS" "${!kickstart}") - - vbox_kbd_escape_key "$vm_name" - - vbox_sleep 1 - - echo -e "${CStatus:-}Pushing boot command line${CReset:-}" - vbox_kbd_string_input "$vm_name" "$boot_args" - - echo "Initiating boot sequence" - vbox_kbd_enter_key "$vm_name" -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/osbash/lib.ubuntu-12.04.4-server-amd64 b/labs/lib/osbash/lib.ubuntu-12.04.4-server-amd64 deleted file mode 100644 index e751dc3e..00000000 --- a/labs/lib/osbash/lib.ubuntu-12.04.4-server-amd64 +++ /dev/null @@ -1,53 +0,0 @@ -# Ubuntu 12.04.4 LTS amd64 server - -# Default scripts for all Ubuntu installs -: ${BASE_INSTALL_SCRIPTS:=scripts.ubuntu_base} - -#------------------------------------------------------------------------------- -# Booting the operating system installer -#------------------------------------------------------------------------------- - -readonly ISO_URL=http://releases.ubuntu.com/12.04/ubuntu-12.04.4-server-amd64.iso - -# Note: Ubuntu 12.04 LTS cannot pull a preseed file over HTTPS -readonly _PS_ssh=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/preseed-ssh-v2.cfg -readonly _PS_vbadd=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/preseed-vbadd.cfg -readonly _PS_all=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/preseed-all-v2.cfg - -readonly _BOOT_ARGS="/install/vmlinuz - noapic - preseed/url=%s - debian-installer=en_US - auto=true - locale=en_US - hostname=osbash - fb=false - debconf/frontend=noninteractive - keyboard-configuration/modelcode=SKIP - initrd=/install/initrd.gz - console-setup/ask_detect=false" - -function vbox_distro_start_installer { - local vm_name=$1 - - # pick a _PS_* file - local preseed=_PS_$VM_ACCESS - - echo "Using $preseed ${!preseed}" - - local boot_args=$(printf "$_BOOT_ARGS" "${!preseed}") - - vbox_kbd_escape_key "$vm_name" - vbox_kbd_escape_key "$vm_name" - vbox_kbd_enter_key "$vm_name" - - vbox_sleep 1 - - echo -e "${CStatus:-}Pushing boot command line${CReset:-}" - vbox_kbd_string_input "$vm_name" "$boot_args" - - echo "Initiating boot sequence" - vbox_kbd_enter_key "$vm_name" -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/osbash/lib.ubuntu-14.04-server-amd64 b/labs/lib/osbash/lib.ubuntu-14.04-server-amd64 deleted file mode 100644 index 57f303d7..00000000 --- a/labs/lib/osbash/lib.ubuntu-14.04-server-amd64 +++ /dev/null @@ -1,53 +0,0 @@ -# Ubuntu 14.04 LTS amd64 server - -# Default scripts for all Ubuntu installs -: ${BASE_INSTALL_SCRIPTS:=scripts.ubuntu_base} - -#------------------------------------------------------------------------------- -# Booting the operating system installer -#------------------------------------------------------------------------------- - -readonly ISO_URL=http://releases.ubuntu.com/14.04/ubuntu-14.04.2-server-amd64.iso -readonly ISO_MD5=83aabd8dcf1e8f469f3c72fff2375195 - -readonly _PS_ssh=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/preseed-ssh-v2.cfg -readonly _PS_vbadd=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/preseed-vbadd.cfg -readonly _PS_all=http://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash/netboot/preseed-all-v2.cfg - -readonly _BOOT_ARGS="/install/vmlinuz - noapic - preseed/url=%s - debian-installer=en_US - auto=true - locale=en_US - hostname=osbash - fb=false - debconf/frontend=noninteractive - keyboard-configuration/modelcode=SKIP - initrd=/install/initrd.gz - console-setup/ask_detect=false" - -function vbox_distro_start_installer { - local vm_name=$1 - - # pick a _PS_* file - local preseed=_PS_$VM_ACCESS - - echo "Using $preseed ${!preseed}" - - local boot_args=$(printf "$_BOOT_ARGS" "${!preseed}") - - vbox_kbd_escape_key "$vm_name" - vbox_kbd_escape_key "$vm_name" - vbox_kbd_enter_key "$vm_name" - - vbox_sleep 1 - - echo -e "${CStatus:-}Pushing boot command line${CReset:-}" - vbox_kbd_string_input "$vm_name" "$boot_args" - - echo "Initiating boot sequence" - vbox_kbd_enter_key "$vm_name" -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/osbash/netboot/ks-all-v2.cfg b/labs/lib/osbash/netboot/ks-all-v2.cfg deleted file mode 100644 index 65283a12..00000000 --- a/labs/lib/osbash/netboot/ks-all-v2.cfg +++ /dev/null @@ -1,75 +0,0 @@ -#platform=x86, AMD64, or Intel EM64T -#version=DEVEL -# Install OS instead of upgrade -install -# Keyboard layouts -keyboard 'us' -# Reboot after installation -reboot --eject -# Root password -rootpw --plaintext osbash -# User -user --name=osbash --password=osbash --plaintext -# System timezone -timezone Etc/UTC --isUtc -# System language -lang en_US -# Firewall configuration -firewall --disabled -# System authorization information -auth --useshadow --passalgo=sha512 -# Use CDROM installation media -cdrom -# Use text mode install -text -# SELinux configuration -selinux --permissive -# Do not configure the X Window System -skipx - -# System bootloader configuration -bootloader --location=mbr -# Partition clearing information -clearpart --all - -part /boot --fstype=ext4 --size=1024 -part pv.0 --grow --size=1 -volgroup ROOTDISK --pesize=4096 pv.0 -logvol swap --name=swap --vgname=ROOTDISK --recommended -logvol / --fstype=ext4 --name=root --vgname=ROOTDISK --size=1 --grow - -%pre --interpreter=bash -%end -#------------------------------------------------------------------------------- -# Enable ssh login with insecure osbash key and password-less sudo for osbash -# Install VirtualBox guest additions, bootstrap osbashauto -%post --interpreter=/bin/bash -DIR=/home/osbash/.ssh -mkdir $DIR -wget -O $DIR/authorized_keys https://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash-ssh-keys/osbash_key.pub -chmod 700 $DIR -chmod 400 $DIR/authorized_keys -chown -R osbash:osbash $DIR -echo "osbash ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -echo "Defaults:osbash !requiretty" >> /etc/sudoers - -yum -y install dkms - -mount /dev/sr1 /mnt -/mnt/VBoxLinuxAdditions.run -umount /mnt - -echo -e '#!/bin/bash\nbash /media/sf_*/autostart/*activate_autostart.sh\nrm /media/*/autostart/*activate_autostart.sh' > /etc/init.d/osbash -chmod 755 /etc/init.d/osbash -ln -s ../init.d/osbash /etc/rc2.d/S40osbash -%end -#------------------------------------------------------------------------------- -# tar, bzip2, kernel-{devel,headers}: needed for VirtualBox guest additions -# (but not in @core) -%packages -wget -tar -bzip2 -kernel-devel -kernel-headers -%end diff --git a/labs/lib/osbash/netboot/ks-all.cfg b/labs/lib/osbash/netboot/ks-all.cfg deleted file mode 100644 index 76d9f80c..00000000 --- a/labs/lib/osbash/netboot/ks-all.cfg +++ /dev/null @@ -1,75 +0,0 @@ -#platform=x86, AMD64, or Intel EM64T -#version=DEVEL -# Install OS instead of upgrade -install -# Keyboard layouts -keyboard 'us' -# Reboot after installation -reboot --eject -# Root password -rootpw --plaintext osbash -# User -user --name=osbash --password=osbash --plaintext -# System timezone -timezone Etc/UTC --isUtc -# System language -lang en_US -# Firewall configuration -firewall --disabled -# System authorization information -auth --useshadow --passalgo=sha512 -# Use CDROM installation media -cdrom -# Use text mode install -text -# SELinux configuration -selinux --permissive -# Do not configure the X Window System -skipx - -# System bootloader configuration -bootloader --location=mbr -# Partition clearing information -clearpart --all - -part /boot --fstype=ext4 --size=1024 -part pv.0 --grow --size=1 -volgroup ROOTDISK --pesize=4096 pv.0 -logvol swap --name=swap --vgname=ROOTDISK --recommended -logvol / --fstype=ext4 --name=root --vgname=ROOTDISK --size=1 --grow - -%pre --interpreter=bash -%end -#------------------------------------------------------------------------------- -# Enable ssh login with insecure Vagrant key and password-less sudo for osbash -# Install VirtualBox guest additions, bootstrap osbashauto -%post --interpreter=/bin/bash -DIR=/home/osbash/.ssh -mkdir $DIR -wget -O $DIR/authorized_keys https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -chmod 700 $DIR -chmod 400 $DIR/authorized_keys -chown -R osbash:osbash $DIR -echo "osbash ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -echo "Defaults:osbash !requiretty" >> /etc/sudoers - -yum -y install dkms - -mount /dev/sr1 /mnt -/mnt/VBoxLinuxAdditions.run -umount /mnt - -echo -e '#!/bin/bash\nbash /media/sf_*/autostart/*activate_autostart.sh\nrm /media/*/autostart/*activate_autostart.sh' > /etc/init.d/osbash -chmod 755 /etc/init.d/osbash -ln -s ../init.d/osbash /etc/rc2.d/S40osbash -%end -#------------------------------------------------------------------------------- -# tar, bzip2, kernel-{devel,headers}: needed for VirtualBox guest additions -# (but not in @core) -%packages -wget -tar -bzip2 -kernel-devel -kernel-headers -%end diff --git a/labs/lib/osbash/netboot/ks-ssh-v2.cfg b/labs/lib/osbash/netboot/ks-ssh-v2.cfg deleted file mode 100644 index fdd8cc22..00000000 --- a/labs/lib/osbash/netboot/ks-ssh-v2.cfg +++ /dev/null @@ -1,58 +0,0 @@ -#platform=x86, AMD64, or Intel EM64T -#version=DEVEL -# Install OS instead of upgrade -install -# Keyboard layouts -keyboard 'us' -# Reboot after installation -reboot --eject -# Root password -rootpw --plaintext osbash -# User -user --name=osbash --password=osbash --plaintext -# System timezone -timezone Etc/UTC --isUtc -# System language -lang en_US -# Firewall configuration -firewall --disabled -# System authorization information -auth --useshadow --passalgo=sha512 -# Use CDROM installation media -cdrom -# Use text mode install -text -# SELinux configuration -selinux --permissive -# Do not configure the X Window System -skipx - -# System bootloader configuration -bootloader --location=mbr -# Partition clearing information -clearpart --all - -part /boot --fstype=ext4 --size=1024 -part pv.0 --grow --size=1 -volgroup ROOTDISK --pesize=4096 pv.0 -logvol swap --name=swap --vgname=ROOTDISK --recommended -logvol / --fstype=ext4 --name=root --vgname=ROOTDISK --size=1 --grow - -%pre --interpreter=bash -%end -#------------------------------------------------------------------------------- -# Enable ssh login with insecure osbash key and password-less sudo for osbash -%post --interpreter=/bin/bash -DIR=/home/osbash/.ssh -mkdir $DIR -wget -O $DIR/authorized_keys https://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash-ssh-keys/osbash_key.pub -chmod 700 $DIR -chmod 400 $DIR/authorized_keys -chown -R osbash:osbash $DIR -echo "osbash ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -echo "Defaults:osbash !requiretty" >> /etc/sudoers -%end - -%packages -wget -%end diff --git a/labs/lib/osbash/netboot/ks-ssh.cfg b/labs/lib/osbash/netboot/ks-ssh.cfg deleted file mode 100644 index 45736a1f..00000000 --- a/labs/lib/osbash/netboot/ks-ssh.cfg +++ /dev/null @@ -1,58 +0,0 @@ -#platform=x86, AMD64, or Intel EM64T -#version=DEVEL -# Install OS instead of upgrade -install -# Keyboard layouts -keyboard 'us' -# Reboot after installation -reboot --eject -# Root password -rootpw --plaintext osbash -# User -user --name=osbash --password=osbash --plaintext -# System timezone -timezone Etc/UTC --isUtc -# System language -lang en_US -# Firewall configuration -firewall --disabled -# System authorization information -auth --useshadow --passalgo=sha512 -# Use CDROM installation media -cdrom -# Use text mode install -text -# SELinux configuration -selinux --permissive -# Do not configure the X Window System -skipx - -# System bootloader configuration -bootloader --location=mbr -# Partition clearing information -clearpart --all - -part /boot --fstype=ext4 --size=1024 -part pv.0 --grow --size=1 -volgroup ROOTDISK --pesize=4096 pv.0 -logvol swap --name=swap --vgname=ROOTDISK --recommended -logvol / --fstype=ext4 --name=root --vgname=ROOTDISK --size=1 --grow - -%pre --interpreter=bash -%end -#------------------------------------------------------------------------------- -# Enable ssh login with insecure Vagrant key and password-less sudo for osbash -%post --interpreter=/bin/bash -DIR=/home/osbash/.ssh -mkdir $DIR -wget -O $DIR/authorized_keys https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -chmod 700 $DIR -chmod 400 $DIR/authorized_keys -chown -R osbash:osbash $DIR -echo "osbash ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -echo "Defaults:osbash !requiretty" >> /etc/sudoers -%end - -%packages -wget -%end diff --git a/labs/lib/osbash/netboot/ks-vbadd.cfg b/labs/lib/osbash/netboot/ks-vbadd.cfg deleted file mode 100644 index a133d6bf..00000000 --- a/labs/lib/osbash/netboot/ks-vbadd.cfg +++ /dev/null @@ -1,64 +0,0 @@ -#platform=x86, AMD64, or Intel EM64T -#version=DEVEL -# Install OS instead of upgrade -install -# Keyboard layouts -keyboard 'us' -# Reboot after installation -reboot --eject -# Root password -rootpw --plaintext osbash -# System timezone -timezone Etc/UTC --isUtc -# System language -lang en_US -# Firewall configuration -firewall --disabled -# System authorization information -auth --useshadow --passalgo=sha512 -# Use CDROM installation media -cdrom -# Use text mode install -text -# SELinux configuration -selinux --permissive -# Do not configure the X Window System -skipx - -# System bootloader configuration -bootloader --location=mbr -# Partition clearing information -clearpart --all - -part /boot --fstype=ext4 --size=1024 -part pv.0 --grow --size=1 -volgroup ROOTDISK --pesize=4096 pv.0 -logvol swap --name=swap --vgname=ROOTDISK --recommended -logvol / --fstype=ext4 --name=root --vgname=ROOTDISK --size=1 --grow - -%pre --interpreter=bash -%end -#------------------------------------------------------------------------------- -# Install VirtualBox guest additions, bootstrap osbashauto -%post --interpreter=/bin/bash - -yum -y install dkms - -mount /dev/sr1 /mnt -/mnt/VBoxLinuxAdditions.run -umount /mnt - -echo -e '#!/bin/bash\nbash /media/sf_*/autostart/*activate_autostart.sh\nrm /media/*/autostart/*activate_autostart.sh' > /etc/init.d/osbash -chmod 755 /etc/init.d/osbash -ln -s ../init.d/osbash /etc/rc2.d/S40osbash - -%end -#------------------------------------------------------------------------------- -# tar, bzip2, kernel-{devel,headers}: needed for VirtualBox guest additions -# (but not in @core) -%packages -tar -bzip2 -kernel-devel -kernel-headers -%end diff --git a/labs/lib/osbash/netboot/preseed-all-v2.cfg b/labs/lib/osbash/netboot/preseed-all-v2.cfg deleted file mode 100644 index ed59a5d4..00000000 --- a/labs/lib/osbash/netboot/preseed-all-v2.cfg +++ /dev/null @@ -1,120 +0,0 @@ -# Based on -# https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt -# -# For details, see: -# https://help.ubuntu.com/12.04/installation-guide/i386/appendix-preseed.html -#------------------------------------------------------------------------------- -# Preseeding only locale sets language, country and locale. -d-i debian-installer/locale string en_US - -# Disable automatic (interactive) keymap detection. -d-i console-setup/ask_detect boolean false -d-i keyboard-configuration/layoutcode string us - -d-i netcfg/get_hostname string osbash -d-i netcfg/get_domain string unassigned-domain -#------------------------------------------------------------------------------- -# Proxy -#d-i mirror/http/proxy string http://192.168.178.20:3128/ -d-i mirror/http/proxy string -#------------------------------------------------------------------------------- -### Clock and time zone setup -# Controls whether or not the hardware clock is set to UTC. -d-i clock-setup/utc boolean true -d-i time/zone string Etc/UTC -#------------------------------------------------------------------------------- -### Partitioning -# The presently available methods are: -# - regular: use the usual partition types for your architecture -# - lvm: use LVM to partition the disk -# - crypto: use LVM within an encrypted partition -d-i partman-auto/method string regular - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /usr, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -d-i partman/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true -#------------------------------------------------------------------------------- -# To create a normal user account. -d-i passwd/user-fullname string OpenStack user -d-i passwd/username string osbash -d-i passwd/user-password password osbash -d-i passwd/user-password-again password osbash -d-i user-setup/allow-password-weak boolean true -d-i user-setup/encrypt-home boolean false -#------------------------------------------------------------------------------- -### Package selection -tasksel tasksel/first minimal - -# Individual additional packages to install -d-i pkgsel/include string openssh-server dkms localepurge - -# http://sfxpt.wordpress.com/2013/06/09/get-the-debianubuntu-ready-and-customized-the-way-you-like-in-10-minutes/ -### Pkg:localepurge -# Options explained at: http://anonscm.debian.org/cgit/collab-maint/localepurge.git/tree/debian/localepurge.templates -localepurge localepurge/nopurge multiselect en_US -# Really remove all locales? -localepurge localepurge/none_selected boolean false -# Also delete localized man pages? -localepurge localepurge/mandelete boolean true -# Avoid note that localepurge will not take any action until configured -localepurge localepurge/remove_no note -# Inform about new locales? -localepurge localepurge/dontbothernew boolean false -# Display verbose output? -localepurge localepurge/verbose boolean false -# Display freed disk space? -localepurge localepurge/showfreedspace boolean true -# Accurate disk space calculation? -localepurge localepurge/quickndirtycalc boolean true -# Use dpkg --path-exclude? -localepurge localepurge/use-dpkg-feature bolean true -#------------------------------------------------------------------------------- -# Whether to upgrade packages after debootstrap. -# Allowed values: none, safe-upgrade, full-upgrade -d-i pkgsel/upgrade select none - -# Policy for applying updates. May be "none" (no automatic updates), -# "unattended-upgrades" (install security updates automatically), or -# "landscape" (manage system with Landscape). -d-i pkgsel/update-policy select none - -# This is fairly safe to set, it makes grub install automatically to the MBR -# if no other operating system is detected on the machine. -d-i grub-installer/only_debian boolean true - -# Avoid warning about install CD not containing full support for language -d-i pkgsel/install-language-support boolean false - -# Avoid reboot confirmation -d-i finish-install/reboot_in_progress note - -d-i cdrom-detect/eject boolean true -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Use the following option to add additional boot parameters for the -# installed system (if supported by the bootloader installer). -# Note: options passed to the installer will be added automatically. - -# With Ubuntu 12.04 LTS, modesetting may result in a blank console -d-i debian-installer/add-kernel-opts string vga=0x301 nomodeset -#------------------------------------------------------------------------------- -#### Advanced options -### Running custom commands during the installation -# d-i preseeding is inherently not secure. Nothing in the installer checks -# for attempts at buffer overflows or other exploits of the values of a -# preconfiguration file like this one. Only use preconfiguration files from -# trusted locations! - -# This command is run just before the install finishes, but when there is -# still a usable /target directory. You can chroot to /target and use it -# directly, or use the apt-install and in-target commands to easily install -# packages and run commands in the target system. -d-i preseed/late_command string echo "DIR=/home/osbash/.ssh; mkdir \$DIR; wget -O \$DIR/authorized_keys https://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash-ssh-keys/osbash_key.pub ; chmod 700 \$DIR; chmod 400 \$DIR/authorized_keys; chown -R osbash:osbash \$DIR; echo 'osbash ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers; echo 'Defaults:osbash !requiretty' >> /etc/sudoers; apt-get -y purge virtualbox-guest-dkms virtualbox-guest-utils; mount /dev/sr1 /mnt; /mnt/VBoxLinuxAdditions.run; umount /mnt; echo -e '#!/bin/bash\nexec > /root/bootstrap.log 2>&1\nset -x\nSCR=/media/sf_bootstrap/autostart/*activate_autostart.sh\nwhile [ ! -f \$SCR ];do sleep 1;done\nbash \$SCR\nrm -v \$SCR' > /etc/rc2.d/S40osbash; chmod 755 /etc/rc2.d/S40osbash;" | chroot /target /bin/bash; diff --git a/labs/lib/osbash/netboot/preseed-all.cfg b/labs/lib/osbash/netboot/preseed-all.cfg deleted file mode 100644 index 1698dcf4..00000000 --- a/labs/lib/osbash/netboot/preseed-all.cfg +++ /dev/null @@ -1,120 +0,0 @@ -# Based on -# https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt -# -# For details, see: -# https://help.ubuntu.com/12.04/installation-guide/i386/appendix-preseed.html -#------------------------------------------------------------------------------- -# Preseeding only locale sets language, country and locale. -d-i debian-installer/locale string en_US - -# Disable automatic (interactive) keymap detection. -d-i console-setup/ask_detect boolean false -d-i keyboard-configuration/layoutcode string us - -d-i netcfg/get_hostname string osbash -d-i netcfg/get_domain string unassigned-domain -#------------------------------------------------------------------------------- -# Proxy -#d-i mirror/http/proxy string http://192.168.178.20:3128/ -d-i mirror/http/proxy string -#------------------------------------------------------------------------------- -### Clock and time zone setup -# Controls whether or not the hardware clock is set to UTC. -d-i clock-setup/utc boolean true -d-i time/zone string Etc/UTC -#------------------------------------------------------------------------------- -### Partitioning -# The presently available methods are: -# - regular: use the usual partition types for your architecture -# - lvm: use LVM to partition the disk -# - crypto: use LVM within an encrypted partition -d-i partman-auto/method string regular - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /usr, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -d-i partman/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true -#------------------------------------------------------------------------------- -# To create a normal user account. -d-i passwd/user-fullname string OpenStack user -d-i passwd/username string osbash -d-i passwd/user-password password osbash -d-i passwd/user-password-again password osbash -d-i user-setup/allow-password-weak boolean true -d-i user-setup/encrypt-home boolean false -#------------------------------------------------------------------------------- -### Package selection -tasksel tasksel/first minimal - -# Individual additional packages to install -d-i pkgsel/include string openssh-server dkms localepurge - -# http://sfxpt.wordpress.com/2013/06/09/get-the-debianubuntu-ready-and-customized-the-way-you-like-in-10-minutes/ -### Pkg:localepurge -# Options explained at: http://anonscm.debian.org/cgit/collab-maint/localepurge.git/tree/debian/localepurge.templates -localepurge localepurge/nopurge multiselect en_US -# Really remove all locales? -localepurge localepurge/none_selected boolean false -# Also delete localized man pages? -localepurge localepurge/mandelete boolean true -# Avoid note that localepurge will not take any action until configured -localepurge localepurge/remove_no note -# Inform about new locales? -localepurge localepurge/dontbothernew boolean false -# Display verbose output? -localepurge localepurge/verbose boolean false -# Display freed disk space? -localepurge localepurge/showfreedspace boolean true -# Accurate disk space calculation? -localepurge localepurge/quickndirtycalc boolean true -# Use dpkg --path-exclude? -localepurge localepurge/use-dpkg-feature bolean true -#------------------------------------------------------------------------------- -# Whether to upgrade packages after debootstrap. -# Allowed values: none, safe-upgrade, full-upgrade -d-i pkgsel/upgrade select none - -# Policy for applying updates. May be "none" (no automatic updates), -# "unattended-upgrades" (install security updates automatically), or -# "landscape" (manage system with Landscape). -d-i pkgsel/update-policy select none - -# This is fairly safe to set, it makes grub install automatically to the MBR -# if no other operating system is detected on the machine. -d-i grub-installer/only_debian boolean true - -# Avoid warning about install CD not containing full support for language -d-i pkgsel/install-language-support boolean false - -# Avoid reboot confirmation -d-i finish-install/reboot_in_progress note - -d-i cdrom-detect/eject boolean true -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Use the following option to add additional boot parameters for the -# installed system (if supported by the bootloader installer). -# Note: options passed to the installer will be added automatically. - -# With Ubuntu 12.04 LTS, modesetting may result in a blank console -d-i debian-installer/add-kernel-opts string vga=0x301 nomodeset -#------------------------------------------------------------------------------- -#### Advanced options -### Running custom commands during the installation -# d-i preseeding is inherently not secure. Nothing in the installer checks -# for attempts at buffer overflows or other exploits of the values of a -# preconfiguration file like this one. Only use preconfiguration files from -# trusted locations! - -# This command is run just before the install finishes, but when there is -# still a usable /target directory. You can chroot to /target and use it -# directly, or use the apt-install and in-target commands to easily install -# packages and run commands in the target system. -d-i preseed/late_command string echo "DIR=/home/osbash/.ssh; mkdir \$DIR; wget -O \$DIR/authorized_keys https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub ; chmod 700 \$DIR; chmod 400 \$DIR/authorized_keys; chown -R osbash:osbash \$DIR; echo 'osbash ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers; echo 'Defaults:osbash !requiretty' >> /etc/sudoers; apt-get -y purge virtualbox-guest-dkms virtualbox-guest-utils; mount /dev/sr1 /mnt; /mnt/VBoxLinuxAdditions.run; umount /mnt; echo -e '#!/bin/bash\nexec > /root/bootstrap.log 2>&1\nset -x\nSCR=/media/sf_bootstrap/autostart/*activate_autostart.sh\nwhile [ ! -f \$SCR ];do sleep 1;done\nbash \$SCR\nrm -v \$SCR' > /etc/rc2.d/S40osbash; chmod 755 /etc/rc2.d/S40osbash;" | chroot /target /bin/bash; diff --git a/labs/lib/osbash/netboot/preseed-ssh-v2.cfg b/labs/lib/osbash/netboot/preseed-ssh-v2.cfg deleted file mode 100644 index 558cd64c..00000000 --- a/labs/lib/osbash/netboot/preseed-ssh-v2.cfg +++ /dev/null @@ -1,120 +0,0 @@ -# Based on -# https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt -# -# For details, see: -# https://help.ubuntu.com/12.04/installation-guide/i386/appendix-preseed.html -#------------------------------------------------------------------------------- -# Preseeding only locale sets language, country and locale. -d-i debian-installer/locale string en_US - -# Disable automatic (interactive) keymap detection. -d-i console-setup/ask_detect boolean false -d-i keyboard-configuration/layoutcode string us - -d-i netcfg/get_hostname string osbash -d-i netcfg/get_domain string unassigned-domain -#------------------------------------------------------------------------------- -# Proxy -#d-i mirror/http/proxy string http://192.168.178.20:3128/ -d-i mirror/http/proxy string -#------------------------------------------------------------------------------- -### Clock and time zone setup -# Controls whether or not the hardware clock is set to UTC. -d-i clock-setup/utc boolean true -d-i time/zone string Etc/UTC -#------------------------------------------------------------------------------- -### Partitioning -# The presently available methods are: -# - regular: use the usual partition types for your architecture -# - lvm: use LVM to partition the disk -# - crypto: use LVM within an encrypted partition -d-i partman-auto/method string regular - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /usr, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -d-i partman/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true -#------------------------------------------------------------------------------- -# To create a normal user account. -d-i passwd/user-fullname string OpenStack user -d-i passwd/username string osbash -d-i passwd/user-password password osbash -d-i passwd/user-password-again password osbash -d-i user-setup/allow-password-weak boolean true -d-i user-setup/encrypt-home boolean false -#------------------------------------------------------------------------------- -### Package selection -tasksel tasksel/first minimal - -# Individual additional packages to install -d-i pkgsel/include string openssh-server dkms localepurge - -# http://sfxpt.wordpress.com/2013/06/09/get-the-debianubuntu-ready-and-customized-the-way-you-like-in-10-minutes/ -### Pkg:localepurge -# Options explained at: http://anonscm.debian.org/cgit/collab-maint/localepurge.git/tree/debian/localepurge.templates -localepurge localepurge/nopurge multiselect en_US -# Really remove all locales? -localepurge localepurge/none_selected boolean false -# Also delete localized man pages? -localepurge localepurge/mandelete boolean true -# Avoid note that localepurge will not take any action until configured -localepurge localepurge/remove_no note -# Inform about new locales? -localepurge localepurge/dontbothernew boolean false -# Display verbose output? -localepurge localepurge/verbose boolean false -# Display freed disk space? -localepurge localepurge/showfreedspace boolean true -# Accurate disk space calculation? -localepurge localepurge/quickndirtycalc boolean true -# Use dpkg --path-exclude? -localepurge localepurge/use-dpkg-feature bolean true -#------------------------------------------------------------------------------- -# Whether to upgrade packages after debootstrap. -# Allowed values: none, safe-upgrade, full-upgrade -d-i pkgsel/upgrade select none - -# Policy for applying updates. May be "none" (no automatic updates), -# "unattended-upgrades" (install security updates automatically), or -# "landscape" (manage system with Landscape). -d-i pkgsel/update-policy select none - -# This is fairly safe to set, it makes grub install automatically to the MBR -# if no other operating system is detected on the machine. -d-i grub-installer/only_debian boolean true - -# Avoid warning about install CD not containing full support for language -d-i pkgsel/install-language-support boolean false - -# Avoid reboot confirmation -d-i finish-install/reboot_in_progress note - -d-i cdrom-detect/eject boolean true -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Use the following option to add additional boot parameters for the -# installed system (if supported by the bootloader installer). -# Note: options passed to the installer will be added automatically. - -# With Ubuntu 12.04 LTS, modesetting may result in a blank console -d-i debian-installer/add-kernel-opts string vga=0x301 nomodeset -#------------------------------------------------------------------------------- -#### Advanced options -### Running custom commands during the installation -# d-i preseeding is inherently not secure. Nothing in the installer checks -# for attempts at buffer overflows or other exploits of the values of a -# preconfiguration file like this one. Only use preconfiguration files from -# trusted locations! - -# This command is run just before the install finishes, but when there is -# still a usable /target directory. You can chroot to /target and use it -# directly, or use the apt-install and in-target commands to easily install -# packages and run commands in the target system. -d-i preseed/late_command string echo "DIR=/home/osbash/.ssh; mkdir \$DIR; wget -O \$DIR/authorized_keys https://git.openstack.org/cgit/openstack/training-guides/plain/labs/lib/osbash-ssh-keys/osbash_key.pub ; chmod 700 \$DIR; chmod 400 \$DIR/authorized_keys; chown -R osbash:osbash \$DIR; echo 'osbash ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers; echo 'Defaults:osbash !requiretty' >> /etc/sudoers;" | chroot /target /bin/bash; diff --git a/labs/lib/osbash/netboot/preseed-ssh.cfg b/labs/lib/osbash/netboot/preseed-ssh.cfg deleted file mode 100644 index 8bf76ee4..00000000 --- a/labs/lib/osbash/netboot/preseed-ssh.cfg +++ /dev/null @@ -1,120 +0,0 @@ -# Based on -# https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt -# -# For details, see: -# https://help.ubuntu.com/12.04/installation-guide/i386/appendix-preseed.html -#------------------------------------------------------------------------------- -# Preseeding only locale sets language, country and locale. -d-i debian-installer/locale string en_US - -# Disable automatic (interactive) keymap detection. -d-i console-setup/ask_detect boolean false -d-i keyboard-configuration/layoutcode string us - -d-i netcfg/get_hostname string osbash -d-i netcfg/get_domain string unassigned-domain -#------------------------------------------------------------------------------- -# Proxy -#d-i mirror/http/proxy string http://192.168.178.20:3128/ -d-i mirror/http/proxy string -#------------------------------------------------------------------------------- -### Clock and time zone setup -# Controls whether or not the hardware clock is set to UTC. -d-i clock-setup/utc boolean true -d-i time/zone string Etc/UTC -#------------------------------------------------------------------------------- -### Partitioning -# The presently available methods are: -# - regular: use the usual partition types for your architecture -# - lvm: use LVM to partition the disk -# - crypto: use LVM within an encrypted partition -d-i partman-auto/method string regular - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /usr, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -d-i partman/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true -#------------------------------------------------------------------------------- -# To create a normal user account. -d-i passwd/user-fullname string OpenStack user -d-i passwd/username string osbash -d-i passwd/user-password password osbash -d-i passwd/user-password-again password osbash -d-i user-setup/allow-password-weak boolean true -d-i user-setup/encrypt-home boolean false -#------------------------------------------------------------------------------- -### Package selection -tasksel tasksel/first minimal - -# Individual additional packages to install -d-i pkgsel/include string openssh-server dkms localepurge - -# http://sfxpt.wordpress.com/2013/06/09/get-the-debianubuntu-ready-and-customized-the-way-you-like-in-10-minutes/ -### Pkg:localepurge -# Options explained at: http://anonscm.debian.org/cgit/collab-maint/localepurge.git/tree/debian/localepurge.templates -localepurge localepurge/nopurge multiselect en_US -# Really remove all locales? -localepurge localepurge/none_selected boolean false -# Also delete localized man pages? -localepurge localepurge/mandelete boolean true -# Avoid note that localepurge will not take any action until configured -localepurge localepurge/remove_no note -# Inform about new locales? -localepurge localepurge/dontbothernew boolean false -# Display verbose output? -localepurge localepurge/verbose boolean false -# Display freed disk space? -localepurge localepurge/showfreedspace boolean true -# Accurate disk space calculation? -localepurge localepurge/quickndirtycalc boolean true -# Use dpkg --path-exclude? -localepurge localepurge/use-dpkg-feature bolean true -#------------------------------------------------------------------------------- -# Whether to upgrade packages after debootstrap. -# Allowed values: none, safe-upgrade, full-upgrade -d-i pkgsel/upgrade select none - -# Policy for applying updates. May be "none" (no automatic updates), -# "unattended-upgrades" (install security updates automatically), or -# "landscape" (manage system with Landscape). -d-i pkgsel/update-policy select none - -# This is fairly safe to set, it makes grub install automatically to the MBR -# if no other operating system is detected on the machine. -d-i grub-installer/only_debian boolean true - -# Avoid warning about install CD not containing full support for language -d-i pkgsel/install-language-support boolean false - -# Avoid reboot confirmation -d-i finish-install/reboot_in_progress note - -d-i cdrom-detect/eject boolean true -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Use the following option to add additional boot parameters for the -# installed system (if supported by the bootloader installer). -# Note: options passed to the installer will be added automatically. - -# With Ubuntu 12.04 LTS, modesetting may result in a blank console -d-i debian-installer/add-kernel-opts string vga=0x301 nomodeset -#------------------------------------------------------------------------------- -#### Advanced options -### Running custom commands during the installation -# d-i preseeding is inherently not secure. Nothing in the installer checks -# for attempts at buffer overflows or other exploits of the values of a -# preconfiguration file like this one. Only use preconfiguration files from -# trusted locations! - -# This command is run just before the install finishes, but when there is -# still a usable /target directory. You can chroot to /target and use it -# directly, or use the apt-install and in-target commands to easily install -# packages and run commands in the target system. -d-i preseed/late_command string echo "DIR=/home/osbash/.ssh; mkdir \$DIR; wget -O \$DIR/authorized_keys https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub ; chmod 700 \$DIR; chmod 400 \$DIR/authorized_keys; chown -R osbash:osbash \$DIR; echo 'osbash ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers; echo 'Defaults:osbash !requiretty' >> /etc/sudoers;" | chroot /target /bin/bash; diff --git a/labs/lib/osbash/netboot/preseed-vbadd.cfg b/labs/lib/osbash/netboot/preseed-vbadd.cfg deleted file mode 100644 index 56eab470..00000000 --- a/labs/lib/osbash/netboot/preseed-vbadd.cfg +++ /dev/null @@ -1,120 +0,0 @@ -# Based on -# https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt -# -# For details, see: -# https://help.ubuntu.com/12.04/installation-guide/i386/appendix-preseed.html -#------------------------------------------------------------------------------- -# Preseeding only locale sets language, country and locale. -d-i debian-installer/locale string en_US - -# Disable automatic (interactive) keymap detection. -d-i console-setup/ask_detect boolean false -d-i keyboard-configuration/layoutcode string us - -d-i netcfg/get_hostname string osbash -d-i netcfg/get_domain string unassigned-domain -#------------------------------------------------------------------------------- -# Proxy -#d-i mirror/http/proxy string http://192.168.178.20:3128/ -d-i mirror/http/proxy string -#------------------------------------------------------------------------------- -### Clock and time zone setup -# Controls whether or not the hardware clock is set to UTC. -d-i clock-setup/utc boolean true -d-i time/zone string Etc/UTC -#------------------------------------------------------------------------------- -### Partitioning -# The presently available methods are: -# - regular: use the usual partition types for your architecture -# - lvm: use LVM to partition the disk -# - crypto: use LVM within an encrypted partition -d-i partman-auto/method string regular - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /usr, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -d-i partman/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true -#------------------------------------------------------------------------------- -# To create a normal user account. -d-i passwd/user-fullname string OpenStack user -d-i passwd/username string osbash -d-i passwd/user-password password osbash -d-i passwd/user-password-again password osbash -d-i user-setup/allow-password-weak boolean true -d-i user-setup/encrypt-home boolean false -#------------------------------------------------------------------------------- -### Package selection -tasksel tasksel/first minimal - -# Individual additional packages to install -d-i pkgsel/include string openssh-server dkms localepurge - -# http://sfxpt.wordpress.com/2013/06/09/get-the-debianubuntu-ready-and-customized-the-way-you-like-in-10-minutes/ -### Pkg:localepurge -# Options explained at: http://anonscm.debian.org/cgit/collab-maint/localepurge.git/tree/debian/localepurge.templates -localepurge localepurge/nopurge multiselect en_US -# Really remove all locales? -localepurge localepurge/none_selected boolean false -# Also delete localized man pages? -localepurge localepurge/mandelete boolean true -# Avoid note that localepurge will not take any action until configured -localepurge localepurge/remove_no note -# Inform about new locales? -localepurge localepurge/dontbothernew boolean false -# Display verbose output? -localepurge localepurge/verbose boolean false -# Display freed disk space? -localepurge localepurge/showfreedspace boolean true -# Accurate disk space calculation? -localepurge localepurge/quickndirtycalc boolean true -# Use dpkg --path-exclude? -localepurge localepurge/use-dpkg-feature bolean true -#------------------------------------------------------------------------------- -# Whether to upgrade packages after debootstrap. -# Allowed values: none, safe-upgrade, full-upgrade -d-i pkgsel/upgrade select none - -# Policy for applying updates. May be "none" (no automatic updates), -# "unattended-upgrades" (install security updates automatically), or -# "landscape" (manage system with Landscape). -d-i pkgsel/update-policy select none - -# This is fairly safe to set, it makes grub install automatically to the MBR -# if no other operating system is detected on the machine. -d-i grub-installer/only_debian boolean true - -# Avoid warning about install CD not containing full support for language -d-i pkgsel/install-language-support boolean false - -# Avoid reboot confirmation -d-i finish-install/reboot_in_progress note - -d-i cdrom-detect/eject boolean true -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Use the following option to add additional boot parameters for the -# installed system (if supported by the bootloader installer). -# Note: options passed to the installer will be added automatically. - -# With Ubuntu 12.04 LTS, modesetting may result in a blank console -d-i debian-installer/add-kernel-opts string vga=0x301 nomodeset -#------------------------------------------------------------------------------- -#### Advanced options -### Running custom commands during the installation -# d-i preseeding is inherently not secure. Nothing in the installer checks -# for attempts at buffer overflows or other exploits of the values of a -# preconfiguration file like this one. Only use preconfiguration files from -# trusted locations! - -# This command is run just before the install finishes, but when there is -# still a usable /target directory. You can chroot to /target and use it -# directly, or use the apt-install and in-target commands to easily install -# packages and run commands in the target system. -d-i preseed/late_command string echo "apt-get -y purge virtualbox-guest-dkms virtualbox-guest-utils; mount /dev/sr1 /mnt; /mnt/VBoxLinuxAdditions.run; umount /mnt; echo -e '#!/bin/bash\nexec > /root/bootstrap.log 2>&1\nset -x\nSCR=/media/sf_bootstrap/autostart/*activate_autostart.sh\nwhile [ ! -f \$SCR ];do sleep 1;done\nbash \$SCR\nrm -v \$SCR' > /etc/rc2.d/S40osbash; chmod 755 /etc/rc2.d/S40osbash;" | chroot /target /bin/bash; diff --git a/labs/lib/osbash/scanlib.sh b/labs/lib/osbash/scanlib.sh deleted file mode 100644 index f66c70f4..00000000 --- a/labs/lib/osbash/scanlib.sh +++ /dev/null @@ -1,302 +0,0 @@ -# The functions in this library are used to get scancode strings for VirtualBox -# keyboard input (keyboardputscancode). -# -# It was generated mostly from output of Cameron Kerr's scancodes.l: -# http://humbledown.org/keyboard-scancodes.xhtml -# -# The library works with bash 3.2 (shipped with Mac OS X as of 2014). - -function char2scancode { - local key=$1 - case "$key" in - 'a') - echo -n " 1e 9e" - ;; - 'b') - echo -n " 30 b0" - ;; - 'c') - echo -n " 2e ae" - ;; - 'd') - echo -n " 20 a0" - ;; - 'e') - echo -n " 12 92" - ;; - 'f') - echo -n " 21 a1" - ;; - 'g') - echo -n " 22 a2" - ;; - 'h') - echo -n " 23 a3" - ;; - 'i') - echo -n " 17 97" - ;; - 'j') - echo -n " 24 a4" - ;; - 'k') - echo -n " 25 a5" - ;; - 'l') - echo -n " 26 a6" - ;; - 'm') - echo -n " 32 b2" - ;; - 'n') - echo -n " 31 b1" - ;; - 'o') - echo -n " 18 98" - ;; - 'p') - echo -n " 19 99" - ;; - 'q') - echo -n " 10 90" - ;; - 'r') - echo -n " 13 93" - ;; - 's') - echo -n " 1f 9f" - ;; - 't') - echo -n " 14 94" - ;; - 'u') - echo -n " 16 96" - ;; - 'v') - echo -n " 2f af" - ;; - 'w') - echo -n " 11 91" - ;; - 'x') - echo -n " 2d ad" - ;; - 'y') - echo -n " 15 95" - ;; - 'z') - echo -n " 2c ac" - ;; - 'A') - echo -n " 2a 1e 9e aa" - ;; - 'B') - echo -n " 2a 30 b0 aa" - ;; - 'C') - echo -n " 2a 2e ae aa" - ;; - 'D') - echo -n " 2a 20 a0 aa" - ;; - 'E') - echo -n " 2a 12 92 aa" - ;; - 'F') - echo -n " 2a 21 a1 aa" - ;; - 'G') - echo -n " 2a 22 a2 aa" - ;; - 'H') - echo -n " 2a 23 a3 aa" - ;; - 'I') - echo -n " 2a 17 97 aa" - ;; - 'J') - echo -n " 2a 24 a4 aa" - ;; - 'K') - echo -n " 2a 25 a5 aa" - ;; - 'L') - echo -n " 2a 26 a6 aa" - ;; - 'M') - echo -n " 2a 32 b2 aa" - ;; - 'N') - echo -n " 2a 31 b1 aa" - ;; - 'O') - echo -n " 2a 18 98 aa" - ;; - 'P') - echo -n " 2a 19 99 aa" - ;; - 'Q') - echo -n " 2a 10 90 aa" - ;; - 'R') - echo -n " 2a 13 93 aa" - ;; - 'S') - echo -n " 2a 1f 9f aa" - ;; - 'T') - echo -n " 2a 14 94 aa" - ;; - 'U') - echo -n " 2a 16 96 aa" - ;; - 'V') - echo -n " 2a 2f af aa" - ;; - 'W') - echo -n " 2a 11 91 aa" - ;; - 'X') - echo -n " 2a 2d ad aa" - ;; - 'Z') - echo -n " 2a 2c ac aa" - ;; - 'Y') - echo -n " 2a 15 95 aa" - ;; - '1') - echo -n " 02 82" - ;; - '2') - echo -n " 03 83" - ;; - '3') - echo -n " 04 84" - ;; - '4') - echo -n " 05 85" - ;; - '5') - echo -n " 06 86" - ;; - '6') - echo -n " 07 87" - ;; - '7') - echo -n " 08 88" - ;; - '8') - echo -n " 09 89" - ;; - '9') - echo -n " 0a 8a" - ;; - '0') - echo -n " 0b 8b" - ;; - '!') - echo -n " 2a 02 82 aa" - ;; - '@') - echo -n " 2a 03 83 aa" - ;; - '#') - echo -n " 2a 04 84 aa" - ;; - '$') - echo -n " 2a 05 85 aa" - ;; - '%') - echo -n " 2a 06 86 aa" - ;; - '^') - echo -n " 2a 07 87 aa" - ;; - '&') - echo -n " 2a 08 88 aa" - ;; - '*') - echo -n " 2a 09 89 aa" - ;; - '(') - echo -n " 2a 0a 8a aa" - ;; - ')') - echo -n " 2a 0b 8b aa" - ;; - '-') - echo -n " 0c 8c" - ;; - '_') - echo -n " 2a 0c 8c aa" - ;; - '=') - echo -n " 0d 8d" - ;; - '+') - echo -n " 2a 0d 8d aa" - ;; - ' ') - echo -n " 39 b9" - ;; - '[') - echo -n " 1a 9a" - ;; - ']') - echo -n " 1b 9b" - ;; - '{') - echo -n " 2a 1a 9a aa" - ;; - '}') - echo -n " 2a 1b 9b aa" - ;; - ';') - echo -n " 27 a7" - ;; - ':') - echo -n " 2a 27 a7 aa" - ;; - ',') - echo -n " 33 b3" - ;; - '.') - echo -n " 34 b4" - ;; - '/') - echo -n " 35 b5" - ;; - '\') - echo -n " 2b ab" - ;; - '|') - echo -n " 2a 2b ab aa" - ;; - '?') - echo -n " 2a 35 b5 aa" - ;; - '"') - echo -n " 2a 28 a8 aa" - ;; - "'") - echo -n " 28 a8" - ;; - ">") - echo -n " 2a 34 b4 aa" - ;; - "<") - echo -n " 2a 33 b3 aa" - ;; - esac -} - -function esc2scancode { - echo -n " 01 81" -} - -function enter2scancode { - echo -n " 1c 9c" -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/osbash/templates/template-fedora-ifcfg-hostonly b/labs/lib/osbash/templates/template-fedora-ifcfg-hostonly deleted file mode 100644 index 0096a958..00000000 --- a/labs/lib/osbash/templates/template-fedora-ifcfg-hostonly +++ /dev/null @@ -1,5 +0,0 @@ -DEVICE=%IF_NAME% -ONBOOT=yes -BOOTPROTO=none -IPADDR=%IP_ADDRESS% -NETMASK=255.255.255.0 diff --git a/labs/lib/osbash/templates/template-fedora-ifcfg-nat b/labs/lib/osbash/templates/template-fedora-ifcfg-nat deleted file mode 100644 index 5b800ec8..00000000 --- a/labs/lib/osbash/templates/template-fedora-ifcfg-nat +++ /dev/null @@ -1,4 +0,0 @@ -# VirtualBox NAT -- for Internet access to VM -DEVICE=%IF_NAME% -ONBOOT=yes -BOOTPROTO=dhcp diff --git a/labs/lib/osbash/templates/template-ubuntu-interfaces-hostonly b/labs/lib/osbash/templates/template-ubuntu-interfaces-hostonly deleted file mode 100644 index 01c19476..00000000 --- a/labs/lib/osbash/templates/template-ubuntu-interfaces-hostonly +++ /dev/null @@ -1,4 +0,0 @@ -auto %IF_NAME% -iface %IF_NAME% inet static - address %IP_ADDRESS% - netmask 255.255.255.0 diff --git a/labs/lib/osbash/templates/template-ubuntu-interfaces-loopback b/labs/lib/osbash/templates/template-ubuntu-interfaces-loopback deleted file mode 100644 index a6923a9d..00000000 --- a/labs/lib/osbash/templates/template-ubuntu-interfaces-loopback +++ /dev/null @@ -1,3 +0,0 @@ -# The loopback network interface -auto lo -iface lo inet loopback diff --git a/labs/lib/osbash/templates/template-ubuntu-interfaces-nat b/labs/lib/osbash/templates/template-ubuntu-interfaces-nat deleted file mode 100644 index bfc01382..00000000 --- a/labs/lib/osbash/templates/template-ubuntu-interfaces-nat +++ /dev/null @@ -1,3 +0,0 @@ -# VirtualBox NAT -- for Internet access to VM -auto eth0 -iface eth0 inet dhcp diff --git a/labs/lib/osbash/virtualbox-functions.sh b/labs/lib/osbash/virtualbox-functions.sh deleted file mode 100644 index 3deda4c8..00000000 --- a/labs/lib/osbash/virtualbox-functions.sh +++ /dev/null @@ -1,738 +0,0 @@ -#------------------------------------------------------------------------------- -# VirtualBoxManage -#------------------------------------------------------------------------------- - -VBM=vbm -: ${VBM_LOG:=$LOG_DIR/vbm.log} - -# vbm is a wrapper around the VirtualBox VBoxManage executable; it handles -# logging and conditional execution (set OSBASH= to prevent the actual call to -# VBoxManage, or WBATCH= to keep a call from being recorded for Windows batch -# files) -function vbm { - ${WBATCH:-:} wbatch_log_vbm "$@" - - mkdir -p "$(dirname "$VBM_LOG")" - - if [[ -n "${OSBASH:-}" ]]; then - echo "$@" >> "$VBM_LOG" - local rc=0 - "$VBM_EXE" "$@" || rc=$? - if [ $rc -ne 0 ]; then - echo -e >&2 "${CError:-}FAILURE: VBoxManage: $@${CReset:-}" - return 1 - fi - else - echo "(not executed) $@" >> "$VBM_LOG" - fi -} - -# Return VirtualBox version string (without distro extensions) -function get_vb_version { - local version="" - # e.g. 4.1.32r92798 4.3.10_RPMFusionr93012 4.3.10_Debianr93012 - local raw=$(WBATCH= $VBM --version) - # Sanitize version string - local re='([0-9]+\.[0-9]+\.[0-9]+).*' - if [[ $raw =~ $re ]]; then - version=${BASH_REMATCH[1]} - fi - echo "$version" -} - -#------------------------------------------------------------------------------- -# VM status -#------------------------------------------------------------------------------- - -function vm_exists { - local vm_name=$1 - return $(WBATCH= $VBM list vms | grep -q "\"$vm_name\"") -} - -function vm_is_running { - local vm_name=$1 - return $(WBATCH= $VBM showvminfo --machinereadable "$vm_name" | \ - grep -q 'VMState="running"') -} - -function vm_wait_for_shutdown { - local vm_name=$1 - - ${WBATCH:-:} wbatch_wait_poweroff "$vm_name" - # Return if we are just faking it for wbatch - ${OSBASH:+:} return 0 - - echo -e >&2 -n "${CStatus:-}Machine shutting down${CReset:-}" - until WBATCH= $VBM showvminfo --machinereadable "$vm_name" 2>/dev/null | \ - grep -q '="poweroff"'; do - echo -n . - sleep 1 - done - echo >&2 -e "${CStatus:-}\nMachine powered off.${CReset:-}" -} - -function vm_power_off { - local vm_name=$1 - if vm_is_running "$vm_name"; then - echo -e >&2 "${CStatus:-}Powering off VM ${CData:-}\"$vm_name\"${CReset:-}" - $VBM controlvm "$vm_name" poweroff - fi - # VirtualBox VM needs a break before taking new commands - vbox_sleep 1 -} - -function vm_snapshot { - local vm_name=$1 - local shot_name=$2 - - $VBM snapshot "$vm_name" take "$shot_name" - # VirtualBox VM needs a break before taking new commands - vbox_sleep 1 -} - -#------------------------------------------------------------------------------- -# Host-only network functions -#------------------------------------------------------------------------------- - -function hostonlyif_in_use { - local if_name=$1 - return $(WBATCH= $VBM list -l runningvms | \ - grep -q "Host-only Interface '$if_name'") -} - -function ip_to_hostonlyif { - local ip=$1 - local prevline="" - WBATCH= $VBM list hostonlyifs | grep -e "^Name:" -e "^IPAddress:" | \ - while read line; do - if [[ "$line" == *$ip* ]]; then - # match longest string that ends with a space - echo ${prevline##Name:* } - break - fi - prevline=$line - done -} - -function create_hostonlyif { - local out=$(WBATCH= $VBM hostonlyif create 2> /dev/null | grep "^Interface") - # out is something like "Interface 'vboxnet3' was successfully created" - local re="Interface '(.*)' was successfully created" - if [[ $out =~ $re ]]; then - echo "${BASH_REMATCH[1]}" - else - echo -e >&2 "${CError:-}Host-only interface creation failed${CReset:-}" - return 1 - fi -} - -function create_network { - local ip=$1 - - # If we are here only for wbatch, ignore actual network interfaces; just - # return a unique identifier (so it can be replaced with the interface - # name used by Windows). - ${OSBASH:+:} mktemp -u XXXXXXXX - ${OSBASH:+:} return 0 - - local if_name=$(ip_to_hostonlyif "$ip") - if [ -n "$if_name" ]; then - if hostonlyif_in_use "$if_name"; then - echo >&2 "Host-only interface $if_name ($ip) is in use." \ - "Using it, too." - fi - else - echo -e >&2 "${CStatus:-}Creating host-only interface${CReset:-}" - if_name=$(create_hostonlyif) - fi - - echo -e >&2 "${CStatus:-}Configuring host-only network ${CData:-}$ip ($if_name)${CReset:-}" - $VBM hostonlyif ipconfig "$if_name" \ - --ip "$ip" \ - --netmask 255.255.255.0 >/dev/null - echo "$if_name" -} - -#------------------------------------------------------------------------------- -# Disk functions -#------------------------------------------------------------------------------- - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Creating, registering and unregistering disk images with VirtualBox -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# disk can be either a path or a disk UUID -function disk_registered { - local disk=$1 - return $(WBATCH= $VBM list hdds | grep -q "$disk") -} - -# disk can be either a path or a disk UUID -function disk_unregister { - local disk=$1 - echo >&2 -e "${CStatus:-}Unregistering disk\n\t${CData:-}$disk${CReset:-}" - $VBM closemedium disk "$disk" -} - -function create_vdi { - local hd_path=$1 - local size=$2 - echo >&2 -e "${CStatus:-}Creating disk:\n\t${CData:-}$hd_path${CReset:-}" - $VBM createhd --format VDI --filename "$hd_path" --size "$size" -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Attaching and detaching disks from VMs -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# disk can be either a path or a disk UUID -function get_next_child_uuid { - local disk=$1 - local child_uuid="" - local line="" - if disk_registered "$disk"; then - line=$(WBATCH= $VBM showhdinfo "$disk" | grep -e "^Child UUIDs:") - child_uuid=${line##Child UUIDs:* } - fi - echo -e "next_child_uuid $disk:\n\t$line\n\t$child_uuid" >> "$VBM_LOG" - echo "$child_uuid" -} - -# disk can be either a path or a disk UUID -function path_to_disk_uuid { - local disk=$1 - local uuid="" - local line=$(WBATCH= $VBM showhdinfo "$disk" | grep -e "^UUID:") - local re='UUID:[ ]+([^ ]+)' - if [[ $line =~ $re ]]; then - uuid=${BASH_REMATCH[1]} - fi - echo -e "path_to_disk_uuid $disk:\n\t$line\n\t$uuid" >> "$VBM_LOG" - echo "$uuid" -} - -# disk can be either a path or a disk UUID -function disk_to_path { - local disk=$1 - local fpath="" - local line=$(WBATCH= $VBM showhdinfo "$disk" | grep -e "^Location:") - local re='Location:[ ]+([^ ]+)' - if [[ $line =~ $re ]]; then - fpath=${BASH_REMATCH[1]} - fi - echo -e "disk_to_path $disk:\n\t$line\n\t$fpath" >> "$VBM_LOG" - echo "$fpath" -} - -# disk can be either a path or a disk UUID -function disk_to_vm { - local disk=$1 - local vm_name="" - local line=$(WBATCH= $VBM showhdinfo "$disk" | grep -e "^In use by VMs:") - local re='In use by VMs:[ ]+([^ ]+) ' - if [[ $line =~ $re ]]; then - vm_name=${BASH_REMATCH[1]} - fi - echo -e "disk_to_vm $disk:\n\t$line\n\t$vm_name" >> "$VBM_LOG" - echo "$vm_name" -} - -function vm_get_disk_path { - local vm_name=$1 - local line=$(WBATCH= $VBM showvminfo --machinereadable "$vm_name" | \ - grep '^"SATA-0-0"=.*vdi"$') - local hd_path=${line##\"SATA-0-0\"=\"} - hd_path=${hd_path%\"} - echo "$hd_path" -} - -function vm_detach_disk { - local vm_name=$1 - echo >&2 "Detaching disk from VM \"$vm_name\"" - $VBM storageattach "$vm_name" \ - --storagectl SATA \ - --port 0 \ - --device 0 \ - --type hdd \ - --medium none - # VirtualBox VM needs a break before taking new commands - vbox_sleep 1 -} - -# disk can be either a path or a disk UUID -function vm_attach_disk { - local vm_name=$1 - local disk=$2 - echo >&2 -e "Attaching to VM \"$vm_name\":\n\t$disk" - $VBM storageattach "$vm_name" \ - --storagectl SATA \ - --port 0 \ - --device 0 \ - --type hdd \ - --medium "$disk" -} - -# disk can be either a path or a disk UUID -function vm_attach_disk_multi { - local vm_name=$1 - local disk=$2 - - $VBM modifyhd --type multiattach "$disk" - - echo >&2 -e "Attaching to VM \"$vm_name\":\n\t$disk" - $VBM storageattach "$vm_name" \ - --storagectl SATA \ - --port 0 \ - --device 0 \ - --type hdd \ - --medium "$disk" -} - -#------------------------------------------------------------------------------- -# VM create and configure -#------------------------------------------------------------------------------- - -function vm_mem { - local vm_name="$1" - local mem="$2" - $VBM modifyvm "$vm_name" --memory "$mem" -} - -function vm_cpus { - local vm_name="$1" - local cpus="$2" - $VBM modifyvm "$vm_name" --cpus "$cpus" -} - -# Port forwarding from host to VM (binding to host's 127.0.0.1) -function vm_port { - local vm_name="$1" - local desc="$2" - local hostport="$3" - local guestport="$4" - $VBM modifyvm "$vm_name" \ - --natpf1 "$desc,tcp,127.0.0.1,$hostport,,$guestport" -} - -function vm_nic_hostonly { - local vm_name=$1 - # We start counting interfaces at 0, but VirtualBox starts NICs at 1 - local nic=$(($2 + 1)) - local net_name=$3 - $VBM modifyvm "$vm_name" \ - "--nictype$nic" "$NICTYPE" \ - "--nic$nic" hostonly \ - "--hostonlyadapter$nic" "$net_name" \ - "--nicpromisc$nic" allow-all -} - -function vm_nic_nat { - local vm_name=$1 - # We start counting interfaces at 0, but VirtualBox starts NICs at 1 - local nic=$(($2 + 1)) - $VBM modifyvm "$vm_name" "--nictype$nic" "$NICTYPE" "--nic$nic" nat -} - -function vm_create { - # NOTE: We assume that a VM with a matching name is ours. - # Remove and recreate just in case someone messed with it. - local vm_name=$1 - - ${WBATCH:-:} wbatch_abort_if_vm_exists "$vm_name" - - # Don't write to wbatch scripts, and don't execute when we are faking it - # it for wbatch - WBATCH= ${OSBASH:-:} vm_delete "$vm_name" - - # XXX ostype is distro-specific; moving it to modifyvm disables networking - - # Note: The VirtualBox GUI may not notice group changes after VM creation - # until GUI is restarted. Moving a VM with group membership will - # fail in cases (lingering files from old VM) where creating a - # VM in that location succeeds. - # - # XXX temporary hack - # --groups not supported in VirtualBox 4.1 (Mac OS X 10.5) - echo -e >&2 "${CStatus:-}Creating VM ${CData:-}\"$vm_name\"${CReset:-}" - local ver=$(get_vb_version) - if [[ $ver = 4.1* ]]; then - $VBM createvm \ - --name "$vm_name" \ - --register \ - --ostype Ubuntu_64 >/dev/null - else - $VBM createvm \ - --name "$vm_name" \ - --register \ - --ostype Ubuntu_64 \ - --groups "/$VM_GROUP" >/dev/null - fi - - $VBM modifyvm "$vm_name" --rtcuseutc on - $VBM modifyvm "$vm_name" --biosbootmenu disabled - $VBM modifyvm "$vm_name" --largepages on - $VBM modifyvm "$vm_name" --boot1 disk - - # XXX temporary hack - # --portcount not supported in VirtualBox 4.1 (Mac OS X 10.5) - if [[ $ver == 4.1* ]]; then - $VBM storagectl "$vm_name" --name SATA --add sata - else - $VBM storagectl "$vm_name" --name SATA --add sata --portcount 1 - fi - $VBM storagectl "$vm_name" --name SATA --hostiocache on - - $VBM storagectl "$vm_name" --name IDE --add ide - echo -e >&2 "${CStatus:-}Created VM ${CData:-}\"$vm_name\"${CReset:-}" -} - -#------------------------------------------------------------------------------- -# VM export -#------------------------------------------------------------------------------- - -# Export node VMs to OVA package file -function vm_export_ova { - local ova_file=$1 - local nodes=$2 - echo >&2 "Removing shared folders for export" - local -a share_paths - local node - for node in $nodes; do - local share_path=$(vm_get_share_path "$node") - share_paths+=("$share_path") - if [ -n "$share_path" ]; then - vm_rm_share "$node" "$SHARE_NAME" - fi - done - rm -f "$ova_file" - mkdir -pv "$IMG_DIR" - $VBM export $nodes --output "$ova_file" - echo >&2 "Appliance exported" - echo >&2 "Reattaching shared folders" - local ii=0 - for node in $nodes; do - if [ -n "${share_paths[$ii]}" ]; then - vm_add_share "$node" "${share_paths[$ii]}" "$SHARE_NAME" - fi - ii=$(($ii + 1)) - done -} - -# Export node VMs by cloning VMs to directory -function vm_export_dir { - local export_dir=$1 - local nodes=$2 - - rm -rvf "$export_dir" - - for node in $nodes; do - if vm_is_running "$node"; then - echo "Powering off node VM $node." - echo "$VBM controlvm $node poweroff" - $VBM controlvm "$node" poweroff - fi - sleep 1 - local share_path=$(vm_get_share_path "$node") - if [ -n "$share_path" ]; then - echo >&2 "Removing shared folder for export" - vm_rm_share "$node" "$SHARE_NAME" - fi - sleep 1 - echo "Exporting VM $node to $export_dir" - # Use all: machineandchildren works only if --snapshot is given as UUID - $VBM clonevm "$node" \ - --mode all \ - --options keepallmacs,keepdisknames \ - --name "$node-e" \ - --groups "/$VM_GROUP" \ - --basefolder "$export_dir" \ - --register - # VirtualBox registers disks and snapshots of the clone VM even if we - # don't register the VM above. Unregistering the registered VM takes - # care of the snapshots, but we still have to unregister the clone - # basedisk. - local snapshot_path=$(vm_get_disk_path "$node-e") - local hd_dir=${snapshot_path%Snapshots/*} - local hd_path=$hd_dir$(get_base_disk_name) - $VBM unregistervm "$node-e" - if [ -n "$hd_path" ]; then - disk_unregister "$hd_path" - fi - if [ -n "$share_path" ]; then - echo >&2 "Reattaching shared folder" - vm_add_share "$node" "$share_path" "$SHARE_NAME" - fi - done -} - -#------------------------------------------------------------------------------- -# VM unregister, remove, delete -#------------------------------------------------------------------------------- - -function vm_unregister_del { - local vm_name=$1 - echo -e >&2 "${CStatus:-}Unregistering and deleting VM ${CData:-}\"$vm_name\"${CReset:-}" - $VBM unregistervm "$vm_name" --delete -} - -function vm_delete { - local vm_name=$1 - echo >&2 -n "Asked to delete VM \"$vm_name\" " - if vm_exists "$vm_name"; then - echo >&2 "(found)" - vm_power_off "$vm_name" - local hd_path=$(vm_get_disk_path "$vm_name") - if [ -n "$hd_path" ]; then - echo >&2 -e "${CInfo:-}Disk attached: ${CData:-}$hd_path${CReset:-}" - vm_detach_disk "$vm_name" - disk_unregister "$hd_path" - echo >&2 -e "Deleting: $hd_path" - rm -f "$hd_path" - fi - vm_unregister_del "$vm_name" - else - echo >&2 "(not found)" - fi -} - -# Remove VMs using disk and its children disks -# disk can be either a path or a disk UUID -function disk_delete_child_vms { - local disk=$1 - if ! disk_registered "$disk"; then - # VirtualBox doesn't know this disk; we are done - echo >&2 -e "${CError:-}Disk not registered with VirtualBox:\n\t${CData:-}$disk${CReset:-}" - return 0 - fi - - # XXX temporary hack - # No Child UUIDs through showhdinfo in VirtualBox 4.1 (Mac OS X 10.5) - local ver=$(get_vb_version) - if [[ $ver == 4.1* ]]; then - local vm_name="" - for vm_name in controller network compute base; do - vm_delete "$vm_name" - done - return 0 - fi - - while [ : ]; do - local child_uuid=$(get_next_child_uuid "$disk") - if [ -n "$child_uuid" ]; then - local child_disk=$(disk_to_path "$child_uuid") - echo >&2 -e "\nChild disk UUID: $child_uuid\n\t$child_disk" - - local vm_name=$(disk_to_vm "$child_uuid") - if [ -n "$vm_name" ]; then - echo 2>&1 -e "\tstill attached to VM \"$vm_name\"" - vm_delete "$vm_name" - else - echo -e >&2 "${CStatus:-}Unregistering and deleting: ${CData:-}$child_uuid${CReset:-}" - disk_unregister "$child_uuid" - echo >&2 -e "\t$child_disk" - rm -f "$child_disk" - fi - else - break - fi - done -} - -#------------------------------------------------------------------------------- -# VM shared folders -#------------------------------------------------------------------------------- - -# Return the host path for a VM's shared directory; assumes there is only one. -function vm_get_share_path { - local vm_name=$1 - local line=$(WBATCH= $VBM showvminfo --machinereadable "$vm_name" | \ - grep '^SharedFolderPathMachineMapping1=') - local share_path=${line##SharedFolderPathMachineMapping1=\"} - share_path=${share_path%\"} - echo "$share_path" -} - -function vm_add_share_automount { - local vm_name=$1 - local share_dir=$2 - local share_name=$3 - $VBM sharedfolder add "$vm_name" \ - --name "$share_name" \ - --hostpath "$share_dir" \ - --automount -} - -function vm_add_share { - local vm_name=$1 - local share_dir=$2 - local share_name=$3 - $VBM sharedfolder add "$vm_name" \ - --name "$share_name" \ - --hostpath "$share_dir" -} - -function vm_rm_share { - local vm_name=$1 - local share_name=$2 - $VBM sharedfolder remove "$vm_name" --name "$share_name" -} - -#------------------------------------------------------------------------------- -# VirtualBox guest add-ons -#------------------------------------------------------------------------------- - -# Download VirtualBox guest-additions. Returns local path of ISO image. -function _download_guestadd-iso { - local iso=VBoxGuestAdditions.iso - local ver=$(get_vb_version) - if [[ -n "$ver" ]]; then - local url="http://download.virtualbox.org/virtualbox/$ver/VBoxGuestAdditions_$ver.iso" - download "$url" "$ISO_DIR" $iso - fi - echo "$ISO_DIR/$iso" -} - -function _get_guestadd-iso { - local iso=VBoxGuestAdditions.iso - - local add_iso="$IMG_DIR/$iso" - if [ -f "$add_iso" ]; then - echo "$add_iso" - return 0 - fi - - add_iso="/Applications/VirtualBox.app/Contents/MacOS/$iso" - if [ -f "$add_iso" ]; then - echo "$add_iso" - return 0 - fi - - echo >&2 "Searching filesystem for VBoxGuestAdditions. This may take a while..." - add_iso=$(find / -name "$iso" 2>/dev/null) || true - if [ -n "$add_iso" ]; then - echo "$add_iso" - return 0 - fi - - echo >&2 "Looking on the Internet" - add_iso=$(_download_guestadd-iso) - if [ -f "$add_iso" ]; then - echo "$add_iso" - return 0 - fi -} - -function _vm_attach_guestadd-iso { - local vm_name=$1 - local guestadd_iso=$2 - local rc=0 - $VBM storageattach "$vm_name" --storagectl IDE --port 1 --device 0 --type dvddrive --medium "$guestadd_iso" 2>/dev/null || rc=$? - return $rc -} - -function vm_attach_guestadd-iso { - local vm_name=$1 - - OSBASH= ${WBATCH:-:} _vm_attach_guestadd-iso "$vm_name" emptydrive - OSBASH= ${WBATCH:-:} _vm_attach_guestadd-iso "$vm_name" additions - # Return if we are just faking it for wbatch - ${OSBASH:+:} return 0 - - if [ -z "${GUESTADD_ISO-}" ]; then - - # No location provided, asking VirtualBox for one - - # An existing drive is needed to make additions shortcut work - # (at least VirtualBox 4.3.12 and below) - WBATCH= _vm_attach_guestadd-iso "$vm_name" emptydrive - - if WBATCH= _vm_attach_guestadd-iso "$vm_name" additions; then - echo >&2 "Using VBoxGuestAdditions provided by VirtualBox" - return 0 - fi - # Neither user nor VirtualBox are helping, let's go guessing - GUESTADD_ISO=$(_get_guestadd-iso) - if [ -z "GUESTADD_ISO" ]; then - # No ISO found - return 2 - fi - fi - if WBATCH= _vm_attach_guestadd-iso "$vm_name" "$GUESTADD_ISO"; then - echo >&2 "Attached $GUESTADD_ISO" - return 0 - else - echo -e >&2 "${CError:-}Failed to attach ${CData:-}$GUESTADD_ISO${CReset:-}" - return 3 - fi -} - -#------------------------------------------------------------------------------- -# Sleep -#------------------------------------------------------------------------------- - -function vbox_sleep { - sec=$1 - - # Don't sleep if we are just faking it for wbatch - ${OSBASH:-:} sleep "$sec" - ${WBATCH:-:} wbatch_sleep "$sec" -} - -#------------------------------------------------------------------------------- -# Booting a VM and passing boot parameters -#------------------------------------------------------------------------------- - -source "$OSBASH_LIB_DIR/scanlib.sh" - -function _vbox_push_scancode { - local vm_name=$1 - shift - # Split string (e.g. '01 81') into arguments (works also if we - # get each hexbyte as a separate argument) - # Not quoting $@ is intentional -- we want to split on blanks - local scan_code=( $@ ) - $VBM controlvm "$vm_name" keyboardputscancode "${scan_code[@]}" -} - -function vbox_kbd_escape_key { - local vm_name=$1 - _vbox_push_scancode "$vm_name" "$(esc2scancode)" -} - -function vbox_kbd_enter_key { - local vm_name=$1 - _vbox_push_scancode "$vm_name" "$(enter2scancode)" -} - -function vbox_kbd_string_input { - local vm_name=$1 - local str=$2 - - # This loop is inefficient enough that we don't overrun the keyboard input - # buffer when pushing scancodes to the VirtualBox. - while IFS= read -r -n1 char; do - if [ -n "$char" ]; then - SC=$(char2scancode "$char") - if [ -n "$SC" ]; then - _vbox_push_scancode "$vm_name" "$SC" - else - echo >&2 "not found: $char" - fi - fi - done <<< "$str" -} - -function vbox_boot { - local vm_name=$1 - - echo -e >&2 "${CStatus:-}Starting VM ${CData:-}\"$vm_name\"${CReset:-}" - if [ -n "${VM_UI:-}" ]; then - $VBM startvm "$vm_name" --type "$VM_UI" - else - $VBM startvm "$vm_name" - fi -} - -#------------------------------------------------------------------------------- - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/osbash/virtualbox-install_base.sh b/labs/lib/osbash/virtualbox-install_base.sh deleted file mode 100644 index f5aa6bb3..00000000 --- a/labs/lib/osbash/virtualbox-install_base.sh +++ /dev/null @@ -1,145 +0,0 @@ -# This bash library contains the main function that creates the base disk. - -function check_md5 { - local file=$1 - local csum=$2 - local md5exe - if ! md5exe=$(which md5sum); then - # On Mac OS X, the tool is called md5 - if ! md5exe=$(which md5); then - echo -e >&2 "${CError:-}Neither md5sum nor md5 found. Aborting.${CReset:-}" - exit 1 - fi - fi - echo -e >&2 -n "${CStatus:-}Verifying ISO image MD5 checksum: ${CReset:-}" - if $md5exe "$file" | grep -q "$csum"; then - echo >&2 "okay." - else - echo -e >&2 "${CError:-}Verification failed. ISO image is corrupt.${CReset:-}" - echo >&2 "Removing the ISO image." - rm "$file" - echo -e >&2 "${CError:-}Please re-run osbash script.${CReset:-}" - exit 1 - fi -} - -function vm_install_base { - local base_disk=$1 - local base_build_disk=$DISK_DIR/tmp-disk.vdi - local vm_name=base - - # Port used for ssh forwarding when building base disk - : ${VM_BASE_SSH_PORT:=2229} - - echo >&2 "$(date) osbash vm_install starts." - - ${WBATCH:-:} wbatch_begin_base - - # Don't remove base_build_disk if we are just faking it for wbatch - ${OSBASH:-:} rm -f "$base_build_disk" - ${WBATCH:-:} wbatch_delete_disk "$base_build_disk" - - vm_create "$vm_name" - vm_mem "$vm_name" "${VM_BASE_MEM:=512}" - - if [ -z "${INSTALL_ISO-}" ]; then - local iso_name=$(get_iso_name) - - if [ -z "$iso_name" ]; then - echo -e >&2 "${CMissing:-}Either ISO URL or name needed (ISO_URL, INSTALL_ISO).${CReset:-}" - exit 1 - fi - INSTALL_ISO=$ISO_DIR/$iso_name - # Don't look for ISO image if we are only doing wbatch - ${OSBASH:-:} find_install-iso "$iso_name" - fi - - echo >&2 -e "${CInfo:-}Install ISO:\n\t${CData:-}$INSTALL_ISO${CReset:-}" - - ${OSBASH:-:} check_md5 "$INSTALL_ISO" "$ISO_MD5" - - $VBM storageattach "$vm_name" \ - --storagectl IDE \ - --port 0 \ - --device 0 \ - --type dvddrive \ - --medium "$INSTALL_ISO" - - ${WBATCH:-:} vm_attach_guestadd-iso "$vm_name" - - ${OSBASH:-:} mkdir -pv "$DISK_DIR" - create_vdi "$base_build_disk" "${BASE_DISK_SIZE:=10000}" - vm_attach_disk "$vm_name" "$base_build_disk" - - #--------------------------------------------------------------------------- - # Set up communication with base VM: ssh port forwarding by default, - # VirtualBox shared folders for wbatch - - # wbatch runs cannot use ssh, so skip port forwarding in that case - ${WBATCH:+:} vm_port "$vm_name" ssh "$VM_BASE_SSH_PORT" 22 - - # Automounted on /media/sf_bootstrap for first boot - ${WBATCH:-:} vm_add_share_automount "$vm_name" "$SHARE_DIR" bootstrap - # Mounted on /$SHARE_NAME after first boot - ${WBATCH:-:} vm_add_share "$vm_name" "$SHARE_DIR" "$SHARE_NAME" - #--------------------------------------------------------------------------- - - $VBM modifyvm "$vm_name" --boot1 dvd - - # Configure autostart - autostart_reset - - # For wbatch, install osbashauto as a boot service - ${WBATCH:-:} autostart osbash/activate_autostart.sh - - autostart osbash/base_fixups.sh - - # By default, set by lib/osbash/lib.* to something like scripts.ubuntu_base - autostart_from_config "$BASE_INSTALL_SCRIPTS" - - autostart zero_empty.sh shutdown.sh - - # Boot VM into distribution installer - vbox_boot "$vm_name" - - local delay=5 - echo >&2 "Waiting $delay seconds for VM \"$vm_name\" to come up" - vbox_sleep "$delay" - - vbox_distro_start_installer "$vm_name" - - echo -e >&2 "${CStatus:-}Installing operating system; waiting for reboot${CReset:-}" - - # Wait for ssh connection and execute scripts in autostart directory - # (for wbatch, osbashauto does the processing instead) - ${WBATCH:+:} ssh_process_autostart "$VM_BASE_SSH_PORT" & - # After reboot - wait_for_autofiles - echo -e >&2 "${CStatus:-}Installation done for VM ${CData:-}$vm_name${CReset:-}" - - vm_wait_for_shutdown "$vm_name" - - # Detach disk from VM now or it will be deleted by vm_unregister_del - vm_detach_disk "$vm_name" - - vm_unregister_del "$vm_name" - - echo >&2 "Compacting $base_build_disk" - $VBM modifyhd "$base_build_disk" --compact - - # This disk will be moved to a new name, and this name will be used for - # a new disk next time the script runs. - disk_unregister "$base_build_disk" - - echo -e >&2 "${CStatus:-}Base disk created${CReset:-}" - - echo >&2 "Moving base disk to $base_disk" - ${OSBASH:-:} mv -vf "$base_build_disk" "$base_disk" - ${WBATCH:-:} wbatch_rename_disk "$base_build_disk" "$base_disk" - - ${WBATCH:-:} wbatch_end_file - - echo >&2 -e "${CData:-}$(date) ${CStatus:-}osbash vm_install ends\n${CReset:-}" -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/osbash/virtualbox-install_nodes.sh b/labs/lib/osbash/virtualbox-install_nodes.sh deleted file mode 100644 index 51ef6581..00000000 --- a/labs/lib/osbash/virtualbox-install_nodes.sh +++ /dev/null @@ -1,86 +0,0 @@ -# This bash library contains the main function that creates a node VM. - -# Configure VirtualBox network interfaces -function _vbox_configure_ifs { - local vm_name=$1 - # Iterate over all NET_IF_? variables - local net_ifs=( "${!NET_IF_@}" ) - local net_if="" - for net_if in "${net_ifs[@]}"; do - local if_num=${net_if##*_} - if [ "${!net_if}" = "nat" ]; then - echo "interface $if_num: NAT" - vm_nic_nat "$vm_name" "$if_num" - else - # Host-only network: net_if is net name (e.g. API_NET) - # Use corresponding VirtualBox interface (e.g. API_NET_IF) - local host_if="${!net_if}_IF" - echo "interface $if_num: host-only ${!host_if}" - vm_nic_hostonly "$vm_name" "$if_num" "${!host_if}" - fi - done -} - -# Boot node VM; wait until autostart files are processed and VM is shut down -function _vbox_boot_with_autostart { - local vm_name=$1 - - vbox_boot "$vm_name" - - # Wait for ssh connection and execute scripts in autostart directory - # (for wbatch, osbashauto does the processing instead) - ${WBATCH:+:} ssh_process_autostart "$vm_name" & - - wait_for_autofiles - echo >&2 "VM \"$vm_name\": autostart files executed" -} - -# Create a new node VM and run basic configuration scripts -function vm_init_node { - # XXX Run this function in sub-shell to protect our caller's environment - # (which might be _our_ enviroment if we get called again) - ( - source "$CONFIG_DIR/config.$vm_name" - - vm_name=$1 - - vm_create "$vm_name" - - # Set VM_MEM in config/config.NODE_NAME to override - vm_mem "$vm_name" "${VM_MEM:-512}" - - # Set VM_CPUS in config/config.NODE_NAME to override - vm_cpus "$vm_name" "${VM_CPUS:-1}" - - _vbox_configure_ifs "$vm_name" - - # Port forwarding - if [ -n "${VM_SSH_PORT:-}" ]; then - vm_port "$vm_name" ssh "$VM_SSH_PORT" 22 - fi - if [ -n "${VM_WWW_PORT:-}" ]; then - vm_port "$vm_name" http "$VM_WWW_PORT" 80 - fi - - vm_add_share "$vm_name" "$SHARE_DIR" "$SHARE_NAME" - vm_attach_disk_multi "$vm_name" "$BASE_DISK" - #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Rename to pass the node name to the script - autostart_and_rename osbash init_xxx_node.sh "init_${vm_name}_node.sh" - - ) -} - -function vm_build_nodes { - CONFIG_NAME=$(get_distro_name "$DISTRO")_$1 - echo -e "${CInfo:-}Configuration file: ${CData:-}$CONFIG_NAME${CReset:-}" - - ${WBATCH:-:} wbatch_begin_node "$CONFIG_NAME" - #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - autostart_reset - autostart_from_config "scripts.$CONFIG_NAME" - #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${WBATCH:-:} wbatch_end_file -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/wbatch/README.rst b/labs/lib/wbatch/README.rst deleted file mode 100644 index 03423220..00000000 --- a/labs/lib/wbatch/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -The files in this directory are used to create Windows batch scripts that -can build base disks and VM clusters. diff --git a/labs/lib/wbatch/batch_for_windows.sh b/labs/lib/wbatch/batch_for_windows.sh deleted file mode 100644 index 3ac7dbbd..00000000 --- a/labs/lib/wbatch/batch_for_windows.sh +++ /dev/null @@ -1,298 +0,0 @@ -# This bash library contains the functions that allow osbash to produce -# Windows batch files. - -: ${WBATCH_DIR:="$TOP_DIR/wbatch"} - -# By default, Windows batch file templates are in the same directory as this -# file -: ${WBATCH_TEMPLATE_DIR:=$(dirname "$BASH_SOURCE")} - -# wbatch cannot use ssh for talking to the VM; install VirtualBox guest -# additions -VM_ACCESS=vbadd - -#------------------------------------------------------------------------------- -# Helper functions -#------------------------------------------------------------------------------- - -# See functions.host for definition and explanation of exec_cmd -WBATCH=exec_cmd - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function wbatch_reset { - clean_dir "$WBATCH_DIR" -} - -function wbatch_new_file { - local file_name=$1 - mkdir -p "$WBATCH_DIR" - WBATCH_OUT="$WBATCH_DIR/$file_name" - echo -n > "$WBATCH_OUT" -} - -function wbatch_close_file { - unset WBATCH_OUT -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function wbatch_write_line { - if [ -n "${WBATCH_OUT:-}" ]; then - # Don't expand backslash escapes except for ending the line with CRLF - # - # Note: Windows batch scripts with LF may seem to work, but (for - # instance) jump labels don't work properly - echo -n "$@" >> "$WBATCH_OUT" - echo -e "\r" >> "$WBATCH_OUT" - fi -} - -function wbatch_write_stdin { - local line="" - - # Set IFS to preserve leading whitespace - while IFS= read -r line; do - wbatch_write_line "$line" - done -} - -function wbatch_echo { - wbatch_write_line "ECHO %time% $@" -} - -#------------------------------------------------------------------------------- -# Batch function calls -#------------------------------------------------------------------------------- - -function wbatch_abort_if_vm_exists { - local vm_name=$1 - wbatch_write_line "CALL :vm_exists $vm_name" -} - -function wbatch_wait_poweroff { - local vm_name=$1 - cat << WBAT | wbatch_write_stdin -ECHO %time% Waiting for VM $vm_name to power off. -CALL :wait_poweroff $vm_name -ECHO %time% VM $vm_name powered off. -WBAT -} - -function wbatch_wait_auto { - cat << WBAT | wbatch_write_stdin -ECHO %time% Waiting for autostart files to execute. -CALL :wait_auto -ECHO %time% All autostart files executed. -WBAT -} - -#------------------------------------------------------------------------------- -# Batch commands -#------------------------------------------------------------------------------- - -function wbatch_delete_disk { - local disk=$(basename "$1") - wbatch_write_line "IF EXIST %IMGDIR%\\$disk DEL %IMGDIR%\\$disk" -} - -function wbatch_rename_disk { - local src=$(basename "$1") - local target=$(basename "$2") - - wbatch_write_line "MOVE /y %IMGDIR%\\$src %IMGDIR%\\$target" -} - -function wbatch_cp_auto { - local src=$(wbatch_path_to_windows "$1") - local target=$(basename "$2") - src=${src//\//\\} - wbatch_write_line "COPY %TOPDIR%\\$src %AUTODIR%\\$target" -} - -function wbatch_sleep { - local sec=$1 - wbatch_write_line "TIMEOUT /T $sec /NOBREAK" -} - -#------------------------------------------------------------------------------- -# Templated parts -#------------------------------------------------------------------------------- - -# Note: BSD and GNU sed behavior is different. Don't try anything fancy -# like inserting \r or in-place editing (-i). - -function wbatch_file_header { - local product=$1 - - sed -e " - s,%PRODUCT%,$product,g; - " "$WBATCH_TEMPLATE_DIR/template-file_header_bat" | wbatch_write_stdin -} - -function wbatch_end_file { - cat "$WBATCH_TEMPLATE_DIR/template-end_file_bat" | wbatch_write_stdin - wbatch_close_file -} - -function wbatch_elevate_privileges { - cat "$WBATCH_TEMPLATE_DIR/template-elevate_privs_bat" | wbatch_write_stdin -} - -function wbatch_find_vbm { - cat "$WBATCH_TEMPLATE_DIR/template-find_vbm_bat" | wbatch_write_stdin -} - -function wbatch_mkdirs { - local autodir=$(wbatch_path_to_windows "$AUTOSTART_DIR") - local imgdir=$(wbatch_path_to_windows "$IMG_DIR") - local logdir=$(wbatch_path_to_windows "$LOG_DIR") - local statusdir=$(wbatch_path_to_windows "$STATUS_DIR") - - autodir=$(wbatch_escape_backslash "$autodir") - imgdir=$(wbatch_escape_backslash "$imgdir") - logdir=$(wbatch_escape_backslash "$logdir") - statusdir=$(wbatch_escape_backslash "$statusdir") - - sed -e " - s,%P_AUTODIR%,$autodir,g; - s,%P_IMGDIR%,$imgdir,g; - s,%P_LOGDIR%,$logdir,g; - s,%P_STATUSDIR%,$statusdir,g; - " "$WBATCH_TEMPLATE_DIR/template-mkdirs_bat" | wbatch_write_stdin -} - -function wbatch_create_hostnet { - wbatch_new_file "create_hostnet.bat" - wbatch_file_header "host-only networks" - # Creating networks requires elevated privileges - wbatch_elevate_privileges - wbatch_find_vbm - - sed -e " - s,%APINET%,$API_NET,g; - s,%DATANET%,$DATA_NET,g; - s,%MGMTNET%,$MGMT_NET,g; - " "$WBATCH_TEMPLATE_DIR/template-create_hostnet_bat" | wbatch_write_stdin - - wbatch_end_file -} - -function wbatch_begin_base { - local iso_name=$(get_iso_name) - - if [ -z "$iso_name" ]; then - echo >&2 "Windows batch file needs install ISO URL (ISO_URL)." - exit 1 - fi - - wbatch_new_file "create_base.bat" - wbatch_file_header "base disk" - wbatch_find_vbm - wbatch_mkdirs - - sed -e " - s,%INSTALLFILE%,$iso_name,g; - s,%ISOURL%,$ISO_URL,g; - " "$WBATCH_TEMPLATE_DIR/template-begin_base_bat" | wbatch_write_stdin -} - -function wbatch_begin_node { - local node_name=$1 - wbatch_new_file "create_${node_name}_node.bat" - wbatch_file_header "$node_name VM" - wbatch_find_vbm - wbatch_mkdirs - - local basedisk=$(basename "$BASE_DISK") - - sed -e " - s,%BASEDISK%,$basedisk,g; - " "$WBATCH_TEMPLATE_DIR/template-begin_node_bat" | wbatch_write_stdin -} - -#------------------------------------------------------------------------------- -# VBoxManage call handling -#------------------------------------------------------------------------------- - -function wbatch_get_hostif_subst { - local hostif=$1 - case "$hostif" in - ${MGMT_NET_IF:-""}) - echo 'VirtualBox Host-Only Ethernet Adapter' - ;; - ${DATA_NET_IF:-""}) - echo 'VirtualBox Host-Only Ethernet Adapter #2' - ;; - ${API_NET_IF:-""}) - echo 'VirtualBox Host-Only Ethernet Adapter #3' - ;; - *) - return 1 - ;; - esac -} - -function wbatch_log_vbm { - ARGS=( "$@" ) - for i in "${!ARGS[@]}"; do - case "${ARGS[i]}" in - --hostonlyadapter*) - # The next arg is the host-only interface name -> change it - ARGS[i+1]=\"$(wbatch_get_hostif_subst "${ARGS[i+1]}")\" - ;; - --hostpath) - # The next arg is the shared dir -> change it - ARGS[i+1]='%SHAREDIR%' - continue - ;; - esac - - # On Windows, ISO and base disk images must be in IMGDIR - re='\.(iso|vdi)$' - if [[ "${ARGS[i]}" =~ $re ]]; then - local img_name=$(basename "${ARGS[i]}") - ARGS[i]="%IMGDIR%\\$img_name" - continue - fi - done - - # Echo what we are about to do - wbatch_write_line "ECHO VBoxManage ${ARGS[@]}" - - wbatch_write_line "VBoxManage ${ARGS[@]}" - - # Abort if VBoxManage call raised errorlevel - wbatch_write_line "IF %errorlevel% NEQ 0 GOTO :vbm_error" - - # Blank line for readability - wbatch_write_line "" -} - -#------------------------------------------------------------------------------- -# Windows path name helpers -#------------------------------------------------------------------------------- - -# On Windows, all paths are relative to TOP_DIR -function wbatch_path_to_windows { - local full_path=$1 - # strip off ${TOP_DIR}/ - full_path="${full_path/$TOP_DIR\//}" - full_path=$(wbatch_slash_to_backslash "$full_path") - echo "$full_path" -} - -# Escape backslashes in (path) variables that are given to sed -function wbatch_escape_backslash { - local string=$1 - string="${string//\\/\\\\}" - echo "$string" -} - -function wbatch_slash_to_backslash { - local some_path=$1 - some_path="${some_path//\//\\}" - echo "$some_path" -} - -# vim: set ai ts=4 sw=4 et ft=sh: diff --git a/labs/lib/wbatch/template-begin_base_bat b/labs/lib/wbatch/template-begin_base_bat deleted file mode 100644 index 33d558c9..00000000 --- a/labs/lib/wbatch/template-begin_base_bat +++ /dev/null @@ -1,37 +0,0 @@ -ECHO %time% Cleaning up autostart and log directories -DEL /S /Q %AUTODIR% -DEL /S /Q %LOGDIR% - -ECHO %time% Looking for %IMGDIR%\%INSTALLFILE% -IF EXIST %IMGDIR%\%INSTALLFILE% goto got_install_iso - -ECHO. -ECHO %INSTALLFILE% not found in %IMGDIR%. -ECHO. -ECHO Trying to download the install ISO from -ECHO %ISOURL% -ECHO. -ECHO Expect this to take several minutes or longer, depending on your -ECHO Internet connection. -ECHO. -cscript /nologo %TOOLSDIR%\downloader.js %ISOURL% -RENAME downloaded.bin %INSTALLFILE% -MOVE %INSTALLFILE% %IMGDIR% -IF EXIST %IMGDIR%\%INSTALLFILE% goto got_install_iso -ECHO. -ECHO %INSTALLFILE% still not found in %IMGDIR%. -ECHO Aborting. -ECHO. - -goto :terminate - -:got_install_iso -ECHO. -ECHO %time% Found %IMGDIR%\%INSTALLFILE% -ECHO. -ECHO %time% Initialization done. Hit any key to continue. -ECHO. -PAUSE - -REM vim: set ai ts=4 sw=4 et ft=dosbatch: - diff --git a/labs/lib/wbatch/template-begin_node_bat b/labs/lib/wbatch/template-begin_node_bat deleted file mode 100644 index 530b71c7..00000000 --- a/labs/lib/wbatch/template-begin_node_bat +++ /dev/null @@ -1,23 +0,0 @@ -ECHO %time% Cleaning up autostart and log directories -DEL /S /Q %AUTODIR% -DEL /S /Q %LOGDIR% - -ECHO %time% Looking for %IMGDIR%\%BASEDISK% -IF EXIST %IMGDIR%\%BASEDISK% goto got_base_disk -ECHO. -ECHO %BASEDISK% not found in %IMGDIR%. -ECHO. -ECHO You need to build a base disk before you can create node VMs. -ECHO. -goto :terminate - -:got_base_disk -ECHO. -ECHO %time% Found %IMGDIR%\%BASEDISK% -ECHO. -ECHO %time% Initialization done. Hit any key to continue. -ECHO. -PAUSE - -REM vim: set ai ts=4 sw=4 et ft=dosbatch: - diff --git a/labs/lib/wbatch/template-create_hostnet_bat b/labs/lib/wbatch/template-create_hostnet_bat deleted file mode 100644 index 867ba0b0..00000000 --- a/labs/lib/wbatch/template-create_hostnet_bat +++ /dev/null @@ -1,31 +0,0 @@ -ECHO. -ECHO %time% Initialization done. Hit any key to continue. -ECHO. -PAUSE - -ECHO VBoxManage hostonlyif create -VBoxManage hostonlyif create -IF %errorlevel% NEQ 0 GOTO :vbm_error - -ECHO VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter" --ip %MGMTNET% --netmask 255.255.255.0 -VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter" --ip %MGMTNET% --netmask 255.255.255.0 -IF %errorlevel% NEQ 0 GOTO :vbm_error - -ECHO VBoxManage hostonlyif create -VBoxManage hostonlyif create -IF %errorlevel% NEQ 0 GOTO :vbm_error - -ECHO VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter #2" --ip %DATANET% --netmask 255.255.255.0 -VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter #2" --ip %DATANET% --netmask 255.255.255.0 -IF %errorlevel% NEQ 0 GOTO :vbm_error - -ECHO VBoxManage hostonlyif create -VBoxManage hostonlyif create -IF %errorlevel% NEQ 0 GOTO :vbm_error - -ECHO VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter #3" --ip %APINET% --netmask 255.255.255.0 -VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter #3" --ip %APINET% --netmask 255.255.255.0 -IF %errorlevel% NEQ 0 GOTO :vbm_error - -REM vim: set ai ts=4 sw=4 et ft=dosbatch: - diff --git a/labs/lib/wbatch/template-elevate_privs_bat b/labs/lib/wbatch/template-elevate_privs_bat deleted file mode 100644 index e6df3632..00000000 --- a/labs/lib/wbatch/template-elevate_privs_bat +++ /dev/null @@ -1,26 +0,0 @@ -REM Elevate credentials, code courtesy of Matthew Newton -REM http://blog.mnewton.com/articles/Windows-Installer-Batch-Script-Revisited.html -REM Check for permissions ->nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" - -REM If error flag set, we do not have admin. -if '%errorlevel%' NEQ '0' ( - echo Requesting administrative privileges... - goto UACPrompt -) else ( goto gotAdmin ) - - -:UACPrompt - echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" - echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" - - "%temp%\getadmin.vbs" - REM we are done, exiting recursive call - exit /B - -:gotAdmin - if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) - echo We have admin privileges, proceeding... - -REM vim: set ai ts=4 sw=4 et ft=dosbatch: - diff --git a/labs/lib/wbatch/template-end_file_bat b/labs/lib/wbatch/template-end_file_bat deleted file mode 100644 index ee732fe9..00000000 --- a/labs/lib/wbatch/template-end_file_bat +++ /dev/null @@ -1,59 +0,0 @@ -ECHO. -ECHO %time% Batch script seems to have succeeded. -ECHO. - -GOTO :terminate - -REM Note: vbm_error falls through to terminate -:vbm_error -ECHO. -ECHO %time% VBoxManage returned with an error. Aborting. -ECHO. - -:terminate -ENDLOCAL -PAUSE -EXIT -GOTO :eof - -REM ============================================================================ -REM -REM End of program, function definitions follow -REM -REM ============================================================================ -:wait_auto -IF EXIST %STATUSDIR%\done ( - DEL %STATUSDIR%\done - GOTO :eof -) -IF EXIST %STATUSDIR%\error ( - ECHO. - ECHO %time% ERROR Script returned error: - ECHO. - TYPE %STATUSDIR%\error - ECHO. - ECHO %time% Aborting. - ECHO. - DEL %STATUSDIR%\error - GOTO :terminate -) -TIMEOUT /T 5 /NOBREAK -GOTO :wait_auto -REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -:wait_poweroff -VBoxManage showvminfo %~1 --machinereadable|findstr poweroff -IF %errorlevel% EQU 0 GOTO :eof -TIMEOUT /T 2 /NOBREAK -GOTO :wait_poweroff -REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -:vm_exists -VBoxManage list vms|findstr %~1 -IF %errorlevel% NEQ 0 GOTO :eof -ECHO. -ECHO %time% VM %~1 already exists. Aborting. -ECHO. -GOTO :terminate -REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -REM vim: set ai ts=4 sw=4 et ft=dosbatch: - diff --git a/labs/lib/wbatch/template-file_header_bat b/labs/lib/wbatch/template-file_header_bat deleted file mode 100644 index 81e8f0c8..00000000 --- a/labs/lib/wbatch/template-file_header_bat +++ /dev/null @@ -1,16 +0,0 @@ -@ECHO OFF - -REM This is an automatically generated Windows batch file. It creates the -REM %PRODUCT% for an OpenStack training-labs setup. - -SETLOCAL ENABLEDELAYEDEXPANSION - -ECHO. -ECHO OpenStack labs for VirtualBox on Windows -ECHO Generated by osbash -ECHO. -ECHO Create %PRODUCT% -ECHO. - -REM vim: set ai ts=4 sw=4 et ft=dosbatch: - diff --git a/labs/lib/wbatch/template-find_vbm_bat b/labs/lib/wbatch/template-find_vbm_bat deleted file mode 100644 index 8a66ea53..00000000 --- a/labs/lib/wbatch/template-find_vbm_bat +++ /dev/null @@ -1,30 +0,0 @@ -REM VBoxManage is not in PATH, but this is a good guess -IF EXIST %ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe ( - SET PATH=%PATH%;%ProgramFiles%\Oracle\VirtualBox - ECHO. - ECHO %time% Found %ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe - ECHO. - GOTO :vbm_found -) - -ECHO. -ECHO %time% Searching %SystemDrive% for VBoxManage, this may take a while -ECHO. -FOR /r %SystemDrive% %%a IN (*) DO ( - IF "%%~nxa"=="VBoxManage.exe" ( - SET PATH=%PATH%;%%~dpa - ECHO %time% Found %%~dpnxa - GOTO :vbm_found - ) -) - -ECHO. -ECHO %time% Cannot find VBoxManage.exe (part of VirtualBox) on %SystemDrive%. -ECHO %time% Program stops. -ECHO. -GOTO :terminate - -:vbm_found - -REM vim: set ai ts=4 sw=4 et ft=dosbatch: - diff --git a/labs/lib/wbatch/template-mkdirs_bat b/labs/lib/wbatch/template-mkdirs_bat deleted file mode 100644 index 192240d4..00000000 --- a/labs/lib/wbatch/template-mkdirs_bat +++ /dev/null @@ -1,20 +0,0 @@ -SET BATDIR=%~dp0 -PUSHD %BATDIR%.. -SET TOPDIR=%cd% -POPD - -SET AUTODIR=%TOPDIR%\%P_AUTODIR% -SET IMGDIR=%TOPDIR%\%P_IMGDIR% -SET LOGDIR=%TOPDIR%\%P_LOGDIR% -SET STATUSDIR=%TOPDIR%\%P_STATUSDIR% -SET SHAREDIR=%TOPDIR% -SET TOOLSDIR=%TOPDIR%\tools - -ECHO %time% Creating directories (if needed) -IF NOT EXIST %AUTODIR% mkdir %AUTODIR% -IF NOT EXIST %IMGDIR% mkdir %IMGDIR% -IF NOT EXIST %LOGDIR% mkdir %LOGDIR% -IF NOT EXIST %SHAREDIR% mkdir %SHAREDIR% - -REM vim: set ai ts=4 sw=4 et ft=dosbatch: - diff --git a/labs/log/README.rst b/labs/log/README.rst deleted file mode 100644 index 911d6277..00000000 --- a/labs/log/README.rst +++ /dev/null @@ -1,5 +0,0 @@ -The log files in this directory are written (and removed) by osbash/wbatch and -the scripts running within the VMs. - -The status subdirectory is used by the VM scripts to inform osbash/wbatch -about their progress. diff --git a/labs/osbash.sh b/labs/osbash.sh deleted file mode 100755 index 3e82e5ed..00000000 --- a/labs/osbash.sh +++ /dev/null @@ -1,245 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset - -# Kill entire process group -trap 'kill -- -$$' SIGINT - -TOP_DIR=$(cd "$(dirname "$0")" && pwd) - -: ${DISTRO:=ubuntu-14.04-server-amd64} - -source "$TOP_DIR/config/localrc" -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/openstack" -source "$CONFIG_DIR/deploy.osbash" -source "$CONFIG_DIR/provider.virtualbox" -source "$OSBASH_LIB_DIR/lib.$DISTRO" -source "$OSBASH_LIB_DIR/functions-host.sh" -source "$OSBASH_LIB_DIR/virtualbox-functions.sh" -source "$OSBASH_LIB_DIR/virtualbox-install_base.sh" -source "$LIB_DIR/osbash/lib-color.sh" - -function usage { - echo "Usage: $0 {-b|-w} [-g GUI] [--no-color] [-n] [-t SNAP] {TARGET}" - # Don't advertise export until it is working properly - # echo " $0 [-e EXPORT] [-n] NODE [NODE..]" - echo - echo "-h|--help Help" - echo "-n Print configuration status and exit" - echo "-b Build basedisk (if necessary) and node VMs (if any)" - - # Don't use -t directly, have tools/repeat-test.sh call it - #echo "-t SNAP Jump to snapshot SNAP and continue build" - - echo "-w Create Windows batch files" - echo "-g GUI GUI type during build" - #echo "-e EXPORT Export node VMs" - echo "--no-color Disables colors during build" - echo - echo "TARGET basedisk: build configured basedisk" - echo " cluster : build OpenStack cluster [all nodes]" - echo " (and basedisk if necessary)" - echo "GUI gui, sdl, or headless (GUI type for VirtualBox)" - - # Don't use -t SNAP directly, have tools/repeat-test.sh call it - #echo "SNAP Name of snapshot from which build continues" - - #echo "EXPORT ova (OVA package file) or dir (VM clone directory)" - exit -} - -function print_config { - if [ "$CMD" = "basedisk" ]; then - echo -e "${CInfo:-}Target is base disk:${CData:-} $BASE_DISK${CReset:-}" - else - echo -e "${CInfo:-}Base disk:${CData:-} $BASE_DISK${CReset:-}" - echo -e "${CInfo:-}Distribution name: ${CData:-} $(get_distro_name "$DISTRO")${CReset:-}" - fi - - if [ -n "${EXPORT_OVA:-}" ]; then - echo "Exporting to OVA: ${EXPORT_OVA}" - elif [ -n "${EXPORT_VM_DIR:-}" ]; then - echo "Exporting to directory: ${EXPORT_VM_DIR}" - else - echo -e -n "${CInfo:-}Creating Windows batch scripts:${CReset:-} " - ${WBATCH:-:} echo -e "${CData:-}yes${CReset:-}" - ${WBATCH:+:} echo -e "${CData:-}no${CReset:-}" - - echo -e -n "${CInfo:-}Creating $CMD on this machine:${CReset:-} " - ${OSBASH:-:} echo -e "${CData:-}yes${CReset:-}" - ${OSBASH:+:} echo -e "${CData:-}no${CReset:-}" - - echo -e "${CInfo:-}VM access method:${CData:-} $VM_ACCESS${CReset:-}" - - # GUI is the VirtualBox default - echo -e "${CInfo:-}GUI type:${CData:-} ${VM_UI:-gui}${CReset:-}" - - if [ -n "${JUMP_SNAPSHOT:-}" ]; then - echo -e "${CInfo:-}Continuing from snapshot:" \ - "${CData:-}${JUMP_SNAPSHOT}${CReset:-}" - fi - fi - -} - -while getopts :be:g:-:hnt:w opt; do - case $opt in - e) - if [ "$OPTARG" = ova ]; then - EXPORT_OVA=$IMG_DIR/oslabs-$DISTRO.ova - elif [ "$OPTARG" = dir ]; then - EXPORT_VM_DIR=$IMG_DIR/oslabs-$DISTRO - else - echo -e "${CError:-}Error: -e argument must be ova or dir${CReset:-}" - exit - fi - OSBASH=exec_cmd - ;; - b) - OSBASH=exec_cmd - ;; - g) - if [[ "$OPTARG" =~ (headless|gui|sdl) ]]; then - VM_UI=$OPTARG - else - echo -e "${CError:-}Error: -g argument must be gui, sdl, or headless${CReset:-}" - exit - fi - ;; - -) - case $OPTARG in - no-color) - unset CError CStatus CInfo CProcess CData CMissing CReset - ;; - help) - usage - ;; - *) - echo -e "${CError:-}Error: invalid option -$OPTARG${CReset:-}" - echo - usage - ;; - esac - ;; - h) - usage - ;; - n) - INFO_ONLY=1 - ;; - t) - JUMP_SNAPSHOT=$OPTARG - ;; - w) - source "$LIB_DIR/wbatch/batch_for_windows" - ;; - :) - echo -e "${CError:-}Error: -$OPTARG needs argument${CReset:-}" - ;; - ?) - echo -e "${CError:-}Error: invalid option -$OPTARG${CReset:-}" - echo - usage - ;; - esac -done - -# Remove processed options from arguments -shift $(( OPTIND - 1 )); - -if [ $# -eq 0 ]; then - # No argument given - usage -else - CMD=$1 -fi - -# Install over ssh by default -: ${VM_ACCESS:=ssh} - -# Get base disk path if none is configured -: ${BASE_DISK:=$(get_base_disk_path)} - -print_config - -if [ "${INFO_ONLY:-0}" -eq 1 ]; then - exit -fi - -# Clean wbatch directory -${WBATCH:-:} wbatch_reset - -if [ -n "${EXPORT_OVA:-}" ]; then - vm_export_ova "$EXPORT_OVA" "$nodes" - exit -fi - -if [ -n "${EXPORT_VM_DIR:-}" ]; then - vm_export_dir "$EXPORT_VM_DIR" "$nodes" - exit -fi - -if [ -z "${OSBASH:-}" -a -z "${WBATCH:-}" ]; then - echo - echo -e "${CMissing:-}No -b, -w, or -e option given. Exiting.${CReset:-}" - exit -fi - -STARTTIME=$(date +%s) -echo -e >&2 "${CStatus:-} $(date) osbash starting ${CReset:-}" - -clean_dir "$LOG_DIR" - -function cleanup_base_disk { - if [ "$CMD" = basedisk -a -f "$BASE_DISK" ]; then - - echo >&2 "Found existing base disk: $BASE_DISK" - - if ! yes_or_no "Keep this base disk?"; then - if disk_registered "$BASE_DISK"; then - # Remove users of base disk - echo >&2 "Unregistering and removing all disks attached to" \ - "base disk path." - disk_delete_child_vms "$BASE_DISK" - echo >&2 "Unregistering old base disk." - disk_unregister "$BASE_DISK" - fi - echo -e >&2 "${CStatus:-}Removing old base disk.${CReset:-}" - rm -f "$BASE_DISK" - else - echo -e >&2 "${CMissing:-}Nothing to do. Exiting.${CReset:-}" - exit - fi - fi -} - -${OSBASH:-:} cleanup_base_disk - -#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -if [ ! -f "$BASE_DISK" ]; then - vm_install_base "$BASE_DISK" -else - # Leave base disk alone, but call the function if wbatch is active - OSBASH= ${WBATCH:-:} vm_install_base "$BASE_DISK" -fi -#------------------------------------------------------------------------------- -if [ "$CMD" = basedisk ]; then - exit -fi - -echo "Using base disk $BASE_DISK" - -${WBATCH:-:} wbatch_create_hostnet -MGMT_NET_IF=$(create_network "$MGMT_NET") -DATA_NET_IF=$(create_network "$DATA_NET") -API_NET_IF=$(create_network "$API_NET") -#------------------------------------------------------------------------------- -source "$OSBASH_LIB_DIR/virtualbox-install_nodes.sh" -vm_build_nodes "$CMD" -#------------------------------------------------------------------------------- -ENDTIME=$(date +%s) -echo -e >&2 "${CStatus:-}$(date) osbash finished successfully${CReset:-}" -echo -e >&2 "${CStatus:-}osbash completed in $(($ENDTIME - $STARTTIME))" \ - "seconds.${CReset:-}" diff --git a/labs/scripts/README.rst b/labs/scripts/README.rst deleted file mode 100644 index 3b1f0775..00000000 --- a/labs/scripts/README.rst +++ /dev/null @@ -1,7 +0,0 @@ -All scripts in this directory run within the VMs. - -They install and configure OpenStack components and any other required -software (such as databases). - -Before these generic scripts run, scripts from the osbash subdirectory -set up the VM and configure basic networking. diff --git a/labs/scripts/config_external_network.sh b/labs/scripts/config_external_network.sh deleted file mode 100755 index cf416408..00000000 --- a/labs/scripts/config_external_network.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Create the external network and a subnet on it -# http://docs.openstack.org/juno/install-guide/install/apt/content/neutron_initial-external-network.html -#------------------------------------------------------------------------------ - -echo "Sourcing the admin credentials." -source "$CONFIG_DIR/admin-openstackrc.sh" - -echo "Waiting for neutron to start." -until neutron net-list >/dev/null 2>&1; do - sleep 1 -done - -echo "Creating the external network." -neutron net-create ext-net \ - --router:external True \ - --provider:physical_network external \ - --provider:network_type flat - -echo "Creating a subnet on the external network." -neutron subnet-create ext-net \ - --name ext-subnet \ - --allocation-pool start="$FLOATING_IP_START,end=$FLOATING_IP_END" \ - --disable-dhcp \ - --gateway "$EXTERNAL_NETWORK_GATEWAY" \ - "$EXTERNAL_NETWORK_CIDR" diff --git a/labs/scripts/config_tenant_network.sh b/labs/scripts/config_tenant_network.sh deleted file mode 100755 index 71266f8f..00000000 --- a/labs/scripts/config_tenant_network.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Create tenant network -# http://docs.openstack.org/juno/install-guide/install/apt/content/neutron_initial-tenant-network.html -#------------------------------------------------------------------------------ - -echo "Sourcing the demo credentials." -source "$CONFIG_DIR/demo-openstackrc.sh" - -echo "Waiting for neutron to start." -until neutron net-list >/dev/null 2>&1; do - sleep 1 -done - -echo "Creating the tenant network." -neutron net-create demo-net - -echo "Creating a subnet on the tenant network." -neutron subnet-create demo-net \ - --name demo-subnet \ - --gateway "$TENANT_NETWORK_GATEWAY" \ - "$TENANT_NETWORK_CIDR" - -echo "Creating a router on the tenant network." -neutron router-create demo-router - -echo "Attaching the router to the demo tenant subnet." -neutron router-interface-add demo-router demo-subnet - -echo "Attaching the router to the external network by setting it as the" \ - "gateway." -neutron router-gateway-set demo-router ext-net diff --git a/labs/scripts/etc_hosts.sh b/labs/scripts/etc_hosts.sh deleted file mode 100755 index 252864bf..00000000 --- a/labs/scripts/etc_hosts.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -HOST_NAME=$(hostname) -HOST_FILE=/etc/hosts - -if ! grep -q "^[^#].*$HOST_NAME" $HOST_FILE; then - # No active entry for our hostname - HOST_IP=127.0.1.1 - if grep -q "^$HOST_IP" $HOST_FILE; then - # Fix the entry for the IP address we want to use - sudo sed -i "s/^$HOST_IP.*/$HOST_IP $HOST_NAME/" $HOST_FILE - else - echo "$HOST_IP $HOST_NAME" | sudo tee -a $HOST_FILE - fi -fi - -# Add entries for the rest of the OpenStack training-labs -cat "$CONFIG_DIR/hosts.multi" | sudo tee -a /etc/hosts diff --git a/labs/scripts/osbash/activate_autostart.sh b/labs/scripts/osbash/activate_autostart.sh deleted file mode 100755 index a5df70d5..00000000 --- a/labs/scripts/osbash/activate_autostart.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -# This script is the first to run and the only one to run as root. - -# XXX The name activate_autostart.sh is hard-coded in ks.cfg and preseed.cfg. - -# Remove files that called us (written by {ks,preseed}.cfg) -rm -f /etc/init.d/osbash /etc/rc2.d/S40osbash - -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -# source_deploy doesn't work here -source "$CONFIG_DIR/deploy.osbash" -source "$LIB_DIR/functions.guest" - -readonly RCAUTOSTART=osbashauto - -indicate_current_auto - -# This guest script doesn't write to $HOME; the log file's extension is .auto -exec_logfile "$LOG_DIR" "auto" - -# Some guest additions leave a broken symlink /sbin/mount.vboxsf -as_root_fix_mount_vboxsf_link - -if ! id -u "$VM_SHELL_USER" >/dev/null 2>&1; then - # User doesn't exist -> add - useradd osbash -G vboxsf - echo "$VM_SHELL_USER:$VM_SHELL_USER" | chpasswd -elif ! id -Gn "$VM_SHELL_USER" >/dev/null 2>&1 | grep -q vboxsf; then - # User isn't in group vboxsf -> add - usermod -a -G vboxsf "$VM_SHELL_USER" -fi - -as_root_inject_sudoer - -if [ ! -f "$OSBASH_SCRIPTS_DIR/template-$RCAUTOSTART" ]; then - echo "Template not found: $OSBASH_SCRIPTS_DIR/template-$RCAUTOSTART" - exit 1 -fi - -# LOG_DIR and SHARE_DIR are based on the temporary mount point /media/sf_* -# which won't be there after reboot; use new paths for osbashauto - -NLOG_DIR="/$SHARE_NAME/$(basename "$LOG_DIR")" - -sed -e " - s,%SHARE_NAME%,$SHARE_NAME,g; - s,%VM_SHELL_USER%,$VM_SHELL_USER,g; - s,%NLOG_DIR%,$NLOG_DIR,g; - s,%RCAUTOSTART%,$RCAUTOSTART,g; - " "$OSBASH_SCRIPTS_DIR/template-$RCAUTOSTART" > "/etc/init.d/$RCAUTOSTART" - -chmod 755 "/etc/init.d/$RCAUTOSTART" - -# Make devstack's is_fedora work with nounset -init_os_ident - -if is_fedora; then - cat << SERVICE > /etc/systemd/system/$RCAUTOSTART.service -[Unit] -Description=OpenStack autostart -Requires=vboxadd-service.service -After=vboxadd-service.service vboxadd.service - -[Service] -ExecStart=/etc/init.d/$RCAUTOSTART - -[Install] -WantedBy=multi-user.target -SERVICE - - systemctl enable "$RCAUTOSTART.service" - systemctl start "$RCAUTOSTART.service" -else - ln -s "../init.d/$RCAUTOSTART" "/etc/rc2.d/S99$RCAUTOSTART" -fi diff --git a/labs/scripts/osbash/base_fixups.sh b/labs/scripts/osbash/base_fixups.sh deleted file mode 100755 index 9071a4a1..00000000 --- a/labs/scripts/osbash/base_fixups.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -# This script is run by vm_install_base. It should work on all supported -# distributions. - -# match Vagrant which removes 70-persistent-net.rules (so we get the same -# names for our network interfaces) -sudo rm -f /etc/udev/rules.d/70-persistent-net.rules diff --git a/labs/scripts/osbash/enable_osbash_ssh_keys.sh b/labs/scripts/osbash/enable_osbash_ssh_keys.sh deleted file mode 100755 index 13fae089..00000000 --- a/labs/scripts/osbash/enable_osbash_ssh_keys.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset - -# This script installs the insecure osbash ssh keys. This allows users to -# log into the VMs using these keys instead of a password. - -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -mkdir -p "$HOME/.ssh" -chmod 700 "$HOME/.ssh" - -# Install the requested osbash insecure key to $HOME/.ssh. -function get_osbash_key { - local key_name=$1 - local osbash_key_dir=$LIB_DIR/osbash-ssh-keys - - if [ -f "$HOME/.ssh/$key_name" ]; then - echo "osbash insecure key already installed: $HOME/.ssh/$key_name." - else - echo "Installing osbash insecure key $key_name." - cp -v "$osbash_key_dir/$key_name" "$HOME/.ssh" - fi -} - -# Authorize named key for ssh logins into this VM. -function authorize_osbash_key { - local pub_key_path=$1 - local auth_key_path=$HOME/.ssh/authorized_keys - if grep -qs "osbash insecure public key" "$auth_key_path"; then - echo "Already authorized." - else - cat "$pub_key_path" >> "$auth_key_path" - fi -} - -echo "Installing osbash insecure private key (connections to other VMs)." -get_osbash_key "osbash_key" -chmod 400 "$HOME/.ssh/osbash_key" - -get_osbash_key "osbash_key.pub" -chmod 444 "$HOME/.ssh/osbash_key.pub" - -echo "Authorizing osbash public key (connections from host and other VMs)." -authorize_osbash_key "$HOME/.ssh/osbash_key.pub" diff --git a/labs/scripts/osbash/init_xxx_node.sh b/labs/scripts/osbash/init_xxx_node.sh deleted file mode 100755 index 6907a116..00000000 --- a/labs/scripts/osbash/init_xxx_node.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset - -# This scripts configures hostname and networking for all nodes. The filename -# determines the node name. - -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" - -# Determine hostname from script name -re=".*init_(.*)_node.sh$" -if [[ $0 =~ $re ]]; then - NODE_NAME=${BASH_REMATCH[1]} - NODE_NAME="${NODE_NAME}" -else - echo "ERROR Unable to determine hostname" - exit 1 -fi - -indicate_current_auto - -exec_logfile - -# Set hostname for now and for rebooted system -sudo hostname "$NODE_NAME" >/dev/null -echo "$NODE_NAME" | sudo tee /etc/hostname > /dev/null - -# Configure network interfaces -config_network diff --git a/labs/scripts/osbash/shutdown.sh b/labs/scripts/osbash/shutdown.sh deleted file mode 120000 index 02d2a8fd..00000000 --- a/labs/scripts/osbash/shutdown.sh +++ /dev/null @@ -1 +0,0 @@ -../shutdown.sh \ No newline at end of file diff --git a/labs/scripts/osbash/template-osbashauto b/labs/scripts/osbash/template-osbashauto deleted file mode 100644 index 10e8e8ac..00000000 --- a/labs/scripts/osbash/template-osbashauto +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -# By default, this file is /etc/init.d/osbashauto on the guest system. -# On boot-up, it executes in order all files that have been put into -# the autostart folder. - -# The name of this file is hard-coded in activate_autostart.sh. - -SHARE_NAME=%SHARE_NAME% - -# Make sure we have a mount point for the shared directory -mkdir -p /$SHARE_NAME - -if ! mountpoint -q /$SHARE_NAME; then - mount -t vboxsf -ouid=%VM_SHELL_USER%,gid=%VM_SHELL_USER% $SHARE_NAME /$SHARE_NAME -fi - -# LOG_DIR is set in activate_autostart.sh as NLOG_DIR -LOG_DIR=%NLOG_DIR% - -STATUS_DIR=%NLOG_DIR%/status - -mkdir -p $STATUS_DIR - -TOP_DIR=/$SHARE_NAME - -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" - -exec_logpath "$LOG_DIR/%RCAUTOSTART%.log" - -echo "$(date) starting" - -shopt -s nullglob -for AUTODIR in "/$SHARE_NAME/autostart" "/$SHARE_NAME/autostart/$HOSTNAME"; do - if [ -d "$AUTODIR" ]; then - echo "$(date) autodir $AUTODIR" - for SCRIPT in $AUTODIR/*.sh; do - if ! as_root_exec_script "$SCRIPT"; then - echo >&2 "Script returned with error, giving up." - # Tell host about the error - echo "ERROR in $SCRIPT" >> "$STATUS_DIR/error" - exit 1 - fi - # Remove script after execution - rm "$SCRIPT" - done - fi -done - -echo "$(date) autostart done" - -# This file is seen and removed by scripts running on the host -touch "$STATUS_DIR/done" - -exit 0 - -# vim: set ai ts=4 sw=4 et: diff --git a/labs/scripts/osbash/wait_debug.sh b/labs/scripts/osbash/wait_debug.sh deleted file mode 100755 index a58152b1..00000000 --- a/labs/scripts/osbash/wait_debug.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -# Wait for removal of /tmp/remove_to_continue -wait_for_file diff --git a/labs/scripts/shutdown.sh b/labs/scripts/shutdown.sh deleted file mode 100755 index b5782777..00000000 --- a/labs/scripts/shutdown.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -echo "Shutting down" - -# Shutdown some time after returning so our caller has time to finish -sudo -b sh -c 'sleep 2; /sbin/shutdown -P now' diff --git a/labs/scripts/shutdown_controller.sh b/labs/scripts/shutdown_controller.sh deleted file mode 100755 index 6aa8a083..00000000 --- a/labs/scripts/shutdown_controller.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -# At this point in the cluster build, we just rebooted the compute VM to take -# a snapshot, and we are about to reboot the controller node for the same -# purpose. -# -# About a minute after we reboot the controller, the status of nova-compute -# (according to nova-manage service list) becomes "XXX". -# -# If we sleep for 2 seconds now, before rebooting the controller, the -# nova-compute service on the compute node will keep running and the status -# will automatically return to ":-)" after some time (may take several -# minutes). If we don't sleep here, the nova-compute service on compute will -# die within a few minutes (needs manual service restart or a compute node -# reboot). -sleep 2 - -echo "Shutting down the controller node." -ssh \ - -o "UserKnownHostsFile /dev/null" \ - -o "StrictHostKeyChecking no" \ - -i "$HOME/.ssh/osbash_key" \ - controller-mgmt \ - sudo /sbin/shutdown -P now diff --git a/labs/scripts/test/README.rst b/labs/scripts/test/README.rst deleted file mode 100644 index 1d35896a..00000000 --- a/labs/scripts/test/README.rst +++ /dev/null @@ -1 +0,0 @@ -The scripts in this directory can be used to test the training-cluster. diff --git a/labs/scripts/test/launch_instance.sh b/labs/scripts/test/launch_instance.sh deleted file mode 100755 index 7855c7c4..00000000 --- a/labs/scripts/test/launch_instance.sh +++ /dev/null @@ -1,793 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/demo-openstackrc.sh" - -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Launch a demo instance. -#------------------------------------------------------------------------------ - -# Packets from the instance VM destined for the Internet will have its -# floating IP address as the sender address. For your instance VM to -# get Internet access, you will probably have to configure masquerading -# on your host computer. - -# On Linux, turning on masquerading may look something like this: - -# echo "1" > /proc/sys/net/ipv4/ip_forward -# modprobe ip_tables -# modprobe ip_conntrack -# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE -# iptables -A FORWARD -i eth0 -o vboxnet2 -m state \ -# --state RELATED,ESTABLISHED -j ACCEPT -# iptables -A FORWARD -i vboxnet2 -o eth0 -j ACCEPT - -# Set this true if you have masquerading enabled to allow instance VMs access -# to the Internet. -: ${MASQUERADING:=true} - -# Set this true if you want the instance to use the Google Public DNS name -# server. The default uses dnsmasq running on a node. -: ${EXT_DNS:=true} - -DEMO_INSTANCE_NAME=demo-instance1 - -echo "SUM --- BEGIN" - -function ssh_no_chk_node { - ssh_no_chk -i "$HOME/.ssh/osbash_key" "$@" -} - -function ssh_no_chk { - echo "ssh $@" - # Options set to disable strict host key checking and related messages. - ssh \ - -o "UserKnownHostsFile /dev/null" \ - -o "StrictHostKeyChecking no" \ - -o LogLevel=error \ - "$@" -} - -# Work around neutron client failing with unsupported locale settings -if [[ "$(neutron --help)" == "unsupported locale setting" ]]; then - echo "Locale not supported on node, setting LC_ALL=C." - export LC_ALL=C -fi - -function wait_for_service { - local node=$1 - local service=$2 - local cnt=0 - echo -n "Node $node, service $service:" - until ssh_no_chk_node "$node" service "$service" status | \ - grep -q "start/running"; do - cnt=$((cnt + 1)) - if [ $((cnt % 150)) -eq 0 ]; then - echo " does not seem to come up. Forcing restart." - - echo - echo "SUM ERROR $service on node $node not coming up." - ssh_no_chk_node "$node" \ - sudo service "$service" restart - SERVICE_RESTARTS="${SERVICE_RESTARTS:-""}$service@$node " - fi - sleep 2 - echo -n . - done - echo " up" -} - -echo "Running on host: $(hostname)" - -echo "Checking network connection to network node." -ping -c1 network-mgmt -echo - -echo "Checking network connection to compute node." -ping -c1 compute-mgmt -echo - -echo "Checking services on network node." -wait_for_service network-mgmt openvswitch-switch -wait_for_service network-mgmt neutron-plugin-openvswitch-agent -wait_for_service network-mgmt neutron-l3-agent -wait_for_service network-mgmt neutron-dhcp-agent -wait_for_service network-mgmt neutron-metadata-agent -echo - -echo "Checking services on compute node." -wait_for_service compute-mgmt nova-compute -wait_for_service compute-mgmt openvswitch-switch -wait_for_service compute-mgmt neutron-plugin-openvswitch-agent -echo - -function wait_for_nova_compute { - if sudo nova-manage service list --service nova-compute | \ - grep -q ":-)"; then - return 0 - fi - echo " Waiting for nova-compute to switch from XXX to :-)." - if ssh_no_chk_node compute-mgmt service nova-compute status | \ - grep -q "start/running"; then - echo -n " Service is up, waiting (may take a few minutes)." - fi - local cnt=0 - local start=$(date +%s) - while sudo nova-manage service list --service nova-compute | grep -q XXX; do - cnt=$((cnt + 1)) - sleep 5 - if ssh_no_chk_node compute-mgmt service nova-compute status | \ - grep -q "start/running"; then - if [ $cnt -eq 300 ]; then - # This should never happen. - echo "SUM ABORT nova-compute remains XXX while up." - echo "Aborting." - exit 1 - fi - echo -n . - else - echo - echo "SUM ERROR nova-compute on compute node has died." - echo "Restarting nova-compute on compute node." - ssh_no_chk_node compute-mgmt \ - sudo service nova-compute restart - NOVA_COMPUTE_RESTART=$((${NOVA_COMPUTE_RESTART:-0} + 1)) - fi - done - echo -} - -function wait_for_nova_services { - local start=$(date +%s) - - echo "Checking services in sudo nova-manage service list." - echo -n " Waiting for controller services to switch from XXX to :-)." - # Ignore nova-compute for now, even if a custom config has it on controller - while sudo nova-manage service list --host controller | \ - grep -v nova-compute | grep -q XXX; do - sleep 2 - echo -n . - done - echo - - if ! sudo nova-manage service list | grep -q nova-compute; then - echo -n " Waiting for nova-compute to turn up in list." - until sudo nova-manage service list | grep -q nova-compute; do - sleep 2 - echo -n . - done - echo - fi - - wait_for_nova_compute - echo - echo "SUM wait for nova services: $(($(date +%s) - start))" -} - -if [ ${NOVA_COMPUTE_RESTART:-0} -ne 0 ]; then - echo "SUM ERROR nova-compute restarts: $NOVA_COMPUTE_RESTART" -fi - -wait_for_nova_services - -echo "All services are ready:" -sudo nova-manage service list -echo - -function show_compute_resource_usage { - echo "nova list:" - nova list - ( - source "$CONFIG_DIR/admin-openstackrc.sh" - echo "As admin user, nova host-list:" - nova host-list - echo "As admin user, nova host-describe compute:" - nova host-describe compute - ) -} - -function wait_for_neutron_agents { - local agent_list=$LOG_DIR/test-agent.list - local start=$(date +%s) - echo -n "Waiting for agents in neutron agent-list." - ( - source "$CONFIG_DIR/admin-openstackrc.sh" - neutron agent-list | sort > "$agent_list" - local out=$(grep " :-) " "$agent_list") - if [ -n "$out" ]; then - echo - echo "$out" - fi - while [ : ]; do - neutron agent-list | sort > "$agent_list.new" - out=$(comm -13 "$agent_list" "$agent_list.new") - if [ -n "$out" ]; then - echo - echo "$out" - fi - if ! grep -q " xxx " "$agent_list"; then - break - fi - mv "$agent_list.new" "$agent_list" - sleep 1 - echo -n . - done - echo - echo "All agents are ready." - neutron agent-list - echo - ) - echo "SUM wait for neutron agents: $(($(date +%s) - start))" -} - -wait_for_neutron_agents - -function check_namespaces { - local cnt - - echo -n "Getting router namespace." - cnt=0 - until ssh_no_chk_node network-mgmt ip netns | grep qrouter; do - cnt=$((cnt + 1)) - sleep 1 - echo -n "." - done - echo "SUM wait for router namespace: $cnt" - local nsrouter=$(ssh_no_chk_node network-mgmt ip netns | grep qrouter) - - echo -n "Getting DHCP namespace." - cnt=0 - until ssh_no_chk_node network-mgmt ip netns | grep qdhcp; do - cnt=$((cnt + 1)) - if [ $cnt -eq 10 ]; then - echo - echo "SUM ERROR No DCHP namespace, restarting neutron-dhcp-agent." - echo "Restarting neutron-dhcp-agent on network node." - ssh_no_chk_node network-mgmt \ - sudo service neutron-dhcp-agent restart - fi - sleep 1 - echo -n "." - done - echo "SUM wait for DHCP namespace: $cnt" - local nsdhcp=$(ssh_no_chk_node network-mgmt ip netns | grep qdhcp) - - echo -n "Waiting for interface qr-* in router namespace." - cnt=0 - until ssh_no_chk_node network-mgmt \ - sudo ip netns exec "$nsrouter" ip addr | \ - grep -Po "(?<=: )qr-.*(?=:)"; do - cnt=$((cnt + 1)) - sleep 1 - echo -n "." - done - echo "SUM wait for interface qr-*: $cnt" - - echo -n "Waiting for interface qg-* in router namespace." - cnt=0 - until ssh_no_chk_node network-mgmt \ - sudo ip netns exec "$nsrouter" ip addr | \ - grep -Po "(?<=: )qg-.*(?=:)"; do - cnt=$((cnt + 1)) - sleep 1 - echo -n "." - done - echo "SUM wait for interface qg-*: $cnt" - - echo -n "Waiting for interface tap* in DHCP namespace." - cnt=0 - until ssh_no_chk_node network-mgmt \ - sudo ip netns exec "$nsdhcp" ip addr | \ - grep -Po "(?<=: )tap.*(?=:)"; do - cnt=$((cnt + 1)) - sleep 1 - echo -n "." - done - echo "SUM wait for interface tap*: $cnt" -} - -check_namespaces - -if [ ! -f ~/.ssh/id_rsa ]; then - echo "Generating an ssh key pair (saved to ~/.ssh/id_rsa*)." - # For training cluster: no password protection on keys to make scripting - # easier - ssh-keygen -f ~/.ssh/id_rsa -N "" -fi - -function check_demo_key { - echo -n "Checking if 'demo-key' is already in our OpenStack environment: " - if nova keypair-show demo-key >/dev/null 2>&1; then - echo "yes." - - echo -n "Checking if the 'demo-key' key pair matches our ssh key: " - - ssh_key=$(< ~/.ssh/id_rsa.pub awk '{print $2}') - stored_key=$(nova keypair-show demo-key | \ - awk '/^Public key: ssh-rsa/ {print $4}') - - if [ "$ssh_key" != "$stored_key" ]; then - echo "no." - echo "Removing the 'demo-key' from the OpenStack envirnoment." - nova keypair-delete demo-key - else - echo "yes." - fi - else - echo "no." - fi -} -check_demo_key - -if ! nova keypair-show demo-key 2>/dev/null; then - echo "Adding the public key to our OpenStack environment." - nova keypair-add --pub-key ~/.ssh/id_rsa.pub demo-key -fi - -echo "Verifying addition of the public key." -nova keypair-list - -echo "Listing available flavors." -nova flavor-list - -echo "Listing available images." -nova image-list - -echo -n "Waiting for neutron to start." -until neutron net-list >/dev/null 2>&1; do - sleep 1 - echo . -done -echo - -echo "Listing available networks." -neutron net-list - -DEMO_NET_ID=$(neutron net-list | awk '/ demo-net / {print $2}') -echo "ID for demo-net tenant network: $DEMO_NET_ID" - -echo "Listing available security groups." -nova secgroup-list - -if [ "$EXT_DNS" = true ]; then - echo "Setting DNS name server for subnet (passed to booting instance VMs)." - neutron subnet-update demo-subnet --dns_nameservers list=true 8.8.4.4 - echo -else - echo "Clearing DNS name server for subnet (passed to booting instance VMs)." - neutron subnet-update demo-subnet --dns_nameservers action=clear -fi -echo "Settings for demo-subnet:" -neutron subnet-show demo-subnet -echo - -nova list -nova list | awk " / $DEMO_INSTANCE_NAME / {print \$2}" | while read instance; do - echo "Removing instance $DEMO_INSTANCE_NAME ($instance)." - nova delete "$instance" -done -echo -n "Waiting for removed instances to disappear (may take > 1 min)." -while nova list|grep -q "$DEMO_INSTANCE_NAME"; do - sleep 1 - echo -n . -done -echo - -echo "There should be no $DEMO_INSTANCE_NAME instances left:" -nova list - -NOVA_SCHED_LOG=/var/log/upstart/nova-scheduler.log -NOVA_API_LOG=/var/log/upstart/nova-api.log - - -VM_LAUNCHES=0 - -function request_instance { - # Keep a copy of current state of nova-scheduler.log - sudo cp -vf $NOVA_SCHED_LOG $NOVA_API_LOG /tmp - - if [ -n "${instance_info:-""}" ]; then - rm -f "$instance_info" - else - instance_info=$LOG_DIR/test-instance.info - echo "Instance info: $instance_info" - fi - - local img_name=$(basename "$CIRROS_URL" -disk.img) - - echo "Requesting an instance." - nova boot \ - --flavor m1.tiny \ - --image "$img_name" \ - --nic net-id="$DEMO_NET_ID" \ - --security-group default \ - --key-name demo-key \ - "$DEMO_INSTANCE_NAME" > "$instance_info" - VM_LAUNCHES=$(( VM_LAUNCHES + 1 )) -} - -BOOT_LOG=$LOG_DIR/test-instance.boot -echo "Boot log: $BOOT_LOG" - -function save_boot_log { - local rc=0 - rm -f "$BOOT_LOG" - nova console-log "$DEMO_INSTANCE_NAME" >"$BOOT_LOG" 2>&1 || rc=$? - if [ $rc -ne 0 ]; then - echo >&2 "nova console-log returned error status $rc" - fi - return $rc -} - -function explain_instance_failure { - cat << TXT_INSTANCE_FAILURE - - After deleting an instance, it can take nova up to a minute to realize that - the compute node is free. Under tight space constraints, this becomes a - common source of failure. - - As an admin, we could list hosts (including compute hosts): - - $ nova host-list - - And check resource usage in description of host 'compute': - - $ nova host-describe compute - - As a regular user, we would have to keep trying for up to a minute and hope - it works soon. - - The fastest way to update the database, however, is to restart nova-compute - on the compute node. - -TXT_INSTANCE_FAILURE -} - -function status_409_fixed { - echo "Checking log files for cause of failure." - - if sudo comm -13 /tmp/nova-scheduler.log $NOVA_SCHED_LOG | - grep "has not been heard from in a while"; then - echo - echo "SUM ERROR Missing connection with nova-compute on compute node." - echo "(Did controller node boot after compute node?)" - echo - elif sudo comm -13 /tmp/nova-scheduler.log $NOVA_SCHED_LOG | - grep "Filter RamFilter returned 0 hosts"; then - echo "SUM ERROR Filter RamFilter returned 0 hosts" - explain_instance_failure - show_compute_resource_usage - elif sudo comm -13 /tmp/nova-api.log $NOVA_API_LOG | - grep "HTTP exception thrown:"; then - # Just waiting should be enough to fix this - echo -n "Waiting for HTTP status 409 to cure itself." - local cnt=0 - until [ $cnt -eq 5 ]; do - if ! console_status_409; then - HTTP_EXCEPTIONS="${HTTP_EXCEPTIONS:-""}$cnt " - echo "okay" - # We can continue with this instance - return 0 - fi - cnt=$((cnt + 1)) - sleep 2 - echo -n . - done - HTTP_EXCEPTIONS="${HTTP_EXCEPTIONS:-""}${cnt}-fail " - echo "failed" - else - echo "Unknown reason. See for yourself." - echo "nova-scheduler.log:" - sudo comm -13 /tmp/nova-scheduler.log $NOVA_SCHED_LOG - echo "nova-api.log:" - sudo comm -13 /tmp/nova-api.log $NOVA_API_LOG - echo "SUM ABORT Unknown 409 error" - exit 1 - fi - # Not fixed, need to try with new VM - return 1 -} - -function console_status_409 { - ! save_boot_log 2>/dev/null && - grep -q "is not ready (HTTP 409)" "$BOOT_LOG" -} - -function console_status_404 { - ! save_boot_log 2>/dev/null && - grep -q "Unable to get console (HTTP 404)" "$BOOT_LOG" -} - -function instance_status { - nova list | awk "/$DEMO_INSTANCE_NAME/ {print \$6}" -} - -function instance_status_is { - local status=$1 - nova list | grep "$DEMO_INSTANCE_NAME" | grep -q "$status" -} - -while [ : ]; do - echo "Launching an instance VM." - request_instance > /dev/null - - if console_status_409; then - echo "nova console-log returned:" - cat "$BOOT_LOG" - echo - - if ! status_409_fixed; then - - echo "Instance build failed." - echo "Deleting failed instance VM." - nova delete "$DEMO_INSTANCE_NAME" - - echo "Checking nova-compute on the compute node." - wait_for_nova_compute - - echo -n "Requesting new instance VMs until it works." - cnt=0 - while [ : ]; do - request_instance >/dev/null - if console_status_409; then - nova delete "$DEMO_INSTANCE_NAME" - cnt=$((cnt + 1)) - if [ $cnt -eq 5 ]; then - echo - echo "SUM ERROR console status remains 409." - echo "Restarting nova-compute on compute node." - ssh_no_chk_node compute-mgmt \ - sudo service nova-compute restart - NOVA_COMPUTE_RESTART=$((${NOVA_COMPUTE_RESTART:-0} + 1)) - fi - sleep 2 - echo -n . - else - # Either no error or a different error - echo - break - fi - done - fi - fi - - if console_status_404; then - echo "nova console-log returned:" - cat "$BOOT_LOG" - echo - - echo -n "Waiting for console." - # Console status 404 may persist after instance status becomes ERROR. - while console_status_404 && instance_status_is BUILD; do - sleep 1 - echo -n . - done - echo - if ! console_status_404; then - echo "Console status is no longer 404." - fi - - fi - - echo -n "Waiting for instance to get out of BUILD status." - while instance_status_is BUILD; do - sleep 1 - echo -n . - done - echo - - if instance_status_is ERROR; then - echo "Instance VM status: ERROR" - echo "Deleting failed instance VM." - nova delete "$DEMO_INSTANCE_NAME" - elif instance_status_is ACTIVE; then - echo "Instance VM status: ACTIVE." - break - fi -done - -if [ "${HTTP_EXCEPTIONS:-0}" != "0" ]; then - echo "SUM ERROR HTTP exceptions: ${HTTP_EXCEPTIONS:-0}" -fi - -echo -n "Waiting for DHCP discover." -until grep -q "Sending discover..." "$BOOT_LOG"; do - sleep 2 - echo -n . - save_boot_log -done -echo - -echo -n "Waiting for DHCP success." -until grep -q "^Lease of" "$BOOT_LOG"; do - DHCP_WAIT=$((${DHCP_WAIT:-0} + 1)) - if grep "No lease, failing" "$BOOT_LOG"; then - echo "SUM ABORT DHCP wait: fail (${DHCP_WAIT:-0})" - echo "Aborting." - exit 1 - fi - sleep 2 - echo -n . - save_boot_log -done -echo -echo "SUM DHCP wait: ${DHCP_WAIT:-0}" -echo - -echo -n "Waiting for metadata success." -until grep -q "successful after" "$BOOT_LOG"; do - if grep "failed to read iid from metadata" "$BOOT_LOG"; then - echo "SUM ABORT failed to get metadata" - echo "Aborting." - exit 1 - fi - sleep 2 - echo -n . - save_boot_log -done -echo - -echo -n "Waiting for login prompt." -until grep -q "$DEMO_INSTANCE_NAME login:" "$BOOT_LOG"; do - sleep 2 - echo -n . - save_boot_log -done -echo - -echo "Obtaining a VNC session URL for our instance." -nova get-vnc-console "$DEMO_INSTANCE_NAME" novnc - -echo -echo "Permitting ICMP (ping) to our instances." -nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 2>/dev/null || rc=$? -if [ ${rc:-0} -ne 0 ]; then - echo "Rule was already there." -fi - -echo -echo "Permitting secure shell (SSH) access to our instances." -nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 2>/dev/null || rc=$? -if [ ${rc:-0} -ne 0 ]; then - echo "Rule was already there." -fi - -echo -echo "Verifying security-group rules." -nova secgroup-list-rules default - -echo -echo "Creating a floating IP address on the ext-net external network." -floating_ip_id=$(neutron floatingip-create ext-net | awk '/ id / {print $4}') -neutron floatingip-show "$floating_ip_id" - -floating_ip=$(neutron floatingip-show "$floating_ip_id" | - awk '/ floating_ip_address / {print $4}') - -echo -echo "Associating the floating IP address with our instance." -nova floating-ip-associate "$DEMO_INSTANCE_NAME" "$floating_ip" - -echo -echo "Checking the status of your floating IP address." -nova list - -echo -echo -n "Verifying network connectivity to instance VM (may take 2+ min)." -# Since Juno, the floating IP often takes a long time to become pingable. -# Hopefully, this will be fixed, but for the time being we just ping the -# floating IP until we get a reply (or we reach a time limit and give up). -function patient_ping { - local ip=$1 - local cnt=0 - - while [ : ]; do - echo -n . - sleep 1 - - # Ping the instance VM every ten seconds - if [[ $((cnt % 10)) -eq 0 ]]; then - if ping -c1 "$floating_ip" > /dev/null ; then - ping -c1 "$floating_ip" - echo "SUM ping instance VM after $cnt seconds." - break - fi - fi - - # Abort if it takes too long - if [[ $cnt -gt 600 ]]; then - echo "SUM ERROR no ping for instance VM in $cnt seconds. Aborting." - exit 1 - fi - - cnt=$((cnt + 1)) - done -} - -patient_ping "$floating_ip" - -echo -echo "Accessing our instance using SSH from the controller node." -ssh_no_chk "cirros@$floating_ip" uptime - -echo -echo "Pinging our own floating IP from inside the instance." -ssh_no_chk "cirros@$floating_ip" ping -c1 "$floating_ip" - -echo -echo "Pinging IP address of controller-api." -ssh_no_chk "cirros@$floating_ip" ping -c1 "$(hostname_to_ip controller-api)" - -if [ "$EXT_DNS" = true ]; then - echo "Skipping tests of dnsmasq /etc/hosts." -else - # Works only with dnsmasq using the node's /etc/hosts - echo - echo "Pinging controller-api (test local DNS name resolution)." - ssh_no_chk "cirros@$floating_ip" ping -c1 controller-api - echo - echo "Pinging network-api." - ssh_no_chk "cirros@$floating_ip" ping -c1 network-api -fi - -if [ "$MASQUERADING" = true -a "$EXT_DNS" = false ]; then - echo - echo "This may work thanks to masquerading." - ssh_no_chk "cirros@$floating_ip" ping -c1 network-mgmt - echo - ssh_no_chk "cirros@$floating_ip" ping -c1 network-data -fi - -function test_internet { - if [ "$MASQUERADING" = true ]; then - local ext_ping=1 - echo - echo "Pinging Google Public DNS name server." - until ssh_no_chk "cirros@$floating_ip" ping -c1 8.8.8.8; do - if [ $ext_ping -eq 3 ]; then - echo "Failed. Giving up." - echo "SUM ERROR ping Internet: failed ($ext_ping)" - ext_ping="$ext_ping (failed)" - return 0 - fi - echo - echo "Trying again in 1 s." - sleep 1 - ext_ping=$((ext_ping + 1)) - done - - echo - echo "Testing DNS name resolution within instance VM." - ssh_no_chk "cirros@$floating_ip" ping -c1 openstack.org - fi - if [ ${ext_ping:-0} -ne 0 ]; then - echo "SUM ERROR ping Internet: ${ext_ping:-0}" - fi -} - -test_internet - -if [ "$EXT_DNS" = true ]; then - echo - echo "Removing DNS name servers from subnet." - neutron subnet-update demo-subnet --dns_nameservers action=clear -fi - -echo -echo "Summary" -echo "=======" -echo "SUM service restarts: ${SERVICE_RESTARTS:--}" -echo "SUM instance launches: $VM_LAUNCHES" -echo "SUM END" - -echo -echo "Try this, it should work:" -echo "Command: 'ssh cirros@$floating_ip' [ password: 'cubswin:)' ]" - diff --git a/labs/scripts/ubuntu/apt_init.sh b/labs/scripts/ubuntu/apt_init.sh deleted file mode 100755 index 17861af8..00000000 --- a/labs/scripts/ubuntu/apt_init.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/openstack" -# Pick up VM_PROXY -source "$CONFIG_DIR/localrc" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -function set_apt_proxy { - local PRX_KEY="Acquire::http::Proxy" - local APT_FILE=/etc/apt/apt.conf - - if [ -f $APT_FILE ] && grep -q $PRX_KEY $APT_FILE; then - # apt proxy has already been set (by preseed/kickstart) - if [ -n "${VM_PROXY-}" ]; then - # Replace with requested proxy - sudo sed -i "s#^\($PRX_KEY\).*#\1 \"$VM_PROXY\";#" $APT_FILE - else - # No proxy requested -- remove - sudo sed -i "s#^$PRX_KEY.*##" $APT_FILE - fi - elif [ -n "${VM_PROXY-}" ]; then - # Proxy requested, but none configured: add line - echo "$PRX_KEY \"$VM_PROXY\";" | sudo tee -a $APT_FILE - fi -} - -set_apt_proxy - -# Get apt index files -sudo apt-get update - -function ubuntu_cloud_archive { - # cloud-keyring to verify packages from ubuntu-cloud repo - sudo apt-get install ubuntu-cloud-keyring - - # Install packages needed for add-apt-repository - sudo apt-get -y install software-properties-common \ - python-software-properties - sudo add-apt-repository -y "cloud-archive:$OPENSTACK_RELEASE" - - # Get index files only for ubuntu-cloud repo but keep standard lists - sudo apt-get update \ - -o Dir::Etc::sourcelist="sources.list.d/cloudarchive-$OPENSTACK_RELEASE.list" \ - -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -} - -function apache_fix { - - # On '$service apache2 restart', apache will use a text browser to check - # connectivity on '127.0.0.1' or 'localhost'. Apache needs www-browser - # (/etc/alternatives/www-browser) virtual package to carry out this check. - # Include a basic text browser to preemptively avoid this error. - sudo apt-get -y install w3m - -} - -# precise needs the cloud archive, and so does trusty for non-Icehouse releases -if grep -qs DISTRIB_CODENAME=precise /etc/lsb-release || - [ "$OPENSTACK_RELEASE" != "icehouse" ]; then - echo "Enabling the Ubuntu cloud archive." - ubuntu_cloud_archive - apache_fix -fi diff --git a/labs/scripts/ubuntu/apt_install_mysql.sh b/labs/scripts/ubuntu/apt_install_mysql.sh deleted file mode 100755 index 75ee9ddc..00000000 --- a/labs/scripts/ubuntu/apt_install_mysql.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" - -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------- -# Controller setup - -# Get FOURTH_OCTET for this node -source "$CONFIG_DIR/config.$(hostname)" - -# Get MGMT_NET -source "$CONFIG_DIR/openstack" - -DB_IP=$(get_ip_from_net_and_fourth "MGMT_NET" "$FOURTH_OCTET") -echo "Will bind MySQL server to $DB_IP." - -echo "Sourced MySQL password from credentials: $DATABASE_PASSWORD" -sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password '$DATABASE_PASSWORD'' -sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password '$DATABASE_PASSWORD'' - -echo "Installing MySQL." -sudo apt-get install -y mysql-server python-mysqldb - -echo "Configuring MySQL to accept requests by other nodes." - -# Enable access by other nodes via the management network -iniset_sudo /etc/mysql/my.cnf mysqld bind-address "$DB_IP" - -# Enable InnoDB -iniset_sudo /etc/mysql/my.cnf mysqld default-storage-engine innodb -iniset_sudo /etc/mysql/my.cnf mysqld innodb_file_per_table 1 - -# Enable UTF-8 character set and UTF-8 collation by default -iniset_sudo /etc/mysql/my.cnf mysqld collation-server utf8_general_ci -iniset_sudo /etc/mysql/my.cnf mysqld init-connect "'SET NAMES utf8'" -iniset_sudo /etc/mysql/my.cnf mysqld character-set-server utf8 - -echo "Restarting MySQL service." -sudo service mysql restart - -# TODO(rluethi) do we need mysql_secure_installation? -# XXX --use-default only in MySQL 5.7.4+ (Ubuntu 12.04 LTS: MySQL 5.5) -# mysql_secure_installation --use-default diff --git a/labs/scripts/ubuntu/apt_pre-download.sh b/labs/scripts/ubuntu/apt_pre-download.sh deleted file mode 100755 index 671b4f0e..00000000 --- a/labs/scripts/ubuntu/apt_pre-download.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/openstack" -source "$LIB_DIR/functions.guest" - -exec_logfile - -indicate_current_auto - -# Download CirrOS image -function get_cirros { - local file_name=$(basename $CIRROS_URL) - local remote_dir=$(dirname $CIRROS_URL) - local md5_f=$file_name.md5sum - - mkdir -p "$IMG_DIR" - - # Download to IMG_DIR to cache the data if the directory is shared - # with the host computer. - if [ ! -f "$IMG_DIR/$md5_f" ]; then - wget -O - "$remote_dir/MD5SUMS"|grep "$file_name" > "$IMG_DIR/$md5_f" - fi - - if [ ! -f "$IMG_DIR/$file_name" ]; then - wget --directory-prefix="$IMG_DIR" "$CIRROS_URL" - fi - - # Make sure we have image and MD5SUM on the basedisk. - if [ "$IMG_DIR" != "$HOME/img" ]; then - mkdir -p "$HOME/img" - cp -a "$IMG_DIR/$file_name" "$IMG_DIR/$md5_f" "$HOME/img" - fi - - cd "$HOME/img" - md5sum -c "$HOME/img/$md5_f" - cd - -} -get_cirros - -function apt_download { - - sudo apt-get install -y --download-only "$@" - -} - -# Download packages for all nodes - -# MySQL, RabbitMQ -apt_download mysql-server python-mysqldb rabbitmq-server - -# Keystone -apt_download keystone - -# Glance -apt_download glance - -# Nova Controller -apt_download nova-api nova-cert nova-conductor nova-consoleauth \ - nova-novncproxy nova-scheduler python-novaclient - -# Neutron Controller -apt_download neutron-server neutron-plugin-ml2 neutron-lbaas-agent - -# Cinder Controller -apt_download cinder-api cinder-scheduler - -# Horizon -apt_download openstack-dashboard memcached - -# Cinder Volumes -apt_download lvm2 cinder-volume - -# Nova Compute -apt_download nova-compute-qemu sysfsutils - -# Neutron Compute -apt_download neutron-common neutron-plugin-ml2 \ - neutron-plugin-openvswitch-agent - -# Neutron Network -apt_download neutron-common neutron-plugin-ml2 \ - neutron-plugin-openvswitch-agent neutron-l3-agent neutron-dhcp-agent - -# Heat -apt_download heat-api heat-api-cfn heat-engine python-heatclient - -# Ceilometer -apt_download mongodb-server mongodb-clients python-pymongo \ - ceilometer-api ceilometer-collector ceilometer-agent-central \ - ceilometer-agent-notification ceilometer-alarm-evaluator \ - ceilometer-alarm-notifier ceilometer-agent-compute \ - python-ceilometerclient diff --git a/labs/scripts/ubuntu/apt_upgrade.sh b/labs/scripts/ubuntu/apt_upgrade.sh deleted file mode 100755 index eb20ef2f..00000000 --- a/labs/scripts/ubuntu/apt_upgrade.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/openstack" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -# XXX We assume that apt_init.sh set up repos and updated the apt index files - -# Upgrade installed packages and the kernel -sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade -sudo apt-get -y dist-upgrade - -# XXX Not a great location for Vagrant specific code -if [[ $VM_SHELL_USER = vagrant ]]; then - init_os_ident - if is_ubuntu; then - sudo apt-get -y install virtualbox-guest-dkms - fi -fi - -# If we upgraded the kernel, remove the old one -INSTALLED_KERNEL=$(readlink /vmlinuz) -INSTALLED_KERNEL=${INSTALLED_KERNEL#boot/vmlinuz-} -RUNNING_KERNEL=$(uname -r) - -if [[ $INSTALLED_KERNEL != $RUNNING_KERNEL ]]; then - echo "Kernel $INSTALLED_KERNEL installed. Removing $RUNNING_KERNEL." - if dpkg -s "linux-image-extra-$RUNNING_KERNEL" >/dev/null 2>&1; then - sudo dpkg --purge "linux-image-extra-$RUNNING_KERNEL" - fi - sudo dpkg --purge "linux-image-$RUNNING_KERNEL" - sudo dpkg --purge "linux-headers-$RUNNING_KERNEL" -fi - -# Clean apt cache -sudo apt-get -y autoremove -sudo apt-get -y clean diff --git a/labs/scripts/ubuntu/install_rabbitmq.sh b/labs/scripts/ubuntu/install_rabbitmq.sh deleted file mode 100755 index 1be38aa8..00000000 --- a/labs/scripts/ubuntu/install_rabbitmq.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" - -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------- -# Install the message broker service (RabbitMQ). - -echo "Installing RabbitMQ." -sudo apt-get install -y rabbitmq-server - -echo "Setting RabbitMQ password to '$RABBIT_PASSWORD'." -sudo rabbitmqctl change_password guest "$RABBIT_PASSWORD" diff --git a/labs/scripts/ubuntu/setup_cinder_controller.sh b/labs/scripts/ubuntu/setup_cinder_controller.sh deleted file mode 100755 index a8ca3ebc..00000000 --- a/labs/scripts/ubuntu/setup_cinder_controller.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up Block Storage service controller (cinder controller node) -# http://docs.openstack.org/juno/install-guide/install/apt/content/cinder-install-controller-node.html -#------------------------------------------------------------------------------ - -echo "Setting up database for cinder." -setup_database cinder - -source "$CONFIG_DIR/admin-openstackrc.sh" - -cinder_admin_user=$(service_to_user_name cinder) -cinder_admin_password=$(service_to_user_password cinder) - -echo "Creating cinder user." -keystone user-create \ - --name "$cinder_admin_user" \ - --pass "$cinder_admin_password" - -echo "Linking cinder user, service tenant and admin role." -keystone user-role-add \ - --user "$cinder_admin_user" \ - --tenant "$SERVICE_TENANT_NAME" \ - --role "$ADMIN_ROLE_NAME" - -echo "Registering cinder with keystone so that other services can locate it." -keystone service-create \ - --name cinder \ - --type volume \ - --description "OpenStack Block Storage" - -keystone service-create \ - --name cinderv2 \ - --type volumev2 \ - --description "OpenStack Block Storage v2" - -cinder_service_id=$(keystone service-list | awk '/ volume / {print $2}') -keystone endpoint-create \ - --service-id "$cinder_service_id" \ - --publicurl 'http://controller-api:8776/v1/%(tenant_id)s' \ - --adminurl 'http://controller-mgmt:8776/v1/%(tenant_id)s' \ - --internalurl 'http://controller-mgmt:8776/v1/%(tenant_id)s' - -cinder_v2_service_id=$(keystone service-list | awk '/ volumev2 / {print $2}') -keystone endpoint-create \ - --service-id "$cinder_v2_service_id" \ - --publicurl 'http://controller-api:8776/v2/%(tenant_id)s' \ - --adminurl 'http://controller-mgmt:8776/v2/%(tenant_id)s' \ - --internalurl 'http://controller-mgmt:8776/v2/%(tenant_id)s' - -echo "Installing cinder." -sudo apt-get install -y cinder-api cinder-scheduler python-cinderclient \ - qemu-utils -# Note: The package 'qemu-utils' is required for 'qemu-img' which allows cinder -# to convert additional image types to bootable volumes. By default only -# raw images can be converted. - -function get_database_url { - local db_user=$(service_to_db_user cinder) - local db_password=$(service_to_db_password cinder) - local database_host=controller-mgmt - - echo "mysql://$db_user:$db_password@$database_host/cinder" -} - -database_url=$(get_database_url) - -echo "Configuring cinder-api.conf." -conf=/etc/cinder/cinder.conf - -echo "Setting database connection: $database_url." -iniset_sudo $conf database connection "$database_url" - -# Configure [DEFAULT] section to use RabbitMQ message broker. -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" -iniset_sudo $conf DEFAULT auth_strategy keystone - -# Configure [keystone_authtoken] section. -iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf keystone_authtoken identity_uri "http://controller-mgmt:35357" -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$cinder_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$cinder_admin_password" - -iniset_sudo $conf DEFAULT my_ip "$(hostname_to_ip controller-mgmt)" - -iniset_sudo $conf DEFAULT verbose True - -echo "Creating the database tables for cinder." -sudo cinder-manage db sync - -echo "Restarting cinder service." -sudo service cinder-scheduler restart -sudo service cinder-api restart - -echo "Removing unused SQLite database file (if any)." -sudo rm -rf /var/lib/cinder/cinder.sqlite diff --git a/labs/scripts/ubuntu/setup_cinder_volumes.sh b/labs/scripts/ubuntu/setup_cinder_volumes.sh deleted file mode 100755 index a8333e27..00000000 --- a/labs/scripts/ubuntu/setup_cinder_volumes.sh +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$CONFIG_DIR/openstack" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/admin-openstackrc.sh" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up Block Storage service (cinder). -# http://docs.openstack.org/juno/install-guide/install/apt/content/cinder-install-storage-node.html -#------------------------------------------------------------------------------ - -# Get FOURTH_OCTET for this node -source "$CONFIG_DIR/config.$(hostname)" - -MY_MGMT_IP=$(get_ip_from_net_and_fourth "MGMT_NET" "$FOURTH_OCTET") -echo "IP address of this node's interface in management network: $MY_MGMT_IP." - -echo "Installing the Logical Volume Manager (LVM)." -sudo apt-get install -y lvm2 - -echo "Configuring LVM physical and logical volumes." - -# We don't have a dedicated physical partition for cinder to use; instead, -# we configure a file-backed loopback device. -cinder_loop_path=/var/lib/cinder-volumes -cinder_loop_dev=/dev/loop2 -sudo dd if=/dev/zero of=$cinder_loop_path bs=1 count=0 seek=4G -sudo losetup $cinder_loop_dev $cinder_loop_path - -# Tell upstart to run losetup again when the system is rebooted -cat << UPSTART | sudo tee "/etc/init/cinder-losetup.conf" -description "Set up loop device for cinder." - -start on mounted MOUNTPOINT=/ -task -exec /sbin/losetup $cinder_loop_dev $cinder_loop_path -UPSTART - -sudo pvcreate $cinder_loop_dev -sudo vgcreate cinder-volumes $cinder_loop_dev - -# We could configure LVM to only use loopback devices or only the device -# we just set up, but scanning our block devices to find our volume group -# is fast enough. - -echo "Installing cinder." -sudo apt-get install -y cinder-volume python-mysqldb - -conf=/etc/cinder/cinder.conf -echo "Configuring $conf." - -function get_database_url { - local db_user=$(service_to_db_user cinder) - local db_password=$(service_to_db_password cinder) - local database_host=controller-mgmt - - echo "mysql://$db_user:$db_password@$database_host/cinder" -} - -database_url=$(get_database_url) - -echo "Setting database connection: $database_url." -iniset_sudo $conf database connection "$database_url" - -# Configure [DEFAULT] section. -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -iniset_sudo $conf DEFAULT auth_strategy keystone - -# Configure [keystone_authtoken] section. -cinder_admin_user=$(service_to_user_name cinder) -cinder_admin_password=$(service_to_user_password cinder) -iniset_sudo $conf keystone_authtoken auth_uri http://controller-mgmt:5000/v2.0 -iniset_sudo $conf keystone_authtoken identity_uri http://controller-mgmt:35357 -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$cinder_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$cinder_admin_password" - -iniset_sudo $conf DEFAULT my_ip "$MY_MGMT_IP" - -iniset_sudo $conf DEFAULT glance_host controller-mgmt - -iniset_sudo $conf DEFAULT verbose True - -echo "Restarting cinder service." -sudo service tgt restart -sudo service cinder-volume restart - -sudo rm -f /var/lib/cinder/cinder.sqlite - -#------------------------------------------------------------------------------ -# Verify the Block Storage installation -# http://docs.openstack.org/juno/install-guide/install/apt/content/cinder-verify.html -#------------------------------------------------------------------------------ - -echo "Verifying Block Storage installation on controller node." - -echo "Sourcing the admin credentials." -AUTH="source $CONFIG_DIR/admin-openstackrc.sh" - -# It takes time for Cinder to be aware of its services status. -# Force restart cinder API and wait for 20 seconds. -echo "Restarting Cinder API." -node_ssh controller-mgmt "sudo service cinder-api restart" -sleep 20 - -echo "Waiting for cinder to start." -until node_ssh controller-mgmt "$AUTH; cinder service-list" >/dev/null 2>&1; do - sleep 1 -done - -echo "cinder service-list" -node_ssh controller-mgmt "$AUTH; cinder service-list" - -function check_cinder_services { - - # It takes some time for cinder to detect its services and update its - # status. This method will wait for 20 seconds to get the status of the - # Cinder services. - local i=1 - while [ : ]; do - if [[ -z $(node_ssh controller-mgmt "$AUTH; cinder service-list" | grep down) ]] > /dev/null 2>&1; then - echo "Cinder services seem to be up and running!" - return 0 - fi - i=$((i + 1)) - if [[ "$i" -gt "20" ]]; then - echo "Error, cinder services are not working as expected." - exit 0 - fi - echo -n . - sleep 1 - done -} - -# To avoid race conditions which were causing Cinder Volumes script to fail, -# check the status of the cinder services. Cinder takes a few seconds before it -# is aware of the exact status of its services. -echo "Waiting for all cinder services to start." -check_cinder_services - -echo "Sourcing the demo credentials." -AUTH="source $CONFIG_DIR/demo-openstackrc.sh" - -echo "cinder create --display-name demo-volume1 1" -node_ssh controller-mgmt "$AUTH; cinder create --display-name demo-volume1 1;sleep 20" - -echo "check if cinder has the given volume" -until node_ssh controller-mgmt "$AUTH; cinder list | grep demo-volume1" > /dev/null 2>&1; do - sleep 1 -done - -function wait_for_cinder_volume { - - # Wait for cinder volume to be created - echo -n 'Waiting for cinder volume to be created.' - local i=1 - while [ : ]; do - if [[ -z $(node_ssh controller-mgmt "$AUTH;cinder list" | grep creating) ]] > /dev/null 2>&1; then - # Proceed if the state of cinder-volumes is error or created. - # Cinder volumes cannot be deleted when it is in creating state. - # Throw an error and stop this script. - # The purpose of this method is to resolve cinder-volumes race. - return 0 - fi - i=$((i + 1)) - if [[ "$i" -gt "20" ]]; then - echo "Error creating cinder volume." - echo "[Warning]: Debug cinder volumes service on the compute node. - Delete the cinder-volume demo-volume1. Script could not delete this - volume." - exit 0 - fi - echo -n . - sleep 1 - done - echo -} - -echo "Checking if volume is created." -wait_for_cinder_volume - -echo "cinder delete demo-volume1" -node_ssh controller-mgmt "$AUTH; cinder delete demo-volume1" - -echo "cinder list" -node_ssh controller-mgmt "$AUTH; cinder list" diff --git a/labs/scripts/ubuntu/setup_glance.sh b/labs/scripts/ubuntu/setup_glance.sh deleted file mode 100755 index 17fadde9..00000000 --- a/labs/scripts/ubuntu/setup_glance.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Install the Image Service (glance). -# http://docs.openstack.org/juno/install-guide/install/apt/content/glance-install.html -#------------------------------------------------------------------------------ - -echo "Setting up database for glance." -setup_database glance - -echo "Sourcing the admin credentials." -source "$CONFIG_DIR/admin-openstackrc.sh" - -glance_admin_user=$(service_to_user_name glance) -glance_admin_password=$(service_to_user_password glance) - -echo "Creating glance user and giving it admin role under service tenant." -keystone user-create \ - --name "$glance_admin_user" \ - --pass "$glance_admin_password" \ - -keystone user-role-add \ - --user "$glance_admin_user" \ - --tenant "$SERVICE_TENANT_NAME" \ - --role "$ADMIN_ROLE_NAME" - -echo "Registering glance with keystone so that other services can locate it." -keystone service-create \ - --name glance \ - --type image \ - --description "OpenStack Image Service" - -glance_service_id=$(keystone service-list | awk '/ image / {print $2}') -keystone endpoint-create \ - --service-id "$glance_service_id" \ - --publicurl "http://controller-api:9292" \ - --internalurl "http://controller-mgmt:9292" \ - --adminurl "http://controller-mgmt:9292" \ - --region "$REGION" - -echo "Installing glance." -sudo apt-get install -y glance python-glanceclient - -function get_database_url { - local db_user=$(service_to_db_user glance) - local db_password=$(service_to_db_password glance) - local database_host=controller-mgmt - - echo "mysql://$db_user:$db_password@$database_host/glance" -} - -database_url=$(get_database_url) -echo "Database connection: $database_url." - -echo "Configuring glance-api.conf." -conf=/etc/glance/glance-api.conf -iniset_sudo $conf database connection "$database_url" -iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf keystone_authtoken identity_uri "http://controller-mgmt:35357" -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$glance_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$glance_admin_password" -iniset_sudo $conf paste_deploy flavor "keystone" -iniset_sudo $conf glance_store default_store file -iniset_sudo $conf glance_store filesystem_store_datadir /var/lib/glance/images/ -iniset_sudo $conf DEFAULT verbose True - -echo "Configuring glance-registry.conf." -conf=/etc/glance/glance-registry.conf -iniset_sudo $conf database connection "$database_url" -iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf keystone_authtoken identity_uri "http://controller-mgmt:35357" -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$glance_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$glance_admin_password" -iniset_sudo $conf paste_deploy flavor "keystone" -iniset_sudo $conf DEFAULT verbose True - -echo "Creating the database tables for glance." -sudo glance-manage db_sync - -echo "Restarting glance service." -sudo service glance-registry restart -sudo service glance-api restart - -echo "Removing default SQLite database." -sudo rm -f /var/lib/glance/glance.sqlite - -#------------------------------------------------------------------------------ -# Verify the Image Service installation -# http://docs.openstack.org/juno/install-guide/install/apt/content/glance-verify.html -#------------------------------------------------------------------------------ - -echo "Waiting for glance to start." -until glance image-list >/dev/null 2>&1; do - sleep 1 -done - -# cirros-0.3.3-x86_64-disk.img -> cirros-0.3.3-x86_64 -img_name=$(basename $CIRROS_URL -disk.img) - -echo "Adding CirrOS image as $img_name to glance." - -glance image-create \ - --name "$img_name" \ - --file "$HOME/img/$(basename $CIRROS_URL)" \ - --disk-format qcow2 \ - --container-format bare \ - --is-public True - -echo "Verifying that the image was successfully added to the service." - -echo "glance image-list" -glance image-list diff --git a/labs/scripts/ubuntu/setup_heat_controller.sh b/labs/scripts/ubuntu/setup_heat_controller.sh deleted file mode 100755 index 4a4250a2..00000000 --- a/labs/scripts/ubuntu/setup_heat_controller.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" - -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Install the Orchestration Service (heat). -# http://docs.openstack.org/juno/install-guide/install/apt/content/heat-install-controller-node.html -#------------------------------------------------------------------------------ - -echo "Setting up database for heat." -setup_database heat - -echo "Sourcing the admin credentials." -source "$CONFIG_DIR/admin-openstackrc.sh" - -heat_admin_user=$(service_to_user_name heat) -heat_admin_password=$(service_to_user_password heat) - -echo "Creating heat user and giving it admin role under service tenant." -keystone user-create \ - --name "$heat_admin_user" \ - --pass "$heat_admin_password" \ - -keystone user-role-add \ - --user "$heat_admin_user" \ - --tenant "$SERVICE_TENANT_NAME" \ - --role "$ADMIN_ROLE_NAME" - -echo "Creating the heat stack owner role." -keystone role-create --name "heat_stack_owner" - -keystone user-role-add \ - --user "$DEMO_USER_NAME" \ - --tenant "$DEMO_TENANT_NAME" \ - --role heat_stack_owner - -echo "Creating the heat stack user role." -keystone role-create --name "heat_stack_user" - -echo "Registering heat with keystone so that other services can locate it." -keystone service-create \ - --name heat \ - --type orchestration \ - --description "Orchestration" - -keystone service-create \ - --name heat-cfn \ - --type cloudformation \ - --description "Orchestration" - - -heat_service_id=$(keystone service-list | awk '/ orchestration / {print $2}') -keystone endpoint-create \ - --service-id "$heat_service_id" \ - --publicurl "http://controller-api:8004/v1/%(tenant_id)s" \ - --internalurl "http://controller-mgmt:8004/v1/%(tenant_id)s" \ - --adminurl "http://controller-mgmt:8004/v1/%(tenant_id)s" \ - --region "$REGION" - -heatcfn_service_id=$(keystone service-list | awk '/ cloudformation / {print $2}') -keystone endpoint-create \ - --service-id "$heatcfn_service_id" \ - --publicurl "http://controller-api:8000/v1" \ - --internalurl "http://controller-mgmt:8000/v1" \ - --adminurl "http://controller-mgmt:8000/v1" \ - --region "$REGION" - - -echo "Installing heat." -sudo apt-get install -y heat-api heat-api-cfn heat-engine \ - python-heatclient - -function get_database_url { - local db_user=$(service_to_db_user heat) - local db_password=$(service_to_db_password heat) - local database_host=controller-mgmt - - echo "mysql://$db_user:$db_password@$database_host/heat" -} - -database_url=$(get_database_url) -echo "Database connection: $database_url." - -echo "Configuring heat.conf." -conf=/etc/heat/heat.conf -iniset_sudo $conf database connection "$database_url" - -echo "Configuring [DEFAULT] section in /etc/heat/heat.conf." - -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - - -iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf keystone_authtoken identity_uri "http://controller-mgmt:35357" -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$heat_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$heat_admin_password" -iniset_sudo $conf ec2authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf DEFAULT heat_metadata_server_url "http://controller-mgmt:8000" -iniset_sudo $conf DEFAULT heat_waitcondition_server_url "http://controller-mgmt:8000/v1/waitcondition" -iniset_sudo $conf DEFAULT verbose True - - -echo "Creating the database tables for heat." -sudo heat-manage db_sync - -echo "Restarting heat service." -sudo service heat-api restart -sudo service heat-api-cfn restart -sudo service heat-engine restart - -echo "Removing default SQLite database." -sudo rm -f /var/lib/heat/heat.sqlite diff --git a/labs/scripts/ubuntu/setup_heat_network.sh b/labs/scripts/ubuntu/setup_heat_network.sh deleted file mode 100755 index 2c3578b9..00000000 --- a/labs/scripts/ubuntu/setup_heat_network.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/openstack" - -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Verify the Orchestration Service installation -# http://docs.openstack.org/juno/install-guide/install/apt/content/heat-verify.html -#------------------------------------------------------------------------------ -echo "Verifying heat installation." - -echo "Waiting for heat-engine to start." - -AUTH="source $CONFIG_DIR/demo-openstackrc.sh" -until node_ssh controller-mgmt "$AUTH; heat stack-list" >/dev/null 2>&1; do - sleep 1 -done - -echo "Creating a test heat template." - -node_ssh controller-mgmt "echo ' -heat_template_version: 2014-10-16 -description: A simple server. - -parameters: - ImageID: - type: string - description: Image use to boot a server - NetID: - type: string - description: Network ID for the server - -resources: - server: - type: OS::Nova::Server - properties: - image: { get_param: ImageID } - flavor: m1.tiny - networks: - - network: { get_param: NetID } - -outputs: - private_ip: - description: IP address of the server in the private network - value: { get_attr: [ server, first_address ] }' > test-stack.yml" - -NET_ID=$(node_ssh controller-mgmt "$AUTH; nova net-list" | awk '/ demo-net / { print $2 }') -img_name=$(basename "$CIRROS_URL" -disk.img) - -node_ssh controller-mgmt "$AUTH; heat stack-create -f test-stack.yml \ - -P 'ImageID=$img_name;NetID=$NET_ID' testStack" - -echo "Verifying successful creation of stack." - -cnt=0 -echo "heat stack-list" -until node_ssh controller-mgmt "$AUTH; heat stack-list" 2>/dev/null | grep "CREATE_COMPLETE"; do - cnt=$((cnt + 1)) - if [ $cnt -eq 60 ]; then - # Print current stack list to help with debugging - echo - node_ssh controller-mgmt "$AUTH; heat stack-list" - echo "Heat stack creation failed. Exiting." - echo "[Warning]: Please debug heat services on the - controller and network node. Heat may not work." - exit 0 - else - sleep 1 - echo -n "." - fi -done - -echo "Deleting the test stack." -heat_stack_id=$(node_ssh controller-mgmt "$AUTH; heat stack-list" | awk '/ testStack / {print $2}') - -node_ssh controller-mgmt "$AUTH; heat stack-delete $heat_stack_id" diff --git a/labs/scripts/ubuntu/setup_horizon.sh b/labs/scripts/ubuntu/setup_horizon.sh deleted file mode 100755 index ffc1c37e..00000000 --- a/labs/scripts/ubuntu/setup_horizon.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up OpenStack Dashboard (horizon) -# http://docs.openstack.org/juno/install-guide/install/apt/content/install_dashboard.html -#------------------------------------------------------------------------------ - -echo "Installing horizon." -sudo apt-get install -y openstack-dashboard apache2 libapache2-mod-wsgi \ - memcached python-memcache - -echo "Purging Ubuntu theme." -sudo dpkg --purge openstack-dashboard-ubuntu-theme - -function check_dashboard_settings { - local dashboard_conf=/etc/openstack-dashboard/local_settings.py - - local auth_host=controller-mgmt - echo "Setting OPENSTACK_HOST = \"$auth_host\"." - sudo sed -i "s#^\(OPENSTACK_HOST =\).*#\1 \"$auth_host\";#" $dashboard_conf - - echo -n "Allowed hosts: " - grep "^ALLOWED_HOSTS" $dashboard_conf - - local memcached_conf=/etc/memcached.conf - # Port is a number on line starting with "-p " - local port=$(grep -Po -- '(?<=^-p )\d+' $memcached_conf) - - # Interface is an IP address on line starting with "-l " - local interface=$(grep -Po -- '(?<=^-l )[\d\.]+' $memcached_conf) - - echo "memcached listening on $interface:$port." - - # Line should read something like: 'LOCATION' : '127.0.0.1:11211', - if grep "LOCATION.*$interface:$port" $dashboard_conf; then - echo "$dashboard_conf agrees." - else - echo >&2 "$dashboard_conf disagrees. Aborting." - exit 1 - fi - - echo -n "Time zone setting: " - grep TIME_ZONE $dashboard_conf -} - -echo "Checking dashboard configuration." -check_dashboard_settings - -function check_apache_service { - # Check if apache service is down, if not force retry a couple of times. - sleep 10 - i=0 - until service apache2 status | grep 'not running'; do - sudo service apache2 stop - sleep 10 - i ++ - if [ $i -gt 3] - then - break - fi - done -} - -echo "Reloading apache and memcached service." -sudo service apache2 stop -check_apache_service -sudo service memcached restart diff --git a/labs/scripts/ubuntu/setup_keystone.sh b/labs/scripts/ubuntu/setup_keystone.sh deleted file mode 100755 index e71cf74c..00000000 --- a/labs/scripts/ubuntu/setup_keystone.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -# Get REGION -source "$CONFIG_DIR/openstack" -source "$LIB_DIR/functions.guest" - -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up keystone for controller node -# http://docs.openstack.org/juno/install-guide/install/apt/content/keystone-install.html -#------------------------------------------------------------------------------ - -echo "Setting up database for keystone." -setup_database keystone - -# Create a "shared secret" used as OS_SERVICE_TOKEN, together with -# OS_SERVICE_ENDPOINT, before keystone can be used for authentication -echo -n "Using openssl to generate a random admin token: " -ADMIN_TOKEN=$(openssl rand -hex 10) -echo "$ADMIN_TOKEN" - -echo "Installing keystone." -sudo apt-get install -y keystone python-keystoneclient - -conf=/etc/keystone/keystone.conf -echo "Configuring [DEFAULT] section in $conf." - -echo "Setting admin_token to bootstrap authentication." -iniset_sudo $conf DEFAULT admin_token "$ADMIN_TOKEN" - -function get_database_url { - local db_user=$(service_to_db_user keystone) - local db_password=$(service_to_db_password keystone) - local database_host=controller-mgmt - - echo "mysql://$db_user:$db_password@$database_host/keystone" -} - -database_url=$(get_database_url) - -echo "Configuring [database] section in /etc/keystone/keystone.conf." - -echo "Setting database connection: $database_url." -iniset_sudo $conf database connection "$database_url" - -echo "Configuring the UUID token provider and SQL driver." -iniset_sudo $conf token provider keystone.token.providers.uuid.Provider -iniset_sudo $conf token driver keystone.token.persistence.backends.sql.Token - -echo "Enabling verbose logging." -iniset_sudo $conf DEFAULT verbose True - -echo "Creating the database tables for keystone." -sudo keystone-manage db_sync - -echo "Restarting keystone." -sudo service keystone restart - -echo "Removing default SQLite database." -sudo rm -f /var/lib/keystone/keystone.db - -if ! sudo crontab -l -u keystone 2>&1 | grep token_flush; then - # No existing crontab entry for token_flush -- add one now. - echo "Adding crontab entry to purge expired tokens:" - cat << CRON | sudo tee -a /var/spool/cron/crontabs/keystone -# Purges expired tokens every hour and logs the output -@hourly /usr/bin/keystone-manage token_flush >/var/log/keystone/keystone-tokenflush.log 2>&1 -CRON - echo "---------------------------------------------" -fi - -#------------------------------------------------------------------------------ -# Configure keystone users, tenants and roles -# http://docs.openstack.org/juno/install-guide/install/apt/content/keystone-users.html -#------------------------------------------------------------------------------ - -echo "Using OS_SERVICE_TOKEN, OS_SERVICE_ENDPOINT for authentication." -export OS_SERVICE_TOKEN=$ADMIN_TOKEN -export OS_SERVICE_ENDPOINT="http://controller-mgmt:35357/v2.0" - -# Wait for keystone to come up -until keystone user-list >/dev/null 2>&1; do - sleep 1 -done - -echo "Adding admin tenant." -keystone tenant-create --name "$ADMIN_TENANT_NAME" --description "Admin Tenant" - -echo "Creating admin user." -keystone user-create \ - --name "$ADMIN_USER_NAME" \ - --pass "$ADMIN_PASSWORD" \ - --email "admin@$MAIL_DOMAIN" - -echo "Creating admin role." -keystone role-create --name "$ADMIN_ROLE_NAME" - -echo "Linking admin user, admin role and admin tenant." -keystone user-role-add \ - --user "$ADMIN_USER_NAME" \ - --tenant "$ADMIN_TENANT_NAME" \ - --role "$ADMIN_ROLE_NAME" - -echo "Creating demo tenant." -keystone tenant-create --name "$DEMO_TENANT_NAME" --description "Demo Tenant" - -echo "Creating demo user." -# Using the --tenant option automatically assigns the _member_ role to a user. -# This option will also create the _member_ role if it does not exist. -keystone user-create \ - --name "$DEMO_USER_NAME" \ - --tenant "$DEMO_TENANT_NAME" \ - --pass "$DEMO_PASSWORD" \ - --email "demo@$MAIL_DOMAIN" - -echo "Adding service tenant." -keystone tenant-create \ - --name "$SERVICE_TENANT_NAME" \ - --description "Service Tenant" - -#------------------------------------------------------------------------------ -# Configure keystone services and API endpoints -# http://docs.openstack.org/juno/install-guide/install/apt/content/keystone-services.html -#------------------------------------------------------------------------------ - -echo "Creating keystone service." -keystone service-create \ - --name keystone \ - --type identity \ - --description 'OpenStack Identity' - -echo "Creating endpoints for keystone." -keystone_service_id=$(keystone service-list | awk '/ keystone / {print $2}') -keystone endpoint-create \ - --service-id "$keystone_service_id" \ - --publicurl "http://controller-api:5000/v2.0" \ - --internalurl "http://controller-mgmt:5000/v2.0" \ - --adminurl "http://controller-mgmt:35357/v2.0" \ - --region "$REGION" - -#------------------------------------------------------------------------------ -# Verify the Identity Service installation -# http://docs.openstack.org/icehouse/install-guide/install/apt/content/keystone-verify.html -#------------------------------------------------------------------------------ - -echo "Verifying keystone installation." - -# From this point on, we are going to use keystone for authentication -unset OS_SERVICE_TOKEN OS_SERVICE_ENDPOINT - -# Load keystone credentials -source "$CONFIG_DIR/admin-openstackrc.sh" - -# The output of the following commands can be used to verify or debug the -# service. - -echo "keystone token-get" -keystone token-get - -echo "keystone user-list" -keystone user-list - -echo "keystone user-role-list --user $ADMIN_USER_NAME --tenant $ADMIN_TENANT_NAME" -keystone user-role-list --user "$ADMIN_USER_NAME" --tenant "$ADMIN_TENANT_NAME" diff --git a/labs/scripts/ubuntu/setup_lbaas_controller.sh b/labs/scripts/ubuntu/setup_lbaas_controller.sh deleted file mode 100755 index 45c2fd4e..00000000 --- a/labs/scripts/ubuntu/setup_lbaas_controller.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/admin-openstackrc.sh" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up OpenStack neutron LBaaS for controller node. -# http://docs.openstack.org/admin-guide-cloud/content/install_neutron-lbaas-agent.html -#------------------------------------------------------------------------------ - -echo "Configuring neutron lbaas for controller node." -conf=/etc/neutron/neutron.conf - -# Configure network plugin parameters -iniset_sudo $conf DEFAULT service_plugins "router,lbaas" - -echo "Restarting neutron service." -sudo service neutron-server restart - -# Configure openstack dashboard -function check_dashboard_settings { - local memcached_conf=/etc/memcached.conf - local dashboard_conf=/etc/openstack-dashboard/local_settings.py - - # Enabling Neutron LBaaS on Horizon - echo "Enabling neutron LBaaS on horizon." - sudo sed -i "s/'enable_lb': False/\'enable_lb\': True/" $dashboard_conf -} - -echo "Checking dashboard configuration." -check_dashboard_settings - -function check_apache_service { - # Check if apache service is down, if not force retry a couple of times. - sleep 10 - i=0 - until service apache2 status | grep 'not running'; do - sudo service apache2 stop - sleep 10 - i=$((i + 1)) - if [ $i -gt 3 ] - then - break - fi - done -} - -echo "Reloading apache and memcached service." -sudo service apache2 stop -check_apache_service -sudo service apache2 start -sudo service memcached restart diff --git a/labs/scripts/ubuntu/setup_lbaas_network.sh b/labs/scripts/ubuntu/setup_lbaas_network.sh deleted file mode 100755 index 6615a4e0..00000000 --- a/labs/scripts/ubuntu/setup_lbaas_network.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/openstack" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up OpenStack neutron LBaaS for network node. -# http://docs.openstack.org/admin-guide-cloud/content/install_neutron-lbaas-agent.html -#------------------------------------------------------------------------------ - -echo "Installing neutron lbaas agent for network node." -sudo apt-get install -y neutron-lbaas-agent - -echo "Configuring LBaaS agent for network node." -conf=/etc/neutron/lbaas_agent.ini -iniset_sudo $conf DEFAULT device_driver neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver -iniset_sudo $conf DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver - -echo "Restarting the neutron lbaas agent service." -sudo service neutron-lbaas-agent restart - -#------------------------------------------------------------------------------ -# Verify the neutron LBaaS installation -#------------------------------------------------------------------------------ - -echo "Verifying neutron lbaas installation." - -echo "Waiting for neutron-lbaas-agent to start." -AUTH="source $CONFIG_DIR/demo-openstackrc.sh" -until node_ssh controller-mgmt "$AUTH; neutron lb-pool-list" >/dev/null 2>&1; do - sleep 1 -done - -LB_NUMBER=$(date +"%d%m%y%H%M%S") -echo "neutron lb-pool-create --lb-method ROUND_ROBIN --name test-lb$LB_NUMBER --protocol HTTP --subnet-id demo-subnet" -node_ssh controller-mgmt "$AUTH; neutron lb-pool-create --lb-method ROUND_ROBIN --name test-lb$LB_NUMBER --protocol HTTP --subnet-id demo-subnet" - -echo "Checking if created pool is active." -until node_ssh controller-mgmt "$AUTH; neutron lb-pool-list | grep test-lb$LB_NUMBER | grep -i ACTIVE" > /dev/null 2>&1; do - sleep 1 -done -echo "Success." - -echo "neutron lb-pool-list" -node_ssh controller-mgmt "$AUTH; neutron lb-pool-list" - -echo "neutron lb-pool-delete test-lb$LB_NUMBER" -node_ssh controller-mgmt "$AUTH; neutron lb-pool-delete test-lb$LB_NUMBER" - -echo "neutron lb-pool-list" -node_ssh controller-mgmt "$AUTH; neutron lb-pool-list" diff --git a/labs/scripts/ubuntu/setup_neutron_compute.sh b/labs/scripts/ubuntu/setup_neutron_compute.sh deleted file mode 100755 index 31d5b60f..00000000 --- a/labs/scripts/ubuntu/setup_neutron_compute.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/admin-openstackrc.sh" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up OpenStack Networking (neutron) for compute node. -# http://docs.openstack.org/juno/install-guide/install/apt/content/neutron-compute-node.html -#------------------------------------------------------------------------------ - -echo "Editing /etc/sysctl.conf: disable Reverse Path Forwarding filter." -cat << SYSCTL | sudo tee -a /etc/sysctl.conf -# Disable Reverse Path Forwarding filter (RFC 3704) -net.ipv4.conf.all.rp_filter=0 -net.ipv4.conf.default.rp_filter=0 -SYSCTL - -# Reload changed file -sudo sysctl -p - -echo "Installing networking components for compute node." -sudo apt-get install -y neutron-plugin-ml2 \ - neutron-plugin-openvswitch-agent - -echo "Configuring neutron for compute node." - -neutron_admin_user=$(service_to_user_name neutron) -neutron_admin_password=$(service_to_user_password neutron) - -conf=/etc/neutron/neutron.conf -echo "Configuring $conf." - -# Configure AMQP parameters -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -# Configuring [DEFAULT] section -iniset_sudo $conf DEFAULT auth_strategy keystone - -# Configuring [keystone_authtoken] section -iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf keystone_authtoken identity_uri http://controller-mgmt:35357 -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$neutron_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$neutron_admin_password" - -# Configure network plugin parameters -iniset_sudo $conf DEFAULT core_plugin ml2 -iniset_sudo $conf DEFAULT service_plugins router -iniset_sudo $conf DEFAULT allow_overlapping_ips True - -iniset_sudo $conf DEFAULT verbose True - -echo "Configuring the OVS plug-in to use GRE tunneling." -conf=/etc/neutron/plugins/ml2/ml2_conf.ini - -# Under the ml2 section -iniset_sudo $conf ml2 type_drivers flat,gre -iniset_sudo $conf ml2 tenant_network_types gre -iniset_sudo $conf ml2 mechanism_drivers openvswitch - -# Under the ml2_type_gre section -iniset_sudo $conf ml2_type_gre tunnel_id_ranges 1:1000 - -# Under the securitygroup section -iniset_sudo $conf securitygroup enable_security_group True -iniset_sudo $conf securitygroup enable_ipset True -iniset_sudo $conf securitygroup firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver - -# Under the ovs section -iniset_sudo $conf ovs local_ip "$(hostname_to_ip compute-data)" -iniset_sudo $conf ovs enable_tunneling True - -iniset_sudo $conf agent tunnel_types gre - -echo "Restarting the Open vSwitch (OVS) service." -sudo service openvswitch-switch restart - -echo "Configuring Compute to use Networking." -conf=/etc/nova/nova.conf -iniset_sudo $conf DEFAULT network_api_class nova.network.neutronv2.api.API -iniset_sudo $conf DEFAULT security_group_api neutron -iniset_sudo $conf DEFAULT linuxnet_interface_driver neutron.agent.linux.interface.OVSInterfaceDriver -iniset_sudo $conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver - - -iniset_sudo $conf neutron url http://controller-mgmt:9696 -iniset_sudo $conf neutron auth_strategy keystone -iniset_sudo $conf neutron admin_auth_url http://controller-mgmt:35357/v2.0 -iniset_sudo $conf neutron admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf neutron admin_username "$neutron_admin_user" -iniset_sudo $conf neutron admin_password "$neutron_admin_password" - -echo "Restarting the Compute service." -sudo service nova-compute restart - -echo "Restarting the OVS agent." -sudo service neutron-plugin-openvswitch-agent restart diff --git a/labs/scripts/ubuntu/setup_neutron_controller.sh b/labs/scripts/ubuntu/setup_neutron_controller.sh deleted file mode 100755 index 6ad1cd78..00000000 --- a/labs/scripts/ubuntu/setup_neutron_controller.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up OpenStack Networking (neutron) for controller node. -# http://docs.openstack.org/juno/install-guide/install/apt/content/neutron-controller-node.html -#------------------------------------------------------------------------------ - -echo "Setting up database for neutron." -setup_database neutron - -source "$CONFIG_DIR/admin-openstackrc.sh" - -neutron_admin_user=$(service_to_user_name neutron) -neutron_admin_password=$(service_to_user_password neutron) - -echo "Creating neutron user and giving it admin role under service tenant." -keystone user-create \ - --name "$neutron_admin_user" \ - --pass "$neutron_admin_password" - -keystone user-role-add \ - --user "$neutron_admin_user" \ - --tenant "$SERVICE_TENANT_NAME" \ - --role "$ADMIN_ROLE_NAME" - -echo "Registering neutron with keystone so that other services can locate it." -keystone service-create \ - --name neutron \ - --type network \ - --description "OpenStack Networking" - -neutron_service_id=$(keystone service-list | awk '/ network / {print $2}') -keystone endpoint-create \ - --service-id "$neutron_service_id" \ - --publicurl "http://controller-mgmt:9696" \ - --adminurl "http://controller-mgmt:9696" \ - --internalurl "http://controller-mgmt:9696" \ - --region "$REGION" - -echo "Installing neutron for controller node." -sudo apt-get install -y neutron-server neutron-plugin-ml2 python-neutronclient - -echo "Configuring neutron for controller node." - -function get_database_url { - local db_user=$(service_to_db_user neutron) - local db_password=$(service_to_db_password neutron) - local database_host=controller-mgmt - - echo "mysql://$db_user:$db_password@$database_host/neutron" -} - -database_url=$(get_database_url) - -echo "Setting database connection: $database_url." -conf=/etc/neutron/neutron.conf -iniset_sudo $conf database connection "$database_url" - -# Configure AMQP parameters -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -# Configuring [DEFAULT] section -iniset_sudo $conf DEFAULT auth_strategy keystone - -# Configuring [keystone_authtoken] section -iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf keystone_authtoken identity_uri "http://controller-mgmt:35357" -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$neutron_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$neutron_admin_password" - -# Configure network plugin parameters -iniset_sudo $conf DEFAULT core_plugin ml2 -iniset_sudo $conf DEFAULT service_plugins router -iniset_sudo $conf DEFAULT allow_overlapping_ips True - -nova_admin_user=$(service_to_user_name nova) -nova_admin_password=$(service_to_user_password nova) - -service_tenant_id=$(keystone tenant-get "$SERVICE_TENANT_NAME" | awk '/ id / {print $4}') -echo "Service tenant id: $service_tenant_id" - -# Configure nova related parameters -iniset_sudo $conf DEFAULT notify_nova_on_port_status_changes True -iniset_sudo $conf DEFAULT notify_nova_on_port_data_changes True -iniset_sudo $conf DEFAULT nova_url http://controller-mgmt:8774/v2 -iniset_sudo $conf DEFAULT nova_admin_auth_url http://controller-mgmt:35357/v2.0 -iniset_sudo $conf DEFAULT nova_region_name "$REGION" -iniset_sudo $conf DEFAULT nova_admin_username "$nova_admin_user" -iniset_sudo $conf DEFAULT nova_admin_tenant_id "$service_tenant_id" -iniset_sudo $conf DEFAULT nova_admin_password "$nova_admin_password" -iniset_sudo $conf DEFAULT verbose True - -echo "Configuring the OVS plug-in to use GRE tunneling." -conf=/etc/neutron/plugins/ml2/ml2_conf.ini - -# Edit the [ml2] section. -iniset_sudo $conf ml2 type_drivers flat,gre -iniset_sudo $conf ml2 tenant_network_types gre -iniset_sudo $conf ml2 mechanism_drivers openvswitch - -# Edit the [ml2_type_gre] section. -iniset_sudo $conf ml2_type_gre tunnel_id_ranges 1:1000 - -# Edit the [securitygroup] section. -iniset_sudo $conf securitygroup enable_security_group True -iniset_sudo $conf securitygroup enable_ipset True -iniset_sudo $conf securitygroup firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver - -echo "Configure Compute to use Networking" -conf=/etc/nova/nova.conf -iniset_sudo $conf DEFAULT network_api_class nova.network.neutronv2.api.API -iniset_sudo $conf DEFAULT security_group_api neutron -iniset_sudo $conf DEFAULT linuxnet_interface_driver neutron.agent.linux.interface.OVSInterfaceDriver -iniset_sudo $conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver - -iniset_sudo $conf neutron url http://controller-mgmt:9696 -iniset_sudo $conf neutron auth_strategy keystone -iniset_sudo $conf neutron admin_auth_url http://controller-mgmt:35357/v2.0 -iniset_sudo $conf neutron admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf neutron admin_username "$neutron_admin_user" -iniset_sudo $conf neutron admin_password "$neutron_admin_password" - -# service_neutron_metadata_proxy, neutron_metadata_proxy_shared_secret from: -# http://docs.openstack.org/juno/install-guide/install/apt/content/neutron-network-node.html -iniset_sudo $conf neutron service_metadata_proxy True -iniset_sudo $conf neutron metadata_proxy_shared_secret "$METADATA_SECRET" - -sudo neutron-db-manage \ - --config-file /etc/neutron/neutron.conf \ - --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ - upgrade juno - -echo "Restart nova services" -sudo service nova-api restart -sudo service nova-scheduler restart -sudo service nova-conductor restart - -echo "Restarting neutron service." -sudo service neutron-server restart - -echo "Verifying operation." -until neutron ext-list >/dev/null 2>&1; do - sleep 1 -done -neutron ext-list diff --git a/labs/scripts/ubuntu/setup_neutron_network.sh b/labs/scripts/ubuntu/setup_neutron_network.sh deleted file mode 100755 index ccb4c810..00000000 --- a/labs/scripts/ubuntu/setup_neutron_network.sh +++ /dev/null @@ -1,248 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/openstack" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up OpenStack Networking (neutron) for network node. -# http://docs.openstack.org/juno/install-guide/install/apt/content/neutron-network-node.html -#------------------------------------------------------------------------------ - -echo "Editing /etc/sysctl.conf: enable IP forwarding, disable RPF filter." -cat << SYSCTL | sudo tee -a /etc/sysctl.conf -# Enable IP forwarding -net.ipv4.ip_forward=1 -# Disable Reverse Path Forwarding filter (RFC 3704) -net.ipv4.conf.all.rp_filter=0 -net.ipv4.conf.default.rp_filter=0 -SYSCTL - -# Reload changed file -sudo sysctl -p - -echo "Installing networking components for network node." -sudo apt-get install -y neutron-plugin-ml2 neutron-plugin-openvswitch-agent \ - neutron-l3-agent neutron-dhcp-agent - -# neutron-l3-agent has just been installed and is about to start. We are also -# about to change its configuration file which tends to result in the agent -# starting up with our changed configuration before the external bridge is -# ready which ends with a misconfigured system (port with tag=4095). We can -# either wait here for neutron-l3-agent to start with the old configuration -# files, or shut it down now and start it with the new configuration files once -# configuration files _and_ the external bridge are ready. -echo "Stopping neutron-l3-agent for now." -sudo service neutron-l3-agent stop - -echo "Configuring neutron for network node." - -neutron_admin_user=$(service_to_user_name neutron) -neutron_admin_password=$(service_to_user_password neutron) - -conf=/etc/neutron/neutron.conf -echo "Configuring $conf." - -# Configure AMQP parameters -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -# Configuring [DEFAULT] section -iniset_sudo $conf DEFAULT auth_strategy keystone - -# Configuring [keystone_authtoken] section -iniset_sudo $conf keystone_authtoken auth_uri http://controller-mgmt:5000/v2.0 -iniset_sudo $conf keystone_authtoken identity_uri http://controller-mgmt:35357 -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$neutron_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$neutron_admin_password" - -# Configure network plugin parameters -iniset_sudo $conf DEFAULT core_plugin ml2 -iniset_sudo $conf DEFAULT service_plugins router -iniset_sudo $conf DEFAULT allow_overlapping_ips True - -iniset_sudo $conf DEFAULT verbose True - -echo "Configuring the OVS plug-in to use GRE tunneling." -conf=/etc/neutron/plugins/ml2/ml2_conf.ini - -# Under the ml2 section -iniset_sudo $conf ml2 type_drivers flat,gre -iniset_sudo $conf ml2 tenant_network_types gre -iniset_sudo $conf ml2 mechanism_drivers openvswitch - -iniset_sudo $conf ml2_type_flat flat_networks external - -# Under the ml2_type_gre section -iniset_sudo $conf ml2_type_gre tunnel_id_ranges 1:1000 - -# Under the securitygroup section -iniset_sudo $conf securitygroup enable_security_group True -iniset_sudo $conf securitygroup enable_ipset True -iniset_sudo $conf securitygroup firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver - -# Under the ovs section -iniset_sudo $conf ovs local_ip "$(hostname_to_ip network-data)" -iniset_sudo $conf ovs enable_tunneling True -iniset_sudo $conf ovs bridge_mappings external:br-ex - -iniset_sudo $conf agent tunnel_types gre - -echo "Configuring Layer-3 agent." -conf=/etc/neutron/l3_agent.ini -iniset_sudo $conf DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver -iniset_sudo $conf DEFAULT use_namespaces True -iniset_sudo $conf DEFAULT external_network_bridge br-ex -iniset_sudo $conf DEFAULT router_delete_namespaces True -iniset_sudo $conf DEFAULT verbose True - -echo "Configuring the DHCP agent" -conf=/etc/neutron/dhcp_agent.ini -iniset_sudo $conf DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver -iniset_sudo $conf DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq -iniset_sudo $conf DEFAULT use_namespaces True -iniset_sudo $conf DEFAULT dhcp_delete_namespaces True -iniset_sudo $conf DEFAULT verbose True -iniset_sudo $conf DEFAULT dnsmasq_config_file /etc/neutron/dnsmasq-neutron.conf - -# Configure a DNS server to be used by VM instances -if [ -n "${TENANT_VM_DNS_SERVER:-''}" ]; then - iniset_sudo $conf DEFAULT dnsmasq_dns_servers "$TENANT_VM_DNS_SERVER" -fi - -cat << DNSMASQ | sudo tee /etc/neutron/dnsmasq-neutron.conf -# Set interface MTU to 1454 (for instance, ssh authentication may fail -# otherwise due to GRE overhead) -dhcp-option-force=26,1454 - -# Override --no-hosts dnsmasq option supplied by neutron -addn-hosts=/etc/hosts - -# Log dnsmasq queries to syslog -log-queries - -# Verbose logging for DHCP -log-dhcp -DNSMASQ - -# Catch and ignore error status if no dnsmasq process is found (the default) -sudo killall dnsmasq||rc=$? - -echo "Configuring the metadata agent" -conf=/etc/neutron/metadata_agent.ini -iniset_sudo $conf DEFAULT auth_url http://controller-mgmt:5000/v2.0 -iniset_sudo $conf DEFAULT auth_region "$REGION" -iniset_sudo $conf DEFAULT admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf DEFAULT admin_user "$neutron_admin_user" -iniset_sudo $conf DEFAULT admin_password "$neutron_admin_password" -iniset_sudo $conf DEFAULT nova_metadata_ip "$(hostname_to_ip controller-mgmt)" -iniset_sudo $conf DEFAULT metadata_proxy_shared_secret "$METADATA_SECRET" -iniset_sudo $conf DEFAULT verbose True - -# The next two steps according to the install-guide (configuring -# service_metadata_proxy and metadata_proxy_shared_secret) have already been -# done in setup_neutron_controller.sh. - -# XXX The install-guide wants us to restart nova-api on controller now, but we -# ignore that for now; by default, the controller gets rebooted for a -# snapshot anyway. - -echo "Restarting the Open vSwitch (OVS) service." -sudo service openvswitch-switch restart - -echo "Adding the external bridge" -sudo ovs-vsctl add-br br-ex - -echo "Adding port to external bridge." -sudo ovs-vsctl add-port br-ex eth3 - -network_api_ip=$(hostname_to_ip network-api) - -echo "Moving network-api IP address from eth3 to a switch-internal device." -sudo ifconfig eth3 0.0.0.0 -sudo ifconfig br-ex "$network_api_ip" - -echo "Making the IP address move reboot-safe." -sudo sed -i "s/$network_api_ip/0.0.0.0/" /etc/network/interfaces -cat << INTERFACES | sudo tee -a /etc/network/interfaces - -auto br-ex -iface br-ex inet static - address $network_api_ip - netmask 255.255.255.0 -INTERFACES - -# Check if we can get to the API network again -ping -c 1 controller-api - -echo "Restarting the network service." -sudo service neutron-plugin-openvswitch-agent restart -sudo service neutron-l3-agent restart - -echo -n "Checking VLAN tags." -# Wait for "tag:" to show up -until sudo ovs-vsctl show|grep tag:; do - echo -n "." - sleep 1 -done -if sudo ovs-vsctl show|grep "tag: 4095"; then - # tag: 4095 indicates an error - echo >&2 "ERROR: port is in limbo and won't recover:" - grep tag=4095 /etc/openvswitch/conf.db >&2 - exit 1 -fi - -echo -n "Getting router namespace." -until ip netns|grep qrouter; do - echo -n "." - sleep 1 -done -nsrouter=$(ip netns|grep qrouter) - -sudo service neutron-dhcp-agent restart - -echo -n "Getting DHCP namespace." -until ip netns|grep qdhcp; do - echo -n "." - sleep 1 -done -nsdhcp=$(ip netns|grep qdhcp) - -echo -n "Waiting for interface qr-* in router namespace." -until sudo ip netns exec "$nsrouter" ip addr|grep -Po "(?<=: )qr-.*(?=:)"; do - echo -n "." - sleep 1 -done - -echo -n "Waiting for interface qg-* in router namespace." -until sudo ip netns exec "$nsrouter" ip addr|grep -Po "(?<=: )qg-.*(?=:)"; do - echo -n "." - sleep 1 -done - -echo -n "Waiting for interface tap* in DHCP namespace." -until sudo ip netns exec "$nsdhcp" ip addr|grep -Po "(?<=: )tap.*(?=:)"; do - echo -n "." - sleep 1 -done - -sudo service neutron-metadata-agent restart - -#------------------------------------------------------------------------------ -# Verify the Networking Service installation -#------------------------------------------------------------------------------ - -echo "Verifying neutron installation." - -# Load keystone credentials -source "$CONFIG_DIR/admin-openstackrc.sh" - -echo "neutron agent-list" -neutron agent-list diff --git a/labs/scripts/ubuntu/setup_nova_compute.sh b/labs/scripts/ubuntu/setup_nova_compute.sh deleted file mode 100755 index 99c60197..00000000 --- a/labs/scripts/ubuntu/setup_nova_compute.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/admin-openstackrc.sh" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Set up OpenStack Compute (nova) for compute node. -# http://docs.openstack.org/juno/install-guide/install/apt/content/ch_nova.html#nova-compute-install -#------------------------------------------------------------------------------ - -echo "Installing nova for compute node." -# We can't use KVM inside VirtualBox. -sudo apt-get install -y nova-compute-qemu sysfsutils - -echo "Configuring nova for compute node." - -conf=/etc/nova/nova.conf -echo "Configuring $conf." - -# Configure RabbitMQ variables -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -# Configuring [DEFAULT] section -iniset_sudo $conf DEFAULT auth_strategy keystone - -nova_admin_user=$(service_to_user_name nova) -nova_admin_password=$(service_to_user_password nova) - -# Configure [keystone_authtoken] section -iniset_sudo $conf keystone_authtoken auth_uri http://controller-mgmt:5000/v2.0 -iniset_sudo $conf keystone_authtoken identity_uri http://controller-mgmt:35357 -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$nova_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$nova_admin_password" - -iniset_sudo $conf DEFAULT my_ip "$(hostname_to_ip compute-mgmt)" - -iniset_sudo $conf DEFAULT vnc_enabled True -iniset_sudo $conf DEFAULT vncserver_listen 0.0.0.0 -iniset_sudo $conf DEFAULT vncserver_proxyclient_address compute-mgmt -iniset_sudo $conf DEFAULT novncproxy_base_url http://"$(hostname_to_ip controller-api)":6080/vnc_auto.html - -iniset_sudo $conf glance host controller-mgmt - -iniset_sudo $conf DEFAULT verbose True - -# Configure nova-compute.conf -conf=/etc/nova/nova-compute.conf -echo -n "Hardware acceleration for virtualization: " -if sudo egrep -q '(vmx|svm)' /proc/cpuinfo; then - echo "available." -else - echo "not available." - iniset_sudo $conf libvirt virt_type qemu -fi -echo "Config: $(sudo grep virt_type $conf)" - -echo "Restarting nova services." -sudo service nova-compute restart - -# Remove SQLite database created by Ubuntu package for nova. -sudo rm -v /var/lib/nova/nova.sqlite diff --git a/labs/scripts/ubuntu/setup_nova_controller.sh b/labs/scripts/ubuntu/setup_nova_controller.sh deleted file mode 100755 index cc12c787..00000000 --- a/labs/scripts/ubuntu/setup_nova_controller.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Install Compute controller services -# http://docs.openstack.org/juno/install-guide/install/apt/content/ch_nova.html#nova-controller-install -#------------------------------------------------------------------------------ - -echo "Setting up database for nova." -setup_database nova - -echo "Sourcing the admin credentials." -source "$CONFIG_DIR/admin-openstackrc.sh" - -nova_admin_user=$(service_to_user_name nova) -nova_admin_password=$(service_to_user_password nova) - -echo "Creating nova user and giving it admin role under service tenant." -keystone user-create \ - --name "$nova_admin_user" \ - --pass "$nova_admin_password" - -keystone user-role-add \ - --user "$nova_admin_user" \ - --tenant "$SERVICE_TENANT_NAME" \ - --role "$ADMIN_ROLE_NAME" - -echo "Registering nova with keystone so that other services can locate it." -keystone service-create \ - --name nova \ - --type compute \ - --description "OpenStack Compute" - -nova_service_id=$(keystone service-list | awk '/ compute / {print $2}') -keystone endpoint-create \ - --service-id "$nova_service_id" \ - --publicurl 'http://controller-api:8774/v2/%(tenant_id)s' \ - --internalurl 'http://controller-mgmt:8774/v2/%(tenant_id)s' \ - --adminurl 'http://controller-mgmt:8774/v2/%(tenant_id)s' \ - --region "$REGION" - -echo "Installing nova for controller node." -sudo apt-get install -y nova-api nova-cert nova-conductor nova-consoleauth \ - nova-novncproxy nova-scheduler python-novaclient - -function get_database_url { - local db_user=$(service_to_db_user nova) - local db_password=$(service_to_db_password nova) - local database_host=controller-mgmt - - echo "mysql://$db_user:$db_password@$database_host/nova" -} - -database_url=$(get_database_url) - -conf=/etc/nova/nova.conf - -echo "Setting database connection: $database_url." -iniset_sudo $conf database connection "$database_url" - -echo "Configuring [DEFAULT] section in /etc/nova/nova.conf for controller node." - -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -iniset_sudo $conf DEFAULT auth_strategy keystone - -iniset_sudo $conf keystone_authtoken auth_uri http://controller-mgmt:5000 -iniset_sudo $conf keystone_authtoken identity_uri http://controller-mgmt:35357 -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$nova_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$nova_admin_password" - -iniset_sudo $conf DEFAULT my_ip "$(hostname_to_ip controller-mgmt)" -iniset_sudo $conf DEFAULT vncserver_listen controller-mgmt -iniset_sudo $conf DEFAULT vncserver_proxyclient_address controller-mgmt - -iniset_sudo $conf glance host controller-mgmt -iniset_sudo $conf DEFAULT verbose True - -echo "Creating the database tables for nova." -sudo nova-manage db sync - -echo "Restarting nova services." -declare -a components=(nova-api nova-cert nova-consoleauth nova-scheduler - nova-conductor nova-novncproxy) -for component in "${components[@]}"; do - echo "Restarting $component" - sudo service "$component" restart -done - -# Remove SQLite database created by Ubuntu package for nova. -sudo rm -v /var/lib/nova/nova.sqlite - -#------------------------------------------------------------------------------ -# Verify the Compute controller installation -#------------------------------------------------------------------------------ - -echo "Verify nova service status." -# This call needs root privileges for read access to /etc/nova/nova.conf. -echo "sudo nova-manage service list" -sudo nova-manage service list - -echo "nova image-list" -nova image-list - -echo "nova list-extensions" -nova list-extensions diff --git a/labs/scripts/ubuntu/setup_telemetry_compute.sh b/labs/scripts/ubuntu/setup_telemetry_compute.sh deleted file mode 100755 index ad5009da..00000000 --- a/labs/scripts/ubuntu/setup_telemetry_compute.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/openstack" -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Install the Telemetry service -# http://docs.openstack.org/juno/install-guide/install/apt/content/ceilometer-nova.html -#------------------------------------------------------------------------------ - -echo "Installing ceilometer." -sudo apt-get install -y ceilometer-agent-compute - -ceilometer_admin_user=$(service_to_user_name ceilometer) -ceilometer_admin_password=$(service_to_user_password ceilometer) - -echo "Configuring ceilometer.conf." -conf=/etc/ceilometer/ceilometer.conf - -iniset_sudo $conf publisher metering_secret "$METERING_SECRET" - - -# Configure RabbitMQ variables -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf keystone_authtoken identity_uri "http://controller-mgmt:35357" -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$ceilometer_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$ceilometer_admin_password" - -iniset_sudo $conf service_credentials os_auth_url "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf service_credentials os_username "$ceilometer_admin_user" -iniset_sudo $conf service_credentials os_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf service_credentials os_password "$ceilometer_admin_password" -iniset_sudo $conf service_credentials os_endpoint_type internalURL -iniset_sudo $conf service_credentials os_region_name "$REGION" - - -iniset_sudo $conf DEFAULT verbose True - -echo "Configuring nova.conf." -conf=/etc/ceilometer/ceilometer.conf - -iniset_sudo $conf DEFAULT instance_usage_audit True -iniset_sudo $conf DEFAULT instance_usage_audit_period hour -iniset_sudo $conf DEFAULT notify_on_state_change vm_and_task_state -iniset_sudo $conf DEFAULT notification_driver messagingv2 - -echo "Restarting telemetry service." -sudo service ceilometer-agent-compute restart - -echo "Restarting compute service." -sudo service nova-compute restart - -#------------------------------------------------------------------------------ -# Configure the Block Storage service(cinder-volume) -# http://docs.openstack.org/juno/install-guide/install/apt/content/ceilometer-cinder.html -#------------------------------------------------------------------------------ - -# Configure the Block Storage Service to send notifications to the message bus - -echo "Configuring cinder.conf." -conf=/etc/cinder/cinder.conf - -iniset_sudo $conf DEFAULT control_exchange cinder -iniset_sudo $conf DEFAULT notification_driver messagingv2 - -echo "Restarting cinder-volumes service." -sudo service cinder-volume restart - -#------------------------------------------------------------------------------ -# Verify the Telemetry installation -# http://docs.openstack.org/juno/install-guide/install/apt/content/ceilometer-verify.html -#------------------------------------------------------------------------------ - -echo "Verifying the telemetry installation." - -AUTH="source $CONFIG_DIR/admin-openstackrc.sh" - -echo "Waiting for ceilometer to start." -until node_ssh controller-mgmt "$AUTH; ceilometer meter-list" >/dev/null 2>&1; do - sleep 1 -done - -echo "List available meters." -node_ssh controller-mgmt "$AUTH; ceilometer meter-list" - -echo "Download an image from the Image Service." -img_name=$(basename "$CIRROS_URL" -disk.img) -node_ssh controller-mgmt "$AUTH; glance image-download \"$img_name\" > /tmp/cirros.img" - -echo "List available meters again to validate detection of the image download." -node_ssh controller-mgmt "$AUTH; ceilometer meter-list" - -echo "Retrieve usage statistics from the image.download meter." -node_ssh controller-mgmt "$AUTH; ceilometer statistics -m image.download -p 60" diff --git a/labs/scripts/ubuntu/setup_telemetry_controller.sh b/labs/scripts/ubuntu/setup_telemetry_controller.sh deleted file mode 100755 index 8751e004..00000000 --- a/labs/scripts/ubuntu/setup_telemetry_controller.sh +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/credentials" -source "$LIB_DIR/functions.guest" -source "$CONFIG_DIR/openstack" - -exec_logfile - -indicate_current_auto - -#------------------------------------------------------------------------------ -# Install the Telemetry service -# http://docs.openstack.org/juno/install-guide/install/apt/content/ceilometer-controller-install.html -#------------------------------------------------------------------------------ - -echo "Setting up database for telemetry." - -echo "Installing the MongoDB packages." -sudo apt-get install -y mongodb-server mongodb-clients python-pymongo - -echo "Configuring mongodb.conf." -conf=/etc/mongodb.conf -iniset_sudo_no_section $conf bind_ip "$(hostname_to_ip controller-mgmt)" -iniset_sudo_no_section $conf smallfiles true - -echo "Restarting mongodb." -sudo service mongodb restart - -echo "Waiting for mongodb to start." -while sudo service mongodb status 2>/dev/null | grep "stop"; do - sleep 5 - echo -n . -done - -ceilometer_admin_user=$(service_to_user_name ceilometer) -ceilometer_admin_password=$(service_to_user_password ceilometer) - -mongodb_user=$(service_to_db_user ceilometer) -mongodb_password=$(service_to_db_password ceilometer) - -echo "Creating the ceilometer database." -mongo --host "$(hostname_to_ip controller-mgmt)" --eval " - db = db.getSiblingDB(\"ceilometer\"); - db.addUser({user: \"${mongodb_user}\", - pwd: \"${mongodb_password}\", - roles: [ \"readWrite\", \"dbAdmin\" ]})" - -echo "Sourcing the admin credentials." -source "$CONFIG_DIR/admin-openstackrc.sh" - -echo "Creating ceilometer user and giving it admin role under service tenant." -keystone user-create \ - --name "$ceilometer_admin_user" \ - --pass "$ceilometer_admin_password" \ - -keystone user-role-add \ - --user "$ceilometer_admin_user" \ - --tenant "$SERVICE_TENANT_NAME" \ - --role "$ADMIN_ROLE_NAME" - -echo "Registering ceilometer with keystone so that other services can locate it." -keystone service-create \ - --name ceilometer \ - --type metering \ - --description "Telemetry" - -ceilometer_service_id=$(keystone service-list | awk '/ metering / {print $2}') -keystone endpoint-create \ - --service-id "$ceilometer_service_id" \ - --publicurl "http://controller-api:8777" \ - --internalurl "http://controller-mgmt:8777" \ - --adminurl "http://controller-mgmt:8777" \ - --region "$REGION" - -echo "Installing ceilometer." -sudo apt-get install -y ceilometer-api ceilometer-collector \ - ceilometer-agent-central \ - ceilometer-agent-notification \ - ceilometer-alarm-evaluator \ - ceilometer-alarm-notifier \ - python-ceilometerclient - -function get_database_url { - local db_user=$(service_to_db_user ceilometer) - local db_password=$(service_to_db_password ceilometer) - local database_host=controller-mgmt - - echo "mongodb://$db_user:$db_password@$database_host:27017/ceilometer" -} - -database_url=$(get_database_url) -echo "Database connection: $database_url." - -echo "Configuring ceilometer.conf." -conf=/etc/ceilometer/ceilometer.conf -iniset_sudo $conf database connection "$database_url" - -# Configure RabbitMQ variables -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -# Configure the [DEFAULT] section -iniset_sudo $conf DEFAULT auth_strategy keystone - -iniset_sudo $conf keystone_authtoken auth_uri "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf keystone_authtoken identity_uri "http://controller-mgmt:35357" -iniset_sudo $conf keystone_authtoken admin_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf keystone_authtoken admin_user "$ceilometer_admin_user" -iniset_sudo $conf keystone_authtoken admin_password "$ceilometer_admin_password" - -iniset_sudo $conf service_credentials os_auth_url "http://controller-mgmt:5000/v2.0" -iniset_sudo $conf service_credentials os_username "$ceilometer_admin_user" -iniset_sudo $conf service_credentials os_tenant_name "$SERVICE_TENANT_NAME" -iniset_sudo $conf service_credentials os_password "$ceilometer_admin_password" - -iniset_sudo $conf publisher metering_secret "$METERING_SECRET" - -iniset_sudo $conf DEFAULT verbose True - - -echo "Restarting telemetry service." -sudo service ceilometer-agent-central restart -sudo service ceilometer-agent-notification restart -sudo service ceilometer-api restart -sudo service ceilometer-collector restart -sudo service ceilometer-alarm-evaluator restart -sudo service ceilometer-alarm-notifier restart - -#------------------------------------------------------------------------------ -# Configure the Image service -# http://docs.openstack.org/juno/install-guide/install/apt/content/ceilometer-glance.html -#------------------------------------------------------------------------------ - -# Configure the Image Service to send notifications to the message bus - -echo "Configuring glance-api.conf." -conf=/etc/glance/glance-api.conf - -iniset_sudo $conf DEFAULT notification_driver messagingv2 -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -echo "Configuring glance-registry.conf." -conf=/etc/glance/glance-registry.conf - -iniset_sudo $conf DEFAULT notification_driver messagingv2 -iniset_sudo $conf DEFAULT rpc_backend rabbit -iniset_sudo $conf DEFAULT rabbit_host controller-mgmt -iniset_sudo $conf DEFAULT rabbit_password "$RABBIT_PASSWORD" - -sudo service glance-registry restart -sudo service glance-api restart - -#------------------------------------------------------------------------------ -# Configure the Block Storage service -# http://docs.openstack.org/juno/install-guide/install/apt/content/ceilometer-cinder.html -#------------------------------------------------------------------------------ - -# Configure the Block Storage Service to send notifications to the message bus - -echo "Configuring cinder.conf." -conf=/etc/cinder/cinder.conf - -iniset_sudo $conf DEFAULT control_exchange cinder -iniset_sudo $conf DEFAULT notification_driver messagingv2 - -echo "Restarting cinder services." -sudo service cinder-api restart -sudo service cinder-scheduler restart diff --git a/labs/scripts/yum_init.sh b/labs/scripts/yum_init.sh deleted file mode 100755 index 238e10b9..00000000 --- a/labs/scripts/yum_init.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/openstack" -# Pick up VM_PROXY -source "$CONFIG_DIR/localrc" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -function set_yum_proxy { - local YUM_FILE=/etc/yum.conf - if [ -z "${VM_PROXY-}" ]; then - return 0; - fi - echo "proxy=${VM_PROXY}" | sudo tee -a $YUM_FILE -} - -set_yum_proxy - -# Enable RDO repo -if [[ ${OPENSTACK_RELEASE:-} = icehouse ]]; then - sudo yum install "http://repos.fedorapeople.org/repos/openstack/openstack-$OPENSTACK_RELEASE/rdo-release-$OPENSTACK_RELEASE-3.noarch.rpm" -else - echo 2>&1 "ERROR Unknown OpenStack release." - return 1 -fi diff --git a/labs/scripts/yum_update.sh b/labs/scripts/yum_update.sh deleted file mode 100755 index d32128e2..00000000 --- a/labs/scripts/yum_update.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/openstack" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -# Upgrade installed packages -sudo yum -y update diff --git a/labs/scripts/zero_empty.sh b/labs/scripts/zero_empty.sh deleted file mode 100755 index d531a3c1..00000000 --- a/labs/scripts/zero_empty.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$LIB_DIR/functions.guest" - -indicate_current_auto - -exec_logfile - -# Fill unused disk space with zeroes (the disk image is easier to compress when -# it doesn't contain leftovers from deleted files) -zero_empty_space diff --git a/labs/tools/README.rst b/labs/tools/README.rst deleted file mode 100644 index 64a1a02f..00000000 --- a/labs/tools/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -The tools in this directory are for advanced users and developers. They -can be used to test changes in the training-cluster. diff --git a/labs/tools/downloader.js b/labs/tools/downloader.js deleted file mode 100644 index 597c6c16..00000000 --- a/labs/tools/downloader.js +++ /dev/null @@ -1,13 +0,0 @@ -/* Taken from http://superuser.com/a/536400 */ -/* Use: cscript /nologo downloader.js */ -/* Used by Windows batch scripts to download distro ISO image */ - -var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1"); -WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false); -WinHttpReq.Send(); - -BinStream = new ActiveXObject("ADODB.Stream"); -BinStream.Type = 1; -BinStream.Open(); -BinStream.Write(WinHttpReq.ResponseBody); -BinStream.SaveToFile("downloaded.bin"); diff --git a/labs/tools/get_upstart_logs.sh b/labs/tools/get_upstart_logs.sh deleted file mode 100755 index 26caac23..00000000 --- a/labs/tools/get_upstart_logs.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/deploy.osbash" -source "$OSBASH_LIB_DIR/functions-host.sh" - -CONTROLLER_PORT=2230 -NETWORK_PORT=2231 -COMPUTE_PORT=2232 - -function usage { - echo "Purpose: Get logs from cluster node VMs." - echo "Usage: $0 []" - exit 1 -} - -if [ $# = 0 ]; then - usage -else - RESULTS_DIR=$1 - if [ ! -d "$RESULTS_DIR" ]; then - echo >&2 "Error: no such directory: $RESULTS_DIR" - exit 1 - fi -fi - -for port in "$CONTROLLER_PORT" "$NETWORK_PORT" "$COMPUTE_PORT"; do - port_dir=$RESULTS_DIR/$port - mkdir "$port_dir" - vm_ssh "$port" "sudo tar cf - -C /var/log upstart" | tar xf - -C "$port_dir" -done - -if vm_ssh "$CONTROLLER_PORT" 'ls log/test-*.*' >/dev/null 2>&1; then - vm_ssh "$CONTROLLER_PORT" 'cd log; tar cf - test-*.*' | tar xf - -C "$RESULTS_DIR" - vm_ssh "$CONTROLLER_PORT" 'rm log/test-*.*' -fi diff --git a/labs/tools/repeat-test.sh b/labs/tools/repeat-test.sh deleted file mode 100755 index 09ac330f..00000000 --- a/labs/tools/repeat-test.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/deploy.osbash" -source "$CONFIG_DIR/provider.virtualbox" -source "$OSBASH_LIB_DIR/functions-host.sh" -source "$OSBASH_LIB_DIR/virtualbox-functions.sh" - -OSBASH=exec_cmd - -LOG_NAME=test.log -RESULTS_ROOT=$LOG_DIR/test-results - -CONTROLLER_SNAPSHOT="controller_node_installed" -TEST_SCRIPT=$TOP_DIR/scripts/test/launch_instance.sh - -VERBOSE=${VERBOSE:=1} - -function usage { - echo "Usage: $0 {-b|-c|-t } [-s '']" - echo "" - echo "-h Help" - echo "-c Restore node VMs to current snapshot for each test" - echo "-t SNAP Restore cluster to target snapshot for each test" - echo "-s NODES Start each named node VM after restoring the cluster" - echo "-b Rebuild cluster for each test, from scratch or snapshot" - echo " (osbash.sh -b cluster [...])" -} - -while getopts :bchs:t: opt; do - case $opt in - b) - REBUILD=yes - ;; - c) - CURRENT=yes - ;; - h) - usage - exit 0 - ;; - s) - START_VMS=$OPTARG - ;; - t) - TARGET_SNAPSHOT=$OPTARG - if ! "$TOP_DIR/tools/restore-cluster.sh" -l | - grep -q "Name: $TARGET_SNAPSHOT "; then - echo >&2 "No snapshot named $TARGET_SNAPSHOT found." - exit 1 - fi - ;; - :) - echo "Error: -$OPTARG needs argument" - ;; - ?) - echo "Error: invalid option -$OPTARG" - echo - usage - exit 1 - ;; - esac -done - -if [ -z "${REBUILD:-}" -a -z "${CURRENT:-}" -a -z "${TARGET_SNAPSHOT:-}" ]; then - usage - exit 1 -fi - -# Remove processed options from arguments -shift $(( OPTIND - 1 )); - -mkdir -p "$RESULTS_ROOT" - -while [ : ]; do - dir_name=$(get_next_prefix "$RESULTS_ROOT" "") - echo "Starting test $dir_name." - dir=$RESULTS_ROOT/$dir_name - mkdir -p "$dir" - - ( - cd "$TOP_DIR" - - if [ -n "${TARGET_SNAPSHOT:-}" ]; then - "$TOP_DIR/tools/restore-cluster.sh" -t "$TARGET_SNAPSHOT" - if [ -n "${START_VMS:-}" ]; then - # Start VMs as requested by user - for vm_name in $START_VMS; do - echo >&2 "$0: booting node $vm_name." - vbox_boot "$vm_name" - # Sleeping for 10 s fixes some problems, but it might be - # better to fix client scripts to wait for the services they - # need instead of just failing. - done - fi - fi - - if [ -n "${REBUILD:-}" ]; then - if [ -n "${TARGET_SNAPSHOT:-}" ]; then - "$TOP_DIR/osbash.sh" -t "$TARGET_SNAPSHOT" -b cluster - else - "$TOP_DIR/osbash.sh" -b cluster - fi - fi - - echo "Running test. Log file: $dir/$LOG_NAME" - rc=0 - TEST_ONCE=$TOP_DIR/tools/test-once.sh - if [ "${VERBOSE:-}" -eq 1 ]; then - "$TEST_ONCE" "$TEST_SCRIPT" 2>&1 | tee "$dir/$LOG_NAME" || rc=$? - else - "$TEST_ONCE" "$TEST_SCRIPT" > "$dir/$LOG_NAME" 2>&1 || rc=$? - fi - - if [ $rc -eq 0 ]; then - echo "Test done." - else - echo "Failed to run test. Aborting." - exit 1 - fi - ) - - echo "Copying osbash log files into $dir." - mv "$LOG_DIR/"*.auto "$LOG_DIR/"*.log "$dir" - - echo "Copying upstart log files into $dir." - "$TOP_DIR/tools/get_upstart_logs.sh" "$dir" -done diff --git a/labs/tools/restore-cluster.sh b/labs/tools/restore-cluster.sh deleted file mode 100755 index 22ee1e12..00000000 --- a/labs/tools/restore-cluster.sh +++ /dev/null @@ -1,155 +0,0 @@ -#!/bin/bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/deploy.osbash" -source "$CONFIG_DIR/provider.virtualbox" -source "$OSBASH_LIB_DIR/functions-host.sh" -source "$OSBASH_LIB_DIR/virtualbox-functions.sh" - -OSBASH=exec_cmd - -VM_LIST="controller network compute" - -function usage { - # Setting to empty string selects latest (current snapshot) - echo "Usage: $0 {-l|-c|-t } [-s]" - echo "" - echo "-h Help" - echo "-l List snapshots for node VMs" - echo "-c Restore cluster node VMs to current snapshot" - echo "-t SNAP Restore cluster to target snapshot" - echo "-s Start each node VMs after restoring it" - exit -} - -function list_snapshots { - for vm_name in $VM_LIST; do - echo -e "Snapshot list for $vm_name node:" - vboxmanage snapshot "$vm_name" list - echo - done - exit 0 -} - -while getopts :chlst: opt; do - case $opt in - c) - CURRENT=yes - ;; - h) - usage - ;; - l) - list_snapshots - ;; - s) - START=yes - ;; - t) - TARGET_SNAPSHOT=$OPTARG - ;; - :) - echo "Error: -$OPTARG needs argument" - ;; - ?) - echo "Error: invalid option -$OPTARG" - echo - usage - ;; - esac -done - -# Remove processed options from arguments -shift $(( OPTIND - 1 )); - -if [ $# -ne 0 ]; then - usage -elif [ -z "${TARGET_SNAPSHOT:-}" -a -z "${CURRENT:-""}" ]; then - echo - echo "Error: no target snapshot given." - echo - usage -elif [ -n "{$TARGET_SNAPSHOT:-}" -a -n "${CURRENT:-""}" ]; then - echo - echo "Error: conflicting options: target snapshot name and -c." - echo - usage -fi - -# Find target_snapshot in scripts_cfg and set global *_SNAPSHOT variables -# to the correct snapshot name for each node (to allow building from there) -function set_snapshot_vars { - local target_snapshot=$1 - - local found=0 - local scripts_cfg="$TOP_DIR/config/scripts.ubuntu_cluster" - - while read -r line; do - if [[ $line =~ ^cmd\ snapshot.*-n\ ([^ ]*)\ (.*) ]]; then - # Node name (e.g. controller) - node=${BASH_REMATCH[1]} - - # Snapshot name (e.g. keystone_installed) - snapshot=${BASH_REMATCH[2]} - - # Global variable name (e.g. CONTROLLER_SNAPSHOT) - # Can't use ${node,,} (OS X bash version is only 3.2) - var_name=$(echo "$node"|tr "a-z" "A-Z")_SNAPSHOT - - if [ "$snapshot" = "$target_snapshot" ]; then - # Can't use associative arrays (OS X bash version is only 3.2) - eval "${var_name}=$snapshot" - - found=1 - elif [ $found -eq 0 ]; then - eval "${var_name}=$snapshot" - fi - fi - done < "$scripts_cfg" - - if [ $found -eq 0 ]; then - echo "ERROR: snapshot '$target_snapshot' not found" - exit 1 - fi -} - -function restore_current_snapshot { - local vm_name=$1 - vboxmanage snapshot "$vm_name" restorecurrent -} - -function restore_named_snapshot { - local vm_name=$1 - local snapshot=$2 - vboxmanage snapshot "$vm_name" restore "$snapshot" -} - -if [ -n "$TARGET_SNAPSHOT" ]; then - set_snapshot_vars "$TARGET_SNAPSHOT" -fi - -for vm_name in $VM_LIST; do - vm_power_off "$vm_name" - vm_wait_for_shutdown "$vm_name" - - if [ "${CURRENT:-""}" = "yes" ]; then - restore_current_snapshot "$vm_name" - if [ "${START:-""}" = "yes" ]; then - vbox_boot "$vm_name" - fi - else - # Global variable name (e.g. CONTROLLER_SNAPSHOT) - # (use tr due to OS X bash limitation) - var_name=$(echo "$vm_name"|tr "a-z" "A-Z")_SNAPSHOT - if [ -z "${!var_name:=""}" ]; then - vm_delete "$vm_name" - else - restore_named_snapshot "$vm_name" "${!var_name}" - if [ "${START:-""}" = "yes" ]; then - vbox_boot "$vm_name" - fi - fi - fi -done - diff --git a/labs/tools/test-once.sh b/labs/tools/test-once.sh deleted file mode 100755 index 2d8ff6d3..00000000 --- a/labs/tools/test-once.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -set -o errexit -o nounset -TOP_DIR=$(cd "$(dirname "$0")/.." && pwd) -source "$TOP_DIR/config/paths" -source "$CONFIG_DIR/deploy.osbash" -source "$OSBASH_LIB_DIR/functions-host.sh" - -# Get remote ssh port of target node (VM_SSH_PORT) -source "$CONFIG_DIR/config.controller" - -if [ $# -eq 0 ]; then - echo "Purpose: Copy one script to target node and execute it via ssh." - echo "Usage: $0