From c7169d18e060bdc5c33033673cc9db15ecde655c Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 31 May 2012 12:43:48 -0700 Subject: [PATCH] Full parameterize the rest of keystones init yaml file with helper params --- anvil/actions/base.py | 3 +- anvil/helpers/nova.py | 37 +++++++++++++-- anvil/helpers/quantum.py | 16 +++++++ anvil/helpers/swift.py | 16 +++++++ anvil/opts.py | 2 +- conf/templates/keystone/init_what.yaml | 64 +++++++++++++------------- 6 files changed, 100 insertions(+), 38 deletions(-) diff --git a/anvil/actions/base.py b/anvil/actions/base.py index 99e64e44..de6396d2 100644 --- a/anvil/actions/base.py +++ b/anvil/actions/base.py @@ -19,7 +19,6 @@ import collections import glob from anvil import colorizer -from anvil import date from anvil import exceptions as excp from anvil import log as logging from anvil import packager @@ -127,7 +126,7 @@ class Action(object): Run a given 'functor' across all of the components, in order. """ component_results = dict() - phase_fn = "%s.%s.phases" % (self.get_action_name(), phase_name.lower()) + phase_fn = "%s.%s.phases" % (self.get_action_name(), phase_name.lower()) phase_recorder = phase.PhaseRecorder(sh.joinpths(self.root_dir, phase_fn)) for c in component_order: instance = instances[c] diff --git a/anvil/helpers/nova.py b/anvil/helpers/nova.py index c3cc1007..12b5782f 100644 --- a/anvil/helpers/nova.py +++ b/anvil/helpers/nova.py @@ -19,7 +19,6 @@ import os import weakref from anvil import cfg -from anvil import date from anvil import exceptions from anvil import libvirt as lv from anvil import log as logging @@ -126,10 +125,42 @@ def canon_virt_driver(virt_driver): return virt_driver -def get_shared_params(cfg): +def get_shared_params(cfgobj): mp = dict() - host_ip = cfg.get('host', 'ip') + + host_ip = cfgobj.get('host', 'ip') mp['service_host'] = host_ip + nova_host = cfgobj.getdefaulted('nova', 'nova_host', host_ip) + nova_protocol = cfgobj.getdefaulted('nova', 'nova_protocol', 'http') + + # Uri's of the various nova endpoints + mp['endpoints'] = { + 'ec2': { + 'uri': utils.make_url(nova_protocol, nova_host, 8773, "services/Admin"), + 'port': 8773, + 'host': host_ip, + 'protocol': nova_protocol, + }, + 'volume': { + 'uri': utils.make_url(nova_protocol, host_ip, 8776, "v1"), + 'port': 8776, + 'host': host_ip, + 'protocol': nova_protocol, + }, + 's3': { + 'uri': utils.make_url('http', host_ip, 3333), + 'port': 3333, + 'host': host_ip, + 'protocol': nova_protocol, + }, + 'api': { + 'uri': utils.make_url('http', host_ip, 8774, "v2"), + 'port': 8774, + 'host': host_ip, + 'protocol': nova_protocol, + }, + } + return mp diff --git a/anvil/helpers/quantum.py b/anvil/helpers/quantum.py index c1fc872c..85adf637 100644 --- a/anvil/helpers/quantum.py +++ b/anvil/helpers/quantum.py @@ -26,4 +26,20 @@ def get_shared_params(cfg): host_ip = cfg.get('host', 'ip') mp['service_host'] = host_ip + # Components of the various endpoints + quantum_host = cfg.getdefaulted('quantum', 'quantum_host', host_ip) + quantum_port = cfg.getdefaulted('quantum', 'quantum_port', '9696') + quantum_proto = cfg.getdefaulted('quantum', 'quantum_protocol', 'http') + quantum_uri = utils.make_url(quantum_proto, quantum_host, quantum_port) + mp['endpoints'] = { + 'admin': { + 'uri': quantum_uri, + 'port': quantum_port, + 'protocol': quantum_proto, + 'host': quantum_host, + }, + } + mp['endpoints']['public'] = dict(mp['endpoints']['admin']) + mp['endpoints']['internal'] = dict(mp['endpoints']['public']) + return mp diff --git a/anvil/helpers/swift.py b/anvil/helpers/swift.py index c1fc872c..2e1cce12 100644 --- a/anvil/helpers/swift.py +++ b/anvil/helpers/swift.py @@ -26,4 +26,20 @@ def get_shared_params(cfg): host_ip = cfg.get('host', 'ip') mp['service_host'] = host_ip + # Components of the various endpoints + swift_host = cfg.getdefaulted('swift', 'swift_host', host_ip) + swift_port = cfg.getdefaulted('swift', 'swift_port', '8080') + swift_proto = cfg.getdefaulted('swift', 'swift_protocol', 'http') + swift_uri = utils.make_url(swift_proto, swift_host, swift_port) + mp['endpoints'] = { + 'admin': { + 'uri': swift_uri, + 'port': swift_port, + 'protocol': swift_proto, + 'host': swift_host, + }, + } + mp['endpoints']['public'] = dict(mp['endpoints']['admin']) + mp['endpoints']['internal'] = dict(mp['endpoints']['public']) + return mp diff --git a/anvil/opts.py b/anvil/opts.py index 5dad9ad3..e2230b2e 100644 --- a/anvil/opts.py +++ b/anvil/opts.py @@ -28,7 +28,7 @@ HELP_WIDTH = 80 def _format_list(in_list): sorted_list = sorted(in_list) - return "[" + ", ".join(sorted_list) + "]" + return "[" + ", ".join(sorted_list) + "]" def parse(): diff --git a/conf/templates/keystone/init_what.yaml b/conf/templates/keystone/init_what.yaml index 6b8ce326..cf6fbd2d 100644 --- a/conf/templates/keystone/init_what.yaml +++ b/conf/templates/keystone/init_what.yaml @@ -1,45 +1,45 @@ --- endpoints: -- admin_url: http://%swift.service_host%:8080/v1/AUTH_%(tenant_id)s - internal_url: http://%swift.service_host%:8080/ - public_url: http://%swift.service_host%:8080/v1/AUTH_%(tenant_id)s +- service: swift + admin_url: "%swift.endpoints.admin.uri%/v1/AUTH_%(tenant_id)s" + internal_url: "%swift.endpoints.internal.uri%" + public_url: "%swift.endpoints.public.uri%/v1/AUTH_%(tenant_id)s" region: RegionOne - service: swift -- admin_url: http://%nova.service_host%:8773/services/Admin - internal_url: http://%nova.service_host%:8773/services/Cloud - public_url: http://%nova.service_host%:8773/services/Cloud +- service: ec2 + admin_url: "%nova.endpoints.ec2.uri%" + internal_url: "%nova.endpoints.ec2.uri%" + public_url: "%nova.endpoints.ec2.uri%" region: RegionOne - service: ec2 -- admin_url: http://%quantum.service_host%:9696/ - internal_url: http://%quantum.service_host%:9696/ - public_url: http://%quantum.service_host%:9696/ +- service: network + admin_url: "%quantum.endpoints.admin.uri%" + internal_url: "%quantum.endpoints.internal.uri%" + public_url: "%quantum.endpoints.public.uri%" region: RegionOne - service: network -- admin_url: http://%glance.service_host%:9292 - internal_url: http://%glance.service_host%:9292 - public_url: http://%glance.service_host%:9292 +- service: glance + admin_url: "%glance.endpoints.admin.uri%" + internal_url: "%glance.endpoints.internal.uri%" + public_url: "%glance.endpoints.public.uri%" region: RegionOne - service: glance -- admin_url: http://%nova.service_host%:8776/v1/%(tenant_id)s - internal_url: http://%nova.service_host%:8776/v1/%(tenant_id)s - public_url: http://%nova.service_host%:8776/v1/%(tenant_id)s +- service: volume + admin_url: "%nova.endpoints.volume.uri%/%(tenant_id)s" + internal_url: "%nova.endpoints.volume.uri%/%(tenant_id)s" + public_url: "%nova.endpoints.volume.uri%/%(tenant_id)s" region: RegionOne - service: volume -- admin_url: http://%nova.service_host%:3333 - internal_url: http://%nova.service_host%:3333 - public_url: http://%nova.service_host%:3333 +- service: s3 + admin_url: "%nova.endpoints.s3.uri%" + internal_url: "%nova.endpoints.s3.uri%" + public_url: "%nova.endpoints.s3.uri%" region: RegionOne - service: s3 -- admin_url: http://%keystone.service_host%:$(admin_port)s/v2.0 - internal_url: http://%keystone.service_host%:$(public_port)s/v2.0 - public_url: http://%keystone.service_host%:$(public_port)s/v2.0 +- service: keystone + admin_url: "%keystone.endpoints.admin.uri%" + internal_url: "%keystone.endpoints.internal.uri%" + public_url: "%keystone.endpoints.public.uri%" region: RegionOne - service: keystone -- admin_url: http://%nova.service_host%:8774/v2/%(tenant_id)s - internal_url: http://%nova.service_host%:8774/v2/%(tenant_id)s - public_url: http://%nova.service_host%:8774/v2/%(tenant_id)s +- service: nova + admin_url: "%nova.endpoints.api.uri%/%(tenant_id)s" + internal_url: "%nova.endpoints.api.uri%/%(tenant_id)s" + public_url: "%nova.endpoints.api.uri%/%(tenant_id)s" region: RegionOne - service: nova roles: - admin - anotherrole