Skip to content

Commit

Permalink
Bugfix in incorrects links inside containers
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Jan 12, 2016
1 parent 520516d commit 111846b
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions IM/REST.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,11 @@ def RESTGetInfrastructureInfo(id=None):
try:
vm_ids = InfrastructureManager.GetInfrastructureInfo(id, auth)
res = ""

server_ip = bottle.request.environ['HTTP_HOST'].split(":")[0]
server_port = bottle.request.environ['HTTP_HOST'].split(":")[1]

for vm_id in vm_ids:
if res:
res += "\n"
res += 'http://' + server_ip + ':' + server_port + '/infrastructures/' + str(id) + '/vms/' + str(vm_id)
res += 'http://' + bottle.request.environ['HTTP_HOST'] + '/infrastructures/' + str(id) + '/vms/' + str(vm_id)

bottle.response.content_type = "text/uri-list"
return res
Expand Down Expand Up @@ -189,12 +186,9 @@ def RESTGetInfrastructureList():
try:
inf_ids = InfrastructureManager.GetInfrastructureList(auth)

server_ip = bottle.request.environ['HTTP_HOST'].split(":")[0]
server_port = bottle.request.environ['HTTP_HOST'].split(":")[1]

res = ""
for inf_id in inf_ids:
res += "http://" + server_ip + ":" + server_port + "/infrastructures/" + str(inf_id) + "\n"
res += "http://" + bottle.request.environ['HTTP_HOST'] + "/infrastructures/" + str(inf_id) + "\n"

bottle.response.content_type = "text/uri-list"
return res
Expand All @@ -217,12 +211,9 @@ def RESTCreateInfrastructure():
try:
radl_data = bottle.request.body.read()
inf_id = InfrastructureManager.CreateInfrastructure(radl_data, auth)

server_ip = bottle.request.environ['HTTP_HOST'].split(":")[0]
server_port = bottle.request.environ['HTTP_HOST'].split(":")[1]

bottle.response.content_type = "text/uri-list"
return "http://" + server_ip + ":" + server_port + "/infrastructures/" + str(inf_id)
return "http://" + bottle.request.environ['HTTP_HOST'] + "/infrastructures/" + str(inf_id)
except UnauthorizedUserException, ex:
bottle.abort(401, "Error Getting Inf. info: " + str(ex))
return False
Expand Down Expand Up @@ -310,15 +301,12 @@ def RESTAddResource(id=None):

radl_data = bottle.request.body.read()
vm_ids = InfrastructureManager.AddResource(id, radl_data, auth, context)

server_ip = bottle.request.environ['HTTP_HOST'].split(":")[0]
server_port = bottle.request.environ['HTTP_HOST'].split(":")[1]

res = ""
for vm_id in vm_ids:
if res:
res += "\n"
res += "http://" + server_ip + ":" + server_port + "/infrastructures/" + str(id) + "/vms/" + str(vm_id)
res += "http://" + bottle.request.environ['HTTP_HOST'] + "/infrastructures/" + str(id) + "/vms/" + str(vm_id)

bottle.response.content_type = "text/uri-list"
return res
Expand Down

0 comments on commit 111846b

Please sign in to comment.