~rlane/nova/ldap-schema-modifications-1

« back to all changes in this revision

Viewing changes to nova/compute/instance_types.py

  • Committer: Ryan Lane
  • Date: 2010-12-08 08:21:44 UTC
  • mfrom: (384.1.3 trunk)
  • Revision ID: laner@controller-20101208082144-xb81vvcfp4zh45zu
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
The built-in instance properties.
22
22
"""
23
23
 
 
24
from nova import flags
 
25
 
 
26
FLAGS = flags.FLAGS
24
27
INSTANCE_TYPES = {
25
28
    'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1),
26
29
    'm1.small': dict(memory_mb=2048, vcpus=1, local_gb=20, flavorid=2),
27
30
    'm1.medium': dict(memory_mb=4096, vcpus=2, local_gb=40, flavorid=3),
28
31
    'm1.large': dict(memory_mb=8192, vcpus=4, local_gb=80, flavorid=4),
29
32
    'm1.xlarge': dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)}
 
33
 
 
34
 
 
35
def get_by_type(instance_type):
 
36
    """Build instance data structure and save it to the data store."""
 
37
    if instance_type is None:
 
38
        return FLAGS.default_instance_type
 
39
    if instance_type not in INSTANCE_TYPES:
 
40
        raise exception.ApiError("Unknown instance type: %s",
 
41
                                 instance_type)
 
42
    return instance_type
 
43
 
 
44
 
 
45
def get_by_flavor_id(flavor_id):
 
46
    for instance_type, details in INSTANCE_TYPES.iteritems():
 
47
        if details['flavorid'] == flavor_id:
 
48
            return instance_type
 
49
    return FLAGS.default_instance_type