Class: Hugo::Cloud
Instance Method Summary
collapse
#set_or_return, #validate
Constructor Details
#initialize ⇒ Cloud
Returns a new instance of Cloud.
8
9
10
|
# File 'lib/hugo/cloud.rb', line 8
def initialize
end
|
Instance Method Details
#app(name, &block) ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/hugo/cloud.rb', line 31
def app(name, &block)
app_info = Hugo::App.instance
app_info.name name
app_info.lb lb
app_info.db db
app_info.instance_eval(&block) if block_given?
cloud_app app_info
end
|
#balancer(&block) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/hugo/cloud.rb', line 24
def balancer(&block)
balancer = Hugo::Balancer.instance
balancer.name name
balancer.instance_eval(&block) if block_given?
lb balancer.deploy
end
|
#cloud_app(arg = nil) ⇒ Object
118
119
120
|
# File 'lib/hugo/cloud.rb', line 118
def cloud_app(arg=nil)
set_or_return(:cloud_app, arg, :kind_of => [Hugo::App])
end
|
#database(db_name, &block) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/hugo/cloud.rb', line 12
def database(db_name, &block)
database = Hugo::Database.instance
database.db_security_group name
database.server name
database.name db_name
database.instance_eval(&block) if block_given?
db database.deploy
end
|
#db(arg = nil) ⇒ Object
110
111
112
|
# File 'lib/hugo/cloud.rb', line 110
def db(arg=nil)
set_or_return(:db, arg, :kind_of => [Hugo::Database])
end
|
#delete ⇒ Object
50
51
52
53
54
55
|
# File 'lib/hugo/cloud.rb', line 50
def delete
[cloud_app, lb].each do |s|
s.destroy if s
end
db.rds.destroy
end
|
#deploy ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/hugo/cloud.rb', line 42
def deploy
if cloud_app
cloud_app.setup
cloud_app.deploy
end
end
|
#lb(arg = nil) ⇒ Object
114
115
116
|
# File 'lib/hugo/cloud.rb', line 114
def lb(arg=nil)
set_or_return(:lb, arg, :kind_of => [Hugo::Aws::Elb])
end
|
#name(arg = nil) ⇒ Object
106
107
108
|
# File 'lib/hugo/cloud.rb', line 106
def name(arg=nil)
set_or_return(:name, arg, :kind_of => [String])
end
|
#print ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/hugo/cloud.rb', line 59
def print
if db
puts <<REPORT
------------------------
DATABASE: #{db.info[:name]}
User: #{db.info[:user]}
Password: #{db.info[:password]}
Uri: #{db.info[:uri]}
REPORT
end
if lb
puts <<REPORT
-----------------------
Balancer: #{lb.name}
Uri: #{lb.uri}
Servers: #{lb.instances.length}
REPORT
lb.instances.each do |i|
ec2 = Hugo::Aws::Ec2.find(i)
puts <<REPORT
-----------------------
Id: #{ec2.name}
Uri: #{ec2.uri}
Type: #{ec2.type}
Zone: #{ec2.zone}
REPORT
end
else
ec2 = Hugo::Aws::Ec2.find(cloud_app.instance)
puts <<REPORT
Since you are not running a balancer
you need to remember to add #{ec2.name} as the instance method in your app
-----------------------
Id: #{ec2.name}
Uri: #{ec2.uri}
Type: #{ec2.type}
Zone: #{ec2.zone}
REPORT
end
end
|