Created
February 24, 2014 20:54
-
-
Save andrewgross/9196823 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _parse_block_device_mappings(user_input): | |
""" | |
Parse block device mappings per AWS CLI tools syntax (modified to add IOPS) | |
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html | |
Syntax: | |
/dev/xvd[a-z]=[snapshot-id|ephemeral]:[size in GB]:[Delete on Term]:[IOPS] | |
- Leave inapplicable fields blank | |
- Delete on Termination defaults to True | |
- IOPS limits are not validated | |
- EBS sizing is not validated | |
Mount an Ephemeral Drive: | |
/dev/xvdb1=ephemeral0 | |
Mount multiple Ephemeral Drives: | |
/dev/xvdb1=ephemeral0,/dev/xvdb2=ephemeral1 | |
Mount a Snapshot: | |
/dev/xvdp=snap-1234abcd | |
Mount a Snapshot to a 100GB drive: | |
/dev/xvdp=snap-1234abcd:100 | |
Mount a Snapshot to a 100GB drive and do not delete on termination: | |
/dev/xvdp=snap-1234abcd:100:false | |
Mount a Fresh 100GB EBS device | |
/dev/xvdp=:100 | |
Mount a Fresh 100GB EBS Device and do not delete on termination: | |
/dev/xvdp=:100:false | |
Mount a Fresh 100GB EBS Device with 1000 IOPS | |
/dev/xvdp=:100::1000 | |
""" | |
block_device_map = BlockDeviceMapping() | |
mappings = user_input.split(",") | |
for mapping in mappings: | |
mount_point, drive = mapping.split("=") | |
block_type = BlockDeviceType() | |
if "ephemeral" in drive: | |
pass | |
elif "snapshot" in drive: | |
pass | |
elif ":" in drive: | |
pass | |
else: | |
pass | |
block_device_map[mount_point] = block_type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment