Class: Cloudshaper::Stack
- Inherits:
-
Object
- Object
- Cloudshaper::Stack
- Defined in:
- lib/cloudshaper/stack.rb
Overview
Wrapper to instantiate a stack from a yaml definition
Defined Under Namespace
Classes: MalformedConfig
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#module ⇒ Object
readonly
Returns the value of attribute module.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#stack_dir ⇒ Object
readonly
Returns the value of attribute stack_dir.
-
#stack_id ⇒ Object
readonly
Returns the value of attribute stack_id.
Class Method Summary collapse
Instance Method Summary collapse
- #apply ⇒ Object
- #destroy ⇒ Object
- #get ⇒ Object
-
#initialize(config) ⇒ Stack
constructor
A new instance of Stack.
- #plan ⇒ Object
- #pull ⇒ Object
- #push ⇒ Object
- #remote_config ⇒ Object
- #show ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(config) ⇒ Stack
Returns a new instance of Stack.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cloudshaper/stack.rb', line 22 def initialize(config) @name = config.fetch('name') @uuid = config.fetch('uuid') @remote = config['remote'] || {} @description = config['description'] || '' @stack_id = "cloudshaper#{@name}_#{@uuid}" @stack_dir = File.join(Stacks.dir, @stack_id) @module = StackModules.get(config.fetch('root')) @variables = config['variables'] || {} @variables['cloudshaper_stack_id'] = @stack_id @module.build(@variables.map { |k, v| [k.to_sym, v] }.to_h) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
19 20 21 |
# File 'lib/cloudshaper/stack.rb', line 19 def description @description end |
#module ⇒ Object (readonly)
Returns the value of attribute module.
19 20 21 |
# File 'lib/cloudshaper/stack.rb', line 19 def module @module end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/cloudshaper/stack.rb', line 19 def name @name end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
19 20 21 |
# File 'lib/cloudshaper/stack.rb', line 19 def remote @remote end |
#stack_dir ⇒ Object (readonly)
Returns the value of attribute stack_dir.
19 20 21 |
# File 'lib/cloudshaper/stack.rb', line 19 def stack_dir @stack_dir end |
#stack_id ⇒ Object (readonly)
Returns the value of attribute stack_id.
19 20 21 |
# File 'lib/cloudshaper/stack.rb', line 19 def stack_id @stack_id end |
Class Method Details
.load(config) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/cloudshaper/stack.rb', line 11 def load(config) fail MalformedConfig, "Configuration malformed at #{config}" unless config.is_a?(Hash) fail MalformedConfig, "A name must be specified for the stack #{config}" unless config.key?('name') fail MalformedConfig, 'You must specify a uuid. Get one from rake uuid and add it to the config' unless config.key?('uuid') new(config) end |
Instance Method Details
#apply ⇒ Object
37 38 39 |
# File 'lib/cloudshaper/stack.rb', line 37 def apply Command.new(self, :apply).execute end |
#destroy ⇒ Object
41 42 43 |
# File 'lib/cloudshaper/stack.rb', line 41 def destroy Command.new(self, :destroy).execute end |
#get ⇒ Object
49 50 51 |
# File 'lib/cloudshaper/stack.rb', line 49 def get Command.new(self, :get).execute end |
#plan ⇒ Object
45 46 47 |
# File 'lib/cloudshaper/stack.rb', line 45 def plan Command.new(self, :plan).execute end |
#pull ⇒ Object
57 58 59 |
# File 'lib/cloudshaper/stack.rb', line 57 def pull Remote.new(self, :pull).execute end |
#push ⇒ Object
61 62 63 |
# File 'lib/cloudshaper/stack.rb', line 61 def push Remote.new(self, :pull).execute end |
#remote_config ⇒ Object
65 66 67 |
# File 'lib/cloudshaper/stack.rb', line 65 def remote_config Remote.new(self, :config).execute end |
#show ⇒ Object
53 54 55 |
# File 'lib/cloudshaper/stack.rb', line 53 def show Command.new(self, :show).execute end |
#to_s ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/cloudshaper/stack.rb', line 69 def to_s <<-eos Name: #{@name} Description: #{@description} Stack Directory: #{@stack_dir} eos end |