From 4d8df54bd8449a350e3eba59d9598b50d2e727ff Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Wed, 1 Mar 2017 11:04:50 -0500 Subject: Fixed docs. Added check for delete failures. Updated namespace to None. --- roles/lib_openshift/src/class/oc_project.py | 6 ++++-- roles/lib_openshift/src/lib/project.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'roles/lib_openshift/src') diff --git a/roles/lib_openshift/src/class/oc_project.py b/roles/lib_openshift/src/class/oc_project.py index cf378ef6d..642d85375 100644 --- a/roles/lib_openshift/src/class/oc_project.py +++ b/roles/lib_openshift/src/class/oc_project.py @@ -4,7 +4,7 @@ # pylint: disable=too-many-instance-attributes class OCProject(OpenShiftCLI): - ''' Class to wrap the oc command line tools ''' + ''' Project Class to manage project/namespace objects''' kind = 'namespace' def __init__(self, @@ -86,7 +86,6 @@ class OCProject(OpenShiftCLI): if result != self.config.config_options['node_selector']['value']: return True - # Check rolebindings and policybindings return False # pylint: disable=too-many-return-statements,too-many-branches @@ -131,6 +130,9 @@ class OCProject(OpenShiftCLI): api_rval = oadm_project.delete() + if api_rval['returncode'] != 0: + return {'failed': True, 'msg': api_rval} + return {'changed': True, 'results': api_rval, 'state': state} return {'changed': False, 'state': state} diff --git a/roles/lib_openshift/src/lib/project.py b/roles/lib_openshift/src/lib/project.py index a06f83d78..40994741c 100644 --- a/roles/lib_openshift/src/lib/project.py +++ b/roles/lib_openshift/src/lib/project.py @@ -6,24 +6,25 @@ class ProjectConfig(OpenShiftCLIConfig): ''' project config object ''' def __init__(self, rname, namespace, kubeconfig, project_options): - super(ProjectConfig, self).__init__(rname, rname, kubeconfig, project_options) + super(ProjectConfig, self).__init__(rname, None, kubeconfig, project_options) + class Project(Yedit): ''' Class to wrap the oc command line tools ''' annotations_path = "metadata.annotations" - kind = 'Service' + kind = 'Project' annotation_prefix = 'openshift.io/' def __init__(self, content): - '''Service constructor''' + '''Project constructor''' super(Project, self).__init__(content=content) def get_annotations(self): - ''' get a list of ports ''' + ''' return the annotations''' return self.get(Project.annotations_path) or {} def add_annotations(self, inc_annos): - ''' add a port object to the ports list ''' + ''' add an annotation to the other annotations''' if not isinstance(inc_annos, list): inc_annos = [inc_annos] @@ -38,7 +39,7 @@ class Project(Yedit): return True def find_annotation(self, key): - ''' find a specific port ''' + ''' find an annotation''' annotations = self.get_annotations() for anno in annotations: if Project.annotation_prefix + key == anno: @@ -66,7 +67,7 @@ class Project(Yedit): return removed def update_annotation(self, key, value): - ''' remove an annotation from a project''' + ''' remove an annotation for a project''' annos = self.get(Project.annotations_path) or {} if not annos: -- cgit v1.2.3