From 3da03a0cf99191f9de8b56e177b16664d6c3f69f Mon Sep 17 00:00:00 2001 From: David LaBissoniere Date: Fri, 9 Nov 2012 13:42:32 -0600 Subject: [PATCH] whitespace --- cloudinitd/__init__.py | 2 +- cloudinitd/bootfabtasks.py | 2 +- cloudinitd/cb_iaas.py | 2 +- cloudinitd/cli/__init__.py | 2 +- cloudinitd/cli/boot.py | 10 +++++----- cloudinitd/cli/cmd_opts.py | 2 +- cloudinitd/global_deps.py | 4 ++-- cloudinitd/nosetests/basic_tests.py | 2 +- cloudinitd/nosetests/basic_unit_tests.py | 2 +- cloudinitd/nosetests/cloudinitd_tests.py | 2 +- cloudinitd/nosetests/instance_dies_tests.py | 2 +- cloudinitd/nosetests/leak_vm_tests.py | 2 +- cloudinitd/nosetests/many_at_once_tests.py | 2 +- .../nosetests/many_terminate_hang_tests.py | 2 +- cloudinitd/nosetests/outputjson_tests.py | 2 +- .../nosetests/remote_locations_tests.py | 2 +- cloudinitd/nosetests/singlevm_tests.py | 2 +- cloudinitd/nosetests/validate_tests.py | 4 ++-- cloudinitd/pollables.py | 20 +++++++++---------- cloudinitd/services.py | 18 ++++++++--------- cloudinitd/user_api.py | 4 ++-- 21 files changed, 45 insertions(+), 45 deletions(-) diff --git a/cloudinitd/__init__.py b/cloudinitd/__init__.py index a6a585e..d8bcb34 100644 --- a/cloudinitd/__init__.py +++ b/cloudinitd/__init__.py @@ -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) diff --git a/cloudinitd/bootfabtasks.py b/cloudinitd/bootfabtasks.py index 6064357..724ac30 100644 --- a/cloudinitd/bootfabtasks.py +++ b/cloudinitd/bootfabtasks.py @@ -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): diff --git a/cloudinitd/cb_iaas.py b/cloudinitd/cb_iaas.py index d20fa10..2d4d605 100644 --- a/cloudinitd/cb_iaas.py +++ b/cloudinitd/cb_iaas.py @@ -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 diff --git a/cloudinitd/cli/__init__.py b/cloudinitd/cli/__init__.py index 3d8b4e2..139597f 100644 --- a/cloudinitd/cli/__init__.py +++ b/cloudinitd/cli/__init__.py @@ -1,2 +1,2 @@ - \ No newline at end of file + diff --git a/cloudinitd/cli/boot.py b/cloudinitd/cli/boot.py index 2a3175d..cbb9bf7 100644 --- a/cloudinitd/cli/boot.py +++ b/cloudinitd/cli/boot.py @@ -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) @@ -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)) @@ -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) @@ -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: @@ -428,7 +428,7 @@ def _status(options, args): rc = 1 _write_json_doc(options, cb) - + return rc def terminate(options, args): diff --git a/cloudinitd/cli/cmd_opts.py b/cloudinitd/cli/cmd_opts.py index fe81d90..a8b4695 100644 --- a/cloudinitd/cli/cmd_opts.py +++ b/cloudinitd/cli/cmd_opts.py @@ -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 diff --git a/cloudinitd/global_deps.py b/cloudinitd/global_deps.py index 3b421fd..2b786b0 100644 --- a/cloudinitd/global_deps.py +++ b/cloudinitd/global_deps.py @@ -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) @@ -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] \ No newline at end of file + return g_global_obj.vars[key] diff --git a/cloudinitd/nosetests/basic_tests.py b/cloudinitd/nosetests/basic_tests.py index 54526e0..7c8a340 100644 --- a/cloudinitd/nosetests/basic_tests.py +++ b/cloudinitd/nosetests/basic_tests.py @@ -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) diff --git a/cloudinitd/nosetests/basic_unit_tests.py b/cloudinitd/nosetests/basic_unit_tests.py index 9b69bd5..70880af 100644 --- a/cloudinitd/nosetests/basic_unit_tests.py +++ b/cloudinitd/nosetests/basic_unit_tests.py @@ -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") diff --git a/cloudinitd/nosetests/cloudinitd_tests.py b/cloudinitd/nosetests/cloudinitd_tests.py index 886892e..12b2821 100644 --- a/cloudinitd/nosetests/cloudinitd_tests.py +++ b/cloudinitd/nosetests/cloudinitd_tests.py @@ -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() diff --git a/cloudinitd/nosetests/instance_dies_tests.py b/cloudinitd/nosetests/instance_dies_tests.py index 74faebf..a48267e 100644 --- a/cloudinitd/nosetests/instance_dies_tests.py +++ b/cloudinitd/nosetests/instance_dies_tests.py @@ -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) diff --git a/cloudinitd/nosetests/leak_vm_tests.py b/cloudinitd/nosetests/leak_vm_tests.py index 010870e..2c0134c 100644 --- a/cloudinitd/nosetests/leak_vm_tests.py +++ b/cloudinitd/nosetests/leak_vm_tests.py @@ -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() diff --git a/cloudinitd/nosetests/many_at_once_tests.py b/cloudinitd/nosetests/many_at_once_tests.py index f2ec78a..5e6e4e5 100644 --- a/cloudinitd/nosetests/many_at_once_tests.py +++ b/cloudinitd/nosetests/many_at_once_tests.py @@ -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) diff --git a/cloudinitd/nosetests/many_terminate_hang_tests.py b/cloudinitd/nosetests/many_terminate_hang_tests.py index 4c77d66..ccfd1f0 100644 --- a/cloudinitd/nosetests/many_terminate_hang_tests.py +++ b/cloudinitd/nosetests/many_terminate_hang_tests.py @@ -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() diff --git a/cloudinitd/nosetests/outputjson_tests.py b/cloudinitd/nosetests/outputjson_tests.py index 4e595b7..c868520 100644 --- a/cloudinitd/nosetests/outputjson_tests.py +++ b/cloudinitd/nosetests/outputjson_tests.py @@ -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) \ No newline at end of file + self.assertEqual(rc, 0) diff --git a/cloudinitd/nosetests/remote_locations_tests.py b/cloudinitd/nosetests/remote_locations_tests.py index f7d1fc8..c8bb750 100644 --- a/cloudinitd/nosetests/remote_locations_tests.py +++ b/cloudinitd/nosetests/remote_locations_tests.py @@ -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) diff --git a/cloudinitd/nosetests/singlevm_tests.py b/cloudinitd/nosetests/singlevm_tests.py index fe08a86..6edbd62 100644 --- a/cloudinitd/nosetests/singlevm_tests.py +++ b/cloudinitd/nosetests/singlevm_tests.py @@ -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: diff --git a/cloudinitd/nosetests/validate_tests.py b/cloudinitd/nosetests/validate_tests.py index 24227f5..fe17f99 100644 --- a/cloudinitd/nosetests/validate_tests.py +++ b/cloudinitd/nosetests/validate_tests.py @@ -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 @@ -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) diff --git a/cloudinitd/pollables.py b/cloudinitd/pollables.py index 65509f9..7f1dd50 100644 --- a/cloudinitd/pollables.py +++ b/cloudinitd/pollables.py @@ -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): @@ -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) @@ -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 @@ -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") @@ -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 @@ -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 @@ -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]: @@ -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 # """ @@ -586,7 +586,7 @@ def cancel(self): lvl = self.levels[i] for p in lvl: p.cancel() - + self._canceled = True @@ -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) diff --git a/cloudinitd/services.py b/cloudinitd/services.py index 0d9a4e6..96269e9 100644 --- a/cloudinitd/services.py +++ b/cloudinitd/services.py @@ -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] @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 = "" @@ -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))) @@ -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 diff --git a/cloudinitd/user_api.py b/cloudinitd/user_api.py index d5739b5..6e175db 100644 --- a/cloudinitd/user_api.py +++ b/cloudinitd/user_api.py @@ -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. @@ -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