Created
July 24, 2012 19:02
-
-
Save mccun934/3171913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/cli/src/katello/client/core/template.py b/cli/src/katello/client/core/template.py | |
| index 38d811e..8c28837 100644 | |
| --- a/cli/src/katello/client/core/template.py | |
| +++ b/cli/src/katello/client/core/template.py | |
| @@ -337,8 +337,8 @@ class Update(TemplateAction): | |
| #self.parser.add_option('--add_product', dest='add_products', action="append", help=_("name of the product")) | |
| #self.parser.add_option('--remove_product', dest='remove_products', action="append", help=_("name of the product")) | |
| - self.parser.add_option('--add_package', dest='add_packages', action="append", help=_("name or nvre of the product (epoch:name-rel.ease-ver.sio.n)")) | |
| - self.parser.add_option('--remove_package', dest='remove_packages', action="append", help=_("name or nvre of the product (epoch:name-rel.ease-ver.sio.n)")) | |
| + parser.add_option('--add_package', dest='add_packages', action="append", help=_("name of the package")) | |
| + parser.add_option('--remove_package', dest='remove_packages', action="append", help=_("name of the package")) | |
| self.parser.add_option('--add_parameter', dest='add_parameters', action="callback", callback=self.store_parameter_name, type="string", | |
| help=_("name of the parameter, %s must follow") % "--value") | |
| diff --git a/src/app/models/changeset.rb b/src/app/models/changeset.rb | |
| index d206504..17016d0 100644 | |
| --- a/src/app/models/changeset.rb | |
| +++ b/src/app/models/changeset.rb | |
| @@ -243,15 +243,20 @@ class Changeset < ActiveRecord::Base | |
| end | |
| def find_package product, name_or_nvre | |
| - package_data = Katello::PackageUtils::parse_nvrea_nvre(name_or_nvre) | |
| - if not package_data.nil? | |
| - packs = product.find_packages_by_nvre(self.environment.prior, package_data[:name], package_data[:version], package_data[:release], package_data[:epoch]) | |
| - else | |
| - packs = product.find_packages_by_name(self.environment.prior, name_or_nvre) | |
| - packs = Katello::PackageUtils::find_latest_packages(packs) | |
| + package_data = Katello::PackageUtils.parse_nvrea_nvre(name_or_nvre) | |
| + | |
| + if package_data | |
| + packs = product.find_packages_by_nvre(self.environment.prior, | |
| + package_data[:name], package_data[:version], | |
| + package_data[:release], package_data[:epoch]) | |
| end | |
| - raise Errors::ChangesetContentException.new(_("Package '%s' was not found in the source environment.") % name_or_nvre) if packs.empty? | |
| - packs[0].with_indifferent_access | |
| + | |
| + if packs.empty? || !package_data | |
| + packs = Katello::PackageUtils::find_latest_packages( | |
| + product.find_packages_by_name(self.environment.prior, name_or_nvre)) | |
| + end | |
| + | |
| + packs.first.with_indifferent_access | |
| end | |
| def find_package_by_nvre product, nvre | |
| diff --git a/src/app/models/system_template.rb b/src/app/models/system_template.rb | |
| index 51003d9..adc6e9d 100644 | |
| --- a/src/app/models/system_template.rb | |
| +++ b/src/app/models/system_template.rb | |
| @@ -205,20 +205,13 @@ class SystemTemplate < ActiveRecord::Base | |
| def add_package package_name | |
| - if pack_attrs = Katello::PackageUtils.parse_nvrea_nvre(package_name) | |
| - self.packages.create!(:package_name => pack_attrs[:name], :version => pack_attrs[:version], :release => pack_attrs[:release], :epoch => pack_attrs[:epoch], :arch => pack_attrs[:arch]) | |
| - else | |
| - self.packages.create!(:package_name => package_name) | |
| - end | |
| + self.packages.create!(:package_name => package_name) | |
| end | |
| def remove_package package_name | |
| - if pack_attrs = Katello::PackageUtils.parse_nvrea_nvre(package_name) | |
| - package = self.packages.find(:first, :conditions => {:package_name => pack_attrs[:name], :version => pack_attrs[:version], :release => pack_attrs[:release], :epoch => pack_attrs[:epoch], :arch => pack_attrs[:arch]}) | |
| - else | |
| - package = self.packages.find(:first, :conditions => {:package_name => package_name}) | |
| - end | |
| + package = self.packages.find(:first, :conditions => {:package_name => package_name}) | |
| + | |
| self.packages.delete(package) | |
| end | |
| diff --git a/src/spec/models/model_spec_helper.rb b/src/spec/models/model_spec_helper.rb | |
| index 00769a1..04cd0ce 100644 | |
| --- a/src/spec/models/model_spec_helper.rb | |
| +++ b/src/spec/models/model_spec_helper.rb | |
| @@ -139,6 +139,7 @@ EOKEY | |
| Pulp::Repository.stub(:distributions).with(RepoTestData::REPO_ID).and_return(RepoTestData::REPO_DISTRIBUTIONS) | |
| Pulp::Repository.stub(:find).with(RepoTestData::REPO_ID).and_return(RepoTestData::REPO_PROPERTIES) | |
| Pulp::Repository.stub(:find).with(RepoTestData::CLONED_REPO_ID).and_return(RepoTestData::CLONED_PROPERTIES) | |
| + Pulp::Package.stub(:name_search).and_return(RepoTestData::REPO_PACKAGES[0]) | |
| end | |
| def disable_cdn | |
| diff --git a/src/spec/models/system_template_revision_spec.rb b/src/spec/models/system_template_revision_spec.rb | |
| index d6155bb..2f040bc 100644 | |
| --- a/src/spec/models/system_template_revision_spec.rb | |
| +++ b/src/spec/models/system_template_revision_spec.rb | |
| @@ -24,6 +24,7 @@ describe SystemTemplate do | |
| before(:each) do | |
| disable_org_orchestration | |
| disable_product_orchestration | |
| + disable_repo_orchestration | |
| @organization = Organization.create!(:name => 'test_organization', :cp_key => 'test_organization') | |
| @environment = KTEnvironment.create!(:name => 'env_1', :prior => @organization.library.id, :organization => @organization) | |
| diff --git a/src/spec/models/system_template_spec.rb b/src/spec/models/system_template_spec.rb | |
| index 70fedf7..92fe27f 100644 | |
| --- a/src/spec/models/system_template_spec.rb | |
| +++ b/src/spec/models/system_template_spec.rb | |
| @@ -21,6 +21,7 @@ describe SystemTemplate do | |
| before(:each) do | |
| disable_org_orchestration | |
| disable_product_orchestration | |
| + disable_repo_orchestration | |
| @organization = Organization.create!(:name => 'test_organization', :cp_key => 'test_organization') | |
| @environment = KTEnvironment.create!(:name => 'env_1', :prior => @organization.library.id, :organization => @organization) | |
| @@ -357,16 +358,6 @@ describe SystemTemplate do | |
| end | |
| describe "#add_package" do | |
| - it "should accept nvrea name" do | |
| - @tpl1.packages.should_receive(:create!).with(nvrea_package_params) | |
| - @tpl1.add_package(nvrea) | |
| - end | |
| - | |
| - it "should accept nvre name" do | |
| - @tpl1.packages.should_receive(:create!).with(nvre_package_params) | |
| - @tpl1.add_package(nvre) | |
| - end | |
| - | |
| it "should accept plain name" do | |
| @tpl1.packages.should_receive(:create!).with(plain_name_package_params) | |
| @tpl1.add_package(plain_name) | |
| @@ -375,16 +366,6 @@ describe SystemTemplate do | |
| describe "#remove_package" do | |
| before { @tpl1.packages.stub(:delete) } | |
| - it "should accept nvrea name" do | |
| - @tpl1.packages.should_receive(:find).with(:first, :conditions => nvrea_package_params) | |
| - @tpl1.remove_package(nvrea) | |
| - end | |
| - | |
| - it "should accept nvre name" do | |
| - @tpl1.packages.should_receive(:find).with(:first, :conditions => nvre_package_params) | |
| - @tpl1.remove_package(nvre) | |
| - end | |
| - | |
| it "should accept plain name" do | |
| @tpl1.packages.should_receive(:find).with(:first, :conditions => plain_name_package_params) | |
| @tpl1.remove_package(plain_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment