Merge "Make k8s.cluster.K8sCluster be used both in py2 and py3"

This commit is contained in:
Jenkins 2016-09-26 12:05:37 +00:00 committed by Gerrit Code Review
commit 315a88605a
2 changed files with 6 additions and 5 deletions

View File

@ -54,7 +54,8 @@ class K8sCluster(object):
def __init__(self, schema="https", user=None, password=None,
host='localhost', port='443', default_namespace='default'):
if user and password:
auth = base64.encodestring('%s:%s' % (user, password))[:-1]
auth_string = '%s:%s' % (user, password)
auth = base64.encodestring(auth_string.encode()).decode()[:-1]
auth = "Basic {}".format(auth)
self._client = api_client.ApiClient(
'{schema}://{host}:{port}/'.format(

View File

@ -177,10 +177,10 @@ class K8SManager(object):
'registry_templates/' \
'service-registry.yaml'
with file(registry_pod) as f:
registry = yaml.load(f)
with file(service_registry) as f:
service = yaml.load(f)
with open(registry_pod) as f:
registry = yaml.load(f.read())
with open(service_registry) as f:
service = yaml.load(f.read())
registry_pod = self.api.pods.create(body=registry, namespace='default')
self.api.services.create(body=service, namespace='default')