Merge lp:~billy-olsen/charms/trusty/cinder/public-endpoint-host into lp:~openstack-charmers-archive/charms/trusty/cinder/next

Proposed by Billy Olsen
Status: Merged
Merged at revision: 97
Proposed branch: lp:~billy-olsen/charms/trusty/cinder/public-endpoint-host
Merge into: lp:~openstack-charmers-archive/charms/trusty/cinder/next
Diff against target: 270 lines (+107/-50)
3 files modified
config.yaml (+13/-0)
hooks/charmhelpers/contrib/openstack/ip.py (+49/-44)
unit_tests/test_cinder_hooks.py (+45/-6)
To merge this branch: bzr merge lp:~billy-olsen/charms/trusty/cinder/public-endpoint-host
Reviewer Review Type Date Requested Status
Corey Bryant (community) Approve
Review via email: mp+261010@code.launchpad.net

Description of the change

Provides a config option which allows the user to specify the public hostname used to advertise to keystone when creating endpoints.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #5048 cinder-next for billy-olsen mp261010
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/11555857/
Build: http://10.245.162.77:8080/job/charm_lint_check/5048/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #4728 cinder-next for billy-olsen mp261010
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/4728/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #5052 cinder-next for billy-olsen mp261010
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/11564175/
Build: http://10.245.162.77:8080/job/charm_lint_check/5052/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #5052 cinder-next for billy-olsen mp261010
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/11564175/
Build: http://10.245.162.77:8080/job/charm_lint_check/5052/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #5052 cinder-next for billy-olsen mp261010
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/11564175/
Build: http://10.245.162.77:8080/job/charm_lint_check/5052/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #4454 cinder-next for billy-olsen mp261010
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4454/

98. By Billy Olsen

Sync with /next branch

99. By Billy Olsen

c-h sync

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #5072 cinder-next for billy-olsen mp261010
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/11576118/
Build: http://10.245.162.77:8080/job/charm_lint_check/5072/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #4751 cinder-next for billy-olsen mp261010
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/4751/

100. By Billy Olsen

Fix lint error

Revision history for this message
Billy Olsen (billy-olsen) wrote :

Apparently the flake8 version used is different than mine and (vivid) doesn't like indented map values.

Revision history for this message
Billy Olsen (billy-olsen) wrote :

err (vivid) is mine - I'm assuming trusty for osci

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #5075 cinder-next for billy-olsen mp261010
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/5075/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #4754 cinder-next for billy-olsen mp261010
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/4754/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #4479 cinder-next for billy-olsen mp261010
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11577184/
Build: http://10.245.162.77:8080/job/charm_amulet_test/4479/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #4482 cinder-next for billy-olsen mp261010
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4482/

Revision history for this message
Corey Bryant (corey.bryant) :
review: Approve
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Hmm cinder tests seem to be failing after the merge. Can you take a look?

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Unit tests, that is.

101. By Billy Olsen

Merge with /next

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-04-02 12:13:45 +0000
+++ config.yaml 2015-06-10 21:37:32 +0000
@@ -207,6 +207,19 @@
207 192.168.0.0/24)207 192.168.0.0/24)
208 .208 .
209 This network will be used for public endpoints.209 This network will be used for public endpoints.
210 os-public-hostname:
211 type: string
212 default:
213 description: |
214 The hostname or address of the public endpoints created for cinder
215 in the keystone identity provider.
216 .
217 This value will be used for public endpoints. For example, an
218 os-public-hostname set to 'cinder.example.com' with ssl enabled will
219 create two public endpoints for cinder.
220 .
221 https://cinder.example.com:443/v1/$(tenant_id)s and
222 https://cinder.example.com:443/v2/$(tenant_id)s
210 prefer-ipv6:223 prefer-ipv6:
211 type: boolean224 type: boolean
212 default: False225 default: False
213226
=== modified file 'hooks/charmhelpers/contrib/openstack/ip.py'
--- hooks/charmhelpers/contrib/openstack/ip.py 2015-03-13 13:00:03 +0000
+++ hooks/charmhelpers/contrib/openstack/ip.py 2015-06-10 21:37:32 +0000
@@ -17,6 +17,7 @@
17from charmhelpers.core.hookenv import (17from charmhelpers.core.hookenv import (
18 config,18 config,
19 unit_get,19 unit_get,
20 service_name,
20)21)
21from charmhelpers.contrib.network.ip import (22from charmhelpers.contrib.network.ip import (
22 get_address_in_network,23 get_address_in_network,
@@ -26,8 +27,6 @@
26)27)
27from charmhelpers.contrib.hahelpers.cluster import is_clustered28from charmhelpers.contrib.hahelpers.cluster import is_clustered
2829
29from functools import partial
30
31PUBLIC = 'public'30PUBLIC = 'public'
32INTERNAL = 'int'31INTERNAL = 'int'
33ADMIN = 'admin'32ADMIN = 'admin'
@@ -35,15 +34,18 @@
35ADDRESS_MAP = {34ADDRESS_MAP = {
36 PUBLIC: {35 PUBLIC: {
37 'config': 'os-public-network',36 'config': 'os-public-network',
38 'fallback': 'public-address'37 'fallback': 'public-address',
38 'override': 'os-public-hostname',
39 },39 },
40 INTERNAL: {40 INTERNAL: {
41 'config': 'os-internal-network',41 'config': 'os-internal-network',
42 'fallback': 'private-address'42 'fallback': 'private-address',
43 'override': 'os-internal-hostname',
43 },44 },
44 ADMIN: {45 ADMIN: {
45 'config': 'os-admin-network',46 'config': 'os-admin-network',
46 'fallback': 'private-address'47 'fallback': 'private-address',
48 'override': 'os-admin-hostname',
47 }49 }
48}50}
4951
@@ -57,15 +59,50 @@
57 :param endpoint_type: str endpoint type to resolve.59 :param endpoint_type: str endpoint type to resolve.
58 :param returns: str base URL for services on the current service unit.60 :param returns: str base URL for services on the current service unit.
59 """61 """
60 scheme = 'http'62 scheme = _get_scheme(configs)
61 if 'https' in configs.complete_contexts():63
62 scheme = 'https'
63 address = resolve_address(endpoint_type)64 address = resolve_address(endpoint_type)
64 if is_ipv6(address):65 if is_ipv6(address):
65 address = "[{}]".format(address)66 address = "[{}]".format(address)
67
66 return '%s://%s' % (scheme, address)68 return '%s://%s' % (scheme, address)
6769
6870
71def _get_scheme(configs):
72 """Returns the scheme to use for the url (either http or https)
73 depending upon whether https is in the configs value.
74
75 :param configs: OSTemplateRenderer config templating object to inspect
76 for a complete https context.
77 :returns: either 'http' or 'https' depending on whether https is
78 configured within the configs context.
79 """
80 scheme = 'http'
81 if configs and 'https' in configs.complete_contexts():
82 scheme = 'https'
83 return scheme
84
85
86def _get_address_override(endpoint_type=PUBLIC):
87 """Returns any address overrides that the user has defined based on the
88 endpoint type.
89
90 Note: this function allows for the service name to be inserted into the
91 address if the user specifies {service_name}.somehost.org.
92
93 :param endpoint_type: the type of endpoint to retrieve the override
94 value for.
95 :returns: any endpoint address or hostname that the user has overridden
96 or None if an override is not present.
97 """
98 override_key = ADDRESS_MAP[endpoint_type]['override']
99 addr_override = config(override_key)
100 if not addr_override:
101 return None
102 else:
103 return addr_override.format(service_name=service_name())
104
105
69def resolve_address(endpoint_type=PUBLIC):106def resolve_address(endpoint_type=PUBLIC):
70 """Return unit address depending on net config.107 """Return unit address depending on net config.
71108
@@ -77,7 +114,10 @@
77114
78 :param endpoint_type: Network endpoing type115 :param endpoint_type: Network endpoing type
79 """116 """
80 resolved_address = None117 resolved_address = _get_address_override(endpoint_type)
118 if resolved_address:
119 return resolved_address
120
81 vips = config('vip')121 vips = config('vip')
82 if vips:122 if vips:
83 vips = vips.split()123 vips = vips.split()
@@ -109,38 +149,3 @@
109 "clustered=%s)" % (net_type, clustered))149 "clustered=%s)" % (net_type, clustered))
110150
111 return resolved_address151 return resolved_address
112
113
114def endpoint_url(configs, url_template, port, endpoint_type=PUBLIC,
115 override=None):
116 """Returns the correct endpoint URL to advertise to Keystone.
117
118 This method provides the correct endpoint URL which should be advertised to
119 the keystone charm for endpoint creation. This method allows for the url to
120 be overridden to force a keystone endpoint to have specific URL for any of
121 the defined scopes (admin, internal, public).
122
123 :param configs: OSTemplateRenderer config templating object to inspect
124 for a complete https context.
125 :param url_template: str format string for creating the url template. Only
126 two values will be passed - the scheme+hostname
127 returned by the canonical_url and the port.
128 :param endpoint_type: str endpoint type to resolve.
129 :param override: str the name of the config option which overrides the
130 endpoint URL defined by the charm itself. None will
131 disable any overrides (default).
132 """
133 if override:
134 # Return any user-defined overrides for the keystone endpoint URL.
135 user_value = config(override)
136 if user_value:
137 return user_value.strip()
138
139 return url_template % (canonical_url(configs, endpoint_type), port)
140
141
142public_endpoint = partial(endpoint_url, endpoint_type=PUBLIC)
143
144internal_endpoint = partial(endpoint_url, endpoint_type=INTERNAL)
145
146admin_endpoint = partial(endpoint_url, endpoint_type=ADMIN)
147152
=== modified file 'unit_tests/test_cinder_hooks.py'
--- unit_tests/test_cinder_hooks.py 2015-05-11 08:19:49 +0000
+++ unit_tests/test_cinder_hooks.py 2015-06-10 21:37:32 +0000
@@ -68,7 +68,6 @@
68 'openstack_upgrade_available',68 'openstack_upgrade_available',
69 'os_release',69 'os_release',
70 # charmhelpers.contrib.hahelpers.cluster_utils70 # charmhelpers.contrib.hahelpers.cluster_utils
71 'canonical_url',
72 'is_elected_leader',71 'is_elected_leader',
73 'get_hacluster_config',72 'get_hacluster_config',
74 'execd_preinstall',73 'execd_preinstall',
@@ -413,12 +412,13 @@
413 vhost='openstack',412 vhost='openstack',
414 relation_id='amqp:1')413 relation_id='amqp:1')
415414
416 def test_identity_service_joined(self):415 @patch.object(hooks, 'canonical_url')
416 def test_identity_service_joined(self, _canonical_url):
417 'It properly requests unclustered endpoint via identity-service'417 'It properly requests unclustered endpoint via identity-service'
418 self.os_release.return_value = 'havana'418 self.os_release.return_value = 'havana'
419 self.unit_get.return_value = 'cindernode1'419 self.unit_get.return_value = 'cindernode1'
420 self.config.side_effect = self.test_config.get420 self.config.side_effect = self.test_config.get
421 self.canonical_url.return_value = 'http://cindernode1'421 _canonical_url.return_value = 'http://cindernode1'
422 hooks.hooks.execute(['hooks/identity-service-relation-joined'])422 hooks.hooks.execute(['hooks/identity-service-relation-joined'])
423 expected = {423 expected = {
424 'region': None,424 'region': None,
@@ -435,12 +435,13 @@
435 }435 }
436 self.relation_set.assert_called_with(**expected)436 self.relation_set.assert_called_with(**expected)
437437
438 def test_identity_service_joined_icehouse(self):438 @patch.object(hooks, 'canonical_url')
439 def test_identity_service_joined_icehouse(self, _canonical_url):
439 'It properly requests unclustered endpoint via identity-service'440 'It properly requests unclustered endpoint via identity-service'
440 self.os_release.return_value = 'icehouse'441 self.os_release.return_value = 'icehouse'
441 self.unit_get.return_value = 'cindernode1'442 self.unit_get.return_value = 'cindernode1'
442 self.config.side_effect = self.test_config.get443 self.config.side_effect = self.test_config.get
443 self.canonical_url.return_value = 'http://cindernode1'444 _canonical_url.return_value = 'http://cindernode1'
444 hooks.hooks.execute(['hooks/identity-service-relation-joined'])445 hooks.hooks.execute(['hooks/identity-service-relation-joined'])
445 expected = {446 expected = {
446 'region': None,447 'region': None,
@@ -463,6 +464,42 @@
463 }464 }
464 self.relation_set.assert_called_with(**expected)465 self.relation_set.assert_called_with(**expected)
465466
467 @patch('charmhelpers.contrib.openstack.ip.config')
468 @patch('charmhelpers.contrib.openstack.ip.unit_get')
469 @patch('charmhelpers.contrib.openstack.ip.is_clustered')
470 def test_identity_service_joined_public_name(self, _is_clustered,
471 _unit_get, _config):
472 self.os_release.return_value = 'icehouse'
473 self.unit_get.return_value = 'cindernode1'
474 _unit_get.return_value = 'cindernode1'
475 self.config.side_effect = self.test_config.get
476 _config.side_effect = self.test_config.get
477 self.test_config.set('os-public-hostname', 'public.example.com')
478 _is_clustered.return_value = False
479 hooks.hooks.execute(['hooks/identity-service-relation-joined'])
480 v1_url = 'http://public.example.com:8776/v1/$(tenant_id)s'
481 v2_url = 'http://public.example.com:8776/v2/$(tenant_id)s'
482 expected = {
483 'region': None,
484 'service': None,
485 'public_url': None,
486 'internal_url': None,
487 'admin_url': None,
488 'cinder_service': 'cinder',
489 'cinder_region': 'RegionOne',
490 'cinder_public_url': v1_url,
491 'cinder_admin_url': 'http://cindernode1:8776/v1/$(tenant_id)s',
492 'cinder_internal_url': 'http://cindernode1:8776/v1/$(tenant_id)s',
493 'cinderv2_service': 'cinderv2',
494 'cinderv2_region': 'RegionOne',
495 'cinderv2_public_url': v2_url,
496 'cinderv2_admin_url': 'http://cindernode1:8776/v2/$(tenant_id)s',
497 'cinderv2_internal_url': ('http://cindernode1:8776/'
498 'v2/$(tenant_id)s'),
499 'relation_id': None,
500 }
501 self.relation_set.assert_called_with(**expected)
502
466 @patch('os.mkdir')503 @patch('os.mkdir')
467 def test_ceph_joined(self, mkdir):504 def test_ceph_joined(self, mkdir):
468 'It correctly prepares for a ceph changed hook'505 'It correctly prepares for a ceph changed hook'
@@ -502,8 +539,10 @@
502 self.assertNotIn(c, self.CONFIGS.write.call_args_list)539 self.assertNotIn(c, self.CONFIGS.write.call_args_list)
503 self.assertFalse(self.set_ceph_env_variables.called)540 self.assertFalse(self.set_ceph_env_variables.called)
504541
542 @patch('charmhelpers.core.host.service')
505 @patch("cinder_hooks.relation_get", autospec=True)543 @patch("cinder_hooks.relation_get", autospec=True)
506 def test_ceph_changed_broker_success(self, mock_relation_get):544 def test_ceph_changed_broker_success(self, mock_relation_get,
545 _service):
507 'It ensures ceph assets created on ceph changed'546 'It ensures ceph assets created on ceph changed'
508 self.CONFIGS.complete_contexts.return_value = ['ceph']547 self.CONFIGS.complete_contexts.return_value = ['ceph']
509 self.service_name.return_value = 'cinder'548 self.service_name.return_value = 'cinder'

Subscribers

People subscribed via source and target branches