Ejemplo n.º 1
0
 def ping(self):
     """
     Add a key to the `config.etcd_path` with a TTL of `config.ping_ttl`.
     A wrapper around `client.add_key`.
     """
     path = '{prefix}/{hostname}'.format(prefix=self._config.etcd_path,
                                         hostname=util.get_hostname())
     response = self._client.write(path,
                                   time.time(),
                                   ttl=self._config.ping_ttl)
     if response.action == 'set':
         # TODO(retr0h): log
         print 'ping -> [ok]'
Ejemplo n.º 2
0
    def test_get_hostname(self, mocked):
        mocked.return_value = 'mocked-fqdn'
        result = util.get_hostname()

        self.assertEquals('mocked-fqdn', result)