mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[terremark] misc fixes, better defaults, get_public_ip method
This commit is contained in:
parent
3866b7cd18
commit
2d974313aa
10 changed files with 84 additions and 6 deletions
|
@ -17,7 +17,7 @@ module Fog
|
|||
Net::SSH.start(@address, @username, @options) do |ssh|
|
||||
commands.each do |command|
|
||||
result = { :command => command }
|
||||
ssh.exec!("bash -lc #{command.inspect}") do |channel, stream, data|
|
||||
ssh.exec!(command) do |channel, stream, data|
|
||||
result[stream] = data
|
||||
end
|
||||
results << result
|
||||
|
|
|
@ -34,6 +34,7 @@ module Fog
|
|||
require 'fog/terremark/parsers/instantiate_vapp_template'
|
||||
require 'fog/terremark/parsers/internet_service'
|
||||
require 'fog/terremark/parsers/node_service'
|
||||
require 'fog/terremark/parsers/public_ip'
|
||||
require 'fog/terremark/parsers/task'
|
||||
require 'fog/terremark/parsers/vapp'
|
||||
require 'fog/terremark/requests/add_internet_service'
|
||||
|
@ -49,6 +50,7 @@ module Fog
|
|||
require 'fog/terremark/requests/get_node_services'
|
||||
require 'fog/terremark/requests/get_organization'
|
||||
require 'fog/terremark/requests/get_organizations'
|
||||
require 'fog/terremark/requests/get_public_ip'
|
||||
require 'fog/terremark/requests/get_public_ips'
|
||||
require 'fog/terremark/requests/get_task'
|
||||
require 'fog/terremark/requests/get_tasks_list'
|
||||
|
@ -179,6 +181,23 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
def default_tasks_list_id
|
||||
if default_organization_id
|
||||
@default_tasks_list_id ||= begin
|
||||
task_lists = get_organization(default_organization_id).body['Links'].select {|link|
|
||||
link['type'] == 'application/vnd.vmware.vcloud.tasksList+xml'
|
||||
}
|
||||
if task_lists.length == 1
|
||||
task_lists.first['href'].split('/').last.to_i
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request(params)
|
||||
|
|
24
lib/fog/terremark/parsers/public_ip.rb
Normal file
24
lib/fog/terremark/parsers/public_ip.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Terremark
|
||||
|
||||
class PublicIp < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'Href', 'Name'
|
||||
@response[name] = @value
|
||||
when 'Id'
|
||||
@response[name] = @value.to_i
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -43,7 +43,7 @@ DATA
|
|||
:expects => 200,
|
||||
:headers => {'Content-Type' => 'application/xml'},
|
||||
:method => 'POST',
|
||||
:parser => Fog::Parsers::Terremark::InternetService.new,
|
||||
:parser => Fog::Parsers::Terremark::NodeService.new,
|
||||
:path => "internetServices/#{service_id}/nodes"
|
||||
)
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
# * 'type'<~String> - type of item
|
||||
# * 'description'<~String> - Description of catalog
|
||||
# * 'name'<~String> - Name of catalog
|
||||
def get_catalog(vdc_id)
|
||||
def get_catalog(vdc_id = default_vdc_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
|||
# * 'rel'<~String> - action to perform
|
||||
# * 'type'<~String> - type of link
|
||||
# * 'name'<~String> - Name of organization
|
||||
def get_organization(organization_id)
|
||||
def get_organization(organization_id = default_organization_id)
|
||||
response = request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
|
|
35
lib/fog/terremark/requests/get_public_ip.rb
Normal file
35
lib/fog/terremark/requests/get_public_ip.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
module Fog
|
||||
module Terremark
|
||||
class Real
|
||||
|
||||
# Get details for a public ip
|
||||
#
|
||||
# ==== Parameters
|
||||
# * public_ip_id<~Integer> - Id of public ip to look up
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'PublicIpAddresses'<~Array>
|
||||
# * 'href'<~String> - linke to item
|
||||
# * 'name'<~String> - name of item
|
||||
def get_public_ip(public_ip_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Terremark::PublicIp.new,
|
||||
:path => "publicIps/#{public_ip_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_public_ip(public_ip_id)
|
||||
raise MockNotImplemented.new("Contributions welcome!")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
# * 'type'<~String> - type of item
|
||||
# * 'description'<~String> - Description of catalog
|
||||
# * 'name'<~String> - Name of catalog
|
||||
def get_tasks_list(tasks_list_id)
|
||||
def get_tasks_list(tasks_list_id = default_tasks_list_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
|
|
|
@ -19,7 +19,7 @@ module Fog
|
|||
# * 'type'<~String> - type of item
|
||||
# * 'description'<~String> - Description of catalog
|
||||
# * 'name'<~String> - Name of catalog
|
||||
def get_vdc(vdc_id)
|
||||
def get_vdc(vdc_id = default_vdc_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
|
|
Loading…
Reference in a new issue