Commit f1cab0d8 authored by harlowja's avatar harlowja

1. Move all info() logging methods to debug()

2. Adjust comment on sources list from depends
3. For the /etc/timezone 'writing', add a header that says created by cloud-init
parent f7e638f6
......@@ -73,8 +73,7 @@ def welcome(action):
}
welcome_msg = "%s" % (templater.render_string(msg, tpl_params))
sys.stderr.write("%s\n" % (welcome_msg))
sys.stderr.flush()
LOG.info(welcome_msg)
LOG.debug(welcome_msg)
def extract_fns(args):
......
......@@ -133,14 +133,14 @@ class Distro(object):
raise NotImplementedError("Unknown interface action %s" % (action))
cmd = IFACE_ACTIONS[action]
try:
LOG.info("Attempting to run %s interface action using command %s",
action, cmd)
LOG.debug("Attempting to run %s interface action using command %s",
action, cmd)
(_out, err) = util.subp(cmd)
if len(err):
LOG.warn("Running %s resulted in stderr output: %s", cmd, err)
return True
except util.ProcessExecutionError:
util.logexc(LOG, "Running %s failed", cmd)
util.logexc(LOG, "Running interface command %s failed", cmd)
return False
......
......@@ -112,7 +112,11 @@ class Distro(distros.Distro):
if not os.path.isfile(tz_file):
raise Exception(("Invalid timezone %s,"
" no file found at %s") % (tz, tz_file))
tz_contents = "%s\n" % tz
tz_lines = [
"# Created by cloud-init",
str(tz),
]
tz_contents = "\n".join(tz_lines)
tz_fn = self._paths.join(False, "/etc/timezone")
util.write_file(tz_fn, tz_contents)
util.copy(tz_file, self._paths.join(False, "/etc/localtime"))
......
......@@ -161,7 +161,7 @@ class Runners(object):
if not args:
args = []
if sem.has_run(name, freq):
LOG.info("%s already ran (freq=%s)", name, freq)
LOG.debug("%s already ran (freq=%s)", name, freq)
return (False, None)
with sem.lock(name, freq, clear_on_fail) as lk:
if not lk:
......
......@@ -98,7 +98,7 @@ class DataSourceCloudStack(sources.DataSource):
timeout=timeout, status_cb=LOG.warn)
if url:
LOG.info("Using metadata source: '%s'", url)
LOG.debug("Using metadata source: '%s'", url)
else:
LOG.critical(("Giving up on waiting for the metadata from %s"
" after %s seconds"),
......
......@@ -87,10 +87,8 @@ class DataSourceConfigDrive(sources.DataSource):
# Update interfaces and ifup only on the local datasource
# this way the DataSourceConfigDriveNet doesn't do it also.
if 'network-interfaces' in md and self.dsmode == "local":
if md['dsmode'] == "pass":
LOG.info("Updating network interfaces from configdrive")
else:
LOG.debug("Updating network interfaces from configdrive")
LOG.debug("Updating network interfaces from config drive (%s)",
md['dsmode'])
self.distro.apply_network(md['network-interfaces'])
self.seed = found
......
......@@ -169,7 +169,7 @@ class DataSourceEc2(sources.DataSource):
timeout=timeout, status_cb=LOG.warn)
if url:
LOG.info("Using metadata source: '%s'", url2base[url])
LOG.debug("Using metadata source: '%s'", url2base[url])
else:
LOG.critical("Giving up on md from %s after %s seconds",
urls, int(time.time() - start_time))
......
......@@ -128,7 +128,7 @@ class DataSourceMAAS(sources.DataSource):
headers_cb=self.md_headers)
if url:
LOG.info("Using metadata source: '%s'", url)
LOG.debug("Using metadata source: '%s'", url)
else:
LOG.critical("Giving up on md from %s after %i seconds",
urls, int(time.time() - starttime))
......
......@@ -152,7 +152,7 @@ class DataSourceNoCloud(sources.DataSource):
# ('local' for NoCloud, 'net' for NoCloudNet')
if ('network-interfaces' in md and
(self.dsmode in ("local", seeded_interfaces))):
LOG.info("Updating network interfaces from %s", self)
LOG.debug("Updating network interfaces from %s", self)
self.distro.apply_network(md['network-interfaces'])
if md['dsmode'] == self.dsmode:
......
......@@ -166,7 +166,7 @@ class DataSource(object):
def find_source(sys_cfg, distro, paths, ds_deps, cfg_list, pkg_list):
ds_list = list_sources(cfg_list, ds_deps, pkg_list)
ds_names = [util.obj_name(f) for f in ds_list]
LOG.info("Searching for data source in: %s", ds_names)
LOG.debug("Searching for data source in: %s", ds_names)
for cls in ds_list:
try:
......@@ -188,9 +188,9 @@ def find_source(sys_cfg, distro, paths, ds_deps, cfg_list, pkg_list):
# Return an ordered list of classes that match (if any)
def list_sources(cfg_list, depends, pkg_list):
src_list = []
LOG.info(("Looking for for data source in: %s,"
" via packages %s that matches dependencies %s"),
cfg_list, pkg_list, depends)
LOG.debug(("Looking for for data source in: %s,"
" via packages %s that matches dependencies %s"),
cfg_list, pkg_list, depends)
for ds_name in cfg_list:
if not ds_name.startswith(DS_PREFIX):
ds_name = '%s%s' % (DS_PREFIX, ds_name)
......@@ -207,17 +207,17 @@ def list_sources(cfg_list, depends, pkg_list):
return src_list
# depends is a list of dependencies (DEP_FILESYSTEM)
# dslist is a list of 2 item lists
# dslist = [
# 'depends' is a list of dependencies (DEP_FILESYSTEM)
# ds_list is a list of 2 item lists
# ds_list = [
# ( class, ( depends-that-this-class-needs ) )
# }
# it returns a list of 'class' that matched these deps exactly
# it is a helper function for DataSourceCollections
def list_from_depends(depends, dslist):
# It returns a list of 'class' that matched these deps exactly
# It mainly is a helper function for DataSourceCollections
def list_from_depends(depends, ds_list):
ret_list = []
depset = set(depends)
for (cls, deps) in dslist:
for (cls, deps) in ds_list:
if depset == set(deps):
ret_list.append(cls)
return ret_list
......@@ -88,8 +88,8 @@ def readurl(url, data=None, timeout=None,
attempts = retries + 1
excepts = []
LOG.info(("Attempting to open '%s' with %s attempts"
" (%s retries, timeout=%s) to be performed"),
LOG.debug(("Attempting to open '%s' with %s attempts"
" (%s retries, timeout=%s) to be performed"),
url, attempts, retries, timeout)
open_args = {}
if timeout is not None:
......@@ -105,8 +105,8 @@ def readurl(url, data=None, timeout=None,
headers = {}
if rh.headers:
headers = dict(rh.headers)
LOG.info("Read from %s (%s, %sb) after %s attempts",
url, status, len(content), (i + 1))
LOG.debug("Read from %s (%s, %sb) after %s attempts",
url, status, len(content), (i + 1))
return UrlResponse(status, content, headers)
except urllib2.HTTPError as e:
excepts.append(e)
......@@ -165,7 +165,7 @@ def wait_for_url(urls, max_wait=None, timeout=None,
start_time = time.time()
def log_status_cb(msg):
LOG.info(msg)
LOG.debug(msg)
if status_cb is None:
status_cb = log_status_cb
......@@ -219,8 +219,8 @@ def wait_for_url(urls, max_wait=None, timeout=None,
break
loop_n = loop_n + 1
LOG.info("Please wait %s seconds while we wait to try again",
sleep_time)
LOG.debug("Please wait %s seconds while we wait to try again",
sleep_time)
time.sleep(sleep_time)
return False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment