heat : Make instance flavors consistent

Add additional instance flavors to align templates with
nova

Fixes #179

Change-Id: I586e57748c9b0a0c7594746399d5328da788efcd
Signed-off-by: Steven Hardy <shardy@redhat.com>
This commit is contained in:
Steven Hardy 2012-08-02 14:37:13 +01:00
parent 1ed94e1382
commit 044887521e
5 changed files with 63 additions and 19 deletions

View File

@ -108,19 +108,6 @@ class Instance(resources.Resource):
self.ipaddress = None
self.mime_string = None
self.itype_oflavor = {'t1.micro': 'm1.tiny',
'm1.small': 'm1.small',
'm1.medium': 'm1.medium',
'm1.large': 'm1.large',
'm1.xlarge': 'm1.tiny', # TODO(sdake)
'm2.xlarge': 'm1.xlarge',
'm2.2xlarge': 'm1.large',
'm2.4xlarge': 'm1.large',
'c1.medium': 'm1.medium',
'c1.4xlarge': 'm1.large',
'cc2.8xlarge': 'm1.large',
'cg1.4xlarge': 'm1.large'}
def _set_ipaddress(self, networks):
'''
Read the server's IP address from a list of networks provided by Nova
@ -202,7 +189,7 @@ class Instance(resources.Resource):
def handle_create(self):
security_groups = self.properties.get('SecurityGroups')
userdata = self.properties['UserData']
flavor = self.itype_oflavor[self.properties['InstanceType']]
flavor = self.properties['InstanceType']
key_name = self.properties['KeyName']
keypairs = [k.name for k in self.nova().keypairs.list()]

View File

@ -68,7 +68,6 @@ class instancesTest(unittest.TestCase):
instance = instances.Instance('test_resource_name',
t['Resources']['WebServer'], stack)
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
instance.t = instance.stack.resolve_runtime_data(instance.t)
# need to resolve the template functions
@ -81,7 +80,6 @@ class instancesTest(unittest.TestCase):
meta=None).AndReturn(self.fc.servers.list()[1])
self.m.ReplayAll()
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
instance.create()
# this makes sure the auto increment worked on instance creation
@ -114,7 +112,6 @@ class instancesTest(unittest.TestCase):
instance = instances.Instance('test_resource_name',
t['Resources']['WebServer'], stack)
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
instance.t = instance.stack.resolve_runtime_data(instance.t)
# need to resolve the template functions
@ -128,7 +125,6 @@ class instancesTest(unittest.TestCase):
self.m.ReplayAll()
instance.instance_id = 1234
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
instance.create()
# this makes sure the auto increment worked on instance creation

View File

@ -71,7 +71,6 @@ def setup_mocks(mocks, stack):
instances.Instance.nova().MultipleTimes().AndReturn(fc)
instance = stack.resources['WebServer']
instance.itype_oflavor['m1.large'] = 'm1.large'
instance.calculate_properties()
server_userdata = instance._build_userdata(instance.properties['UserData'])
mocks.StubOutWithMock(fc.servers, 'create')

60
tools/nova_create_flavors.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/sh
# Create additional nova instance types (flavors)
# to map to the AWS instance types we have in the templates
# Default nova install (via tools/openstack) gives this:
# +----+-----------+-----------+------+-----------+------+-------+-------------+
# | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor |
# +----+-----------+-----------+------+-----------+------+-------+-------------+
# | 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 |
# | 2 | m1.small | 2048 | 10 | 20 | | 1 | 1.0 |
# | 3 | m1.medium | 4096 | 10 | 40 | | 2 | 1.0 |
# | 4 | m1.large | 8192 | 10 | 80 | | 4 | 1.0 |
# | 5 | m1.xlarge | 16384 | 10 | 160 | | 8 | 1.0 |
# +----+-----------+-----------+------+-----------+------+-------+-------------+
# Templates define these as valid
# "t1.micro" : { "Arch" : "32" },
# "m1.small" : { "Arch" : "32" },
# "m1.large" : { "Arch" : "64" },
# "m1.xlarge" : { "Arch" : "64" },
# "m2.xlarge" : { "Arch" : "64" },
# "m2.2xlarge" : { "Arch" : "64" },
# "m2.4xlarge" : { "Arch" : "64" },
# "c1.medium" : { "Arch" : "32" },
# "c1.xlarge" : { "Arch" : "64" },
# "cc1.4xlarge" : { "Arch" : "64" }
# So for development purposes, we create all flavors, but with a maximum of
# 2vcpus, 10G disk and 2G RAM (since we're all running on laptops..)
for f in $(nova flavor-list | grep "^| [0-9]" | awk '{print $2}')
do
nova flavor-delete $f
done
# Note, horrible sleep 1's are because nova starts failing requests due
# to rate limiting without them..
nova flavor-create --ephemeral 0 --swap 0 --rxtx-factor 1 t1.micro 1 256 0 1
sleep 1
nova flavor-create --ephemeral 0 --swap 0 --rxtx-factor 1 m1.tiny 2 256 0 1
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.small 3 512 0 1
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.medium 4 768 0 1
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.large 5 1024 0 1
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m1.xlarge 6 2048 0 1
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m2.xlarge 7 2048 0 2
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m2.2xlarge 8 2048 0 2
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 m2.4xlarge 9 2048 0 2
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 c1.medium 10 2048 0 2
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 c1.xlarge 11 2048 0 2
sleep 1
nova flavor-create --ephemeral 10 --swap 0 --rxtx-factor 1 cc1.4xlarge 12 2048 0 2

View File

@ -160,6 +160,8 @@ EOF
sleep 1
echo "Installation Complete."
echo "Testing nova and glance. If any errors are displayed, the install failed..."
# Create additional flavors required by heat templates
${BASE_DIR}/nova_create_flavors.sh
nova flavor-list
glance index
echo