lib/kitchen/driver/oci/blockstorage.rb in kitchen-oci-1.16.2 vs lib/kitchen/driver/oci/blockstorage.rb in kitchen-oci-1.17.0
- old
+ new
@@ -24,12 +24,10 @@
require_relative "api"
require_relative "config"
require_relative "models/iscsi"
require_relative "models/paravirtual"
- attr_accessor :config, :state, :oci, :api, :volume_state, :volume_attachment_state
-
def initialize(config, state, oci, api, action = :create)
super()
@config = config
@state = state
@oci = oci
@@ -37,10 +35,50 @@
@volume_state = {}
@volume_attachment_state = {}
oci.compartment if action == :create
end
+ #
+ # The config provided by the driver
+ #
+ # @return [Kitchen::LazyHash]
+ #
+ attr_accessor :config
+
+ #
+ # The definition of the state of the instance from the statefile
+ #
+ # @return [Hash]
+ #
+ attr_accessor :state
+
+ #
+ # The config object that contains properties of the authentication to OCI
+ #
+ # @return [Kitchen::Driver::Oci::Config]
+ #
+ attr_accessor :oci
+
+ #
+ # The API object that contains each of the authenticated clients for interfacing with OCI
+ #
+ # @return [Kitchen::Driver::Oci::Api]
+ #
+ attr_accessor :api
+
+ # The definition of the state of a volume
+ #
+ # @return [Hash]
+ #
+ attr_accessor :volume_state
+
+ # The definition of the state of a volume attachment
+ #
+ # @return [Hash]
+ #
+ attr_accessor :volume_attachment_state
+
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]}>.")
@@ -67,19 +105,9 @@
info("Detaching <#{attachment_name(volume_attachment)}>...")
api.compute.detach_volume(volume_attachment[:id])
api.compute.get_volume_attachment(volume_attachment[:id])
.wait_until(:lifecycle_state, OCI::Core::Models::VolumeAttachment::LIFECYCLE_STATE_DETACHED)
info("Finished detaching <#{attachment_name(volume_attachment)}>.")
- end
-
- def detatch_and_delete
- state[:volume_attachments].each do |att|
- detatch_volume(att)
- end
-
- state[:volumes].each do |vol|
- delete_volume(vol)
- end
end
def final_state(response)
case response
when OCI::Core::Models::Volume