1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
16 import novaclient.client
17 client_available = True
19 client_available = False
22 log = logging.getLogger('heat-translator')
26 'm1.xlarge': {'mem_size': 16384, 'disk_size': 160, 'num_cpus': 8},
27 'm1.large': {'mem_size': 8192, 'disk_size': 80, 'num_cpus': 4},
28 'm1.medium': {'mem_size': 4096, 'disk_size': 40, 'num_cpus': 2},
29 'm1.small': {'mem_size': 2048, 'disk_size': 20, 'num_cpus': 1},
30 'm1.tiny': {'mem_size': 512, 'disk_size': 1, 'num_cpus': 1},
31 'm1.micro': {'mem_size': 128, 'disk_size': 0, 'num_cpus': 1},
32 'm1.nano': {'mem_size': 64, 'disk_size': 0, 'num_cpus': 1}
46 if SESSION is not None and client_available:
48 client = novaclient.client.Client("2", session=SESSION)
49 except Exception as e:
50 # Handles any exception coming from openstack
51 log.warn(_('Choosing predefined flavors since received '
52 'Openstack Exception: %s') % str(e))
54 for flv in client.flavors.list(detailed=True):
55 FLAVORS[str(flv.name)] = {
57 "disk_size": flv.disk,
62 FLAVORS = PREDEF_FLAVORS