summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorDaniel Watkins <daniel.watkins@canonical.com>2015-01-13 11:34:49 +0000
committerDaniel Watkins <daniel.watkins@canonical.com>2015-01-13 11:34:49 +0000
commit1a56b32de0d2954c172e2de2c756e08471e47b6e (patch)
treef0c1c7fb6592cf9f7cf57f75cbef66af1f8fa61f /cloudinit/config
parent29ab69a1e550ba52c436a6c605aa691d1f20623c (diff)
downloadvyos-cloud-init-1a56b32de0d2954c172e2de2c756e08471e47b6e.tar.gz
vyos-cloud-init-1a56b32de0d2954c172e2de2c756e08471e47b6e.zip
Implement check_partition_gpt_layout.
This includes moving some shared logic in to check_partition_layout.
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_disk_setup.py42
1 files changed, 30 insertions, 12 deletions
diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
index 6c5047a7..8334657e 100644
--- a/cloudinit/config/cc_disk_setup.py
+++ b/cloudinit/config/cc_disk_setup.py
@@ -393,6 +393,36 @@ def check_partition_mbr_layout(device, layout):
break
found_layout.append(type_label)
+ return found_layout
+
+
+def check_partition_gpt_layout(device, layout):
+ prt_cmd = ['sgdisk', '-p', device]
+ try:
+ out, _err = util.subp(prt_cmd)
+ except Exception as e:
+ raise Exception("Error running partition command on %s\n%s" % (
+ device, e))
+
+ out_lines = iter(out.splitlines())
+ # Skip header
+ for line in out_lines:
+ if line.strip().startswith('Number'):
+ break
+
+ return [line.strip().split()[-1] for line in out_lines]
+
+
+def check_partition_layout(table_type, device, layout):
+ """
+ See if the partition lay out matches.
+
+ This is future a future proofing function. In order
+ to add support for other disk layout schemes, add a
+ function called check_partition_%s_layout
+ """
+ found_layout = get_dyn_func(
+ "check_partition_%s_layout", table_type, device, layout)
if isinstance(layout, bool):
# if we are using auto partitioning, or "True" be happy
@@ -417,18 +447,6 @@ def check_partition_mbr_layout(device, layout):
return False
-def check_partition_layout(table_type, device, layout):
- """
- See if the partition lay out matches.
-
- This is future a future proofing function. In order
- to add support for other disk layout schemes, add a
- function called check_partition_%s_layout
- """
- return get_dyn_func("check_partition_%s_layout", table_type, device,
- layout)
-
-
def get_partition_mbr_layout(size, layout):
"""
Calculate the layout of the partition table. Partition sizes