summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin André <martin.andre@kvhasia.com>2015-04-28 12:12:14 +0900
committerMartin André <martin.andre@kvhasia.com>2015-04-28 12:15:42 +0900
commit90ad52c4c1f2fd18749697064e069a4483b0e2c5 (patch)
treee5b311027be2d803212cf98cd4e77558b669c0e6
parent5f1cfa824ff79853ebe39244fc29a6f8add0e6ca (diff)
downloadkolla-90ad52c4c1f2fd18749697064e069a4483b0e2c5.tar.gz
kolla-90ad52c4c1f2fd18749697064e069a4483b0e2c5.zip
Consolidate tools/conf-* scripts in tools/init-runonce
Fix issues reported in https://review.openstack.org/#/c/177681/3, and simplify detection of cirros images in glance. Only add developer's SSH key to nova if ~/.ssh/id_rsa.pub exists and is readable. Change-Id: I5936c6db399d63902d460b0d3c959619073cc3cc
-rw-r--r--compose/README.md4
-rwxr-xr-xtools/conf-neutronnet63
-rwxr-xr-xtools/conf-novanet55
-rwxr-xr-xtools/init-runonce80
-rwxr-xr-xtools/kolla2
5 files changed, 83 insertions, 121 deletions
diff --git a/compose/README.md b/compose/README.md
index 926f86824..4cd0cf63c 100644
--- a/compose/README.md
+++ b/compose/README.md
@@ -14,7 +14,7 @@ to use the installation. If using nova networking use:
```
# source openrc
-# tools/conf-novanet
+# tools/init-runonce
# nova boot --flavor m1.medium --key_name mykey --image puffy_clouds instance_name
# ssh cirros@<ip>
```
@@ -23,7 +23,7 @@ Else if using neutron networking use:
```
# source openrc
-# tools/conf-neutronnet
+# tools/init-runonce
# nova boot --flavor m1.medium --key_name mykey --image puffy_clouds instance_name --nic net-id:<net id>
# ssh cirros@<ip>
```
diff --git a/tools/conf-neutronnet b/tools/conf-neutronnet
deleted file mode 100755
index 0efea55a2..000000000
--- a/tools/conf-neutronnet
+++ /dev/null
@@ -1,63 +0,0 @@
-# This script is meant to be run once after running start for the first
-# time. This script downloads a cirros image and registers it. Then it
-# configures neutron networking and nova quotas to allow 40 m1.small instances
-#to be created.
-
-# Move to top level directory
-REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
-cd "$(dirname "$REAL_PATH")/.."
-
-# Test for credentials set
-if [[ "${OS_USERNAME}" == "" ]]; then
- echo "No Keystone credentials specified. Try running source openrc"
- exit
-fi
-
-# Test to ensure configure script is run only once
-if [[ `glance image-list | grep cirros | wc -l` -gt 0 ]]; then
- echo "This tool should only be run once per deployment."
- exit
-fi
-
-echo Downloading glance image.
-IMAGE_URL=http://download.cirros-cloud.net/0.3.3/
-IMAGE=cirros-0.3.3-x86_64-disk.img
-if ! [ -f "$IMAGE" ]; then
- curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE
-fi
-echo Creating glance image.
-glance image-create --name cirros --progress --is-public false --disk-format qcow2 --container-format bare --file ./$IMAGE
-
-## Non Provider Option
-neutron net-create public1 --router:external True --provider:physical_network physnet1 --provider:network_type flat
-neutron subnet-create --name 1-subnet --disable-dhcp --allocation-pool start=192.168.100.150,end=192.168.100.199 public1 192.168.100.0/24 --gateway 192.168.100.1 --dns_nameservers list=true 192.168.100.1
-neutron net-create demo-net --provider:network_type vxlan --provider:segmentation_id 10
-neutron subnet-create demo-net --name demo-subnet --gateway 10.10.10.1 10.10.10.0/24
-neutron router-create demo-router
-neutron router-interface-add demo-router demo-subnet
-neutron router-gateway-set demo-router public1
-
-# Sec Group Config
-neutron security-group-rule-create default --direction ingress --ethertype IPv4 --protocol icmp --remote-ip-prefix 0.0.0.0/0
-neutron security-group-rule-create default --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 22 --port-range-max 22 --remote-ip-prefix 0.0.0.0/0
-
-# Create a keypair
-nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
-
-# Increase the quota to allow 40 m1.small instances to be created
-
-# Get admin user and tenant IDs
-ADMIN_USER=$(keystone user-list | awk '/admin/ {print $2'})
-ADMIN_TENANT=$(keystone tenant-list | awk '/admin/ {print $2}')
-
-# 40 instances
-nova quota-update --instances 40 $ADMIN_TENANT
-nova quota-update --user $ADMIN_USER --instances 40 $ADMIN_TENANT
-
-# 40 cores
-nova quota-update --cores 40 $ADMIN_TENANT
-nova quota-update --user $ADMIN_USER --cores 40 $ADMIN_TENANT
-
-# 96GB ram
-nova quota-update --ram 96000 $ADMIN_TENANT
-nova quota-update --user $ADMIN_USER --ram 96000 $ADMIN_TENANT
diff --git a/tools/conf-novanet b/tools/conf-novanet
deleted file mode 100755
index ed299b9c2..000000000
--- a/tools/conf-novanet
+++ /dev/null
@@ -1,55 +0,0 @@
-# This script is meant to be run once after running start for the first
-# time. This script downloads a cirros image and registers it. Then it
-# configures nova networking and nova quotas to allow 40 m1.small instances
-#to be created.
-
-# Move to top level directory
-REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
-cd "$(dirname "$REAL_PATH")/.."
-
-# Test for credentials set
-if [[ "${OS_USERNAME}" == "" ]]; then
- echo "No Keystone credentials specified. Try running source openrc"
- exit
-fi
-
-# Test to ensure configure script is run only once
-if [[ `glance image-list | grep cirros | wc -l` -gt 0 ]]; then
- echo "This tool should only be run once per deployment."
- exit
-fi
-
-echo Downloading glance image.
-IMAGE_URL=http://download.cirros-cloud.net/0.3.3/
-IMAGE=cirros-0.3.3-x86_64-disk.img
-if ! [ -f "$IMAGE" ]; then
- curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE
-fi
-echo Creating glance image.
-glance image-create --name cirros --is-public false --disk-format qcow2 --container-format bare --file ./$IMAGE
-
-echo Configuring nova networking.
-nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
-nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
-nova network-create vmnet --fixed-range-v4=10.0.0.0/24 --bridge=br100 --multi-host=T
-
-echo Configuring nova public key and quotas.
-nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
-
-# Increase the quota to allow 40 m1.small instances to be created
-
-# Get admin user and tenant IDs
-ADMIN_USER=$(keystone user-list | awk '/admin/ {print $2'})
-ADMIN_TENANT=$(keystone tenant-list | awk '/admin/ {print $2}')
-
-# 40 instances
-nova quota-update --instances 40 $ADMIN_TENANT
-nova quota-update --user $ADMIN_USER --instances 40 $ADMIN_TENANT
-
-# 40 cores
-nova quota-update --cores 40 $ADMIN_TENANT
-nova quota-update --user $ADMIN_USER --cores 40 $ADMIN_TENANT
-
-# 96GB ram
-nova quota-update --ram 96000 $ADMIN_TENANT
-nova quota-update --user $ADMIN_USER --ram 96000 $ADMIN_TENANT
diff --git a/tools/init-runonce b/tools/init-runonce
new file mode 100755
index 000000000..38b5856b3
--- /dev/null
+++ b/tools/init-runonce
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# This script is meant to be run once after running start for the first
+# time. This script downloads a cirros image and registers it. Then it
+# configures networking and nova quotas to allow 40 m1.small instances
+# to be created.
+
+# Move to top level directory
+REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
+cd "$(dirname "$REAL_PATH")/.."
+
+NETWORK_MANAGER=$(grep -sri NETWORK_MANAGER ./compose/openstack.env | cut -f2 -d'=')
+if [[ -z "$NETWORK_MANAGER" ]]; then
+ echo 'No network manager defined in ./compose/openstack.env, defaulting to "neutron".'
+ NETWORK_MANAGER="neutron"
+fi
+
+# Test for credentials set
+if [[ "${OS_USERNAME}" == "" ]]; then
+ echo "No Keystone credentials specified. Try running source openrc"
+ exit
+fi
+
+# Test to ensure configure script is run only once
+if glance image-list | grep -q cirros; then
+ echo "This tool should only be run once per deployment."
+ exit
+fi
+
+echo Downloading glance image.
+IMAGE_URL=http://download.cirros-cloud.net/0.3.3/
+IMAGE=cirros-0.3.3-x86_64-disk.img
+if ! [ -f "$IMAGE" ]; then
+ curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE
+fi
+echo Creating glance image.
+glance image-create --name cirros --progress --is-public false --disk-format qcow2 --container-format bare --file ./$IMAGE
+
+if [[ "${NETWORK_MANAGER}" == "nova" ]] ; then
+ echo Configuring nova networking.
+ nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
+ nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
+ nova network-create vmnet --fixed-range-v4=10.0.0.0/24 --bridge=br100 --multi-host=T
+else
+ echo Configuring neutron.
+ neutron net-create public1 --router:external True --provider:physical_network physnet1 --provider:network_type flat
+ neutron subnet-create --name 1-subnet --disable-dhcp --allocation-pool start=192.168.100.150,end=192.168.100.199 public1 192.168.100.0/24 --gateway 192.168.100.1 --dns_nameservers list=true 192.168.100.1
+ neutron net-create demo-net --provider:network_type vxlan --provider:segmentation_id 10
+ neutron subnet-create demo-net --name demo-subnet --gateway 10.10.10.1 10.10.10.0/24
+ neutron router-create demo-router
+ neutron router-interface-add demo-router demo-subnet
+ neutron router-gateway-set demo-router public1
+
+ # Sec Group Config
+ neutron security-group-rule-create default --direction ingress --ethertype IPv4 --protocol icmp --remote-ip-prefix 0.0.0.0/0
+ neutron security-group-rule-create default --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 22 --port-range-max 22 --remote-ip-prefix 0.0.0.0/0
+fi
+
+if [ -r ~/.ssh/id_rsa.pub ]; then
+ echo Configuring nova public key and quotas.
+ nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
+fi
+
+# Increase the quota to allow 40 m1.small instances to be created
+
+# Get admin user and tenant IDs
+ADMIN_USER=$(keystone user-list | awk '/admin/ {print $2}')
+ADMIN_TENANT=$(keystone tenant-list | awk '/admin/ {print $2}')
+
+# 40 instances
+nova quota-update --instances 40 $ADMIN_TENANT
+nova quota-update --user $ADMIN_USER --instances 40 $ADMIN_TENANT
+
+# 40 cores
+nova quota-update --cores 40 $ADMIN_TENANT
+nova quota-update --user $ADMIN_USER --cores 40 $ADMIN_TENANT
+
+# 96GB ram
+nova quota-update --ram 96000 $ADMIN_TENANT
+nova quota-update --user $ADMIN_USER --ram 96000 $ADMIN_TENANT
diff --git a/tools/kolla b/tools/kolla
index 6b190f00b..20d72dd28 100755
--- a/tools/kolla
+++ b/tools/kolla
@@ -84,7 +84,7 @@ function post_start {
echo source openrc # source keystone credentials
echo Configure your environment once by running:
- echo tools/conf-novanet # configure OpenStack with Nova Networking
+ echo tools/init-runonce
}
function usage {