Class: Roark::AmiCreateWorkflow

Inherits:
Object
  • Object
show all
Defined in:
lib/roark/ami_create_workflow.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ AmiCreateWorkflow

Returns a new instance of AmiCreateWorkflow.



4
5
6
7
8
9
10
# File 'lib/roark/ami_create_workflow.rb', line 4

def initialize(args)
  @account_ids = Array(args[:account_ids])
  @ami         = args[:ami]
  @tags        = args.fetch :tags, {}
  @parameters  = args[:parameters]
  @template    = args[:template]
end

Instance Method Details

#add_tagsObject



50
51
52
# File 'lib/roark/ami_create_workflow.rb', line 50

def add_tags
  @ami.add_tags @tags
end

#authorize_account_idsObject



54
55
56
# File 'lib/roark/ami_create_workflow.rb', line 54

def 
  @ami. @account_ids
end

#create_amiObject



38
39
40
# File 'lib/roark/ami_create_workflow.rb', line 38

def create_ami
  @ami.create_ami
end

#create_instanceObject



21
22
23
24
# File 'lib/roark/ami_create_workflow.rb', line 21

def create_instance
  @ami.create_instance :parameters => @parameters,
                       :template   => @template
end

#destroy_instanceObject



46
47
48
# File 'lib/roark/ami_create_workflow.rb', line 46

def destroy_instance
  @ami.destroy_instance
end

#executeObject



12
13
14
15
16
17
18
19
# File 'lib/roark/ami_create_workflow.rb', line 12

def execute
  %w(create_instance wait_for_instance stop_instance wait_for_instance_to_stop
     create_ami wait_for_ami destroy_instance add_tags authorize_account_ids).each do |m|
    response = self.send m.to_sym
    return response unless response.success?
  end
  Response.new :code => 0, :message => "AMI create workflow completed succesfully."
end

#stop_instanceObject



30
31
32
# File 'lib/roark/ami_create_workflow.rb', line 30

def stop_instance
  @ami.stop_instance
end

#wait_for_amiObject



42
43
44
# File 'lib/roark/ami_create_workflow.rb', line 42

def wait_for_ami
  @ami.wait_for_ami
end

#wait_for_instanceObject



26
27
28
# File 'lib/roark/ami_create_workflow.rb', line 26

def wait_for_instance
  @ami.wait_for_instance
end

#wait_for_instance_to_stopObject



34
35
36
# File 'lib/roark/ami_create_workflow.rb', line 34

def wait_for_instance_to_stop
  @ami.wait_for_instance_to_stop
end