Class: Kitchen::Driver::Oci::Models::Dbaas

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

Overview

Database system model.

Author:

  • Justin Steele <justin.steele@oracle.com>

Instance Attribute Summary collapse

Attributes inherited from Instance

#api, #config, #logger, #oci, #state

Instance Method Summary collapse

Methods inherited from Instance

#final_state

Methods included from Kitchen::Driver::Oci::Mixin::SshKeys

#algorithm, #generate_keys, #private_key_file, #public_key_file, #read_public_key

Methods included from Instance::CommonLaunchDetails

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

Methods inherited from Kitchen::Driver::Oci

#create, #destroy, #finalize_config!, validation_error

Methods included from Kitchen::Driver::Oci::Mixin::Volumes

#create_and_attach_volumes, #create_volume, #detatch_and_delete_volumes, #process_volumes

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

#instance_class, #volume_class

Methods included from Kitchen::Driver::Oci::Mixin::Actions

#are_legacy_imds_endpoints_disbled?, #auth, #execute_post_create_file, #execute_post_create_script, #execute_post_create_string, #instance_options, #instance_options?

Constructor Details

#initialize(opts = {}) ⇒ Dbaas

Returns a new instance of Dbaas.



31
32
33
34
35
36
# File 'lib/kitchen/driver/oci/models/dbaas.rb', line 31

def initialize(opts = {})
  super
  @launch_details = OCI::Database::Models::LaunchDbSystemDetails.new
  @database_details = OCI::Database::Models::CreateDatabaseDetails.new
  @db_home_details = OCI::Database::Models::CreateDbHomeDetails.new
end

Instance Attribute Details

#database_detailsOCI::Database::Models::CreateDatabaseDetails

The details model that describes the database.

Returns:

  • (OCI::Database::Models::CreateDatabaseDetails)


46
47
48
# File 'lib/kitchen/driver/oci/models/dbaas.rb', line 46

def database_details
  @database_details
end

#db_home_detailsOCI::Database::Models::CreateDbHomeDetails

The details model that describes the database home.

Returns:

  • (OCI::Database::Models::CreateDbHomeDetails)


51
52
53
# File 'lib/kitchen/driver/oci/models/dbaas.rb', line 51

def db_home_details
  @db_home_details
end

#launch_detailsOCI::Database::Models::LaunchDbSystemDetails

The details model that describes the db system.

Returns:

  • (OCI::Database::Models::LaunchDbSystemDetails)


41
42
43
# File 'lib/kitchen/driver/oci/models/dbaas.rb', line 41

def launch_details
  @launch_details
end

Instance Method Details

#launchHash

Launches a database system.

Returns:

  • (Hash)

    the finalized state after the instance has been launched and is running.



56
57
58
59
60
61
62
63
# File 'lib/kitchen/driver/oci/models/dbaas.rb', line 56

def launch
  response = api.dbaas.launch_db_system(launch_instance_details)
  instance_id = response.data.id

  api.dbaas.get_db_system(instance_id).wait_until(:lifecycle_state, OCI::Database::Models::DbSystem::LIFECYCLE_STATE_AVAILABLE,
                                                  max_interval_seconds: 900, max_wait_seconds: 21_600)
  final_state(state, instance_id)
end

#rebootObject

Reboots a DBaaS node.



73
74
75
76
77
# File 'lib/kitchen/driver/oci/models/dbaas.rb', line 73

def reboot
  db_node_id = dbaas_node(state[:server_id]).first.id
  api.dbaas.db_node_action(db_node_id, "SOFTRESET")
  api.dbaas.get_db_node(db_node_id).wait_until(:lifecycle_state, OCI::Database::Models::DbNode::LIFECYCLE_STATE_AVAILABLE)
end

#terminateObject

Terminates a DBaaS system.



66
67
68
69
70
# File 'lib/kitchen/driver/oci/models/dbaas.rb', line 66

def terminate
  api.dbaas.terminate_db_system(state[:server_id])
  api.dbaas.get_db_system(state[:server_id]).wait_until(:lifecycle_state, OCI::Database::Models::DbSystem::LIFECYCLE_STATE_TERMINATING,
                                                        max_interval_seconds: 900, max_wait_seconds: 21_600)
end