[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pulp-list] Simple ping service


I have created a very simple ping service that just respond with current timestamp. I use it for my "alive" script. I prefer such a simple service because other services could likely pull some data from database. The ping service should be fast. It also does not require any authentication.

It could return the pulp version rather than current time but I did not find a way to retrieve version. I guess its not stored in the codebase yet.

What you think?

  Lukas "lzap" Zapletal
>From c118d5183c273aa54874b45f4c7ce6172b9b2dd2 Mon Sep 17 00:00:00 2001
From: Lukas Zapletal <lzap+git redhat com>
Date: Thu, 10 Feb 2011 16:40:49 +0100
Subject: [PATCH] New dummy webservice - ping

 .../server/webservices/controllers/services.py     |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/pulp/server/webservices/controllers/services.py b/src/pulp/server/webservices/controllers/services.py
index 96cfdd6..b899b11 100644
--- a/src/pulp/server/webservices/controllers/services.py
+++ b/src/pulp/server/webservices/controllers/services.py
@@ -122,12 +122,23 @@ class PackageSearch(JSONController):
         log.warning('deprecated DependencyActions.PUT called')
         return self.POST()
+class PingAction(JSONController):
+    @JSONController.error_handler
+    def GET(self):
+        """
+        Dummy call that just prints time.
+        @return: time - seconds from epoch (UTC)
+        """
+        return self.ok({ "time": int(time.time()) })
 # web.py application ----------------------------------------------------------
 URLS = (
     '/dependencies/$', 'DependencyActions',
     '/search/packages/$', 'PackageSearch',
     '/upload/$', 'UploadAction',
+    '/ping/$', 'PingAction',
 application = web.application(URLS, globals())

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]