2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

Fix traces when trailing slashes are omitted from node resource collections

When a url that could have been a valid resource collection with a trailing
slash hits the daemon without a trailing slash, it would fail.  Correct by
recognizing this scenario and properly handling it.
This commit is contained in:
Jarrod Johnson 2014-06-16 16:44:05 -04:00
parent 87700d6d3d
commit 1d635add9e
2 changed files with 8 additions and 22 deletions

18
TODO
View File

@ -50,22 +50,4 @@ Traceback (most recent call last):
AttributeError: 'str' object has no attribute 'iterkeys'
[root@odin ~]# confetty
/ -> cd /nodes/n3
-Jun 11 14:51:49 Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/confluent/httpapi.py", line 238, in resourcehandler
for rsp in resourcehandler_backend(env, start_response):
File "/usr/lib/python2.6/site-packages/confluent/httpapi.py", line 358, in resourcehandler_backend
extension):
File "/usr/lib/python2.6/site-packages/confluent/httpapi.py", line 406, in _assemble_html
for rsp in responses:
File "/usr/lib/python2.6/site-packages/confluent/core.py", line 168, in stripnode
for i in iterablersp:
File "/usr/lib/python2.6/site-packages/confluent/plugins/hardwaremanagement/ipmi.py", line 196, in next
retdata = self.currdata.next()
File "/usr/lib/python2.6/site-packages/confluent/plugins/hardwaremanagement/ipmi.py", line 288, in health
response = self.ipmicmd.get_health()
File "/usr/lib/python2.6/site-packages/pyghmi/ipmi/command.py", line 301, in get_health
for reading in self.get_sensor_data():
File "/usr/lib/python2.6/site-packages/pyghmi/ipmi/command.py", line 322, in get_sensor_data
raise Exception(rsp['error'])
Exception: Payload already active on another session
-try to get 'health' without trailing /

View File

@ -321,6 +321,13 @@ def handle_path(path, operation, configmanager, inputdata=None):
return iterate_collections(configmanager.list_nodes())
if len(pathcomponents) == 2:
iscollection = True
else:
try:
routespec = nested_lookup(noderesources, pathcomponents[2:])
except KeyError:
raise exc.NotFoundException("Invalid element requested")
if isinstance(routespec, dict):
iscollection = True
if iscollection:
if operation == "delete":
return delete_node_collection(pathcomponents, configmanager)
@ -330,10 +337,7 @@ def handle_path(path, operation, configmanager, inputdata=None):
raise Exception("TODO here")
del pathcomponents[0:2]
passvalue = None
try:
plugroute = nested_lookup(noderesources, pathcomponents).routeinfo
except KeyError:
raise exc.NotFoundException("Invalid element requested")
plugroute = routespec.routeinfo
inputdata = msg.get_input_message(
pathcomponents, operation, inputdata, (node,))
if 'handler' in plugroute: # fixed handler definition