]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Allow the Getting Started script to run non-interactively
authorZane Bitter <zbitter@redhat.com>
Mon, 14 May 2012 14:03:49 +0000 (16:03 +0200)
committerZane Bitter <zbitter@redhat.com>
Mon, 14 May 2012 14:03:49 +0000 (16:03 +0200)
Related: #84

Signed-off-by: Zane Bitter <zbitter@redhat.com>
bin/heat
bin/heat-db-setup
docs/GettingStarted.rst
heat/utils.py
tools/heat-db-drop
tools/openstack
tools/uninstall-heat

index fa55ad51898ac16f6faa7760b81384f1d3b3f525..e574ff1d7da9c9393dc35bc5e4a0774b8c43dd30 100755 (executable)
--- a/bin/heat
+++ b/bin/heat
@@ -311,6 +311,9 @@ def create_options(parser):
                       help="Print more verbose output")
     parser.add_option('-d', '--debug', default=False, action="store_true",
                       help="Print more verbose output")
+    parser.add_option('-y', '--yes', default=False, action="store_true",
+                      help="Don't prompt for user input; assume the answer to "
+                           "every question is 'yes'.")
     parser.add_option('-H', '--host', metavar="ADDRESS", default="0.0.0.0",
                       help="Address of heat API host. "
                            "Default: %default")
index 744df3630ee771966fb9b6ee584d0c540471d1b5..56f7165b1e127422f1cce6c05e9c453f9db71d04 100755 (executable)
@@ -29,7 +29,7 @@ Options:
 
        --help        | -h
                Print usage information.
-       --heatpw <pw> | -n <pw>
+       --password <pw> | -p <pw>
                Specify the password for the 'heat' MySQL user that  will
                use to connect to the 'heat' MySQL database.  By default,
                the password 'heat' will be used.
@@ -66,11 +66,6 @@ MYSQL_HEAT_PW=${MYSQL_HEAT_PW_DEFAULT}
 HEAT_CONFIG="/etc/heat/heat-engine.conf"
 ASSUME_YES=""
 
-if [ $# -eq 0 ]
-then
-       usage
-fi
-
 case "$1" in
        rpm)
                echo "Installing on an RPM system."
@@ -90,6 +85,9 @@ case "$1" in
                SERVICE_STATUS="service $SERVICE_MYSQLD status"
                SERVICE_ENABLE=""
                ;;
+       *)
+               usage
+               ;;
 esac
 
 while [ $# -gt 0 ]
@@ -98,7 +96,7 @@ do
                -h|--help)
                        usage
                        ;;
-               -n|--novapw)
+               -p|--password)
                        shift
                        MYSQL_HEAT_PW=${1}
                        ;;
@@ -111,7 +109,6 @@ do
                        ;;
                *)
                        # ignore
-                       shift
                        ;;
        esac
        shift
index 4d54736c2a2e73443ec69e9052638669a547c9a7..011bca2759a0431588d93674e4d91fafe678633d 100644 (file)
@@ -34,7 +34,7 @@ Installing OpenStack on Fedora 16
 Note: on Fedora 16 you have to enable the `Preview Repository`_ to install the required OpenStack Essex release.
 A script called "``openstack``" in the tools directory of the repository will install and start OpenStack for you on Fedora 16/17::
 
-    ./tools/openstack install
+    ./tools/openstack install -y -r ${MYSQL_ROOT_PASSWORD}
 
 If you use this method, you will need to manually create a guest network.  How this is done depends on your environment.  An example network create operation:
 
@@ -90,9 +90,9 @@ Setup the MySQL database for Heat
 
 ::
 
-    ./bin/heat-db-setup rpm
+    heat-db-setup rpm -y -r ${MYSQL_ROOT_PASSWORD}
 
-Note: the first argument is either ``rpm`` for RPM-based distros (such as Fedora) or ``deb`` for Debian-based distros (such as Ubuntu).
+Note: the first argument is either ``rpm`` for RPM-based distros (such as Fedora) or ``deb`` for Debian-based distros (such as Ubuntu). To prompt for confirmation when e.g. installing MySQL Server, omit the ``-y`` option. Run ``heat-db-setup --help`` for detailed documentation.
 
 Register heat with keystone
 ---------------------------
@@ -128,7 +128,7 @@ Create a JEOS
 
 ::
 
-    sudo -E heat jeos_create F16 x86_64 cfntools
+    sudo -E heat -y jeos_create F16 x86_64 cfntools
 
 Note: The ``-E`` option to ``sudo`` preserves the environment, specifically the keystone credentials, when ``jeos_create`` is run as root.
 
index 0691d241281001c815bbd9a1aff7bb338e09e830..1a8294b8af789ff03fda4af0130ac68e64368996 100644 (file)
@@ -178,7 +178,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
         if image['name'] == distro + '-' + arch + '-' + instance_type:
             image_registered = True
 
-    runoz = None
+    runoz = options.yes and 'y' or None
     if os.access(qcow2_filename, os.R_OK):
         while runoz not in ('y', 'n'):
             runoz = raw_input('An existing JEOS was found on disk.' \
index e472452ecc904428f7d6982bce72042035300a48..e137e8ae5ee06007bfeb21b7f3010da7ac65d011 100755 (executable)
@@ -1,8 +1,26 @@
 #!/bin/bash
-cat << EOF | mysql -u root -p
-DROP USER 'heat'@'localhost';
-DROP USER 'heat'@'%';
-DROP DATABASE heat;
+
+DATABASE=heat
+
+while [ $# -gt 0 ]; do
+    case $1 in
+        heat|nova|keystone|glance)
+            DATABASE=$1
+            ;;
+        -r|--rootpw)
+            shift
+            MYSQL_ROOT_PW_ARG="--password=$1"
+            ;;
+        *)
+            ;;
+    esac
+    shift
+done
+
+cat << EOF | mysql -u root ${MYSQL_ROOT_PW_ARG}
+DROP USER '${DATABASE}'@'localhost';
+DROP USER '${DATABASE}'@'%';
+DROP DATABASE ${DATABASE};
 flush privileges;
 EOF
 
index 032dd2bccb1622aef4ac4172dc133596b0ab0aaa..e205b6b7d132d989eec8fda73045388b1585ef6c 100755 (executable)
@@ -7,6 +7,7 @@
 
 # sleep 1 = systemd's definition of start is different from mine
 
+BASE_DIR=`dirname $0`
 
 action=$1
 if [ -z "$action" ]
@@ -72,18 +73,9 @@ function os_erase() {
        sudo systemctl start mysqld.service
        sleep 1
 
-cat << EOF | mysql -u root -p
-DROP USER 'nova'@'localhost';
-DROP USER 'nova'@'%';
-DROP USER 'keystone'@'localhost';
-DROP USER 'keystone'@'%';
-DROP USER 'glance'@'localhost';
-DROP USER 'glance'@'%';
-DROP DATABASE nova;
-DROP DATABASE keystone;
-DROP DATABASE glance;
-flush privileges;
-EOF
+       $BASE_DIR/heat-db-drop nova $*
+       $BASE_DIR/heat-db-drop keystone $*
+       $BASE_DIR/heat-db-drop glance $*
 
        sudo vgchange -an nova-volumes
        sudo losetup -d /dev/loop0
@@ -100,9 +92,9 @@ function os_install() {
        sudo systemctl start mysqld.service
        sleep 1
        # Configure the databases
-       sudo openstack-nova-db-setup
-       sudo openstack-glance-db-setup
-       sudo openstack-keystone-db-setup
+       sudo openstack-nova-db-setup $*
+       sudo openstack-glance-db-setup $*
+       sudo openstack-keystone-db-setup $*
 
        # Create a keystone RC file
        mkdir -p $HOME/.openstack
@@ -143,17 +135,18 @@ EOF
        os_start
        sleep 1
        echo "Installation Complete."
-       echo "Testing nova and glance.  If any errors are displayed, the install failed."
+       echo "Testing nova and glance.  If any errors are displayed, the install failed..."
        nova flavor-list
        glance index
+        echo
        echo "note: This tool does not create a network.  Creating a network"
        echo "depends on your environment.  An example network create operation:"
        echo
-       echo "sudo nova-manage network create demonet 10.0.0.0/24 1 256 --bridge=demonetbr0"
+       echo "  sudo nova-manage network create demonet 10.0.0.0/24 1 256 --bridge=demonetbr0"
        echo
-       echo "The network range here, should *not* be the one used on your existing physical network."
-       echo "It should be a range dedicated for the network that OpenStack will configure. So if"
-       echo "10.0.0.0/24 clashes with your local network, pick another range."
+       echo -e "The network range here should *not* be one used on your existing physical\n network."
+       echo "It should be a range dedicated for the network that OpenStack will configure."
+       echo "If 10.0.0.0/24 clashes with your local network, pick another range."
 
 }
 
@@ -167,10 +160,12 @@ case $action in
                os_stop
                ;;
        erase)
-               os_erase
+               shift
+               os_erase $*
                ;;
        install)
-               os_install
+               shift
+               os_install $*
                ;;
        status)
                os_status
index 3527ec85b6380e3347b2ab4a5ec1f4213be7aac5..fcc3cf3b819d880c5becc94f949a4f4820e1b538 100755 (executable)
@@ -1,8 +1,9 @@
 #!/bin/bash
 
 TOOLS_DIR=`dirname $0`
-if [ "$1" = "-y" ]; then
+if [ "$1" = "-y" ] || [ "$1" = "--yes" ]; then
     SKIP_ASK=y
+    shift
 fi
 
 user_wants() {
@@ -31,12 +32,12 @@ if [ -n "$HEAT_PIDS" ]; then
 fi
 
 if user_wants 'Drop Heat database tables?'; then
-    $TOOLS_DIR/heat-db-drop
+    $TOOLS_DIR/heat-db-drop $*
     echo 1>&2
 fi
 
 if user_wants 'Erase OpenStack installation?'; then
-    $TOOLS_DIR/openstack erase
+    $TOOLS_DIR/openstack erase $*
     echo 1>&2
 fi