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 glanceclient.client
17 client_available = True
19 client_available = False
22 log = logging.getLogger('heat-translator')
26 'ubuntu-software-config-os-init': {'architecture': 'x86_64',
28 'distribution': 'Ubuntu',
30 'ubuntu-12.04-software-config-os-init': {'architecture': 'x86_64',
32 'distribution': 'Ubuntu',
34 'fedora-amd64-heat-config': {'architecture': 'x86_64',
36 'distribution': 'Fedora',
38 'F18-x86_64-cfntools': {'architecture': 'x86_64',
40 'distribution': 'Fedora',
42 'Fedora-x86_64-20-20131211.1-sda': {'architecture': 'x86_64',
44 'distribution': 'Fedora',
46 'cirros-0.3.1-x86_64-uec': {'architecture': 'x86_64',
48 'distribution': 'CirrOS',
50 'cirros-0.3.2-x86_64-uec': {'architecture': 'x86_64',
52 'distribution': 'CirrOS',
54 'rhel-6.5-test-image': {'architecture': 'x86_64',
56 'distribution': 'RHEL',
71 if SESSION is not None and client_available:
73 client = glanceclient.client.Client("2", session=SESSION)
74 except Exception as e:
75 # Handles any exception coming from openstack
76 log.warn(_('Choosing predefined images since received '
77 'Openstack Exception: %s') % str(e))
79 for image in client.images.list():
80 image_name = image.name.encode('ascii', 'ignore')
81 metadata = ["architecture", "type", "distribution", "version"]
82 if any(key in image.keys() for key in metadata):
83 IMAGES[image_name] = {}
85 if key in image.keys():
86 IMAGES[image_name][key] = image[key]
89 IMAGES = PREDEF_IMAGES