support for putting vm images in custom locations

Change-Id: I685de4207f1f7f17264cc4ad2d81c3348ca20074
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/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/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