mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Various fixes to get the go_grid extension into basic usable shape.
This commit is contained in:
parent
97f93df58d
commit
55731cf58c
3 changed files with 45 additions and 10 deletions
|
@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|||
## If your rubyforge_project name is different, then edit it and comment out
|
||||
## the sub! line in the Rakefile
|
||||
s.name = 'phpfog-fog'
|
||||
s.version = '0.4.1'
|
||||
s.version = '0.4.1.2'
|
||||
s.date = '2011-01-21'
|
||||
s.rubyforge_project = 'fog'
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.grid_server_destroy(id)
|
||||
connection.grid_server_delete(id)
|
||||
true
|
||||
end
|
||||
|
||||
def image
|
||||
requires :image_id
|
||||
connection.grid_image_get(image_id)
|
||||
connection.grid_image_get(:image => image_id)
|
||||
end
|
||||
|
||||
def ready?
|
||||
|
@ -40,14 +40,50 @@ module Fog
|
|||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :name, :image_id, :ip, :memory
|
||||
options['isSandbox'] = sandbox if sandbox
|
||||
options['server.ram'] = memory
|
||||
options['image'] = image_id
|
||||
options = {
|
||||
'isSandbox' => sandbox,
|
||||
'server.ram' => memory,
|
||||
'image' => image_id
|
||||
}
|
||||
options = options.reject {|key, value| value.nil?}
|
||||
data = connection.grid_server_add(name, image, ip, options)
|
||||
puts data.body.inspect
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
end
|
||||
|
||||
def ssh(commands)
|
||||
requires :ip, :identity, :username
|
||||
|
||||
options = {}
|
||||
options[:key_data] = [private_key] if private_key
|
||||
Fog::SSH.new(ip['ip'], username, options).run(commands)
|
||||
end
|
||||
|
||||
def setup(credentials = {})
|
||||
requires :ip, :identity, :public_key, :username
|
||||
Fog::SSH.new(ip['ip'], username, credentials).run([
|
||||
%{mkdir .ssh},
|
||||
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
||||
%{passwd -l root},
|
||||
%{echo "#{attributes.to_json}" >> ~/attributes.json},
|
||||
%{echo "#{metadata.to_json}" >> ~/metadata.json}
|
||||
])
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep(1)
|
||||
retry
|
||||
end
|
||||
|
||||
def username
|
||||
@username ||= 'root'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def adminPass=(new_admin_pass)
|
||||
@password = new_admin_pass
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,11 +6,11 @@ module Fog
|
|||
# Create a new server
|
||||
#
|
||||
# ==== Parameters
|
||||
# * 'name'<~String> - name of the server, 20 or fewer characters
|
||||
# * 'image'<~String> - image to use, in grid_image_list
|
||||
# * 'ip'<~String> - initial public ip for this server
|
||||
# * 'name'<~String> - name of the server, 20 or fewer characters
|
||||
# * 'server_ram'<~String> - flavor to use, in common_lookup_list('server.ram')
|
||||
# * 'options'<~Hash>:
|
||||
# * 'server.ram'<~String> - flavor to use, in common_lookup_list('server.ram')
|
||||
# * 'description'<~String> - description of this server
|
||||
# * 'isSandbox'<~String> - treat this server as image sandbox? in ['true', 'false']
|
||||
#
|
||||
|
@ -18,14 +18,13 @@ module Fog
|
|||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# TODO: docs
|
||||
def grid_server_add(image, ip, name, server_ram, options={})
|
||||
def grid_server_add(name, image, ip, options={})
|
||||
request(
|
||||
:path => 'grid/server/add',
|
||||
:query => {
|
||||
'image' => image,
|
||||
'ip' => ip,
|
||||
'name' => name,
|
||||
'server.ram' => server_ram
|
||||
}.merge!(options)
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue