Sending rebased version. No additional patches are required (all is already pushed).
From: Jan Provaznik jprovazn@redhat.com
Don't forget to run "rake dc:prepare_repos" --- src/app/models/template.rb | 15 ++++++++++----- src/app/util/image_descriptor_xml.rb | 10 +++++++--- src/app/views/image_factory/templates/_list.haml | 2 +- .../image_descriptor_package_repositories.yml | 15 +++++++++++---- .../image_descriptor_platform_repositories.yml | 7 ++++++- src/features/api.feature | 1 + src/features/instance.feature | 1 + src/features/provider.feature | 1 + src/features/template.feature | 20 ++++++++++---------- src/spec/factories/template.rb | 2 +- src/spec/fixtures/repositories.json | 4 ++-- src/spec/utils/repository_manager_spec.rb | 2 +- 12 files changed, 52 insertions(+), 28 deletions(-)
diff --git a/src/app/models/template.rb b/src/app/models/template.rb index f4dc905..de12dae 100644 --- a/src/app/models/template.rb +++ b/src/app/models/template.rb @@ -67,11 +67,12 @@ class Template < ActiveRecord::Base def update_xml xml.name = self.name xml.description = self.summary - platform = {} - platform['name'] = self.platform.capitalize - platform['version'] = self.platform_version - platform['arch'] = self.architecture - xml.platform = platform + xml.platform = { + 'id' => self.platform, + 'name' => platforms[self.platform] ? platforms[self.platform]['name'] : '', + 'version' => self.platform_version, + 'arch' => self.architecture, + } write_attribute(:xml, xml.to_xml) end
@@ -115,6 +116,10 @@ class Template < ActiveRecord::Base self.architecture = platforms[plat]['architecture'] end
+ def platform_name + platforms[self.platform] ? platforms[self.platform]['name'] : '' + end + # sets platform info from hash (used when importing images) def platform_hash=(plat) write_attribute(:platform, plat[:platform]) diff --git a/src/app/util/image_descriptor_xml.rb b/src/app/util/image_descriptor_xml.rb index 3a4bbae..cd146cf 100644 --- a/src/app/util/image_descriptor_xml.rb +++ b/src/app/util/image_descriptor_xml.rb @@ -64,6 +64,7 @@ class ImageDescriptorXML #recreate_repo_nodes platform_node = get_or_create_node('os') platform_node.xpath('.//*').remove + platform_id = platform_hash.delete('id') platform_hash.each do |key, value| snode = Nokogiri::XML::Node.new(key, @doc) platform_node << snode @@ -73,9 +74,12 @@ class ImageDescriptorXML install_node.set_attribute('type', 'url') platform_node << install_node url_node = Nokogiri::XML::Node.new('url', @doc) - # TODO: change when more than one os is supported by conductor - # url_node.content = "http://download.fedoraproject.org/pub/fedora/linux/releases/13/Fedora/x86_64..." - url_node.content = YAML.load_file("#{RAILS_ROOT}/config/image_descriptor_package_repositories.yml")['baseurl'] + # TODO - currently we have platform repositories and package repositories, + # mainly because it was possible to have multiple package repositories for + # a platform before. Also platform url wasn't needed for old imagefactory. + # Should be reworked when we switch to pulp + rep = repository_manager.repositories.find {|r| r.id == platform_id} + url_node.content = rep.yumurl if rep install_node << url_node end
diff --git a/src/app/views/image_factory/templates/_list.haml b/src/app/views/image_factory/templates/_list.haml index 6cec40b..bf8be82 100644 --- a/src/app/views/image_factory/templates/_list.haml +++ b/src/app/views/image_factory/templates/_list.haml @@ -15,7 +15,7 @@ = check_box_tag 'selected[]', template.id, @url_params[:select] == 'all', :id => "selected_#{template.id}" = image_tag "blnk.png", :alt => template.platform, :class => "icon platform #{template.platform}" = link_to template.name, image_factory_template_path(template) - %td= template.platform + %td= template.platform_name %td= template.platform_version %td= image_tag 'blnk.png', :alt => 'yes', :class => "icon yes" %td= template.architecture diff --git a/src/config/image_descriptor_package_repositories.yml b/src/config/image_descriptor_package_repositories.yml index 12a15d1..fd1a747 100644 --- a/src/config/image_descriptor_package_repositories.yml +++ b/src/config/image_descriptor_package_repositories.yml @@ -1,7 +1,14 @@ -id: fedora -name: Fedora -baseurl: http://download.fedoraproject.org/pub/fedora/linux/releases/13/Fedora/x86_64... -type: xml +- + id: fedora13 + name: Fedora + baseurl: http://download.fedoraproject.org/pub/fedora/linux/releases/13/Fedora/x86_64... + type: xml + +- + id: fedora14 + name: Fedora + baseurl: http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86_64... + type: xml
# you can define multiple repositories, as array, for example: # diff --git a/src/config/image_descriptor_platform_repositories.yml b/src/config/image_descriptor_platform_repositories.yml index d16d0c0..b43c115 100644 --- a/src/config/image_descriptor_platform_repositories.yml +++ b/src/config/image_descriptor_platform_repositories.yml @@ -1,4 +1,9 @@ -fedora: +fedora13: name: Fedora version: 13 architecture: x86_64 + +fedora14: + name: Fedora + version: 14 + architecture: x86_64 diff --git a/src/features/api.feature b/src/features/api.feature index 4ff624a..4651b8f 100644 --- a/src/features/api.feature +++ b/src/features/api.feature @@ -6,6 +6,7 @@ Feature: User authentication Background: Given I am an authorised user And I am logged in + And There is a mock pulp repository
Scenario: Check can start instance Given there is a user "testuser" diff --git a/src/features/instance.feature b/src/features/instance.feature index ed08fb4..19b80bd 100644 --- a/src/features/instance.feature +++ b/src/features/instance.feature @@ -7,6 +7,7 @@ Feature: Mange Instances Background: Given I am an authorised user And I am logged in + And There is a mock pulp repository
Scenario: Download an Instance Key Given a mock running instance exists diff --git a/src/features/provider.feature b/src/features/provider.feature index 4b6c50c..7dac8b0 100644 --- a/src/features/provider.feature +++ b/src/features/provider.feature @@ -6,6 +6,7 @@ Feature: Manage Providers Background: Given I am an authorised user And I am logged in + And There is a mock pulp repository
Scenario: List providers Given I am on the homepage diff --git a/src/features/template.feature b/src/features/template.feature index a59d7cd..acdf337 100644 --- a/src/features/template.feature +++ b/src/features/template.feature @@ -14,7 +14,7 @@ Feature: Manage Templates Then I should be on the new image factory template page When I fill in the following: | tpl_name | mocktemplate | - | tpl_platform | fedora | + | tpl_platform | fedora13 | | tpl_summary | mockdesc | When I press "Save" Then I should be on the image factory templates page @@ -177,15 +177,15 @@ Feature: Manage Templates Scenario: Search for templates Given there are these templates: | name | platform | platform_version | architecture | summary | - | Test1 | fedora | 13 | x86_64 | Test Template Fedora 13 64 bit Description | - | Mock | fedora | 14 | i386 | Test Template Fedora 14 Description | - | Other | fedora | 10.04 | i386 | Test Template Ubuntu 10.04 32 bit Description | + | Test1 | fedora13 | 13 | x86_64 | Test Template Fedora 13 64 bit Description | + | Mock | fedora14 | 14 | i386 | Test Template Fedora 14 Description | + | Other | fedora14 | 10.04 | i386 | Test Template Ubuntu 10.04 32 bit Description | And I am on the image factory templates page Then I should see the following: | NAME | OS | VERSION | ARCH | - | Test1 | fedora | 13 | x86_64 | - | Mock | fedora | 14 | i386 | - | Other | fedora | 10.04 | i386 | + | Test1 | Fedora | 13 | x86_64 | + | Mock | Fedora | 14 | i386 | + | Other | Fedora | 10.04 | i386 | When I fill in "q" with "test" And I press "Search" Then I should see "Test1" @@ -220,9 +220,9 @@ Feature: Manage Templates Scenario: Delete multiple templates Given there are these templates: | name | platform | platform_version | architecture | summary | - | Test1 | fedora | 13 | x86_64 | Test Template Fedora 13 64 bit Description | - | Mock | fedora | 14 | i386 | Test Template Fedora 14 Description | - | Other | fedora | 10.04 | i386 | Test Template Ubuntu 10.04 32 bit Description | + | Test1 | fedora13 | 13 | x86_64 | Test Template Fedora 13 64 bit Description | + | Mock | fedora13 | 14 | i386 | Test Template Fedora 14 Description | + | Other | fedora13 | 10.04 | i386 | Test Template Ubuntu 10.04 32 bit Description | And I am on the image factory templates page When I check "Test1" template And I check "Mock" template diff --git a/src/spec/factories/template.rb b/src/spec/factories/template.rb index 1bb6fa6..9640cbc 100644 --- a/src/spec/factories/template.rb +++ b/src/spec/factories/template.rb @@ -1,6 +1,6 @@ Factory.define :template do |i| i.sequence(:name) { |n| "template#{n}" } - i.platform 'fedora' + i.platform 'fedora13' i.after_build do |tpl| if tpl.respond_to?(:stub!) tpl.stub!(:upload).and_return(true) diff --git a/src/spec/fixtures/repositories.json b/src/spec/fixtures/repositories.json index 4f9a6c8..732cb77 100644 --- a/src/spec/fixtures/repositories.json +++ b/src/spec/fixtures/repositories.json @@ -1,7 +1,7 @@ -[ { "_id" : "fedora", +[ { "_id" : "fedora13", "arch" : "x86_64", "errata" : "/repositories/fedora/errata/", - "id" : "fedora", + "id" : "fedora13", "name" : "fedora", "packagegroupcategories" : "/repositories/fedora/packagegroupcategories/", "packagegroups" : "/repositories/fedora/packagegroups/", diff --git a/src/spec/utils/repository_manager_spec.rb b/src/spec/utils/repository_manager_spec.rb index 53ce840..7876254 100644 --- a/src/spec/utils/repository_manager_spec.rb +++ b/src/spec/utils/repository_manager_spec.rb @@ -32,7 +32,7 @@ describe RepositoryManager do
it 'should return a list of repositories' do @rmanager.repositories.should have(1).items - @rmanager.repositories.first.id.should eql('fedora') + @rmanager.repositories.first.id.should eql('fedora13') end
it 'should return a list of packagegroups' do
On 03/22/2011 02:32 PM, jprovazn@redhat.com wrote:
From: Jan Provaznikjprovazn@redhat.com
Don't forget to run "rake dc:prepare_repos"
src/app/models/template.rb | 15 ++++++++++----- src/app/util/image_descriptor_xml.rb | 10 +++++++--- src/app/views/image_factory/templates/_list.haml | 2 +- .../image_descriptor_package_repositories.yml | 15 +++++++++++---- .../image_descriptor_platform_repositories.yml | 7 ++++++- src/features/api.feature | 1 + src/features/instance.feature | 1 + src/features/provider.feature | 1 + src/features/template.feature | 20 ++++++++++---------- src/spec/factories/template.rb | 2 +- src/spec/fixtures/repositories.json | 4 ++-- src/spec/utils/repository_manager_spec.rb | 2 +- 12 files changed, 52 insertions(+), 28 deletions(-)
diff --git a/src/app/models/template.rb b/src/app/models/template.rb index f4dc905..de12dae 100644 --- a/src/app/models/template.rb +++ b/src/app/models/template.rb @@ -67,11 +67,12 @@ class Template< ActiveRecord::Base def update_xml xml.name = self.name xml.description = self.summary
- platform = {}
- platform['name'] = self.platform.capitalize
- platform['version'] = self.platform_version
- platform['arch'] = self.architecture
- xml.platform = platform
- xml.platform = {
'id' => self.platform,
'name' => platforms[self.platform] ? platforms[self.platform]['name'] : '',
'version' => self.platform_version,
'arch' => self.architecture,
- } write_attribute(:xml, xml.to_xml) end
@@ -115,6 +116,10 @@ class Template< ActiveRecord::Base self.architecture = platforms[plat]['architecture'] end
- def platform_name
- platforms[self.platform] ? platforms[self.platform]['name'] : ''
- end
- # sets platform info from hash (used when importing images) def platform_hash=(plat) write_attribute(:platform, plat[:platform])
diff --git a/src/app/util/image_descriptor_xml.rb b/src/app/util/image_descriptor_xml.rb index 3a4bbae..cd146cf 100644 --- a/src/app/util/image_descriptor_xml.rb +++ b/src/app/util/image_descriptor_xml.rb @@ -64,6 +64,7 @@ class ImageDescriptorXML #recreate_repo_nodes platform_node = get_or_create_node('os') platform_node.xpath('.//*').remove
- platform_id = platform_hash.delete('id') platform_hash.each do |key, value| snode = Nokogiri::XML::Node.new(key, @doc) platform_node<< snode
@@ -73,9 +74,12 @@ class ImageDescriptorXML install_node.set_attribute('type', 'url') platform_node<< install_node url_node = Nokogiri::XML::Node.new('url', @doc)
- # TODO: change when more than one os is supported by conductor
- # url_node.content = "http://download.fedoraproject.org/pub/fedora/linux/releases/13/Fedora/x86_64..."
- url_node.content = YAML.load_file("#{RAILS_ROOT}/config/image_descriptor_package_repositories.yml")['baseurl']
- # TODO - currently we have platform repositories and package repositories,
- # mainly because it was possible to have multiple package repositories for
- # a platform before. Also platform url wasn't needed for old imagefactory.
- # Should be reworked when we switch to pulp
- rep = repository_manager.repositories.find {|r| r.id == platform_id}
- url_node.content = rep.yumurl if rep install_node<< url_node end
diff --git a/src/app/views/image_factory/templates/_list.haml b/src/app/views/image_factory/templates/_list.haml index 6cec40b..bf8be82 100644 --- a/src/app/views/image_factory/templates/_list.haml +++ b/src/app/views/image_factory/templates/_list.haml @@ -15,7 +15,7 @@ = check_box_tag 'selected[]', template.id, @url_params[:select] == 'all', :id => "selected_#{template.id}" = image_tag "blnk.png", :alt => template.platform, :class => "icon platform #{template.platform}" = link_to template.name, image_factory_template_path(template)
%td= template.platform
%td= template.platform_name %td= template.platform_version %td= image_tag 'blnk.png', :alt => 'yes', :class => "icon yes" %td= template.architecture
diff --git a/src/config/image_descriptor_package_repositories.yml b/src/config/image_descriptor_package_repositories.yml index 12a15d1..fd1a747 100644 --- a/src/config/image_descriptor_package_repositories.yml +++ b/src/config/image_descriptor_package_repositories.yml @@ -1,7 +1,14 @@ -id: fedora -name: Fedora -baseurl: http://download.fedoraproject.org/pub/fedora/linux/releases/13/Fedora/x86_64... -type: xml +-
- id: fedora13
- name: Fedora
- baseurl: http://download.fedoraproject.org/pub/fedora/linux/releases/13/Fedora/x86_64...
- type: xml
+-
id: fedora14
name: Fedora
baseurl: http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86_64...
type: xml
# you can define multiple repositories, as array, for example: #
diff --git a/src/config/image_descriptor_platform_repositories.yml b/src/config/image_descriptor_platform_repositories.yml index d16d0c0..b43c115 100644 --- a/src/config/image_descriptor_platform_repositories.yml +++ b/src/config/image_descriptor_platform_repositories.yml @@ -1,4 +1,9 @@ -fedora: +fedora13: name: Fedora version: 13 architecture: x86_64
+fedora14:
- name: Fedora
- version: 14
- architecture: x86_64
diff --git a/src/features/api.feature b/src/features/api.feature index 4ff624a..4651b8f 100644 --- a/src/features/api.feature +++ b/src/features/api.feature @@ -6,6 +6,7 @@ Feature: User authentication Background: Given I am an authorised user And I am logged in
And There is a mock pulp repository
Scenario: Check can start instance Given there is a user "testuser"
diff --git a/src/features/instance.feature b/src/features/instance.feature index ed08fb4..19b80bd 100644 --- a/src/features/instance.feature +++ b/src/features/instance.feature @@ -7,6 +7,7 @@ Feature: Mange Instances Background: Given I am an authorised user And I am logged in
And There is a mock pulp repository
Scenario: Download an Instance Key Given a mock running instance exists
diff --git a/src/features/provider.feature b/src/features/provider.feature index 4b6c50c..7dac8b0 100644 --- a/src/features/provider.feature +++ b/src/features/provider.feature @@ -6,6 +6,7 @@ Feature: Manage Providers Background: Given I am an authorised user And I am logged in
And There is a mock pulp repository
Scenario: List providers Given I am on the homepage
diff --git a/src/features/template.feature b/src/features/template.feature index a59d7cd..acdf337 100644 --- a/src/features/template.feature +++ b/src/features/template.feature @@ -14,7 +14,7 @@ Feature: Manage Templates Then I should be on the new image factory template page When I fill in the following: | tpl_name | mocktemplate |
| tpl_platform | fedora |
| tpl_platform | fedora13 | | tpl_summary | mockdesc | When I press "Save" Then I should be on the image factory templates page
@@ -177,15 +177,15 @@ Feature: Manage Templates Scenario: Search for templates Given there are these templates: | name | platform | platform_version | architecture | summary |
- | Test1 | fedora | 13 | x86_64 | Test Template Fedora 13 64 bit Description |
- | Mock | fedora | 14 | i386 | Test Template Fedora 14 Description |
- | Other | fedora | 10.04 | i386 | Test Template Ubuntu 10.04 32 bit Description |
- | Test1 | fedora13 | 13 | x86_64 | Test Template Fedora 13 64 bit Description |
- | Mock | fedora14 | 14 | i386 | Test Template Fedora 14 Description |
- | Other | fedora14 | 10.04 | i386 | Test Template Ubuntu 10.04 32 bit Description | And I am on the image factory templates page Then I should see the following: | NAME | OS | VERSION | ARCH |
- | Test1 | fedora | 13 | x86_64 |
- | Mock | fedora | 14 | i386 |
- | Other | fedora | 10.04 | i386 |
- | Test1 | Fedora | 13 | x86_64 |
- | Mock | Fedora | 14 | i386 |
- | Other | Fedora | 10.04 | i386 | When I fill in "q" with "test" And I press "Search" Then I should see "Test1"
@@ -220,9 +220,9 @@ Feature: Manage Templates Scenario: Delete multiple templates Given there are these templates: | name | platform | platform_version | architecture | summary |
- | Test1 | fedora | 13 | x86_64 | Test Template Fedora 13 64 bit Description |
- | Mock | fedora | 14 | i386 | Test Template Fedora 14 Description |
- | Other | fedora | 10.04 | i386 | Test Template Ubuntu 10.04 32 bit Description |
- | Test1 | fedora13 | 13 | x86_64 | Test Template Fedora 13 64 bit Description |
- | Mock | fedora13 | 14 | i386 | Test Template Fedora 14 Description |
- | Other | fedora13 | 10.04 | i386 | Test Template Ubuntu 10.04 32 bit Description | And I am on the image factory templates page When I check "Test1" template And I check "Mock" template
diff --git a/src/spec/factories/template.rb b/src/spec/factories/template.rb index 1bb6fa6..9640cbc 100644 --- a/src/spec/factories/template.rb +++ b/src/spec/factories/template.rb @@ -1,6 +1,6 @@ Factory.define :template do |i| i.sequence(:name) { |n| "template#{n}" }
- i.platform 'fedora'
- i.platform 'fedora13' i.after_build do |tpl| if tpl.respond_to?(:stub!) tpl.stub!(:upload).and_return(true)
diff --git a/src/spec/fixtures/repositories.json b/src/spec/fixtures/repositories.json index 4f9a6c8..732cb77 100644 --- a/src/spec/fixtures/repositories.json +++ b/src/spec/fixtures/repositories.json @@ -1,7 +1,7 @@ -[ { "_id" : "fedora", +[ { "_id" : "fedora13", "arch" : "x86_64", "errata" : "/repositories/fedora/errata/",
- "id" : "fedora",
- "id" : "fedora13", "name" : "fedora", "packagegroupcategories" : "/repositories/fedora/packagegroupcategories/", "packagegroups" : "/repositories/fedora/packagegroups/",
diff --git a/src/spec/utils/repository_manager_spec.rb b/src/spec/utils/repository_manager_spec.rb index 53ce840..7876254 100644 --- a/src/spec/utils/repository_manager_spec.rb +++ b/src/spec/utils/repository_manager_spec.rb @@ -32,7 +32,7 @@ describe RepositoryManager do
it 'should return a list of repositories' do @rmanager.repositories.should have(1).items
- @rmanager.repositories.first.id.should eql('fedora')
@rmanager.repositories.first.id.should eql('fedora13') end
it 'should return a list of packagegroups' do
With this patch I was able to build a Fedora 14 image, upload it to EC2 and launch the instance.
I'm getting 1 cucumber and 1 rspec failure, though:
~$ rake cucumber
(::) failed steps (::)
pulp repository: failed to fetch http://pulptest/repositories/ (code 0): (RuntimeError) ./app/util/repository_manager/pulp_repository.rb:10:in `method_missing' ./app/util/repository_manager/pulp_repository.rb:23:in `repositories' ./app/util/repository_manager.rb:98:in `get_repositories' ./app/util/repository_manager.rb:94:in `each' ./app/util/repository_manager.rb:94:in `get_repositories' ./app/util/repository_manager.rb:30:in `initialize' ./app/util/image_descriptor_xml.rb:217:in `new' ./app/util/image_descriptor_xml.rb:217:in `repository_manager' ./app/util/image_descriptor_xml.rb:81:in `platform=' ./app/models/template.rb:70:in `update_xml' ./features/step_definitions/provider_account_steps.rb:2:in `/^the account has an instance associated with it$/' features/provider_account.feature:61:in `And the account has an instance associated with it'
Failing Scenarios: cucumber features/provider_account.feature:58 # Scenario: Delete a provider account
~$ rake spec 1) 'DataServiceActiveRecord should calculate the total instance quota usage for a provider with a number of cloud accounts' FAILED expected: #<struct DataServiceActiveRecord::TotalQuotaUsagePoint name="username0", no_instances=10>, got: #<struct DataServiceActiveRecord::TotalQuotaUsagePoint name="username1", no_instances=20> (using ==) ./spec/services/data_service_active_record_spec.rb:23:
Finished in 649.429856 seconds
198 examples, 1 failure
aeolus-devel@lists.fedorahosted.org