diff --git a/lib/fog/ssh.rb b/lib/fog/ssh.rb index 6f1af30ca..5c338aa37 100644 --- a/lib/fog/ssh.rb +++ b/lib/fog/ssh.rb @@ -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 diff --git a/lib/fog/terremark.rb b/lib/fog/terremark.rb index 91cc18caf..258bdec2a 100644 --- a/lib/fog/terremark.rb +++ b/lib/fog/terremark.rb @@ -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) diff --git a/lib/fog/terremark/parsers/get_public_Ips.rb b/lib/fog/terremark/parsers/get_public_ips.rb similarity index 100% rename from lib/fog/terremark/parsers/get_public_Ips.rb rename to lib/fog/terremark/parsers/get_public_ips.rb diff --git a/lib/fog/terremark/parsers/public_ip.rb b/lib/fog/terremark/parsers/public_ip.rb new file mode 100644 index 000000000..d2162cb7d --- /dev/null +++ b/lib/fog/terremark/parsers/public_ip.rb @@ -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 diff --git a/lib/fog/terremark/requests/add_node_service.rb b/lib/fog/terremark/requests/add_node_service.rb index 9808f0c55..2090eb0c0 100644 --- a/lib/fog/terremark/requests/add_node_service.rb +++ b/lib/fog/terremark/requests/add_node_service.rb @@ -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 diff --git a/lib/fog/terremark/requests/get_catalog.rb b/lib/fog/terremark/requests/get_catalog.rb index 594cbba94..12186f9db 100644 --- a/lib/fog/terremark/requests/get_catalog.rb +++ b/lib/fog/terremark/requests/get_catalog.rb @@ -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', diff --git a/lib/fog/terremark/requests/get_organization.rb b/lib/fog/terremark/requests/get_organization.rb index 531bd9996..59e6a15d4 100644 --- a/lib/fog/terremark/requests/get_organization.rb +++ b/lib/fog/terremark/requests/get_organization.rb @@ -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', diff --git a/lib/fog/terremark/requests/get_public_ip.rb b/lib/fog/terremark/requests/get_public_ip.rb new file mode 100644 index 000000000..56813afbb --- /dev/null +++ b/lib/fog/terremark/requests/get_public_ip.rb @@ -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 diff --git a/lib/fog/terremark/requests/get_tasks_list.rb b/lib/fog/terremark/requests/get_tasks_list.rb index 02922761e..c629c440f 100644 --- a/lib/fog/terremark/requests/get_tasks_list.rb +++ b/lib/fog/terremark/requests/get_tasks_list.rb @@ -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', diff --git a/lib/fog/terremark/requests/get_vdc.rb b/lib/fog/terremark/requests/get_vdc.rb index 547aab16d..c95a644cb 100644 --- a/lib/fog/terremark/requests/get_vdc.rb +++ b/lib/fog/terremark/requests/get_vdc.rb @@ -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',