--- src/app/models/provider.rb | 16 ++++++++++++++-- src/app/models/provider_account.rb | 16 ++++++++++++++-- src/app/util/condormatic.rb | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb index a099c56..30ea2dd 100644 --- a/src/app/models/provider.rb +++ b/src/app/models/provider.rb @@ -64,6 +64,13 @@ class Provider < ActiveRecord::Base
before_destroy :destroyable?
+ def encoded_url_with_driver_and_provider + url_extras = ";driver=#{provider_type.deltacloud_driver}" + if deltacloud_provider + url_extras += ";provider=#{CGI::escape(deltacloud_provider)}" + end + return url + url_extras + end # there is a destroy dependency for a cloud accounts association, # but a cloud account is silently not destroyed when there is # an instance for the cloud account @@ -81,7 +88,12 @@ class Provider < ActiveRecord::Base
def connect begin - return DeltaCloud.new(nil, nil, url) + opts = {:username => nil, + :password => nil, + :driver => provider_type.deltacloud_driver } + opts[:provider] = deltacloud_provider if deltacloud_provider + client = DeltaCloud.new(nil, nil, url) + return client.with_config(opts) rescue Exception => e logger.error("Error connecting to framework: #{e.message}") logger.error("Backtrace: #{e.backtrace.join("\n")}") @@ -112,4 +124,4 @@ class Provider < ActiveRecord::Base connect.nil? ? false : true end
-end \ No newline at end of file +end diff --git a/src/app/models/provider_account.rb b/src/app/models/provider_account.rb index 3fbb198..1604480 100644 --- a/src/app/models/provider_account.rb +++ b/src/app/models/provider_account.rb @@ -125,7 +125,14 @@ class ProviderAccount < ActiveRecord::Base
def connect begin - return DeltaCloud.new(credentials_hash['username'], credentials_hash['password'], provider.url) + opts = {:username => credentials_hash['username'], + :password => credentials_hash['password'], + :driver => provider.provider_type.deltacloud_driver } + opts[:provider] = provider.deltacloud_provider if provider.deltacloud_provider + client = DeltaCloud.new(credentials_hash['username'], + credentials_hash['password'], + provider.url) + return client.with_config(opts) rescue Exception => e logger.error("Error connecting to framework: #{e.message}") logger.error("Backtrace: #{e.backtrace.join("\n")}") @@ -169,7 +176,12 @@ class ProviderAccount < ActiveRecord::Base if credentials_hash['username'].blank? || credentials_hash['password'].blank? return false end - DeltaCloud::valid_credentials?(credentials_hash['username'].to_s, credentials_hash['password'].to_s, provider.url) + opts = {:driver => provider.provider_type.deltacloud_driver } + opts[:provider] = provider.deltacloud_provider if provider.deltacloud_provider + DeltaCloud::valid_credentials?(credentials_hash['username'].to_s, + credentials_hash['password'].to_s, + provider.url, + opts) end
def build_credentials diff --git a/src/app/util/condormatic.rb b/src/app/util/condormatic.rb index 431697a..c35afe1 100644 --- a/src/app/util/condormatic.rb +++ b/src/app/util/condormatic.rb @@ -89,7 +89,7 @@ def condormatic_instance_create(task) pipe_and_log(pipe, "executable = #{job_name}\n")
pipe_and_log(pipe, - "grid_resource = deltacloud #{found.account.provider.url}\n") + "grid_resource = deltacloud #{found.account.provider.encoded_url_with_driver_and_provider};\n") pipe_and_log(pipe, "DeltacloudUsername = #{found.account.credentials_hash['username']}\n") pipe_and_log(pipe, "DeltacloudPasswordFile = #{pwfilename}") pipe_and_log(pipe, "DeltacloudImageId = #{found.provider_image.target_identifier}\n")