4094 Dyre Tjeldvoll 2012-10-09
Removed unused function and added missing docstr
modified:
storage/ndb/mcc/remote_clusterhost.py
storage/ndb/mcc/util.py
4093 Dyre Tjeldvoll 2012-10-09
Update doc strings
modified:
storage/ndb/mcc/request_handler.py
4092 Dyre Tjeldvoll 2012-10-09
Remove unnecessary class MockClusterHost
modified:
storage/ndb/mcc/remote_clusterhost.py
4091 Dyre Tjeldvoll 2012-10-09
Update doc strings
modified:
storage/ndb/mcc/clusterhost.py
4090 Gunn Olaussen 2012-10-08
Fix MacOS HostInfo bug
modified:
storage/ndb/mcc/clusterhost.py
=== modified file 'storage/ndb/mcc/clusterhost.py'
--- a/storage/ndb/mcc/clusterhost.py 2012-10-08 11:01:54 +0000
+++ b/storage/ndb/mcc/clusterhost.py 2012-10-09 08:36:12 +0000
@@ -49,7 +49,7 @@ class ExecException(Exception):
class HostInfo(object):
- """x"""
+ """Class which provides host information from a Linux-style /proc file system."""
def __init__(self, ch, uname, machine):
self.ch = ch
self.uname = uname
@@ -79,6 +79,7 @@ class HostInfo(object):
@property
def rep(self):
+ """A Python dict representation of the hostInfoRep structure which can be directly converted to Json."""
reply = None
try:
reply = self._run_host_info()
@@ -97,10 +98,12 @@ class HostInfo(object):
@property
def path_module(self):
+ """Returns the python path module to use when manipulating path names on this host."""
return posixpath
+
class SolarisHostInfo(HostInfo):
- """"""
+ """Specialization for Solaris which uses prtconf and psrinfo to retrieve host information."""
def _get_hostInfo(self):
return { 'host': { 'name' : self.ch.host },
@@ -109,7 +112,7 @@ class SolarisHostInfo(HostInfo):
'uname': self.uname}}
class MacHostInfo(HostInfo):
- """x"""
+ """Specialization for MacOS which uses sysctl to retrieve host information."""
def _get_hostInfo(self):
sysinfo = self.ch.exec_blocking(['/usr/sbin/sysctl', 'hw.'])
@@ -120,7 +123,7 @@ class MacHostInfo(HostInfo):
'uname': self.uname}}
class CygwinHostInfo(HostInfo):
- """x"""
+ """Specialization for Windows Cygwin which uses systeminfo and wmic to retrieve host information, but retains posixpath as the path module."""
@property
def _host_info_path(self):
@@ -144,11 +147,12 @@ class CygwinHostInfo(HostInfo):
class WindowsHostInfo(CygwinHostInfo):
- """ """
+ """Specialization of CygwinHostInfo for native Windows which uses ntpath as the path module."""
@property
def path_module(self):
return ntpath
-
+
+# Map from uname string to HostInfo type
hostInfo_map = { 'SunOS' : SolarisHostInfo,
'Darwin' : MacHostInfo,
'Windows' : WindowsHostInfo,
=== modified file 'storage/ndb/mcc/remote_clusterhost.py'
--- a/storage/ndb/mcc/remote_clusterhost.py 2012-09-26 09:39:16 +0000
+++ b/storage/ndb/mcc/remote_clusterhost.py 2012-10-09 11:14:15 +0000
@@ -13,6 +13,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+"""Provides specialization of ABClusterHost for remote hosts using Paramiko."""
+
import errno
import stat
import util
@@ -241,12 +243,3 @@ class RemoteClusterHost(ABClusterHost):
assert isinstance(cmdv, list)
return self._exec_cmdln(' '.join([a.replace(' ', '\\ ') for a in cmdv]), procCtrl, stdinFile)
-class MockClusterHost(RemoteClusterHost):
- """Subclass used for testing. Stores the password internally."""
-
- def __init__(self, host, user='', passwd=''):
- super(MockClusterHost, self).__init__(host, user, passwd)
- # Mockup objects - stores password
- self._msg_ssh = { 'user': user, 'pwd': passwd, 'keyBased': False}
- self._msg_head = { 'head': { 'seq': 0, 'cmd': None }, 'body': None }
-
=== modified file 'storage/ndb/mcc/request_handler.py'
--- a/storage/ndb/mcc/request_handler.py 2012-10-05 12:20:54 +0000
+++ b/storage/ndb/mcc/request_handler.py 2012-10-09 11:07:34 +0000
@@ -23,9 +23,6 @@ communication protocol used to communica
"""
import traceback
-#import cgitb
-#cgitb.enable()
-
import SocketServer
import BaseHTTPServer
import json
@@ -54,6 +51,7 @@ from clusterhost import produce_ABCluste
_logger = logging.getLogger(__name__)
class ShutdownException(Exception):
+ """Exception thrown when shutdown command arrives"""
pass
class ReplyJsonEncoder(json.JSONEncoder):
@@ -248,7 +246,7 @@ def handle_appendFileReq(req, body):
def stop_pgroup(req, body):
- """"""
+ """Not implemeneted yet."""
pass
def handle_stopClusterReq(req, body):
@@ -296,6 +294,7 @@ def handle_getLogTailReq(req, body):
def _parse_until_delim(ctx, fld, delim):
+ """ Return False unless delim exists in ctx['str']. Assign ctx['str'] excluding delim to ctx[fld] and assign ctx[str] to the remainder, excluding delim, and return True otherwise."""
i = ctx['str'].find(delim)
if (i == -1):
return False
@@ -305,21 +304,26 @@ def _parse_until_delim(ctx, fld, delim):
return True
def parse_empty_line(ctx):
- if ctx['str'].startswith('\n'):
- ctx['str'] = ctx['str'][1:]
- return True
- return False
+ """Return False unless ctx[str] starts with an empty line. Consume the empty line and return True otherwise."""
+ if ctx['str'].startswith('\n'):
+ ctx['str'] = ctx['str'][1:]
+ return True
+ return False
def parse_property(ctx):
- if _parse_until_delim(ctx, 'key', ': ') and _parse_until_delim(ctx, 'val', '\n'):
- ctx['properties'][ctx['key']] = ctx['val']
- return True
- return False
+ """Return False unless key and value parsing succeeds. Add kv-pair to ctx['properties'] and return True otherwise."""
+ if _parse_until_delim(ctx, 'key', ': ') and _parse_until_delim(ctx, 'val', '\n'):
+ ctx['properties'][ctx['key']] = ctx['val']
+ return True
+ return False
def parse_properties(ctx):
+ """Return False unless ctx['str'] is a list of properties, a single property or an empty line.
+ Parse the list of properties and return True otherwise."""
return parse_property(ctx) and parse_properties(ctx) or parse_empty_line(ctx)
def parse_reply(ctx):
+ """Return False unless ctx['str'] is an mgmd reply. Assign first line to ctx['reply_type], parse property list and return True otherwise."""
return _parse_until_delim(ctx, 'reply_type', '\n') and parse_properties(ctx)
@@ -333,8 +337,8 @@ class mgmd_reply(dict):
def __str__(self):
return self.reply_type+'\n'+'\n'.join(['{0}: {1}'.format(str(k), str(self[k])) for k in self.keys()])+'\n'
-def handle_runMgmdCommand(req, body):
- """x"""
+def handle_runMgmdCommandReq(req, body):
+ """Handler function for runMgmdCommandReq commands. Opens a new connection to mgmd, sends command, parses reply and wraps reply in mcc Rep object."""
with socket.create_connection((body['hostname'], body['port'])) as mgmd:
mgmd.sendall(body['mgmd_command']+'\n\n')
s = mgmd.recv(4096)
@@ -356,7 +360,7 @@ def handle_runMgmdCommand(req, body):
def log_thread_name():
- """x"""
+ """Utility for dumping thread id in the log."""
cur_thread = threading.current_thread()
_logger.debug("cur_thread="+str(cur_thread.name))
=== modified file 'storage/ndb/mcc/util.py'
--- a/storage/ndb/mcc/util.py 2012-09-20 12:19:53 +0000
+++ b/storage/ndb/mcc/util.py 2012-10-09 11:14:15 +0000
@@ -23,8 +23,6 @@ import stat
import platform
import logging
-def logger():
- return logging.getLogger(__name__)
def is_set(val, mask):
"""Return True if bits in mask are also set in val."""
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5-cluster-7.2 branch (Dyre.Tjeldvoll:4090 to 4094) | Dyre Tjeldvoll | 9 Oct |