Class: Hugo::App

Inherits:
Object
  • Object
show all
Includes:
Mixin::ParamsValidate, Singleton
Defined in:
lib/hugo/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin::ParamsValidate

#set_or_return, #validate

Instance Attribute Details

#dnaObject

Returns the value of attribute dna.



7
8
9
# File 'lib/hugo/app.rb', line 7

def dna
  @dna
end

Instance Method Details

#add_recipe(name, options = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/hugo/app.rb', line 38

def add_recipe(name, options=nil)
  run_list [] if run_list.nil?
  run_list << "recipe[#{name}]"
  if options
    empty_hash = {}
    self.dna = {} if self.dna.nil?
    self.dna.merge!(options)
  end
end

#application(arg = nil) ⇒ Object



76
77
78
# File 'lib/hugo/app.rb', line 76

def application(arg=nil)
  set_or_return(:application, arg, :kind_of => [String]) 
end

#cloud_name(arg = nil) ⇒ Object



84
85
86
# File 'lib/hugo/app.rb', line 84

def cloud_name(arg=nil)
  set_or_return(:cloud_name, arg, :kind_of => [String])
end

#cookbook(arg = nil) ⇒ Object



92
93
94
# File 'lib/hugo/app.rb', line 92

def cookbook(arg=nil)
  set_or_return(:cookbook, arg, :kind_of => [String])
end

#db(arg = nil) ⇒ Object



56
57
58
# File 'lib/hugo/app.rb', line 56

def db(arg=nil)
  set_or_return(:db, arg, :kind_of => [Hugo::Aws::Rds]) 
end

#deployObject



26
27
28
29
# File 'lib/hugo/app.rb', line 26

def deploy
  deploy_ec2
  puts "Deploy Completed"    
end

#deploy_info(arg = nil) ⇒ Object



104
105
106
# File 'lib/hugo/app.rb', line 104

def deploy_info(arg=nil)
  set_or_return(:deploy_info, arg, :kind_of => [Hash])                    
end

#destroyObject



31
32
33
34
35
# File 'lib/hugo/app.rb', line 31

def destroy
  lb.instances.each do |i|
    Hugo::Aws::Ec2.find(i).destroy
  end    
end

#image_id(arg = nil) ⇒ Object



72
73
74
# File 'lib/hugo/app.rb', line 72

def image_id(arg=nil)
  set_or_return(:image_id, arg, :kind_of => [String]) 
end

#key_name(arg = nil) ⇒ Object



88
89
90
# File 'lib/hugo/app.rb', line 88

def key_name(arg=nil)
  set_or_return(:key_name, arg, :kind_of => [String])
end

#key_path(arg = nil) ⇒ Object



96
97
98
# File 'lib/hugo/app.rb', line 96

def key_path(arg=nil)
  set_or_return(:key_pair_file, arg, :kind_of => [String])    
end

#lb(arg = nil) ⇒ Object



52
53
54
# File 'lib/hugo/app.rb', line 52

def lb(arg=nil)
  set_or_return(:lb, arg, :kind_of => [Hugo::Aws::Elb]) 
end

#name(arg = nil) ⇒ Object



48
49
50
# File 'lib/hugo/app.rb', line 48

def name(arg=nil)
  set_or_return(:name, arg, :kind_of => [String]) 
end

#run_list(arg = nil) ⇒ Object



100
101
102
# File 'lib/hugo/app.rb', line 100

def run_list(arg=nil)
  set_or_return(:run_list, arg, :kind_of => [Array])                
end

#security_group(arg = nil) ⇒ Object



80
81
82
# File 'lib/hugo/app.rb', line 80

def security_group(arg=nil)
  set_or_return(:security_group, arg, :kind_of => [String]) 
end

#servers(instances = 1) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/hugo/app.rb', line 9

def servers(instances=1)
  if lb
    if instances > lb.instances.length
      build_ec2(instances - lb.instances.length)
    elsif instances < lb.instances.length
      delete_ec2(lb.instances.length - instances)
    end    
  end
end

#setupObject



19
20
21
22
23
24
# File 'lib/hugo/app.rb', line 19

def setup
  lb.instances.each do |i|
    setup_ec2(i)
  end
  puts "Setup Completed"
end

#type(arg = nil) ⇒ Object



64
65
66
# File 'lib/hugo/app.rb', line 64

def type(arg=nil)
  set_or_return(:type, arg, :kind_of => [String]) 
end

#uri(arg = nil) ⇒ Object



60
61
62
# File 'lib/hugo/app.rb', line 60

def uri(arg=nil)
  set_or_return(:uri, arg, :kind_of => [String]) 
end

#zone(arg = nil) ⇒ Object



68
69
70
# File 'lib/hugo/app.rb', line 68

def zone(arg=nil)
  set_or_return(:zone, arg, :kind_of => [String]) 
end