summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/library/oc_scale.py
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2017-02-08 12:19:45 -0500
committerGitHub <noreply@github.com>2017-02-08 12:19:45 -0500
commitbf1b4def44894ddc71d35e28c48c56078f90b947 (patch)
treeaf513224a29ed2d6d0e7f73a22428dec65258997 /roles/lib_openshift/library/oc_scale.py
parentb1565e9e843e99c6b3c0d99518c27249472f57fe (diff)
parent04ea66c4ab6cd1e5daa217526d7c9591aa164f10 (diff)
downloadopenshift-bf1b4def44894ddc71d35e28c48c56078f90b947.tar.gz
openshift-bf1b4def44894ddc71d35e28c48c56078f90b947.tar.bz2
openshift-bf1b4def44894ddc71d35e28c48c56078f90b947.tar.xz
openshift-bf1b4def44894ddc71d35e28c48c56078f90b947.zip
Merge pull request #3290 from kwoodson/tmp_admin_kubeconfig
Added tmpfile for kubeconfig. Fixed tests.
Diffstat (limited to 'roles/lib_openshift/library/oc_scale.py')
-rw-r--r--roles/lib_openshift/library/oc_scale.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/roles/lib_openshift/library/oc_scale.py b/roles/lib_openshift/library/oc_scale.py
index 63d818c66..48a629b5e 100644
--- a/roles/lib_openshift/library/oc_scale.py
+++ b/roles/lib_openshift/library/oc_scale.py
@@ -713,7 +713,7 @@ class OpenShiftCLI(object):
''' Constructor for OpenshiftCLI '''
self.namespace = namespace
self.verbose = verbose
- self.kubeconfig = kubeconfig
+ self.kubeconfig = Utils.create_tmpfile_copy(kubeconfig)
self.all_namespaces = all_namespaces
# Pylint allows only 5 arguments to be passed.
@@ -999,7 +999,18 @@ class Utils(object):
return tmp
@staticmethod
- def create_tmpfile(prefix=None):
+ def create_tmpfile_copy(inc_file):
+ '''create a temporary copy of a file'''
+ tmpfile = Utils.create_tmpfile('lib_openshift-')
+ Utils._write(tmpfile, open(inc_file).read())
+
+ # Cleanup the tmpfile
+ atexit.register(Utils.cleanup, [tmpfile])
+
+ return tmpfile
+
+ @staticmethod
+ def create_tmpfile(prefix='tmp'):
''' Generates and returns a temporary file name '''
with tempfile.NamedTemporaryFile(prefix=prefix, delete=False) as tmp: