summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2018-10-02 06:27:57 -0500
committerDeepak Kodihalli <dkodihal@in.ibm.com>2018-10-02 13:43:13 -0500
commitc043cdda0b2363c04abefdce0d7f19138b00b131 (patch)
tree7d9d5d31528b9b00f37ae2ac9dbb0c3e61311dfb
parentdee2ef579be581abe0d7e1dc8873463029b30deb (diff)
downloadphosphor-rest-server-c043cdda0b2363c04abefdce0d7f19138b00b131.zip
phosphor-rest-server-c043cdda0b2363c04abefdce0d7f19138b00b131.tar.gz
certificate handler: use mapper
Use mapper to retrieve a D-Bus busname, instead of assuming a well-known busname. Change-Id: I668f750ab098b847bf3a662abdf6614170471c41 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r--module/obmc/wsgi/apps/rest_dbus.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py
index 63d0f5e..5a5aaec 100644
--- a/module/obmc/wsgi/apps/rest_dbus.py
+++ b/module/obmc/wsgi/apps/rest_dbus.py
@@ -880,11 +880,10 @@ class CertificateHandler:
file_loc = '/tmp'
file_suffix = '.pem'
file_prefix = 'cert_'
- CERT_BUSNAME = 'xyz.openbmc_project.Certs.Manager'
CERT_PATH = '/xyz/openbmc_project/certs'
CERT_IFACE = 'xyz.openbmc_project.Certs.Install'
- def do_upload(cls, cert_type, service):
+ def do_upload(cls, route_handler, cert_type, service):
def cleanup():
if os.path.exists(temp.name):
os.remove(temp.name)
@@ -911,16 +910,20 @@ class CertificateHandler:
try:
bus = dbus.SystemBus()
- busName = cls.CERT_BUSNAME + "." + cert_type.capitalize() + "." \
- + service.capitalize()
certPath = cls.CERT_PATH + "/" + cert_type + "/" + service
- obj = bus.get_object(busName, certPath)
- iface = dbus.Interface(obj, cls.CERT_IFACE)
- iface.Install(temp.name)
- except dbus.exceptions.DBusException as e:
+ intfs = route_handler.try_mapper_call(
+ route_handler.mapper.get_object, path=certPath)
+ for busname,intf in intfs.items():
+ if cls.CERT_IFACE in intf:
+ obj = bus.get_object(busName, certPath)
+ iface = dbus.Interface(obj, cls.CERT_IFACE)
+ iface.Install(temp.name)
+ cleanup()
+ return
+ abort(404, "Path not found")
+ except Exception as e:
cleanup()
abort(503, str(e))
- cleanup()
class CertificatePutHandler(RouteHandler):
@@ -935,7 +938,7 @@ class CertificatePutHandler(RouteHandler):
app, bus, self.verbs, self.rules, self.content_type)
def do_put(self, cert_type, service):
- return CertificateHandler().do_upload(cert_type, service)
+ return CertificateHandler().do_upload(self, cert_type, service)
def find(self, **kw):
pass
OpenPOWER on IntegriCloud