aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_interface
diff options
context:
space:
mode:
authorThomas Duval <thomas.duval@orange.com>2017-11-06 14:02:18 +0100
committerThomas Duval <thomas.duval@orange.com>2017-11-06 14:06:10 +0100
commit9519d179cda8734fa0890d136c4bd2019bb7ddc4 (patch)
tree48b0c8b882f574e0f93ae5e087878e2700e40c0d /moonv4/moon_interface
parentb372140e577ca5d850875139fde6e36ae0e868d4 (diff)
Fix the bug on the connection between interface and authz.
Change-Id: Iea2f763fb2cfb90250be76d91cb2fe0e9b481716
Diffstat (limited to 'moonv4/moon_interface')
-rw-r--r--moonv4/moon_interface/Dockerfile2
-rw-r--r--moonv4/moon_interface/moon_interface/authz_requests.py29
2 files changed, 14 insertions, 17 deletions
diff --git a/moonv4/moon_interface/Dockerfile b/moonv4/moon_interface/Dockerfile
index 1bc7e87c..268aba48 100644
--- a/moonv4/moon_interface/Dockerfile
+++ b/moonv4/moon_interface/Dockerfile
@@ -6,7 +6,7 @@ RUN pip3 install moon_utilities moon_db pip --upgrade
ADD . /root
WORKDIR /root/
RUN pip3 install -r requirements.txt --upgrade
-RUN pip3 install /root/dist/* --upgrade
+#RUN pip3 install /root/dist/* --upgrade
RUN pip3 install .
CMD ["python3", "-m", "moon_interface"] \ No newline at end of file
diff --git a/moonv4/moon_interface/moon_interface/authz_requests.py b/moonv4/moon_interface/moon_interface/authz_requests.py
index 10356787..b6b0e58e 100644
--- a/moonv4/moon_interface/moon_interface/authz_requests.py
+++ b/moonv4/moon_interface/moon_interface/authz_requests.py
@@ -28,8 +28,6 @@ class AuthzRequest:
self.context = Context(ctx, CACHE)
self.args = args
self.request_id = ctx["request_id"]
- # LOG.info("container={}".format(CACHE.containers))
- # LOG.info("container_chaining={}".format(CACHE.container_chaining))
if ctx['project_id'] not in CACHE.container_chaining:
raise exceptions.KeystoneProjectError("Unknown Project ID {}".format(ctx['project_id']))
self.container_chaining = CACHE.container_chaining[ctx['project_id']]
@@ -40,36 +38,35 @@ class AuthzRequest:
def run(self):
self.context.delete_cache()
+ req = None
try:
- LOG.debug("url=http://{}:{}/authz".format(
- self.container_chaining[0]["hostname"],
- self.container_chaining[0]["port"]))
req = requests.post("http://{}:{}/authz".format(
- self.container_chaining[0]["hostname"],
+ self.container_chaining[0]["hostip"],
self.container_chaining[0]["port"],
), data=pickle.dumps(self.context))
if req.status_code != 200:
- # LOG.error("Cannot connect to {}".format(
- # "http://{}:{}/authz".format(
- # self.container_chaining[0]["hostname"],
- # self.container_chaining[0]["port"]
- # )))
+ # LOG.error("req={}".format(req))
raise exceptions.AuthzException(
"Receive bad response from Authz function "
- "(with hostname - {})".format(
+ "(with IP address - {})".format(
req.status_code
))
except requests.exceptions.ConnectionError:
+ LOG.error("Cannot connect to {}".format(
+ "http://{}:{}/authz".format(
+ self.container_chaining[0]["hostip"],
+ self.container_chaining[0]["port"]
+ )))
+ except ValueError:
try:
req = requests.post("http://{}:{}/authz".format(
- self.container_chaining[0]["hostip"],
+ self.container_chaining[0]["hostname"],
self.container_chaining[0]["port"],
), data=pickle.dumps(self.context))
if req.status_code != 200:
- # LOG.error("req={}".format(req))
raise exceptions.AuthzException(
"Receive bad response from Authz function "
- "(with IP address - {})".format(
+ "(with hostname - {})".format(
req.status_code
))
except requests.exceptions.ConnectionError:
@@ -81,7 +78,7 @@ class AuthzRequest:
raise exceptions.AuthzException(
"Cannot connect to Authz function with IP address")
self.context.set_cache(CACHE)
- if len(self.container_chaining) == 1:
+ if req and len(self.container_chaining) == 1:
# req.raw.decode_content = True
self.result = pickle.loads(req.content)