2 # Licensed under the Apache License, Version 2.0 (the "License"); you may
3 # not use this file except in compliance with the License. You may obtain
4 # a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 # License for the specific language governing permissions and limitations
17 import glanceclient.client
18 client_available = True
20 client_available = False
23 log = logging.getLogger('heat-translator')
27 'ubuntu-software-config-os-init': {'architecture': 'x86_64',
29 'os_distro': 'ubuntu',
33 'ubuntu-12.04-software-config-os-init': {'architecture': 'x86_64',
35 'os_distro': 'ubuntu',
38 'fedora-amd64-heat-config': {'architecture': 'x86_64',
40 'os_distro': 'fedora',
43 'F18-x86_64-cfntools': {'architecture': 'x86_64',
45 'os_distro': 'fedora',
48 'Fedora-x86_64-20-20131211.1-sda': {'architecture': 'x86_64',
50 'os_distro': 'fedora',
53 'cirros-0.3.1-x86_64-uec': {'architecture': 'x86_64',
55 'os_distro': 'cirros',
58 'cirros-0.3.2-x86_64-uec': {'architecture': 'x86_64',
60 'os_distro': 'cirros',
63 'rhel-6.5-test-image': {'architecture': 'x86_64',
68 'cirros-0.4.0-aarch64-disk': {'architecture': 'aarch64',
70 'os_distro': 'cirros',
86 if SESSION is not None and client_available:
88 client = glanceclient.client.Client("2", session=SESSION)
89 except Exception as e:
90 # Handles any exception coming from openstack
91 log.warn(_('Choosing predefined images since received '
92 'Openstack Exception: %s') % str(e))
94 for image in client.images.list():
95 image_name = image.name.encode('ascii', 'ignore')
96 metadata = ["architecture", "type", "distribution", "version",
97 "os_distro", "os_type", "os_version"]
98 if any(key in image.keys() for key in metadata):
99 IMAGES[image_name] = {}
101 if key in image.keys():
102 IMAGES[image_name][key] = image[key]
105 IMAGES = PREDEF_IMAGES