Class: Kitchen::Driver::Oci::Blockstorage
- Inherits:
-
Kitchen::Driver::Oci
- Object
- Base
- Kitchen::Driver::Oci
- Kitchen::Driver::Oci::Blockstorage
- Defined in:
- lib/kitchen/driver/oci/blockstorage.rb
Overview
generic class for blockstorage
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#config ⇒ Object
Returns the value of attribute config.
-
#oci ⇒ Object
Returns the value of attribute oci.
-
#state ⇒ Object
Returns the value of attribute state.
-
#volume_attachment_state ⇒ Object
Returns the value of attribute volume_attachment_state.
-
#volume_state ⇒ Object
Returns the value of attribute volume_state.
Instance Method Summary collapse
- #attach_volume(volume_details, server_id) ⇒ Object
- #create_volume(volume) ⇒ Object
- #delete_volume(volume) ⇒ Object
- #detatch_and_delete ⇒ Object
- #detatch_volume(volume_attachment) ⇒ Object
- #final_state(response) ⇒ Object
-
#initialize(config, state, oci, api, action = :create) ⇒ Blockstorage
constructor
A new instance of Blockstorage.
Methods inherited from Kitchen::Driver::Oci
#create, #destroy, validation_error
Methods included from Models
#instance_class, #volume_class
Constructor Details
#initialize(config, state, oci, api, action = :create) ⇒ Blockstorage
Returns a new instance of Blockstorage.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 31 def initialize(config, state, oci, api, action = :create) super() @config = config @state = state @oci = oci @api = api @volume_state = {} @volume_attachment_state = {} oci.compartment if action == :create end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
29 30 31 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 29 def api @api end |
#config ⇒ Object
Returns the value of attribute config.
29 30 31 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 29 def config @config end |
#oci ⇒ Object
Returns the value of attribute oci.
29 30 31 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 29 def oci @oci end |
#state ⇒ Object
Returns the value of attribute state.
29 30 31 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 29 def state @state end |
#volume_attachment_state ⇒ Object
Returns the value of attribute volume_attachment_state.
29 30 31 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 29 def @volume_attachment_state end |
#volume_state ⇒ Object
Returns the value of attribute volume_state.
29 30 31 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 29 def volume_state @volume_state end |
Instance Method Details
#attach_volume(volume_details, server_id) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 50 def attach_volume(volume_details, server_id) info("Attaching <#{volume_details.display_name}>...") attach_volume = api.compute.attach_volume((volume_details, server_id)) response = (attach_volume.data.id) info("Finished attaching <#{volume_details.display_name}>.") final_state(response) end |
#create_volume(volume) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 42 def create_volume(volume) info("Creating <#{volume[:name]}>...") result = api.blockstorage.create_volume(volume_details(volume)) response = volume_response(result.data.id) info("Finished creating <#{volume[:name]}>.") [response, final_state(response)] end |
#delete_volume(volume) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 58 def delete_volume(volume) info("Deleting <#{volume[:display_name]}>...") api.blockstorage.delete_volume(volume[:id]) api.blockstorage.get_volume(volume[:id]) .wait_until(:lifecycle_state, OCI::Core::Models::Volume::LIFECYCLE_STATE_TERMINATED) info("Finished deleting <#{volume[:display_name]}>.") end |
#detatch_and_delete ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 74 def detatch_and_delete state[:volume_attachments].each do |att| detatch_volume(att) end state[:volumes].each do |vol| delete_volume(vol) end end |
#detatch_volume(volume_attachment) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 66 def detatch_volume() info("Detaching <#{()}>...") api.compute.detach_volume([:id]) api.compute.([:id]) .wait_until(:lifecycle_state, OCI::Core::Models::VolumeAttachment::LIFECYCLE_STATE_DETACHED) info("Finished detaching <#{()}>.") end |
#final_state(response) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 84 def final_state(response) case response when OCI::Core::Models::Volume final_volume_state(response) when OCI::Core::Models::VolumeAttachment (response) end end |