Skip to content

Commit

Permalink
reimport-manifest - don't delete untracked products when importing
Browse files Browse the repository at this point in the history
As a work-around for deleting an organization with some product not tracked in
Katello this products were deleted right after the manifest. The problem with
with this showed up, when an uebercert was created (and therefore a product that
is not in the Katello). When reimporting, Katello tried to remove this ueber
product which caused validation error on the Candlepin side.

Therefore now we don't delete any product on manifest import. It seems this
problem with untracked products that caused problem on deleting an organization
got away with new manifest.
  • Loading branch information
iNecas committed Dec 8, 2011
1 parent 2531673 commit 6319064
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
33 changes: 0 additions & 33 deletions src/app/models/glue/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def owner_imports
def queue_import_manifest zip_file_path, options
queue.create(:name => "import manifest #{zip_file_path} for owner: #{self.organization.name}", :priority => 3, :action => [self, :owner_import, zip_file_path, options])
queue.create(:name => "import of products in manifest #{zip_file_path}", :priority => 5, :action => [self, :import_products_from_cp])
queue.create(:name => "delete imported products not assigned to any owner #{zip_file_path}", :priority => 6, :action => [self, :delete_not_assigned_products])
end

def import_products_from_cp
Expand All @@ -178,26 +177,6 @@ def import_products_from_cp
end
end

def delete_not_assigned_products
not_assigned_products.each do |product_attrs|

unless product_attrs['productContent'].nil?
product_attrs['productContent'].each do |pc|
Candlepin::Product.remove_content product_attrs['id'], pc[:content][:id]
end
end

Candlepin::Product.destroy product_attrs['id']
end
end

def delete_not_assigned_content

not_assigned_content_ids.each do |content_id|
Candlepin::Content.destroy(content_id)
end
end

def destroy_products_orchestration
queue.create(:name => "delete products for provider: #{self.name}", :priority => 1, :action => [self, :del_products])
end
Expand All @@ -213,18 +192,6 @@ def added_products
new_product_ids.collect {|id| (Candlepin::Product.get(id))[0] }
end

def not_assigned_products
all_product_existing_in_katello_ids = Product.all(:select => "cp_id").map(&:cp_id)
all_product_existing_in_cp_ids = get_all_product_ids

product_ids = (all_product_existing_in_cp_ids - all_product_existing_in_katello_ids)
product_ids.collect {|id| (Candlepin::Product.get(id))[0] }
end

def not_assigned_content_ids
(get_all_content_ids - get_assigned_content_ids)
end

def get_pool_product_ids
pools = Candlepin::Owner.pools self.organization.cp_key
pools.collect do |pool|
Expand Down
1 change: 0 additions & 1 deletion src/spec/models/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
it "should make correct calls" do
@provider.should_receive(:owner_import).once.and_return(true)
@provider.should_receive(:import_products_from_cp).once.and_return(true)
@provider.should_receive(:delete_not_assigned_products).once.and_return(true)

@provider.import_manifest "path_to_manifest"
end
Expand Down

0 comments on commit 6319064

Please sign in to comment.