From 49f46a7686cab15eb2ec9335ca00e9cd7eb547b3 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Wed, 8 Mar 2017 13:03:35 -0500 Subject: Removing ordereddict. Replaced with sorted keys. --- roles/lib_openshift/library/oadm_manage_node.py | 8 ++++---- roles/lib_openshift/library/oc_adm_ca_server_cert.py | 8 ++++---- roles/lib_openshift/library/oc_adm_policy_group.py | 8 ++++---- roles/lib_openshift/library/oc_adm_policy_user.py | 8 ++++---- roles/lib_openshift/library/oc_adm_registry.py | 10 +++++----- roles/lib_openshift/library/oc_adm_router.py | 10 +++++----- roles/lib_openshift/library/oc_edit.py | 8 ++++---- roles/lib_openshift/library/oc_env.py | 8 ++++---- roles/lib_openshift/library/oc_label.py | 8 ++++---- roles/lib_openshift/library/oc_obj.py | 8 ++++---- roles/lib_openshift/library/oc_objectvalidator.py | 8 ++++---- roles/lib_openshift/library/oc_process.py | 8 ++++---- roles/lib_openshift/library/oc_project.py | 8 ++++---- roles/lib_openshift/library/oc_route.py | 8 ++++---- roles/lib_openshift/library/oc_scale.py | 8 ++++---- roles/lib_openshift/library/oc_secret.py | 8 ++++---- roles/lib_openshift/library/oc_service.py | 8 ++++---- roles/lib_openshift/library/oc_serviceaccount.py | 8 ++++---- roles/lib_openshift/library/oc_serviceaccount_secret.py | 8 ++++---- roles/lib_openshift/library/oc_version.py | 8 ++++---- roles/lib_openshift/src/class/oc_adm_registry.py | 2 +- roles/lib_openshift/src/class/oc_adm_router.py | 2 +- roles/lib_openshift/src/lib/base.py | 7 ++++--- roles/lib_openshift/src/lib/import.py | 1 - roles/lib_openshift/src/test/unit/test_oc_adm_registry.py | 8 ++++---- roles/lib_openshift/src/test/unit/test_oc_adm_router.py | 8 +++++--- 26 files changed, 97 insertions(+), 95 deletions(-) (limited to 'roles/lib_openshift') diff --git a/roles/lib_openshift/library/oadm_manage_node.py b/roles/lib_openshift/library/oadm_manage_node.py index 612f62e81..8bb0538c0 100644 --- a/roles/lib_openshift/library/oadm_manage_node.py +++ b/roles/lib_openshift/library/oadm_manage_node.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1345,7 +1344,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1359,10 +1358,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_adm_ca_server_cert.py b/roles/lib_openshift/library/oc_adm_ca_server_cert.py index 775fefb05..4ecfd2bff 100644 --- a/roles/lib_openshift/library/oc_adm_ca_server_cert.py +++ b/roles/lib_openshift/library/oc_adm_ca_server_cert.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1353,7 +1352,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1367,10 +1366,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_adm_policy_group.py b/roles/lib_openshift/library/oc_adm_policy_group.py index be32d42e0..28df1cf94 100644 --- a/roles/lib_openshift/library/oc_adm_policy_group.py +++ b/roles/lib_openshift/library/oc_adm_policy_group.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1331,7 +1330,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1345,10 +1344,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_adm_policy_user.py b/roles/lib_openshift/library/oc_adm_policy_user.py index f76295fb9..9b26a2159 100644 --- a/roles/lib_openshift/library/oc_adm_policy_user.py +++ b/roles/lib_openshift/library/oc_adm_policy_user.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1331,7 +1330,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1345,10 +1344,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_adm_registry.py b/roles/lib_openshift/library/oc_adm_registry.py index dc9aadf36..c398c5551 100644 --- a/roles/lib_openshift/library/oc_adm_registry.py +++ b/roles/lib_openshift/library/oc_adm_registry.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1449,7 +1448,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1463,10 +1462,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval @@ -2293,7 +2293,7 @@ class Registry(OpenShiftCLI): ''' prepare a registry for instantiation ''' options = self.config.to_option_list() - cmd = ['registry', '-n', self.config.namespace] + cmd = ['registry'] cmd.extend(options) cmd.extend(['--dry-run=True', '-o', 'json']) diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py index 00a1015a9..ab06a5141 100644 --- a/roles/lib_openshift/library/oc_adm_router.py +++ b/roles/lib_openshift/library/oc_adm_router.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1474,7 +1473,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1488,10 +1487,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval @@ -2730,7 +2730,7 @@ class Router(OpenShiftCLI): options = self.config.to_option_list() - cmd = ['router', self.config.name, '-n', self.config.namespace] + cmd = ['router', self.config.name] cmd.extend(options) cmd.extend(['--dry-run=True', '-o', 'json']) diff --git a/roles/lib_openshift/library/oc_edit.py b/roles/lib_openshift/library/oc_edit.py index ae19a9094..7a7eaf40a 100644 --- a/roles/lib_openshift/library/oc_edit.py +++ b/roles/lib_openshift/library/oc_edit.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1373,7 +1372,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1387,10 +1386,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_env.py b/roles/lib_openshift/library/oc_env.py index 40240b17d..a1994b0f1 100644 --- a/roles/lib_openshift/library/oc_env.py +++ b/roles/lib_openshift/library/oc_env.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1340,7 +1339,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1354,10 +1353,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_label.py b/roles/lib_openshift/library/oc_label.py index e0147790b..109a78184 100644 --- a/roles/lib_openshift/library/oc_label.py +++ b/roles/lib_openshift/library/oc_label.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1349,7 +1348,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1363,10 +1362,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_obj.py b/roles/lib_openshift/library/oc_obj.py index 54914d484..bd6e77c2a 100644 --- a/roles/lib_openshift/library/oc_obj.py +++ b/roles/lib_openshift/library/oc_obj.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1352,7 +1351,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1366,10 +1365,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_objectvalidator.py b/roles/lib_openshift/library/oc_objectvalidator.py index 3b005f1b7..e691c2ea7 100644 --- a/roles/lib_openshift/library/oc_objectvalidator.py +++ b/roles/lib_openshift/library/oc_objectvalidator.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1284,7 +1283,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1298,10 +1297,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_process.py b/roles/lib_openshift/library/oc_process.py index f215b09a7..14d519e52 100644 --- a/roles/lib_openshift/library/oc_process.py +++ b/roles/lib_openshift/library/oc_process.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1341,7 +1340,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1355,10 +1354,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_project.py b/roles/lib_openshift/library/oc_project.py index 147813693..4f82abcfe 100644 --- a/roles/lib_openshift/library/oc_project.py +++ b/roles/lib_openshift/library/oc_project.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1338,7 +1337,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1352,10 +1351,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_route.py b/roles/lib_openshift/library/oc_route.py index e487147dc..97dd310bc 100644 --- a/roles/lib_openshift/library/oc_route.py +++ b/roles/lib_openshift/library/oc_route.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1383,7 +1382,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1397,10 +1396,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_scale.py b/roles/lib_openshift/library/oc_scale.py index 8257040b3..56e4e38f7 100644 --- a/roles/lib_openshift/library/oc_scale.py +++ b/roles/lib_openshift/library/oc_scale.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1327,7 +1326,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1341,10 +1340,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_secret.py b/roles/lib_openshift/library/oc_secret.py index cff27083f..ad32d4900 100644 --- a/roles/lib_openshift/library/oc_secret.py +++ b/roles/lib_openshift/library/oc_secret.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1373,7 +1372,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1387,10 +1386,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_service.py b/roles/lib_openshift/library/oc_service.py index 5b4a8271e..a4d0ca3f3 100644 --- a/roles/lib_openshift/library/oc_service.py +++ b/roles/lib_openshift/library/oc_service.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1379,7 +1378,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1393,10 +1392,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_serviceaccount.py b/roles/lib_openshift/library/oc_serviceaccount.py index ea178f4ee..b6586fca9 100644 --- a/roles/lib_openshift/library/oc_serviceaccount.py +++ b/roles/lib_openshift/library/oc_serviceaccount.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1325,7 +1324,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1339,10 +1338,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_serviceaccount_secret.py b/roles/lib_openshift/library/oc_serviceaccount_secret.py index 39d2c3ef8..925a5a088 100644 --- a/roles/lib_openshift/library/oc_serviceaccount_secret.py +++ b/roles/lib_openshift/library/oc_serviceaccount_secret.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1325,7 +1324,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1339,10 +1338,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/library/oc_version.py b/roles/lib_openshift/library/oc_version.py index e4e4833c0..8f59d4d7e 100644 --- a/roles/lib_openshift/library/oc_version.py +++ b/roles/lib_openshift/library/oc_version.py @@ -33,7 +33,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os @@ -1297,7 +1296,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -1311,10 +1310,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/src/class/oc_adm_registry.py b/roles/lib_openshift/src/class/oc_adm_registry.py index a9911966b..c083cd179 100644 --- a/roles/lib_openshift/src/class/oc_adm_registry.py +++ b/roles/lib_openshift/src/class/oc_adm_registry.py @@ -145,7 +145,7 @@ class Registry(OpenShiftCLI): ''' prepare a registry for instantiation ''' options = self.config.to_option_list() - cmd = ['registry', '-n', self.config.namespace] + cmd = ['registry'] cmd.extend(options) cmd.extend(['--dry-run=True', '-o', 'json']) diff --git a/roles/lib_openshift/src/class/oc_adm_router.py b/roles/lib_openshift/src/class/oc_adm_router.py index 7b163b120..356d06fdf 100644 --- a/roles/lib_openshift/src/class/oc_adm_router.py +++ b/roles/lib_openshift/src/class/oc_adm_router.py @@ -224,7 +224,7 @@ class Router(OpenShiftCLI): options = self.config.to_option_list() - cmd = ['router', self.config.name, '-n', self.config.namespace] + cmd = ['router', self.config.name] cmd.extend(options) cmd.extend(['--dry-run=True', '-o', 'json']) diff --git a/roles/lib_openshift/src/lib/base.py b/roles/lib_openshift/src/lib/base.py index 3bc34a675..334542b97 100644 --- a/roles/lib_openshift/src/lib/base.py +++ b/roles/lib_openshift/src/lib/base.py @@ -577,7 +577,7 @@ class OpenShiftCLIConfig(object): self.kubeconfig = kubeconfig self.name = rname self.namespace = namespace - self._options = collections.OrderedDict(options) + self._options = options @property def config_options(self): @@ -591,10 +591,11 @@ class OpenShiftCLIConfig(object): def stringify(self): ''' return the options hash as cli params in a string ''' rval = [] - for key, data in self.config_options.items(): + for key in sorted(self.config_options.keys()): + data = self.config_options[key] if data['include'] \ and (data['value'] or isinstance(data['value'], int)): - rval.append('--%s=%s' % (key.replace('_', '-'), data['value'])) + rval.append('--{}={}'.format(key.replace('_', '-'), data['value'])) return rval diff --git a/roles/lib_openshift/src/lib/import.py b/roles/lib_openshift/src/lib/import.py index 97e03062e..a79297898 100644 --- a/roles/lib_openshift/src/lib/import.py +++ b/roles/lib_openshift/src/lib/import.py @@ -7,7 +7,6 @@ from __future__ import print_function import atexit -import collections import copy import json import os diff --git a/roles/lib_openshift/src/test/unit/test_oc_adm_registry.py b/roles/lib_openshift/src/test/unit/test_oc_adm_registry.py index 540048119..bab36fddc 100755 --- a/roles/lib_openshift/src/test/unit/test_oc_adm_registry.py +++ b/roles/lib_openshift/src/test/unit/test_oc_adm_registry.py @@ -208,7 +208,7 @@ class RegistryTest(unittest.TestCase): @mock.patch('oc_adm_registry.Utils._write') @mock.patch('oc_adm_registry.Utils.create_tmpfile_copy') @mock.patch('oc_adm_registry.Registry._run') - def test_state_list(self, mock_cmd, mock_tmpfile_copy, mock_write): + def test_state_present(self, mock_cmd, mock_tmpfile_copy, mock_write): ''' Testing state present ''' params = {'state': 'present', 'debug': False, @@ -254,9 +254,9 @@ class RegistryTest(unittest.TestCase): mock_cmd.assert_has_calls([ mock.call(['oc', 'get', 'dc', 'docker-registry', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'get', 'svc', 'docker-registry', '-o', 'json', '-n', 'default'], None), - mock.call(['oc', 'adm', 'registry', '-n', 'default', '--replicas=1', '--selector=type=infra', - '--enforce-quota=False', '--service-account=registry', '--ports=5000', - '--daemonset=False', '--dry-run=True', '-o', 'json', '-n', 'default'], None), + mock.call(['oc', 'adm', 'registry', '--daemonset=False', '--enforce-quota=False', + '--ports=5000', '--replicas=1', '--selector=type=infra', + '--service-account=registry', '--dry-run=True', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None), ]) diff --git a/roles/lib_openshift/src/test/unit/test_oc_adm_router.py b/roles/lib_openshift/src/test/unit/test_oc_adm_router.py index 9f56f1e54..51393dbaf 100755 --- a/roles/lib_openshift/src/test/unit/test_oc_adm_router.py +++ b/roles/lib_openshift/src/test/unit/test_oc_adm_router.py @@ -289,8 +289,8 @@ class RouterTest(unittest.TestCase): @mock.patch('oc_adm_router.Utils._write') @mock.patch('oc_adm_router.Utils.create_tmpfile_copy') @mock.patch('oc_adm_router.Router._run') - def test_state_list(self, mock_cmd, mock_tmpfile_copy, mock_write): - ''' Testing a get ''' + def test_state_present(self, mock_cmd, mock_tmpfile_copy, mock_write): + ''' Testing a create ''' params = {'state': 'present', 'debug': False, 'namespace': 'default', @@ -357,7 +357,9 @@ class RouterTest(unittest.TestCase): mock.call(['oc', 'get', 'sa', 'router', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'get', 'secret', 'router-certs', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'get', 'clusterrolebinding', 'router-router-role', '-o', 'json', '-n', 'default'], None), - mock.call(['oc', 'adm', 'router', 'router', '-n', 'default', '--external-host-insecure=False', '--replicas=2', '--selector=type=infra', '--stats-port=1936', '--service-account=router', '--expose-metrics=False', '--ports=80:80,443:443', '--dry-run=True', '-o', 'json', '-n', 'default'], None), + mock.call(['oc', 'adm', 'router', 'router', '--expose-metrics=False', '--external-host-insecure=False', + '--ports=80:80,443:443', '--replicas=2', '--selector=type=infra', '--service-account=router', + '--stats-port=1936', '--dry-run=True', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None), -- cgit v1.2.3