From: Jan Provaznik <jprovazn(a)redhat.com>
Imagefactory now sets username even for mock images, so
this hack is not needed anymore.
---
src/app/models/deployable.rb | 2 +-
src/app/models/instance.rb | 2 +-
src/app/models/provider_account.rb | 11 -----------
src/app/views/images/show.html.haml | 4 ++--
src/spec/vcr/cassettes/iwhd_connection.yml | 6 +++---
5 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/src/app/models/deployable.rb b/src/app/models/deployable.rb
index 9712008..b0e61ec 100644
--- a/src/app/models/deployable.rb
+++ b/src/app/models/deployable.rb
@@ -167,7 +167,7 @@ class Deployable < ActiveRecord::Base
account.credentials_hash["username"])
provider_image = target_image.find_provider_image_by_provider_and_account(
- account.provider.name, account.warehouse_id).first
+ account.provider.name, account.credentials_hash["username"]).first
return :not_pushed unless provider_image
:pushed
end
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index c139b8a..34dcc7b 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -192,7 +192,7 @@ class Instance < ActiveRecord::Base
def provider_images_for_match(provider_account)
if (the_build = build)
the_build.provider_images_by_provider_and_account(
- provider_account.provider.name, provider_account.warehouse_id)
+ provider_account.provider.name,
provider_account.credentials_hash['username'])
else
[]
end
diff --git a/src/app/models/provider_account.rb b/src/app/models/provider_account.rb
index 6010e61..110ae68 100644
--- a/src/app/models/provider_account.rb
+++ b/src/app/models/provider_account.rb
@@ -326,17 +326,6 @@ class ProviderAccount < ActiveRecord::Base
res
end
- def warehouse_id
- # TODO: provider_account_identifier is not set for 'mock' provider images
- # in warehouse, provider_image is supposed to be pushed to all mock provider
- # accounts then
- if provider.provider_type.deltacloud_driver == 'mock'
- return nil
- else
- return credentials_hash['username']
- end
- end
-
# This is to allow us to look up the ProviderAccount for a given provider image
def self.find_by_provider_name_and_login(provider_name, login)
begin
diff --git a/src/app/views/images/show.html.haml b/src/app/views/images/show.html.haml
index 4405deb..eda142d 100644
--- a/src/app/views/images/show.html.haml
+++ b/src/app/views/images/show.html.haml
@@ -49,7 +49,7 @@
%th.image_controls
%tbody
- group[:accounts].each do |account|
- - pimg = timg ?
timg.find_provider_image_by_provider_and_account(account.provider.name,
account.warehouse_id).first : nil
+ - pimg = timg ?
timg.find_provider_image_by_provider_and_account(account.provider.name,
account.credentials_hash['username']).first : nil
%tr
%td
%strong= account.name
@@ -58,7 +58,7 @@
%td.light
= pimg ? pimg.target_identifier : ''
%td.image_controls
- - if timg and b = @builder.find_active_push(timg.id,
account.provider.name, account.warehouse_id)
+ - if timg and b = @builder.find_active_push(timg.id,
account.provider.name, account.credentials_hash['username'])
= label_tag b.status
- elsif timg and not pimg and @build and @build.id ==
@latest_build
= button_to t('.upload'),
image_provider_images_path((a)image.id, :build_id => @build.id, :target_image_id =>
timg.id, :account_id => account.id), :method => :post, :class =>
'upload_image'
diff --git a/src/spec/vcr/cassettes/iwhd_connection.yml
b/src/spec/vcr/cassettes/iwhd_connection.yml
index 6de6e67..fc26a1a 100644
--- a/src/spec/vcr/cassettes/iwhd_connection.yml
+++ b/src/spec/vcr/cassettes/iwhd_connection.yml
@@ -2224,7 +2224,7 @@
request: !ruby/struct:VCR::Request
method: :post
uri:
http://localhost:9090/provider_images/_query
- body: ($target_image == "1a955a06-ca92-4546-9121-6c35e162f67b" &&
$provider == "mock")
+ body: ($target_image == "1a955a06-ca92-4546-9121-6c35e162f67b" &&
$provider == "mock" && $provider_account_identifier ==
"mockuser")
headers:
accept:
- "*/*; q=0.5, application/xml"
@@ -2284,7 +2284,7 @@
request: !ruby/struct:VCR::Request
method: :post
uri:
http://localhost:9090/provider_images/_query
- body: ($target_image == "ce1c6d32-5e26-4feb-9b86-83435a39b1f0" &&
$provider == "mock")
+ body: ($target_image == "ce1c6d32-5e26-4feb-9b86-83435a39b1f0" &&
$provider == "mock" && $provider_account_identifier ==
"mockuser")
headers:
accept:
- "*/*; q=0.5, application/xml"
@@ -2314,7 +2314,7 @@
request: !ruby/struct:VCR::Request
method: :post
uri:
http://localhost:9090/provider_images/_query
- body: ($target_image == "ce1c6d32-5e26-4feb-9b86-83435a39b1f0" &&
$provider == "mock2")
+ body: ($target_image == "ce1c6d32-5e26-4feb-9b86-83435a39b1f0" &&
$provider == "mock2" && $provider_account_identifier ==
"mockuser")
headers:
accept:
- "*/*; q=0.5, application/xml"
--
1.7.7.5