Browse Source

glusterfs: bind created volume to the claim

Vadim Rutkovsky 6 years ago
parent
commit
2105aa6e49
1 changed files with 6 additions and 1 deletions
  1. 6 1
      roles/lib_utils/action_plugins/generate_pv_pvcs_list.py

+ 6 - 1
roles/lib_utils/action_plugins/generate_pv_pvcs_list.py

@@ -84,7 +84,7 @@ class ActionModule(ActionBase):
         endpoints = self.get_templated(str(varname) + '_glusterfs_endpoints')
         path = self.get_templated(str(varname) + '_glusterfs_path')
         read_only = self.get_templated(str(varname) + '_glusterfs_readOnly')
-        return dict(
+        result = dict(
             name="{0}-volume".format(volume),
             capacity=size,
             labels=labels,
@@ -94,6 +94,11 @@ class ActionModule(ActionBase):
                     endpoints=endpoints,
                     path=path,
                     readOnly=read_only)))
+        # Add claimref for glusterfs as default storageclass can be different
+        create_pvc = self.task_vars.get(str(varname) + '_create_pvc')
+        if create_pvc and self._templar.template(create_pvc):
+            result['storage']['claimName'] = "{0}-claim".format(volume)
+        return result
 
     def build_pv_hostpath(self, varname=None):
         """Build pv dictionary for hostpath storage type"""