Class: Kitchen::Driver::Oci::Models::Compute

Inherits:
Instance show all
Includes:
ComputeLaunchDetails
Defined in:
lib/kitchen/driver/oci/models/compute.rb

Overview

Compute instance model

Instance Attribute Summary collapse

Attributes inherited from Instance

#api, #config, #oci, #state

Instance Method Summary collapse

Methods inherited from Instance

#final_state

Methods included from Instance::CommonLaunchDetails

#availability_domain, #compartment_id, #defined_tags, #freeform_tags, #shape

Methods inherited from Kitchen::Driver::Oci

#create, #destroy, validation_error

Methods included from Kitchen::Driver::Oci::Models

#instance_class, #volume_class

Constructor Details

#initialize(config, state, oci, api, action) ⇒ Compute

Returns a new instance of Compute.



29
30
31
32
# File 'lib/kitchen/driver/oci/models/compute.rb', line 29

def initialize(config, state, oci, api, action)
  super
  @launch_details = OCI::Core::Models::LaunchInstanceDetails.new
end

Instance Attribute Details

#launch_detailsOCI::Core::Models::LaunchInstanceDetails

The details model that describes a compute instance

Returns:

  • (OCI::Core::Models::LaunchInstanceDetails)


39
40
41
# File 'lib/kitchen/driver/oci/models/compute.rb', line 39

def launch_details
  @launch_details
end

Instance Method Details

#launchObject



41
42
43
44
45
46
47
# File 'lib/kitchen/driver/oci/models/compute.rb', line 41

def launch
  process_windows_options
  response = api.compute.launch_instance(launch_instance_details)
  instance_id = response.data.id
  api.compute.get_instance(instance_id).wait_until(:lifecycle_state, OCI::Core::Models::Instance::LIFECYCLE_STATE_RUNNING)
  final_state(state, instance_id)
end

#rebootObject



54
55
56
57
# File 'lib/kitchen/driver/oci/models/compute.rb', line 54

def reboot
  api.compute.instance_action(state[:server_id], "SOFTRESET")
  api.compute.get_instance(state[:server_id]).wait_until(:lifecycle_state, OCI::Core::Models::Instance::LIFECYCLE_STATE_RUNNING)
end

#terminateObject



49
50
51
52
# File 'lib/kitchen/driver/oci/models/compute.rb', line 49

def terminate
  api.compute.terminate_instance(state[:server_id])
  api.compute.get_instance(state[:server_id]).wait_until(:lifecycle_state, OCI::Core::Models::Instance::LIFECYCLE_STATE_TERMINATING)
end