summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/library/oc_adm_registry.py
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2017-03-01 16:34:48 -0500
committerGitHub <noreply@github.com>2017-03-01 16:34:48 -0500
commitef3aa534d7b54c92c076f89c91f514972ba64612 (patch)
tree6031a633254d5e0a6803186a88e4ff0bb14599b3 /roles/lib_openshift/library/oc_adm_registry.py
parent0a782a06d49942dadb2b8d51509e94f656570ec4 (diff)
parente62a4bf341637bc26503a9ba5246afb9b016ea36 (diff)
downloadopenshift-ef3aa534d7b54c92c076f89c91f514972ba64612.tar.gz
openshift-ef3aa534d7b54c92c076f89c91f514972ba64612.tar.bz2
openshift-ef3aa534d7b54c92c076f89c91f514972ba64612.tar.xz
openshift-ef3aa534d7b54c92c076f89c91f514972ba64612.zip
Merge pull request #3493 from kwoodson/registry_reencyrpt_route
Adding support for a route with reencrypt and certificates.
Diffstat (limited to 'roles/lib_openshift/library/oc_adm_registry.py')
-rw-r--r--roles/lib_openshift/library/oc_adm_registry.py55
1 files changed, 37 insertions, 18 deletions
diff --git a/roles/lib_openshift/library/oc_adm_registry.py b/roles/lib_openshift/library/oc_adm_registry.py
index 7908dd91e..62018d758 100644
--- a/roles/lib_openshift/library/oc_adm_registry.py
+++ b/roles/lib_openshift/library/oc_adm_registry.py
@@ -1387,8 +1387,8 @@ class Utils(object):
elif value != user_def[key]:
if debug:
print('value should be identical')
- print(value)
print(user_def[key])
+ print(value)
return False
# recurse on a dictionary
@@ -1408,8 +1408,8 @@ class Utils(object):
if api_values != user_values:
if debug:
print("keys are not equal in dict")
- print(api_values)
print(user_values)
+ print(api_values)
return False
result = Utils.check_def_equal(user_def[key], value, skip_keys=skip_keys, debug=debug)
@@ -1985,6 +1985,7 @@ class Service(Yedit):
port_path = "spec.ports"
portal_ip = "spec.portalIP"
cluster_ip = "spec.clusterIP"
+ selector_path = 'spec.selector'
kind = 'Service'
def __init__(self, content):
@@ -1995,6 +1996,10 @@ class Service(Yedit):
''' get a list of ports '''
return self.get(Service.port_path) or []
+ def get_selector(self):
+ ''' get the service selector'''
+ return self.get(Service.selector_path) or {}
+
def add_ports(self, inc_ports):
''' add a port object to the ports list '''
if not isinstance(inc_ports, list):
@@ -2244,7 +2249,7 @@ class Registry(OpenShiftCLI):
if result['returncode'] == 0 and part['kind'] == 'dc':
self.deploymentconfig = DeploymentConfig(result['results'][0])
elif result['returncode'] == 0 and part['kind'] == 'svc':
- self.service = Yedit(content=result['results'][0])
+ self.service = Service(result['results'][0])
if result['returncode'] != 0:
rval = result['returncode']
@@ -2255,7 +2260,7 @@ class Registry(OpenShiftCLI):
def exists(self):
'''does the object exist?'''
self.get()
- if self.deploymentconfig or self.service:
+ if self.deploymentconfig and self.service:
return True
return False
@@ -2314,6 +2319,9 @@ class Registry(OpenShiftCLI):
if self.portal_ip:
service.put('spec.portalIP', self.portal_ip)
+ # the dry-run doesn't apply the selector correctly
+ 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)
deployment_file = Utils.create_tmp_file_from_contents('deploymentconfig', deploymentconfig.yaml_dict)
@@ -2328,8 +2336,20 @@ class Registry(OpenShiftCLI):
def create(self):
'''Create a registry'''
results = []
- for config_file in ['deployment_file', 'service_file']:
- results.append(self._create(self.prepared_registry[config_file]))
+ self.needs_update()
+ # if the object is none, then we need to create it
+ # if the object needs an update, then we should call replace
+ # Handle the deploymentconfig
+ if self.deploymentconfig is None:
+ results.append(self._create(self.prepared_registry['deployment_file']))
+ elif self.prepared_registry['deployment_update']:
+ results.append(self._replace(self.prepared_registry['deployment_file']))
+
+ # Handle the service
+ if self.service is None:
+ results.append(self._create(self.prepared_registry['service_file']))
+ elif self.prepared_registry['service_update']:
+ results.append(self._replace(self.prepared_registry['service_file']))
# Clean up returned results
rval = 0
@@ -2341,7 +2361,7 @@ class Registry(OpenShiftCLI):
return {'returncode': rval, 'results': results}
def update(self):
- '''run update for the registry. This performs a delete and then create '''
+ '''run update for the registry. This performs a replace if required'''
# Store the current service IP
if self.service:
svcip = self.service.get('spec.clusterIP')
@@ -2415,14 +2435,12 @@ class Registry(OpenShiftCLI):
def needs_update(self):
''' check to see if we need to update '''
- if not self.service or not self.deploymentconfig:
- return True
-
exclude_list = ['clusterIP', 'portalIP', 'type', 'protocol']
- if not Utils.check_def_equal(self.prepared_registry['service'].yaml_dict,
- self.service.yaml_dict,
- exclude_list,
- debug=self.verbose):
+ if self.service is None or \
+ not Utils.check_def_equal(self.prepared_registry['service'].yaml_dict,
+ self.service.yaml_dict,
+ exclude_list,
+ debug=self.verbose):
self.prepared_registry['service_update'] = True
exclude_list = ['dnsPolicy',
@@ -2438,10 +2456,11 @@ class Registry(OpenShiftCLI):
'activeDeadlineSeconds', # added in 1.5 for timeouts
]
- if not Utils.check_def_equal(self.prepared_registry['deployment'].yaml_dict,
- self.deploymentconfig.yaml_dict,
- exclude_list,
- debug=self.verbose):
+ if self.deploymentconfig is None or \
+ not Utils.check_def_equal(self.prepared_registry['deployment'].yaml_dict,
+ self.deploymentconfig.yaml_dict,
+ exclude_list,
+ debug=self.verbose):
self.prepared_registry['deployment_update'] = True
return self.prepared_registry['deployment_update'] or self.prepared_registry['service_update'] or False