diff --git a/Dockerfile b/Dockerfile index eaaec93..765e70e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ENV DEBIAN_FRONTEND noninteractive # - remove defunct packages # - start supervisor # -RUN apt-get -y update && apt-get -y upgrade && apt-get -y install git curl python python-requests supervisor +RUN apt-get -y update && apt-get -y upgrade && apt-get -y install git python python-requests supervisor RUN curl https://bootstrap.pypa.io/get-pip.py | python ADD resources/supervisor/supervisord.conf /etc/supervisor/supervisord.conf RUN pip install git+https://github.com/autodesk-cloud/ochopod.git diff --git a/ochopod/bindings/ec2/kubernetes.py b/ochopod/bindings/ec2/kubernetes.py index 48de1ec..744ac6e 100644 --- a/ochopod/bindings/ec2/kubernetes.py +++ b/ochopod/bindings/ec2/kubernetes.py @@ -31,7 +31,7 @@ from pykka import ThreadingFuture from pykka.exceptions import Timeout, ActorDeadError from flask import Flask, request -from requests import post +import requests from requests.auth import HTTPBasicAuth #: Our ochopod logger. @@ -106,9 +106,9 @@ def boot(self, lifecycle, model=Reactive, local=0): # - we'll retrieve the underlying metadata using curl # def _aws(token): - code, lines = shell('curl -f http://169.254.169.254/latest/meta-data/%s' % token) - assert code is 0, 'unable to lookup EC2 metadata for %s (are you running on EC2 ?)' % token - return lines[0] + result = requests.get('http://169.254.169.254/latest/meta-data/%s' % token) + assert result.status_code is requests.codes.ok, 'unable to lookup EC2 metadata for %s (are you running on EC2 ?)' % token + return result.text[0] # # - lame workaround to fetch the master IP and credentials as there does not seem to be a way to @@ -117,9 +117,10 @@ def _aws(token): # - don't forget to merge the resulting output # def _k8s(token): - code, lines = shell('curl -f -u %s:%s -k https://%s/api/v1beta3/namespaces/default/%s' % (env['KUBERNETES_USER'], env['KUBERNETES_PWD'], env['KUBERNETES_MASTER'], token)) - assert code is 0, 'unable to look the RO service up (is the master running ?)' - return json.loads(''.join(lines)) + result = requests.get('https://%s//api/v1beta3/namespaces/default/%s' % (env['KUBERNETES_MASTER'], token), + auth=(env['KUBERNETES_USER'], env['KUBERNETES_PWD'])) + assert result.status_code is requests.codes.ok, 'unable to look the RO service up (is the master running ?)' + return result.json() # # - look our local k8s pod up @@ -333,7 +334,7 @@ def run(self): # shutdown(executor) shutdown(coordinator) - post('http://127.0.0.1:%s/terminate' % env['ochopod_port']) + requests.post('http://127.0.0.1:%s/terminate' % env['ochopod_port']) except KeyboardInterrupt: @@ -343,4 +344,4 @@ def run(self): logger.fatal('unexpected condition -> %s' % diagnostic(failure)) - exit(1) \ No newline at end of file + exit(1) diff --git a/ochopod/bindings/ec2/marathon.py b/ochopod/bindings/ec2/marathon.py index c57eba6..df783e7 100644 --- a/ochopod/bindings/ec2/marathon.py +++ b/ochopod/bindings/ec2/marathon.py @@ -31,7 +31,7 @@ from pykka import ThreadingFuture from pykka.exceptions import Timeout, ActorDeadError from flask import Flask, request -from requests import post +import requests #: Our ochopod logger. logger = logging.getLogger('ochopod') @@ -119,9 +119,9 @@ def boot(self, lifecycle, model=Reactive, local=0): # - get our underlying metadata using curl # def _peek(token, strict=True): - code, lines = shell('curl -f http://169.254.169.254/latest/meta-data/%s' % token) - assert not strict or code is 0, 'unable to lookup EC2 metadata for %s (are you running on EC2 ?)' % token - return lines[0] + result = requests.get('http://169.254.169.254/latest/meta-data/%s' % token) + assert not strict or result.status_code is requests.codes.ok, 'unable to lookup EC2 metadata for %s (are you running on EC2 ?)' % token + return result.text[0] # # - get our local and public IPV4 addresses @@ -335,7 +335,7 @@ def run(self): # shutdown(executor) shutdown(coordinator) - post('http://127.0.0.1:%s/terminate' % env['ochopod_port']) + requests.post('http://127.0.0.1:%s/terminate' % env['ochopod_port']) except KeyboardInterrupt: @@ -343,4 +343,4 @@ def run(self): except Exception as failure: - logger.fatal('unexpected condition -> %s' % diagnostic(failure)) \ No newline at end of file + logger.fatal('unexpected condition -> %s' % diagnostic(failure))