summaryrefslogtreecommitdiff
path: root/cloudinit/tests/helpers.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2018-04-26 16:24:24 -0500
committerRyan Harper <ryan.harper@canonical.com>2018-04-26 16:24:24 -0500
commit6ef92c98c3d2b127b05d6708337efc8a81e00071 (patch)
tree9d7bc15bbc750effce7e90915ef47fc10aee649d /cloudinit/tests/helpers.py
parent4731c8da25ee9bfbcf0ade1d7ffec95814d8622a (diff)
downloadvyos-cloud-init-6ef92c98c3d2b127b05d6708337efc8a81e00071.tar.gz
vyos-cloud-init-6ef92c98c3d2b127b05d6708337efc8a81e00071.zip
IBMCloud: recognize provisioning environment during debug boots.
When images are deployed from template in a production environment the artifacts of the provisioning stage (provisioningConfiguration.cfg) that cloud-init referenced are cleaned up. However, when provisioned in "debug" mode (internal to IBM) the artifacts are left. This changes the 'is_ibm_provisioning' implementations in both ds-identify and in the IBM datasource to identify the provisioning stage more correctly. The change is to consider provisioning only if the provisioing file existed and there was no log file or the log file was older than this boot. LP: #1767166
Diffstat (limited to 'cloudinit/tests/helpers.py')
-rw-r--r--cloudinit/tests/helpers.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/cloudinit/tests/helpers.py b/cloudinit/tests/helpers.py
index 4999f1f6..117a9cfe 100644
--- a/cloudinit/tests/helpers.py
+++ b/cloudinit/tests/helpers.py
@@ -8,6 +8,7 @@ import os
import shutil
import sys
import tempfile
+import time
import unittest
import mock
@@ -263,7 +264,8 @@ class FilesystemMockingTestCase(ResourceUsingTestCase):
os.path: [('isfile', 1), ('exists', 1),
('islink', 1), ('isdir', 1), ('lexists', 1)],
os: [('listdir', 1), ('mkdir', 1),
- ('lstat', 1), ('symlink', 2)]
+ ('lstat', 1), ('symlink', 2),
+ ('stat', 1)]
}
if hasattr(os, 'scandir'):
@@ -349,6 +351,15 @@ def populate_dir(path, files):
return ret
+def populate_dir_with_ts(path, data):
+ """data is {'file': ('contents', mtime)}. mtime relative to now."""
+ populate_dir(path, dict((k, v[0]) for k, v in data.items()))
+ btime = time.time()
+ for fpath, (_contents, mtime) in data.items():
+ ts = btime + mtime if mtime else btime
+ os.utime(os.path.sep.join((path, fpath)), (ts, ts))
+
+
def dir2dict(startdir, prefix=None):
flist = {}
if prefix is None: