Merge lp:~billy-olsen/charms/trusty/nova-cloud-controller/backport-lp1398182 into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/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
Reviewer Review Type Date Requested Status
Corey Bryant (community) Approve
Review via email: mp+262006@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/

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

charm_unit_test #5041 nova-cloud-controller for billy-olsen mp262006
    UNIT OK: passed

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

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

charm_amulet_test #4652 nova-cloud-controller for billy-olsen mp262006
    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/11721376/
Build: http://10.245.162.77:8080/job/charm_amulet_test/4652/

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-controller for billy-olsen mp262006
    AMULET OK: passed

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

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
=== modified file 'config.yaml'
--- config.yaml 2015-04-20 10:21:36 +0000
+++ config.yaml 2015-06-18 23:39:46 +0000
@@ -230,6 +230,18 @@
230 192.168.0.0/24)230 192.168.0.0/24)
231 .231 .
232 This network will be used for public endpoints.232 This network will be used for public endpoints.
233 os-public-hostname:
234 type: string
235 default:
236 description: |
237 The hostname or address of the public endpoints provided by the
238 nova-cloud-controller in the keystone identity provider.
239 .
240 This value will be used for public endpoints. For example, an
241 os-public-hostname set to 'ncc.example.com' with ssl enabled will
242 create public endpoints such as:
243 .
244 https://ncc.example.com:8775/v2/$(tenant_id)s
233 service-guard:245 service-guard:
234 type: boolean246 type: boolean
235 default: false247 default: false
236248
=== modified file 'hooks/charmhelpers/contrib/hahelpers/cluster.py'
--- hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-03-16 14:17:04 +0000
+++ hooks/charmhelpers/contrib/hahelpers/cluster.py 2015-06-18 23:39:46 +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-31 14:56:11 +0000
+++ hooks/charmhelpers/contrib/openstack/ip.py 2015-06-18 23:39:46 +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_nova_cc_contexts.py'
--- unit_tests/test_nova_cc_contexts.py 2015-04-20 10:21:36 +0000
+++ unit_tests/test_nova_cc_contexts.py 2015-06-18 23:39:46 +0000
@@ -90,11 +90,13 @@
90 self.assertEqual({'memcached_servers': "%s:11211" % (formated_ip, )},90 self.assertEqual({'memcached_servers': "%s:11211" % (formated_ip, )},
91 instance_console())91 instance_console())
9292
93 @mock.patch('charmhelpers.contrib.openstack.neutron.os_release')
93 @mock.patch.object(context, 'use_local_neutron_api')94 @mock.patch.object(context, 'use_local_neutron_api')
94 @mock.patch('charmhelpers.contrib.openstack.ip.config')95 @mock.patch('charmhelpers.contrib.openstack.ip.config')
95 @mock.patch('charmhelpers.contrib.openstack.ip.is_clustered')96 @mock.patch('charmhelpers.contrib.openstack.ip.is_clustered')
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,
97 mock_use_local_neutron_api):98 mock_use_local_neutron_api,
99 _os_release):
98 mock_use_local_neutron_api.return_value = True100 mock_use_local_neutron_api.return_value = True
99 self.https.return_value = False101 self.https.return_value = False
100 mock_is_clustered.return_value = True102 mock_is_clustered.return_value = True
@@ -102,7 +104,7 @@
102 'os-internal-network': '10.0.0.1/24',104 'os-internal-network': '10.0.0.1/24',
103 'os-admin-network': '10.0.1.0/24',105 'os-admin-network': '10.0.1.0/24',
104 'os-public-network': '10.0.2.0/24'}106 'os-public-network': '10.0.2.0/24'}
105 mock_config.side_effect = lambda key: config[key]107 mock_config.side_effect = lambda key: config.get(key)
106108
107 mock_use_local_neutron_api.return_value = False109 mock_use_local_neutron_api.return_value = False
108 ctxt = context.NeutronCCContext()()110 ctxt = context.NeutronCCContext()()
@@ -114,18 +116,20 @@
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')
115 self.assertEqual(ctxt['neutron_url'], 'http://10.0.0.1:9696')117 self.assertEqual(ctxt['neutron_url'], 'http://10.0.0.1:9696')
116118
119 @mock.patch('charmhelpers.contrib.openstack.neutron.os_release')
117 @mock.patch.object(context, 'use_local_neutron_api')120 @mock.patch.object(context, 'use_local_neutron_api')
118 @mock.patch('charmhelpers.contrib.openstack.ip.config')121 @mock.patch('charmhelpers.contrib.openstack.ip.config')
119 @mock.patch('charmhelpers.contrib.openstack.ip.is_clustered')122 @mock.patch('charmhelpers.contrib.openstack.ip.is_clustered')
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,
121 mock_use_local_neutron_api):124 mock_use_local_neutron_api,
125 _os_release):
122 self.https.return_value = False126 self.https.return_value = False
123 mock_is_clustered.return_value = True127 mock_is_clustered.return_value = True
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',
125 'os-internal-network': '10.0.1.0/24',129 'os-internal-network': '10.0.1.0/24',
126 'os-admin-network': '10.0.0.0/24',130 'os-admin-network': '10.0.0.0/24',
127 'os-public-network': '10.0.2.0/24'}131 'os-public-network': '10.0.2.0/24'}
128 mock_config.side_effect = lambda key: config[key]132 mock_config.side_effect = lambda key: config.get(key)
129133
130 mock_use_local_neutron_api.return_value = False134 mock_use_local_neutron_api.return_value = False
131 ctxt = context.NeutronCCContext()()135 ctxt = context.NeutronCCContext()()
132136
=== modified file 'unit_tests/test_nova_cc_hooks.py'
--- unit_tests/test_nova_cc_hooks.py 2015-06-15 09:50:18 +0000
+++ unit_tests/test_nova_cc_hooks.py 2015-06-18 23:39:46 +0000
@@ -25,13 +25,13 @@
25 'api_port',25 'api_port',
26 'apt_update',26 'apt_update',
27 'apt_install',27 'apt_install',
28 'canonical_url',
29 'configure_installation_source',28 'configure_installation_source',
30 'charm_dir',29 'charm_dir',
31 'do_openstack_upgrade',30 'do_openstack_upgrade',
32 'openstack_upgrade_available',31 'openstack_upgrade_available',
33 'cmd_all_services',32 'cmd_all_services',
34 'config',33 'config',
34 'determine_endpoints',
35 'determine_packages',35 'determine_packages',
36 'determine_ports',36 'determine_ports',
37 'disable_services',37 'disable_services',
@@ -114,7 +114,12 @@
114 self.assertTrue(self.save_script_rc.called)114 self.assertTrue(self.save_script_rc.called)
115 mock_filter_packages.assert_called_with([])115 mock_filter_packages.assert_called_with([])
116116
117<<<<<<< TREE
117 @patch.object(hooks, 'filter_installed_packages')118 @patch.object(hooks, 'filter_installed_packages')
119=======
120 @patch('charmhelpers.contrib.openstack.ip.service_name',
121 lambda *args: 'nova-cloud-controller')
122>>>>>>> MERGE-SOURCE
118 @patch.object(hooks, 'cluster_joined')123 @patch.object(hooks, 'cluster_joined')
119 @patch.object(hooks, 'identity_joined')124 @patch.object(hooks, 'identity_joined')
120 @patch.object(hooks, 'neutron_api_relation_joined')125 @patch.object(hooks, 'neutron_api_relation_joined')
@@ -193,9 +198,11 @@
193 self.assertEquals(sorted(self.relation_set.call_args_list),198 self.assertEquals(sorted(self.relation_set.call_args_list),
194 sorted(expected_relations))199 sorted(expected_relations))
195200
201 @patch.object(hooks, 'canonical_url')
196 @patch.object(utils, 'config')202 @patch.object(utils, 'config')
197 @patch.object(hooks, '_auth_config')203 @patch.object(hooks, '_auth_config')
198 def test_compute_joined_neutron(self, auth_config, _util_config):204 def test_compute_joined_neutron(self, auth_config, _util_config,
205 _canonical_url):
199 _util_config.return_value = None206 _util_config.return_value = None
200 self.is_relation_made.return_value = False207 self.is_relation_made.return_value = False
201 self.network_manager.return_value = 'neutron'208 self.network_manager.return_value = 'neutron'
@@ -203,7 +210,7 @@
203 self.keystone_ca_cert_b64.return_value = 'foocert64'210 self.keystone_ca_cert_b64.return_value = 'foocert64'
204 self.volume_service.return_value = 'cinder'211 self.volume_service.return_value = 'cinder'
205 self.unit_get.return_value = 'nova-cc-host1'212 self.unit_get.return_value = 'nova-cc-host1'
206 self.canonical_url.return_value = 'http://nova-cc-host1'213 _canonical_url.return_value = 'http://nova-cc-host1'
207 self.api_port.return_value = '9696'214 self.api_port.return_value = '9696'
208 self.neutron_plugin.return_value = 'nvp'215 self.neutron_plugin.return_value = 'nvp'
209 auth_config.return_value = FAKE_KS_AUTH_CFG216 auth_config.return_value = FAKE_KS_AUTH_CFG
@@ -222,11 +229,12 @@
222 quantum_plugin='nvp',229 quantum_plugin='nvp',
223 network_manager='neutron', **FAKE_KS_AUTH_CFG)230 network_manager='neutron', **FAKE_KS_AUTH_CFG)
224231
232 @patch.object(hooks, 'canonical_url')
225 @patch.object(utils, 'config')233 @patch.object(utils, 'config')
226 @patch.object(hooks, 'NeutronAPIContext')234 @patch.object(hooks, 'NeutronAPIContext')
227 @patch.object(hooks, '_auth_config')235 @patch.object(hooks, '_auth_config')
228 def test_compute_joined_neutron_api_rel(self, auth_config, napi,236 def test_compute_joined_neutron_api_rel(self, auth_config, napi,
229 _util_config):237 _util_config, _canonical_url):
230 def mock_NeutronAPIContext():238 def mock_NeutronAPIContext():
231 return {239 return {
232 'neutron_plugin': 'bob',240 'neutron_plugin': 'bob',
@@ -241,7 +249,7 @@
241 self.keystone_ca_cert_b64.return_value = 'foocert64'249 self.keystone_ca_cert_b64.return_value = 'foocert64'
242 self.volume_service.return_value = 'cinder'250 self.volume_service.return_value = 'cinder'
243 self.unit_get.return_value = 'nova-cc-host1'251 self.unit_get.return_value = 'nova-cc-host1'
244 self.canonical_url.return_value = 'http://nova-cc-host1'252 _canonical_url.return_value = 'http://nova-cc-host1'
245 self.api_port.return_value = '9696'253 self.api_port.return_value = '9696'
246 self.neutron_plugin.return_value = 'nvp'254 self.neutron_plugin.return_value = 'nvp'
247 auth_config.return_value = FAKE_KS_AUTH_CFG255 auth_config.return_value = FAKE_KS_AUTH_CFG
@@ -259,13 +267,14 @@
259 quantum_plugin='bob',267 quantum_plugin='bob',
260 network_manager='neutron', **FAKE_KS_AUTH_CFG)268 network_manager='neutron', **FAKE_KS_AUTH_CFG)
261269
270 @patch.object(hooks, 'canonical_url')
262 @patch.object(hooks, '_auth_config')271 @patch.object(hooks, '_auth_config')
263 def test_nova_vmware_joined(self, auth_config):272 def test_nova_vmware_joined(self, auth_config, _canonical_url):
264 auth_config.return_value = FAKE_KS_AUTH_CFG273 auth_config.return_value = FAKE_KS_AUTH_CFG
265 # quantum-security-groups, plugin274 # quantum-security-groups, plugin
266 self.neutron_plugin.return_value = 'nvp'275 self.neutron_plugin.return_value = 'nvp'
267 self.network_manager.return_value = 'neutron'276 self.network_manager.return_value = 'neutron'
268 self.canonical_url.return_value = 'http://nova-cc-host1'277 _canonical_url.return_value = 'http://nova-cc-host1'
269 self.api_port.return_value = '9696'278 self.api_port.return_value = '9696'
270 hooks.nova_vmware_relation_joined()279 hooks.nova_vmware_relation_joined()
271 self.relation_set.assert_called_with(280 self.relation_set.assert_called_with(
@@ -283,6 +292,25 @@
283 nova_hostname='nova.foohost.com')292 nova_hostname='nova.foohost.com')
284 self.unit_get.assert_called_with('private-address')293 self.unit_get.assert_called_with('private-address')
285294
295 @patch('charmhelpers.contrib.openstack.ip.service_name',
296 lambda *args: 'nova-cloud-controller')
297 @patch('charmhelpers.contrib.openstack.ip.unit_get')
298 @patch('charmhelpers.contrib.openstack.ip.is_clustered')
299 @patch('charmhelpers.contrib.openstack.ip.config')
300 def test_identity_joined(self, _ip_config, _is_clustered, _unit_get):
301 _is_clustered.return_value = False
302 _unit_get.return_value = '127.0.0.1'
303 _ip_config.side_effect = self.test_config.get
304
305 self.test_config.set('os-public-hostname', 'ncc.example.com')
306 hooks.identity_joined()
307
308 self.determine_endpoints.asssert_called_with(
309 public_url='http://ncc.example.com',
310 internal_url='http://127.0.0.1',
311 admin_url='http://127.0.0.1'
312 )
313
286 def test_postgresql_nova_db_joined(self):314 def test_postgresql_nova_db_joined(self):
287 self.is_relation_made.return_value = False315 self.is_relation_made.return_value = False
288 hooks.pgsql_nova_db_joined()316 hooks.pgsql_nova_db_joined()
@@ -447,9 +475,10 @@
447 call('/etc/neutron/neutron.conf')])475 call('/etc/neutron/neutron.conf')])
448 cell_joined.assert_called_with(rid='nova-cell-api/0')476 cell_joined.assert_called_with(rid='nova-cell-api/0')
449477
450 def test_nova_cell_relation_joined(self):478 @patch.object(hooks, 'canonical_url')
479 def test_nova_cell_relation_joined(self, _canonical_url):
451 self.uuid.uuid4.return_value = 'bob'480 self.uuid.uuid4.return_value = 'bob'
452 self.canonical_url.return_value = 'http://novaurl'481 _canonical_url.return_value = 'http://novaurl'
453 hooks.nova_cell_relation_joined(rid='rid',482 hooks.nova_cell_relation_joined(rid='rid',
454 remote_restart=True)483 remote_restart=True)
455 self.relation_set.assert_called_with(restart_trigger='bob',484 self.relation_set.assert_called_with(restart_trigger='bob',
@@ -468,19 +497,20 @@
468 }497 }
469 self.assertEquals(hooks.get_cell_type(), 'parent')498 self.assertEquals(hooks.get_cell_type(), 'parent')
470499
500 @patch.object(hooks, 'canonical_url')
471 @patch.object(os, 'rename')501 @patch.object(os, 'rename')
472 @patch.object(os.path, 'isfile')502 @patch.object(os.path, 'isfile')
473 @patch.object(hooks, 'CONFIGS')503 @patch.object(hooks, 'CONFIGS')
474 @patch.object(hooks, 'get_cell_type')504 @patch.object(hooks, 'get_cell_type')
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,
476 rename):506 rename, _canonical_url):
477 neutron_conf = '/etc/neutron/neutron.conf'507 neutron_conf = '/etc/neutron/neutron.conf'
478 nova_url = 'http://novaurl:8774/v2'508 nova_url = 'http://novaurl:8774/v2'
479 isfile.return_value = True509 isfile.return_value = True
480 self.service_running.return_value = True510 self.service_running.return_value = True
481 _identity_joined = self.patch('identity_joined')511 _identity_joined = self.patch('identity_joined')
482 self.relation_ids.return_value = ['relid']512 self.relation_ids.return_value = ['relid']
483 self.canonical_url.return_value = 'http://novaurl'513 _canonical_url.return_value = 'http://novaurl'
484 get_cell_type.return_value = 'parent'514 get_cell_type.return_value = 'parent'
485 self.uuid.uuid4.return_value = 'bob'515 self.uuid.uuid4.return_value = 'bob'
486 with patch_open() as (_open, _file):516 with patch_open() as (_open, _file):
@@ -517,11 +547,12 @@
517 self.assertTrue(_compute_joined.called)547 self.assertTrue(_compute_joined.called)
518 self.assertTrue(_quantum_joined.called)548 self.assertTrue(_quantum_joined.called)
519549
550 @patch.object(hooks, 'canonical_url')
520 @patch.object(utils, 'config')551 @patch.object(utils, 'config')
521 def test_console_settings_vnc(self, _utils_config):552 def test_console_settings_vnc(self, _utils_config, _canonical_url):
522 _utils_config.return_value = 'vnc'553 _utils_config.return_value = 'vnc'
523 _cc_host = "nova-cc-host1"554 _cc_host = "nova-cc-host1"
524 self.canonical_url.return_value = 'http://' + _cc_host555 _canonical_url.return_value = 'http://' + _cc_host
525 _con_sets = hooks.console_settings()556 _con_sets = hooks.console_settings()
526 console_settings = {557 console_settings = {
527 'console_proxy_novnc_address': 'http://%s:6080/vnc_auto.html' %558 'console_proxy_novnc_address': 'http://%s:6080/vnc_auto.html' %
@@ -537,11 +568,12 @@
537 }568 }
538 self.assertEqual(_con_sets, console_settings)569 self.assertEqual(_con_sets, console_settings)
539570
571 @patch.object(hooks, 'canonical_url')
540 @patch.object(utils, 'config')572 @patch.object(utils, 'config')
541 def test_console_settings_xvpvnc(self, _utils_config):573 def test_console_settings_xvpvnc(self, _utils_config, _canonical_url):
542 _utils_config.return_value = 'xvpvnc'574 _utils_config.return_value = 'xvpvnc'
543 _cc_host = "nova-cc-host1"575 _cc_host = "nova-cc-host1"
544 self.canonical_url.return_value = 'http://' + _cc_host576 _canonical_url.return_value = 'http://' + _cc_host
545 _con_sets = hooks.console_settings()577 _con_sets = hooks.console_settings()
546 console_settings = {578 console_settings = {
547 'console_access_protocol': 'xvpvnc',579 'console_access_protocol': 'xvpvnc',
@@ -553,11 +585,12 @@
553 }585 }
554 self.assertEqual(_con_sets, console_settings)586 self.assertEqual(_con_sets, console_settings)
555587
588 @patch.object(hooks, 'canonical_url')
556 @patch.object(utils, 'config')589 @patch.object(utils, 'config')
557 def test_console_settings_novnc(self, _utils_config):590 def test_console_settings_novnc(self, _utils_config, _canonical_url):
558 _utils_config.return_value = 'novnc'591 _utils_config.return_value = 'novnc'
559 _cc_host = "nova-cc-host1"592 _cc_host = "nova-cc-host1"
560 self.canonical_url.return_value = 'http://' + _cc_host593 _canonical_url.return_value = 'http://' + _cc_host
561 _con_sets = hooks.console_settings()594 _con_sets = hooks.console_settings()
562 console_settings = {595 console_settings = {
563 'console_proxy_novnc_address': 'http://%s:6080/vnc_auto.html' %596 'console_proxy_novnc_address': 'http://%s:6080/vnc_auto.html' %
@@ -569,11 +602,12 @@
569 }602 }
570 self.assertEqual(_con_sets, console_settings)603 self.assertEqual(_con_sets, console_settings)
571604
605 @patch.object(hooks, 'canonical_url')
572 @patch.object(utils, 'config')606 @patch.object(utils, 'config')
573 def test_console_settings_spice(self, _utils_config):607 def test_console_settings_spice(self, _utils_config, _canonical_url):
574 _utils_config.return_value = 'spice'608 _utils_config.return_value = 'spice'
575 _cc_host = "nova-cc-host1"609 _cc_host = "nova-cc-host1"
576 self.canonical_url.return_value = 'http://' + _cc_host610 _canonical_url.return_value = 'http://' + _cc_host
577 _con_sets = hooks.console_settings()611 _con_sets = hooks.console_settings()
578 console_settings = {612 console_settings = {
579 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' %613 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' %
@@ -585,14 +619,16 @@
585 }619 }
586 self.assertEqual(_con_sets, console_settings)620 self.assertEqual(_con_sets, console_settings)
587621
622 @patch.object(hooks, 'canonical_url')
588 @patch.object(utils, 'config')623 @patch.object(utils, 'config')
589 def test_console_settings_explicit_ip(self, _utils_config):624 def test_console_settings_explicit_ip(self, _utils_config,
625 _canonical_url):
590 _utils_config.return_value = 'spice'626 _utils_config.return_value = 'spice'
591 _cc_public_host = "public-host"627 _cc_public_host = "public-host"
592 _cc_private_host = "private-host"628 _cc_private_host = "private-host"
593 self.test_config.set('console-proxy-ip', _cc_public_host)629 self.test_config.set('console-proxy-ip', _cc_public_host)
594 _con_sets = hooks.console_settings()630 _con_sets = hooks.console_settings()
595 self.canonical_url.return_value = 'http://' + _cc_private_host631 _canonical_url.return_value = 'http://' + _cc_private_host
596 console_settings = {632 console_settings = {
597 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' %633 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' %
598 (_cc_public_host),634 (_cc_public_host),

Subscribers

People subscribed via source and target branches