From 2c918a46b36caeb5f003488bf0bd0ef0a6888b34 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Fri, 22 Jan 2016 10:33:27 +0000 Subject: [PATCH] Enable notifications for designate --- hooks/nova-designate-relation-broken | 1 + hooks/nova-designate-relation-changed | 1 + hooks/nova-designate-relation-joined | 1 + hooks/nova_compute_context.py | 17 +++ hooks/nova_compute_utils.py | 2 + metadata.yaml | 2 + templates/kilo/nova.conf | 6 - templates/liberty/nova.conf | 190 ++++++++++++++++++++++++++ 8 files changed, 214 insertions(+), 6 deletions(-) create mode 120000 hooks/nova-designate-relation-broken create mode 120000 hooks/nova-designate-relation-changed create mode 120000 hooks/nova-designate-relation-joined create mode 100644 templates/liberty/nova.conf diff --git a/hooks/nova-designate-relation-broken b/hooks/nova-designate-relation-broken new file mode 120000 index 00000000..3ba0bdea --- /dev/null +++ b/hooks/nova-designate-relation-broken @@ -0,0 +1 @@ +nova_compute_hooks.py \ No newline at end of file diff --git a/hooks/nova-designate-relation-changed b/hooks/nova-designate-relation-changed new file mode 120000 index 00000000..3ba0bdea --- /dev/null +++ b/hooks/nova-designate-relation-changed @@ -0,0 +1 @@ +nova_compute_hooks.py \ No newline at end of file diff --git a/hooks/nova-designate-relation-joined b/hooks/nova-designate-relation-joined new file mode 120000 index 00000000..3ba0bdea --- /dev/null +++ b/hooks/nova-designate-relation-joined @@ -0,0 +1 @@ +nova_compute_hooks.py \ No newline at end of file diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 1717eadb..cf9e73d6 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -452,6 +452,23 @@ class MetadataServiceContext(context.OSContextGenerator): return ctxt +class DesignateContext(context.OSContextGenerator): + + def __call__(self): + ctxt = {} + ctxt['enable_designate_designate'] = False + for rid in relation_ids('nova-designate'): + if related_units(rid): + ctxt['enable_designate_designate'] = True + if ctxt['enable_designate_designate']: + ctxt['notification_driver'] = 'messaging' + ctxt['notification_topics'] = 'notifications_designate' + ctxt['notify_on_state_change'] = 'vm_and_task_state' + # ctxt['instance_usage_audit_period'] = 'hour' + # ctxt['instance_usage_audit'] = 'true' + return ctxt + + class NeutronComputeContext(context.NeutronContext): interfaces = [] diff --git a/hooks/nova_compute_utils.py b/hooks/nova_compute_utils.py index 5dbafc62..a52da82b 100644 --- a/hooks/nova_compute_utils.py +++ b/hooks/nova_compute_utils.py @@ -78,6 +78,7 @@ from nova_compute_context import ( CEPH_CONF, ceph_config_file, HostIPContext, + DesignateContext, ) CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt' @@ -178,6 +179,7 @@ BASE_RESOURCE_MAP = { context.NotificationDriverContext(), MetadataServiceContext(), HostIPContext(), + DesignateContext(), context.LogLevelContext()], }, } diff --git a/metadata.yaml b/metadata.yaml index bfb108f0..8fd4acbd 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -27,6 +27,8 @@ requires: interface: glance ceph: interface: ceph-client + nova-designate: + interface: nova-designate lxd: interface: containers scope: container diff --git a/templates/kilo/nova.conf b/templates/kilo/nova.conf index be1c4bfa..8d28464f 100644 --- a/templates/kilo/nova.conf +++ b/templates/kilo/nova.conf @@ -107,12 +107,6 @@ volume_api_class = nova.volume.cinder.API instances_path = {{ instances_path }} {% endif -%} -notification_driver=messaging -notification_topics = notifications_designate -notify_on_state_change = vm_and_task_state -instance_usage_audit_period = hour -instance_usage_audit = true - {% if sections and 'DEFAULT' in sections -%} {% for key, value in sections['DEFAULT'] -%} {{ key }} = {{ value }} diff --git a/templates/liberty/nova.conf b/templates/liberty/nova.conf new file mode 100644 index 00000000..7d8f18a4 --- /dev/null +++ b/templates/liberty/nova.conf @@ -0,0 +1,190 @@ +# liberty +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +{% if restart_trigger -%} +# restart trigger: {{ restart_trigger }} +{% endif -%} +############################################################################### +[DEFAULT] +verbose={{ verbose }} +debug={{ debug }} +dhcpbridge_flagfile=/etc/nova/nova.conf +dhcpbridge=/usr/bin/nova-dhcpbridge +logdir=/var/log/nova +state_path=/var/lib/nova +force_dhcp_release=True +use_syslog = {{ use_syslog }} +ec2_private_dns_show_ip=True +api_paste_config=/etc/nova/api-paste.ini +enabled_apis=ec2,osapi_compute,metadata +auth_strategy=keystone +my_ip = {{ host_ip }} + +{% if arch == 'aarch64' -%} +libvirt_use_virtio_for_bridges=False +libvirt_disk_prefix=vd +{% endif -%} + +{% if console_vnc_type -%} +vnc_enabled = True +novnc_enabled = True +vnc_keymap = {{ console_keymap }} +vncserver_listen = 0.0.0.0 +vncserver_proxyclient_address = {{ console_listen_addr }} +{% if console_access_protocol == 'novnc' or console_access_protocol == 'vnc' -%} +novncproxy_base_url = {{ novnc_proxy_address }} +{% 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 in ('ovs', 'midonet') -%} +libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtGenericVIFDriver +{% if neutron_security_groups -%} +security_group_api = neutron +firewall_driver = nova.virt.firewall.NoopFirewallDriver +{% endif -%} +{% endif -%} + +{% if neutron_plugin and neutron_plugin == 'vsp' -%} +network_api_class=nova.network.neutronv2.api.API +libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtGenericVIFDriver +neutron_ovs_bridge=alubr0 +security_group_api=nova +firewall_driver = nova.virt.firewall.NoopFirewallDriver +{% endif -%} + +{% if neutron_plugin and (neutron_plugin == 'nvp' or neutron_plugin == 'nsx') -%} +libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtOpenVswitchVirtualPortDriver +security_group_api = neutron +firewall_driver = nova.virt.firewall.NoopFirewallDriver +{% endif -%} + +{% if neutron_plugin and neutron_plugin == 'Calico' -%} +security_group_api = neutron +firewall_driver = nova.virt.firewall.NoopFirewallDriver +{% endif -%} + +{% if neutron_plugin and neutron_plugin == 'plumgrid' -%} +security_group_api=neutron +firewall_driver = nova.virt.firewall.NoopFirewallDriver +{% endif -%} + +{% if network_manager != 'neutron' and network_manager_config -%} +{% for key, value in network_manager_config.iteritems() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + +{% if network_manager == 'neutron' -%} +network_api_class = nova.network.neutronv2.api.API +{% else -%} +network_manager = nova.network.manager.FlatDHCPManager +{% endif -%} + +{% if network_device_mtu -%} +network_device_mtu = {{ network_device_mtu }} +{% endif -%} + +{% if volume_service -%} +volume_api_class = nova.volume.cinder.API +{% endif -%} + +{% if user_config_flags -%} +{% for key, value in user_config_flags.iteritems() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + +{% if instances_path -%} +instances_path = {{ instances_path }} +{% endif -%} + +{% if enable_designate_designate -%} +notification_driver = {{ notification_driver }} +notification_topics = {{ notification_topics }} +notify_on_state_change = {{ notify_on_state_change }} +{% endif -%} + +{% if sections and 'DEFAULT' in sections -%} +{% for key, value in sections['DEFAULT'] -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + +{% include "section-zeromq" %} + +{% if network_manager == 'neutron' and network_manager_config -%} +[neutron] +url = {{ network_manager_config.neutron_url }} +{% if network_manager_config.keystone_host -%} +{% if neutron_plugin and neutron_plugin == 'vsp' -%} +ovs_bridge = alubr0 +{% endif -%} +auth_strategy = keystone +admin_tenant_name = {{ network_manager_config.neutron_admin_tenant_name }} +admin_username = {{ network_manager_config.neutron_admin_username }} +admin_password = {{ network_manager_config.neutron_admin_password }} +admin_auth_url = {{ network_manager_config.auth_protocol }}://{{ network_manager_config.keystone_host }}:{{ network_manager_config.auth_port }}/v2.0 +{% if metadata_shared_secret -%} +metadata_proxy_shared_secret = {{ metadata_shared_secret }} +service_metadata_proxy=True +{% endif -%} +{% endif -%} +{% endif -%} + +{% if glance_api_servers -%} +[glance] +api_servers = {{ glance_api_servers }} +{% endif -%} + +{% if console_access_protocol == 'spice' -%} +[spice] +agent_enabled = True +enabled = True +html5proxy_base_url = {{ spice_proxy_address }} +keymap = {{ console_keymap }} +server_listen = 0.0.0.0 +server_proxyclient_address = {{ console_listen_addr }} +{% endif -%} + +[libvirt] +{% if cpu_mode -%} +cpu_mode = {{ cpu_mode }} +{% endif -%} +{% if cpu_model -%} +cpu_model = {{ cpu_model }} +{% endif -%} +{% if libvirt_images_type -%} +images_type = {{ libvirt_images_type }} +images_rbd_pool = {{ rbd_pool }} +images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }} +inject_password=false +inject_key=false +inject_partition=-2 +{% endif -%} +{% if rbd_pool -%} +rbd_pool = {{ rbd_pool }} +rbd_user = {{ rbd_user }} +rbd_secret_uuid = {{ rbd_secret_uuid }} +{% endif -%} +{% if live_migration_uri -%} +live_migration_uri = {{ live_migration_uri }} +{% endif -%} +{% if disk_cachemodes -%} +disk_cachemodes = {{ disk_cachemodes }} +{% endif -%} + +{% include "parts/section-database" %} + +{% include "section-rabbitmq-oslo" %} + +[oslo_concurrency] +lock_path=/var/lock/nova