summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-08-22 14:26:35 -0400
committerScott Moser <smoser@ubuntu.com>2012-08-22 14:26:35 -0400
commit0bc9f3aad55b6b1d50f80ef1b1688c2ceb1c8a84 (patch)
tree84509440ef196e5741ece308a7f806d660accbda /cloudinit/util.py
parent26dd7461ce7ce9a6cba541ece94b802df772168b (diff)
parent451e48732ff7885502db2f8296777fa58b670f3b (diff)
downloadvyos-cloud-init-0bc9f3aad55b6b1d50f80ef1b1688c2ceb1c8a84.tar.gz
vyos-cloud-init-0bc9f3aad55b6b1d50f80ef1b1688c2ceb1c8a84.zip
merge from trunk for pep8 fixes
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index a8c0cceb..825867a7 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -24,8 +24,8 @@
from StringIO import StringIO
-import copy as obj_copy
import contextlib
+import copy as obj_copy
import errno
import glob
import grp
@@ -317,8 +317,9 @@ def multi_log(text, console=True, stderr=True,
else:
log.log(log_level, text)
+
def is_ipv4(instr):
- """ determine if input string is a ipv4 address. return boolean"""
+ """determine if input string is a ipv4 address. return boolean."""
toks = instr.split('.')
if len(toks) != 4:
return False
@@ -826,12 +827,12 @@ def get_cmdline_url(names=('cloud-config-url', 'url'),
def is_resolvable(name):
- """ determine if a url is resolvable, return a boolean
+ """determine if a url is resolvable, return a boolean
This also attempts to be resilent against dns redirection.
Note, that normal nsswitch resolution is used here. So in order
to avoid any utilization of 'search' entries in /etc/resolv.conf
- we have to append '.'.
+ we have to append '.'.
The top level 'invalid' domain is invalid per RFC. And example.com
should also not exist. The random entry will be resolved inside
@@ -847,7 +848,7 @@ def is_resolvable(name):
try:
result = socket.getaddrinfo(iname, None, 0, 0,
socket.SOCK_STREAM, socket.AI_CANONNAME)
- badresults[iname] = []
+ badresults[iname] = []
for (_fam, _stype, _proto, cname, sockaddr) in result:
badresults[iname].append("%s: %s" % (cname, sockaddr[0]))
badips.add(sockaddr[0])
@@ -856,7 +857,7 @@ def is_resolvable(name):
_DNS_REDIRECT_IP = badips
if badresults:
LOG.debug("detected dns redirection: %s" % badresults)
-
+
try:
result = socket.getaddrinfo(name, None)
# check first result's sockaddr field
@@ -874,7 +875,7 @@ def get_hostname():
def is_resolvable_url(url):
- """ determine if this url is resolvable (existing or ip) """
+ """determine if this url is resolvable (existing or ip)."""
return (is_resolvable(urlparse.urlparse(url).hostname))
@@ -1105,7 +1106,7 @@ def hash_blob(blob, routine, mlen=None):
def rename(src, dest):
LOG.debug("Renaming %s to %s", src, dest)
- # TODO use a se guard here??
+ # TODO(harlowja) use a se guard here??
os.rename(src, dest)