diff options
Diffstat (limited to 'roles')
-rw-r--r-- | roles/lib_openshift/library/oc_storageclass.py | 28 | ||||
-rw-r--r-- | roles/lib_openshift/src/class/oc_storageclass.py | 17 | ||||
-rw-r--r-- | roles/lib_openshift/src/doc/storageclass | 2 | ||||
-rw-r--r-- | roles/lib_openshift/src/lib/storageclass.py | 9 |
4 files changed, 38 insertions, 18 deletions
diff --git a/roles/lib_openshift/library/oc_storageclass.py b/roles/lib_openshift/library/oc_storageclass.py index fa5a1ab15..5ca2e23a7 100644 --- a/roles/lib_openshift/library/oc_storageclass.py +++ b/roles/lib_openshift/library/oc_storageclass.py @@ -130,7 +130,7 @@ EXAMPLES = ''' encrypted: 'true' kmsKeyId: '<full kms key arn>' provisioner: aws-ebs - default_sc: False + default_storage_class: False register: sc_out notify: - restart openshift master services @@ -1430,7 +1430,7 @@ class StorageClassConfig(object): provisioner=None, parameters=None, annotations=None, - default_sc="false", + default_storage_class="false", api_version='v1', kubeconfig='/etc/origin/master/admin.kubeconfig'): ''' constructor for handling storageclass options ''' @@ -1439,7 +1439,7 @@ class StorageClassConfig(object): self.annotations = annotations self.provisioner = provisioner self.api_version = api_version - self.default_sc = default_sc + self.default_storage_class = str(default_storage_class).lower() self.kubeconfig = kubeconfig self.data = {} @@ -1453,7 +1453,10 @@ class StorageClassConfig(object): self.data['metadata']['name'] = self.name self.data['metadata']['annotations'] = {} - self.data['metadata']['annotations']['storageclass.beta.kubernetes.io/is-default-class'] = self.default_sc + if self.annotations is not None: + self.data['metadata']['annotations'] = self.annotations + + self.data['metadata']['annotations']['storageclass.beta.kubernetes.io/is-default-class'] = self.default_storage_class if self.provisioner is None: self.data['provisioner'] = 'kubernetes.io/aws-ebs' @@ -1497,7 +1500,7 @@ class StorageClass(Yedit): # pylint: disable=too-many-instance-attributes class OCStorageClass(OpenShiftCLI): ''' Class to wrap the oc command line tools ''' - kind = 'sc' + kind = 'storageclass' # pylint allows 5 # pylint: disable=too-many-arguments @@ -1539,15 +1542,22 @@ class OCStorageClass(OpenShiftCLI): '''update the object''' # parameters are currently unable to be updated. need to delete and recreate self.delete() + # pause here and attempt to wait for delete. + # Better option would be to poll + time.sleep(5) return self.create() def needs_update(self): ''' verify an update is needed ''' # check if params have updated - if self.storage_class.get_parameters() == self.config.parameters: - return False + if self.storage_class.get_parameters() != self.config.parameters: + return True - return True + for anno_key, anno_value in self.storage_class.get_annotations().items(): + if 'is-default-class' in anno_key and anno_value != self.config.default_storage_class: + return True + + return False @staticmethod # pylint: disable=too-many-return-statements,too-many-branches @@ -1560,7 +1570,7 @@ class OCStorageClass(OpenShiftCLI): parameters=params['parameters'], annotations=params['annotations'], api_version="storage.k8s.io/{}".format(params['api_version']), - default_sc=params['default_storage_class'], + default_storage_class=params.get('default_storage_class', 'false'), kubeconfig=params['kubeconfig'], ) diff --git a/roles/lib_openshift/src/class/oc_storageclass.py b/roles/lib_openshift/src/class/oc_storageclass.py index 6c62c7bd8..ece684c56 100644 --- a/roles/lib_openshift/src/class/oc_storageclass.py +++ b/roles/lib_openshift/src/class/oc_storageclass.py @@ -4,7 +4,7 @@ # pylint: disable=too-many-instance-attributes class OCStorageClass(OpenShiftCLI): ''' Class to wrap the oc command line tools ''' - kind = 'sc' + kind = 'storageclass' # pylint allows 5 # pylint: disable=too-many-arguments @@ -46,15 +46,22 @@ class OCStorageClass(OpenShiftCLI): '''update the object''' # parameters are currently unable to be updated. need to delete and recreate self.delete() + # pause here and attempt to wait for delete. + # Better option would be to poll + time.sleep(5) return self.create() def needs_update(self): ''' verify an update is needed ''' # check if params have updated - if self.storage_class.get_parameters() == self.config.parameters: - return False + if self.storage_class.get_parameters() != self.config.parameters: + return True + + for anno_key, anno_value in self.storage_class.get_annotations().items(): + if 'is-default-class' in anno_key and anno_value != self.config.default_storage_class: + return True - return True + return False @staticmethod # pylint: disable=too-many-return-statements,too-many-branches @@ -67,7 +74,7 @@ class OCStorageClass(OpenShiftCLI): parameters=params['parameters'], annotations=params['annotations'], api_version="storage.k8s.io/{}".format(params['api_version']), - default_sc=params['default_storage_class'], + default_storage_class=params.get('default_storage_class', 'false'), kubeconfig=params['kubeconfig'], ) diff --git a/roles/lib_openshift/src/doc/storageclass b/roles/lib_openshift/src/doc/storageclass index 278c0b5b3..5a7320d55 100644 --- a/roles/lib_openshift/src/doc/storageclass +++ b/roles/lib_openshift/src/doc/storageclass @@ -79,7 +79,7 @@ EXAMPLES = ''' encrypted: 'true' kmsKeyId: '<full kms key arn>' provisioner: aws-ebs - default_sc: False + default_storage_class: False register: sc_out notify: - restart openshift master services diff --git a/roles/lib_openshift/src/lib/storageclass.py b/roles/lib_openshift/src/lib/storageclass.py index 958bb2876..a01a6b222 100644 --- a/roles/lib_openshift/src/lib/storageclass.py +++ b/roles/lib_openshift/src/lib/storageclass.py @@ -11,7 +11,7 @@ class StorageClassConfig(object): provisioner=None, parameters=None, annotations=None, - default_sc="false", + default_storage_class="false", api_version='v1', kubeconfig='/etc/origin/master/admin.kubeconfig'): ''' constructor for handling storageclass options ''' @@ -20,7 +20,7 @@ class StorageClassConfig(object): self.annotations = annotations self.provisioner = provisioner self.api_version = api_version - self.default_sc = default_sc + self.default_storage_class = str(default_storage_class).lower() self.kubeconfig = kubeconfig self.data = {} @@ -34,7 +34,10 @@ class StorageClassConfig(object): self.data['metadata']['name'] = self.name self.data['metadata']['annotations'] = {} - self.data['metadata']['annotations']['storageclass.beta.kubernetes.io/is-default-class'] = self.default_sc + if self.annotations is not None: + self.data['metadata']['annotations'] = self.annotations + + self.data['metadata']['annotations']['storageclass.beta.kubernetes.io/is-default-class'] = self.default_storage_class if self.provisioner is None: self.data['provisioner'] = 'kubernetes.io/aws-ebs' |