Merge "Add suport for availability zones"
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..8b89e35
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,107 @@
+---
+driver:
+  name: docker
+  hostname: neutron.ci.local
+  use_sudo: false
+
+provisioner:
+  name: salt_solo
+  salt_install: bootstrap
+  salt_bootstrap_url: https://bootstrap.saltstack.com
+  salt_version: latest
+  require_chef: false
+  log_level: error
+  formula: neutron
+  grains:
+    noservices: True
+  vendor_repo:
+    - type: apt
+      url: http://apt-mk.mirantis.com/trusty
+      key_url: http://apt-mk.mirantis.com/public.gpg
+      components: oc303 extra
+      distribution: nightly
+  dependencies:
+    - name: linux
+      repo: git
+      source: https://github.com/salt-formulas/salt-formula-linux
+  state_top:
+    base:
+      "*":
+        - linux.system
+        - neutron
+  pillars:
+    top.sls:
+      base:
+        "*":
+          - linux_repo_openstack
+          - neutron
+  pillars-from-files:
+    linux_repo_openstack.sls: tests/pillar/repo_mos9.sls
+
+verifier:
+  name: inspec
+  sudo: true
+
+platforms:
+  - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+    driver_config:
+      image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+      platform: ubuntu
+
+suites:
+
+  - name: compute_dpdk
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/compute_dpdk.sls
+
+  - name: compute_dvr
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/compute_dvr.sls
+
+  - name: compute_legacy
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/compute_legacy.sls
+
+  - name: compute_nonexternal_dvr
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/compute_nonexternal_dvr.sls
+
+  - name: compute_sriov
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/compute_sriov.sls
+
+  - name: control_cluster
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/control_cluster.sls
+
+  - name: control_dvr
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/control_dvr.sls
+
+  - name: control_nodvr
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/control_nodvr.sls
+
+  - name: control_single
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/control_single.sls
+
+  - name: gateway_dvr
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/gateway_dvr.sls
+
+  - name: gateway_legacy
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/gateway_legacy.sls
+# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7a77247
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,39 @@
+sudo: required
+services:
+  - docker
+
+install:
+  - pip install PyYAML
+  - pip install virtualenv
+  - |
+    test -e Gemfile || cat <<EOF > Gemfile
+    source 'https://rubygems.org'
+    gem 'rake'
+    gem 'test-kitchen'
+    gem 'kitchen-docker'
+    gem 'kitchen-inspec'
+    gem 'inspec'
+    gem 'kitchen-salt', :git => 'https://github.com/salt-formulas/kitchen-salt.git'
+  - bundle install
+
+env:
+    - PLATFORM=trevorj/salty-whales:trusty
+    - PLATFORM=trevorj/salty-whales:xenial
+
+before_script:
+  - set -o pipefail
+  - make test | tail
+
+script:
+  - test ! -e .kitchen.yml || bundle exec kitchen test -t tests/integration
+
+notifications:
+  webhooks:
+    urls:
+      - https://webhooks.gitter.im/e/6123573504759330786b
+    on_success: change  # options: [always|never|change] default: always
+    on_failure: never  # options: [always|never|change] default: always
+    on_start: never     # options: [always|never|change] default: always
+    on_cancel: never    # options: [always|never|change] default: always
+    on_error: never    # options: [always|never|change] default: always
+  email: false
diff --git a/neutron/compute.sls b/neutron/compute.sls
index e67eac5..bd6e3e0 100644
--- a/neutron/compute.sls
+++ b/neutron/compute.sls
@@ -38,6 +38,7 @@
     - file: /etc/neutron/neutron.conf
     - file: /etc/neutron/plugins/ml2/openvswitch_agent.ini
     - file: /etc/neutron/plugins/ml2/sriov_agent.ini
+  - unless: grains.get('noservices', False)
 
 {% endif %}
 
@@ -84,4 +85,4 @@
     - file: /etc/neutron/neutron.conf
     - file: /etc/neutron/plugins/ml2/openvswitch_agent.ini
 
-{%- endif %}
\ No newline at end of file
+{%- endif %}
diff --git a/neutron/server.sls b/neutron/server.sls
index 23b439b..2f530e2 100644
--- a/neutron/server.sls
+++ b/neutron/server.sls
@@ -27,12 +27,14 @@
   pkg.installed:
   - name: neutron-plugin-contrail
 
+{%- if not grains.get('noservices', False) %}
 neutron_server_service:
   service.running:
   - name: neutron-server
   - enable: true
   - watch:
     - file: /etc/neutron/neutron.conf
+{%- endif %}
 
 {%- endif %}
 
@@ -53,12 +55,14 @@
   - require:
     - file: /etc/neutron/plugins/ml2/ml2_conf.ini
 
+{%- if not grains.get('noservices', False) %}
 neutron_db_manage:
   cmd.run:
   - name: neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head
   - require:
     - file: /etc/neutron/neutron.conf
     - file: /etc/neutron/plugins/ml2/ml2_conf.ini
+{%- endif %}
 
 {%- endif %}
 
@@ -104,12 +108,14 @@
     - dir_mode: 755
     - template: jinja
 
+{%- if not grains.get('noservices', False) %}
 neutron_db_manage:
   cmd.run:
   - name: neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/midonet/midonet.ini upgrade head
   - require:
     - file: /etc/neutron/neutron.conf
     - file: /etc/neutron/plugins/midonet/midonet.ini
+{%- endif %}
 
 {%- if server.version == "kilo" %}
 
@@ -132,12 +138,14 @@
     - python-neutron-lbaas
     - python-neutron-fwaas
 
+{%- if not grains.get('noservices', False) %}
 neutron_db_manage:
   cmd.run:
   - name: neutron-db-manage --subproject networking-midonet upgrade head
   - require:
     - file: /etc/neutron/neutron.conf
     - file: /etc/neutron/plugins/midonet/midonet.ini
+{%- endif %}
 
 {%- endif %}
 {%- endif %}
diff --git a/tests/pillar/compute_dpdk.sls b/tests/pillar/compute_dpdk.sls
index 0a3a498..c56fb81 100644
--- a/tests/pillar/compute_dpdk.sls
+++ b/tests/pillar/compute_dpdk.sls
@@ -14,12 +14,12 @@
     local_ip: 10.1.0.105
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
       virtual_host: /openstack
     metadata:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: password
     version: mitaka
diff --git a/tests/pillar/compute_dvr.sls b/tests/pillar/compute_dvr.sls
index 9f0160e..8d5f7d5 100644
--- a/tests/pillar/compute_dvr.sls
+++ b/tests/pillar/compute_dvr.sls
@@ -13,12 +13,12 @@
     local_ip: 10.1.0.105
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
       virtual_host: /openstack
     metadata:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: password
     version: mitaka
\ No newline at end of file
diff --git a/tests/pillar/compute_legacy.sls b/tests/pillar/compute_legacy.sls
index ee9d7c8..154af25 100644
--- a/tests/pillar/compute_legacy.sls
+++ b/tests/pillar/compute_legacy.sls
@@ -13,12 +13,12 @@
     local_ip: 10.1.0.105
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
       virtual_host: /openstack
     metadata:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: password
     version: mitaka
diff --git a/tests/pillar/compute_nonexternal_dvr.sls b/tests/pillar/compute_nonexternal_dvr.sls
index 42fee7e..8ce0da1 100644
--- a/tests/pillar/compute_nonexternal_dvr.sls
+++ b/tests/pillar/compute_nonexternal_dvr.sls
@@ -13,12 +13,12 @@
     local_ip: 10.1.0.105
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
       virtual_host: /openstack
     metadata:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: password
     version: mitaka
diff --git a/tests/pillar/compute_sriov.sls b/tests/pillar/compute_sriov.sls
index 9504878..f5a106f 100644
--- a/tests/pillar/compute_sriov.sls
+++ b/tests/pillar/compute_sriov.sls
@@ -17,12 +17,12 @@
     local_ip: 10.1.0.105
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
       virtual_host: /openstack
     metadata:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: password
     version: mitaka
diff --git a/tests/pillar/control_dvr.sls b/tests/pillar/control_dvr.sls
index 7684188..014de67 100644
--- a/tests/pillar/control_dvr.sls
+++ b/tests/pillar/control_dvr.sls
@@ -11,14 +11,14 @@
       address: 172.16.10.101
       port: 9696
     compute:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       region: RegionOne
       tenant: service
       user: nova
     database:
       engine: mysql
-      host: 172.16.10.254
+      host: 127.0.0.1
       name: neutron
       password: workshop
       port: 3306
@@ -29,7 +29,7 @@
     global_physnet_mtu: 1500
     identity:
       engine: keystone
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 35357
       region: RegionOne
@@ -39,7 +39,7 @@
     l3_ha: false
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
diff --git a/tests/pillar/control_nodvr.sls b/tests/pillar/control_nodvr.sls
index 154c47e..8840b5e 100644
--- a/tests/pillar/control_nodvr.sls
+++ b/tests/pillar/control_nodvr.sls
@@ -11,14 +11,14 @@
       address: 172.16.10.101
       port: 9696
     compute:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       region: RegionOne
       tenant: service
       user: nova
     database:
       engine: mysql
-      host: 172.16.10.254
+      host: 127.0.0.1
       name: neutron
       password: workshop
       port: 3306
@@ -29,7 +29,7 @@
     global_physnet_mtu: 1500
     identity:
       engine: keystone
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 35357
       region: RegionOne
@@ -39,7 +39,7 @@
     l3_ha: True
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
diff --git a/tests/pillar/gateway_dvr.sls b/tests/pillar/gateway_dvr.sls
index 7591008..2c47529 100644
--- a/tests/pillar/gateway_dvr.sls
+++ b/tests/pillar/gateway_dvr.sls
@@ -13,12 +13,12 @@
     local_ip: 10.1.0.110
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
       virtual_host: /openstack
     metadata:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: password
     version: mitaka
\ No newline at end of file
diff --git a/tests/pillar/gateway_legacy.sls b/tests/pillar/gateway_legacy.sls
index 661eebd..d9b7ef8 100644
--- a/tests/pillar/gateway_legacy.sls
+++ b/tests/pillar/gateway_legacy.sls
@@ -13,12 +13,12 @@
     local_ip: 10.1.0.110
     message_queue:
       engine: rabbitmq
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: workshop
       port: 5672
       user: openstack
       virtual_host: /openstack
     metadata:
-      host: 172.16.10.254
+      host: 127.0.0.1
       password: password
     version: mitaka
diff --git a/tests/pillar/repo_mos9.sls b/tests/pillar/repo_mos9.sls
new file mode 100644
index 0000000..cd14fe8
--- /dev/null
+++ b/tests/pillar/repo_mos9.sls
@@ -0,0 +1,8 @@
+linux:
+  system:
+    enabled: true
+    repo:
+      mirantis_openstack:
+        source: "deb http://mirror.fuel-infra.org/mos-repos/ubuntu/9.0/ mos9.0 main restricted"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mos-repos/ubuntu/9.0/archive-mos9.0.key"
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 8c07e58..a4cac88 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -44,6 +44,7 @@
     [ ! -d ${SALT_PILLAR_DIR} ] && mkdir -p ${SALT_PILLAR_DIR}
     echo "base:" > ${SALT_PILLAR_DIR}/top.sls
     for pillar in ${PILLARDIR}/*; do
+        grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
         state_name=$(basename ${pillar%.sls})
         echo -e "  ${state_name}:\n    - ${state_name}" >> ${SALT_PILLAR_DIR}/top.sls
     done
@@ -56,6 +57,7 @@
 
     echo "base:" > ${SALT_FILE_DIR}/top.sls
     for pillar in ${PILLARDIR}/*.sls; do
+        grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
         state_name=$(basename ${pillar%.sls})
         echo -e "  ${state_name}:\n    - ${FORMULA_NAME}" >> ${SALT_FILE_DIR}/top.sls
     done
@@ -126,6 +128,7 @@
 
 run() {
     for pillar in ${PILLARDIR}/*.sls; do
+        grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
         state_name=$(basename ${pillar%.sls})
         salt_run --id=${state_name} state.show_sls ${FORMULA_NAME} || (log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1)
     done