summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceOVF.py
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2016-03-03 17:16:13 -0600
committerRyan Harper <ryan.harper@canonical.com>2016-03-03 17:16:13 -0600
commit63357ed731710b2418810535d9c991adbaea8dcb (patch)
tree5c553b0671669beb204c4edb3d82ebeda78d7cd3 /cloudinit/sources/DataSourceOVF.py
parentb1046db66bbed6a063f218992449b8abfd1ae99b (diff)
parent3d9153d16b194e7a3139c290e723ef17518e617d (diff)
downloadvyos-cloud-init-63357ed731710b2418810535d9c991adbaea8dcb.tar.gz
vyos-cloud-init-63357ed731710b2418810535d9c991adbaea8dcb.zip
Apply pep8, pyflakes fixes for python2 and 3
Update make check target to use pep8, pyflakes, pyflakes3.
Diffstat (limited to 'cloudinit/sources/DataSourceOVF.py')
-rw-r--r--cloudinit/sources/DataSourceOVF.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/cloudinit/sources/DataSourceOVF.py b/cloudinit/sources/DataSourceOVF.py
index d12601a4..be467bad 100644
--- a/cloudinit/sources/DataSourceOVF.py
+++ b/cloudinit/sources/DataSourceOVF.py
@@ -66,18 +66,21 @@ class DataSourceOVF(sources.DataSource):
system_type = util.read_dmi_data("system-product-name")
if system_type is None:
- LOG.debug("No system-product-name found")
+ LOG.debug("No system-product-name found")
elif 'vmware' in system_type.lower():
LOG.debug("VMware Virtual Platform found")
- deployPkgPluginPath = search_file("/usr/lib/vmware-tools", "libdeployPkgPlugin.so")
+ deployPkgPluginPath = search_file("/usr/lib/vmware-tools",
+ "libdeployPkgPlugin.so")
if deployPkgPluginPath:
- vmwareImcConfigFilePath = util.log_time(logfunc=LOG.debug,
+ vmwareImcConfigFilePath = \
+ util.log_time(logfunc=LOG.debug,
msg="waiting for configuration file",
func=wait_for_imc_cfg_file,
args=("/tmp", "cust.cfg"))
if vmwareImcConfigFilePath:
- LOG.debug("Found VMware DeployPkg Config File Path at %s" % vmwareImcConfigFilePath)
+ LOG.debug("Found VMware DeployPkg Config File Path at %s" %
+ vmwareImcConfigFilePath)
else:
LOG.debug("Didn't find VMware DeployPkg Config File Path")
@@ -147,7 +150,7 @@ class DataSourceOVF(sources.DataSource):
def get_public_ssh_keys(self):
if 'public-keys' not in self.metadata:
- return []
+ return []
pks = self.metadata['public-keys']
if isinstance(pks, (list)):
return pks
@@ -170,7 +173,7 @@ class DataSourceOVFNet(DataSourceOVF):
def wait_for_imc_cfg_file(dirpath, filename, maxwait=180, naplen=5):
waited = 0
-
+
while waited < maxwait:
fileFullPath = search_file(dirpath, filename)
if fileFullPath:
@@ -179,6 +182,7 @@ def wait_for_imc_cfg_file(dirpath, filename, maxwait=180, naplen=5):
waited += naplen
return None
+
# This will return a dict with some content
# meta-data, user-data, some config
def read_vmware_imc(config):
@@ -186,13 +190,14 @@ def read_vmware_imc(config):
cfg = {}
ud = ""
if config.host_name:
- if config.domain_name:
- md['local-hostname'] = config.host_name + "." + config.domain_name
- else:
- md['local-hostname'] = config.host_name
+ if config.domain_name:
+ md['local-hostname'] = config.host_name + "." + config.domain_name
+ else:
+ md['local-hostname'] = config.host_name
return (md, ud, cfg)
+
# This will return a dict with some content
# meta-data, user-data, some config
def read_ovf_environment(contents):
@@ -328,14 +333,14 @@ def get_properties(contents):
# could also check here that elem.namespaceURI ==
# "http://schemas.dmtf.org/ovf/environment/1"
propSections = find_child(dom.documentElement,
- lambda n: n.localName == "PropertySection")
+ lambda n: n.localName == "PropertySection")
if len(propSections) == 0:
raise XmlError("No 'PropertySection's")
props = {}
propElems = find_child(propSections[0],
- (lambda n: n.localName == "Property"))
+ (lambda n: n.localName == "Property"))
for elem in propElems:
key = elem.attributes.getNamedItemNS(envNsURI, "key").value
@@ -347,7 +352,7 @@ def get_properties(contents):
def search_file(dirpath, filename):
if not dirpath or not filename:
- return None
+ return None
for root, dirs, files in os.walk(dirpath):
if filename in files:
@@ -355,6 +360,7 @@ def search_file(dirpath, filename):
return None
+
class XmlError(Exception):
pass