(see previous comment about git troubles) On Mon, May 31, 2010 at 8:25 AM, Michael Hanselmann <han...@google.com> wrote: > Am 29. Mai 2010 22:27 schrieb Tom Limoncelli <t...@google.com>: >> --- a/daemons/ganeti-watcher >> +++ b/daemons/ganeti-watcher >> @@ -48,6 +49,7 @@ from ganeti import ssconf >> from ganeti import bdev >> from ganeti import hypervisor >> from ganeti.confd import client as confd_client >> +from ganeti.rapi import client as rapi_client > > Please don't do “from x import y as z” imports. Use the following (see > tools/move-instance, too). Confd should be changed, too. > > --- > from ganeti import rapi > > import ganeti.rapi.client > ---
Fixed and I also fixed the legacy code. >> @@ -595,6 +597,30 @@ def OpenStateFile(path): >> return os.fdopen(statefile_fd, "w+") >> >> >> +def IsRAPIResponding(cluster): > > IsRapiResponding (CamelCase) Fixed. >> + """Connects to RAPI port and does a simple test. >> + >> + �...@type cluster: string >> + �...@param cluster: hostname of the cluster to connect to. >> + >> + Returns: >> + True: basic tests passed. >> + False: basic tests failed. >> + """ > > Empty line at end of docstring is missing. See > http://code.google.com/p/ganeti/wiki/StyleGuide. Fixed. >> + ssl_config = rapi_client.CertAuthorityVerify(constants.RAPI_CERT_FILE) >> + try: >> + master_version = rapi_client.GanetiRapiClient( >> + cluster, > > Don't wrap after opening parenthesis. Brought into compliance with http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Indentation (4-space hanging indent; nothing on first line) > master_version = \ > rapi.client.GanetiRapiClient(cluster, > port=…, …) > > (Variable assignments and “assert” are the only places where we allow > backslashes) fixed. >> + port=constants.DEFAULT_RAPI_PORT, >> + config_ssl_verification=ssl_config, >> + username="", password="").GetVersion() >> + except: >> + logging.warning("Could not open connection to RAPI") >> + return False >> + logging.debug("RAPI master_version is %s", master_version) >> + return master_version == constants.RAPI_VERSION >> + >> + >> def ParseOptions(): >> """Parse the command line options. >> >> @@ -668,6 +694,21 @@ def main(): >> # we are on master now >> utils.EnsureDaemon(constants.RAPI) >> >> + # If RAPI isn't responding to queries, try one restart. >> + logging.debug("Attempting to talk with RAPI") >> + rapi_test_result = IsRAPIResponding("localhost") >> + logging.debug("RAPI Result = %s", rapi_test_result) >> + if rapi_test_result == None: > > “is None” Fixed. (reworked to be "if not rapi_responding:") >> + logging.warning("RAPI is running but did not speak. Killing RAPI") > > Once space only after period. Fixed (though I protest... this is what typesetters call "french spacing" and it is an abomination in monospaced text.) >> + utils.StopDaemon(constants.RAPI) >> + utils.EnsureDaemon(constants.RAPI) >> + logging.debug("Attempting to talk with RAPI") >> + rapi_test_result = IsRAPIResponding("localhost") > > Use constants.LOCALHOST_IP_ADDRESS and be glad we don't verify X509's > commonName/subjectAltName (yet) in the RAPI client. Fixed. >> + logging.debug("RAPI Result = %s", rapi_test_result) >> + if rapi_test_result is None: >> + logging.fatal("RAPI is not responding. Please investigate.") >> + logging.debug("RAPI works. Result = %s", rapi_test_result) >> + > > Michael Thanks for the feedback!