Glance API works now with HAProxy

This commit is contained in:
Przemyslaw Kaminski 2015-06-03 16:28:28 +02:00
parent 5cbccf9006
commit 973c1beaa2
7 changed files with 28 additions and 15 deletions

View File

@ -53,14 +53,17 @@ def deploy():
glance_keystone_user = resource.create('glance_keystone_user', 'resources/keystone_user', {'user_name': 'glance_admin', 'user_password': 'password1234', 'tenant_name': 'service_admins', 'role_name': 'glance_admin', 'keystone_host': '', 'keystone_port': '', 'admin_token': '', 'ip': '', 'ssh_key': '', 'ssh_user': ''})
glance_keystone_role = resource.create('glance_keystone_role', 'resources/keystone_role', {'keystone_host': '', 'keystone_port': '', 'login_user': 'admin', 'admin_token': '', 'tenant_name': '', 'user_name': '', 'role_name': 'admin', 'ip': '', 'ssh_user': '', 'ssh_key': ''})
glance_config = resource.create('glance_config', 'resources/glance_config/', {'ip': '', 'ssh_key': '', 'ssh_user': '', 'keystone_ip': '', 'keystone_port': '', 'config_dir': {}, 'api_port': '', 'registry_port': '', 'mysql_ip': '', 'mysql_db': '', 'mysql_user': '', 'mysql_password': '', 'keystone_admin_user': '', 'keystone_admin_password': '', 'keystone_admin_port': '', 'keystone_admin_tenant': ''})
# TODO: add api_host and registry_host -- they can be different! Currently 'ip' is used.
glance_config = resource.create('glance_config', 'resources/glance_config/', {'ip': '', 'ssh_key': '', 'ssh_user': '', 'keystone_ip': '', 'keystone_port': '', 'config_dir': {}, 'api_port': 9393, 'registry_port': '', 'mysql_ip': '', 'mysql_db': '', 'mysql_user': '', 'mysql_password': '', 'keystone_admin_user': '', 'keystone_admin_password': '', 'keystone_admin_port': '', 'keystone_admin_tenant': ''})
glance_api_container = resource.create('glance_api_container', 'resources/glance_api_service/', {'image': 'cgenie/centos-rdo-glance-api', 'ports': [{'value': [{'value': 9393}]}], 'host_binds': [], 'volume_binds': [], 'db_password': '', 'keystone_password': '', 'keystone_admin_token': '', 'keystone_host': '', 'ip': '', 'ssh_key': '', 'ssh_user': ''})
glance_registry_container = resource.create('glance_registry_container', 'resources/glance_registry_service/', {'image': 'cgenie/centos-rdo-glance-registry', 'ports': [{'value': [{'value': 9191}]}], 'host_binds': [], 'volume_binds': [], 'db_host': '', 'db_root_password': '', 'db_password': '', 'db_name': '', 'db_user': '', 'keystone_admin_tenant': '', 'keystone_password': '', 'keystone_user': '', 'keystone_admin_token': '', 'keystone_host': '', 'ip': '', 'ssh_key': '', 'ssh_user': ''})
# TODO: admin_port should be refactored, we need to rethink docker
# container resource and make it common for all
# resources used in this demo
glance_api_endpoint = resource.create('glance_api_endpoint', 'resources/keystone_service_endpoint/', {'ip': '', 'ssh_key': '', 'ssh_user': '', 'admin_port': '', 'admin_token': '', 'adminurl': 'http://{{ip}}:{{admin_port}}', 'internalurl': 'http://{{ip}}:{{port}}', 'publicurl': 'http://{{ip}}:{{port}}', 'description': 'OpenStack Image Service', 'keystone_host': '', 'keystone_port': '', 'name': 'glance', 'port': '', 'type': 'image'})
haproxy_glance_api_config = resource.create('haproxy_glance_api_config', 'resources/haproxy_service_config/', {'name': 'glance_api_config', 'listen_port': 9292, 'servers': [], 'ports':[]})
# TODO: ports value 9393 is a HACK -- fix glance_api_container's port and move to some config
# TODO: glance registry container's API port needs to point to haproxy_config
haproxy_glance_api_config = resource.create('haproxy_glance_api_config', 'resources/haproxy_service_config/', {'name': 'glance_api_config', 'listen_port': 9292, 'servers': [], 'ports':[{'value': 9393}]})
admin_tenant = resource.create('admin_tenant', 'resources/keystone_tenant', {'keystone_host': '', 'keystone_port': '', 'login_user': 'admin', 'admin_token': '', 'tenant_name': 'admin', 'ip': '', 'ssh_user': '', 'ssh_key': ''})
admin_user = resource.create('admin_user', 'resources/keystone_user', {'keystone_host': '', 'keystone_port': '', 'login_user': 'admin', 'admin_token': '', 'tenant_name': '', 'user_name': 'admin', 'user_password': 'admin', 'ip': '', 'ssh_user': '', 'ssh_key': ''})
@ -166,11 +169,12 @@ def deploy():
# glance haproxy
signals.connect(glance_api_container, haproxy_glance_api_config, {'ip': 'servers'})
signals.connect(glance_config, haproxy_glance_api_config, {'api_port': 'ports'})
#signals.connect(glance_config, haproxy_glance_api_config, {'api_port': 'ports'})
signals.connect(haproxy_glance_api_config, haproxy_config, {'listen_port': 'listen_ports', 'name': 'configs_names', 'ports': 'configs_ports', 'servers': 'configs'})
# glance keystone endpoint
signals.connect(glance_api_container, glance_api_endpoint, {'ip': 'ip', 'ssh_user': 'ssh_user', 'ssh_key': 'ssh_key'})
#signals.connect(glance_api_container, glance_api_endpoint, {'ip': 'ip', 'ssh_user': 'ssh_user', 'ssh_key': 'ssh_key'})
signals.connect(haproxy_service, glance_api_endpoint, {'ip': 'ip', 'ssh_user': 'ssh_user', 'ssh_key': 'ssh_key'})
signals.connect(keystone_config1, glance_api_endpoint, {'admin_token': 'admin_token'})
signals.connect(keystone_service1, glance_api_endpoint, {'ip': 'keystone_host', 'admin_port': 'keystone_port'})
signals.connect(haproxy_glance_api_config, glance_api_endpoint, {'listen_port': 'admin_port'})
@ -220,10 +224,15 @@ def deploy():
actions.resource_action(glance_db, 'run')
actions.resource_action(glance_db_user, 'run')
actions.resource_action(glance_config, 'run')
actions.resource_action(glance_registry_container, 'run')
time.sleep(10) #TODO fix
actions.resource_action(glance_api_container, 'run')
actions.resource_action(glance_api_endpoint, 'run')
time.sleep(10) #TODO fix
actions.resource_action(glance_registry_container, 'run')
time.sleep(10)
# HAProxy needs to be restarted after Glance API is up
actions.resource_action(haproxy_service, 'remove')
actions.resource_action(haproxy_service, 'run')
time.sleep(10)
# test working configuration
@ -250,8 +259,11 @@ def deploy():
requests.get('http://%s:%s' % (rabbitmq_service1.args['ip'].value, rabbitmq_service1.args['management_port'].value))
#requests.get('http://%s:%s' % (glance_api_container.args['ip'].value, glance_api_container.args['ports'].value[0]['value'][0]['value']))
requests.get('http://%s:%s' % (glance_api_container.args['ip'].value, haproxy_glance_api_config.args['listen_port'].value))
images = requests.get(
'http://%s:%s/v1/images' % (glance_api_container.args['ip'].value, haproxy_glance_api_config.args['listen_port'].value),
headers={'X-Auth-Token': token}
)
assert images.json() == {'images': []}
requests.get(
'http://%s:%s' % (glance_registry_container.args['ip'].value, glance_registry_container.args['ports'].value[0]['value'][0]['value']),
headers={'X-Auth-Token': token}

View File

@ -9,9 +9,9 @@
image: {{ image }}
state: running
expose:
- 9292
- 9393
ports:
- {{ ports.value[0]['value'][0]['value'] }}:9292
- {{ ports.value[0]['value'][0]['value'] }}:9393
{% if host_binds.value %}
volumes:
# TODO: host_binds might need more work

View File

@ -1,6 +1,7 @@
- hosts: [{{ ip }}]
sudo: yes
vars:
ip: {{ ip }}
api_port: {{ api_port }}
registry_port: {{ registry_port }}
keystone_ip: {{ keystone_ip }}

View File

@ -4,7 +4,7 @@ bind_host = 0.0.0.0
bind_port = {{ api_port }}
log_file = /var/log/glance/api.log
backlog = 4096
registry_host = 0.0.0.0
registry_host = {{ ip }}
registry_port = {{ registry_port }}
registry_client_protocol = http

View File

@ -26,7 +26,7 @@ image_cache_stall_time = 86400
image_cache_max_size = 10737418240
# Address to find the registry server
registry_host = 0.0.0.0
registry_host = {{ ip }}
# Port the registry server is listening on
registry_port = 9191

View File

@ -32,7 +32,7 @@ cleanup_scrubber = False
cleanup_scrubber_time = 86400
# Address to find the registry server for cleanups
registry_host = 0.0.0.0
registry_host = {{ ip }}
# Port the registry server is listening on
registry_port = 9191

View File

@ -3,8 +3,8 @@
sudo: yes
tasks:
- docker:
command: /bin/bash -c "glance-manage db_sync && /usr/bin/glance-registry"
#command: /usr/bin/glance-registry
#command: /bin/bash -c "glance-manage db_sync && /usr/bin/glance-registry"
command: /usr/bin/glance-registry
name: {{ name }}
image: {{ image }}
state: running