summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceOVF.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-04 01:45:58 -0500
committerScott Moser <smoser@ubuntu.com>2016-03-04 01:45:58 -0500
commit8092805079d011093724d87e9485e5bf79479a72 (patch)
tree22e58fc368bc1ec27f527c153b8fe6fe27de4997 /cloudinit/sources/DataSourceOVF.py
parent3400f839651d308e495d1d8a1d7c1c2b463ad98b (diff)
parent63357ed731710b2418810535d9c991adbaea8dcb (diff)
downloadvyos-cloud-init-8092805079d011093724d87e9485e5bf79479a72.tar.gz
vyos-cloud-init-8092805079d011093724d87e9485e5bf79479a72.zip
Apply pep8, pyflakes fixes for python2 and 3
Update make check target to run pep8 and run pyflakes or pyflakes3 depending on the value of 'PYVER'. This way the python3 build environment does not need python2 and vice versa. Also have make check run the 'yaml' test. tox: have tox run pep8 in the pyflakes
Diffstat (limited to 'cloudinit/sources/DataSourceOVF.py')
-rw-r--r--cloudinit/sources/DataSourceOVF.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/cloudinit/sources/DataSourceOVF.py b/cloudinit/sources/DataSourceOVF.py
index d12601a4..8e97e51a 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,14 +360,15 @@ def search_file(dirpath, filename):
return None
+
class XmlError(Exception):
pass
# Used to match classes to dependencies
datasources = (
- (DataSourceOVF, (sources.DEP_FILESYSTEM, )),
- (DataSourceOVFNet, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
+ (DataSourceOVF, (sources.DEP_FILESYSTEM, )),
+ (DataSourceOVFNet, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
)