summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-07-30 15:10:55 -0400
committerScott Moser <smoser@ubuntu.com>2013-07-30 15:10:55 -0400
commit219191673b5491fab683ca5ff1befe845c81f6cf (patch)
tree4afcc24f3d00a08b5cd442fc0a0e81a15a653e36 /cloudinit/sources
parent88b2a8ef062398499a2c14d309c132a081cac26b (diff)
parent0ca150b08433fbc57e10d599a46e300142c955c5 (diff)
downloadvyos-cloud-init-219191673b5491fab683ca5ff1befe845c81f6cf.tar.gz
vyos-cloud-init-219191673b5491fab683ca5ff1befe845c81f6cf.zip
add util.log_time helper
The reason for this is that more and more things I was wanting to be able to see how long they took. This puts that time logic into a single place. It also supports from /proc/uptime as the timing mechanism. While reading /proc/uptime is almost certainly slower than time.time(), it does give millisecond granularity and is not affected by 'ntpdate' having run in between the two events.
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceAzure.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 2f28702e..1a74de21 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -138,13 +138,11 @@ class DataSourceAzureNet(sources.DataSource):
bname = pk['fingerprint'] + ".crt"
fp_files += [os.path.join(mycfg['data_dir'], bname)]
- start = time.time()
- missing = wait_for_files(wait_for + fp_files)
+ missing = util.log_time(logfunc=LOG.debug, msg="waiting for files",
+ func=wait_for_files,
+ args=(wait_for + fp_files,))
if len(missing):
LOG.warn("Did not find files, but going on: %s", missing)
- else:
- LOG.debug("waited %.3f seconds for %d files to appear",
- time.time() - start, len(wait_for))
if shcfgxml in missing:
LOG.warn("SharedConfig.xml missing, using static instance-id")
@@ -206,11 +204,12 @@ def apply_hostname_bounce(hostname, policy, interface, command,
command = BOUNCE_COMMAND
LOG.debug("pubhname: publishing hostname [%s]", msg)
- start = time.time()
shell = not isinstance(command, (list, tuple))
# capture=False, see comments in bug 1202758 and bug 1206164.
- (output, err) = util.subp(command, shell=shell, capture=False, env=env)
- LOG.debug("publishing hostname took %.3f seconds", time.time() - start)
+ util.log_time(logfunc=LOG.debug, msg="publishing hostname",
+ get_uptime=True, func=util.subp,
+ kwargs={'command': command, 'shell': shell, 'capture': False,
+ 'env': env})
def crtfile_to_pubkey(fname):