Class: OracleCloud::Orchestrations

Inherits:
Assets
  • Object
show all
Defined in:
lib/oraclecloud/orchestrations.rb

Instance Attribute Summary

Attributes inherited from Assets

#asset_klass, #asset_type, #client, #create_opts

Instance Method Summary collapse

Methods inherited from Assets

#all, #all_asset_ids_by_container, #asset_ids_for_container, #by_name, #containers, #create, #directory, #ids_from_results, #initialize, #strip_identity_domain, #validate!

Constructor Details

This class inherits a constructor from OracleCloud::Assets

Instance Method Details

#create_request_payloadObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/oraclecloud/orchestrations.rb', line 36

def create_request_payload
  {
    'name' => "#{client.full_identity_domain}/#{client.username}/#{create_opts[:name]}",
    'relationships' => [],
    'account' => "#{client.full_identity_domain}/default",
    'description' => create_opts[:description],
    'schedule' => { 'start_time' => nil, 'stop_time' => nil },
    'uri' => nil,
    'oplans' => [
      {
        'status' => 'unknown',
        'info' => {},
        'obj_type' => 'launchplan',
        'ha_policy' => 'active',
        'label' => create_opts[:launch_plan_label],
        'objects' => [
          {
            'instances' => create_opts[:instances].map(&:to_h)
          }
        ]
      }
    ]
  }
end

#local_initObject



23
24
25
26
# File 'lib/oraclecloud/orchestrations.rb', line 23

def local_init
  @asset_type  = 'orchestration'
  @asset_klass = OracleCloud::Orchestration
end

#validate_create_options!Object

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
# File 'lib/oraclecloud/orchestrations.rb', line 28

def validate_create_options!
  raise ArgumentError, 'instances option must be an array of instance requests to create' unless create_opts[:instances].respond_to?(:each)
  raise ArgumentError, 'orchestration description is required' unless create_opts[:description]

  create_opts[:name] = SecureRandom.uuid unless create_opts[:name]
  create_opts[:launch_plan_label] = 'launch_plan' unless create_opts[:launch_plan_label]
end