From 1eec7cb3778cdca523241c9b857d1d8655724550 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 9 Jul 2014 14:09:40 +0100 Subject: [PATCH 01/10] Add config for guest console access --- hooks/nova_compute_context.py | 23 +++++++++++++++++++++++ hooks/nova_compute_utils.py | 3 ++- templates/grizzly/nova.conf | 14 ++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 1a6351b5..5265f2d4 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -310,7 +310,30 @@ class CloudComputeContext(context.OSContextGenerator): if self.restart_trigger(): ctxt['restart_trigger'] = self.restart_trigger() + return ctxt + +class InstanceConsoleContext(context.OSContextGenerator): + interfaces = [] + + def __call__(self): + ctxt = {} + for rid in relation_ids('cloud-compute'): + for unit in related_units(rid): + rel = {'rid': rid, 'unit': unit} + proto = relation_get('console_access_protocol', **rel) + if not proto: + # only bother with units that have a neutron url set. + continue + ctxt = { + 'console_access_protocol': proto, + 'console_proxy_address': relation_get( + 'console_proxy_address', **rel), + 'console_keymap': relation_get( + 'console_keymap', **rel), + } + break + ctxt['local_spice_addr'] = get_host_ip(unit_get('private-address')) return ctxt diff --git a/hooks/nova_compute_utils.py b/hooks/nova_compute_utils.py index 601b916a..627c9ac1 100644 --- a/hooks/nova_compute_utils.py +++ b/hooks/nova_compute_utils.py @@ -77,7 +77,8 @@ BASE_RESOURCE_MAP = { context.SubordinateConfigContext( interface='nova-ceilometer', service='nova', - config_file=NOVA_CONF)], + config_file=NOVA_CONF), + context.InstanceConsoleContext(), ], }, } diff --git a/templates/grizzly/nova.conf b/templates/grizzly/nova.conf index bec7a7b3..44fbad2f 100644 --- a/templates/grizzly/nova.conf +++ b/templates/grizzly/nova.conf @@ -36,6 +36,11 @@ rbd_user = {{ rbd_user }} rbd_secret_uuid = {{ rbd_secret_uuid }} {% endif -%} +{% if == 'spice' -%} +vnc_enabled = False +novnc_enabled = False +{% endif -%} + {% if neutron_plugin and neutron_plugin == 'ovs' -%} libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtGenericVIFDriver {% if neutron_security_groups -%} @@ -80,3 +85,12 @@ live_migration_uri = {{ live_migration_uri }} instances_path = {{ instances_path }} {% endif -%} +{% if == 'spice' -%} +[spice] +agent_enabled = True +enabled = True +html5proxy_base_url = {{ console_proxy_address }} +keymap = {{ console_keymap }} +server_listen = {{ local_spice_addr }} +server_proxyclient_address = {{ local_spice_addr }} +{% endif -%} From cd00f463be8b30a22d36750a979886c3b18b5b92 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 9 Jul 2014 14:30:56 +0100 Subject: [PATCH 02/10] Minor bug fix --- hooks/nova_compute_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooks/nova_compute_utils.py b/hooks/nova_compute_utils.py index 627c9ac1..a04608ff 100644 --- a/hooks/nova_compute_utils.py +++ b/hooks/nova_compute_utils.py @@ -32,6 +32,7 @@ from nova_compute_context import ( NovaComputeLibvirtContext, NovaComputeCephContext, NeutronComputeContext, + InstanceConsoleContext(), ) CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt' @@ -78,7 +79,7 @@ BASE_RESOURCE_MAP = { interface='nova-ceilometer', service='nova', config_file=NOVA_CONF), - context.InstanceConsoleContext(), ], + InstanceConsoleContext(), ], }, } From 0d15e2c3e1c20d1fd1263afbe377d825a9664ab8 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 9 Jul 2014 14:42:57 +0100 Subject: [PATCH 03/10] Another Minor bug fix --- hooks/nova_compute_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/nova_compute_utils.py b/hooks/nova_compute_utils.py index a04608ff..1f941407 100644 --- a/hooks/nova_compute_utils.py +++ b/hooks/nova_compute_utils.py @@ -32,7 +32,7 @@ from nova_compute_context import ( NovaComputeLibvirtContext, NovaComputeCephContext, NeutronComputeContext, - InstanceConsoleContext(), + InstanceConsoleContext, ) CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt' From 1aab75b7112618fd75a2a76c579ab59bf7df4836 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 9 Jul 2014 15:40:09 +0100 Subject: [PATCH 04/10] Add console settings to havana template --- templates/grizzly/nova.conf | 4 ++-- templates/havana/nova.conf | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/templates/grizzly/nova.conf b/templates/grizzly/nova.conf index 44fbad2f..3d23e041 100644 --- a/templates/grizzly/nova.conf +++ b/templates/grizzly/nova.conf @@ -36,7 +36,7 @@ rbd_user = {{ rbd_user }} rbd_secret_uuid = {{ rbd_secret_uuid }} {% endif -%} -{% if == 'spice' -%} +{% if console_access_protocol == 'spice' -%} vnc_enabled = False novnc_enabled = False {% endif -%} @@ -85,7 +85,7 @@ live_migration_uri = {{ live_migration_uri }} instances_path = {{ instances_path }} {% endif -%} -{% if == 'spice' -%} +{% if console_access_protocol == 'spice' -%} [spice] agent_enabled = True enabled = True diff --git a/templates/havana/nova.conf b/templates/havana/nova.conf index 0b16ad34..532b29b6 100644 --- a/templates/havana/nova.conf +++ b/templates/havana/nova.conf @@ -36,6 +36,11 @@ rbd_user = {{ rbd_user }} rbd_secret_uuid = {{ rbd_secret_uuid }} {% endif -%} +{% if console_access_protocol == 'spice' -%} +vnc_enabled = False +novnc_enabled = False +{% endif -%} + {% if neutron_plugin and neutron_plugin == 'ovs' -%} libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtGenericVIFDriver {% if neutron_security_groups -%} @@ -85,3 +90,13 @@ instances_path = {{ instances_path }} {{ key }} = {{ value }} {% endfor -%} {% endif -%} + +{% if console_access_protocol == 'spice' -%} +[spice] +agent_enabled = True +enabled = True +html5proxy_base_url = {{ console_proxy_address }} +keymap = {{ console_keymap }} +server_listen = {{ local_spice_addr }} +server_proxyclient_address = {{ local_spice_addr }} +{% endif -%} From 24a3e61a010178d3060498aef1297cc1ca202d57 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 9 Jul 2014 16:42:07 +0100 Subject: [PATCH 05/10] Added novnc support to nova-compute --- templates/havana/nova.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/havana/nova.conf b/templates/havana/nova.conf index 532b29b6..505dd3a3 100644 --- a/templates/havana/nova.conf +++ b/templates/havana/nova.conf @@ -39,6 +39,12 @@ rbd_secret_uuid = {{ rbd_secret_uuid }} {% if console_access_protocol == 'spice' -%} vnc_enabled = False novnc_enabled = False +{% elif console_access_protocol == 'novnc' -%} +vnc_enabled = True +novnc_enabled = True +vncserver_proxyclient_address = {{ local_spice_addr }} +vncserver_listen = {{ local_spice_addr }} +novncproxy_base_url = {{ console_proxy_address }} {% endif -%} {% if neutron_plugin and neutron_plugin == 'ovs' -%} From 187895df133f9865da645f8c434d81827dc3ef26 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 10 Jul 2014 08:28:35 +0100 Subject: [PATCH 06/10] Update to support all vnc types --- hooks/nova_compute_context.py | 31 ++++++++++++++++++++++--------- templates/grizzly/nova.conf | 9 ++++++++- templates/havana/nova.conf | 27 +++++++++++++++++---------- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 5265f2d4..bdb236be 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -316,6 +316,18 @@ class CloudComputeContext(context.OSContextGenerator): class InstanceConsoleContext(context.OSContextGenerator): interfaces = [] + def get_console_settings(self, proto, **kwargs): + console_settings = { + proto + '_proxy_address': \ + relation_get('console_proxy_%s_address' % \ + (proto), **kwargs), + proto + '_proxy_host': \ + relation_get('console_proxy_%s_host' % (proto), **kwargs), + proto + '_proxy_port': \ + relation_get('console_proxy_%s_port' % (proto), **kwargs), + } + return console_settings + def __call__(self): ctxt = {} for rid in relation_ids('cloud-compute'): @@ -323,17 +335,18 @@ class InstanceConsoleContext(context.OSContextGenerator): rel = {'rid': rid, 'unit': unit} proto = relation_get('console_access_protocol', **rel) if not proto: - # only bother with units that have a neutron url set. + # only bother with units that have a proto set. continue - ctxt = { - 'console_access_protocol': proto, - 'console_proxy_address': relation_get( - 'console_proxy_address', **rel), - 'console_keymap': relation_get( - 'console_keymap', **rel), - } + ctxt['console_keymap'] = relation_get('console_keymap', **rel) + ctxt['console_access_protocol'] = proto + ctxt['console_vnc_type'] = True if 'vnc' in proto else False + if proto == 'vnc': + ctxt = dict(ctxt, **self.get_console_settings('xvpvnc', **rel)) + ctxt = dict(ctxt, **self.get_console_settings('novnc', **rel)) + else: + ctxt = dict(ctxt, **self.get_console_settings(proto, **rel)) break - ctxt['local_spice_addr'] = get_host_ip(unit_get('private-address')) + ctxt['console_listen_addr'] = get_host_ip(unit_get('private-address')) return ctxt diff --git a/templates/grizzly/nova.conf b/templates/grizzly/nova.conf index 3d23e041..a491e160 100644 --- a/templates/grizzly/nova.conf +++ b/templates/grizzly/nova.conf @@ -39,6 +39,13 @@ rbd_secret_uuid = {{ rbd_secret_uuid }} {% if console_access_protocol == 'spice' -%} vnc_enabled = False novnc_enabled = False +{% elif console_access_protocol == 'novnc' -%} +vnc_enabled = True +novnc_enabled = True +vncserver_proxyclient_address = {{ local_spice_addr }} +vncserver_listen = 0.0.0.0 +novncproxy_base_url = {{ console_proxy_address }} +keymap = {{ console_keymap }} {% endif -%} {% if neutron_plugin and neutron_plugin == 'ovs' -%} @@ -91,6 +98,6 @@ agent_enabled = True enabled = True html5proxy_base_url = {{ console_proxy_address }} keymap = {{ console_keymap }} -server_listen = {{ local_spice_addr }} +server_listen = 0.0.0.0 server_proxyclient_address = {{ local_spice_addr }} {% endif -%} diff --git a/templates/havana/nova.conf b/templates/havana/nova.conf index 505dd3a3..a42a86da 100644 --- a/templates/havana/nova.conf +++ b/templates/havana/nova.conf @@ -36,15 +36,22 @@ rbd_user = {{ rbd_user }} rbd_secret_uuid = {{ rbd_secret_uuid }} {% endif -%} -{% if console_access_protocol == 'spice' -%} -vnc_enabled = False -novnc_enabled = False -{% elif console_access_protocol == 'novnc' -%} +{% if console_vnc_type -%} vnc_enabled = True novnc_enabled = True -vncserver_proxyclient_address = {{ local_spice_addr }} -vncserver_listen = {{ local_spice_addr }} -novncproxy_base_url = {{ console_proxy_address }} +vnc_keymap = {{ console_keymap }} +vncserver_listen = 0.0.0.0 +vncserver_proxyclient_address = {{ console_listen_addr }} +{% else -%} +vnc_enabled = False +novnc_enabled = False +{% endif -%} +{% if console_access_protocol == 'novnc' or console_access_protocol == 'vnc' -%} +novncproxy_base_url = {{ console_proxy_novnc_address }} +{% elif console_access_protocol == 'xvpvnc' or console_access_protocol == 'vnc' -%} +xvpvncproxy_port = {{ console_proxy_xvpvnc_port }} +xvpvncproxy_host = {{ console_proxy_xvpvnc_host }} +xvpvncproxy_base_url = {{ console_proxy_xvpvnc_address }} {% endif -%} {% if neutron_plugin and neutron_plugin == 'ovs' -%} @@ -101,8 +108,8 @@ instances_path = {{ instances_path }} [spice] agent_enabled = True enabled = True -html5proxy_base_url = {{ console_proxy_address }} +html5proxy_base_url = {{ console_proxy_spice_address }} keymap = {{ console_keymap }} -server_listen = {{ local_spice_addr }} -server_proxyclient_address = {{ local_spice_addr }} +server_listen = 0.0.0.0 +server_proxyclient_address = {{ console_listen_addr }} {% endif -%} From 1e092ad7194fe6d049d64e3bce13dfcae76f26e6 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 10 Jul 2014 08:33:11 +0100 Subject: [PATCH 07/10] Fixed lint --- hooks/nova_compute_context.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index bdb236be..2542c3f6 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -316,15 +316,14 @@ class CloudComputeContext(context.OSContextGenerator): class InstanceConsoleContext(context.OSContextGenerator): interfaces = [] - def get_console_settings(self, proto, **kwargs): + def get_console_info(self, proto, **kwargs): console_settings = { - proto + '_proxy_address': \ - relation_get('console_proxy_%s_address' % \ - (proto), **kwargs), - proto + '_proxy_host': \ - relation_get('console_proxy_%s_host' % (proto), **kwargs), - proto + '_proxy_port': \ - relation_get('console_proxy_%s_port' % (proto), **kwargs), + proto + '_proxy_address': + relation_get('console_proxy_%s_address' % (proto), **kwargs), + proto + '_proxy_host': + relation_get('console_proxy_%s_host' % (proto), **kwargs), + proto + '_proxy_port': + relation_get('console_proxy_%s_port' % (proto), **kwargs), } return console_settings @@ -341,10 +340,10 @@ class InstanceConsoleContext(context.OSContextGenerator): ctxt['console_access_protocol'] = proto ctxt['console_vnc_type'] = True if 'vnc' in proto else False if proto == 'vnc': - ctxt = dict(ctxt, **self.get_console_settings('xvpvnc', **rel)) - ctxt = dict(ctxt, **self.get_console_settings('novnc', **rel)) + ctxt = dict(ctxt, **self.get_console_info('xvpvnc', **rel)) + ctxt = dict(ctxt, **self.get_console_info('novnc', **rel)) else: - ctxt = dict(ctxt, **self.get_console_settings(proto, **rel)) + ctxt = dict(ctxt, **self.get_console_info(proto, **rel)) break ctxt['console_listen_addr'] = get_host_ip(unit_get('private-address')) return ctxt From d3efb89cd8e77e3e2ec994aeaefb95b61b355eb8 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 10 Jul 2014 09:11:17 +0100 Subject: [PATCH 08/10] Fix mismatch in variable names between context and template --- templates/havana/nova.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/havana/nova.conf b/templates/havana/nova.conf index a42a86da..efff2361 100644 --- a/templates/havana/nova.conf +++ b/templates/havana/nova.conf @@ -47,11 +47,11 @@ vnc_enabled = False novnc_enabled = False {% endif -%} {% if console_access_protocol == 'novnc' or console_access_protocol == 'vnc' -%} -novncproxy_base_url = {{ console_proxy_novnc_address }} +novncproxy_base_url = {{ novnc_proxy_address }} {% elif console_access_protocol == 'xvpvnc' or console_access_protocol == 'vnc' -%} -xvpvncproxy_port = {{ console_proxy_xvpvnc_port }} -xvpvncproxy_host = {{ console_proxy_xvpvnc_host }} -xvpvncproxy_base_url = {{ console_proxy_xvpvnc_address }} +xvpvncproxy_port = {{ xvpvnc_proxy_port }} +xvpvncproxy_host = {{ xvpvnc_proxy_host }} +xvpvncproxy_base_url = {{ xvpvnc_proxy_address }} {% endif -%} {% if neutron_plugin and neutron_plugin == 'ovs' -%} @@ -108,7 +108,7 @@ instances_path = {{ instances_path }} [spice] agent_enabled = True enabled = True -html5proxy_base_url = {{ console_proxy_spice_address }} +html5proxy_base_url = {{ spice_proxy_address }} keymap = {{ console_keymap }} server_listen = 0.0.0.0 server_proxyclient_address = {{ console_listen_addr }} From 5bafcb92bb9198494e58341be0fa3cc1ac26987d Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 10 Jul 2014 09:00:44 +0000 Subject: [PATCH 09/10] Updated template to set xvpvnc setting when in vnc mode --- templates/havana/nova.conf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/templates/havana/nova.conf b/templates/havana/nova.conf index efff2361..ed4d7a1b 100644 --- a/templates/havana/nova.conf +++ b/templates/havana/nova.conf @@ -42,17 +42,18 @@ novnc_enabled = True vnc_keymap = {{ console_keymap }} vncserver_listen = 0.0.0.0 vncserver_proxyclient_address = {{ console_listen_addr }} -{% else -%} -vnc_enabled = False -novnc_enabled = False -{% endif -%} {% if console_access_protocol == 'novnc' or console_access_protocol == 'vnc' -%} novncproxy_base_url = {{ novnc_proxy_address }} -{% elif console_access_protocol == 'xvpvnc' or console_access_protocol == 'vnc' -%} +{% endif -%} +{% if console_access_protocol == 'xvpvnc' or console_access_protocol == 'vnc' -%} xvpvncproxy_port = {{ xvpvnc_proxy_port }} xvpvncproxy_host = {{ xvpvnc_proxy_host }} xvpvncproxy_base_url = {{ xvpvnc_proxy_address }} {% endif -%} +{% else -%} +vnc_enabled = False +novnc_enabled = False +{% endif -%} {% if neutron_plugin and neutron_plugin == 'ovs' -%} libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtGenericVIFDriver From 6d11ac3e67d01f2014a0af7a2816fa315308445e Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 10 Jul 2014 09:17:19 +0000 Subject: [PATCH 10/10] Revert console config from grizzly template as it will be out of support by the time these branches land and grizzly does not support spice --- templates/grizzly/nova.conf | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/templates/grizzly/nova.conf b/templates/grizzly/nova.conf index a491e160..bec7a7b3 100644 --- a/templates/grizzly/nova.conf +++ b/templates/grizzly/nova.conf @@ -36,18 +36,6 @@ rbd_user = {{ rbd_user }} rbd_secret_uuid = {{ rbd_secret_uuid }} {% endif -%} -{% if console_access_protocol == 'spice' -%} -vnc_enabled = False -novnc_enabled = False -{% elif console_access_protocol == 'novnc' -%} -vnc_enabled = True -novnc_enabled = True -vncserver_proxyclient_address = {{ local_spice_addr }} -vncserver_listen = 0.0.0.0 -novncproxy_base_url = {{ console_proxy_address }} -keymap = {{ console_keymap }} -{% endif -%} - {% if neutron_plugin and neutron_plugin == 'ovs' -%} libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtGenericVIFDriver {% if neutron_security_groups -%} @@ -92,12 +80,3 @@ live_migration_uri = {{ live_migration_uri }} instances_path = {{ instances_path }} {% endif -%} -{% if console_access_protocol == 'spice' -%} -[spice] -agent_enabled = True -enabled = True -html5proxy_base_url = {{ console_proxy_address }} -keymap = {{ console_keymap }} -server_listen = 0.0.0.0 -server_proxyclient_address = {{ local_spice_addr }} -{% endif -%}