Class: UploadBundleParameters
- Inherits:
-
S3ToolParameters
- Object
- OptionParser
- ParametersBase
- S3ToolParameters
- UploadBundleParameters
- Defined in:
- lib/ec2/amitools/uploadbundleparameters.rb
Overview
——————————————————————————#
Constant Summary collapse
- MANIFEST_DESCRIPTION =
"The path to the manifest file."
- ACL_DESCRIPTION =
["The access control list policy [\"public-read\" | \"aws-exec-read\"].", "Defaults to \"aws-exec-read\"."]
- DIRECTORY_DESCRIPTION =
["The directory containing the bundled AMI parts to upload.", "Defaults to the directory containing the manifest."]
- PART_DESCRIPTION =
"Upload the specified part and upload all subsequent parts."
- RETRY_DESCRIPTION =
"Automatically retry failed uploads."
- SKIP_MANIFEST_DESCRIPTION =
"Do not upload the manifest."
- LOCATION_DESCRIPTION =
"The location of the bucket to upload to [#{AwsRegion.s3_locations.join(',')}]."
Constants inherited from S3ToolParameters
S3ToolParameters::BUCKET_DESCRIPTION, S3ToolParameters::DEFAULT_REGION, S3ToolParameters::DEFAULT_URL, S3ToolParameters::DELEGATION_TOKEN_DESCRIPTION, S3ToolParameters::PROFILE_HOST, S3ToolParameters::PROFILE_PATH, S3ToolParameters::REGION_DESCRIPTION, S3ToolParameters::REGION_MAP, S3ToolParameters::SIGV2_DESCRIPTION, S3ToolParameters::URL_DESCRIPTION, S3ToolParameters::VALID_SIGV
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
-
#acl ⇒ Object
Returns the value of attribute acl.
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#location ⇒ Object
Returns the value of attribute location.
-
#manifest ⇒ Object
Returns the value of attribute manifest.
-
#part ⇒ Object
Returns the value of attribute part.
-
#retry ⇒ Object
Returns the value of attribute retry.
-
#skipmanifest ⇒ Object
Returns the value of attribute skipmanifest.
Attributes inherited from S3ToolParameters
#bucket, #keyprefix, #pass, #region, #sigv, #url, #user
Attributes inherited from ParametersBase
#batch_mode, #debug, #manual, #show_help, #version
Instance Method Summary collapse
-
#mandatory_params ⇒ Object
—————————————————————————-#.
-
#optional_params ⇒ Object
—————————————————————————-#.
-
#set_defaults ⇒ Object
—————————————————————————-#.
-
#validate_params ⇒ Object
—————————————————————————-#.
Methods inherited from S3ToolParameters
#get_creds_from_instance_profile, #split_container
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?, #version_copyright_string
Constructor Details
This class inherits a constructor from ParametersBase
Instance Attribute Details
#acl ⇒ Object
Returns the value of attribute acl.
28 29 30 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 28 def acl @acl end |
#directory ⇒ Object
Returns the value of attribute directory.
28 29 30 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 28 def directory @directory end |
#location ⇒ Object
Returns the value of attribute location.
28 29 30 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 28 def location @location end |
#manifest ⇒ Object
Returns the value of attribute manifest.
28 29 30 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 28 def manifest @manifest end |
#part ⇒ Object
Returns the value of attribute part.
28 29 30 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 28 def part @part end |
#retry ⇒ Object
Returns the value of attribute retry.
28 29 30 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 28 def retry @retry end |
#skipmanifest ⇒ Object
Returns the value of attribute skipmanifest.
28 29 30 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 28 def skipmanifest @skipmanifest end |
Instance Method Details
#mandatory_params ⇒ Object
—————————————————————————-#
38 39 40 41 42 43 44 45 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 38 def mandatory_params() super() on('-m', '--manifest PATH', String, MANIFEST_DESCRIPTION) do |manifest| assert_file_exists(manifest, '--manifest') @manifest = manifest end end |
#optional_params ⇒ Object
—————————————————————————-#
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 49 def optional_params() super() on('--acl ACL', String, *ACL_DESCRIPTION) do |acl| assert_option_in(acl, ['public-read', 'aws-exec-read'], '--acl') @acl = acl end on('-d', '--directory DIRECTORY', String, *DIRECTORY_DESCRIPTION) do |directory| assert_directory_exists(directory, '--directory') @directory = directory end on('--part PART', Integer, PART_DESCRIPTION) do |part| @part = part end on('--retry', RETRY_DESCRIPTION) do @retry = true end on('--skipmanifest', SKIP_MANIFEST_DESCRIPTION) do @skipmanifest = true end on('--location LOCATION', LOCATION_DESCRIPTION) do |location| assert_option_in(location, AwsRegion.s3_locations, '--location') @location = case location when "eu-west-1" then "EU" when "US" then :unconstrained else location end end end |
#set_defaults ⇒ Object
—————————————————————————-#
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 93 def set_defaults() super() @acl ||= 'aws-exec-read' @directory ||= File::dirname(@manifest) # If no location is given, set it equal to the region. # For legacy reasons if no location is given the location is set to US # If the region is us-east-1, we must not set the location. By not setting # the location S3 will default to the correct US location (which can't be # specified). if @region && !@location && !(@region == 'us-east-1') STDERR.puts "No location specified, setting location to conform with region: #{@region}" @location = @region end end |
#validate_params ⇒ Object
—————————————————————————-#
86 87 88 89 |
# File 'lib/ec2/amitools/uploadbundleparameters.rb', line 86 def validate_params() super() raise MissingMandatory.new('--manifest') unless @manifest end |