def GET(self, section="", param=""): parser = Parse("properties.cfg") web.header("Content-Type", "application/json") if len(section) > 0 and len(param) > 0: return json.dumps(parser.get_value(section, param), indent=4) elif len(section) > 0: return json.dumps(parser.get_section(section), indent=4) else: return web.BadRequest()
# ******************************************************************** # * Copyright (c) 2009-2012 Cisco Systems, Inc. # * All rights reserved. # ******************************************************************** import web import httplib import re import simplejson as json from configParse import Parse parser = Parse("properties.cfg") _endpoint = parser.get_value("AUTH", "auth_service") _admin_endpoint = parser.get_value("AUTH", "auth_admin") admin_user_id = parser.get_value("ADMIN", "admin_user_id") admin_role_id = parser.get_value("ADMIN", "admin_role_id") object_ip = parser.get_value("OBJECT", "object_ip") object_port = parser.get_value("OBJECT", "object_port") object_root = parser.get_value("OBJECT", "object_root") import identity urls = ( "/tenant", "tenant", "/tenant/(.*)", "tenant", "/token", "tokenWeb", "/user", "user", "/user/(.*)", "user" )
from libcloud.compute.types import Provider from libcloud.compute.providers import get_driver from libcloud.common.openstack import OpenStackBaseConnection from configParse import Parse parser = Parse("properties.cfg") host = parser.get_value("HOST", "host") auth_service = parser.get_value("AUTH", "auth_service") compute_service = parser.get_value("COMPUTE", "compute_service") image_service = parser.get_value("IMAGE", "image_service") auth_admin = parser.get_value("AUTH", "auth_admin") auth_ip = parser.get_value("AUTH", "auth_ip") auth_port = parser.get_value("AUTH", "auth_port") auth_admin_port = parser.get_value("AUTH", "auth_admin_port") auth_servcie_name = parser.get_value("AUTH", "auth_service_name") auth_password_version = parser.get_value("AUTH", "auth_password_version") auth_token_version = parser.get_value("AUTH", "auth_token_version") def libcloud_driver_password(username, password, project): Driver = get_driver(Provider.OPENSTACK) conn = Driver(username, password, host=host, port=8774, secure=False, ex_tenant_name=project, ex_force_auth_version='2.0_password', ex_force_service_name='Compute Service', ex_force_auth_url=auth_service, ex_force_service_region="RegionOne") return conn def libcloud_driver_identity(username, password, project): Driver = get_driver(Provider.OPENSTACK) conn = Driver(username, password, host=auth_host, port=auth_port, secure=False, ex_tenant_name=project, ex_force_auth_version='2.0_password', ex_force_service_name='Identity Service',
# ******************************************************************** # * Copyright (c) 2009-2012 Cisco Systems, Inc. # * All rights reserved. # ******************************************************************** from glance import client as glance_client from configParse import Parse parser = Parse("properties.cfg") _glance_host = parser.get_value("IMAGE", "image_ip") _glance_port = parser.get_value("IMAGE", "image_port") def get_images(token): glance = glance_client.Client(_glance_host, int(_glance_port), auth_tok=token) images = [] for image in glance.get_images(): images.append(_format_image(image)) return images def get_images_detailed(token): glance = glance_client.Client(_glance_host, int(_glance_port), auth_tok=token) images = [] for image in glance.get_images_detailed(): images.append(_format_image_detailed(image)) return images def get_image_meta(image_id, token): glance = glance_client.Client(_glance_host, int(_glance_port), auth_tok=token) #return _format_image_detailed(glance.get_image_meta(image_id)) return glance.get_image_meta(image_id) def update_image_meta(token, image_id, image_meta=None, image_data=None, features=None):
# ******************************************************************** # * Copyright (c) 2009-2012 Cisco Systems, Inc. # * All rights reserved. # ******************************************************************** from swift.common import client as client import cloudfiles from configParse import Parse parser = Parse("properties.cfg") _object_ip = parser.get_value("OBJECT", "object_ip") _object_port = parser.get_value("OBJECT", "object_port") _object_root = parser.get_value("OBJECT", "object_root") _object_url = parser.get_value("OBJECT", "object_service") class SwiftAuthentication(object): """ Auth container in the format CloudFiles expects. """ def __init__(self, storage_url, auth_token): self.storage_url = storage_url self.auth_token = auth_token def authenticate(self): return (self.storage_url, '', self.auth_token) def swift_api(token): endpoint = _object_url auth = SwiftAuthentication(endpoint, token) return cloudfiles.get_connection(auth=auth) def swift_get_containers(token, marker=None): limit = 1000