Class: Hugo::App
- Inherits:
-
Object
- Object
- Hugo::App
- Includes:
- Mixin::ParamsValidate, Singleton
- Defined in:
- lib/hugo/app.rb
Constant Summary collapse
- AMI =
ENV['EC2_AMI_ID'] || 'ami-1515f67c'
- ZONE =
"us-east-1c"
- TYPE =
"m1.small"
Instance Attribute Summary collapse
-
#dna ⇒ Object
Returns the value of attribute dna.
Instance Method Summary collapse
-
#add_recipe(name, options = nil) ⇒ Object
Dyanamically add recipes to your json.
-
#aws_access_key_id(arg = nil) ⇒ Object
Aws Access Key for EC2 Deployment.
-
#aws_secret_access_key(arg = nil) ⇒ Object
Aws Access Secret Key for EC2 Deployment.
- #clear ⇒ Object
- #cookbook(arg = nil) ⇒ Object
-
#db(arg = nil) ⇒ Object
Database Object.
-
#deploy ⇒ Object
deploy will run you json with chef-sole against your cookbooks.
-
#destroy ⇒ Object
will kill all app servers.
- #help ⇒ Object
- #image_id(arg = nil) ⇒ Object
-
#instance(arg = nil) ⇒ Object
Set the instance if you only are deploying one server.
- #key_name(arg = nil) ⇒ Object
- #key_path(arg = nil) ⇒ Object
-
#lb(arg = nil) ⇒ Object
Load Balancer Object.
-
#name(arg = nil) ⇒ Object
Name of app - should relate to github repository.
- #run_list(arg = nil) ⇒ Object
- #security_group(arg = nil) ⇒ Object
-
#servers(instances = 1) ⇒ Object
How many servers do you want in your cloud This function will give and take away servers.
-
#setup ⇒ Object
Setup will install chef-solo on server instance.
-
#zone(arg = nil) ⇒ Object
def type(arg=nil) set_or_return(:type, arg, :kind_of => [String]) end.
Methods included from Mixin::ParamsValidate
Instance Attribute Details
#dna ⇒ Object
Returns the value of attribute dna.
12 13 14 |
# File 'lib/hugo/app.rb', line 12 def dna @dna end |
Instance Method Details
#add_recipe(name, options = nil) ⇒ Object
Dyanamically add recipes to your json
76 77 78 79 80 81 82 83 84 |
# File 'lib/hugo/app.rb', line 76 def add_recipe(name, =nil) run_list [] if run_list.nil? run_list << "recipe[#{name}]" if empty_hash = {} self.dna = {} if self.dna.nil? self.dna.merge!() end end |
#aws_access_key_id(arg = nil) ⇒ Object
Aws Access Key for EC2 Deployment
107 108 109 |
# File 'lib/hugo/app.rb', line 107 def aws_access_key_id(arg=nil) set_or_return(:aws_access_key_id, arg, :kind_of => [String]) end |
#aws_secret_access_key(arg = nil) ⇒ Object
Aws Access Secret Key for EC2 Deployment
112 113 114 |
# File 'lib/hugo/app.rb', line 112 def aws_secret_access_key(arg=nil) set_or_return(:aws_secret_access_key, arg, :kind_of => [String]) end |
#clear ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/hugo/app.rb', line 65 def clear @key_name = nil @key_path = nil @cookbook = nil @run_list = nil @aws_access_key_id = nil @aws_secret_access_key = nil end |
#cookbook(arg = nil) ⇒ Object
141 142 143 |
# File 'lib/hugo/app.rb', line 141 def cookbook(arg=nil) set_or_return(:cookbook, arg, :kind_of => [String]) end |
#db(arg = nil) ⇒ Object
Database Object
102 103 104 |
# File 'lib/hugo/app.rb', line 102 def db(arg=nil) set_or_return(:db, arg, :kind_of => [Hugo::Database]) end |
#deploy ⇒ Object
deploy will run you json with chef-sole against your cookbooks
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hugo/app.rb', line 41 def deploy raise ArgumentError, "app.key_name Required" unless key_name raise ArgumentError, "app.key_path Required" unless key_path raise ArgumentError, "app.cookbook Required" unless cookbook raise ArgumentError, "app.run_list Required" unless run_list raise ArgumentError, "app.aws_access_key_id Required" unless aws_access_key_id raise ArgumentError, "app.aws_secret_access_key Required" unless aws_secret_access_key deploy_ec2 #puts "Deploy Completed" end |
#destroy ⇒ Object
will kill all app servers
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hugo/app.rb', line 54 def destroy if lb lb.instances.each do |i| ec2(i).destroy end else ec2(instance).destroy end end |
#help ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/hugo/app.rb', line 154 def help x = <<HELP Hugo app ----------------- There are two ways to run hugo app, a single instance mode, or with a balancer. If you do not use a balancer, then after your initial run, which creates the server instance, you need to enter the server instance into your config, so it will not create a new ec2 everytime Required attributes ----------------- key_name key_path cookbook run_list Methods ------------------ servers deploy add_recipe destroy help Optional Attributes ----------------- instance lb db uri type zone image_id HELP puts x x end |
#image_id(arg = nil) ⇒ Object
129 130 131 |
# File 'lib/hugo/app.rb', line 129 def image_id(arg=nil) set_or_return(:image_id, arg, :kind_of => [String]) end |
#instance(arg = nil) ⇒ Object
Set the instance if you only are deploying one server
87 88 89 |
# File 'lib/hugo/app.rb', line 87 def instance(arg=nil) set_or_return(:instance, arg, :kind_of => [String]) end |
#key_name(arg = nil) ⇒ Object
137 138 139 |
# File 'lib/hugo/app.rb', line 137 def key_name(arg=nil) set_or_return(:key_name, arg, :kind_of => [String]) end |
#key_path(arg = nil) ⇒ Object
145 146 147 |
# File 'lib/hugo/app.rb', line 145 def key_path(arg=nil) set_or_return(:key_path, arg, :kind_of => [String]) end |
#lb(arg = nil) ⇒ Object
Load Balancer Object
97 98 99 |
# File 'lib/hugo/app.rb', line 97 def lb(arg=nil) set_or_return(:lb, arg, :kind_of => [Hugo::Aws::Elb]) end |
#name(arg = nil) ⇒ Object
Name of app - should relate to github repository
92 93 94 |
# File 'lib/hugo/app.rb', line 92 def name(arg=nil) set_or_return(:name, arg, :kind_of => [String]) end |
#run_list(arg = nil) ⇒ Object
149 150 151 |
# File 'lib/hugo/app.rb', line 149 def run_list(arg=nil) set_or_return(:run_list, arg, :kind_of => [Array]) end |
#security_group(arg = nil) ⇒ Object
133 134 135 |
# File 'lib/hugo/app.rb', line 133 def security_group(arg=nil) set_or_return(:security_group, arg, :kind_of => [String]) end |
#servers(instances = 1) ⇒ Object
How many servers do you want in your cloud This function will give and take away servers
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hugo/app.rb', line 16 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 else instance(build_ec2(1)) unless instance end end |
#setup ⇒ Object
Setup will install chef-solo on server instance
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hugo/app.rb', line 29 def setup if lb lb.instances.each do |i| setup_ec2(i) end else setup_ec2(instance) end # puts "Setup Completed" end |
#zone(arg = nil) ⇒ Object
def type(arg=nil)
set_or_return(:type, arg, :kind_of => [String])
end
125 126 127 |
# File 'lib/hugo/app.rb', line 125 def zone(arg=nil) set_or_return(:zone, arg, :kind_of => [String]) end |