Add glusterfs backend support

This patch allows to configure glusterfs backend options
by this formula.

Change-Id: Ib13a677b366cedb838103423d1481a0db44e4be2
diff --git a/.kitchen.yml b/.kitchen.yml
index 05c9827..ab515bc 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -80,5 +80,15 @@
             common:
               version: <%= ENV['OS_VERSION'] || 'pike' %>
 
+  - name: share_glusterfs
+    provisioner:
+      pillars-from-files:
+        manila.sls: tests/pillar/share_glusterfs.sls
+      pillars:
+        release.sls:
+          manila:
+            common:
+              version: <%= ENV['OS_VERSION'] || 'pike' %>
+
 # vim: ft=yaml sw=2 ts=2 sts=2 tw=125
 
diff --git a/.travis.yml b/.travis.yml
index b9d198d..8bb51f4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,9 +20,11 @@
   - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3 OS_VERSION=pike SUITE=server_cluster
   - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3 OS_VERSION=pike SUITE=server_single
   - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3 OS_VERSION=pike SUITE=share_nexenta
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3 OS_VERSION=pike SUITE=share_glusterfs
   - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2017.7 OS_VERSION=pike SUITE=server_cluster
   - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2017.7 OS_VERSION=pike SUITE=server_single
   - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2017.7 OS_VERSION=pike SUITE=share_nexenta
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2017.7 OS_VERSION=pike SUITE=share_glusterfs
 
 before_script:
   - set -o pipefail
diff --git a/README.rst b/README.rst
index 0b47c0b..5fcede9 100644
--- a/README.rst
+++ b/README.rst
@@ -47,7 +47,7 @@
 =====================
 
 
-Nexenta backend
+Nexenta driver
 
 .. code-block:: yaml
 
@@ -64,6 +64,35 @@
             nexenta_user: nonexistent
             nexenta_volume: volume1
 
+Glusterfs driver
+
+.. code-block:: yaml
+
+
+    manila:
+      share:
+        enabled_share_backends:
+          glusterfs:
+            name: glusterfs
+            type: glusterfs
+            enabled: true
+            share_driver: manila.share.drivers.glusterfs_native.GlusterfsNativeShareDriver
+            dhss: false
+            glusterfs_ganesha_server_ip: 1.2.3.4
+            glusterfs_ganesha_server_password: secretpassword
+            glusterfs_ganesha_server_username: nonexistent
+            glusterfs_mount_point_base: state_path/mnt
+            glusterfs_server_password: secretpassword
+            glusterfs_path_to_private_key: /path/to/key
+            glusterfs_nfs_server_type: glusterfs
+            glusterfs_share_layout: share_layout
+            glusterfs_target: remove:target
+            glusterfs_servers:
+              - server1
+              - server2
+            glusterfs_volume_pattern: manila-share-volume-d+$
+
+
 More information
 ================
 
diff --git a/manila/files/pike/_backend_glusterfs.conf b/manila/files/pike/_backend_glusterfs.conf
new file mode 100644
index 0000000..a584d3d
--- /dev/null
+++ b/manila/files/pike/_backend_glusterfs.conf
@@ -0,0 +1,33 @@
+{%- if backend.glusterfs_server_password is defined %}
+glusterfs_server_password = {{ backend.glusterfs_server_password }}
+{%- endif %}
+{%- if backend.glusterfs_path_to_private_key is defined %}
+glusterfs_path_to_private_key = {{ backend.glusterfs_path_to_private_key }}
+{%- endif %}
+{%- if backend.glusterfs_nfs_server_type is defined %}
+glusterfs_nfs_server_type = {{ backend.glusterfs_nfs_server_type }}
+{%- endif %}
+{%- if backend.glusterfs_ganesha_server_ip is defined %}
+glusterfs_ganesha_server_ip = {{ backend.glusterfs_ganesha_server_ip }}
+{%- endif %}
+{%- if backend.glusterfs_ganesha_server_username is defined %}
+glusterfs_ganesha_server_username = {{ backend.glusterfs_ganesha_server_username }}
+{%- endif %}
+{%- if backend.glusterfs_ganesha_server_password is defined %}
+glusterfs_ganesha_server_password = {{ backend.glusterfs_ganesha_server_password }}
+{%- endif %}
+{%- if backend.glusterfs_share_layout is defined %}
+glusterfs_share_layout = {{ backend.glusterfs_share_layout }}
+{%- endif %}
+{%- if backend.glusterfs_target is defined %}
+glusterfs_target = {{ backend.glusterfs_target }}
+{%- endif %}
+{%- if backend.glusterfs_mount_point_base is defined %}
+glusterfs_mount_point_base = {{ backend.glusterfs_mount_point_base }}
+{%- endif %}
+{%- if backend.glusterfs_servers is defined %}
+glusterfs_servers = {{ ','.join(backend.glusterfs_servers) }}
+{%- endif %}
+{%- if backend.glusterfs_volume_pattern is defined %}
+glusterfs_volume_pattern = {{ backend.glusterfs_volume_pattern }}
+{%- endif %}
diff --git a/tests/pillar/share_glusterfs.sls b/tests/pillar/share_glusterfs.sls
new file mode 100644
index 0000000..41a9526
--- /dev/null
+++ b/tests/pillar/share_glusterfs.sls
@@ -0,0 +1,86 @@
+manila:
+  common:
+    identity:
+      engine: keystone
+      host: 127.0.0.1
+      port: 35357
+      tenant: service
+      user: manila
+      password: misterio
+      endpoint_type: internalURL
+    database:
+      engine: mysql
+      host: 127.0.0.1
+      port: 3306
+      name: manila
+      user: manila
+      password: misterio
+    message_queue:
+      engine: rabbitmq
+      host: '127.0.0.1'
+      port: 5672
+      user: openstack
+      password: workshop
+      virtual_host: '/openstack'
+  share:
+    version: pike
+    enabled: true
+    enabled_share_backends:
+      glusterfs:
+        name: glusterfs
+        type: glusterfs
+        enabled: true
+        share_driver: manila.share.drivers.glusterfs_native.GlusterfsNativeShareDriver
+        dhss: false
+        glusterfs_ganesha_server_ip: 1.2.3.4
+        glusterfs_ganesha_server_password: secretpassword
+        glusterfs_ganesha_server_username: nonexistent
+        glusterfs_mount_point_base: state_path/mnt
+        glusterfs_server_password: secretpassword
+        glusterfs_path_to_private_key: /path/to/key
+        glusterfs_nfs_server_type: glusterfs
+        glusterfs_share_layout: share_layout
+        glusterfs_target: remove:target
+        glusterfs_servers:
+          - server1
+          - server2
+        glusterfs_volume_pattern: manila-share-volume-d+$
+apache:
+  server:
+    enabled: true
+    default_mpm: event
+    mpm:
+      prefork:
+        enabled: true
+        servers:
+          start: 5
+          spare:
+            min: 2
+            max: 10
+        max_requests: 0
+        max_clients: 20
+        limit: 20
+    site:
+      manila:
+        enabled: false
+        available: true
+        type: wsgi
+        name: manila
+        host:
+          name: manila.ci.local
+          address: 127.0.0.1
+          port: 8041
+        log:
+          custom:
+            format: >-
+              %v:%p %{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %D %O \"%{Referer}i\" \"%{User-Agent}i\"
+        wsgi:
+          daemon_process: manila-api
+          processes: 2
+          threads: 10
+          user: manila
+          group: manila
+          display_name: '%{GROUP}'
+          script_alias: '/ /usr/bin/manila-api'
+          application_group: '%{GLOBAL}'
+          authorization: 'On'