From: Leandro Lucarella Date: Mon, 24 Sep 2007 20:59:20 +0000 (-0300) Subject: Add DhcpHandler.get() and HostHandler.get() to get a single value. X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/2caea9b817885fc1dcb6b1feaf7a06a8a6f54aac?ds=sidebyside Add DhcpHandler.get() and HostHandler.get() to get a single value. As a show() companion, new get() commands are added to get the information about a single DHCP parameter or host. --- diff --git a/services/dhcp/__init__.py b/services/dhcp/__init__.py index d7c185c..1df0062 100644 --- a/services/dhcp/__init__.py +++ b/services/dhcp/__init__.py @@ -148,6 +148,17 @@ class HostHandler: raise HostNotFoundError(name) del self.hosts[name] + @handler + def get(self, name): + r"""get(name) -> CSV string :: List all the information of a host. + + The host is returned as a CSV list of: hostname,ip,mac + """ + if not name in self.hosts: + raise HostNotFoundError(name) + h = self.hosts[name] + return '%s,%s,%s' % (h.name, h.ip, h.mac) + @handler def list(self): r"""list() -> CSV string :: List all the hostnames. @@ -211,6 +222,13 @@ class DhcpHandler: raise ParameterNotFoundError(param) self.vars[param] = value + @handler + def get(self, param): + r"get(param) -> None :: Get a DHCP parameter." + if not param in self.vars: + raise ParameterNotFoundError(param) + return self.vars[param] + @handler def list(self): r"""list() -> CSV string :: List all the parameter names.