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
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/hugo/cloud.rb', line 32
def app(name, &block)
app_info = Hugo::App.instance
app_info.name name
app_info.lb lb
app_info.db db
app_info.cloud_name name
app_info.instance_eval(&block) if block_given?
cloud_app app_info
end
|
#balancer(&block) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/hugo/cloud.rb', line 25
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
105
106
107
|
# File 'lib/hugo/cloud.rb', line 105
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
23
|
# 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
97
98
99
|
# File 'lib/hugo/cloud.rb', line 97
def db(arg=nil)
set_or_return(:db, arg, :kind_of => [Hugo::Aws::Rds])
end
|
#delete ⇒ Object
51
52
53
54
55
|
# File 'lib/hugo/cloud.rb', line 51
def delete
[db, cloud_app, lb].each do |s|
s.destroy if s
end
end
|
#deploy ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/hugo/cloud.rb', line 43
def deploy
if cloud_app
cloud_app.setup
cloud_app.deploy
end
end
|
#lb(arg = nil) ⇒ Object
101
102
103
|
# File 'lib/hugo/cloud.rb', line 101
def lb(arg=nil)
set_or_return(:lb, arg, :kind_of => [Hugo::Aws::Elb])
end
|
#name(arg = nil) ⇒ Object
93
94
95
|
# File 'lib/hugo/cloud.rb', line 93
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
|
# File 'lib/hugo/cloud.rb', line 59
def print
if db
puts <<REPORT
------------------------
DATABASE: #{db.db}
User: #{db.user}
Password: #{db.password}
Uri: #{db.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
end
end
|