Merge lp:~billy-olsen/charms/trusty/nova-cloud-controller/backport-lp1398182 into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/trunk
- Trusty Tahr (14.04)
- backport-lp1398182
- Merge into trunk
Proposed by
Billy Olsen
Status: | Merged |
---|---|
Merged at revision: | 165 |
Proposed branch: | lp:~billy-olsen/charms/trusty/nova-cloud-controller/backport-lp1398182 |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/trunk |
Diff against target: |
506 lines (+151/-69) (has conflicts) 5 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_nova_cc_contexts.py (+8/-4) unit_tests/test_nova_cc_hooks.py (+57/-21) Text conflict in unit_tests/test_nova_cc_hooks.py |
To merge this branch: | bzr merge lp:~billy-olsen/charms/trusty/nova-cloud-controller/backport-lp1398182 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Corey Bryant (community) | Approve | ||
Review via email: mp+262006@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #5041 nova-cloud-
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #4652 nova-cloud-
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://
Build: http://
Revision history for this message
Corey Bryant (corey.bryant) : | # |
review:
Approve
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #4663 nova-cloud-
AMULET OK: passed
Build: http://
- 165. By Billy Olsen
-
Official c-h stable sync
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'config.yaml' | |||
2 | --- config.yaml 2015-04-20 10:21:36 +0000 | |||
3 | +++ config.yaml 2015-06-18 23:39:46 +0000 | |||
4 | @@ -230,6 +230,18 @@ | |||
5 | 230 | 192.168.0.0/24) | 230 | 192.168.0.0/24) |
6 | 231 | . | 231 | . |
7 | 232 | This network will be used for public endpoints. | 232 | This network will be used for public endpoints. |
8 | 233 | os-public-hostname: | ||
9 | 234 | type: string | ||
10 | 235 | default: | ||
11 | 236 | description: | | ||
12 | 237 | The hostname or address of the public endpoints provided by the | ||
13 | 238 | nova-cloud-controller in the keystone identity provider. | ||
14 | 239 | . | ||
15 | 240 | This value will be used for public endpoints. For example, an | ||
16 | 241 | os-public-hostname set to 'ncc.example.com' with ssl enabled will | ||
17 | 242 | create public endpoints such as: | ||
18 | 243 | . | ||
19 | 244 | https://ncc.example.com:8775/v2/$(tenant_id)s | ||
20 | 233 | service-guard: | 245 | service-guard: |
21 | 234 | type: boolean | 246 | type: boolean |
22 | 235 | default: false | 247 | default: false |
23 | 236 | 248 | ||
24 | === modified file 'hooks/charmhelpers/contrib/hahelpers/cluster.py' | |||
25 | --- hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-03-16 14:17:04 +0000 | |||
26 | +++ hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-06-18 23:39:46 +0000 | |||
27 | @@ -52,6 +52,8 @@ | |||
28 | 52 | bool_from_string, | 52 | bool_from_string, |
29 | 53 | ) | 53 | ) |
30 | 54 | 54 | ||
31 | 55 | DC_RESOURCE_NAME = 'DC' | ||
32 | 56 | |||
33 | 55 | 57 | ||
34 | 56 | class HAIncompleteConfig(Exception): | 58 | class HAIncompleteConfig(Exception): |
35 | 57 | pass | 59 | pass |
36 | @@ -95,6 +97,27 @@ | |||
37 | 95 | return False | 97 | return False |
38 | 96 | 98 | ||
39 | 97 | 99 | ||
40 | 100 | def is_crm_dc(): | ||
41 | 101 | """ | ||
42 | 102 | Determine leadership by querying the pacemaker Designated Controller | ||
43 | 103 | """ | ||
44 | 104 | cmd = ['crm', 'status'] | ||
45 | 105 | try: | ||
46 | 106 | status = subprocess.check_output(cmd, stderr=subprocess.STDOUT) | ||
47 | 107 | if not isinstance(status, six.text_type): | ||
48 | 108 | status = six.text_type(status, "utf-8") | ||
49 | 109 | except subprocess.CalledProcessError: | ||
50 | 110 | return False | ||
51 | 111 | current_dc = '' | ||
52 | 112 | for line in status.split('\n'): | ||
53 | 113 | if line.startswith('Current DC'): | ||
54 | 114 | # Current DC: juju-lytrusty-machine-2 (168108163) - partition with quorum | ||
55 | 115 | current_dc = line.split(':')[1].split()[0] | ||
56 | 116 | if current_dc == get_unit_hostname(): | ||
57 | 117 | return True | ||
58 | 118 | return False | ||
59 | 119 | |||
60 | 120 | |||
61 | 98 | @retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound) | 121 | @retry_on_exception(5, base_delay=2, exc_type=CRMResourceNotFound) |
62 | 99 | def is_crm_leader(resource, retry=False): | 122 | def is_crm_leader(resource, retry=False): |
63 | 100 | """ | 123 | """ |
64 | @@ -104,6 +127,8 @@ | |||
65 | 104 | We allow this operation to be retried to avoid the possibility of getting a | 127 | We allow this operation to be retried to avoid the possibility of getting a |
66 | 105 | false negative. See LP #1396246 for more info. | 128 | false negative. See LP #1396246 for more info. |
67 | 106 | """ | 129 | """ |
68 | 130 | if resource == DC_RESOURCE_NAME: | ||
69 | 131 | return is_crm_dc() | ||
70 | 107 | cmd = ['crm', 'resource', 'show', resource] | 132 | cmd = ['crm', 'resource', 'show', resource] |
71 | 108 | try: | 133 | try: |
72 | 109 | status = subprocess.check_output(cmd, stderr=subprocess.STDOUT) | 134 | status = subprocess.check_output(cmd, stderr=subprocess.STDOUT) |
73 | 110 | 135 | ||
74 | === modified file 'hooks/charmhelpers/contrib/openstack/ip.py' | |||
75 | --- hooks/charmhelpers/contrib/openstack/ip.py 2015-03-31 14:56:11 +0000 | |||
76 | +++ hooks/charmhelpers/contrib/openstack/ip.py 2015-06-18 23:39:46 +0000 | |||
77 | @@ -17,6 +17,7 @@ | |||
78 | 17 | from charmhelpers.core.hookenv import ( | 17 | from charmhelpers.core.hookenv import ( |
79 | 18 | config, | 18 | config, |
80 | 19 | unit_get, | 19 | unit_get, |
81 | 20 | service_name, | ||
82 | 20 | ) | 21 | ) |
83 | 21 | from charmhelpers.contrib.network.ip import ( | 22 | from charmhelpers.contrib.network.ip import ( |
84 | 22 | get_address_in_network, | 23 | get_address_in_network, |
85 | @@ -26,8 +27,6 @@ | |||
86 | 26 | ) | 27 | ) |
87 | 27 | from charmhelpers.contrib.hahelpers.cluster import is_clustered | 28 | from charmhelpers.contrib.hahelpers.cluster import is_clustered |
88 | 28 | 29 | ||
89 | 29 | from functools import partial | ||
90 | 30 | |||
91 | 31 | PUBLIC = 'public' | 30 | PUBLIC = 'public' |
92 | 32 | INTERNAL = 'int' | 31 | INTERNAL = 'int' |
93 | 33 | ADMIN = 'admin' | 32 | ADMIN = 'admin' |
94 | @@ -35,15 +34,18 @@ | |||
95 | 35 | ADDRESS_MAP = { | 34 | ADDRESS_MAP = { |
96 | 36 | PUBLIC: { | 35 | PUBLIC: { |
97 | 37 | 'config': 'os-public-network', | 36 | 'config': 'os-public-network', |
99 | 38 | 'fallback': 'public-address' | 37 | 'fallback': 'public-address', |
100 | 38 | 'override': 'os-public-hostname', | ||
101 | 39 | }, | 39 | }, |
102 | 40 | INTERNAL: { | 40 | INTERNAL: { |
103 | 41 | 'config': 'os-internal-network', | 41 | 'config': 'os-internal-network', |
105 | 42 | 'fallback': 'private-address' | 42 | 'fallback': 'private-address', |
106 | 43 | 'override': 'os-internal-hostname', | ||
107 | 43 | }, | 44 | }, |
108 | 44 | ADMIN: { | 45 | ADMIN: { |
109 | 45 | 'config': 'os-admin-network', | 46 | 'config': 'os-admin-network', |
111 | 46 | 'fallback': 'private-address' | 47 | 'fallback': 'private-address', |
112 | 48 | 'override': 'os-admin-hostname', | ||
113 | 47 | } | 49 | } |
114 | 48 | } | 50 | } |
115 | 49 | 51 | ||
116 | @@ -57,15 +59,50 @@ | |||
117 | 57 | :param endpoint_type: str endpoint type to resolve. | 59 | :param endpoint_type: str endpoint type to resolve. |
118 | 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. |
119 | 59 | """ | 61 | """ |
123 | 60 | scheme = 'http' | 62 | scheme = _get_scheme(configs) |
124 | 61 | if 'https' in configs.complete_contexts(): | 63 | |
122 | 62 | scheme = 'https' | ||
125 | 63 | address = resolve_address(endpoint_type) | 64 | address = resolve_address(endpoint_type) |
126 | 64 | if is_ipv6(address): | 65 | if is_ipv6(address): |
127 | 65 | address = "[{}]".format(address) | 66 | address = "[{}]".format(address) |
128 | 67 | |||
129 | 66 | return '%s://%s' % (scheme, address) | 68 | return '%s://%s' % (scheme, address) |
130 | 67 | 69 | ||
131 | 68 | 70 | ||
132 | 71 | def _get_scheme(configs): | ||
133 | 72 | """Returns the scheme to use for the url (either http or https) | ||
134 | 73 | depending upon whether https is in the configs value. | ||
135 | 74 | |||
136 | 75 | :param configs: OSTemplateRenderer config templating object to inspect | ||
137 | 76 | for a complete https context. | ||
138 | 77 | :returns: either 'http' or 'https' depending on whether https is | ||
139 | 78 | configured within the configs context. | ||
140 | 79 | """ | ||
141 | 80 | scheme = 'http' | ||
142 | 81 | if configs and 'https' in configs.complete_contexts(): | ||
143 | 82 | scheme = 'https' | ||
144 | 83 | return scheme | ||
145 | 84 | |||
146 | 85 | |||
147 | 86 | def _get_address_override(endpoint_type=PUBLIC): | ||
148 | 87 | """Returns any address overrides that the user has defined based on the | ||
149 | 88 | endpoint type. | ||
150 | 89 | |||
151 | 90 | Note: this function allows for the service name to be inserted into the | ||
152 | 91 | address if the user specifies {service_name}.somehost.org. | ||
153 | 92 | |||
154 | 93 | :param endpoint_type: the type of endpoint to retrieve the override | ||
155 | 94 | value for. | ||
156 | 95 | :returns: any endpoint address or hostname that the user has overridden | ||
157 | 96 | or None if an override is not present. | ||
158 | 97 | """ | ||
159 | 98 | override_key = ADDRESS_MAP[endpoint_type]['override'] | ||
160 | 99 | addr_override = config(override_key) | ||
161 | 100 | if not addr_override: | ||
162 | 101 | return None | ||
163 | 102 | else: | ||
164 | 103 | return addr_override.format(service_name=service_name()) | ||
165 | 104 | |||
166 | 105 | |||
167 | 69 | def resolve_address(endpoint_type=PUBLIC): | 106 | def resolve_address(endpoint_type=PUBLIC): |
168 | 70 | """Return unit address depending on net config. | 107 | """Return unit address depending on net config. |
169 | 71 | 108 | ||
170 | @@ -77,7 +114,10 @@ | |||
171 | 77 | 114 | ||
172 | 78 | :param endpoint_type: Network endpoing type | 115 | :param endpoint_type: Network endpoing type |
173 | 79 | """ | 116 | """ |
175 | 80 | resolved_address = None | 117 | resolved_address = _get_address_override(endpoint_type) |
176 | 118 | if resolved_address: | ||
177 | 119 | return resolved_address | ||
178 | 120 | |||
179 | 81 | vips = config('vip') | 121 | vips = config('vip') |
180 | 82 | if vips: | 122 | if vips: |
181 | 83 | vips = vips.split() | 123 | vips = vips.split() |
182 | @@ -109,38 +149,3 @@ | |||
183 | 109 | "clustered=%s)" % (net_type, clustered)) | 149 | "clustered=%s)" % (net_type, clustered)) |
184 | 110 | 150 | ||
185 | 111 | return resolved_address | 151 | return resolved_address |
186 | 112 | |||
187 | 113 | |||
188 | 114 | def endpoint_url(configs, url_template, port, endpoint_type=PUBLIC, | ||
189 | 115 | override=None): | ||
190 | 116 | """Returns the correct endpoint URL to advertise to Keystone. | ||
191 | 117 | |||
192 | 118 | This method provides the correct endpoint URL which should be advertised to | ||
193 | 119 | the keystone charm for endpoint creation. This method allows for the url to | ||
194 | 120 | be overridden to force a keystone endpoint to have specific URL for any of | ||
195 | 121 | the defined scopes (admin, internal, public). | ||
196 | 122 | |||
197 | 123 | :param configs: OSTemplateRenderer config templating object to inspect | ||
198 | 124 | for a complete https context. | ||
199 | 125 | :param url_template: str format string for creating the url template. Only | ||
200 | 126 | two values will be passed - the scheme+hostname | ||
201 | 127 | returned by the canonical_url and the port. | ||
202 | 128 | :param endpoint_type: str endpoint type to resolve. | ||
203 | 129 | :param override: str the name of the config option which overrides the | ||
204 | 130 | endpoint URL defined by the charm itself. None will | ||
205 | 131 | disable any overrides (default). | ||
206 | 132 | """ | ||
207 | 133 | if override: | ||
208 | 134 | # Return any user-defined overrides for the keystone endpoint URL. | ||
209 | 135 | user_value = config(override) | ||
210 | 136 | if user_value: | ||
211 | 137 | return user_value.strip() | ||
212 | 138 | |||
213 | 139 | return url_template % (canonical_url(configs, endpoint_type), port) | ||
214 | 140 | |||
215 | 141 | |||
216 | 142 | public_endpoint = partial(endpoint_url, endpoint_type=PUBLIC) | ||
217 | 143 | |||
218 | 144 | internal_endpoint = partial(endpoint_url, endpoint_type=INTERNAL) | ||
219 | 145 | |||
220 | 146 | admin_endpoint = partial(endpoint_url, endpoint_type=ADMIN) | ||
221 | 147 | 152 | ||
222 | === modified file 'unit_tests/test_nova_cc_contexts.py' | |||
223 | --- unit_tests/test_nova_cc_contexts.py 2015-04-20 10:21:36 +0000 | |||
224 | +++ unit_tests/test_nova_cc_contexts.py 2015-06-18 23:39:46 +0000 | |||
225 | @@ -90,11 +90,13 @@ | |||
226 | 90 | self.assertEqual({'memcached_servers': "%s:11211" % (formated_ip, )}, | 90 | self.assertEqual({'memcached_servers': "%s:11211" % (formated_ip, )}, |
227 | 91 | instance_console()) | 91 | instance_console()) |
228 | 92 | 92 | ||
229 | 93 | @mock.patch('charmhelpers.contrib.openstack.neutron.os_release') | ||
230 | 93 | @mock.patch.object(context, 'use_local_neutron_api') | 94 | @mock.patch.object(context, 'use_local_neutron_api') |
231 | 94 | @mock.patch('charmhelpers.contrib.openstack.ip.config') | 95 | @mock.patch('charmhelpers.contrib.openstack.ip.config') |
232 | 95 | @mock.patch('charmhelpers.contrib.openstack.ip.is_clustered') | 96 | @mock.patch('charmhelpers.contrib.openstack.ip.is_clustered') |
233 | 96 | def test_neutron_context_single_vip(self, mock_is_clustered, mock_config, | 97 | def test_neutron_context_single_vip(self, mock_is_clustered, mock_config, |
235 | 97 | mock_use_local_neutron_api): | 98 | mock_use_local_neutron_api, |
236 | 99 | _os_release): | ||
237 | 98 | mock_use_local_neutron_api.return_value = True | 100 | mock_use_local_neutron_api.return_value = True |
238 | 99 | self.https.return_value = False | 101 | self.https.return_value = False |
239 | 100 | mock_is_clustered.return_value = True | 102 | mock_is_clustered.return_value = True |
240 | @@ -102,7 +104,7 @@ | |||
241 | 102 | 'os-internal-network': '10.0.0.1/24', | 104 | 'os-internal-network': '10.0.0.1/24', |
242 | 103 | 'os-admin-network': '10.0.1.0/24', | 105 | 'os-admin-network': '10.0.1.0/24', |
243 | 104 | 'os-public-network': '10.0.2.0/24'} | 106 | 'os-public-network': '10.0.2.0/24'} |
245 | 105 | mock_config.side_effect = lambda key: config[key] | 107 | mock_config.side_effect = lambda key: config.get(key) |
246 | 106 | 108 | ||
247 | 107 | mock_use_local_neutron_api.return_value = False | 109 | mock_use_local_neutron_api.return_value = False |
248 | 108 | ctxt = context.NeutronCCContext()() | 110 | ctxt = context.NeutronCCContext()() |
249 | @@ -114,18 +116,20 @@ | |||
250 | 114 | self.assertEqual(ctxt['nova_url'], 'http://10.0.0.1:8774/v2') | 116 | self.assertEqual(ctxt['nova_url'], 'http://10.0.0.1:8774/v2') |
251 | 115 | self.assertEqual(ctxt['neutron_url'], 'http://10.0.0.1:9696') | 117 | self.assertEqual(ctxt['neutron_url'], 'http://10.0.0.1:9696') |
252 | 116 | 118 | ||
253 | 119 | @mock.patch('charmhelpers.contrib.openstack.neutron.os_release') | ||
254 | 117 | @mock.patch.object(context, 'use_local_neutron_api') | 120 | @mock.patch.object(context, 'use_local_neutron_api') |
255 | 118 | @mock.patch('charmhelpers.contrib.openstack.ip.config') | 121 | @mock.patch('charmhelpers.contrib.openstack.ip.config') |
256 | 119 | @mock.patch('charmhelpers.contrib.openstack.ip.is_clustered') | 122 | @mock.patch('charmhelpers.contrib.openstack.ip.is_clustered') |
257 | 120 | def test_neutron_context_multi_vip(self, mock_is_clustered, mock_config, | 123 | def test_neutron_context_multi_vip(self, mock_is_clustered, mock_config, |
259 | 121 | mock_use_local_neutron_api): | 124 | mock_use_local_neutron_api, |
260 | 125 | _os_release): | ||
261 | 122 | self.https.return_value = False | 126 | self.https.return_value = False |
262 | 123 | mock_is_clustered.return_value = True | 127 | mock_is_clustered.return_value = True |
263 | 124 | config = {'vip': '10.0.0.1 10.0.1.1 10.0.2.1', | 128 | config = {'vip': '10.0.0.1 10.0.1.1 10.0.2.1', |
264 | 125 | 'os-internal-network': '10.0.1.0/24', | 129 | 'os-internal-network': '10.0.1.0/24', |
265 | 126 | 'os-admin-network': '10.0.0.0/24', | 130 | 'os-admin-network': '10.0.0.0/24', |
266 | 127 | 'os-public-network': '10.0.2.0/24'} | 131 | 'os-public-network': '10.0.2.0/24'} |
268 | 128 | mock_config.side_effect = lambda key: config[key] | 132 | mock_config.side_effect = lambda key: config.get(key) |
269 | 129 | 133 | ||
270 | 130 | mock_use_local_neutron_api.return_value = False | 134 | mock_use_local_neutron_api.return_value = False |
271 | 131 | ctxt = context.NeutronCCContext()() | 135 | ctxt = context.NeutronCCContext()() |
272 | 132 | 136 | ||
273 | === modified file 'unit_tests/test_nova_cc_hooks.py' | |||
274 | --- unit_tests/test_nova_cc_hooks.py 2015-06-15 09:50:18 +0000 | |||
275 | +++ unit_tests/test_nova_cc_hooks.py 2015-06-18 23:39:46 +0000 | |||
276 | @@ -25,13 +25,13 @@ | |||
277 | 25 | 'api_port', | 25 | 'api_port', |
278 | 26 | 'apt_update', | 26 | 'apt_update', |
279 | 27 | 'apt_install', | 27 | 'apt_install', |
280 | 28 | 'canonical_url', | ||
281 | 29 | 'configure_installation_source', | 28 | 'configure_installation_source', |
282 | 30 | 'charm_dir', | 29 | 'charm_dir', |
283 | 31 | 'do_openstack_upgrade', | 30 | 'do_openstack_upgrade', |
284 | 32 | 'openstack_upgrade_available', | 31 | 'openstack_upgrade_available', |
285 | 33 | 'cmd_all_services', | 32 | 'cmd_all_services', |
286 | 34 | 'config', | 33 | 'config', |
287 | 34 | 'determine_endpoints', | ||
288 | 35 | 'determine_packages', | 35 | 'determine_packages', |
289 | 36 | 'determine_ports', | 36 | 'determine_ports', |
290 | 37 | 'disable_services', | 37 | 'disable_services', |
291 | @@ -114,7 +114,12 @@ | |||
292 | 114 | self.assertTrue(self.save_script_rc.called) | 114 | self.assertTrue(self.save_script_rc.called) |
293 | 115 | mock_filter_packages.assert_called_with([]) | 115 | mock_filter_packages.assert_called_with([]) |
294 | 116 | 116 | ||
295 | 117 | <<<<<<< TREE | ||
296 | 117 | @patch.object(hooks, 'filter_installed_packages') | 118 | @patch.object(hooks, 'filter_installed_packages') |
297 | 119 | ======= | ||
298 | 120 | @patch('charmhelpers.contrib.openstack.ip.service_name', | ||
299 | 121 | lambda *args: 'nova-cloud-controller') | ||
300 | 122 | >>>>>>> MERGE-SOURCE | ||
301 | 118 | @patch.object(hooks, 'cluster_joined') | 123 | @patch.object(hooks, 'cluster_joined') |
302 | 119 | @patch.object(hooks, 'identity_joined') | 124 | @patch.object(hooks, 'identity_joined') |
303 | 120 | @patch.object(hooks, 'neutron_api_relation_joined') | 125 | @patch.object(hooks, 'neutron_api_relation_joined') |
304 | @@ -193,9 +198,11 @@ | |||
305 | 193 | self.assertEquals(sorted(self.relation_set.call_args_list), | 198 | self.assertEquals(sorted(self.relation_set.call_args_list), |
306 | 194 | sorted(expected_relations)) | 199 | sorted(expected_relations)) |
307 | 195 | 200 | ||
308 | 201 | @patch.object(hooks, 'canonical_url') | ||
309 | 196 | @patch.object(utils, 'config') | 202 | @patch.object(utils, 'config') |
310 | 197 | @patch.object(hooks, '_auth_config') | 203 | @patch.object(hooks, '_auth_config') |
312 | 198 | def test_compute_joined_neutron(self, auth_config, _util_config): | 204 | def test_compute_joined_neutron(self, auth_config, _util_config, |
313 | 205 | _canonical_url): | ||
314 | 199 | _util_config.return_value = None | 206 | _util_config.return_value = None |
315 | 200 | self.is_relation_made.return_value = False | 207 | self.is_relation_made.return_value = False |
316 | 201 | self.network_manager.return_value = 'neutron' | 208 | self.network_manager.return_value = 'neutron' |
317 | @@ -203,7 +210,7 @@ | |||
318 | 203 | self.keystone_ca_cert_b64.return_value = 'foocert64' | 210 | self.keystone_ca_cert_b64.return_value = 'foocert64' |
319 | 204 | self.volume_service.return_value = 'cinder' | 211 | self.volume_service.return_value = 'cinder' |
320 | 205 | self.unit_get.return_value = 'nova-cc-host1' | 212 | self.unit_get.return_value = 'nova-cc-host1' |
322 | 206 | self.canonical_url.return_value = 'http://nova-cc-host1' | 213 | _canonical_url.return_value = 'http://nova-cc-host1' |
323 | 207 | self.api_port.return_value = '9696' | 214 | self.api_port.return_value = '9696' |
324 | 208 | self.neutron_plugin.return_value = 'nvp' | 215 | self.neutron_plugin.return_value = 'nvp' |
325 | 209 | auth_config.return_value = FAKE_KS_AUTH_CFG | 216 | auth_config.return_value = FAKE_KS_AUTH_CFG |
326 | @@ -222,11 +229,12 @@ | |||
327 | 222 | quantum_plugin='nvp', | 229 | quantum_plugin='nvp', |
328 | 223 | network_manager='neutron', **FAKE_KS_AUTH_CFG) | 230 | network_manager='neutron', **FAKE_KS_AUTH_CFG) |
329 | 224 | 231 | ||
330 | 232 | @patch.object(hooks, 'canonical_url') | ||
331 | 225 | @patch.object(utils, 'config') | 233 | @patch.object(utils, 'config') |
332 | 226 | @patch.object(hooks, 'NeutronAPIContext') | 234 | @patch.object(hooks, 'NeutronAPIContext') |
333 | 227 | @patch.object(hooks, '_auth_config') | 235 | @patch.object(hooks, '_auth_config') |
334 | 228 | def test_compute_joined_neutron_api_rel(self, auth_config, napi, | 236 | def test_compute_joined_neutron_api_rel(self, auth_config, napi, |
336 | 229 | _util_config): | 237 | _util_config, _canonical_url): |
337 | 230 | def mock_NeutronAPIContext(): | 238 | def mock_NeutronAPIContext(): |
338 | 231 | return { | 239 | return { |
339 | 232 | 'neutron_plugin': 'bob', | 240 | 'neutron_plugin': 'bob', |
340 | @@ -241,7 +249,7 @@ | |||
341 | 241 | self.keystone_ca_cert_b64.return_value = 'foocert64' | 249 | self.keystone_ca_cert_b64.return_value = 'foocert64' |
342 | 242 | self.volume_service.return_value = 'cinder' | 250 | self.volume_service.return_value = 'cinder' |
343 | 243 | self.unit_get.return_value = 'nova-cc-host1' | 251 | self.unit_get.return_value = 'nova-cc-host1' |
345 | 244 | self.canonical_url.return_value = 'http://nova-cc-host1' | 252 | _canonical_url.return_value = 'http://nova-cc-host1' |
346 | 245 | self.api_port.return_value = '9696' | 253 | self.api_port.return_value = '9696' |
347 | 246 | self.neutron_plugin.return_value = 'nvp' | 254 | self.neutron_plugin.return_value = 'nvp' |
348 | 247 | auth_config.return_value = FAKE_KS_AUTH_CFG | 255 | auth_config.return_value = FAKE_KS_AUTH_CFG |
349 | @@ -259,13 +267,14 @@ | |||
350 | 259 | quantum_plugin='bob', | 267 | quantum_plugin='bob', |
351 | 260 | network_manager='neutron', **FAKE_KS_AUTH_CFG) | 268 | network_manager='neutron', **FAKE_KS_AUTH_CFG) |
352 | 261 | 269 | ||
353 | 270 | @patch.object(hooks, 'canonical_url') | ||
354 | 262 | @patch.object(hooks, '_auth_config') | 271 | @patch.object(hooks, '_auth_config') |
356 | 263 | def test_nova_vmware_joined(self, auth_config): | 272 | def test_nova_vmware_joined(self, auth_config, _canonical_url): |
357 | 264 | auth_config.return_value = FAKE_KS_AUTH_CFG | 273 | auth_config.return_value = FAKE_KS_AUTH_CFG |
358 | 265 | # quantum-security-groups, plugin | 274 | # quantum-security-groups, plugin |
359 | 266 | self.neutron_plugin.return_value = 'nvp' | 275 | self.neutron_plugin.return_value = 'nvp' |
360 | 267 | self.network_manager.return_value = 'neutron' | 276 | self.network_manager.return_value = 'neutron' |
362 | 268 | self.canonical_url.return_value = 'http://nova-cc-host1' | 277 | _canonical_url.return_value = 'http://nova-cc-host1' |
363 | 269 | self.api_port.return_value = '9696' | 278 | self.api_port.return_value = '9696' |
364 | 270 | hooks.nova_vmware_relation_joined() | 279 | hooks.nova_vmware_relation_joined() |
365 | 271 | self.relation_set.assert_called_with( | 280 | self.relation_set.assert_called_with( |
366 | @@ -283,6 +292,25 @@ | |||
367 | 283 | nova_hostname='nova.foohost.com') | 292 | nova_hostname='nova.foohost.com') |
368 | 284 | self.unit_get.assert_called_with('private-address') | 293 | self.unit_get.assert_called_with('private-address') |
369 | 285 | 294 | ||
370 | 295 | @patch('charmhelpers.contrib.openstack.ip.service_name', | ||
371 | 296 | lambda *args: 'nova-cloud-controller') | ||
372 | 297 | @patch('charmhelpers.contrib.openstack.ip.unit_get') | ||
373 | 298 | @patch('charmhelpers.contrib.openstack.ip.is_clustered') | ||
374 | 299 | @patch('charmhelpers.contrib.openstack.ip.config') | ||
375 | 300 | def test_identity_joined(self, _ip_config, _is_clustered, _unit_get): | ||
376 | 301 | _is_clustered.return_value = False | ||
377 | 302 | _unit_get.return_value = '127.0.0.1' | ||
378 | 303 | _ip_config.side_effect = self.test_config.get | ||
379 | 304 | |||
380 | 305 | self.test_config.set('os-public-hostname', 'ncc.example.com') | ||
381 | 306 | hooks.identity_joined() | ||
382 | 307 | |||
383 | 308 | self.determine_endpoints.asssert_called_with( | ||
384 | 309 | public_url='http://ncc.example.com', | ||
385 | 310 | internal_url='http://127.0.0.1', | ||
386 | 311 | admin_url='http://127.0.0.1' | ||
387 | 312 | ) | ||
388 | 313 | |||
389 | 286 | def test_postgresql_nova_db_joined(self): | 314 | def test_postgresql_nova_db_joined(self): |
390 | 287 | self.is_relation_made.return_value = False | 315 | self.is_relation_made.return_value = False |
391 | 288 | hooks.pgsql_nova_db_joined() | 316 | hooks.pgsql_nova_db_joined() |
392 | @@ -447,9 +475,10 @@ | |||
393 | 447 | call('/etc/neutron/neutron.conf')]) | 475 | call('/etc/neutron/neutron.conf')]) |
394 | 448 | cell_joined.assert_called_with(rid='nova-cell-api/0') | 476 | cell_joined.assert_called_with(rid='nova-cell-api/0') |
395 | 449 | 477 | ||
397 | 450 | def test_nova_cell_relation_joined(self): | 478 | @patch.object(hooks, 'canonical_url') |
398 | 479 | def test_nova_cell_relation_joined(self, _canonical_url): | ||
399 | 451 | self.uuid.uuid4.return_value = 'bob' | 480 | self.uuid.uuid4.return_value = 'bob' |
401 | 452 | self.canonical_url.return_value = 'http://novaurl' | 481 | _canonical_url.return_value = 'http://novaurl' |
402 | 453 | hooks.nova_cell_relation_joined(rid='rid', | 482 | hooks.nova_cell_relation_joined(rid='rid', |
403 | 454 | remote_restart=True) | 483 | remote_restart=True) |
404 | 455 | self.relation_set.assert_called_with(restart_trigger='bob', | 484 | self.relation_set.assert_called_with(restart_trigger='bob', |
405 | @@ -468,19 +497,20 @@ | |||
406 | 468 | } | 497 | } |
407 | 469 | self.assertEquals(hooks.get_cell_type(), 'parent') | 498 | self.assertEquals(hooks.get_cell_type(), 'parent') |
408 | 470 | 499 | ||
409 | 500 | @patch.object(hooks, 'canonical_url') | ||
410 | 471 | @patch.object(os, 'rename') | 501 | @patch.object(os, 'rename') |
411 | 472 | @patch.object(os.path, 'isfile') | 502 | @patch.object(os.path, 'isfile') |
412 | 473 | @patch.object(hooks, 'CONFIGS') | 503 | @patch.object(hooks, 'CONFIGS') |
413 | 474 | @patch.object(hooks, 'get_cell_type') | 504 | @patch.object(hooks, 'get_cell_type') |
414 | 475 | def test_neutron_api_relation_joined(self, get_cell_type, configs, isfile, | 505 | def test_neutron_api_relation_joined(self, get_cell_type, configs, isfile, |
416 | 476 | rename): | 506 | rename, _canonical_url): |
417 | 477 | neutron_conf = '/etc/neutron/neutron.conf' | 507 | neutron_conf = '/etc/neutron/neutron.conf' |
418 | 478 | nova_url = 'http://novaurl:8774/v2' | 508 | nova_url = 'http://novaurl:8774/v2' |
419 | 479 | isfile.return_value = True | 509 | isfile.return_value = True |
420 | 480 | self.service_running.return_value = True | 510 | self.service_running.return_value = True |
421 | 481 | _identity_joined = self.patch('identity_joined') | 511 | _identity_joined = self.patch('identity_joined') |
422 | 482 | self.relation_ids.return_value = ['relid'] | 512 | self.relation_ids.return_value = ['relid'] |
424 | 483 | self.canonical_url.return_value = 'http://novaurl' | 513 | _canonical_url.return_value = 'http://novaurl' |
425 | 484 | get_cell_type.return_value = 'parent' | 514 | get_cell_type.return_value = 'parent' |
426 | 485 | self.uuid.uuid4.return_value = 'bob' | 515 | self.uuid.uuid4.return_value = 'bob' |
427 | 486 | with patch_open() as (_open, _file): | 516 | with patch_open() as (_open, _file): |
428 | @@ -517,11 +547,12 @@ | |||
429 | 517 | self.assertTrue(_compute_joined.called) | 547 | self.assertTrue(_compute_joined.called) |
430 | 518 | self.assertTrue(_quantum_joined.called) | 548 | self.assertTrue(_quantum_joined.called) |
431 | 519 | 549 | ||
432 | 550 | @patch.object(hooks, 'canonical_url') | ||
433 | 520 | @patch.object(utils, 'config') | 551 | @patch.object(utils, 'config') |
435 | 521 | def test_console_settings_vnc(self, _utils_config): | 552 | def test_console_settings_vnc(self, _utils_config, _canonical_url): |
436 | 522 | _utils_config.return_value = 'vnc' | 553 | _utils_config.return_value = 'vnc' |
437 | 523 | _cc_host = "nova-cc-host1" | 554 | _cc_host = "nova-cc-host1" |
439 | 524 | self.canonical_url.return_value = 'http://' + _cc_host | 555 | _canonical_url.return_value = 'http://' + _cc_host |
440 | 525 | _con_sets = hooks.console_settings() | 556 | _con_sets = hooks.console_settings() |
441 | 526 | console_settings = { | 557 | console_settings = { |
442 | 527 | 'console_proxy_novnc_address': 'http://%s:6080/vnc_auto.html' % | 558 | 'console_proxy_novnc_address': 'http://%s:6080/vnc_auto.html' % |
443 | @@ -537,11 +568,12 @@ | |||
444 | 537 | } | 568 | } |
445 | 538 | self.assertEqual(_con_sets, console_settings) | 569 | self.assertEqual(_con_sets, console_settings) |
446 | 539 | 570 | ||
447 | 571 | @patch.object(hooks, 'canonical_url') | ||
448 | 540 | @patch.object(utils, 'config') | 572 | @patch.object(utils, 'config') |
450 | 541 | def test_console_settings_xvpvnc(self, _utils_config): | 573 | def test_console_settings_xvpvnc(self, _utils_config, _canonical_url): |
451 | 542 | _utils_config.return_value = 'xvpvnc' | 574 | _utils_config.return_value = 'xvpvnc' |
452 | 543 | _cc_host = "nova-cc-host1" | 575 | _cc_host = "nova-cc-host1" |
454 | 544 | self.canonical_url.return_value = 'http://' + _cc_host | 576 | _canonical_url.return_value = 'http://' + _cc_host |
455 | 545 | _con_sets = hooks.console_settings() | 577 | _con_sets = hooks.console_settings() |
456 | 546 | console_settings = { | 578 | console_settings = { |
457 | 547 | 'console_access_protocol': 'xvpvnc', | 579 | 'console_access_protocol': 'xvpvnc', |
458 | @@ -553,11 +585,12 @@ | |||
459 | 553 | } | 585 | } |
460 | 554 | self.assertEqual(_con_sets, console_settings) | 586 | self.assertEqual(_con_sets, console_settings) |
461 | 555 | 587 | ||
462 | 588 | @patch.object(hooks, 'canonical_url') | ||
463 | 556 | @patch.object(utils, 'config') | 589 | @patch.object(utils, 'config') |
465 | 557 | def test_console_settings_novnc(self, _utils_config): | 590 | def test_console_settings_novnc(self, _utils_config, _canonical_url): |
466 | 558 | _utils_config.return_value = 'novnc' | 591 | _utils_config.return_value = 'novnc' |
467 | 559 | _cc_host = "nova-cc-host1" | 592 | _cc_host = "nova-cc-host1" |
469 | 560 | self.canonical_url.return_value = 'http://' + _cc_host | 593 | _canonical_url.return_value = 'http://' + _cc_host |
470 | 561 | _con_sets = hooks.console_settings() | 594 | _con_sets = hooks.console_settings() |
471 | 562 | console_settings = { | 595 | console_settings = { |
472 | 563 | 'console_proxy_novnc_address': 'http://%s:6080/vnc_auto.html' % | 596 | 'console_proxy_novnc_address': 'http://%s:6080/vnc_auto.html' % |
473 | @@ -569,11 +602,12 @@ | |||
474 | 569 | } | 602 | } |
475 | 570 | self.assertEqual(_con_sets, console_settings) | 603 | self.assertEqual(_con_sets, console_settings) |
476 | 571 | 604 | ||
477 | 605 | @patch.object(hooks, 'canonical_url') | ||
478 | 572 | @patch.object(utils, 'config') | 606 | @patch.object(utils, 'config') |
480 | 573 | def test_console_settings_spice(self, _utils_config): | 607 | def test_console_settings_spice(self, _utils_config, _canonical_url): |
481 | 574 | _utils_config.return_value = 'spice' | 608 | _utils_config.return_value = 'spice' |
482 | 575 | _cc_host = "nova-cc-host1" | 609 | _cc_host = "nova-cc-host1" |
484 | 576 | self.canonical_url.return_value = 'http://' + _cc_host | 610 | _canonical_url.return_value = 'http://' + _cc_host |
485 | 577 | _con_sets = hooks.console_settings() | 611 | _con_sets = hooks.console_settings() |
486 | 578 | console_settings = { | 612 | console_settings = { |
487 | 579 | 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' % | 613 | 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' % |
488 | @@ -585,14 +619,16 @@ | |||
489 | 585 | } | 619 | } |
490 | 586 | self.assertEqual(_con_sets, console_settings) | 620 | self.assertEqual(_con_sets, console_settings) |
491 | 587 | 621 | ||
492 | 622 | @patch.object(hooks, 'canonical_url') | ||
493 | 588 | @patch.object(utils, 'config') | 623 | @patch.object(utils, 'config') |
495 | 589 | def test_console_settings_explicit_ip(self, _utils_config): | 624 | def test_console_settings_explicit_ip(self, _utils_config, |
496 | 625 | _canonical_url): | ||
497 | 590 | _utils_config.return_value = 'spice' | 626 | _utils_config.return_value = 'spice' |
498 | 591 | _cc_public_host = "public-host" | 627 | _cc_public_host = "public-host" |
499 | 592 | _cc_private_host = "private-host" | 628 | _cc_private_host = "private-host" |
500 | 593 | self.test_config.set('console-proxy-ip', _cc_public_host) | 629 | self.test_config.set('console-proxy-ip', _cc_public_host) |
501 | 594 | _con_sets = hooks.console_settings() | 630 | _con_sets = hooks.console_settings() |
503 | 595 | self.canonical_url.return_value = 'http://' + _cc_private_host | 631 | _canonical_url.return_value = 'http://' + _cc_private_host |
504 | 596 | console_settings = { | 632 | console_settings = { |
505 | 597 | 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' % | 633 | 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' % |
506 | 598 | (_cc_public_host), | 634 | (_cc_public_host), |
charm_lint_check #5409 nova-cloud- controller for billy-olsen mp262006
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/5409/