From ac44b2062ddb10d503aca46225d3edf057875fbc Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Wed, 14 Feb 2018 13:15:39 -0500 Subject: [PATCH] Revert "Upgrade to openshift client 0.4.0 (#35127)" --- lib/ansible/module_utils/k8s/helper.py | 18 +++++++++--------- lib/ansible/modules/clustering/k8s/k8s_raw.py | 2 +- .../modules/clustering/k8s/k8s_scale.py | 2 +- .../clustering/openshift/openshift_raw.py | 2 +- .../clustering/openshift/openshift_scale.py | 2 +- lib/ansible/plugins/inventory/k8s.py | 5 ----- lib/ansible/plugins/inventory/openshift.py | 5 ----- lib/ansible/plugins/lookup/k8s.py | 2 +- lib/ansible/plugins/lookup/openshift.py | 2 +- 9 files changed, 15 insertions(+), 25 deletions(-) diff --git a/lib/ansible/module_utils/k8s/helper.py b/lib/ansible/module_utils/k8s/helper.py index 438dd9d0dd8..f8f6098dda6 100644 --- a/lib/ansible/module_utils/k8s/helper.py +++ b/lib/ansible/module_utils/k8s/helper.py @@ -381,7 +381,7 @@ class AnsibleMixin(object): if not request_value: return - model_class = self.model_class_from_name(obj_class) + sample_obj = self.model_class_from_name(obj_class)() # Try to determine the unique key for the array key_names = [ @@ -390,7 +390,7 @@ class AnsibleMixin(object): ] key_name = None for key in key_names: - if hasattr(model_class, key): + if hasattr(sample_obj, key): key_name = key break @@ -421,14 +421,14 @@ class AnsibleMixin(object): found = True for key, value in iteritems(item): snake_key = self.attribute_to_snake(key) - item_kind = model_class.swagger_types.get(snake_key) + item_kind = sample_obj.swagger_types.get(snake_key) if item_kind and item_kind in PRIMITIVES or type(value).__name__ in PRIMITIVES: setattr(obj, snake_key, value) elif item_kind and item_kind.startswith('list['): obj_type = item_kind.replace('list[', '').replace(']', '') if getattr(obj, snake_key) is None: setattr(obj, snake_key, []) - if obj_type not in ('str', 'int', 'bool', 'object'): + if obj_type not in ('str', 'int', 'bool'): self.__compare_obj_list(getattr(obj, snake_key), value, obj_type, param_name) else: # Straight list comparison @@ -462,7 +462,7 @@ class AnsibleMixin(object): ) if not found: # Requested item not found. Adding. - obj = self.model_class_from_name(obj_class)(**item) + obj = self.__update_object_properties(self.model_class_from_name(obj_class)(), item) src_value.append(obj) else: # There isn't a key, or we don't know what it is, so check for all properties to match @@ -480,7 +480,7 @@ class AnsibleMixin(object): found = True break if not found: - obj = self.model_class_from_name(obj_class)(**item) + obj = self.__update_object_properties(self.model_class_from_name(obj_class)(), item) src_value.append(obj) def __update_object_properties(self, obj, item): @@ -512,7 +512,7 @@ class AnsibleMixin(object): """ Convert a list of properties to an argument_spec dictionary - :param properties: List of properties from self.properties_from_model_class() + :param properties: List of properties from self.properties_from_model_obj() :param prefix: String to prefix to argument names. :param path: List of property names providing the recursive path through the model to the property :param alternate_prefix: a more minimal version of prefix @@ -598,7 +598,7 @@ class AnsibleMixin(object): } args.update(self.__transform_properties(sub_props, prefix=p, path=paths, alternate_prefix=a)) else: - sub_props = self.properties_from_model_class(prop_attributes['class']) + sub_props = self.properties_from_model_obj(prop_attributes['class']()) args.update(self.__transform_properties(sub_props, prefix=p, path=paths, alternate_prefix=a)) else: # Adds a primitive property @@ -608,7 +608,7 @@ class AnsibleMixin(object): paths.append(prop) property_type = prop_attributes['class'].__name__ - if property_type == 'object': + if property_type == 'IntstrIntOrString': property_type = 'str' args[arg_prefix + prop] = { diff --git a/lib/ansible/modules/clustering/k8s/k8s_raw.py b/lib/ansible/modules/clustering/k8s/k8s_raw.py index 5f574bb2156..87b143f0005 100644 --- a/lib/ansible/modules/clustering/k8s/k8s_raw.py +++ b/lib/ansible/modules/clustering/k8s/k8s_raw.py @@ -39,7 +39,7 @@ extends_documentation_fragment: requirements: - "python >= 2.7" - - "openshift == 0.4.1" + - "openshift >= 0.3" - "PyYAML >= 3.11" ''' diff --git a/lib/ansible/modules/clustering/k8s/k8s_scale.py b/lib/ansible/modules/clustering/k8s/k8s_scale.py index c4603fff223..3fda8e08eaa 100644 --- a/lib/ansible/modules/clustering/k8s/k8s_scale.py +++ b/lib/ansible/modules/clustering/k8s/k8s_scale.py @@ -35,7 +35,7 @@ extends_documentation_fragment: requirements: - "python >= 2.7" - - "openshift == 0.4.1" + - "openshift >= 0.3" - "PyYAML >= 3.11" ''' diff --git a/lib/ansible/modules/clustering/openshift/openshift_raw.py b/lib/ansible/modules/clustering/openshift/openshift_raw.py index 52a56a668b3..3059f8592ab 100644 --- a/lib/ansible/modules/clustering/openshift/openshift_raw.py +++ b/lib/ansible/modules/clustering/openshift/openshift_raw.py @@ -49,7 +49,7 @@ options: requirements: - "python >= 2.7" - - "openshift == 0.4.1" + - "openshift >= 0.3" - "PyYAML >= 3.11" ''' diff --git a/lib/ansible/modules/clustering/openshift/openshift_scale.py b/lib/ansible/modules/clustering/openshift/openshift_scale.py index b1400ad5352..385999b457f 100644 --- a/lib/ansible/modules/clustering/openshift/openshift_scale.py +++ b/lib/ansible/modules/clustering/openshift/openshift_scale.py @@ -35,7 +35,7 @@ extends_documentation_fragment: requirements: - "python >= 2.7" - - "openshift == 0.4.1" + - "openshift >= 0.3" - "PyYAML >= 3.11" ''' diff --git a/lib/ansible/plugins/inventory/k8s.py b/lib/ansible/plugins/inventory/k8s.py index b5089288885..82f31ab391f 100644 --- a/lib/ansible/plugins/inventory/k8s.py +++ b/lib/ansible/plugins/inventory/k8s.py @@ -73,11 +73,6 @@ DOCUMENTATION = ''' description: - List of namespaces. If not specified, will fetch all containers for all namespaces user is authorized to access. - - requirements: - - "python >= 2.7" - - "openshift == 0.4.1" - - "PyYAML >= 3.11" ''' EXAMPLES = ''' diff --git a/lib/ansible/plugins/inventory/openshift.py b/lib/ansible/plugins/inventory/openshift.py index 17b8f347ede..f4e65cd8d96 100644 --- a/lib/ansible/plugins/inventory/openshift.py +++ b/lib/ansible/plugins/inventory/openshift.py @@ -74,11 +74,6 @@ DOCUMENTATION = ''' description: - List of namespaces. If not specified, will fetch all containers for all namespaces user is authorized to access. - - requirements: - - "python >= 2.7" - - "openshift == 0.4.1" - - "PyYAML >= 3.11" ''' EXAMPLES = ''' diff --git a/lib/ansible/plugins/lookup/k8s.py b/lib/ansible/plugins/lookup/k8s.py index 5b7c6069482..544a8295ecb 100644 --- a/lib/ansible/plugins/lookup/k8s.py +++ b/lib/ansible/plugins/lookup/k8s.py @@ -115,7 +115,7 @@ DOCUMENTATION = """ requirements: - "python >= 2.7" - - "openshift == 0.4.1" + - "openshift >= 0.3" - "PyYAML >= 3.11" notes: diff --git a/lib/ansible/plugins/lookup/openshift.py b/lib/ansible/plugins/lookup/openshift.py index fffeca777bc..5c12e747a81 100644 --- a/lib/ansible/plugins/lookup/openshift.py +++ b/lib/ansible/plugins/lookup/openshift.py @@ -115,7 +115,7 @@ DOCUMENTATION = """ requirements: - "python >= 2.7" - - "openshift == 0.4.1" + - "openshift >= 0.3" - "PyYAML >= 3.11" notes: