summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2018-03-23 17:17:55 -0600
committerChad Smith <chad.smith@canonical.com>2018-03-23 17:17:55 -0600
commite0f644b7c8c76bd63d242558685722cc70d9c51d (patch)
treece2e0609efb2bd3a1b3bfe3b8eb558bdb74038ca /cloudinit/util.py
parent68d798bb793052f589a7e48c508aca9031c7e271 (diff)
downloadvyos-cloud-init-e0f644b7c8c76bd63d242558685722cc70d9c51d.tar.gz
vyos-cloud-init-e0f644b7c8c76bd63d242558685722cc70d9c51d.zip
IBMCloud: Initial IBM Cloud datasource.
This adds a specific IBM Cloud datasource. IBM Cloud is identified by: a.) running on xen b.) one of a LABEL=METADATA disk or a LABEL=config-2 disk with UUID=9796-932E The datasource contains its own config-drive reader that reads only the currently supported portion of config-drive needed for ibm cloud. During the provisioning boot, cloud-init is disabled. See the docstring in DataSourceIBMCloud.py for more more information.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index cae8b196..fb4ee5fe 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1237,6 +1237,37 @@ def find_devs_with(criteria=None, oformat='device',
return entries
+def blkid(devs=None, disable_cache=False):
+ """Get all device tags details from blkid.
+
+ @param devs: Optional list of device paths you wish to query.
+ @param disable_cache: Bool, set True to start with clean cache.
+
+ @return: Dict of key value pairs of info for the device.
+ """
+ if devs is None:
+ devs = []
+ else:
+ devs = list(devs)
+
+ cmd = ['blkid', '-o', 'full']
+ if disable_cache:
+ cmd.extend(['-c', '/dev/null'])
+ cmd.extend(devs)
+
+ # we have to decode with 'replace' as shelx.split (called by
+ # load_shell_content) can't take bytes. So this is potentially
+ # lossy of non-utf-8 chars in blkid output.
+ out, _ = subp(cmd, capture=True, decode="replace")
+ ret = {}
+ for line in out.splitlines():
+ dev, _, data = line.partition(":")
+ ret[dev] = load_shell_content(data)
+ ret[dev]["DEVNAME"] = dev
+
+ return ret
+
+
def peek_file(fname, max_bytes):
LOG.debug("Peeking at %s (max_bytes=%s)", fname, max_bytes)
with open(fname, 'rb') as ifh: