Merge "Add more upgrade tasks according to phases"
diff --git a/cinder/map.jinja b/cinder/map.jinja
index 79dff75..18050cf 100644
--- a/cinder/map.jinja
+++ b/cinder/map.jinja
@@ -77,7 +77,11 @@
     'BaseDefaults': default_params,
     'Debian': {
         'pkgs': ['cinder-volume', 'lvm2', 'sysfsutils', 'sg3-utils', 'python-cinder','python-mysqldb','p7zip', 'gettext-base', 'python-memcache', 'python-pycadf'],
+        'openiscsi_pkgs': ['open-iscsi', 'tgt'],
+        'iscsitarget_pkgs': ['iscsitarget', 'iscsitarget-dkms'],
         'services': ['cinder-volume'],
+        'iscsitarget_services': ['iscsitarget'],
+        'openiscsi_services': ['open-iscsi', 'tgt', 'iscsid'],
         'wipe_method': 'none',
         'notification': False,
         'audit': {
@@ -106,6 +110,10 @@
     },
     'RedHat': {
         'pkgs': ['openstack-cinder', 'python-cinder', 'lvm2', 'sysfsutils', 'sg3_utils', 'device-mapper-multipath', 'device-mapper-multipath-libs', 'python-pycadf'],
+        'iscsitarget_pkgs': ['iscsitarget', 'iscsitarget-dkms'],
+        'openiscsi_pkgs': ['open-iscsi', 'tgt'],
+        'iscsitarget_services': ['iscsitarget'],
+        'openiscsi_services': ['open-iscsi', 'tgt', 'iscsid'],
         'services': ['openstack-cinder-volume'],
         'wipe_method': 'none',
         'notification': False,
diff --git a/cinder/volume.sls b/cinder/volume.sls
index 080466f..fd94860 100644
--- a/cinder/volume.sls
+++ b/cinder/volume.sls
@@ -191,14 +191,29 @@
 
 {%- endif %}
 
-{%- if backend.engine in ['iscsi' , 'hp_lefthand'] %}
+{%- if backend.engine in ['lvm'] %}
+
+cinder_openiscsi_packages_{{ loop.index }}:
+  pkg.installed:
+  - names: {{ volume.openiscsi_pkgs }}
+  - require:
+    - pkg: cinder_volume_packages
+
+cinder_openiscsi_service:
+  service.running:
+  - names: {{ volume.openiscsi_services }}
+  - enable: true
+  {%- if grains.get('noservices') %}
+  - onlyif: /bin/false
+  {%- endif %}
+  - require:
+    - pkg: cinder_openiscsi_packages_{{ loop.index }}
+
+{%- elif backend.engine in ['iscsi' , 'hp_lefthand'] %}
 
 cinder_iscsi_packages_{{ loop.index }}:
   pkg.installed:
-  - names:
-    - iscsitarget
-    - open-iscsi
-    - iscsitarget-dkms
+  - names: {{ volume.iscsitarget_pkgs + volume.openiscsi_pkgs }}
   - require:
     - pkg: cinder_volume_packages
 
@@ -211,9 +226,7 @@
 
 cinder_scsi_service:
   service.running:
-  - names:
-    - iscsitarget
-    - open-iscsi
+  - names: {{ volume.iscsitarget_services +  volume.openiscsi_services }}
   - enable: true
   {%- if grains.get('noservices') %}
   - onlyif: /bin/false