Skip to content

Commit b1f6a2c

Browse files
committed
Don't fail on missing Delete interfaces
On the DELETE HTTP request, don't immediately fail if the specified bus does't provide the delete interface on the specified path, just skip it instead. Only return the 403 error if nothing at all ended up being deleted on the request. This allows multiple services to host the same object path while only requiring one to support the delete interface. The others will just listen for the interfaces removed signal to remove their objects. Resolves openbmc/openbmc#3181 Tested: * Issue a -X DELETE with curl on a path provided by multiple services where only 1 provides the delete interface. * Issue a -X POST .../action/delete with curl with the same test setup. * Issue a -X DELETE with curl on a path without a delete interface and get a 403 back. Change-Id: Ib76c80081361160e617ddfe8b48e3e4588abce67 Signed-off-by: Matt Spinler <[email protected]>
1 parent 5706861 commit b1f6a2c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

module/obmc/wsgi/apps/rest_dbus.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -600,15 +600,18 @@ def do_put(self, path):
600600
path, p, v)
601601

602602
def do_delete(self, path):
603-
for bus_info in request.route_data['map'][path].items():
604-
if self.bus_missing_delete(path, *bus_info):
605-
abort(403, _4034_msg % ('resource', 'removed', path))
606-
607-
for bus in request.route_data['map'][path].keys():
608-
self.delete_on_bus(path, bus)
609-
610-
def bus_missing_delete(self, path, bus, interfaces):
611-
return DELETE_IFACE not in interfaces
603+
deleted = False
604+
for bus, interfaces in request.route_data['map'][path].items():
605+
if self.bus_has_delete(interfaces):
606+
self.delete_on_bus(path, bus)
607+
deleted = True
608+
609+
#It's OK if some objects didn't have a Delete, but not all
610+
if not deleted:
611+
abort(403, _4034_msg % ('resource', 'removed', path))
612+
613+
def bus_has_delete(self, interfaces):
614+
return DELETE_IFACE in interfaces
612615

613616
def delete_on_bus(self, path, bus):
614617
obj = self.bus.get_object(bus, path, introspect=False)

0 commit comments

Comments
 (0)