summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2015-07-24 23:38:04 +0200
committerSol Jerome <sol.jerome@gmail.com>2015-10-13 13:11:01 -0500
commit76ab7f6e8a2392a2dbe3d9cf4cf3c7399c6fa3f2 (patch)
tree497d4662b49285394dcc464bb3f7bcba615d602e
parent64dc09e18b8a34d57c9ff6c64cc9656c1e65c29c (diff)
downloadbcfg2-76ab7f6e8a2392a2dbe3d9cf4cf3c7399c6fa3f2.tar.gz
bcfg2-76ab7f6e8a2392a2dbe3d9cf4cf3c7399c6fa3f2.tar.bz2
bcfg2-76ab7f6e8a2392a2dbe3d9cf4cf3c7399c6fa3f2.zip
Admin: Add expirecache command
Expirecache is now part of bcfg2-admin and will call expire_metadata_cache from Core via XML-RPC. This will expire the metadata cache of the supplied clients (or the complete cache if no arguments are supplied) on a running bcfg2-server.
-rw-r--r--src/lib/Bcfg2/Server/Admin.py19
-rw-r--r--src/lib/Bcfg2/Server/Core.py15
2 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Server/Admin.py b/src/lib/Bcfg2/Server/Admin.py
index b038980a1..c32b1989b 100644
--- a/src/lib/Bcfg2/Server/Admin.py
+++ b/src/lib/Bcfg2/Server/Admin.py
@@ -443,6 +443,25 @@ class Compare(AdminCmd):
print("")
+class ExpireCache(_ProxyAdminCmd):
+ """ Expire the metadata cache """
+
+ options = _ProxyAdminCmd.options + [
+ Bcfg2.Options.PositionalArgument(
+ "hostname", nargs="*", default=[],
+ help="Expire cache for the given host(s)")]
+
+ def run(self, setup):
+ clients = None
+ if setup.hostname is not None and len(setup.hostname) > 0:
+ clients = setup.hostname
+
+ try:
+ self.proxy.expire_metadata_cache(clients)
+ except Bcfg2.Client.Proxy.ProxyError:
+ self.errExit("Proxy Error: %s" % sys.exc_info()[1])
+
+
class Init(AdminCmd):
"""Interactively initialize a new repository."""
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py
index a9628c024..3db97f770 100644
--- a/src/lib/Bcfg2/Server/Core.py
+++ b/src/lib/Bcfg2/Server/Core.py
@@ -1368,6 +1368,21 @@ class Core(object):
return "This method is deprecated and will be removed in a future " + \
"release\n%s" % self.fam.set_debug(debug)
+ @exposed
+ def expire_metadata_cache(self, _, hostnames=None):
+ """ Expire the metadata cache for one or all clients
+
+ :param hostnames: A list of hostnames to expire the metadata
+ cache for or None. If None the cache of
+ all clients will be expired.
+ :type hostnames: None or list of strings
+ """
+ if hostnames is not None:
+ for hostname in hostnames:
+ self.metadata_cache.expire(hostname)
+ else:
+ self.metadata_cache.expire()
+
class NetworkCore(Core):
""" A server core that actually listens on the network, can be