Use spice_agent_enabled key from cloud-compute relation
spice_agent_enabled is provided by nova-cloud-controller to inform nova-compute the value that needs to be set in the configuration option [spice].agent_enabled Change-Id: I49d6e04a545d4b13f9a65e5fd239aa911e75a3ba Closes-Bug: #1856602
This commit is contained in:
parent
ae3172b3c8
commit
e351544423
@ -717,6 +717,7 @@ class InstanceConsoleContext(context.OSContextGenerator):
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
|
||||
for rid in relation_ids('cloud-compute'):
|
||||
for unit in related_units(rid):
|
||||
rel = {'rid': rid, 'unit': unit}
|
||||
@ -726,6 +727,8 @@ class InstanceConsoleContext(context.OSContextGenerator):
|
||||
continue
|
||||
ctxt['console_keymap'] = relation_get('console_keymap', **rel)
|
||||
ctxt['console_access_protocol'] = proto
|
||||
ctxt['spice_agent_enabled'] = relation_get(
|
||||
'spice_agent_enabled', **rel)
|
||||
ctxt['console_vnc_type'] = True if 'vnc' in proto else False
|
||||
if proto == 'vnc':
|
||||
ctxt = dict(ctxt, **self.get_console_info('xvpvnc', **rel))
|
||||
|
@ -168,7 +168,7 @@ api_servers = {{ glance_api_servers }}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
agent_enabled = {{ spice_agent_enabled }}
|
||||
enabled = True
|
||||
html5proxy_base_url = {{ spice_proxy_address }}
|
||||
keymap = {{ console_keymap }}
|
||||
|
@ -173,7 +173,7 @@ api_servers = {{ glance_api_servers }}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
agent_enabled = {{ spice_agent_enabled }}
|
||||
enabled = True
|
||||
html5proxy_base_url = {{ spice_proxy_address }}
|
||||
keymap = {{ console_keymap }}
|
||||
|
@ -179,7 +179,7 @@ api_servers = {{ glance_api_servers }}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
agent_enabled = {{ spice_agent_enabled }}
|
||||
enabled = True
|
||||
html5proxy_base_url = {{ spice_proxy_address }}
|
||||
keymap = {{ console_keymap }}
|
||||
|
@ -180,7 +180,7 @@ api_servers = {{ glance_api_servers }}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
agent_enabled = {{ spice_agent_enabled }}
|
||||
enabled = True
|
||||
html5proxy_base_url = {{ spice_proxy_address }}
|
||||
keymap = {{ console_keymap }}
|
||||
|
@ -192,7 +192,7 @@ vendordata_dynamic_targets = {{ vendor_data_url }}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
agent_enabled = {{ spice_agent_enabled }}
|
||||
enabled = True
|
||||
html5proxy_base_url = {{ spice_proxy_address }}
|
||||
keymap = {{ console_keymap }}
|
||||
|
@ -192,7 +192,7 @@ vendordata_dynamic_targets = {{ vendor_data_url }}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
agent_enabled = {{ spice_agent_enabled }}
|
||||
enabled = True
|
||||
html5proxy_base_url = {{ spice_proxy_address }}
|
||||
keymap = {{ console_keymap }}
|
||||
|
@ -196,7 +196,7 @@ vendordata_dynamic_targets = {{ vendor_data_url }}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
agent_enabled = {{ spice_agent_enabled }}
|
||||
enabled = True
|
||||
html5proxy_base_url = {{ spice_proxy_address }}
|
||||
keymap = {{ console_keymap }}
|
||||
|
@ -824,3 +824,34 @@ class NovaComputeAvailabilityZoneContextTests(CharmTestCase):
|
||||
az_context = context.NovaComputeAvailabilityZoneContext()
|
||||
self.assertEqual(
|
||||
{'default_availability_zone': 'az1'}, az_context())
|
||||
|
||||
|
||||
class InstanceConsoleContextTest(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(InstanceConsoleContextTest, self).setUp(context, TO_PATCH)
|
||||
self.os_release.return_value = 'mitaka'
|
||||
|
||||
@patch.object(context, 'relation_ids')
|
||||
@patch.object(context, 'related_units')
|
||||
def test_spice(self, mock_related_units, mock_relation_ids):
|
||||
mock_relation_ids.return_value = ['cloud-compute:15']
|
||||
mock_related_units.return_value = ['nova-compute/0']
|
||||
|
||||
rel_settings = {
|
||||
'console_access_protocol': 'spice',
|
||||
'spice_agent_enabled': True,
|
||||
'console_keymap': 'en-us',
|
||||
'console_proxy_spice_address': 'http://1.2.3.4:56/spice_auto.html',
|
||||
'console_proxy_spice_host': '1.2.3.4',
|
||||
'console_proxy_spice_port': '56',
|
||||
}
|
||||
|
||||
def rel_get(key, rid, unit):
|
||||
return rel_settings[key]
|
||||
|
||||
self.relation_get.side_effect = rel_get
|
||||
|
||||
ctxt = context.InstanceConsoleContext()()
|
||||
|
||||
self.assertEqual(ctxt['spice_agent_enabled'], True, str(ctxt))
|
||||
|
Loading…
x
Reference in New Issue
Block a user