~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to tools/nova_create_flavors.sh

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Yolanda Robla, Chuck Short
  • Date: 2013-07-22 16:22:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130722162229-zzvfu40id94ii0hc
Tags: 2013.2~b2-0ubuntu1
[ Yolanda Robla ]
* debian/tests: added autopkg tests

[ Chuck Short ]
* New upstream release
* debian/control:
  - Add python-pbr to build-depends.
  - Add python-d2to to build-depends.
  - Dropped python-argparse.
  - Add python-six to build-depends.
  - Dropped python-sendfile.
  - Dropped python-nose.
  - Added testrepository.
  - Added python-testtools.
* debian/rules: Run testrepository instead of nosetets.
* debian/patches/removes-lxml-version-limitation-from-pip-requires.patch: Dropped
  no longer needed.
* debian/patches/fix-package-version-detection-when-building-doc.patch: Dropped
  no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
 
# Create additional nova instance types (flavors)
3
 
# to map to the AWS instance types we have in the templates
4
 
 
5
 
# Default nova install (via tools/openstack) gives this:
6
 
# +----+-----------+-----------+------+-----------+------+-------+-------------+
7
 
# | ID |    Name   | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor |
8
 
# +----+-----------+-----------+------+-----------+------+-------+-------------+
9
 
# | 1  | m1.tiny   | 512       | 0    | 0         |      | 1     | 1.0         |
10
 
# | 2  | m1.small  | 2048      | 10   | 20        |      | 1     | 1.0         |
11
 
# | 3  | m1.medium | 4096      | 10   | 40        |      | 2     | 1.0         |
12
 
# | 4  | m1.large  | 8192      | 10   | 80        |      | 4     | 1.0         |
13
 
# | 5  | m1.xlarge | 16384     | 10   | 160       |      | 8     | 1.0         |
14
 
# +----+-----------+-----------+------+-----------+------+-------+-------------+
15
 
 
16
 
# Templates define these as valid
17
 
#      "t1.micro"    : { "Arch" : "32" },
18
 
#      "m1.small"    : { "Arch" : "32" },
19
 
#      "m1.large"    : { "Arch" : "64" },
20
 
#      "m1.xlarge"   : { "Arch" : "64" },
21
 
#      "m2.xlarge"   : { "Arch" : "64" },
22
 
#      "m2.2xlarge"  : { "Arch" : "64" },
23
 
#      "m2.4xlarge"  : { "Arch" : "64" },
24
 
#      "c1.medium"   : { "Arch" : "32" },
25
 
#      "c1.xlarge"   : { "Arch" : "64" },
26
 
#      "cc1.4xlarge" : { "Arch" : "64" }
27
 
 
28
 
# So for development purposes, we create all flavors, but with a maximum of
29
 
# 2vcpus, 10G disk and 2G RAM (since we're all running on laptops..)
30
 
 
31
 
 
32
 
# Nova rate limits actions so we need retry/sleep logic to avoid
33
 
# spurious failures when doing sequential operations
34
 
# we also sleep after every operation otherwise rate-limiting will definitely
35
 
# cause lots of failures
36
 
retry_cmd() {
37
 
    MAX_TRIES=5
38
 
    attempts=0
39
 
    while [[ ${attempts} < ${MAX_TRIES} ]]
40
 
    do
41
 
        attempts=$((${attempts} + 1))
42
 
        if ! $@ 2>/dev/null
43
 
        then
44
 
            echo "Command : \"$@\" failed, retry after 1s ${attempts}/${MAX_TRIES}"
45
 
            sleep 1
46
 
        else
47
 
            echo "$@ : OK"
48
 
            sleep 1
49
 
            break
50
 
        fi
51
 
    done
52
 
 
53
 
    if [[ ${attempts} == ${MAX_TRIES} ]]
54
 
    then
55
 
        echo "ERROR : persistent error attempting to run command \"$@\"!"
56
 
    fi
57
 
}
58
 
 
59
 
 
60
 
# Sanity-test nova flavor-list, this should catch problems with credentials
61
 
# or if nova is not running.  When calling from openstack install, it seems
62
 
# that nova gives 400 errors despite the service showing as active via
63
 
# systemctl, so we work around that by polling via retry_cmd before doing the
64
 
# final check - this should mean we wait for the service to come up but still
65
 
# exit if there is a non-transient problem
66
 
retry_cmd "nova flavor-list"
67
 
if ! nova flavor-list > /dev/null
68
 
then
69
 
    echo "ERROR, unable to do \"nova flavor-list\""
70
 
    echo "Check keystone credentials and that nova services are running"
71
 
    exit 1
72
 
fi
73
 
 
74
 
# This list should match the flavor-creates below to be sure we remove the
75
 
# flavors we're about to create, and no others
76
 
FLAVORS="t1\.micro|m1\.tiny|m1\.small|m1\.medium|m1\.large|m1\.xlarge|m2\.xlarge|m2\.2xlarge|m2\.4xlarge|c1\.medium|c1\.xlarge|cc1\.4xlarge"
77
 
 
78
 
for f in $(nova flavor-list | grep -E "^\|\s+[0-9]+\s+\|\s+($FLAVORS)\s" | awk '{print $2}')
79
 
do
80
 
    retry_cmd "nova flavor-delete $f"
81
 
done
82
 
 
83
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 t1.micro 1 256 0 1"
84
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.tiny 2 256 0 1"
85
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.small 3 512 0 1"
86
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.medium 4 768 0 1"
87
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.large 5 1024 0 1"
88
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.xlarge 6 2048 0 1"
89
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m2.xlarge 7 2048 0 2"
90
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m2.2xlarge 8 2048 0 2"
91
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m2.4xlarge 9 2048 0 2"
92
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 c1.medium 10 2048 0 2"
93
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 c1.xlarge 11 2048 0 2"
94
 
retry_cmd "nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 cc1.4xlarge 12 2048 0 2"
95
 
 
96
 
# Check we get the expected number of flavors on completion
97
 
num_flavors=$(nova flavor-list | grep "[0-9]. *|" | wc -l)
98
 
expected_flavors=12
99
 
if [[ ${num_flavors} != ${expected_flavors} ]]
100
 
then
101
 
    echo "ERROR : problem creating flavors, created ${num_flavors}, expected ${expected_flavors}"
102
 
fi
 
2
echo "WARNING: This script now make no modifications to the current flavors"
 
3
nova flavor-list