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 ⇒ Kitchen::Driver::Oci::Api
The API object that contains each of the authenticated clients for interfacing with OCI.
-
#config ⇒ Kitchen::LazyHash
The config provided by the driver.
-
#oci ⇒ Kitchen::Driver::Oci::Config
The config object that contains properties of the authentication to OCI.
-
#state ⇒ Hash
The definition of the state of the instance from the statefile.
-
#volume_attachment_state ⇒ Hash
The definition of the state of a volume attachment.
-
#volume_state ⇒ Hash
The definition of the state of a volume.
Instance Method Summary collapse
- #attach_volume(volume_details, server_id, volume_config) ⇒ Object
- #create_clone_volume(volume) ⇒ Object
- #create_volume(volume) ⇒ Object
- #delete_volume(volume) ⇒ 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.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 29 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 ⇒ Kitchen::Driver::Oci::Api
The API object that contains each of the authenticated clients for interfacing with OCI
66 67 68 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 66 def api @api end |
#config ⇒ Kitchen::LazyHash
The config provided by the driver
45 46 47 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 45 def config @config end |
#oci ⇒ Kitchen::Driver::Oci::Config
The config object that contains properties of the authentication to OCI
59 60 61 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 59 def oci @oci end |
#state ⇒ Hash
The definition of the state of the instance from the statefile
52 53 54 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 52 def state @state end |
#volume_attachment_state ⇒ Hash
The definition of the state of a volume attachment
78 79 80 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 78 def @volume_attachment_state end |
#volume_state ⇒ Hash
The definition of the state of a volume
72 73 74 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 72 def volume_state @volume_state end |
Instance Method Details
#attach_volume(volume_details, server_id, volume_config) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 97 def attach_volume(volume_details, server_id, volume_config) info("Attaching <#{volume_details.display_name}>...") attach_volume = api.compute.attach_volume((volume_details, server_id, volume_config)) response = (attach_volume.data.id) info("Finished attaching <#{volume_details.display_name}>.") final_state(response) end |
#create_clone_volume(volume) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 88 def create_clone_volume(volume) clone_volume_name = clone_volume_display_name(volume[:volume_id]) info("Creating <#{clone_volume_name}>...") result = api.blockstorage.create_volume(volume_clone_details(volume, clone_volume_name)) response = volume_response(result.data.id) info("Finished creating <#{clone_volume_name}>.") [response, final_state(response)] end |
#create_volume(volume) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 80 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
105 106 107 108 109 110 111 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 105 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_volume(volume_attachment) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 113 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
121 122 123 124 125 126 127 128 |
# File 'lib/kitchen/driver/oci/blockstorage.rb', line 121 def final_state(response) case response when OCI::Core::Models::Volume final_volume_state(response) when OCI::Core::Models::VolumeAttachment (response) end end |