2
# Copyright (C) 2015 Canonical
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
"""Functions for cloud interactions."""
21
import keystoneclient.v2_0.client
24
def get_glance_client(config):
25
keystone = keystoneclient.v2_0.client.Client(
26
username=config.get('nova', 'os_username'),
27
password=config.get('nova', 'os_password'),
28
tenant_name=config.get('nova', 'os_tenant_name'),
29
auth_url=config.get('nova', 'os_auth_url')
31
glance_endpoints = keystone.service_catalog.get_endpoints(
34
glance_endpoint_url = glance_endpoints['image'][0]['internalURL']
35
glance_client = glanceclient.Client(
37
endpoint=glance_endpoint_url,
38
token=keystone.auth_token