Class: Miasma::Models::Orchestration::Stack::Plan

Inherits:
Types::Model show all
Defined in:
lib/miasma/models/orchestration/plan.rb

Overview

Stack update plan

Defined Under Namespace

Classes: Diff, Item

Constant Summary collapse

DIFF_ATTRIBUTES =
[
  :add, :remove, :replace, :interrupt, :unavailable, :unknown,
]

Instance Attribute Summary collapse

Attributes inherited from Types::Model

#api

Instance Method Summary collapse

Methods inherited from Types::Model

from_json, #id?, #persisted?, #reload, #save

Methods included from Utils::ApiMethoding

#api_method_for

Methods inherited from Types::Data

from_json, #from_json, #to_json

Constructor Details

#initialize(stack, args = {}) ⇒ Plan

Returns a new instance of Plan.



11
12
13
14
# File 'lib/miasma/models/orchestration/plan.rb', line 11

def initialize(stack, args = {})
  @stack = stack
  super stack.api, args
end

Instance Attribute Details

#stackObject (readonly)

Returns the value of attribute stack.



9
10
11
# File 'lib/miasma/models/orchestration/plan.rb', line 9

def stack
  @stack
end

Instance Method Details

#destroyStack

Destroy this stack plan

Returns:



70
71
72
73
74
75
76
77
# File 'lib/miasma/models/orchestration/plan.rb', line 70

def destroy
  if self == stack.plan
    stack.plan_destroy
  else
    raise Error::OrchestrationError::InvalidStackPlan.new "Plan is no longer valid for linked stack."
  end
  stack.reload
end

#empty?TrueClass, FalseClass

Plan has no modifications

Returns:

  • (TrueClass, FalseClass)


49
50
51
52
53
# File 'lib/miasma/models/orchestration/plan.rb', line 49

def empty?
  DIFF_ATTRIBUTES.all? { |attr|
    self.send(attr).empty?
  } && stacks.values.all? { |stk| stk.empty? }
end

#execute!Stack

Execute this stack plan

Returns:



58
59
60
61
62
63
64
65
# File 'lib/miasma/models/orchestration/plan.rb', line 58

def execute!
  if self == stack.plan
    stack.plan_execute
  else
    raise Error::OrchestrationError::InvalidStackPlan.new "Plan is no longer valid for linked stack."
  end
  stack.reload
end

#perform_reloadObject

Proxy reload action up to the API



80
81
82
# File 'lib/miasma/models/orchestration/plan.rb', line 80

def perform_reload
  api.stack_plan_reload(self)
end