Revision 69b99987

b/lib/asyncnotifier.py
31 31

  
32 32
  """
33 33

  
34
  def __init__(self, watch_manager,
35
               default_proc_fun=None,
36
               map=None):
37
    """
38
    Constructor for AsyncNotifier, a special asyncore file_dispatcher that
39
    actually wraps a pyinotify Notifier, making it asyncronous.
34
  def __init__(self, watch_manager, default_proc_fun=None, map=None):
35
    """Initializes this class.
36

  
37
    This is a a special asyncore file_dispatcher that actually wraps a
38
    pyinotify Notifier, making it asyncronous.
40 39

  
41 40
    """
42 41
    if default_proc_fun is None:
43
      default_proc_fun=pyinotify.ProcessEvent()
42
      default_proc_fun = pyinotify.ProcessEvent()
43

  
44 44
    self.notifier = pyinotify.Notifier(watch_manager, default_proc_fun)
45

  
45 46
    # here we need to steal the file descriptor from the notifier, so we can
46 47
    # use it in the global asyncore select, and avoid calling the
47 48
    # check_events() function of the notifier (which doesn't allow us to select
......
52 53
  def handle_read(self):
53 54
    self.notifier.read_events()
54 55
    self.notifier.process_events()
55

  
b/lib/backend.py
1768 1768
  @raise RPCFail: if we don't find a valid OS
1769 1769

  
1770 1770
  """
1771
  name_only = name.split('+',1)[0]
1771
  name_only = name.split("+", 1)[0]
1772 1772
  status, payload = _TryOSFromDisk(name_only, base_dir)
1773 1773

  
1774 1774
  if not status:
b/lib/cli.py
25 25
import sys
26 26
import textwrap
27 27
import os.path
28
import copy
29 28
import time
30 29
import logging
31 30
from cStringIO import StringIO
......
813 812
                                    default=False, action="store_true",
814 813
                                    help="Ignore errors from secondaries")
815 814

  
816
NOSHUTDOWN_OPT = cli_option("","--noshutdown", dest="shutdown",
815
NOSHUTDOWN_OPT = cli_option("--noshutdown", dest="shutdown",
817 816
                            action="store_false", default=True,
818 817
                            help="Don't shutdown the instance (unsafe)")
819 818

  
b/lib/confd/client.py
29 29
and can proceed even if some udp packets are lost. It's up to the user to
30 30
reschedule queries if they haven't received responses and they need them.
31 31

  
32
Example usage:
32
Example usage::
33

  
33 34
  client = ConfdClient(...) # includes callback specification
34 35
  req = confd_client.ConfdClientRequest(type=constants.CONFD_REQ_PING)
35 36
  client.SendRequest(req)
......
43 44
confirming what you already got.
44 45

  
45 46
"""
47

  
46 48
import socket
47 49
import time
48 50
import random
......
97 99
    @param callback: function to call when getting answers
98 100
    @type port: integer
99 101
    @keyword port: confd port (default: use GetDaemonPort)
100
    @type logger: L{logging.Logger}
102
    @type logger: logging.Logger
101 103
    @keyword logger: optional logger for internal conditions
102 104

  
103 105
    """
......
318 320

  
319 321
    @type callback: f(L{ConfdUpcallPayload})
320 322
    @param callback: function to call when getting answers
321
    @type logger: L{logging.Logger}
323
    @type logger: logging.Logger
322 324
    @keyword logger: optional logger for internal conditions
323 325

  
324 326
    """
b/lib/daemon.py
24 24

  
25 25
import asyncore
26 26
import os
27
import select
28 27
import signal
29 28
import errno
30 29
import logging
......
158 157
class Mainloop(object):
159 158
  """Generic mainloop for daemons
160 159

  
160
  @ivar scheduler: A sched.scheduler object, which can be used to register
161
    timed events
162

  
161 163
  """
162 164
  def __init__(self):
163 165
    """Constructs a new Mainloop instance.
164 166

  
165
    @ivar scheduler: A L{sched.scheduler} object, which can be used to register
166
    timed events
167

  
168 167
    """
169 168
    self._signal_wait = []
170 169
    self.scheduler = AsyncoreScheduler(time.time)
171 170

  
172 171
  @utils.SignalHandled([signal.SIGCHLD])
173 172
  @utils.SignalHandled([signal.SIGTERM])
174
  def Run(self, stop_on_empty=False, signal_handlers=None):
173
  def Run(self, signal_handlers=None):
175 174
    """Runs the mainloop.
176 175

  
177
    @type stop_on_empty: bool
178
    @param stop_on_empty: Whether to stop mainloop once all I/O waiters
179
                          unregistered
180 176
    @type signal_handlers: dict
181 177
    @param signal_handlers: signal->L{utils.SignalHandler} passed by decorator
182 178

  
......
187 183
    running = True
188 184
    # Start actual main loop
189 185
    while running:
190
      # Stop if nothing is listening anymore
191
      if stop_on_empty and not (self._io_wait):
192
        break
193

  
194 186
      if not self.scheduler.empty():
195 187
        try:
196 188
          self.scheduler.run()
......
234 226

  
235 227
  @type daemon_name: string
236 228
  @param daemon_name: daemon name
237
  @type optionparser: L{optparse.OptionParser}
229
  @type optionparser: optparse.OptionParser
238 230
  @param optionparser: initialized optionparser with daemon-specific options
239 231
                       (common -f -d options will be handled by this module)
240
  @type options: object @param options: OptionParser result, should contain at
241
                 least the fork and the debug options
242 232
  @type dirs: list of strings
243 233
  @param dirs: list of directories that must exist for this daemon to work
244 234
  @type check_fn: function which accepts (options, args)
b/lib/hypervisor/hv_kvm.py
370 370
    else:
371 371
      kvm_cmd.extend(['-nographic'])
372 372

  
373
    monitor_dev = 'unix:%s,server,nowait' % \
374
      self._InstanceMonitor(instance.name)
373
    monitor_dev = ("unix:%s,server,nowait" %
374
                   self._InstanceMonitor(instance.name))
375 375
    kvm_cmd.extend(['-monitor', monitor_dev])
376 376
    if hvp[constants.HV_SERIAL_CONSOLE]:
377 377
      serial_dev = ('unix:%s,server,nowait' %
b/lib/hypervisor/hv_xen.py
508 508
class XenHvmHypervisor(XenHypervisor):
509 509
  """Xen HVM hypervisor interface"""
510 510

  
511
  ANCILLARY_FILES = XenHypervisor.ANCILLARY_FILES + \
512
    [constants.VNC_PASSWORD_FILE]
511
  ANCILLARY_FILES = XenHypervisor.ANCILLARY_FILES + [
512
    constants.VNC_PASSWORD_FILE,
513
    ]
513 514

  
514 515
  PARAMETERS = {
515 516
    constants.HV_ACPI: hv_base.NO_CHECK,
b/lib/jqueue.py
1027 1027
    queue, in order for it to be picked up by the queue processors.
1028 1028

  
1029 1029
    @type job_id: job ID
1030
    @param jod_id: the job ID for the new job
1030
    @param job_id: the job ID for the new job
1031 1031
    @type ops: list
1032 1032
    @param ops: The list of OpCodes that will become the new job.
1033 1033
    @rtype: job ID
b/lib/locking.py
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 19
# 02110-1301, USA.
20 20

  
21
# Disable "Invalid name ..." message
22
# pylint: disable-msg=C0103
23

  
21 24
"""Module implementing the Ganeti locking code."""
22 25

  
23 26
import os
......
113 116
  def __init__(self, lock):
114 117
    """Constructor for _BaseCondition.
115 118

  
116
    @type lock: L{threading.Lock}
119
    @type lock: threading.Lock
117 120
    @param lock: condition base lock
118 121

  
119 122
    """
......
180 183
    self._poller = None
181 184

  
182 185
  def _check_unnotified(self):
186
    """Throws an exception if already notified.
187

  
188
    """
183 189
    if self._notified:
184 190
      raise RuntimeError("cannot use already notified condition")
185 191

  
b/lib/mcpu.py
38 38
from ganeti import rpc
39 39
from ganeti import cmdlib
40 40
from ganeti import locking
41
from ganeti import utils
42 41

  
43 42

  
44 43
class _LockAcquireTimeout(Exception):
b/lib/rapi/connector.py
114 114
    return baserlib.BuildUriList(rootlist, "/%s")
115 115

  
116 116

  
117
def _getResources(id):
117
def _getResources(id_):
118 118
  """Return a list of resources underneath given id.
119 119

  
120 120
  This is to generalize querying of version resources lists.
......
122 122
  @return: a list of resources names.
123 123

  
124 124
  """
125
  r_pattern = re.compile('^R_%s_([a-zA-Z0-9]+)$' % id)
125
  r_pattern = re.compile('^R_%s_([a-zA-Z0-9]+)$' % id_)
126 126

  
127 127
  rlist = []
128 128
  for handler in CONNECTOR.values():
b/lib/rapi/rlib2.py
439 439
    for idx, d in enumerate(disk_data):
440 440
      if not isinstance(d, int):
441 441
        raise http.HttpBadRequest("Disk %d specification wrong: should"
442
                                  " be an integer")
442
                                  " be an integer" % idx)
443 443
      disks.append({"size": d})
444 444
    # nic processing (one nic only)
445 445
    nics = [{"mac": fn("mac", constants.VALUE_AUTO)}]
......
450 450
    if fn("link", None) is not None:
451 451
      nics[0]["link"] = fn("link")
452 452
    if fn("bridge", None) is not None:
453
       nics[0]["bridge"] = fn("bridge")
453
      nics[0]["bridge"] = fn("bridge")
454 454

  
455 455
    op = opcodes.OpCreateInstance(
456 456
      mode=constants.INSTANCE_CREATE,
b/lib/ssconf.py
57 57
    self._last_inode = None
58 58
    self._last_mtime = None
59 59
    self._last_size = None
60

  
61
    self._config_data = None
62
    self._instances_ips = None
63
    self._inst_ips_by_link = None
64
    self._ip_to_instance = None
65
    self._mc_primary_ips = None
66
    self._nodes_primary_ips = None
67

  
60 68
    # we need a forced reload at class init time, to initialize _last_*
61 69
    self._Load(force=True)
62 70

  
......
79 87
    mtime = cfg_stat.st_mtime
80 88
    size = cfg_stat.st_size
81 89

  
82
    reload = False
83
    if force or inode != self._last_inode or \
84
       mtime > self._last_mtime or \
85
       size != self._last_size:
90
    if (force or inode != self._last_inode or
91
        mtime > self._last_mtime or
92
        size != self._last_size):
86 93
      self._last_inode = inode
87 94
      self._last_mtime = mtime
88 95
      self._last_size = size
89
      reload = True
90

  
91
    if not reload:
96
    else:
97
      # Don't reload
92 98
      return False
93 99

  
94 100
    try:

Also available in: Unified diff