Merge "Remove salt-master, reclass from pkg dependencis"
diff --git a/.kitchen.yml b/.kitchen.yml
index 8518d18..379123c 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -149,6 +149,7 @@
         control_cloud_digitalocean.sls: tests/pillar/control_cloud_digitalocean.sls
         control_cloud_openstack.sls: tests/pillar/control_cloud_openstack.sls
         control_virt.sls: tests/pillar/control_virt.sls
+        control_virt_custom.sls: tests/pillar/control_virt_custom.sls
 
   - name: minion_multi_master_failover
     provisioner:
diff --git a/README.rst b/README.rst
index 1e42a95..454f465 100644
--- a/README.rst
+++ b/README.rst
@@ -574,6 +574,11 @@
 .. literalinclude:: tests/pillar/control_virt.sls
    :language: yaml
 
+salt virt with custom destination for image file
+
+.. literalinclude:: tests/pillar/control_virt_custom.sls
+   :language: yaml
+
 
 Usage
 =====
diff --git a/_modules/modelschema.py b/_modules/modelschema.py
index cb45153..5e319ae 100644
--- a/_modules/modelschema.py
+++ b/_modules/modelschema.py
@@ -132,7 +132,7 @@
         data = 'Schema is valid'
     except SchemaError as exc:
         LOG.error("SchemaError:{}".format(exc))
-        data = repr(exc)
+        raise Exception("SchemaError")
     return {'{}-{}'.format(service, role): data}
 
 
@@ -154,10 +154,15 @@
         data = 'Model is valid'
     except SchemaError as exc:
         LOG.error("SchemaError:{}".format(exc))
-        data = repr(exc)
+        raise Exception("SchemaError")
     except ValidationError as exc:
         LOG.error("ValidationError:{}\nInstance:{}\n"
-                  "SchemaPath:{}".format(exc.message, exc.instance,
+                  "Schema title:{}\n"
+                  "SchemaPath:{}".format(exc.message,
+                                         exc.instance,
+                                         exc.schema.get(
+                                             "title",
+                                             "Schema title not set!"),
                                          exc.schema_path))
         raise Exception("ValidationError")
     return {'{}-{}'.format(service, role): data}
@@ -176,10 +181,15 @@
         data = 'Model is valid'
     except SchemaError as exc:
         LOG.error("SchemaError:{}".format(exc))
-        data = str(exc)
+        raise Exception("SchemaError")
     except ValidationError as exc:
         LOG.error("ValidationError:{}\nInstance:{}\n"
-                  "SchemaPath:{}".format(exc.message, exc.instance,
+                  "Schema title:{}\n"
+                  "SchemaPath:{}".format(exc.message,
+                                         exc.instance,
+                                         exc.schema.get(
+                                             "title",
+                                             "Schema title not set!"),
                                          exc.schema_path))
         raise Exception("ValidationError")
     return data
@@ -214,9 +224,10 @@
             except Exception as exc:
                 LOG.error('{}: {}'.format(pillar, repr(exc)))
     if service not in raw_data.keys():
-        raise Exception(
-            "Could not find applicable  data "
-            "for:{}\n at:{}".format(service, _get_base_dir()))
+        LOG.error("Could not find applicable  data "
+                  "for:{}\n at:{}".format(service, _get_base_dir()))
+        raise Exception("DataError")
+
     data = raw_data[service]
     output = {}
     for role_name, role in data.items():
diff --git a/_modules/virtng.py b/_modules/virtng.py
index a79e5dd..6f180b0 100644
--- a/_modules/virtng.py
+++ b/_modules/virtng.py
@@ -354,7 +354,10 @@
     elif hypervisor in ['kvm', 'qemu']:
         ret['disktype'] = 'qcow2'
         ret['filename'] = '{0}{1}'.format(name, '.qcow2')
-        ret['pool'] = __salt__['config.option']('virt.images')
+        if 'img_dest' in kwargs:
+            ret['pool'] = kwargs['img_dest']
+        else:
+            ret['pool'] = __salt__['config.option']('virt.images')
     return ret
 
 
@@ -408,10 +411,11 @@
                    'pool': '[{0}] '.format(kwargs.get('pool', '0'))
                   }
     elif hypervisor in ['qemu', 'kvm']:
-        overlay = {'format': 'qcow2',
-                   'model': 'virtio',
-                   'pool': __salt__['config.option']('virt.images')
-                  }
+        if 'img_dest' in kwargs:
+            pool = kwargs['img_dest']
+        else:
+            pool = __salt__['config.option']('virt.images')
+        overlay = {'format': 'qcow2', 'model': 'virtio', 'pool': pool}
     else:
         overlay = {}
 
@@ -589,7 +593,8 @@
                     xml = _gen_vol_xml(name,
                                        disk_name,
                                        args['size'],
-                                       hypervisor)
+                                       hypervisor,
+                                       **kwargs)
                     define_vol_xml_str(xml)
 
             elif hypervisor in ['qemu', 'kvm']:
@@ -599,7 +604,10 @@
                 # disk size TCP cloud
                 disk_size = args['size']
 
-                img_dir = __salt__['config.option']('virt.images')
+                if 'img_dest' in kwargs:
+                    img_dir = kwargs['img_dest']
+                else:
+                    img_dir = __salt__['config.option']('virt.images')
                 img_dest = os.path.join(
                     img_dir,
                     name,
diff --git a/metadata/service/master/syndic.yml b/metadata/service/master/syndic.yml
new file mode 100644
index 0000000..470cbe0
--- /dev/null
+++ b/metadata/service/master/syndic.yml
@@ -0,0 +1,4 @@
+parameters:
+  salt:
+    master:
+      order_masters: true
diff --git a/metadata/service/syndic/cluster.yml b/metadata/service/syndic/cluster.yml
new file mode 100644
index 0000000..278b7ce
--- /dev/null
+++ b/metadata/service/syndic/cluster.yml
@@ -0,0 +1,7 @@
+parameters:
+  salt:
+    syndic:
+      enabled: true
+      masters:
+      - host: ${_param:salt_syndic_master_address_01}
+      - host: ${_param:salt_syndic_master_address_02}
diff --git a/metadata/service/syndic/single.yml b/metadata/service/syndic/single.yml
new file mode 100644
index 0000000..088cbdf
--- /dev/null
+++ b/metadata/service/syndic/single.yml
@@ -0,0 +1,6 @@
+parameters:
+  salt:
+    syndic:
+      enabled: true
+      master:
+        host: ${_param:salt_syndic_master_address}
diff --git a/salt/control/virt.sls b/salt/control/virt.sls
index b30f7af..84d9c12 100644
--- a/salt/control/virt.sls
+++ b/salt/control/virt.sls
@@ -30,6 +30,7 @@
 
 {%- set size = control.size.get(node.size) %}
 
+
 salt_control_virt_{{ cluster_name }}_{{ node_name }}:
   module.run:
   - name: virtng.init
@@ -44,6 +45,9 @@
       seed: True
       serial_type: pty
       console: True
+      {%- if node.img_dest is defined %}
+      img_dest: {{ node.img_dest }}
+      {%- endif %}
   - unless: virsh list --all --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
 
 #salt_control_seed_{{ cluster_name }}_{{ node_name }}:
@@ -61,9 +65,9 @@
   - vm_: {{ node_name }}.{{ cluster.domain }}
   - state: true
   - unless: virsh list --autostart --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
-  
+
 {%- endif %}
-  
+
 {%- endif %}
 
 {%- endfor %}
diff --git a/tests/pillar/control_virt_custom.sls b/tests/pillar/control_virt_custom.sls
new file mode 100644
index 0000000..7397494
--- /dev/null
+++ b/tests/pillar/control_virt_custom.sls
@@ -0,0 +1,55 @@
+virt:
+  disk:
+    three_disks:
+      - system:
+          size: 4096
+          image: ubuntu.qcow
+      - repository_snapshot:
+          size: 8192
+          image: snapshot.qcow
+      - cinder-volume:
+          size: 2048
+salt:
+  minion:
+    enabled: true
+    master:
+      host: config01.dc01.domain.com
+  control:
+    enabled: true
+    virt_enabled: true
+    size:
+      small:
+        cpu: 1
+        ram: 1
+      medium:
+        cpu: 2
+        ram: 4
+      large:
+        cpu: 4
+        ram: 8
+      medium_three_disks:
+        cpu: 2
+        ram: 4
+        disk_profile: three_disks
+    cluster:
+      vpc20_infra:
+        domain: neco.virt.domain.com
+        engine: virt
+        config:
+          engine: salt
+          host: master.domain.com
+        node:
+          ubuntu1:
+            provider: node01.domain.com
+            image: ubuntu.qcow
+            size: medium
+            img_dest: /var/lib/libvirt/ssdimages
+          ubuntu2:
+            provider: node02.domain.com
+            image: bubuntu.qcomw
+            size: small
+            img_dest: /var/lib/libvirt/hddimages
+          ubuntu3:
+            provider: node03.domain.com
+            image: meowbuntu.qcom2
+            size: medium_three_disks