Class: Bosh::Stemcell::Aws::AmiCollection
- Inherits:
-
Object
- Object
- Bosh::Stemcell::Aws::AmiCollection
- Defined in:
- lib/bosh/stemcell/aws/ami_collection.rb
Constant Summary collapse
- MAX_COPY_IMAGE_WAIT_ATTEMPTS =
360
Instance Attribute Summary collapse
-
#stemcell ⇒ Object
readonly
Returns the value of attribute stemcell.
Instance Method Summary collapse
-
#initialize(stemcell, regions, virtualization_type) ⇒ AmiCollection
constructor
A new instance of AmiCollection.
- #publish ⇒ Object
Constructor Details
#initialize(stemcell, regions, virtualization_type) ⇒ AmiCollection
Returns a new instance of AmiCollection.
13 14 15 16 17 18 19 20 21 |
# File 'lib/bosh/stemcell/aws/ami_collection.rb', line 13 def initialize(stemcell, regions, virtualization_type) @stemcell = stemcell @seed_region = regions.first @dest_regions = regions - [@seed_region] @virtualization_type = virtualization_type @access_key_id = ENV['BOSH_AWS_ACCESS_KEY_ID'] @secret_access_key = ENV['BOSH_AWS_SECRET_ACCESS_KEY'] end |
Instance Attribute Details
#stemcell ⇒ Object (readonly)
Returns the value of attribute stemcell
11 12 13 |
# File 'lib/bosh/stemcell/aws/ami_collection.rb', line 11 def stemcell @stemcell end |
Instance Method Details
#publish ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bosh/stemcell/aws/ami_collection.rb', line 23 def publish logger = Logger.new('ami.log') cloud_config = OpenStruct.new(logger: logger, task_checkpoint: nil) Bosh::Clouds::Config.configure(cloud_config) cloud = Bosh::Clouds::Provider.create(, 'fake-director-uuid') region_ami_mapping = {} @stemcell.extract do |tmp_dir, stemcell_manifest| cloud_properties = stemcell_manifest['cloud_properties'].merge( 'virtualization_type' => @virtualization_type ) seed_ami_id = nil Bosh::Retryable.new(tries: 3, sleep: 20, on: [Bosh::Clouds::CloudError]).retryer do seed_ami_id = cloud.create_stemcell("#{tmp_dir}/image", cloud_properties) end seed_ami = cloud.ec2.images[seed_ami_id] seed_ami.public = true region_ami_mapping = copy_to_regions(logger, seed_ami_id, seed_ami.name, seed_ami.) region_ami_mapping[@seed_region] = seed_ami_id end region_ami_mapping end |