corl 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +5 -10
- data/VERSION +1 -1
- data/bootstrap/bootstrap.sh +1 -4
- data/bootstrap/os/ubuntu/05_ruby.sh +9 -3
- data/bootstrap/os/ubuntu/10_corl.sh +26 -2
- data/corl.gemspec +7 -10
- data/lib/CORL/machine/AWS.rb +38 -38
- data/lib/CORL/machine/rackspace.rb +2 -3
- data/lib/CORL/node/AWS.rb +36 -36
- data/lib/CORL/node/rackspace.rb +30 -30
- data/lib/core/mod/fog_rackspace_server.rb +29 -0
- data/lib/core/plugin/fog_machine.rb +66 -65
- data/lib/core/plugin/fog_node.rb +56 -56
- data/lib/core/plugin/node.rb +1 -1
- data/lib/corl.rb +14 -14
- data/lib/nucleon/action/node/bootstrap.rb +1 -1
- metadata +20 -30
- data/bootstrap/os/ubuntu/06_puppet.sh +0 -51
data/lib/CORL/node/rackspace.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
|
2
2
|
module CORL
|
3
3
|
module Node
|
4
|
-
class Rackspace <
|
5
|
-
|
4
|
+
class Rackspace < FogBase
|
5
|
+
|
6
6
|
#-----------------------------------------------------------------------------
|
7
7
|
# Node plugin interface
|
8
|
-
|
8
|
+
|
9
9
|
def normalize(reload)
|
10
10
|
super do
|
11
11
|
region_info.import({
|
12
12
|
:dfw => 'Dallas',
|
13
13
|
:ord => 'Chicago',
|
14
|
-
:lon => 'London (for UK accounts)'
|
14
|
+
:lon => 'London (for UK accounts)'
|
15
15
|
})
|
16
16
|
# Return machine provider
|
17
17
|
:rackspace
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
#-----------------------------------------------------------------------------
|
22
22
|
# Checks
|
23
|
-
|
23
|
+
|
24
24
|
def usable_image?(image)
|
25
25
|
image.state != 'DELETED'
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
#-----------------------------------------------------------------------------
|
29
29
|
# Property accessors / modifiers
|
30
|
-
|
30
|
+
|
31
31
|
#-----------------------------------------------------------------------------
|
32
32
|
# Settings groups
|
33
|
-
|
33
|
+
|
34
34
|
def machine_config
|
35
35
|
super do |config|
|
36
|
-
config.import({
|
37
|
-
:provider => 'rackspace',
|
36
|
+
config.import({
|
37
|
+
:provider => 'rackspace',
|
38
38
|
:version => :v2,
|
39
39
|
:rackspace_region => region
|
40
40
|
})
|
41
|
-
|
41
|
+
|
42
42
|
config[:rackspace_username] = api_user if api_user
|
43
43
|
config[:rackspace_api_key] = api_key if api_key
|
44
44
|
config[:rackspace_auth_url] = auth_url if auth_url
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
#---
|
49
|
-
|
49
|
+
|
50
50
|
def create_config
|
51
|
-
{ :name => hostname, :flavor_id => machine_type, :image_id => image }
|
51
|
+
{ :name => hostname, :flavor_id => machine_type, :image_id => image }
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
#-----------------------------------------------------------------------------
|
55
55
|
# Node operations
|
56
|
-
|
56
|
+
|
57
57
|
def create(options = {})
|
58
58
|
super do |op, config|
|
59
59
|
if op == :config
|
@@ -61,9 +61,9 @@ class Rackspace < Fog
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
#---
|
66
|
-
|
66
|
+
|
67
67
|
def start(options = {})
|
68
68
|
super do |op, config|
|
69
69
|
if op == :config
|
@@ -71,30 +71,30 @@ class Rackspace < Fog
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
#-----------------------------------------------------------------------------
|
76
76
|
# Utilities
|
77
|
-
|
77
|
+
|
78
78
|
def render_machine_type(machine_type)
|
79
|
-
sprintf("%-30s %-35s [ VCPUS: %-5s ] ( RAM: %6sMB | DISK: %4sGB )",
|
79
|
+
sprintf("%-30s %-35s [ VCPUS: %-5s ] ( RAM: %6sMB | DISK: %4sGB )",
|
80
80
|
purple(machine_type_id(machine_type)),
|
81
|
-
yellow(machine_type.name),
|
82
|
-
blue(machine_type.vcpus.to_s),
|
83
|
-
blue(machine_type.ram.to_s),
|
81
|
+
yellow(machine_type.name),
|
82
|
+
blue(machine_type.vcpus.to_s),
|
83
|
+
blue(machine_type.ram.to_s),
|
84
84
|
blue(machine_type.disk.to_s)
|
85
85
|
)
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
#---
|
89
|
-
|
89
|
+
|
90
90
|
def render_image(image)
|
91
91
|
sprintf("%-47s [ %-10s ] %s", purple(image_id(image)), blue(image.state), yellow(image.name))
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
#---
|
95
|
-
|
95
|
+
|
96
96
|
def image_search_text(image)
|
97
|
-
sprintf("%s %s %s", image_id(image), image.name, image.state)
|
97
|
+
sprintf("%s %s %s", image_id(image), image.name, image.state)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class RackspaceV2
|
4
|
+
class Server
|
5
|
+
|
6
|
+
def setup(credentials = {})
|
7
|
+
requires :ssh_ip_address, :identity, :public_key, :username
|
8
|
+
|
9
|
+
commands = [
|
10
|
+
%{mkdir .ssh},
|
11
|
+
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
12
|
+
password_lock,
|
13
|
+
%{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
|
14
|
+
%{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json}
|
15
|
+
]
|
16
|
+
commands.compact
|
17
|
+
|
18
|
+
@password = nil if password_lock
|
19
|
+
|
20
|
+
Fog::SSH.new(ssh_ip_address, username, credentials).run(commands)
|
21
|
+
|
22
|
+
rescue Errno::ECONNREFUSED, Net::SSH::Disconnect
|
23
|
+
sleep(1)
|
24
|
+
retry
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -5,146 +5,147 @@ nucleon_require(File.dirname(__FILE__), :machine)
|
|
5
5
|
|
6
6
|
module CORL
|
7
7
|
module Machine
|
8
|
-
class
|
9
|
-
|
8
|
+
class FogBase < Nucleon.plugin_class(:CORL, :machine)
|
9
|
+
|
10
10
|
include Mixin::Machine::SSH
|
11
11
|
|
12
12
|
#-----------------------------------------------------------------------------
|
13
13
|
# Machine plugin interface
|
14
|
-
|
14
|
+
|
15
15
|
def normalize(reload)
|
16
16
|
super
|
17
17
|
myself.plugin_name = '' if myself.plugin_provider == myself.plugin_name.to_sym
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
#-----------------------------------------------------------------------------
|
21
21
|
# Checks
|
22
|
-
|
22
|
+
|
23
23
|
def created?
|
24
24
|
server && ! server.state != 'DELETED'
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
#---
|
28
|
-
|
28
|
+
|
29
29
|
def running?
|
30
30
|
created? && server.ready?
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
#-----------------------------------------------------------------------------
|
34
34
|
# Property accessors / modifiers
|
35
|
-
|
35
|
+
|
36
36
|
def set_connection
|
37
37
|
logger.info("Initializing Fog Compute connection to cloud hosting provider")
|
38
38
|
logger.debug("Compute settings: #{export.inspect}")
|
39
|
-
|
39
|
+
|
40
40
|
ENV['DEBUG'] = 'true' if CORL.log_level == :debug
|
41
|
-
|
41
|
+
|
42
42
|
require 'fog'
|
43
|
-
|
43
|
+
yield if block_given?
|
44
|
+
|
44
45
|
myself.compute = ::Fog::Compute.new(export)
|
45
46
|
end
|
46
47
|
protected :set_connection
|
47
|
-
|
48
|
+
|
48
49
|
#---
|
49
|
-
|
50
|
+
|
50
51
|
def compute=compute
|
51
52
|
@compute = compute
|
52
53
|
end
|
53
|
-
|
54
|
+
|
54
55
|
def compute
|
55
56
|
set_connection unless @compute
|
56
57
|
@compute
|
57
58
|
end
|
58
|
-
|
59
|
+
|
59
60
|
#---
|
60
|
-
|
61
|
+
|
61
62
|
def server=id
|
62
63
|
@server = nil
|
63
|
-
|
64
|
+
|
64
65
|
if id.is_a?(String)
|
65
66
|
@server = compute.servers.get(id) unless id.empty?
|
66
67
|
elsif ! id.nil?
|
67
68
|
@server = id
|
68
|
-
end
|
69
|
+
end
|
69
70
|
init_server
|
70
71
|
end
|
71
|
-
|
72
|
+
|
72
73
|
def server
|
73
74
|
compute
|
74
75
|
load unless @server
|
75
76
|
@server
|
76
77
|
end
|
77
|
-
|
78
|
+
|
78
79
|
#---
|
79
|
-
|
80
|
+
|
80
81
|
def state
|
81
82
|
return translate_state(server.state) if server
|
82
83
|
translate_state(:aborted)
|
83
84
|
end
|
84
|
-
|
85
|
+
|
85
86
|
#---
|
86
|
-
|
87
|
+
|
87
88
|
def public_ip
|
88
89
|
return server.public_ip_address if server
|
89
90
|
nil
|
90
91
|
end
|
91
|
-
|
92
|
+
|
92
93
|
#---
|
93
|
-
|
94
|
+
|
94
95
|
def private_ip
|
95
96
|
return server.private_ip_address if server
|
96
97
|
nil
|
97
98
|
end
|
98
|
-
|
99
|
+
|
99
100
|
#---
|
100
|
-
|
101
|
+
|
101
102
|
def machine_types
|
102
103
|
return compute.flavors if compute
|
103
104
|
[]
|
104
105
|
end
|
105
|
-
|
106
|
+
|
106
107
|
#---
|
107
|
-
|
108
|
+
|
108
109
|
def machine_type
|
109
110
|
return server.flavor.id if server
|
110
111
|
nil
|
111
112
|
end
|
112
|
-
|
113
|
+
|
113
114
|
#---
|
114
|
-
|
115
|
+
|
115
116
|
def images
|
116
117
|
return compute.images if compute
|
117
118
|
[]
|
118
119
|
end
|
119
|
-
|
120
|
+
|
120
121
|
#---
|
121
|
-
|
122
|
+
|
122
123
|
def image
|
123
124
|
return server.image.id if server
|
124
125
|
nil
|
125
126
|
end
|
126
|
-
|
127
|
+
|
127
128
|
#-----------------------------------------------------------------------------
|
128
129
|
# Management
|
129
|
-
|
130
|
+
|
130
131
|
def init_server
|
131
132
|
unless @server.nil?
|
132
133
|
yield # Implement in fog machine providers
|
133
|
-
end
|
134
|
+
end
|
134
135
|
end
|
135
136
|
protected :init_server
|
136
|
-
|
137
|
+
|
137
138
|
#---
|
138
|
-
|
139
|
+
|
139
140
|
def load
|
140
141
|
super do
|
141
142
|
myself.server = plugin_name if compute && plugin_name
|
142
143
|
! plugin_name && @server.nil? ? false : true
|
143
|
-
end
|
144
|
+
end
|
144
145
|
end
|
145
|
-
|
146
|
+
|
146
147
|
#---
|
147
|
-
|
148
|
+
|
148
149
|
def create(options = {}, &code)
|
149
150
|
super do |config|
|
150
151
|
if compute
|
@@ -154,83 +155,83 @@ class Fog < Nucleon.plugin_class(:CORL, :machine)
|
|
154
155
|
myself.server ? true : false
|
155
156
|
end
|
156
157
|
end
|
157
|
-
|
158
|
+
|
158
159
|
#---
|
159
|
-
|
160
|
+
|
160
161
|
def download(remote_path, local_path, options = {}, &code)
|
161
162
|
super do |config, success|
|
162
163
|
ssh_download(remote_path, local_path, config, &code)
|
163
|
-
end
|
164
|
+
end
|
164
165
|
end
|
165
|
-
|
166
|
+
|
166
167
|
#---
|
167
|
-
|
168
|
+
|
168
169
|
def upload(local_path, remote_path, options = {}, &code)
|
169
170
|
super do |config, success|
|
170
171
|
ssh_upload(local_path, remote_path, config, &code)
|
171
|
-
end
|
172
|
+
end
|
172
173
|
end
|
173
|
-
|
174
|
+
|
174
175
|
#---
|
175
|
-
|
176
|
+
|
176
177
|
def exec(commands, options = {}, &code)
|
177
178
|
super do |config|
|
178
179
|
ssh_exec(commands, config, &code)
|
179
180
|
end
|
180
181
|
end
|
181
|
-
|
182
|
+
|
182
183
|
#---
|
183
|
-
|
184
|
+
|
184
185
|
def terminal(user, options = {})
|
185
186
|
super do |config|
|
186
187
|
ssh_terminal(user, config)
|
187
188
|
end
|
188
189
|
end
|
189
|
-
|
190
|
+
|
190
191
|
#---
|
191
|
-
|
192
|
+
|
192
193
|
def reload(options = {}, &code)
|
193
194
|
super do |config|
|
194
|
-
success = code ? code.call(config) : true
|
195
|
+
success = code ? code.call(config) : true
|
195
196
|
success = init_ssh_session(true, config.get(:tries, 12), config.get(:sleep_time, 5)) if success
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|
199
200
|
#---
|
200
|
-
|
201
|
+
|
201
202
|
def create_image(options = {}, &code)
|
202
203
|
super do |config|
|
203
204
|
image_name = sprintf("%s (%s)", node.plugin_name, Time.now.to_s)
|
204
|
-
|
205
|
-
success = code ? code.call(image_name, config, success) : true
|
205
|
+
|
206
|
+
success = code ? code.call(image_name, config, success) : true
|
206
207
|
success = init_ssh_session(true, config.get(:tries, 12), config.get(:sleep_time, 5)) if success
|
207
208
|
end
|
208
209
|
end
|
209
|
-
|
210
|
+
|
210
211
|
#---
|
211
|
-
|
212
|
+
|
212
213
|
def stop(options = {})
|
213
214
|
super do |config|
|
214
|
-
success = false
|
215
|
+
success = false
|
215
216
|
success = destroy(config.import({ :stop => true })) if create_image(config)
|
216
217
|
end
|
217
218
|
end
|
218
|
-
|
219
|
+
|
219
220
|
#---
|
220
221
|
|
221
222
|
def destroy(options = {}, &code)
|
222
223
|
super do |config|
|
223
224
|
success = server.destroy
|
224
225
|
success = code.call(config) if success && code
|
225
|
-
|
226
|
+
|
226
227
|
close_ssh_session if success
|
227
228
|
success
|
228
229
|
end
|
229
230
|
end
|
230
|
-
|
231
|
+
|
231
232
|
#-----------------------------------------------------------------------------
|
232
233
|
# Utilities
|
233
|
-
|
234
|
+
|
234
235
|
def ssh_wait_for_ready
|
235
236
|
server.wait_for { ready? }
|
236
237
|
end
|