Class: OracleCloud::Orchestration
- Inherits:
-
Asset
- Object
- Asset
- OracleCloud::Orchestration
show all
- Defined in:
- lib/oraclecloud/orchestration.rb
Instance Attribute Summary
Attributes inherited from Asset
#asset_data, #asset_type, #client, #container, #path
Instance Method Summary
collapse
Methods inherited from Asset
#fetch, #full_name, #id, #initialize, #name_with_container, #strip_identity_domain, #validate!
Instance Method Details
#delete ⇒ Object
46
47
48
|
# File 'lib/oraclecloud/orchestration.rb', line 46
def delete
client.asset_delete(asset_type, name_with_container)
end
|
#description ⇒ Object
28
29
30
|
# File 'lib/oraclecloud/orchestration.rb', line 28
def description
asset_data['description']
end
|
#error? ⇒ Boolean
75
76
77
|
# File 'lib/oraclecloud/orchestration.rb', line 75
def error?
status == 'error'
end
|
#errors ⇒ Object
79
80
81
82
83
|
# File 'lib/oraclecloud/orchestration.rb', line 79
def errors
return [] unless launch_plan.key?('info') && launch_plan['info'].key?('errors')
launch_plan['info']['errors'].values
end
|
#instance_count ⇒ Object
71
72
73
|
# File 'lib/oraclecloud/orchestration.rb', line 71
def instance_count
instance_records.count
end
|
#instance_records ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/oraclecloud/orchestration.rb', line 56
def instance_records
return [] if launch_plan.nil? || launch_plan['objects'].nil?
instance_object = launch_plan['objects'].find { |x| x.respond_to?(:key?) && x.key?('instances') }
return [] if instance_object.nil?
instance_object['instances'].select { |x| x.key?('state') }
end
|
#instances ⇒ Object
65
66
67
68
69
|
# File 'lib/oraclecloud/orchestration.rb', line 65
def instances
return [] if instance_records.nil?
instance_records.map { |x| client.instances.by_name(x['name']) }
end
|
#launch_plan ⇒ Object
50
51
52
53
54
|
# File 'lib/oraclecloud/orchestration.rb', line 50
def launch_plan
return if asset_data['oplans'].nil?
asset_data['oplans'].find { |x| x['obj_type'] == 'launchplan' }
end
|
#local_init ⇒ Object
20
21
22
|
# File 'lib/oraclecloud/orchestration.rb', line 20
def local_init
@asset_type = 'orchestration'
end
|
#start ⇒ Object
32
33
34
35
36
37
|
# File 'lib/oraclecloud/orchestration.rb', line 32
def start
return if %w(starting ready).include?(status)
client.asset_put(asset_type, "#{name_with_container}?action=START")
refresh
end
|
#status ⇒ Object
24
25
26
|
# File 'lib/oraclecloud/orchestration.rb', line 24
def status
asset_data['status']
end
|
#stop ⇒ Object
39
40
41
42
43
44
|
# File 'lib/oraclecloud/orchestration.rb', line 39
def stop
return if status == 'stopped'
client.asset_put(asset_type, "#{name_with_container}?action=STOP")
refresh
end
|