Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
labisso committed Nov 9, 2012
1 parent 4ff70d3 commit 3da03a0
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cloudinitd/__init__.py
Expand Up @@ -134,7 +134,7 @@ def make_logger(log_level, runname, logdir=None, servicename=None):
logfile = logdir + "/" + servicename + ".log"
else:
logfile = logdir + "/" + runname + ".log"

handler = logging.handlers.RotatingFileHandler(logfile, maxBytes=100*1024*1024, backupCount=5)

logger.addHandler(handler)
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/bootfabtasks.py
Expand Up @@ -36,7 +36,7 @@ def _tartask(directory, basename, tarball, run_pgm=run):

# In case they forgot:
run_pgm("chmod +x %s" % destpgm)

return destpgm

def _make_ssh(pgm, args="", local_exe=None):
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/cb_iaas.py
Expand Up @@ -156,7 +156,7 @@ def _find_instance(self, instance_id):
return i

class IaaSLibCloudConn(object):

def __init__(self, svc, key, secret, iaasurl, iaas):
#cloudinitd.log(log, logging.INFO, "loading up a lobcloud driver %s" % (iaas))
self._svc = svc
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/cli/__init__.py
@@ -1,2 +1,2 @@


10 changes: 5 additions & 5 deletions cloudinitd/cli/boot.py
Expand Up @@ -120,7 +120,7 @@ def parse_commands(argv):
os.chmod(homedir, stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR)
except Exception, ex:
print_chars(0, "Error creating cloudinit.d directort %s : %s" % (homedir, str(ex)))

(options, args) = parser.parse_args(args=argv)

_deal_with_cmd_line_globals(options)
Expand Down Expand Up @@ -214,7 +214,7 @@ def level_callback(cb, action, current_level):

def service_callback(cb, cloudservice, action, msg):
global g_action

if action == cloudinitd.callback_action_started:
print_chars(3, "\t%s\n" % (msg))

Expand Down Expand Up @@ -336,7 +336,7 @@ def launch_new(options, args):
if not os.path.exists(path):
raise Exception("That DB does not seem to exist: %s" % (path))
os.remove(path)

return rc

(rc, cb) = _launch_new(options, args, cb)
Expand All @@ -363,7 +363,7 @@ def _launch_new(options, args, cb):
finally:
fake_args = ["clean", options.name]
clean_ice(options, fake_args)

rc = 0
ex = cb.get_exception()
if ex is None:
Expand Down Expand Up @@ -428,7 +428,7 @@ def _status(options, args):
rc = 1

_write_json_doc(options, cb)

return rc

def terminate(options, args):
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/cli/cmd_opts.py
Expand Up @@ -34,7 +34,7 @@ def validate(self, options):
if float(val) == -1.0:
if float(self.range[0]) != -1.0 and float(self.range[1]) != -1.0:
raise Exception("you specified a value out of range")

else:
return

Expand Down
4 changes: 2 additions & 2 deletions cloudinitd/global_deps.py
Expand Up @@ -12,7 +12,7 @@ def __init__(self):

def set_var(self, key, val):
self.vars[key] = val

def set_global_var_file(path, rank):
parser = ConfigParser.ConfigParser()
parser.read(path)
Expand Down Expand Up @@ -48,4 +48,4 @@ def get_global(key, default=None, raise_ex=False):
if raise_ex:
raise ConfigException("The global variable %s is not set." % (key))
return default
return g_global_obj.vars[key]
return g_global_obj.vars[key]
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/basic_tests.py
Expand Up @@ -30,7 +30,7 @@ def _start_one(self, conf_file):
def test_lotsonlevel(self):
tst_name = "lotsonlevel"
self._start_one(tst_name)

def test_multileveldeps(self):
tst_name = "multileveldeps"
self._start_one(tst_name)
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/basic_unit_tests.py
Expand Up @@ -43,7 +43,7 @@ def test_exceptions(self):
self.assertEqual(msg, str(ex))
ex = IaaSException(Exception("test"))
print ex
ex = MultilevelException([ex], [ex], 5)
ex = MultilevelException([ex], [ex], 5)
print ex
fakesvc = FakeSvc("name")
ex = ServiceException(Exception("tester"), fakesvc, msg="msg")
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/cloudinitd_tests.py
Expand Up @@ -45,7 +45,7 @@ def _find_str(self, filename, needle):
file.close()

def _dump_output(self, filename):
file = open(filename, "r")
file = open(filename, "r")
print file.readlines()
file.close()

Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/instance_dies_tests.py
Expand Up @@ -57,7 +57,7 @@ def test_get_service(self):
h = svc.get_attr_from_bag("hostname")
print h
self._terminate(dir, cb.run_name)

def test_getlevels(self):
tst_name = "multilevelsimple"
(dir, cb) = self._start_one(tst_name)
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/leak_vm_tests.py
Expand Up @@ -45,7 +45,7 @@ def _find_str(self, filename, needle):
file.close()

def _dump_output(self, filename):
file = open(filename, "r")
file = open(filename, "r")
print file.readlines()
file.close()

Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/many_at_once_tests.py
Expand Up @@ -66,7 +66,7 @@ def test_get_service(self):
h = svc.get_attr_from_bag("hostname")
print h
self._terminate(dir, cb.run_name)

def test_getlevels(self):
tst_name = "multilevelsimple"
(dir, cb) = self._start_one(tst_name)
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/many_terminate_hang_tests.py
Expand Up @@ -45,7 +45,7 @@ def _find_str(self, filename, needle):
file.close()

def _dump_output(self, filename):
file = open(filename, "r")
file = open(filename, "r")
print file.readlines()
file.close()

Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/outputjson_tests.py
Expand Up @@ -88,4 +88,4 @@ def check_repair_error_test(self):

print "start terminate"
rc = cloudinitd.cli.boot.main(["terminate", "%s" % (runname)])
self.assertEqual(rc, 0)
self.assertEqual(rc, 0)
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/remote_locations_tests.py
Expand Up @@ -52,7 +52,7 @@ def test_env_set(self):

rc = os.system(ssh_cmd)
self.assertEquals(rc, 0)

cb = CloudInitD(dir, db_name=cb.run_name, terminate=True, boot=False, ready=False)
cb.shutdown()
cb.block_until_complete(poll_period=1.0)
Expand Down
2 changes: 1 addition & 1 deletion cloudinitd/nosetests/singlevm_tests.py
Expand Up @@ -44,7 +44,7 @@ def test_manyservices_one_vm_simple(self):
cb.block_until_complete(poll_period=1.0)


# this test should be taken with a grain of salt. It will fail if you
# this test should be taken with a grain of salt. It will fail if you
# are doin anything else with you account
def test_only_one_launched(self):
if 'CLOUDINITD_CLEAN_ACCOUNT' not in os.environ:
Expand Down
4 changes: 2 additions & 2 deletions cloudinitd/nosetests/validate_tests.py
Expand Up @@ -23,7 +23,7 @@ def test_validateiaas(self):
conf_file = self.plan_basedir + "/iaastypevalidate/top.conf"
cb = CloudInitD(dir, conf_file, terminate=False, boot=True, ready=True)
cb.start()

cb.block_until_complete(poll_period=1.0)

# check the log for a warning
Expand All @@ -41,7 +41,7 @@ def test_validateiaas(self):
found = True
self.assertTrue(found, "a warning with the key 2.7 should be in the logfile %s" %(fname))
f.close()

cb = CloudInitD(dir, db_name=cb.run_name, terminate=True, boot=False, ready=False)
cb.shutdown()
cb.block_until_complete(poll_period=1.0)
Expand Down
20 changes: 10 additions & 10 deletions cloudinitd/pollables.py
Expand Up @@ -161,7 +161,7 @@ def poll(self):
cloudinitd.log(self._log, logging.ERROR, "safety error count exceeded" + str(ex), tb=traceback)
raise
cloudinitd.log(self._log, logging.INFO, "Retry %d for %s:%d" % (self._poll_error_count, self._host, self._port))

return False

def cancel(self):
Expand Down Expand Up @@ -265,7 +265,7 @@ def _thread_poll(self, poll_period=1.0):
try:
if self._instance.get_state() not in self._ok_states:
cloudinitd.log(self._log, logging.DEBUG, "%s polling thread done" % (self.get_instance_id()))
done = True
done = True
# because update is called in start we will sleep first
else:
time.sleep(poll_period)
Expand Down Expand Up @@ -322,7 +322,7 @@ def poll(self):
if self._exception:
raise self._exception
if not self._started:
raise APIUsageException("You must call start before calling poll.")
raise APIUsageException("You must call start before calling poll.")
if self._done:
return True
# check timeout here
Expand Down Expand Up @@ -369,7 +369,7 @@ def _poll(self):
if self._error_count >= self._allowed_errors:
ex = Exception("Process exceeded the allowed number of failures %d with %d: %s" % (self._allowed_errors, self._error_count, self._cmd))
raise ProcessException(ex, self._stdout_str, self._stderr_str, rc)
self._last_run = datetime.datetime.now()
self._last_run = datetime.datetime.now()
return False
self._done = True
self._execute_cb(cloudinitd.callback_action_complete, "Pollable complete")
Expand Down Expand Up @@ -403,7 +403,7 @@ def _read_output(self, p, poll_period):

if f == p.stdout:
# we assume there will be a full line or eof
# not the fastest str concat, but this is small
# not the fastest str concat, but this is small
self._stdout_str = self._stdout_str + line
if not line:
self._stdout_eof = True
Expand Down Expand Up @@ -467,7 +467,7 @@ def pre_start(self):
p.pre_start()

def start(self):
Pollable.start(self)
Pollable.start(self)
if self.level_ndx >= 0:
return

Expand All @@ -476,7 +476,7 @@ def start(self):
if len(self.levels) == 0:
return
self._start()

def _start(self):
self._execute_cb(cloudinitd.callback_action_started, self._get_callback_level())
for p in self.levels[self.level_ndx]:
Expand Down Expand Up @@ -559,7 +559,7 @@ def _execute_cb(self, action, lvl):

def get_level_times(self):
return self.level_times

#def cancel(self):
# table this for now
# """
Expand All @@ -586,7 +586,7 @@ def cancel(self):
lvl = self.levels[i]
for p in lvl:
p.cancel()

self._canceled = True


Expand All @@ -595,7 +595,7 @@ class ValidationPollable(Pollable):
def __init__(self, svc, timeout=600, done_cb=None):
Pollable.__init__(self, timeout, done_cb=done_cb)
self._svc = svc


def start(self):
Pollable.start(self)
18 changes: 9 additions & 9 deletions cloudinitd/services.py
Expand Up @@ -64,7 +64,7 @@ def get_services(self, basename=None):
svcs.append(v)

return svcs

@cloudinitd.LogEntryDecorator
def get_service(self, name):
return self.services[name]
Expand All @@ -84,7 +84,7 @@ def new_service(self, s, db, boot=None, ready=None, terminate=None, log=None, lo
raise APIUsageException("A service by the name of %s is already know to this boot configuration. Please check your config files and try another name" % (s.name))

if s.image is None and s.hostname is None:
raise APIUsageException("You must have an image or a hostname or there will be no VM")
raise APIUsageException("You must have an image or a hostname or there will be no VM")

if boot is None:
boot = self._boot
Expand Down Expand Up @@ -173,8 +173,8 @@ def __init__(self, db, s, top_level, boot=True, ready=True, terminate=False, log

self._stagedir = "%s/%s" % (get_remote_working_dir(), self.name)
self._validate_and_reinit(boot=boot, ready=ready, terminate=terminate, callback=callback, repair=reload)
self._db.db_commit()

self._db.db_commit()
self._restart_limit = 2
self._restart_count = 0

Expand Down Expand Up @@ -277,7 +277,7 @@ def _make_first_pollers(self):
instance = iaas_con.find_instance(self._s.instance_id)
self._shutdown_poller = InstanceTerminatePollable(instance, log=self._log, done_cb=self._teminate_done)
self._term_host_pollers.add_level([self._shutdown_poller])
except IaaSException, iaas_ex:
except IaaSException, iaas_ex:
emsg = "Skipping terminate due to IaaS exception %s" % (str(iaas_ex))
self._execute_callback(cloudinitd.callback_action_transition, emsg)
cloudinitd.log(self._log, logging.INFO, emsg)
Expand Down Expand Up @@ -321,7 +321,7 @@ def pre_start_iaas(self):
def _make_pollers(self):
if self._do_boot or self._do_ready:
self._do_attr_bag()

self._ready_poller = None
self._boot_poller = None
self._terminate_poller = None
Expand Down Expand Up @@ -601,7 +601,7 @@ def poll(self):
try:
rc = self._poll()
if rc:
self._running = False
self._running = False
return rc
except MultilevelException, multiex:
msg = ""
Expand Down Expand Up @@ -662,7 +662,7 @@ def _log_poller_output(self, poller):
stdout = poller.get_stdout()
stderr = poller.get_stderr()
cmd = poller.get_command()
# this is reapeated info but at a convient location.
# this is reapeated info but at a convient location.
cloudinitd.log(self._log, logging.DEBUG, "Output for the command %s:\nstdout\n------\n%s\nstderr\n------\n%s" % (cmd, stdout, stderr))
except Exception, ex:
cloudinitd.log(self._log, logging.ERROR, "Failed to log output info | %s" % (str(ex)))
Expand Down Expand Up @@ -768,7 +768,7 @@ def _get_readypgm_cmd(self):

if readypgm_args:
readypgm_args = urllib.quote(readypgm_args)

cmd = self._get_fab_command() + " 'readypgm:hosts=%s,pgm=%s,args=%s,stagedir=%s,local_exe=%s'" % (host, readypgm, readypgm_args, self._stagedir, str(self._s.local_exe))
cloudinitd.log(self._log, logging.DEBUG, "Using ready pgm command %s" % (cmd))
return cmd
Expand Down
4 changes: 2 additions & 2 deletions cloudinitd/user_api.py
Expand Up @@ -43,7 +43,7 @@ class CloudInitD(object):
A service cannot be created without this object. This object holds a dictionary of all services which is
used for querying dependencies
"""

def __init__(self, db_dir, config_file=None, db_name=None, log_level="warn", logdir=None, level_callback=None, service_callback=None, boot=True, ready=True, terminate=False, continue_on_error=False, fail_if_db_present=False):
"""
db_dir: a path to a directories where databases can be stored.
Expand Down Expand Up @@ -401,7 +401,7 @@ def get_service_name(self):
@cloudinitd.LogEntryDecorator
def get_context_state(self):
return self._svc._s.state

@cloudinitd.LogEntryDecorator
def get_service_iaas_handle(self):
return self._svc._s.instance_id
Expand Down

0 comments on commit 3da03a0

Please sign in to comment.