summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Howard <ben.howard@canonical.com>2013-10-03 17:30:57 -0600
committerBen Howard <ben.howard@canonical.com>2013-10-03 17:30:57 -0600
commit7b5480e46e14c6e31492e0a1e9ef4eb05a9d746d (patch)
treed8d505daab74e30a08aa1ad9158ae372ab95aea1
parent193704c37b97a5687cab09416f9f38e632c76fa3 (diff)
downloadvyos-cloud-init-7b5480e46e14c6e31492e0a1e9ef4eb05a9d746d.tar.gz
vyos-cloud-init-7b5480e46e14c6e31492e0a1e9ef4eb05a9d746d.zip
Added support for 'ephmeral0.<auto|any|0>' for device mappings in disk
formating support.
-rw-r--r--cloudinit/config/cc_disk_setup.py27
-rw-r--r--doc/examples/cloud-config-disk-setup.txt11
2 files changed, 33 insertions, 5 deletions
diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
index 127b5879..5faffefc 100644
--- a/cloudinit/config/cc_disk_setup.py
+++ b/cloudinit/config/cc_disk_setup.py
@@ -94,6 +94,15 @@ def update_disk_setup_devices(disk_setup, tformer):
LOG.debug("updated disk_setup device entry '%s' to '%s'",
origname, transformed)
+def reset_part_definition(definition, value):
+ if not value and 'partition' in definition:
+ definition['opartition'] = definition['partition']
+ del definition['partition']
+
+ else:
+ definition['partition'] = value
+
+ return definition
def update_fs_setup_devices(disk_setup, tformer):
# update 'fs_setup' dictionary anywhere were a device may occur
@@ -109,17 +118,27 @@ def update_fs_setup_devices(disk_setup, tformer):
continue
transformed = None
- if len(origname.split('.')) > 1:
+ if len(origname.split('.')) == 2:
# this maps ephemeralX.Y to a proper disk name. For example,
# if the origname is 'ephemeral0.1' and transformed is /dev/sdb
# then the returned device will be /dev/sdb1 _if_ /dev/sdb1 exists
# otherwise NONE
- base_name = origname.split('.')[0]
+ base_name, partition = origname.split('.')
tformed = tformer(base_name)
LOG.info("base device for %s is %s" % (origname, tformed))
- transformed = util.map_device_alias(tformed, alias=origname)
- LOG.info("%s is mapped to %s" % (origname, transformed))
+ if partition == "0":
+ transformed = tformed
+ definition = reset_part_definition(definition, None)
+
+ elif partition in ("auto", "any"):
+ definition = reset_part_definition(definition, partition)
+ transformed = tformed
+
+ else:
+ definition = reset_part_definition(definition, None)
+ transformed = util.map_device_alias(tformed, alias=origname)
+ LOG.info("%s is mapped to %s" % (origname, transformed))
else:
transformed = tformer(origname)
diff --git a/doc/examples/cloud-config-disk-setup.txt b/doc/examples/cloud-config-disk-setup.txt
index bc6e1923..6ad61c33 100644
--- a/doc/examples/cloud-config-disk-setup.txt
+++ b/doc/examples/cloud-config-disk-setup.txt
@@ -170,6 +170,7 @@ The general format is:
device: <DEVICE>
partition: <PART_VALUE>
overwrite: <OVERWRITE>
+ replace_fs: <FS_TYPE>
Where:
<LABEL>: The file system label to be used. If set to None, no label is
@@ -189,7 +190,10 @@ Where:
If you define the device as 'ephemeralX.Y' then Y will be interpetted
as a partition value. However, ephermalX.0 is the _same_ as ephemeralX.
- <PART_VALUE>: The valid options are:
+ <PART_VALUE>:
+ Partition definitions are overwriten if you use the '<DEVICE>.Y' notation.
+
+ The valid options are:
"auto|any": tell cloud-init not to care whether there is a partition
or not. Auto will use the first partition that does not contain a
file system already. In the absence of a partition table, it will
@@ -238,5 +242,10 @@ Where:
"false": If an existing file system exists, skip the creation.
+ <REPLACE_FS>: This is a special directive, used for Windows Azure that
+ instructs cloud-init to replace a file system of <FS_TYPE>. NOTE:
+ unless you define a label, this requires the use of the 'any' partition
+ directive.
+
Behavior Caveat: The default behavior is to _check_ if the file system exists.
If a file system matches the specification, then the operation is a no-op.