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
This commit is contained in:
parent
18b4447613
commit
dc0a6d4bdb
129
labs/HACKING.rst
129
labs/HACKING.rst
@ -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 <https://www.virtualbox.org/>`_. 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 <http://devstack.org/>`_.
|
||||
|
||||
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-\*-<distro>.vdi), the VM export images (oslabs-<distro>.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 <https://github.com/openstack-dev/bashate>`_ (must pass)
|
||||
- `shellcheck <https://github.com/koalaman/shellcheck.git>`_ (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.
|
||||
|
198
labs/README.md
198
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
|
||||
|
@ -1,2 +0,0 @@
|
||||
osbash/wbatch copy shell scripts (*.sh) into this directory to have them
|
||||
automatically executed (and removed) upon boot.
|
@ -1,2 +0,0 @@
|
||||
The configuration files in this directory are used by osbash/wbatch and
|
||||
by scripts running inside the VMs (scripts directory).
|
@ -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"
|
@ -1,4 +0,0 @@
|
||||
# Base disk VM configuration. Used by osbash/wbatch (host and guest).
|
||||
|
||||
# Port forwarding
|
||||
VM_SSH_PORT=2229
|
@ -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
|
@ -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
|
@ -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
|
@ -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:
|
@ -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"
|
@ -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:
|
@ -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
|
@ -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:
|
@ -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:
|
@ -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:
|
@ -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:
|
@ -1,2 +0,0 @@
|
||||
# Scripts for Fedora installations
|
||||
cmd queue yum_init.sh
|
@ -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
|
@ -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
|
||||
#==============================================================================
|
@ -1 +0,0 @@
|
||||
TODO: Getting started section will lie in this section.
|
@ -1,26 +0,0 @@
|
||||
OsBash
|
||||
------
|
||||
|
||||
About
|
||||
-----
|
||||
|
||||
By default, osbash will put into this directory its base disk images
|
||||
(base-*-<distro>.vdi), the VM export images (oslabs-<distro>.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
|
@ -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.
|
File diff suppressed because it is too large
Load Diff
@ -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:
|
@ -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:
|
@ -1,2 +0,0 @@
|
||||
This directory contains the insecure ssh keys used by osbash for logging into
|
||||
the node VMs.
|
@ -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-----
|
@ -1 +0,0 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSnGKD4VTg7KhomNhFxjO8VfvSHZJzuFSvthK9jIeH2+M45QTR4batY+4qOtq9DzGgjsSVp6hP2QSfcVbZtSL3jjh3sjSN3ErT4UKeqRehNX/bCKmdHg0eK5m1EbPpJlY+fzSYj4qDw5x8rDeFoHVHydh2jyRFdd39/McaNQOYuQRmZbR9f7IISH99isIxmosYn3PeAfIVAcLqT9OcYPgPKJ+tsTvbFkYE2hOiS7Eek0C90KOVbJP01Vz3b/ccEYQ5WFlL0oqFkesVQ5I4cth1wMG26glbZO5SVT0GAldMwvm+H/wnVhQ/AjF5NmuIEGn45K4/c0csoIzWcKduPEyf osbash insecure public key
|
@ -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 <src_dir> <file> <new_name>
|
||||
# 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 <file> [<file> ...]
|
||||
# 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 <gui_type>] [-n <node_name>]
|
||||
# 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 <node_name>] <snapshot_name>
|
||||
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 <node_name>]
|
||||
get_cmd_options $args
|
||||
echo >&2 vm_wait_for_shutdown "$vm_name"
|
||||
vm_wait_for_shutdown "$vm_name"
|
||||
;;
|
||||
snapshot_cycle)
|
||||
# Format: snapshot_cycle [-g <gui_type>] [-n <node_name>]
|
||||
# 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 <node_name>]
|
||||
get_cmd_options $args
|
||||
echo >&2 vm_init_node "$vm_name"
|
||||
vm_init_node "$vm_name"
|
||||
;;
|
||||
queue)
|
||||
# Queue a script for autostart
|
||||
# Format: queue <script_name>
|
||||
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:
|
@ -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
|
@ -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:
|
@ -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:
|
@ -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:
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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:
|
@ -1,5 +0,0 @@
|
||||
DEVICE=%IF_NAME%
|
||||
ONBOOT=yes
|
||||
BOOTPROTO=none
|
||||
IPADDR=%IP_ADDRESS%
|
||||
NETMASK=255.255.255.0
|
@ -1,4 +0,0 @@
|
||||
# VirtualBox NAT -- for Internet access to VM
|
||||
DEVICE=%IF_NAME%
|
||||
ONBOOT=yes
|
||||
BOOTPROTO=dhcp
|
@ -1,4 +0,0 @@
|
||||
auto %IF_NAME%
|
||||
iface %IF_NAME% inet static
|
||||
address %IP_ADDRESS%
|
||||
netmask 255.255.255.0
|
@ -1,3 +0,0 @@
|
||||
# The loopback network interface
|
||||
auto lo
|
||||
iface lo inet loopback
|
@ -1,3 +0,0 @@
|
||||
# VirtualBox NAT -- for Internet access to VM
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
@ -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:
|
@ -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:
|
@ -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:
|
@ -1,2 +0,0 @@
|
||||
The files in this directory are used to create Windows batch scripts that
|
||||
can build base disks and VM clusters.
|
@ -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:
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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.
|
245
labs/osbash.sh
245
labs/osbash.sh
@ -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:-}"
|
@ -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.
|
@ -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"
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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"
|
@ -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
|
@ -1 +0,0 @@
|
||||
../shutdown.sh
|
@ -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:
|
@ -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
|
@ -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'
|
@ -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
|
@ -1 +0,0 @@
|
||||
The scripts in this directory can be used to test the training-cluster.
|
@ -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:)' ]"
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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"
|
@ -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
|
@ -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"
|
@ -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
|
@ -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
|
@ -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"
|
@ -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
|
@ -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"
|
@ -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
|
@ -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"
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user