From 2e1e9cdaf549e069f30fab1f102cdf83dbb49aca Mon Sep 17 00:00:00 2001 From: heavenshell Date: Sun, 15 Mar 2015 14:15:21 +0900 Subject: [PATCH] Add comment headers. --- mackerel/host.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mackerel/host.py b/mackerel/host.py index c4b001b..c6d27e1 100644 --- a/mackerel/host.py +++ b/mackerel/host.py @@ -3,7 +3,7 @@ mackerel.host ~~~~~~~~~~~~~ - Mackerel client implemented by Pyton. + Mackerel client implemented by Python. Ported from `mackerel-client-ruby`. @@ -19,6 +19,19 @@ class Host(object): MACKEREL_INTERFACE_NAME_PATTERN = re.compile(r'^eth\d') def __init__(self, **kwargs): + """Construct a host. + + :param name: Host name + :param meta: Host metadata + :param type: Host type + :param status: Host status + :param memo: Host memo + :param is_retired: Retired flag + :param id: Host id + :param created_at: Created datetime + :param roles: Host roles + :param interfaces: Host interfaces + """ self.args = kwargs self.name = kwargs.get('name', None) self.meta = kwargs.get('meta', None) @@ -32,11 +45,13 @@ def __init__(self, **kwargs): self.interfaces = kwargs.get('interfaces', None) def ip_addr(self): + """Get ipaddress.""" for i in self.interfaces: if self.MACKEREL_INTERFACE_NAME_PATTERN.search(i['name']): return i['ipAddress'] def mac_addr(self): + """Get MAC address.""" for i in self.interfaces: if self.MACKEREL_INTERFACE_NAME_PATTERN.search(i['name']): return i['macAddress']