Merge lp:~billy-olsen/charms/trusty/ceilometer/backport-lp1398182 into lp:~openstack-charmers-archive/charms/trusty/ceilometer/trunk

Proposed by Billy Olsen
Status: Merged
Merged at revision: 85
Proposed branch: lp:~billy-olsen/charms/trusty/ceilometer/backport-lp1398182
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceilometer/trunk
Diff against target: 276 lines (+113/-47)
4 files modified
config.yaml (+12/-0)
hooks/charmhelpers/contrib/hahelpers/cluster.py (+25/-0)
hooks/charmhelpers/contrib/openstack/ip.py (+49/-44)
unit_tests/test_ceilometer_hooks.py (+27/-3)
To merge this branch: bzr merge lp:~billy-olsen/charms/trusty/ceilometer/backport-lp1398182
Reviewer Review Type Date Requested Status
Corey Bryant (community) Approve
charmers Pending
Review via email: mp+261999@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #5034 ceilometer for billy-olsen mp261999
    UNIT OK: passed

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

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

charm_lint_check #5402 ceilometer for billy-olsen mp261999
    LINT OK: passed

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

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

charm_amulet_test #4645 ceilometer for billy-olsen mp261999
    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/11721339/
Build: http://10.245.162.77:8080/job/charm_amulet_test/4645/

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

The amulet failure looks like a pre-existing condition.

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

Yep, amulet test needs a fix backported so ignoring that.

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

charm_amulet_test #4664 ceilometer for billy-olsen mp261999
    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/11736479/
Build: http://10.245.162.77:8080/job/charm_amulet_test/4664/

86. By Billy Olsen

[billy-olsen,trivial] Official charm-helper stable branch sync to include
charm-helper change for public-hostname.

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

charm_lint_check #5461 ceilometer for billy-olsen mp261999
    LINT OK: passed

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

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

charm_unit_test #5093 ceilometer for billy-olsen mp261999
    UNIT OK: passed

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

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

charm_amulet_test #4665 ceilometer for billy-olsen mp261999
    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/11737936/
Build: http://10.245.162.77:8080/job/charm_amulet_test/4665/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-02-19 02:03:06 +0000
+++ config.yaml 2015-06-18 23:03:27 +0000
@@ -100,6 +100,18 @@
100 192.168.0.0/24)100 192.168.0.0/24)
101 .101 .
102 This network will be used for public endpoints.102 This network will be used for public endpoints.
103 os-public-hostname:
104 type: string
105 default:
106 description: |
107 The hostname or address of the public endpoints created for ceilometer
108 in the keystone identity provider.
109 .
110 This value will be used for public endpoints. For example, an
111 os-public-hostname set to 'ceilometer.example.com' with ssl enabled will
112 create the following public endpoints for ceilometer:
113 .
114 https://ceilometer.example.com:8777/
103 # HA configuration settings115 # HA configuration settings
104 vip:116 vip:
105 type: string117 type: string
106118
=== modified file 'hooks/charmhelpers/contrib/hahelpers/cluster.py'
--- hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-03-13 12:57:45 +0000
+++ hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-06-18 23:03:27 +0000
@@ -52,6 +52,8 @@
52 bool_from_string,52 bool_from_string,
53)53)
5454
55DC_RESOURCE_NAME = 'DC'
56
5557
56class HAIncompleteConfig(Exception):58class HAIncompleteConfig(Exception):
57 pass59 pass
@@ -95,6 +97,27 @@
95 return False97 return False
9698
9799
100def is_crm_dc():
101 """
102 Determine leadership by querying the pacemaker Designated Controller
103 """
104 cmd = ['crm', 'status']
105 try:
106 status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
107 if not isinstance(status, six.text_type):
108 status = six.text_type(status, "utf-8")
109 except subprocess.CalledProcessError:
110 return False
111 current_dc = ''
112 for line in status.split('\n'):
113 if line.startswith('Current DC'):
114 # Current DC: juju-lytrusty-machine-2 (168108163) - partition with quorum
115 current_dc = line.split(':')[1].split()[0]
116 if current_dc == get_unit_hostname():
117 return True
118 return False
119
120
98@retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound)121@retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound)
99def is_crm_leader(resource, retry=False):122def is_crm_leader(resource, retry=False):
100 """123 """
@@ -104,6 +127,8 @@
104 We allow this operation to be retried to avoid the possibility of getting a127 We allow this operation to be retried to avoid the possibility of getting a
105 false negative. See LP #1396246 for more info.128 false negative. See LP #1396246 for more info.
106 """129 """
130 if resource == DC_RESOURCE_NAME:
131 return is_crm_dc()
107 cmd = ['crm', 'resource', 'show', resource]132 cmd = ['crm', 'resource', 'show', resource]
108 try:133 try:
109 status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)134 status = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
110135
=== modified file 'hooks/charmhelpers/contrib/openstack/ip.py'
--- hooks/charmhelpers/contrib/openstack/ip.py 2015-03-13 12:57:45 +0000
+++ hooks/charmhelpers/contrib/openstack/ip.py 2015-06-18 23:03:27 +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_ceilometer_hooks.py'
--- unit_tests/test_ceilometer_hooks.py 2015-04-08 15:49:34 +0000
+++ unit_tests/test_ceilometer_hooks.py 2015-06-18 23:03:27 +0000
@@ -31,7 +31,6 @@
31 'get_ceilometer_context',31 'get_ceilometer_context',
32 'lsb_release',32 'lsb_release',
33 'get_packages',33 'get_packages',
34 'canonical_url',
35 'service_restart',34 'service_restart',
36 'update_nrpe_config',35 'update_nrpe_config',
37 'configure_https',36 'configure_https',
@@ -136,9 +135,10 @@
136 self.assertTrue(self.CONFIGS.write_all.called)135 self.assertTrue(self.CONFIGS.write_all.called)
137 self.assertTrue(joined.called)136 self.assertTrue(joined.called)
138137
138 @patch.object(hooks, 'canonical_url')
139 @patch('charmhelpers.core.hookenv.config')139 @patch('charmhelpers.core.hookenv.config')
140 def test_keystone_joined(self, mock_config):140 def test_keystone_joined(self, mock_config, _canonical_url):
141 self.canonical_url.return_value = "http://thishost"141 _canonical_url.return_value = "http://thishost"
142 self.test_config.set('region', 'myregion')142 self.test_config.set('region', 'myregion')
143 hooks.hooks.execute(['hooks/identity-service-relation-joined'])143 hooks.hooks.execute(['hooks/identity-service-relation-joined'])
144 url = "http://{}:{}".format('thishost', hooks.CEILOMETER_PORT)144 url = "http://{}:{}".format('thishost', hooks.CEILOMETER_PORT)
@@ -148,6 +148,30 @@
148 requested_roles=hooks.CEILOMETER_ROLE,148 requested_roles=hooks.CEILOMETER_ROLE,
149 region='myregion', relation_id=None)149 region='myregion', relation_id=None)
150150
151 @patch('charmhelpers.contrib.openstack.ip.service_name',
152 lambda *args: 'ceilometer')
153 @patch('charmhelpers.contrib.openstack.ip.unit_get')
154 @patch('charmhelpers.contrib.openstack.ip.is_clustered')
155 @patch('charmhelpers.core.hookenv.config')
156 @patch('charmhelpers.contrib.openstack.ip.config')
157 def test_keystone_joined_url_override(self, _config, mock_config,
158 _is_clustered, _unit_get):
159 _unit_get.return_value = "thishost"
160 _is_clustered.return_value = False
161 _config.side_effect = self.test_config.get
162 mock_config.side_effect = self.test_config.get
163 self.test_config.set('region', 'myregion')
164 self.test_config.set('os-public-hostname', 'ceilometer.example.com')
165 hooks.keystone_joined(None)
166 url = "http://{}:{}".format('thishost', hooks.CEILOMETER_PORT)
167 public_url = "http://{}:{}".format('ceilometer.example.com',
168 hooks.CEILOMETER_PORT)
169 self.relation_set.assert_called_with(
170 service=hooks.CEILOMETER_SERVICE,
171 public_url=public_url, admin_url=url, internal_url=url,
172 requested_roles=hooks.CEILOMETER_ROLE,
173 region='myregion', relation_id=None)
174
151 @patch('charmhelpers.core.hookenv.config')175 @patch('charmhelpers.core.hookenv.config')
152 def test_ceilometer_joined(self, mock_config):176 def test_ceilometer_joined(self, mock_config):
153 self.relation_ids.return_value = ['ceilometer:0']177 self.relation_ids.return_value = ['ceilometer:0']

Subscribers

People subscribed via source and target branches