diff --git a/src/cloud/marketplace/bin/onemarket b/src/cloud/marketplace/bin/onemarket index 5f8ece131a..b80eec723c 100755 --- a/src/cloud/marketplace/bin/onemarket +++ b/src/cloud/marketplace/bin/onemarket @@ -37,6 +37,8 @@ require 'cli/cli_helper' require 'rubygems' require 'json' +USER_AGENT = "CLI" + # # Options # @@ -113,7 +115,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do client = Market::ApplianceClient.new( options[:username], options[:password], - options[:server]) + options[:server], + USER_AGENT) response = client.list @@ -142,7 +145,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do client = Market::ApplianceClient.new( options[:username], options[:password], - options[:server]) + options[:server], + USER_AGENT) response = client.create(File.read(args[0])) @@ -165,7 +169,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do client = Market::ApplianceClient.new( options[:username], options[:password], - options[:server]) + options[:server], + USER_AGENT) response = client.show(args[0]) diff --git a/src/cloud/marketplace/lib/marketplace_client.rb b/src/cloud/marketplace/lib/marketplace_client.rb index 3006b26e26..f92419f05b 100644 --- a/src/cloud/marketplace/lib/marketplace_client.rb +++ b/src/cloud/marketplace/lib/marketplace_client.rb @@ -19,12 +19,14 @@ require 'cloud/CloudClient' module Market class Client - def initialize(username, password, url) + def initialize(username, password, url, user_agent="Ruby") @username = username @password = password - url ||= 'http://localhost:9292/' + url ||= 'http://localhost:9292/' @uri = URI.parse(url) + + @user_agent = "OpenNebula 3.5.80 (#{user_agent})" end def get(path) @@ -47,6 +49,8 @@ module Market req.basic_auth @username, @password end + req['User-Agent'] = @user_agent + res = CloudClient::http_start(@uri, @timeout) do |http| http.request(req) end @@ -57,8 +61,8 @@ module Market class ApplianceClient < Client - def initialize(user, password, url) - super(user, password, url) + def initialize(user, password, url, agent) + super(user, password, url, agent) end def list diff --git a/src/sunstone/models/SunstoneMarketplace.rb b/src/sunstone/models/SunstoneMarketplace.rb index 2e3745be5c..6f8745f5fa 100644 --- a/src/sunstone/models/SunstoneMarketplace.rb +++ b/src/sunstone/models/SunstoneMarketplace.rb @@ -17,11 +17,14 @@ require 'marketplace/marketplace_client' module SunstoneMarketplace + USER_AGENT = "Sunstone" + def get_appliance_pool client = Market::ApplianceClient.new( @config[:marketplace_username], @config[:marketplace_password], - @config[:marketplace_url]) + @config[:marketplace_url], + USER_AGENT) response = client.list @@ -37,7 +40,8 @@ module SunstoneMarketplace client = Market::ApplianceClient.new( @config[:marketplace_username], @config[:marketplace_password], - @config[:marketplace_url]) + @config[:marketplace_url], + USER_AGENT) response = client.show(app_id)