Class: Miasma::Models::Orchestration::Stack
- Inherits:
-
Types::Model
- Object
- Types::Data
- Types::Model
- Miasma::Models::Orchestration::Stack
- Includes:
- Bogo::Memoization
- Defined in:
- lib/miasma/models/orchestration/stack.rb,
lib/miasma/models/orchestration/plan.rb,
lib/miasma/models/orchestration/event.rb,
lib/miasma/models/orchestration/plans.rb,
lib/miasma/models/orchestration/events.rb,
lib/miasma/models/orchestration/resource.rb,
lib/miasma/models/orchestration/resources.rb
Overview
Abstract server
Defined Under Namespace
Classes: Event, Events, Output, Plan, Plans, Resource, Resources
Constant Summary collapse
- VALID_PLAN_STATES =
Stack states which are valid to execute update plan
[ :create_complete, :update_complete, :update_failed, :rollback_complete, :rollback_failed, :unknown, ]
Instance Attribute Summary
Attributes inherited from Types::Model
Instance Method Summary collapse
- #events ⇒ Events
-
#load_data(args = {}) ⇒ Object
Overload the loader so we can extract resources, events, and outputs.
-
#plan_destroy ⇒ self
Delete the current plan.
-
#plan_execute ⇒ self
Execute current execute.
-
#plan_generate ⇒ Plan
Create a new stack plan.
- #plans ⇒ Plans
-
#reload ⇒ self
Override to scrub custom caches.
- #resources ⇒ Resources
-
#save ⇒ Object
Always perform save.
-
#validate ⇒ TrueClass
Validate the stack template.
Methods inherited from Types::Model
#destroy, from_json, #id?, #initialize, #persisted?
Methods included from Utils::ApiMethoding
Methods inherited from Types::Data
from_json, #from_json, #initialize, #to_json
Constructor Details
This class inherits a constructor from Miasma::Types::Model
Instance Method Details
#events ⇒ Events
139 140 141 142 143 |
# File 'lib/miasma/models/orchestration/stack.rb', line 139 def events memoize(:events) do Events.new(self) end end |
#load_data(args = {}) ⇒ Object
Overload the loader so we can extract resources, events, and outputs
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/miasma/models/orchestration/stack.rb', line 66 def load_data(args = {}) args = args.to_smash @resources = (args.delete(:resources) || []).each do |r| Resource.new(r) end @events = (args.delete(:events) || []).each do |e| Event.new(e) end super args end |
#plan_destroy ⇒ self
Delete the current plan
114 115 116 117 118 119 120 121 122 |
# File 'lib/miasma/models/orchestration/stack.rb', line 114 def plan_destroy if dirty?(:plan) perform_plan_destroy else raise Miasma::Error::OrchestrationError::InvalidStackPlan.new( "This stack instance does not have a generated plan" ) end end |
#plan_execute ⇒ self
Execute current execute
101 102 103 104 105 106 107 108 109 |
# File 'lib/miasma/models/orchestration/stack.rb', line 101 def plan_execute if dirty?(:plan) perform_plan_execute else raise Miasma::Error::OrchestrationError::InvalidStackPlan.new( "This stack instance does not have a generated plan" ) end end |
#plan_generate ⇒ Plan
Create a new stack plan
88 89 90 91 92 93 94 95 96 |
# File 'lib/miasma/models/orchestration/stack.rb', line 88 def plan_generate if plan raise Miasma::Error::OrchestrationError::StackPlanExists.new( "Plan already exists for this stack" ) else perform_plan end end |
#plans ⇒ Plans
146 147 148 149 150 |
# File 'lib/miasma/models/orchestration/stack.rb', line 146 def plans memoize(:plans) do Plans.new(self) end end |
#reload ⇒ self
Override to scrub custom caches
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/miasma/models/orchestration/stack.rb', line 127 def reload clear_memoizations! remove = data.keys.find_all do |k| ![:id, :name].include?(k.to_sym) end remove.each do |k| data.delete(k) end super end |
#resources ⇒ Resources
153 154 155 156 157 |
# File 'lib/miasma/models/orchestration/stack.rb', line 153 def resources memoize(:resources) do Resources.new(self) end end |
#save ⇒ Object
Always perform save. Remove dirty check provided by default.
161 162 163 |
# File 'lib/miasma/models/orchestration/stack.rb', line 161 def save perform_save end |
#validate ⇒ TrueClass
Validate the stack template
81 82 83 |
# File 'lib/miasma/models/orchestration/stack.rb', line 81 def validate perform_template_validate end |