~joetalbott/+junk/fix_tmpdir

« back to all changes in this revision

Viewing changes to core_image_builder/cloud.py

  • Committer: Joe Talbott
  • Date: 2015-05-19 21:37:40 UTC
  • Revision ID: joe.talbott@canonical.com-20150519213740-48l0u6bmecbyg9mt
Add core-image-publisher code with name changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# core-image-builder
 
2
# Copyright (C) 2015 Canonical
 
3
#
 
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.
 
8
#
 
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.
 
13
#
 
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/>.
 
16
#
 
17
 
 
18
"""Functions for cloud interactions."""
 
19
 
 
20
import glanceclient
 
21
import keystoneclient.v2_0.client
 
22
 
 
23
 
 
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')
 
30
    )
 
31
    glance_endpoints = keystone.service_catalog.get_endpoints(
 
32
        service_type='image'
 
33
    )
 
34
    glance_endpoint_url = glance_endpoints['image'][0]['internalURL']
 
35
    glance_client = glanceclient.Client(
 
36
        version='1',
 
37
        endpoint=glance_endpoint_url,
 
38
        token=keystone.auth_token
 
39
    )
 
40
    return glance_client