Merge pull request #17 from dukov/master

Policy.json should be defined by user
diff --git a/.kitchen.yml b/.kitchen.yml
index a2b4313..c3e27e9 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -32,8 +32,13 @@
         "*":
           - linux_repo_openstack
           - nova
+    nova:
+      controller:
+        version: <%= ENV['OS_VERSION'] || 'mitaka' %>
+      compute:
+        version: <%= ENV['OS_VERSION'] || 'mitaka' %>
   pillars-from-files:
-    linux_repo_openstack.sls: tests/pillar/repo_mcp_openstack.sls
+    linux_repo_openstack.sls: tests/pillar/repo_mcp_openstack_<%= ENV['OS_VERSION'] || 'mitaka' %>.sls
 
 verifier:
   name: inspec
diff --git a/.travis.yml b/.travis.yml
index 08d84af..ceebb08 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,8 +17,9 @@
   - bundle install
 
 env:
-  - PLATFORM=trevorj/salty-whales:trusty
-  - PLATFORM=trevorj/salty-whales:xenial
+  - PLATFORM=trevorj/salty-whales:trusty OS_VERSION=mitaka
+  - PLATFORM=trevorj/salty-whales:xenial OS_VERSION=mitaka
+  - PLATFORM=trevorj/salty-whales:xenial OS_VERSION=newton
 
 before_script:
   - set -o pipefail
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 41e4b3f..b1d9bcd 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -6,7 +6,7 @@
       heka:
         enabled: true
       sensu:
-        enabled: true
+        enabled: false
       sphinx:
         enabled: true
       config:
diff --git a/nova/compute.sls b/nova/compute.sls
index efc8b0a..584dbe4 100644
--- a/nova/compute.sls
+++ b/nova/compute.sls
@@ -36,9 +36,9 @@
     - name: libvirtd
     - system: True
     - require_in:
-      - user: user_nova
+      - user: user_nova_compute
 
-user_nova:
+user_nova_compute:
   user.present:
   - name: nova
   - home: /var/lib/nova
@@ -61,13 +61,13 @@
     - file: /var/lib/nova/.ssh/id_rsa
     {%- endif %}
 
-group_nova:
+group_nova_compute:
   group.present:
     - name: nova
     - gid: 303
     - system: True
     - require_in:
-      - user: user_nova
+      - user: user_nova_compute
 {%- endif %}
 
 {%- if compute.user is defined %}
@@ -105,20 +105,20 @@
 {%- endif %}
 
 {%- if pillar.nova.controller is not defined %}
-
 /etc/nova/nova.conf:
   file.managed:
   - source: salt://nova/files/{{ compute.version }}/nova-compute.conf.{{ grains.os_family }}
   - template: jinja
+  - watch_in:
+    - service: nova_compute_services
   - require:
     - pkg: nova_compute_packages
+{%- endif %}
 
 nova_compute_services:
   service.running:
   - enable: true
   - names: {{ compute.services }}
-  - watch:
-    - file: /etc/nova/nova.conf
 
 {%- set ident = compute.identity %}
 
@@ -249,8 +249,6 @@
 
 {%- endif %}
 
-{%- endif %}
-
 {# temporary hack to fix broken init script in MOS 9.0 libvirt package #}
 
 {%- if compute.get('manage_init', False) and grains.init == 'upstart' %}
diff --git a/nova/controller.sls b/nova/controller.sls
index c6a4a03..03b8db7 100644
--- a/nova/controller.sls
+++ b/nova/controller.sls
@@ -101,9 +101,6 @@
     {%- if controller.version == "mitaka" or controller.version == "newton" or controller.version == "ocata" %}
     - nova-manage api_db sync
     {%- endif %}
-    {%- if controller.version == "ocata" %}
-    - 'su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova'
-    {%- endif %}
     {%- if controller.version == "newton" or controller.version == "ocata" %}
     - nova-manage db online_data_migrations
     {%- endif %}
@@ -113,9 +110,22 @@
 
 {%- if controller.version == "ocata" %}
 
+nova_controller_cell_syncdb:
+  cmd.run:
+  - name: 'su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova'
+  - require:
+    - cmd: nova_controller_syncdb
+
+nova_placement_service_mask:
+  file.symlink:
+   - name: /etc/systemd/system/nova-placement-api.service
+   - target: /dev/null
+
 nova_placement_package:
   pkg.installed:
   - name: nova-placement-api
+  - require:
+    - file: nova_placement_service_mask
 
 /etc/apache2/sites-available/nova-placement-api.conf:
   file.managed:
diff --git a/nova/files/ocata/nova-compute.conf.Debian b/nova/files/ocata/nova-compute.conf.Debian
index c78117c..b13d4a8 100644
--- a/nova/files/ocata/nova-compute.conf.Debian
+++ b/nova/files/ocata/nova-compute.conf.Debian
@@ -3062,7 +3062,7 @@
                          {%- endfor -%}
                              /{{ compute.message_queue.virtual_host }}
 {%- else %}
-transport_url = rabbit://{{ compute.message_queue.user }}:{{ compute.message_queue.password }}@{{ compute.message_queue.host }}:{{ controller.message_queue.port }}{{ compute.message_queue.virtual_host }}
+transport_url = rabbit://{{ compute.message_queue.user }}:{{ compute.message_queue.password }}@{{ compute.message_queue.host }}:{{ compute.message_queue.port }}{{ compute.message_queue.virtual_host }}
 {%- endif %}
 
 rpc_backend=rabbit
diff --git a/tests/pillar/repo_mcp_openstack_mitaka.sls b/tests/pillar/repo_mcp_openstack_mitaka.sls
new file mode 100644
index 0000000..ea24305
--- /dev/null
+++ b/tests/pillar/repo_mcp_openstack_mitaka.sls
@@ -0,0 +1,44 @@
+linux:
+  system:
+    enabled: true
+    repo:
+      mirantis_openstack_repo:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }} mitaka main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }}/archive-mcpmitaka.key"
+        pin:
+        - pin: 'release a=mitaka'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_hotfix:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }} mitaka-hotfix main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }}/archive-mcpmitaka.key"
+        pin:
+        - pin: 'release a=mitaka-hotfix'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_security:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }} mitaka-security main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }}/archive-mcpmitaka.key"
+        pin:
+        - pin: 'release a=mitaka-security'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_updates:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }} mitaka-updates main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }}/archive-mcpmitaka.key"
+        pin:
+        - pin: 'release a=mitaka-uptades'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_holdback:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }} mitaka-holdback main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/mitaka/{{ grains.get('oscodename') }}/archive-mcpmitaka.key"
+        pin:
+        - pin: 'release a=mitaka-holdback'
+          priority: 1050
+          package: '*'
diff --git a/tests/pillar/repo_mcp_openstack_newton.sls b/tests/pillar/repo_mcp_openstack_newton.sls
new file mode 100644
index 0000000..9504235
--- /dev/null
+++ b/tests/pillar/repo_mcp_openstack_newton.sls
@@ -0,0 +1,44 @@
+linux:
+  system:
+    enabled: true
+    repo:
+      mirantis_openstack_repo:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }} newton main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }}/archive-mcpnewton.key"
+        pin:
+        - pin: 'release a=newton'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_hotfix:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }} newton-hotfix main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }}/archive-mcpnewton.key"
+        pin:
+        - pin: 'release a=newton-hotfix'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_security:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }} newton-security main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }}/archive-mcpnewton.key"
+        pin:
+        - pin: 'release a=newton-security'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_updates:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }} newton-updates main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }}/archive-mcpnewton.key"
+        pin:
+        - pin: 'release a=newton-uptades'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_holdback:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }} newton-holdback main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/newton/{{ grains.get('oscodename') }}/archive-mcpnewton.key"
+        pin:
+        - pin: 'release a=newton-holdback'
+          priority: 1050
+          package: '*'
diff --git a/tests/pillar/repo_mcp_openstack_ocata.sls b/tests/pillar/repo_mcp_openstack_ocata.sls
new file mode 100644
index 0000000..e601208
--- /dev/null
+++ b/tests/pillar/repo_mcp_openstack_ocata.sls
@@ -0,0 +1,44 @@
+linux:
+  system:
+    enabled: true
+    repo:
+      mirantis_openstack_repo:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }} ocata main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }}/archive-mcpocata.key"
+        pin:
+        - pin: 'release a=ocata'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_hotfix:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }} ocata-hotfix main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }}/archive-mcpocata.key"
+        pin:
+        - pin: 'release a=ocata-hotfix'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_security:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }} ocata-security main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }}/archive-mcpocata.key"
+        pin:
+        - pin: 'release a=ocata-security'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_updates:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }} ocata-updates main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }}/archive-mcpocata.key"
+        pin:
+        - pin: 'release a=ocata-uptades'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_holdback:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }} ocata-holdback main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/ocata/{{ grains.get('oscodename') }}/archive-mcpocata.key"
+        pin:
+        - pin: 'release a=ocata-holdback'
+          priority: 1050
+          package: '*'