summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.coveragerc2
-rw-r--r--inventory/byo/hosts.origin.example2
-rw-r--r--inventory/byo/hosts.ose.example2
-rw-r--r--roles/contiv/defaults/main.yml15
-rw-r--r--roles/contiv/files/loopbackbin3909976 -> 0 bytes
-rw-r--r--roles/contiv/tasks/download_bins.yml19
-rw-r--r--roles/contiv/tasks/netplugin.yml3
-rw-r--r--roles/etcd/tasks/etcdctl.yml2
-rw-r--r--roles/etcd/tasks/main.yml2
-rw-r--r--roles/etcd_server_certificates/tasks/main.yml2
-rw-r--r--roles/lib_openshift/library/oadm_manage_node.py5
-rw-r--r--roles/lib_openshift/library/oc_adm_ca_server_cert.py5
-rw-r--r--roles/lib_openshift/library/oc_adm_policy_group.py5
-rw-r--r--roles/lib_openshift/library/oc_adm_policy_user.py5
-rw-r--r--roles/lib_openshift/library/oc_adm_registry.py11
-rw-r--r--roles/lib_openshift/library/oc_adm_router.py7
-rw-r--r--roles/lib_openshift/library/oc_edit.py5
-rw-r--r--roles/lib_openshift/library/oc_env.py5
-rw-r--r--roles/lib_openshift/library/oc_label.py5
-rw-r--r--roles/lib_openshift/library/oc_obj.py5
-rw-r--r--roles/lib_openshift/library/oc_objectvalidator.py5
-rw-r--r--roles/lib_openshift/library/oc_process.py5
-rw-r--r--roles/lib_openshift/library/oc_project.py5
-rw-r--r--roles/lib_openshift/library/oc_route.py5
-rw-r--r--roles/lib_openshift/library/oc_scale.py5
-rw-r--r--roles/lib_openshift/library/oc_secret.py5
-rw-r--r--roles/lib_openshift/library/oc_service.py5
-rw-r--r--roles/lib_openshift/library/oc_serviceaccount.py5
-rw-r--r--roles/lib_openshift/library/oc_serviceaccount_secret.py5
-rw-r--r--roles/lib_openshift/library/oc_version.py5
-rw-r--r--roles/lib_openshift/src/class/oc_adm_registry.py6
-rw-r--r--roles/lib_openshift/src/class/oc_adm_router.py2
-rw-r--r--roles/lib_openshift/src/lib/base.py5
-rwxr-xr-xroles/lib_openshift/src/test/unit/test_oc_adm_registry.py369
-rwxr-xr-xroles/lib_openshift/src/test/unit/test_oc_adm_router.py474
-rw-r--r--roles/openshift_excluder/meta/main.yml1
-rw-r--r--roles/openshift_excluder/tasks/adjust.yml2
-rw-r--r--roles/openshift_excluder/tasks/enable.yml2
-rw-r--r--roles/openshift_excluder/tasks/exclude.yml2
-rw-r--r--roles/openshift_excluder/tasks/install.yml2
-rw-r--r--roles/openshift_excluder/tasks/status.yml2
-rw-r--r--roles/openshift_excluder/tasks/unexclude.yml2
42 files changed, 965 insertions, 61 deletions
diff --git a/.coveragerc b/.coveragerc
index 00f46b61b..ad7893b91 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -14,7 +14,7 @@ omit =
*/test/*
[report]
-fail_under = 29
+fail_under = 28
[html]
directory = cover
diff --git a/inventory/byo/hosts.origin.example b/inventory/byo/hosts.origin.example
index 0ddca6576..6dec97fda 100644
--- a/inventory/byo/hosts.origin.example
+++ b/inventory/byo/hosts.origin.example
@@ -89,6 +89,8 @@ openshift_release=v1.4
# Skip upgrading Docker during an OpenShift upgrade, leaves the current Docker version alone.
# docker_upgrade=False
+# Specify exact version of etcd to configure or upgrade to.
+# etcd_version="3.1.0"
# Upgrade Hooks
#
diff --git a/inventory/byo/hosts.ose.example b/inventory/byo/hosts.ose.example
index 7f80a9639..2b61e7d8d 100644
--- a/inventory/byo/hosts.ose.example
+++ b/inventory/byo/hosts.ose.example
@@ -89,6 +89,8 @@ openshift_release=v3.4
# Skip upgrading Docker during an OpenShift upgrade, leaves the current Docker version alone.
# docker_upgrade=False
+# Specify exact version of etcd to configure or upgrade to.
+# etcd_version="3.1.0"
# Upgrade Hooks
#
diff --git a/roles/contiv/defaults/main.yml b/roles/contiv/defaults/main.yml
index c2b72339c..1ccae61f2 100644
--- a/roles/contiv/defaults/main.yml
+++ b/roles/contiv/defaults/main.yml
@@ -2,11 +2,18 @@
# The version of Contiv binaries to use
contiv_version: 1.0.0-beta.3-02-21-2017.20-52-42.UTC
+# The version of cni binaries
+cni_version: v0.4.0
+
contiv_default_subnet: "20.1.1.1/24"
contiv_default_gw: "20.1.1.254"
# TCP port that Netmaster listens for network connections
netmaster_port: 9999
+# Default for contiv_role
+contiv_role: netmaster
+
+
# TCP port that Netplugin listens for network connections
netplugin_port: 6640
contiv_rpc_port1: 9001
@@ -33,6 +40,14 @@ bin_dir: /usr/bin
# Path to the contivk8s cni binary
cni_bin_dir: /opt/cni/bin
+# Path to cni archive download directory
+cni_download_dir: /tmp
+
+# URL for cni binaries
+cni_bin_url_base: "https://github.com/containernetworking/cni/releases/download/"
+cni_bin_url: "{{ cni_bin_url_base }}/{{ cni_version }}/cni-{{ cni_version }}.tbz2"
+
+
# Contiv config directory
contiv_config_dir: /opt/contiv/config
diff --git a/roles/contiv/files/loopback b/roles/contiv/files/loopback
deleted file mode 100644
index f02b0b1fb..000000000
--- a/roles/contiv/files/loopback
+++ /dev/null
Binary files differ
diff --git a/roles/contiv/tasks/download_bins.yml b/roles/contiv/tasks/download_bins.yml
index 28ed50fae..319fce46c 100644
--- a/roles/contiv/tasks/download_bins.yml
+++ b/roles/contiv/tasks/download_bins.yml
@@ -25,3 +25,22 @@
src: "{{ contiv_current_release_directory }}/netplugin-{{ contiv_version }}.tar.bz2"
dest: "{{ contiv_current_release_directory }}"
copy: no
+
+- name: Download Bins | Download cni tar file
+ get_url:
+ url: "{{ cni_bin_url }}"
+ dest: "{{ cni_download_dir }}"
+ mode: 0755
+ validate_certs: False
+ environment:
+ http_proxy: "{{ http_proxy|default('') }}"
+ https_proxy: "{{ https_proxy|default('') }}"
+ no_proxy: "{{ no_proxy|default('') }}"
+ register: download_file
+
+- name: Download Bins | Extract cni tar file
+ unarchive:
+ src: "{{ download_file.dest }}"
+ dest: "{{ cni_download_dir }}"
+ copy: no
+ when: download_file.changed
diff --git a/roles/contiv/tasks/netplugin.yml b/roles/contiv/tasks/netplugin.yml
index ec6c72fe9..97b9762df 100644
--- a/roles/contiv/tasks/netplugin.yml
+++ b/roles/contiv/tasks/netplugin.yml
@@ -43,8 +43,9 @@
- name: Netplugin | Copy CNI loopback bin
copy:
- src: loopback
+ src: "{{ cni_download_dir }}/loopback"
dest: "{{ cni_bin_dir }}/loopback"
+ remote_src: True
mode: 0755
- name: Netplugin | Ensure kube_plugin_dir and cni/net.d directories exist
diff --git a/roles/etcd/tasks/etcdctl.yml b/roles/etcd/tasks/etcdctl.yml
index bb6fabf64..649ad23c1 100644
--- a/roles/etcd/tasks/etcdctl.yml
+++ b/roles/etcd/tasks/etcdctl.yml
@@ -1,6 +1,6 @@
---
- name: Install etcd for etcdctl
- package: name=etcd state=present
+ package: name=etcd{{ '-' + etcd_version if etcd_version is defined else '' }} state=present
when: not openshift.common.is_atomic | bool
- name: Configure etcd profile.d alises
diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml
index b4ffc99e3..c09da3b61 100644
--- a/roles/etcd/tasks/main.yml
+++ b/roles/etcd/tasks/main.yml
@@ -7,7 +7,7 @@
etcd_ip: "{{ etcd_ip }}"
- name: Install etcd
- package: name=etcd state=present
+ package: name=etcd{{ '-' + etcd_version if etcd_version is defined else '' }} state=present
when: not etcd_is_containerized | bool
- name: Pull etcd container
diff --git a/roles/etcd_server_certificates/tasks/main.yml b/roles/etcd_server_certificates/tasks/main.yml
index 242c1e997..4ae9b79c4 100644
--- a/roles/etcd_server_certificates/tasks/main.yml
+++ b/roles/etcd_server_certificates/tasks/main.yml
@@ -1,6 +1,6 @@
---
- name: Install etcd
- package: name=etcd state=present
+ package: name=etcd{{ '-' + etcd_version if etcd_version is defined else '' }} state=present
when: not etcd_is_containerized | bool
- name: Check status of etcd certificates
diff --git a/roles/lib_openshift/library/oadm_manage_node.py b/roles/lib_openshift/library/oadm_manage_node.py
index 8c0a29ac7..8bb0538c0 100644
--- a/roles/lib_openshift/library/oadm_manage_node.py
+++ b/roles/lib_openshift/library/oadm_manage_node.py
@@ -1358,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 bbcd9d0c5..4ecfd2bff 100644
--- a/roles/lib_openshift/library/oc_adm_ca_server_cert.py
+++ b/roles/lib_openshift/library/oc_adm_ca_server_cert.py
@@ -1366,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 ecb6ca485..49ff22584 100644
--- a/roles/lib_openshift/library/oc_adm_policy_group.py
+++ b/roles/lib_openshift/library/oc_adm_policy_group.py
@@ -1344,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 cecfb3b70..bed05044c 100644
--- a/roles/lib_openshift/library/oc_adm_policy_user.py
+++ b/roles/lib_openshift/library/oc_adm_policy_user.py
@@ -1344,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 dcfc326a9..c398c5551 100644
--- a/roles/lib_openshift/library/oc_adm_registry.py
+++ b/roles/lib_openshift/library/oc_adm_registry.py
@@ -1462,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
@@ -2266,7 +2267,6 @@ class Registry(OpenShiftCLI):
def exists(self):
'''does the object exist?'''
- self.get()
if self.deploymentconfig and self.service:
return True
@@ -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'])
@@ -2327,7 +2327,8 @@ class Registry(OpenShiftCLI):
service.put('spec.portalIP', self.portal_ip)
# the dry-run doesn't apply the selector correctly
- service.put('spec.selector', self.service.get_selector())
+ if self.service:
+ service.put('spec.selector', self.service.get_selector())
# need to create the service and the deploymentconfig
service_file = Utils.create_tmp_file_from_contents('service', service.yaml_dict)
diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py
index 68b797577..ab06a5141 100644
--- a/roles/lib_openshift/library/oc_adm_router.py
+++ b/roles/lib_openshift/library/oc_adm_router.py
@@ -1487,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
@@ -2729,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 0347644eb..7a7eaf40a 100644
--- a/roles/lib_openshift/library/oc_edit.py
+++ b/roles/lib_openshift/library/oc_edit.py
@@ -1386,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 e343c70df..a1994b0f1 100644
--- a/roles/lib_openshift/library/oc_env.py
+++ b/roles/lib_openshift/library/oc_env.py
@@ -1353,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 c4ed42bbe..109a78184 100644
--- a/roles/lib_openshift/library/oc_label.py
+++ b/roles/lib_openshift/library/oc_label.py
@@ -1362,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 863443517..bd6e77c2a 100644
--- a/roles/lib_openshift/library/oc_obj.py
+++ b/roles/lib_openshift/library/oc_obj.py
@@ -1365,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 5a966fa93..1d0e4c876 100644
--- a/roles/lib_openshift/library/oc_objectvalidator.py
+++ b/roles/lib_openshift/library/oc_objectvalidator.py
@@ -1297,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 03c9d2044..14d519e52 100644
--- a/roles/lib_openshift/library/oc_process.py
+++ b/roles/lib_openshift/library/oc_process.py
@@ -1354,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 812c67de5..4f82abcfe 100644
--- a/roles/lib_openshift/library/oc_project.py
+++ b/roles/lib_openshift/library/oc_project.py
@@ -1351,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 2ce3824e9..97dd310bc 100644
--- a/roles/lib_openshift/library/oc_route.py
+++ b/roles/lib_openshift/library/oc_route.py
@@ -1396,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 c9e9b1790..56e4e38f7 100644
--- a/roles/lib_openshift/library/oc_scale.py
+++ b/roles/lib_openshift/library/oc_scale.py
@@ -1340,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 6058f0ee2..ad32d4900 100644
--- a/roles/lib_openshift/library/oc_secret.py
+++ b/roles/lib_openshift/library/oc_secret.py
@@ -1386,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 8f6303a66..a4d0ca3f3 100644
--- a/roles/lib_openshift/library/oc_service.py
+++ b/roles/lib_openshift/library/oc_service.py
@@ -1392,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 7d78c96d0..b6586fca9 100644
--- a/roles/lib_openshift/library/oc_serviceaccount.py
+++ b/roles/lib_openshift/library/oc_serviceaccount.py
@@ -1338,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 c058c555b..925a5a088 100644
--- a/roles/lib_openshift/library/oc_serviceaccount_secret.py
+++ b/roles/lib_openshift/library/oc_serviceaccount_secret.py
@@ -1338,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 4e65b8a0a..8f59d4d7e 100644
--- a/roles/lib_openshift/library/oc_version.py
+++ b/roles/lib_openshift/library/oc_version.py
@@ -1310,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 37904c43f..c083cd179 100644
--- a/roles/lib_openshift/src/class/oc_adm_registry.py
+++ b/roles/lib_openshift/src/class/oc_adm_registry.py
@@ -119,7 +119,6 @@ class Registry(OpenShiftCLI):
def exists(self):
'''does the object exist?'''
- self.get()
if self.deploymentconfig and self.service:
return True
@@ -146,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'])
@@ -180,7 +179,8 @@ class Registry(OpenShiftCLI):
service.put('spec.portalIP', self.portal_ip)
# the dry-run doesn't apply the selector correctly
- service.put('spec.selector', self.service.get_selector())
+ if self.service:
+ service.put('spec.selector', self.service.get_selector())
# need to create the service and the deploymentconfig
service_file = Utils.create_tmp_file_from_contents('service', service.yaml_dict)
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 d037074a5..334542b97 100644
--- a/roles/lib_openshift/src/lib/base.py
+++ b/roles/lib_openshift/src/lib/base.py
@@ -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/test/unit/test_oc_adm_registry.py b/roles/lib_openshift/src/test/unit/test_oc_adm_registry.py
new file mode 100755
index 000000000..bab36fddc
--- /dev/null
+++ b/roles/lib_openshift/src/test/unit/test_oc_adm_registry.py
@@ -0,0 +1,369 @@
+#!/usr/bin/env python
+'''
+ Unit tests for oc adm registry
+'''
+
+import os
+import six
+import sys
+import unittest
+import mock
+
+# Removing invalid variable names for tests so that I can
+# keep them brief
+# pylint: disable=invalid-name,no-name-in-module
+# Disable import-error b/c our libraries aren't loaded in jenkins
+# pylint: disable=import-error
+# place class in our python path
+module_path = os.path.join('/'.join(os.path.realpath(__file__).split('/')[:-4]), 'library') # noqa: E501
+sys.path.insert(0, module_path)
+from oc_adm_registry import Registry, locate_oc_binary # noqa: E402
+
+
+# pylint: disable=too-many-public-methods
+class RegistryTest(unittest.TestCase):
+ '''
+ Test class for Registry
+ '''
+ dry_run = '''{
+ "kind": "List",
+ "apiVersion": "v1",
+ "metadata": {},
+ "items": [
+ {
+ "kind": "ServiceAccount",
+ "apiVersion": "v1",
+ "metadata": {
+ "name": "registry",
+ "creationTimestamp": null
+ }
+ },
+ {
+ "kind": "ClusterRoleBinding",
+ "apiVersion": "v1",
+ "metadata": {
+ "name": "registry-registry-role",
+ "creationTimestamp": null
+ },
+ "userNames": [
+ "system:serviceaccount:default:registry"
+ ],
+ "groupNames": null,
+ "subjects": [
+ {
+ "kind": "ServiceAccount",
+ "namespace": "default",
+ "name": "registry"
+ }
+ ],
+ "roleRef": {
+ "kind": "ClusterRole",
+ "name": "system:registry"
+ }
+ },
+ {
+ "kind": "DeploymentConfig",
+ "apiVersion": "v1",
+ "metadata": {
+ "name": "docker-registry",
+ "creationTimestamp": null,
+ "labels": {
+ "docker-registry": "default"
+ }
+ },
+ "spec": {
+ "strategy": {
+ "resources": {}
+ },
+ "triggers": [
+ {
+ "type": "ConfigChange"
+ }
+ ],
+ "replicas": 1,
+ "test": false,
+ "selector": {
+ "docker-registry": "default"
+ },
+ "template": {
+ "metadata": {
+ "creationTimestamp": null,
+ "labels": {
+ "docker-registry": "default"
+ }
+ },
+ "spec": {
+ "volumes": [
+ {
+ "name": "registry-storage",
+ "emptyDir": {}
+ }
+ ],
+ "containers": [
+ {
+ "name": "registry",
+ "image": "openshift3/ose-docker-registry:v3.5.0.39",
+ "ports": [
+ {
+ "containerPort": 5000
+ }
+ ],
+ "env": [
+ {
+ "name": "REGISTRY_HTTP_ADDR",
+ "value": ":5000"
+ },
+ {
+ "name": "REGISTRY_HTTP_NET",
+ "value": "tcp"
+ },
+ {
+ "name": "REGISTRY_HTTP_SECRET",
+ "value": "WQjSGeUu5KFZRTwGeIXgwIjyraNDLmdJblsFbtzZdF8="
+ },
+ {
+ "name": "REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_ENFORCEQUOTA",
+ "value": "false"
+ }
+ ],
+ "resources": {
+ "requests": {
+ "cpu": "100m",
+ "memory": "256Mi"
+ }
+ },
+ "volumeMounts": [
+ {
+ "name": "registry-storage",
+ "mountPath": "/registry"
+ }
+ ],
+ "livenessProbe": {
+ "httpGet": {
+ "path": "/healthz",
+ "port": 5000
+ },
+ "initialDelaySeconds": 10,
+ "timeoutSeconds": 5
+ },
+ "readinessProbe": {
+ "httpGet": {
+ "path": "/healthz",
+ "port": 5000
+ },
+ "timeoutSeconds": 5
+ },
+ "securityContext": {
+ "privileged": false
+ }
+ }
+ ],
+ "nodeSelector": {
+ "type": "infra"
+ },
+ "serviceAccountName": "registry",
+ "serviceAccount": "registry"
+ }
+ }
+ },
+ "status": {
+ "latestVersion": 0,
+ "observedGeneration": 0,
+ "replicas": 0,
+ "updatedReplicas": 0,
+ "availableReplicas": 0,
+ "unavailableReplicas": 0
+ }
+ },
+ {
+ "kind": "Service",
+ "apiVersion": "v1",
+ "metadata": {
+ "name": "docker-registry",
+ "creationTimestamp": null,
+ "labels": {
+ "docker-registry": "default"
+ }
+ },
+ "spec": {
+ "ports": [
+ {
+ "name": "5000-tcp",
+ "port": 5000,
+ "targetPort": 5000
+ }
+ ],
+ "selector": {
+ "docker-registry": "default"
+ },
+ "clusterIP": "172.30.119.110",
+ "sessionAffinity": "ClientIP"
+ },
+ "status": {
+ "loadBalancer": {}
+ }
+ }
+ ]}'''
+
+ @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_present(self, mock_cmd, mock_tmpfile_copy, mock_write):
+ ''' Testing state present '''
+ params = {'state': 'present',
+ 'debug': False,
+ 'namespace': 'default',
+ 'name': 'docker-registry',
+ 'kubeconfig': '/etc/origin/master/admin.kubeconfig',
+ 'images': None,
+ 'latest_images': None,
+ 'labels': None,
+ 'ports': ['5000'],
+ 'replicas': 1,
+ 'selector': 'type=infra',
+ 'service_account': 'registry',
+ 'mount_host': None,
+ 'volume_mounts': None,
+ 'env_vars': {},
+ 'enforce_quota': False,
+ 'force': False,
+ 'daemonset': False,
+ 'tls_key': None,
+ 'tls_certificate': None,
+ 'edits': []}
+
+ mock_cmd.side_effect = [
+ (1, '', 'Error from server (NotFound): deploymentconfigs "docker-registry" not found'),
+ (1, '', 'Error from server (NotFound): service "docker-registry" not found'),
+ (0, RegistryTest.dry_run, ''),
+ (0, '', ''),
+ (0, '', ''),
+ ]
+
+ mock_tmpfile_copy.side_effect = [
+ '/tmp/mocked_kubeconfig',
+ '/tmp/mocked_kubeconfig',
+ ]
+
+ results = Registry.run_ansible(params, False)
+
+ self.assertTrue(results['changed'])
+ for result in results['results']['results']:
+ self.assertEqual(result['returncode'], 0)
+
+ 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', '--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), ])
+
+ @unittest.skipIf(six.PY3, 'py2 test only')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
+ ''' Testing binary lookup fallback '''
+
+ mock_env_get.side_effect = lambda _v, _d: ''
+
+ mock_path_exists.side_effect = lambda _: False
+
+ self.assertEqual(locate_oc_binary(), 'oc')
+
+ @unittest.skipIf(six.PY3, 'py2 test only')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
+ ''' Testing binary lookup in path '''
+
+ oc_bin = '/usr/bin/oc'
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_path_exists.side_effect = lambda f: f == oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY3, 'py2 test only')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
+ ''' Testing binary lookup in /usr/local/bin '''
+
+ oc_bin = '/usr/local/bin/oc'
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_path_exists.side_effect = lambda f: f == oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY3, 'py2 test only')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
+ ''' Testing binary lookup in ~/bin '''
+
+ oc_bin = os.path.expanduser('~/bin/oc')
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_path_exists.side_effect = lambda f: f == oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY2, 'py3 test only')
+ @mock.patch('shutil.which')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
+ ''' Testing binary lookup fallback '''
+
+ mock_env_get.side_effect = lambda _v, _d: ''
+
+ mock_shutil_which.side_effect = lambda _f, path=None: None
+
+ self.assertEqual(locate_oc_binary(), 'oc')
+
+ @unittest.skipIf(six.PY2, 'py3 test only')
+ @mock.patch('shutil.which')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
+ ''' Testing binary lookup in path '''
+
+ oc_bin = '/usr/bin/oc'
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_shutil_which.side_effect = lambda _f, path=None: oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY2, 'py3 test only')
+ @mock.patch('shutil.which')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
+ ''' Testing binary lookup in /usr/local/bin '''
+
+ oc_bin = '/usr/local/bin/oc'
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_shutil_which.side_effect = lambda _f, path=None: oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY2, 'py3 test only')
+ @mock.patch('shutil.which')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
+ ''' Testing binary lookup in ~/bin '''
+
+ oc_bin = os.path.expanduser('~/bin/oc')
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_shutil_which.side_effect = lambda _f, path=None: oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
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
new file mode 100755
index 000000000..51393dbaf
--- /dev/null
+++ b/roles/lib_openshift/src/test/unit/test_oc_adm_router.py
@@ -0,0 +1,474 @@
+#!/usr/bin/env python
+'''
+ Unit tests for oc adm router
+'''
+
+import os
+import six
+import sys
+import unittest
+import mock
+
+# Removing invalid variable names for tests so that I can
+# keep them brief
+# pylint: disable=invalid-name,no-name-in-module
+# Disable import-error b/c our libraries aren't loaded in jenkins
+# pylint: disable=import-error
+# place class in our python path
+module_path = os.path.join('/'.join(os.path.realpath(__file__).split('/')[:-4]), 'library') # noqa: E501
+sys.path.insert(0, module_path)
+from oc_adm_router import Router, locate_oc_binary # noqa: E402
+
+
+# pylint: disable=too-many-public-methods
+class RouterTest(unittest.TestCase):
+ '''
+ Test class for Router
+ '''
+ dry_run = '''{
+ "kind": "List",
+ "apiVersion": "v1",
+ "metadata": {},
+ "items": [
+ {
+ "kind": "ServiceAccount",
+ "apiVersion": "v1",
+ "metadata": {
+ "name": "router",
+ "creationTimestamp": null
+ }
+ },
+ {
+ "kind": "ClusterRoleBinding",
+ "apiVersion": "v1",
+ "metadata": {
+ "name": "router-router-role",
+ "creationTimestamp": null
+ },
+ "userNames": [
+ "system:serviceaccount:default:router"
+ ],
+ "groupNames": null,
+ "subjects": [
+ {
+ "kind": "ServiceAccount",
+ "namespace": "default",
+ "name": "router"
+ }
+ ],
+ "roleRef": {
+ "kind": "ClusterRole",
+ "name": "system:router"
+ }
+ },
+ {
+ "kind": "DeploymentConfig",
+ "apiVersion": "v1",
+ "metadata": {
+ "name": "router",
+ "creationTimestamp": null,
+ "labels": {
+ "router": "router"
+ }
+ },
+ "spec": {
+ "strategy": {
+ "type": "Rolling",
+ "rollingParams": {
+ "maxUnavailable": "25%",
+ "maxSurge": 0
+ },
+ "resources": {}
+ },
+ "triggers": [
+ {
+ "type": "ConfigChange"
+ }
+ ],
+ "replicas": 2,
+ "test": false,
+ "selector": {
+ "router": "router"
+ },
+ "template": {
+ "metadata": {
+ "creationTimestamp": null,
+ "labels": {
+ "router": "router"
+ }
+ },
+ "spec": {
+ "volumes": [
+ {
+ "name": "server-certificate",
+ "secret": {
+ "secretName": "router-certs"
+ }
+ }
+ ],
+ "containers": [
+ {
+ "name": "router",
+ "image": "openshift3/ose-haproxy-router:v3.5.0.39",
+ "ports": [
+ {
+ "containerPort": 80
+ },
+ {
+ "containerPort": 443
+ },
+ {
+ "name": "stats",
+ "containerPort": 1936,
+ "protocol": "TCP"
+ }
+ ],
+ "env": [
+ {
+ "name": "DEFAULT_CERTIFICATE_DIR",
+ "value": "/etc/pki/tls/private"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_HOSTNAME"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_HTTPS_VSERVER"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_HTTP_VSERVER"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_INSECURE",
+ "value": "false"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_INTERNAL_ADDRESS"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_PARTITION_PATH"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_PASSWORD"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_PRIVKEY",
+ "value": "/etc/secret-volume/router.pem"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_USERNAME"
+ },
+ {
+ "name": "ROUTER_EXTERNAL_HOST_VXLAN_GW_CIDR"
+ },
+ {
+ "name": "ROUTER_SERVICE_HTTPS_PORT",
+ "value": "443"
+ },
+ {
+ "name": "ROUTER_SERVICE_HTTP_PORT",
+ "value": "80"
+ },
+ {
+ "name": "ROUTER_SERVICE_NAME",
+ "value": "router"
+ },
+ {
+ "name": "ROUTER_SERVICE_NAMESPACE",
+ "value": "default"
+ },
+ {
+ "name": "ROUTER_SUBDOMAIN"
+ },
+ {
+ "name": "STATS_PASSWORD",
+ "value": "eSfUICQyyr"
+ },
+ {
+ "name": "STATS_PORT",
+ "value": "1936"
+ },
+ {
+ "name": "STATS_USERNAME",
+ "value": "admin"
+ }
+ ],
+ "resources": {
+ "requests": {
+ "cpu": "100m",
+ "memory": "256Mi"
+ }
+ },
+ "volumeMounts": [
+ {
+ "name": "server-certificate",
+ "readOnly": true,
+ "mountPath": "/etc/pki/tls/private"
+ }
+ ],
+ "livenessProbe": {
+ "httpGet": {
+ "path": "/healthz",
+ "port": 1936,
+ "host": "localhost"
+ },
+ "initialDelaySeconds": 10
+ },
+ "readinessProbe": {
+ "httpGet": {
+ "path": "/healthz",
+ "port": 1936,
+ "host": "localhost"
+ },
+ "initialDelaySeconds": 10
+ },
+ "imagePullPolicy": "IfNotPresent"
+ }
+ ],
+ "nodeSelector": {
+ "type": "infra"
+ },
+ "serviceAccountName": "router",
+ "serviceAccount": "router",
+ "hostNetwork": true,
+ "securityContext": {}
+ }
+ }
+ },
+ "status": {
+ "latestVersion": 0,
+ "observedGeneration": 0,
+ "replicas": 0,
+ "updatedReplicas": 0,
+ "availableReplicas": 0,
+ "unavailableReplicas": 0
+ }
+ },
+ {
+ "kind": "Service",
+ "apiVersion": "v1",
+ "metadata": {
+ "name": "router",
+ "creationTimestamp": null,
+ "labels": {
+ "router": "router"
+ },
+ "annotations": {
+ "service.alpha.openshift.io/serving-cert-secret-name": "router-certs"
+ }
+ },
+ "spec": {
+ "ports": [
+ {
+ "name": "80-tcp",
+ "port": 80,
+ "targetPort": 80
+ },
+ {
+ "name": "443-tcp",
+ "port": 443,
+ "targetPort": 443
+ },
+ {
+ "name": "1936-tcp",
+ "protocol": "TCP",
+ "port": 1936,
+ "targetPort": 1936
+ }
+ ],
+ "selector": {
+ "router": "router"
+ }
+ },
+ "status": {
+ "loadBalancer": {}
+ }
+ }
+ ]
+}'''
+
+ @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_present(self, mock_cmd, mock_tmpfile_copy, mock_write):
+ ''' Testing a create '''
+ params = {'state': 'present',
+ 'debug': False,
+ 'namespace': 'default',
+ 'name': 'router',
+ 'default_cert': None,
+ 'cert_file': None,
+ 'key_file': None,
+ 'cacert_file': None,
+ 'labels': None,
+ 'ports': ['80:80', '443:443'],
+ 'images': None,
+ 'latest_images': None,
+ 'clusterip': None,
+ 'portalip': None,
+ 'session_affinity': None,
+ 'service_type': None,
+ 'kubeconfig': '/etc/origin/master/admin.kubeconfig',
+ 'replicas': 2,
+ 'selector': 'type=infra',
+ 'service_account': 'router',
+ 'router_type': None,
+ 'host_network': None,
+ 'external_host': None,
+ 'external_host_vserver': None,
+ 'external_host_insecure': False,
+ 'external_host_partition_path': None,
+ 'external_host_username': None,
+ 'external_host_password': None,
+ 'external_host_private_key': None,
+ 'expose_metrics': False,
+ 'metrics_image': None,
+ 'stats_user': None,
+ 'stats_password': None,
+ 'stats_port': 1936,
+ 'edits': []}
+
+ mock_cmd.side_effect = [
+ (1, '', 'Error from server (NotFound): deploymentconfigs "router" not found'),
+ (1, '', 'Error from server (NotFound): service "router" not found'),
+ (1, '', 'Error from server (NotFound): serviceaccount "router" not found'),
+ (1, '', 'Error from server (NotFound): secret "router-certs" not found'),
+ (1, '', 'Error from server (NotFound): clsuterrolebinding "router-router-role" not found'),
+ (0, RouterTest.dry_run, ''),
+ (0, '', ''),
+ (0, '', ''),
+ (0, '', ''),
+ (0, '', ''),
+ (0, '', ''),
+ ]
+
+ mock_tmpfile_copy.side_effect = [
+ '/tmp/mocked_kubeconfig',
+ ]
+
+ results = Router.run_ansible(params, False)
+
+ self.assertTrue(results['changed'])
+ for result in results['results']['results']:
+ self.assertEqual(result['returncode'], 0)
+
+ mock_cmd.assert_has_calls([
+ mock.call(['oc', 'get', 'dc', 'router', '-o', 'json', '-n', 'default'], None),
+ mock.call(['oc', 'get', 'svc', 'router', '-o', 'json', '-n', 'default'], None),
+ 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', '--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),
+ mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None)])
+
+ @unittest.skipIf(six.PY3, 'py2 test only')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
+ ''' Testing binary lookup fallback '''
+
+ mock_env_get.side_effect = lambda _v, _d: ''
+
+ mock_path_exists.side_effect = lambda _: False
+
+ self.assertEqual(locate_oc_binary(), 'oc')
+
+ @unittest.skipIf(six.PY3, 'py2 test only')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
+ ''' Testing binary lookup in path '''
+
+ oc_bin = '/usr/bin/oc'
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_path_exists.side_effect = lambda f: f == oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY3, 'py2 test only')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
+ ''' Testing binary lookup in /usr/local/bin '''
+
+ oc_bin = '/usr/local/bin/oc'
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_path_exists.side_effect = lambda f: f == oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY3, 'py2 test only')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
+ ''' Testing binary lookup in ~/bin '''
+
+ oc_bin = os.path.expanduser('~/bin/oc')
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_path_exists.side_effect = lambda f: f == oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY2, 'py3 test only')
+ @mock.patch('shutil.which')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
+ ''' Testing binary lookup fallback '''
+
+ mock_env_get.side_effect = lambda _v, _d: ''
+
+ mock_shutil_which.side_effect = lambda _f, path=None: None
+
+ self.assertEqual(locate_oc_binary(), 'oc')
+
+ @unittest.skipIf(six.PY2, 'py3 test only')
+ @mock.patch('shutil.which')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
+ ''' Testing binary lookup in path '''
+
+ oc_bin = '/usr/bin/oc'
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_shutil_which.side_effect = lambda _f, path=None: oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY2, 'py3 test only')
+ @mock.patch('shutil.which')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
+ ''' Testing binary lookup in /usr/local/bin '''
+
+ oc_bin = '/usr/local/bin/oc'
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_shutil_which.side_effect = lambda _f, path=None: oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
+
+ @unittest.skipIf(six.PY2, 'py3 test only')
+ @mock.patch('shutil.which')
+ @mock.patch('os.environ.get')
+ def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
+ ''' Testing binary lookup in ~/bin '''
+
+ oc_bin = os.path.expanduser('~/bin/oc')
+
+ mock_env_get.side_effect = lambda _v, _d: '/bin:/usr/bin'
+
+ mock_shutil_which.side_effect = lambda _f, path=None: oc_bin
+
+ self.assertEqual(locate_oc_binary(), oc_bin)
diff --git a/roles/openshift_excluder/meta/main.yml b/roles/openshift_excluder/meta/main.yml
index 8bca38e77..4d1c1efca 100644
--- a/roles/openshift_excluder/meta/main.yml
+++ b/roles/openshift_excluder/meta/main.yml
@@ -13,3 +13,4 @@ galaxy_info:
- cloud
dependencies:
- { role: openshift_facts }
+- { role: openshift_repos }
diff --git a/roles/openshift_excluder/tasks/adjust.yml b/roles/openshift_excluder/tasks/adjust.yml
index 6f4070c3d..2535b9ea6 100644
--- a/roles/openshift_excluder/tasks/adjust.yml
+++ b/roles/openshift_excluder/tasks/adjust.yml
@@ -20,4 +20,4 @@
# disable it if the docker excluder is enabled
disable_openshift_excluder: "{{ openshift_excluder_on | bool }}"
when:
- - not openshift.common.is_containerized | bool
+ - not openshift.common.is_atomic | bool
diff --git a/roles/openshift_excluder/tasks/enable.yml b/roles/openshift_excluder/tasks/enable.yml
index ef6fc4a01..413c7b5cf 100644
--- a/roles/openshift_excluder/tasks/enable.yml
+++ b/roles/openshift_excluder/tasks/enable.yml
@@ -18,4 +18,4 @@
enable_openshift_excluder: "{{ not disable_openshift_excluder_override | default(not openshift_excluder_on) | bool }}"
when:
- - not openshift.common.is_containerized | bool
+ - not openshift.common.is_atomic | bool
diff --git a/roles/openshift_excluder/tasks/exclude.yml b/roles/openshift_excluder/tasks/exclude.yml
index ee0ad8a0b..af9824aae 100644
--- a/roles/openshift_excluder/tasks/exclude.yml
+++ b/roles/openshift_excluder/tasks/exclude.yml
@@ -17,4 +17,4 @@
when:
- enable_openshift_excluder | default(false) | bool
when:
- - not openshift.common.is_containerized | bool
+ - not openshift.common.is_atomic | bool
diff --git a/roles/openshift_excluder/tasks/install.yml b/roles/openshift_excluder/tasks/install.yml
index 01fe5da55..dcc8df0cb 100644
--- a/roles/openshift_excluder/tasks/install.yml
+++ b/roles/openshift_excluder/tasks/install.yml
@@ -18,4 +18,4 @@
when:
- install_openshift_excluder | default(true) | bool
when:
- - not openshift.common.is_containerized | bool
+ - not openshift.common.is_atomic | bool
diff --git a/roles/openshift_excluder/tasks/status.yml b/roles/openshift_excluder/tasks/status.yml
index 3b6821244..363ccdbea 100644
--- a/roles/openshift_excluder/tasks/status.yml
+++ b/roles/openshift_excluder/tasks/status.yml
@@ -81,4 +81,4 @@
- "{{ docker_excluder_on }}"
when:
- - not openshift.common.is_containerized | bool
+ - not openshift.common.is_atomic | bool
diff --git a/roles/openshift_excluder/tasks/unexclude.yml b/roles/openshift_excluder/tasks/unexclude.yml
index 4df92bc65..196ca25f5 100644
--- a/roles/openshift_excluder/tasks/unexclude.yml
+++ b/roles/openshift_excluder/tasks/unexclude.yml
@@ -16,4 +16,4 @@
- disable_openshift_excluder | default(false) | bool
when:
- - not openshift.common.is_containerized | bool
+ - not openshift.common.is_atomic | bool