keystone_changed

This commit is contained in:
Andres Rodriguez 2013-06-24 23:24:17 -04:00
parent e50a423f33
commit d9a942d88c
7 changed files with 177 additions and 61 deletions

View File

@ -241,64 +241,15 @@ def keystone_joined(relation_id=None):
def keystone_changed():
CONFIGS.write('/etc/glance/glance-api-paste.ini')
CONFIGS.write('/etc/glance/glance-registry-paste.ini')
if 'identity-service' not in CONFIGS.complete_contexts():
juju_log('INFO', 'identity-service relation incomplete. Peer not ready?')
return
CONFIGS.write('/etc/glance/glance-api.conf')
CONFIGS.write('/etc/glance/glance-registry.conf')
restart(*SERVICES)
# Configure any object-store / swift relations now that we have an
# identity-service
if relation_ids('object-store'):
object_store_joined()
# possibly configure HTTPS for API and registry
configure_https()
for r_id in relation_ids('identity-service'):
keystone_joined(relation_id=r_id)
for r_id in relation_ids('image-service'):
image_service_joined(relation_id=r_id)
def keystone_changed(rid=None):
relation_data = relation_get_dict(relation_id=rid)
token = relation_data["admin_token"]
service_port = relation_data["service_port"]
auth_port = relation_data["auth_port"]
service_username = relation_data["service_username"]
service_password = relation_data["service_password"]
service_tenant = relation_data["service_tenant"]
if not token or not service_port or not auth_port or \
not service_username or not service_password or not service_tenant:
juju_log('INFO', 'keystone_changed: Peer not ready')
sys.exit(0)
if token == "-1":
juju_log('ERROR', 'keystone_changed: admin token error')
sys.exit(1)
juju_log('INFO', 'keystone_changed: Acquired admin token')
keystone_host = relation_data["auth_host"]
set_or_update(key='flavor', value='keystone', file='api', section="paste_deploy")
set_or_update(key='flavor', value='keystone', file='registry', section="paste_deploy")
section = "filter:authtoken"
for i in ['api-paste', 'registry-paste']:
set_or_update(key='service_host', value=keystone_host, file=i, section=section)
set_or_update(key='service_port', value=service_port, file=i, section=section)
set_or_update(key='auth_host', value=keystone_host, file=i, section=section)
set_or_update(key='auth_port', value=auth_port, file=i, section=section)
set_or_update(key='auth_uri', value="http://%s:%s/" % (keystone_host, service_port), file=i, section=section)
set_or_update(key='admin_token', value=token, file=i, section=section)
set_or_update(key='admin_tenant_name', value=service_tenant, file=i, section=section)
set_or_update(key='admin_user', value=service_username, file=i, section=section)
set_or_update(key='admin_password', value=service_password, file=i, section=section)
CONFIGS.write('/etc/glance/glance-api-paste.ini')
CONFIGS.write('/etc/glance/glance-registry-paste.ini')
restart(*SERVICES)
@ -310,10 +261,11 @@ def keystone_changed(rid=None):
# possibly configure HTTPS for API and registry
configure_https()
for r_id in relation_ids('identity-service'):
keystone_joined(relation_id=r_id)
for r_id in relation_ids('image-service'):
image_service_joined(relation_id=r_id)
# TODO: maybe this should be removed as it was added on the initial port.
#for r_id in relation_ids('identity-service'):
# keystone_joined(relation_id=r_id)
#for r_id in relation_ids('image-service'):
# image_service_joined(relation_id=r_id)
def config_changed():

View File

@ -27,13 +27,23 @@ TEMPLATES = 'templates/'
CONFIG_FILES = OrderedDict([
('/etc/glance/glance-registry.conf', {
'hook_contexts': [context.SharedDBContext()],
'hook_contexts': [context.SharedDBContext(),
context.IdentityServiceContext()],
'services': ['glance-registry']
}),
('/etc/glance/glance-api.conf', {
'hook_contexts': [context.SharedDBContext()],
'hook_contexts': [context.SharedDBContext(),
context.IdentityServiceContext()],
'services': ['glance-api']
}),
('/etc/glance/glance-api-paste.ini', {
'hook_contexts': [context.IdentityServiceContext()],
'services': ['glance-api']
}),
('/etc/glance/glance-registry-paste.ini', {
'hook_contexts': [context.IdentityServiceContext()],
'services': ['glance-registry']
}),
])
def register_configs():
@ -44,7 +54,9 @@ def register_configs():
openstack_release='grizzly')
confs = ['/etc/glance/glance-registry.conf',
'/etc/glance/glance-api.conf']
'/etc/glance/glance-api.conf',
'/etc/glance/glance-api-paste.ini',
'/etc/glance/glance-registry-paste.ini',]
for conf in confs:
configs.register(conf, CONFIG_FILES[conf]['hook_contexts'])

View File

@ -0,0 +1,65 @@
[DEFAULT]
verbose = True
debug = True
default_store = file
bind_host = 0.0.0.0
bind_port = 9292
log_file = /var/log/glance/api.log
backlog = 4096
workers = 0
use_syslog = False
registry_host = 0.0.0.0
registry_port = 9191
registry_client_protocol = http
notifier_strategy = noop
rabbit_host = localhost
rabbit_port = 5672
rabbit_use_ssl = false
rabbit_userid = guest
rabbit_password = guest
rabbit_virtual_host = /
rabbit_notification_exchange = glance
rabbit_notification_topic = glance_notifications
qpid_notification_exchange = glance
qpid_notification_topic = glance_notifications
qpid_host = localhost
qpid_port = 5672
qpid_username =
qpid_password =
qpid_sasl_mechanisms =
qpid_reconnect_timeout = 0
qpid_reconnect_limit = 0
qpid_reconnect_interval_min = 0
qpid_reconnect_interval_max = 0
qpid_reconnect_interval = 0
qpid_heartbeat = 5
qpid_protocol = tcp
qpid_tcp_nodelay = True
filesystem_store_datadir = /var/lib/glance/images/
swift_store_auth_version = 2
swift_store_auth_address = 127.0.0.1:35357/v2.0/
swift_store_user = jdoe:jdoe
swift_store_key = a86850deb2742ec3cb41518e26aa2d89
swift_store_container = glance
swift_store_create_container_on_put = False
swift_store_large_object_size = 5120
swift_store_large_object_chunk_size = 200
swift_enable_snet = False
s3_store_host = 127.0.0.1:8080/v1.0/
s3_store_access_key = <20-char AWS access key>
s3_store_secret_key = <40-char AWS secret key>
s3_store_bucket = <lowercased 20-char aws access key>glance
s3_store_create_bucket_on_put = False
rbd_store_ceph_conf = /etc/ceph/ceph.conf
rbd_store_user = glance
rbd_store_pool = images
rbd_store_chunk_size = 8
delayed_delete = False
scrub_time = 43200
scrubber_datadir = /var/lib/glance/scrubber
image_cache_dir = /var/lib/glance/image-cache/
{% if auth_host %}
[paste_deploy]
flavor = keystone
{% endif %}

View File

@ -74,4 +74,7 @@ admin_tenant_name = %SERVICE_TENANT_NAME%
admin_user = %SERVICE_USER%
admin_password = %SERVICE_PASSWORD%
{% if auth_host %}
[paste_deploy]
flavor = keystone
{% endif %}

View File

@ -0,0 +1,51 @@
[pipeline:glance-api]
pipeline = versionnegotiation context apiv1app
[pipeline:glance-api-keystone]
pipeline = versionnegotiation authtoken context apiv1app
[pipeline:glance-api-caching]
pipeline = versionnegotiation context cache apiv1app
[pipeline:glance-api-keystone+caching]
pipeline = versionnegotiation authtoken context cache apiv1app
[pipeline:glance-api-cachemanagement]
pipeline = versionnegotiation context cache cachemanage apiv1app
[pipeline:glance-api-keystone+cachemanagement]
pipeline = versionnegotiation authtoken context cache cachemanage apiv1app
[app:apiv1app]
paste.app_factory = glance.common.wsgi:app_factory
glance.app_factory = glance.api.v1.router:API
[filter:versionnegotiation]
paste.filter_factory = glance.common.wsgi:filter_factory
glance.filter_factory = glance.api.middleware.version_negotiation:VersionNegotiationFilter
[filter:cache]
paste.filter_factory = glance.common.wsgi:filter_factory
glance.filter_factory = glance.api.middleware.cache:CacheFilter
[filter:cachemanage]
paste.filter_factory = glance.common.wsgi:filter_factory
glance.filter_factory = glance.api.middleware.cache_manage:CacheManageFilter
[filter:context]
paste.filter_factory = glance.common.wsgi:filter_factory
glance.filter_factory = glance.common.context:ContextMiddleware
[filter:authtoken]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
service_protocol = {{ service_protocol }}
service_host = {{ service_host }}
service_port = {{ service_port }}
auth_host = {{ auth_host }}
auth_port = {{ auth_port }}
auth_protocol = {{ auth_protocol }}
auth_uri = http://{{ service_host }}:{{ service_port }}/
admin_tenant_name = {{ admin_tenant_name }}
admin_user = {{ admin_user }}
admin_password = {{ admin_password }}
admin_token = {{ admin_token }}

View File

@ -0,0 +1,28 @@
[pipeline:glance-registry]
pipeline = context registryapp
[pipeline:glance-registry-keystone]
pipeline = authtoken context registryapp
[app:registryapp]
paste.app_factory = glance.common.wsgi:app_factory
glance.app_factory = glance.registry.api.v1:API
[filter:context]
context_class = glance.registry.context.RequestContext
paste.filter_factory = glance.common.wsgi:filter_factory
glance.filter_factory = glance.common.context:ContextMiddleware
[filter:authtoken]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
service_protocol = {{ service_protocol }}
service_host = {{ service_host }}
service_port = {{ service_port }}
auth_host = {{ auth_host }}
auth_port = {{ auth_port }}
auth_protocol = {{ auth_protocol }}
auth_uri = http://{{ service_host }}:{{ service_port }}/
admin_tenant_name = {{ admin_tenant_name }}
admin_user = {{ admin_user }}
admin_password = {{ admin_password }}
admin_token = {{ admin_token }

View File

@ -12,3 +12,8 @@ sql_idle_timeout = 3600
api_limit_max = 1000
limit_param_default = 25
use_syslog = False
{% if auth_host %}
[paste_deploy]
flavor = keystone
{% endif %}