def generate_ha_relation_data(service, extra_settings=None):
    """ Generate relation data for ha relation

    Based on configuration options and unit interfaces, generate a json
    encoded dict of relation data items for the hacluster relation,
    providing configuration for DNS HA or VIP's + haproxy clone sets.

    Example of supplying additional settings::

        COLO_CONSOLEAUTH = 'inf: res_nova_consoleauth grp_nova_vips'
        AGENT_CONSOLEAUTH = 'ocf:openstack:nova-consoleauth'
        AGENT_CA_PARAMS = 'op monitor interval="5s"'

        ha_console_settings = {
            'colocations': {'vip_consoleauth': COLO_CONSOLEAUTH},
            'init_services': {'res_nova_consoleauth': 'nova-consoleauth'},
            'resources': {'res_nova_consoleauth': AGENT_CONSOLEAUTH},
            'resource_params': {'res_nova_consoleauth': AGENT_CA_PARAMS})
        generate_ha_relation_data('nova', extra_settings=ha_console_settings)


    @param service: Name of the service being configured
    @param extra_settings: Dict of additional resource data
    @returns dict: json encoded data for use with relation_set
    """
    _haproxy_res = 'res_{}_haproxy'.format(service)
    _relation_data = {
        'resources': {
            _haproxy_res: 'lsb:haproxy',
        },
        'resource_params': {
            _haproxy_res: 'op monitor interval="5s"'
        },
        'init_services': {
            _haproxy_res: 'haproxy'
        },
        'clones': {
            'cl_{}_haproxy'.format(service): _haproxy_res
        },
    }

    if extra_settings:
        for k, v in extra_settings.items():
            if _relation_data.get(k):
                _relation_data[k].update(v)
            else:
                _relation_data[k] = v

    if config('dns-ha'):
        update_hacluster_dns_ha(service, _relation_data)
    else:
        update_hacluster_vip(service, _relation_data)

    return {
        'json_{}'.format(k): json.dumps(v, **JSON_ENCODE_OPTIONS)
        for k, v in _relation_data.items() if v
    }
Generate relation data for ha relation

    Based on configuration options and unit interfaces, generate a json
    encoded dict of relation data items for the hacluster relation,
    providing configuration for DNS HA or VIP's + haproxy clone sets.

    Example of supplying additional settings::

        COLO_CONSOLEAUTH = 'inf: res_nova_consoleauth grp_nova_vips'
        AGENT_CONSOLEAUTH = 'ocf:openstack:nova-consoleauth'
        AGENT_CA_PARAMS = 'op monitor interval="5s"'

        ha_console_settings = {
            'colocations': {'vip_consoleauth': COLO_CONSOLEAUTH},
            'init_services': {'res_nova_consoleauth': 'nova-consoleauth'},
            'resources': {'res_nova_consoleauth': AGENT_CONSOLEAUTH},
            'resource_params': {'res_nova_consoleauth': AGENT_CA_PARAMS})
        generate_ha_relation_data('nova', extra_settings=ha_console_settings)


    @param service: Name of the service being configured
    @param extra_settings: Dict of additional resource data
    @returns dict: json encoded data for use with relation_set