From 1905a6247c4004451312f58656beea70137c5b4b Mon Sep 17 00:00:00 2001
From: rajinir <rajini_ram@dell.com>
Date: Thu, 12 Nov 2015 16:50:39 -0600
Subject: [PATCH] Enable Dell Storage Center iscsi Backends in Cinder

Enables support for configuring Cinder with a Dell
Storage Center iscsi storage backend.
This change adds all relevant parameters for:
 - Dell Storage Center SC Series (iSCSI)

Change-Id: I3b1a4346f494139ab123c7dc1a62f81d03c9e728
---
 environments/cinder-dellsc-config.yaml        | 17 ++++
 puppet/controller.yaml                        |  1 +
 .../pre_deploy/controller/cinder-dellsc.yaml  | 87 +++++++++++++++++++
 puppet/manifests/overcloud_controller.pp      | 23 ++++-
 .../overcloud_controller_pacemaker.pp         | 23 ++++-
 5 files changed, 149 insertions(+), 2 deletions(-)
 create mode 100644 environments/cinder-dellsc-config.yaml
 create mode 100644 puppet/extraconfig/pre_deploy/controller/cinder-dellsc.yaml

diff --git a/environments/cinder-dellsc-config.yaml b/environments/cinder-dellsc-config.yaml
new file mode 100644
index 0000000000..92e257d497
--- /dev/null
+++ b/environments/cinder-dellsc-config.yaml
@@ -0,0 +1,17 @@
+# A Heat environment file which can be used to enable a
+# a Cinder  Dell Storage Center ISCSI backend, configured via puppet
+resource_registry:
+  OS::TripleO::ControllerExtraConfigPre: ../puppet/extraconfig/pre_deploy/controller/cinder-dellsc.yaml
+
+parameter_defaults:
+  CinderEnableDellScBackend: true
+  CinderDellScBackendName: 'tripleo_dellsc'
+  CinderDellScSanIp: ''
+  CinderDellScSanLogin: 'Admin'
+  CinderDellScSanPassword: ''
+  CinderDellScSsn: '64702'
+  CinderDellScIscsiIpAddress: ''
+  CinderDellScIscsiPort: '3260'
+  CinderDellScApiPort: '3033'
+  CinderDellScServerFolder: 'dellsc_server'
+  CinderDellScVolumeFolder: 'dellsc_volume'
diff --git a/puppet/controller.yaml b/puppet/controller.yaml
index a825f58259..9ab28c1d47 100644
--- a/puppet/controller.yaml
+++ b/puppet/controller.yaml
@@ -1141,6 +1141,7 @@ resources:
             - vip_data # provided by vip-config
             - '"%{::osfamily}"'
             - common
+            - cinder_dellsc_data # Optionally provided by ControllerExtraConfigPre
             - cinder_netapp_data # Optionally provided by ControllerExtraConfigPre
             - cinder_eqlx_data # Optionally provided by ControllerExtraConfigPre
             - neutron_bigswitch_data # Optionally provided by ControllerExtraConfigPre
diff --git a/puppet/extraconfig/pre_deploy/controller/cinder-dellsc.yaml b/puppet/extraconfig/pre_deploy/controller/cinder-dellsc.yaml
new file mode 100644
index 0000000000..905f196daf
--- /dev/null
+++ b/puppet/extraconfig/pre_deploy/controller/cinder-dellsc.yaml
@@ -0,0 +1,87 @@
+heat_template_version: 2015-11-12
+
+description: Configure hieradata for Cinder Dell Storage Center configuration
+
+parameters:
+  server:
+    description: ID of the controller node to apply this config to
+    type: string
+
+  # Config specific parameters, to be provided via parameter_defaults
+  CinderEnableDellScBackend:
+    type: boolean
+    default: true
+  CinderDellScBackendName:
+    type: string
+    default: 'tripleo_dellsc'
+  CinderDellScSanIp:
+    type: string
+  CinderDellScSanLogin:
+    type: string
+    default: 'Admin'
+  CinderDellScSanPassword:
+    type: string
+    hidden: true
+  CinderDellScSsn:
+    type: string
+    default: '64702'
+  CinderDellScIscsiIpAddress:
+    type: string
+    default: ''
+  CinderDellScIscsiPort:
+    type: string
+    default: '3260'
+  CinderDellScApiPort:
+    type: string
+    default: '3033'
+  CinderDellScServerFolder:
+    type: string
+    default: 'dellsc_server'
+  CinderDellScVolumeFolder:
+    type: string
+    default: 'dellsc_volume'
+
+resources:
+  CinderDellScConfig:
+    type: OS::Heat::StructuredConfig
+    properties:
+      group: os-apply-config
+      config:
+        hiera:
+          datafiles:
+            cinder_dellsc_data:
+              mapped_data:
+                cinder_enable_dellsc_backend: {get_input: EnableDellScBackend}
+                cinder::backend::dellsc_iscsi::volume_backend_name: {get_input: DellScBackendName}
+                cinder::backend::dellsc_iscsi::san_ip: {get_input: DellScSanIp}
+                cinder::backend::dellsc_iscsi::san_login: {get_input: DellScSanLogin}
+                cinder::backend::dellsc_iscsi::san_password: {get_input: DellScSanPassword}
+                cinder::backend::dellsc_iscsi::dell_sc_ssn: {get_input: DellScSsn}
+                cinder::backend::dellsc_iscsi::iscsi_ip_address: {get_input: DellScIscsiIpAddress}
+                cinder::backend::dellsc_iscsi::iscsi_port: {get_input: DellScIscsiPort}
+                cinder::backend::dellsc_iscsi::dell_sc_api_port: {get_input: DellScApiPort}
+                cinder::backend::dellsc_iscsi::dell_sc_server_folder: {get_input: DellScServerFolder}
+                cinder::backend::dellsc_iscsi::dell_sc_volume_folder: {get_input: DellScVolumeFolder}
+
+  CinderDellScDeployment:
+    type: OS::Heat::StructuredDeployment
+    properties:
+      config: {get_resource: CinderDellScConfig}
+      server: {get_param: server}
+      input_values:
+        EnableDellScBackend: {get_param: CinderEnableDellScBackend}
+        DellScBackendName: {get_param: CinderDellScBackendName}
+        DellScSanIp: {get_param: CinderDellScSanIp}
+        DellScSanLogin: {get_param: CinderDellScSanLogin}
+        DellScSanPassword: {get_param: CinderDellScSanPassword}
+        DellScSsn: {get_param: CinderDellScSsn}
+        DellScIscsiIpAddress: {get_param: CinderDellScIscsiIpAddress}
+        DellScIscsiPort: {get_param: CinderDellScIscsiPort}
+        DellScApiPort: {get_param: CinderDellScApiPort}
+        DellScServerFolder: {get_param: CinderDellScServerFolder}
+        DellScVolumeFolder: {get_param: CinderDellScVolumeFolder}
+
+outputs:
+  deploy_stdout:
+    description: Deployment reference, used to trigger puppet apply on changes
+    value: {get_attr: [CinderDellScDeployment, deploy_stdout]}
diff --git a/puppet/manifests/overcloud_controller.pp b/puppet/manifests/overcloud_controller.pp
index 913bcb6345..35d1c39bda 100644
--- a/puppet/manifests/overcloud_controller.pp
+++ b/puppet/manifests/overcloud_controller.pp
@@ -420,6 +420,27 @@ if hiera('step') >= 3 {
     }
   }
 
+  if hiera('cinder_enable_dellsc_backend', false) {
+    $cinder_dellsc_backend = hiera('cinder::backend::dellsc_iscsi::volume_backend_name')
+
+    cinder_config {
+      "${cinder_dellsc_backend}/host": value => 'hostgroup';
+    }
+
+    cinder::backend::dellsc_iscsi{ $cinder_dellsc_backend :
+      volume_backend_name   => hiera('cinder::backend::dellsc_iscsi::volume_backend_name', undef),
+      san_ip                => hiera('cinder::backend::dellsc_iscsi::san_ip', undef),
+      san_login             => hiera('cinder::backend::dellsc_iscsi::san_login', undef),
+      san_password          => hiera('cinder::backend::dellsc_iscsi::san_password', undef),
+      dell_sc_ssn           => hiera('cinder::backend::dellsc_iscsi::dell_sc_ssn', undef),
+      iscsi_ip_address      => hiera('cinder::backend::dellsc_iscsi::iscsi_ip_address', undef),
+      iscsi_port            => hiera('cinder::backend::dellsc_iscsi::iscsi_port', undef),
+      dell_sc_port          => hiera('cinder::backend::dellsc_iscsi::dell_sc_port', undef),
+      dell_sc_server_folder => hiera('cinder::backend::dellsc_iscsi::dell_sc_server_folder', undef),
+      dell_sc_volume_folder => hiera('cinder::backend::dellsc_iscsi::dell_sc_volume_folder', undef),
+    }
+  }
+
   if hiera('cinder_enable_netapp_backend', false) {
     $cinder_netapp_backend = hiera('cinder::backend::netapp::title')
 
@@ -473,7 +494,7 @@ if hiera('step') >= 3 {
     }
   }
 
-  $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend, $cinder_eqlx_backend, $cinder_netapp_backend, $cinder_nfs_backend])
+  $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend, $cinder_eqlx_backend, $cinder_dellsc_backend, $cinder_netapp_backend, $cinder_nfs_backend])
   class { '::cinder::backends' :
     enabled_backends => $cinder_enabled_backends,
   }
diff --git a/puppet/manifests/overcloud_controller_pacemaker.pp b/puppet/manifests/overcloud_controller_pacemaker.pp
index e6ee85ae1c..df89625fad 100644
--- a/puppet/manifests/overcloud_controller_pacemaker.pp
+++ b/puppet/manifests/overcloud_controller_pacemaker.pp
@@ -794,6 +794,27 @@ if hiera('step') >= 3 {
     }
   }
 
+  if hiera('cinder_enable_dellsc_backend', false) {
+    $cinder_dellsc_backend = hiera('cinder::backend::dellsc_iscsi::volume_backend_name')
+
+    cinder_config {
+      "${cinder_dellsc_backend}/host": value => 'hostgroup';
+    }
+
+    cinder::backend::dellsc_iscsi{ $cinder_dellsc_backend :
+      volume_backend_name   => hiera('cinder::backend::dellsc_iscsi::volume_backend_name', undef),
+      san_ip                => hiera('cinder::backend::dellsc_iscsi::san_ip', undef),
+      san_login             => hiera('cinder::backend::dellsc_iscsi::san_login', undef),
+      san_password          => hiera('cinder::backend::dellsc_iscsi::san_password', undef),
+      dell_sc_ssn           => hiera('cinder::backend::dellsc_iscsi::dell_sc_ssn', undef),
+      iscsi_ip_address      => hiera('cinder::backend::dellsc_iscsi::iscsi_ip_address', undef),
+      iscsi_port            => hiera('cinder::backend::dellsc_iscsi::iscsi_port', undef),
+      dell_sc_port          => hiera('cinder::backend::dellsc_iscsi::dell_sc_port', undef),
+      dell_sc_server_folder => hiera('cinder::backend::dellsc_iscsi::dell_sc_server_folder', undef),
+      dell_sc_volume_folder => hiera('cinder::backend::dellsc_iscsi::dell_sc_volume_folder', undef),
+    }
+  }
+
   if hiera('cinder_enable_netapp_backend', false) {
     $cinder_netapp_backend = hiera('cinder::backend::netapp::title')
 
@@ -847,7 +868,7 @@ if hiera('step') >= 3 {
     }
   }
 
-  $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend, $cinder_netapp_backend, $cinder_nfs_backend,$cinder_eqlx_backend])
+  $cinder_enabled_backends = delete_undef_values([$cinder_iscsi_backend, $cinder_rbd_backend, $cinder_eqlx_backend, $cinder_dellsc_backend, $cinder_netapp_backend, $cinder_nfs_backend])
   class { '::cinder::backends' :
     enabled_backends => $cinder_enabled_backends,
   }