summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceOVF.py
diff options
context:
space:
mode:
authorSankar Tanguturi <stanguturi@stanguturi-rhel>2016-02-16 17:34:24 -0800
committerSankar Tanguturi <stanguturi@stanguturi-rhel>2016-02-16 17:34:24 -0800
commit0ce71cb8975e19677eea415101e15da5f4095cd5 (patch)
tree7ba79660baedc87c86b6b9e98f9d13ce5a576367 /cloudinit/sources/DataSourceOVF.py
parent39f668e5db8d09c46eee3a5df73a69f8d85ba489 (diff)
downloadvyos-cloud-init-0ce71cb8975e19677eea415101e15da5f4095cd5.tar.gz
vyos-cloud-init-0ce71cb8975e19677eea415101e15da5f4095cd5.zip
- Used proper 4 space indentations for config_nic.py and nic.py
- Implemented the 'search_file' function using 'os.walk()' - Fixed few variable names. - Removed size() function in config_file.py - Updated the test_config_file.py to use len() instead of .size()
Diffstat (limited to 'cloudinit/sources/DataSourceOVF.py')
-rw-r--r--cloudinit/sources/DataSourceOVF.py34
1 files changed, 9 insertions, 25 deletions
diff --git a/cloudinit/sources/DataSourceOVF.py b/cloudinit/sources/DataSourceOVF.py
index add7d243..6d3bf7bb 100644
--- a/cloudinit/sources/DataSourceOVF.py
+++ b/cloudinit/sources/DataSourceOVF.py
@@ -64,13 +64,12 @@ class DataSourceOVF(sources.DataSource):
(seedfile, contents) = get_ovf_env(self.paths.seed_dir)
dmi_info = dmi_data()
- system_uuid = ""
system_type = ""
- if dmi_info is False:
+ if dmi_info is None:
LOG.debug("No dmidata utility found")
else:
- system_uuid, system_type = tuple(dmi_info)
+ (_, system_type) = dmi_info
if 'vmware' in system_type.lower():
LOG.debug("VMware Virtual Platform found")
@@ -172,11 +171,11 @@ class DataSourceOVFNet(DataSourceOVF):
self.supported_seed_starts = ("http://", "https://", "ftp://")
-def wait_for_imc_cfg_file(directoryPath, filename, maxwait=180, naplen=5):
+def wait_for_imc_cfg_file(dirpath, filename, maxwait=180, naplen=5):
waited = 0
while waited < maxwait:
- fileFullPath = search_file(directoryPath, filename)
+ fileFullPath = search_file(dirpath, filename)
if fileFullPath:
return fileFullPath
time.sleep(naplen)
@@ -357,28 +356,13 @@ def dmi_data():
return (sys_uuid.lower(), sys_type)
-def search_file(directoryPath, filename):
- if not directoryPath or not filename:
+def search_file(dirpath, filename):
+ if not dirpath or not filename:
return None
- dirs = []
-
- if os.path.isdir(directoryPath):
- dirs.append(directoryPath)
-
- while dirs:
- dir = dirs.pop()
- children = []
- try:
- children.extend(os.listdir(dir))
- except:
- LOG.debug("Ignoring the error while searching the directory %s" % dir)
- for child in children:
- childFullPath = os.path.join(dir, child)
- if os.path.isdir(childFullPath):
- dirs.append(childFullPath)
- elif child == filename:
- return childFullPath
+ for root, dirs, files in os.walk(dirpath):
+ if filename in files:
+ return os.path.join(root, filename)
return None