{% set compute_bind_defaults = {
    'vnc_address': '10.0.0.10',
    'vnc_port': '6080',
    'vnc_name': 'cloud.domain.com',
    'vnc_protocol': 'http',
} %}

{% set controller = salt['grains.filter_by']({
    'Debian': {
        'pkgs': ['nova-consoleproxy', 'novnc', 'nova-api', 'nova-cert', 'nova-conductor', 'nova-consoleauth', 'nova-doc', 'nova-scheduler', 'python-novaclient', 'python-memcache', 'gettext-base', 'python-pycadf'],
        'services': ['nova-api', 'nova-cert', 'nova-consoleauth', 'nova-scheduler', 'nova-conductor', 'nova-novncproxy'],
        'debug': false,
        'audit': {
          'enabled': false
        },
    },
    'RedHat': {
        'pkgs': ['openstack-nova-novncproxy', 'python-nova', 'openstack-nova-api', 'openstack-nova-console', 'openstack-nova-scheduler', 'python-novaclient', 'openstack-nova-common', 'openstack-nova-conductor', 'openstack-nova-cert', 'python-pycadf'],
        'services': ['openstack-nova-api', 'openstack-nova-cert', 'openstack-nova-consoleauth', 'openstack-nova-scheduler', 'openstack-nova-conductor', 'openstack-nova-novncproxy'],
        'debug': false,
        'audit': {
          'enabled': false
        },
    },
}, merge=pillar.nova.get('controller', {})) %}

{% set compute = salt['grains.filter_by']({
    'Debian': {
        'pkgs': ['nova-compute-kvm', 'python-novaclient', 'pm-utils', 'sysfsutils', 'sg3-utils', 'libvirt-bin', 'python-memcache', 'qemu-kvm','python-guestfs', 'gettext-base'],
        'services': ['nova-compute'],
        'libvirt_config': 'libvirtd.conf',
        'libvirt_service': 'libvirtd',
        'bind': compute_bind_defaults,
        'debug': false,
        'identity': {
            'region': 'RegionOne'
        },
        'network': {
            'region': 'RegionOne'
        },
        'heal_instance_info_cache_interval': '60',
    },
    'RedHat': {
        'pkgs': ['openstack-nova-compute', 'python-novaclient', 'python-nova', 'sysfsutils', 'sg3_utils'],
        'services': ['messagebus', 'openstack-nova-compute', 'libvirtd'],
        'libvirt_config': 'libvirt.conf',
        'libvirt_bin': '/etc/sysconfig/libvirtd',
        'libvirt_service': 'libvirtd',
        'bind': compute_bind_defaults,
        'debug': false,
        'identity': {
            'region': 'RegionOne'
        },
        'network': {
            'region': 'RegionOne'
        },
        'heal_instance_info_cache_interval': '60',
    },
}, merge=salt['grains.filter_by']({
    'trusty': {
        'libvirt_bin': '/etc/default/libvirt-bin',
        'libvirt_service': 'libvirt-bin',
    },
}, grain='oscodename', merge=pillar.nova.get('compute', {}))) %}

{%- if salt['pillar.get']('linux:system:repo:mirantis_openstack' , False) or salt['pillar.get']('linux:system:repo:mirantis' , False) %}
{%- do compute.update({'libvirt_bin': '/etc/default/libvirtd'}) %}
{%- do compute.update({'libvirt_service': 'libvirtd'}) %}
{%- endif %}
