Merge "Retrieve the swift version with recon"
This commit is contained in:
commit
1b283d47cd
@ -16,6 +16,7 @@
|
||||
import errno
|
||||
import os
|
||||
|
||||
from swift import __version__ as swiftver
|
||||
from swift.common.swob import Request, Response
|
||||
from swift.common.utils import get_logger, config_true_value, json
|
||||
from swift.common.constraints import check_mount
|
||||
@ -77,6 +78,11 @@ class ReconMiddleware(object):
|
||||
self.logger.exception(_('Error retrieving recon data'))
|
||||
return dict((key, None) for key in cache_keys)
|
||||
|
||||
def get_version(self):
|
||||
"""get swift version"""
|
||||
verinfo = {'version': swiftver}
|
||||
return verinfo
|
||||
|
||||
def get_mounted(self, openr=open):
|
||||
"""get ALL mounted fs from /proc/mounts"""
|
||||
mounts = []
|
||||
@ -305,6 +311,8 @@ class ReconMiddleware(object):
|
||||
content = self.get_quarantine_count()
|
||||
elif rcheck == "sockstat":
|
||||
content = self.get_socket_info()
|
||||
elif rcheck == "version":
|
||||
content = self.get_version()
|
||||
else:
|
||||
content = "Invalid path: %s" % req.path
|
||||
return Response(request=req, status="404 Not Found",
|
||||
|
@ -20,8 +20,10 @@ from posix import stat_result, statvfs_result
|
||||
import os
|
||||
|
||||
import swift.common.constraints
|
||||
from swift import __version__ as swiftver
|
||||
from swift.common.swob import Request
|
||||
from swift.common.middleware import recon
|
||||
from swift.common.utils import json
|
||||
|
||||
|
||||
class FakeApp(object):
|
||||
@ -652,6 +654,11 @@ class TestReconMiddleware(unittest.TestCase):
|
||||
resp = self.app(req.environ, start_response)
|
||||
self.assertEquals(resp, get_mem_resp)
|
||||
|
||||
def test_recon_get_version(self):
|
||||
req = Request.blank('/recon/version', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = self.app(req.environ, start_response)
|
||||
self.assertEquals(resp, [json.dumps({'version': swiftver})])
|
||||
|
||||
def test_recon_get_load(self):
|
||||
get_load_resp = ['{"loadtest": "1"}']
|
||||
req = Request.blank('/recon/load', environ={'REQUEST_METHOD': 'GET'})
|
||||
|
Loading…
Reference in New Issue
Block a user