2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-17 13:13:18 +00:00

Correct behavior of various paths when node does not exist

This commit is contained in:
Jarrod Johnson 2014-08-26 14:03:15 -04:00
parent 6fc75d8394
commit 276ba4abd7
4 changed files with 12 additions and 4 deletions

View File

@ -415,6 +415,8 @@ class ConsoleSession(object):
def __init__(self, node, configmanager, username, datacallback=None):
self.tenant = configmanager.tenant
if not configmanager.is_node(node):
raise exc.NotFoundException("Invalid node")
consk = (node, self.tenant)
self.ckey = consk
self.username = username

View File

@ -311,6 +311,8 @@ def handle_path(path, operation, configmanager, inputdata=None):
#single node request of some sort
try:
node = pathcomponents[1]
if not configmanager.is_node(node):
raise exc.NotFoundException("Invalid Node")
except IndexError: # doesn't actually have a long enough path
# this is enumerating a list of nodes
if operation == "delete":

View File

@ -300,9 +300,14 @@ def resourcehandler_backend(env, start_response):
auditmsg['tenant'] = authorized['tenant']
auditlog.log(auditmsg)
# Request for new session
consession = consoleserver.ConsoleSession(
node=nodename, configmanager=cfgmgr,
username=authorized['username'])
try:
consession = consoleserver.ConsoleSession(
node=nodename, configmanager=cfgmgr,
username=authorized['username'])
except exc.NotFoundException:
start_response("404 Not found", headers)
yield "404 - Request Path not recognized"
return
if not consession:
start_response("500 Internal Server Error", headers)
return

View File

@ -128,7 +128,6 @@ def send_response(responses, connection):
def process_request(connection, request, cfm, authdata, authname, skipauth):
#TODO(jbjohnso): authorize each request
if not isinstance(request, dict):
raise ValueError
operation = request['operation']