Module: Kitchen::Driver::Oci::Mixin::Volumes
- Included in:
- Kitchen::Driver::Oci
- Defined in:
- lib/kitchen/driver/oci/mixin/volumes.rb
Overview
Mixins for working with volumes and attachments.
Instance Method Summary collapse
-
#create_and_attach_volumes(config, state, oci, api) ⇒ Object
Create and attach volumes.
-
#create_volume(vol, volume) ⇒ Object
Creates or clones the volume.
-
#detatch_and_delete_volumes(state, oci, api) ⇒ Object
Detatch and delete volumes.
-
#process_volumes(config, state, oci, api) ⇒ Hash
Process volumes specified in the kitchen config.
Instance Method Details
#create_and_attach_volumes(config, state, oci, api) ⇒ Object
Create and attach volumes.
34 35 36 37 38 39 |
# File 'lib/kitchen/driver/oci/mixin/volumes.rb', line 34 def create_and_attach_volumes(config, state, oci, api) return if config[:volumes].empty? volume_state = process_volumes(config, state, oci, api) state.merge!(volume_state) end |
#create_volume(vol, volume) ⇒ Object
Creates or clones the volume.
77 78 79 80 81 82 83 |
# File 'lib/kitchen/driver/oci/mixin/volumes.rb', line 77 def create_volume(vol, volume) if volume.key?(:volume_id) vol.create_clone_volume(volume) else vol.create_volume(volume) end end |
#detatch_and_delete_volumes(state, oci, api) ⇒ Object
Detatch and delete volumes.
46 47 48 49 50 51 52 |
# File 'lib/kitchen/driver/oci/mixin/volumes.rb', line 46 def detatch_and_delete_volumes(state, oci, api) return unless state[:volumes] bls = Blockstorage.new(config: config, state: state, oci: oci, api: api, action: :destroy, logger: instance.logger) state[:volume_attachments].each { |att| bls.detatch_volume(att) } state[:volumes].each { |vol| bls.delete_volume(vol) } end |
#process_volumes(config, state, oci, api) ⇒ Hash
Process volumes specified in the kitchen config.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/kitchen/driver/oci/mixin/volumes.rb', line 61 def process_volumes(config, state, oci, api) volume_state = { volumes: [], volume_attachments: [] } config[:volumes].each do |volume| vol = volume_class(volume[:type], config, state, oci, api) volume_details, vol_state = create_volume(vol, volume) attach_state = vol.attach_volume(volume_details, state[:server_id], volume) volume_state[:volumes] << vol_state volume_state[:volume_attachments] << attach_state end volume_state end |