Class: BundleVolParameters
- Inherits:
-
BundleMachineParameters
- Object
- OptionParser
- ParametersBase
- BundleParameters
- BundleMachineParameters
- BundleVolParameters
- Defined in:
- lib/ec2/amitools/bundlevolparameters.rb
Overview
The Bundle Volume command line parameters.
Constant Summary collapse
- PREFIX_DESCRIPTION =
"The filename prefix for bundled AMI files. Defaults to \"image\"."
- EXCLUDE_DESCRIPTION =
["A comma-separated list of absolute directory paths, relative to", "the volume being bundled, to exclude. This option overrides the", "\"--all\" option."]
- INCLUDE_DESCRIPTION =
["Linux Only. A comma-separated list of absolute file paths, relative", "to the volume being bundled, to include. This option overrides the", "default filtered files list."]
- FILTER_DESCRIPTION =
"Do not use the default filtered files list."
- CLONE_VOLUME_DESCRIPTION =
'Clone volume into an image but do not generate a bundle.'
- ALL_DESCRIPTION =
["Include all directories in the volume being bundled, including those", "on remotely mounted filesystems."]
- SIZE_DESCRIPTION =
["The size, in MB (1024 * 1024 bytes), of the image file to create.", "The maximum size is 10240 MB."]
- VOLUME_DESCRIPTION =
"The absolute path to the mounted volume to be bundled. Defaults to \"/\"."
- FSTAB_DESCRIPTION =
"The absolute path to the fstab to be bundled into the image."
- GENERATE_FSTAB_DESCRIPTION =
["Inject a generated EC2 fstab. (Only use this if you are not rebundling", "an existing instance.)"]
- GRUB_CONFIG_DESCRIPTION =
"The absolute path to the grub config to be bundled into the image."
- PARTITION_TYPE_DESCRIPTION =
["Create a disk image using a partition table. Optionally, specify the", "partition table type to use. Viable options are 'mbr' or 'gpt'. If no", "partition table type is specified, the type used on the parent block", "device of the specified volume is used, if applicable, otherwise, we", "default to using 'gpt'. You may also specify 'none' to disable the use", "of partition tables, altogether." ]
- SCRIPT_DESCRIPTION =
['Executable customization script to call after cloning volume. The file', 'must expect a single argument: the mount point of the cloned volume.']
- INHERIT_DESCRIPTION =
['Inherit instance metadata. Enabled by default.', 'Bundling will fail if inherit is enabled but instance data', 'is not accessible, for example not bundling an EC2 instance.']
Constants inherited from BundleMachineParameters
BundleMachineParameters::ANCESTOR_AMI_IDS_DESCRIPTION, BundleMachineParameters::BDM_DESCRIPTION, BundleMachineParameters::KERNEL_DESCRIPTION, BundleMachineParameters::RAMDISK_DESCRIPTION
Constants inherited from BundleParameters
BundleParameters::ARCHITECTURE_DESCRIPTION, BundleParameters::BATCH_DESCRIPTION, BundleParameters::DEBUG_DESCRIPTION, BundleParameters::DESTINATION_DESCRIPTION, BundleParameters::EC2_CERT_PATH_DESCRIPTION, BundleParameters::HELP_DESCRIPTION, BundleParameters::MANUAL_DESCRIPTION, BundleParameters::PRODUCT_CODES_DESCRIPTION, BundleParameters::PROMPT_TIMEOUT, BundleParameters::SIZE_CHECKS_DESCRIPTION, BundleParameters::SUPPORTED_ARCHITECTURES, BundleParameters::USER_DESCRIPTION, BundleParameters::VERSION_DESCRIPTION
Constants inherited from ParametersBase
ParametersBase::BATCH_DESCRIPTION, ParametersBase::DEBUG_DESCRIPTION, ParametersBase::HELP_DESCRIPTION, ParametersBase::MANUAL_DESCRIPTION, ParametersBase::PASS_DESCRIPTION, ParametersBase::USER_ACCOUNT_DESCRIPTION, ParametersBase::USER_CERT_PATH_DESCRIPTION, ParametersBase::USER_DESCRIPTION, ParametersBase::USER_PK_PATH_DESCRIPTION, ParametersBase::VERSION_DESCRIPTION
Instance Attribute Summary collapse
-
#all ⇒ Object
Returns the value of attribute all.
-
#clone_only ⇒ Object
Returns the value of attribute clone_only.
-
#exclude ⇒ Object
Returns the value of attribute exclude.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#fstab ⇒ Object
Returns the value of attribute fstab.
-
#generate_fstab ⇒ Object
Returns the value of attribute generate_fstab.
-
#grub_config ⇒ Object
Returns the value of attribute grub_config.
-
#includes ⇒ Object
Returns the value of attribute includes.
-
#inherit ⇒ Object
Returns the value of attribute inherit.
-
#part_type ⇒ Object
Returns the value of attribute part_type.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#script ⇒ Object
Returns the value of attribute script.
-
#size ⇒ Object
Returns the value of attribute size.
-
#volume ⇒ Object
Returns the value of attribute volume.
Attributes inherited from BundleMachineParameters
#ancestor_ami_ids, #block_device_mapping, #kernel_id, #ramdisk_id
Attributes inherited from BundleParameters
#arch, #batch_mode, #debug, #destination, #ec2_cert_path, #manual, #product_codes, #show_help, #size_checks, #user, #user_cert_path, #user_pk_path
Attributes inherited from ParametersBase
#batch_mode, #debug, #manual, #show_help, #version
Instance Method Summary collapse
Methods inherited from BundleParameters
Methods inherited from ParametersBase
#assert_directory_exists, #assert_exists, #assert_file_executable, #assert_file_exists, #assert_glob_expands, #assert_good_key, #assert_option_in, #common_params, #early_exit?, #initialize, #interactive?, #mandatory_params, #version_copyright_string
Constructor Details
This class inherits a constructor from ParametersBase
Instance Attribute Details
#all ⇒ Object
Returns the value of attribute all.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def all @all end |
#clone_only ⇒ Object
Returns the value of attribute clone_only.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def clone_only @clone_only end |
#exclude ⇒ Object
Returns the value of attribute exclude.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def exclude @exclude end |
#filter ⇒ Object
Returns the value of attribute filter.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def filter @filter end |
#fstab ⇒ Object
Returns the value of attribute fstab.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def fstab @fstab end |
#generate_fstab ⇒ Object
Returns the value of attribute generate_fstab.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def generate_fstab @generate_fstab end |
#grub_config ⇒ Object
Returns the value of attribute grub_config.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def grub_config @grub_config end |
#includes ⇒ Object
Returns the value of attribute includes.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def includes @includes end |
#inherit ⇒ Object
Returns the value of attribute inherit.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def inherit @inherit end |
#part_type ⇒ Object
Returns the value of attribute part_type.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def part_type @part_type end |
#prefix ⇒ Object
Returns the value of attribute prefix.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def prefix @prefix end |
#script ⇒ Object
Returns the value of attribute script.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def script @script end |
#size ⇒ Object
Returns the value of attribute size.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def size @size end |
#volume ⇒ Object
Returns the value of attribute volume.
46 47 48 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 46 def volume @volume end |
Instance Method Details
#optional_params ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 61 def optional_params() super() on('-a', '--all', *ALL_DESCRIPTION) do @all = true end on('-e', '--exclude DIR1,DIR2,...', Array, *EXCLUDE_DESCRIPTION) do |p| @exclude = p end on('-i', '--include FILE1,FILE2,...', Array, *INCLUDE_DESCRIPTION) do |p| @includes = p end on('--no-filter', FILTER_DESCRIPTION) do @filter = false end on('-p', '--prefix PREFIX', String, PREFIX_DESCRIPTION) do |prefix| assert_good_key(prefix, '--prefix') @prefix = prefix end on('--clone-only', CLONE_VOLUME_DESCRIPTION) do @clone_only = true end on('-s', '--size MB', Integer, *SIZE_DESCRIPTION) do |p| @size = p end on('--[no-]inherit', *INHERIT_DESCRIPTION) do |p| @inherit = p end on('-v', '--volume PATH', String, VOLUME_DESCRIPTION) do |volume| assert_directory_exists(volume, '--volume') @volume = volume end on('--fstab PATH', String, FSTAB_DESCRIPTION) do |fstab| assert_file_exists(fstab, '--fstab') @fstab = fstab end on('--grub-config PATH', String, GRUB_CONFIG_DESCRIPTION) do |grub_config| assert_file_exists(grub_config, '--grub-config') @grub_config = grub_config end on('-P', '--partition TYPE', EC2::Platform::PartitionType.list, *PARTITION_TYPE_DESCRIPTION) do |ptype| @part_type = ptype end on('-S', '--script SCRIPT', String, *SCRIPT_DESCRIPTION) do |scriptfile| assert_file_executable(scriptfile, '--script') @script = scriptfile end on('--generate-fstab', *GENERATE_FSTAB_DESCRIPTION) do @generate_fstab = true end end |
#set_defaults ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 148 def set_defaults() super() @inherit = true if @inherit.nil? # false means a parameter was provided. @exclude ||= [] @includes ||= [] @filter = true if @filter.nil? @prefix ||= 'image' @size ||= MAX_SIZE_MB @volume ||= '/' @clone_only ||= false @part_type ||= :auto if @generate_fstab @fstab = :default @fstab = :legacy if @arch == "i386" end end |
#validate_params ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/ec2/amitools/bundlevolparameters.rb', line 126 def validate_params() raise InvalidCombination.new("--fstab", "--generate-fstab") if @fstab and @generate_fstab if @exclude volume = @volume || '/' @exclude.each do |dir| path = File::join(volume, dir) (path, '--exclude') end end if @includes volume = @volume || '/' @includes.each do |file| path = File::join(volume, file) (path, '--include') end end super() end |