Image Import feature rev.2
by Francesco Vollero
This patch its a review of the last patch of Image Imports. What i do here is:
1) Redesign the combobox design in a more slick way
2) Apply the jtomasek suggestion in cucumber test.
3) Fix a distraction bug in controller, uncommenting again the before_filter.
12 years, 6 months
[PATCH] Ensure qpidd is started before aeolus-connector by aeolus-configure
by Angus Thomas
From: Angus Thomas <athomas(a)redhat.com>
---
recipes/aeolus_recipe/manifests/conductor.pp | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/recipes/aeolus_recipe/manifests/conductor.pp b/recipes/aeolus_recipe/manifests/conductor.pp
index fe9d124..1d43ce8 100644
--- a/recipes/aeolus_recipe/manifests/conductor.pp
+++ b/recipes/aeolus_recipe/manifests/conductor.pp
@@ -55,7 +55,8 @@ class aeolus::conductor inherits aeolus {
ensure => 'running',
enable => true,
hasstatus => true,
- require => return_if($enable_packages, Package['rubygem-image_factory_connector'])}
+ require => [return_if($enable_packages, Package['rubygem-image_factory_connector']),
+ Service[qpidd]]}
### Initialize and start the aeolus database
# Right now we configure and start postgres, at some point I want
--
1.7.4
12 years, 6 months
[PATCH aeolus] BZ 692009 - bugfix
by jzigmund@redhat.com
From: Jozef Zigmund <jzigmund(a)redhat.com>
Bugfix for "Not able to add same account under two different providers"
---
src/app/models/provider_account.rb | 8 +++++++-
src/spec/models/provider_account_spec.rb | 7 +++++++
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/src/app/models/provider_account.rb b/src/app/models/provider_account.rb
index 80072c3..ecf5ffd 100644
--- a/src/app/models/provider_account.rb
+++ b/src/app/models/provider_account.rb
@@ -83,7 +83,13 @@ class ProviderAccount < ActiveRecord::Base
def validate_unique_username
cid = CredentialDefinition.find_by_name('username', :conditions => {:provider_type_id => provider.provider_type.id})
- errors.add(:base, "Username has already been taken") unless Credential.all(:conditions => {:value => credentials_hash['username'], :credential_definition_id => cid}).empty?
+ Credential.all(:conditions => {:value => credentials_hash['username'], :credential_definition_id => cid}).each do |c|
+ if c.provider_account.provider == self.provider
+ errors.add(:base, "Username has already been taken")
+ return false
+ end
+ end
+ return true
end
# Hooks
diff --git a/src/spec/models/provider_account_spec.rb b/src/spec/models/provider_account_spec.rb
index 3b6ae82..6845ed2 100644
--- a/src/spec/models/provider_account_spec.rb
+++ b/src/spec/models/provider_account_spec.rb
@@ -80,4 +80,11 @@ EOT
}
provider_account.build_credentials.to_s.should eql(expected_xml)
end
+
+ it "should create provider account with same username for different provider" do
+ provider_account1 = Factory :mock_provider_account
+ provider_account2 = Factory.build(:mock_provider_account, :provider => Factory.create(:mock_provider2))
+ provider_account1.credentials_hash.should == provider_account2.credentials_hash
+ provider_account2.should be_valid
+ end
end
--
1.7.4
12 years, 6 months
[PATCH configure 1/1] Ensure libvirt is installed before trying to start the service.
by Mike Orazi
---
recipes/aeolus_recipe/manifests/image-factory.pp | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/recipes/aeolus_recipe/manifests/image-factory.pp b/recipes/aeolus_recipe/manifests/image-factory.pp
index 499b6e4..5bcd24f 100644
--- a/recipes/aeolus_recipe/manifests/image-factory.pp
+++ b/recipes/aeolus_recipe/manifests/image-factory.pp
@@ -2,6 +2,11 @@
class aeolus::image-factory inherits aeolus {
if $enable_packages {
+
+ package { 'libvirt':
+ provider => 'yum',
+ ensure=> 'installed'
+ }
package { 'imagefactory':
provider => 'yum', ensure => 'installed',
require => [Yumrepo['aeolus_arch', 'aeolus_noarch']]
@@ -31,7 +36,8 @@ class aeolus::image-factory inherits aeolus {
service {'libvirtd':
ensure => 'running',
enable => true,
- hasstatus => true }
+ hasstatus => true,
+ require => return_if($enable_packages, Package['libvirt'])}
$requires = [return_if($enable_packages, Package['imagefactory']),
File['/var/tmp/imagefactory-mock'],
Service[qpidd], Service[libvirtd],
--
1.7.4
12 years, 6 months
Initial new logo and website design for Aeolus
by Justin Clift
Hi all,
Kyle Baker, one of the talented UX Design guys here at Red Hat,
is putting together a logo and initial website design
(look-n-feel, not structure) for Aeolus.
With the logo, Kyle said he wanted to represent blowing wind
in an abstract way. The logo as seen in the (attached) site
designs works for me. Personally (!) I like the colour balance
and rounded organic sort of shapes for the logo. I reckon
this'll be workable. :)
With these designs, the next step is for him to cut them into
appropriate .png image pieces (early next week). Then I'll
create some new webby templates using them (1-2 days prob).
The harder task is writing the new web content to use them,
which I'm working on. Still, I figured people might want to
see this stuff early.
Hope it's interesting. :)
Regards and best wishes,
Justin Clift
12 years, 6 months
[PATCH conductor] ImageImports UI and Image model changes to adapt to ImageImports UI need
by Francesco Vollero
From: Francesco Vollero <fvollero(a)redhat.com>
---
.../image_factory/image_imports_controller.rb | 28 +++++++++++++++++
src/app/models/image.rb | 10 +++++-
src/app/models/image_warehouse_object.rb | 1 +
src/app/views/image_factory/image_imports/new.haml | 14 ++++++++
src/config/locales/en.yml | 1 +
src/config/navigation.rb | 1 +
src/config/routes.rb | 1 +
src/features/image_import.feature | 33 ++++++++++++++++++++
8 files changed, 87 insertions(+), 2 deletions(-)
create mode 100644 src/app/controllers/image_factory/image_imports_controller.rb
create mode 100644 src/app/views/image_factory/image_imports/new.haml
create mode 100644 src/features/image_import.feature
diff --git a/src/app/controllers/image_factory/image_imports_controller.rb b/src/app/controllers/image_factory/image_imports_controller.rb
new file mode 100644
index 0000000..d8f3afa
--- /dev/null
+++ b/src/app/controllers/image_factory/image_imports_controller.rb
@@ -0,0 +1,28 @@
+class ImageFactory::ImageImportsController < ApplicationController
+ #before_filter :require_user
+
+ def new
+ init_provider_vars
+ end
+
+ def create
+ begin
+ Image.import(ProviderAccount.find(params[:provider_account_id]), params[:ami_id])
+ flash[:notice]="Image successfully imported"
+ redirect_to image_factory_templates_path
+ rescue => e
+ init_provider_vars
+ flash.now[:error]=e.message
+ Rails.logger.error([e.message,e.backtrace].join("\n "))
+ render :new
+ end
+ end
+
+protected
+def init_provider_vars
+ @providers = Provider.list_for_user(current_user, Privilege::VIEW)
+ if params[:provider]
+ @accounts_related_to_provider = Provider.find(params[:provider]).provider_accounts
+ end
+end
+end
diff --git a/src/app/models/image.rb b/src/app/models/image.rb
index f15f2da..5e7c994 100644
--- a/src/app/models/image.rb
+++ b/src/app/models/image.rb
@@ -78,7 +78,7 @@ class Image < ActiveRecord::Base
# TODO: for now when build is finished we call upload automatically for all providers
def after_update
- if self.status_changed? and self.status == STATE_COMPLETED
+ if not self.new_record? and self.status_changed? and self.status == STATE_COMPLETED
safe_warehouse_sync
upload_to_all_providers_with_account
end
@@ -126,6 +126,9 @@ class Image < ActiveRecord::Base
end
def self.import(account, image_id)
+ if image_id.blank?
+ raise "image id should not be blank"
+ end
unless raw_image = account.connect.image(image_id)
raise "There is no image with '#{image_id}' id"
end
@@ -154,6 +157,8 @@ class Image < ActiveRecord::Base
:provider_type_id => account.provider.provider_type_id,
:template_id => template.id
)
+ image.generate_uuid
+ image.upload
image.save!
rep = ProviderImage.new(
@@ -162,9 +167,10 @@ class Image < ActiveRecord::Base
:provider_image_key => image_id,
:status => STATE_COMPLETED
)
+ rep.generate_uuid
+ rep.upload
rep.save!
- template.upload
end
image
end
diff --git a/src/app/models/image_warehouse_object.rb b/src/app/models/image_warehouse_object.rb
index 43f3b76..b88cc93 100644
--- a/src/app/models/image_warehouse_object.rb
+++ b/src/app/models/image_warehouse_object.rb
@@ -45,6 +45,7 @@ module ImageWarehouseObject
# TODO: for now there is no way how it check if bucket exists in warehouse
# so we try to create bucket everytime, if bucket exists, warehouse returns
# 500 Internal server error
+ raise "uuid is not set" unless self.uuid
warehouse.create_bucket(warehouse_bucket) rescue true
# TODO: we delete existing object if it exists
warehouse.bucket(warehouse_bucket).object(self.uuid).delete! rescue true
diff --git a/src/app/views/image_factory/image_imports/new.haml b/src/app/views/image_factory/image_imports/new.haml
new file mode 100644
index 0000000..1ca7826
--- /dev/null
+++ b/src/app/views/image_factory/image_imports/new.haml
@@ -0,0 +1,14 @@
+- form_tag do
+ %fieldset.clear
+ = label_tag :provider, "Provider: "
+ = select_tag "provider", options_from_collection_for_select(@providers, 'id', "name"),{:include_blank => true}
+ = restful_submit_tag "Choose", 'new',new_image_factory_image_import_path, 'GET', :class => 'button'
+ %fieldset.clear
+ - if @accounts_related_to_provider
+ = label_tag :provider_account_id, "Provider Account ID: "
+ = select_tag :provider_account_id, options_from_collection_for_select(@accounts_related_to_provider, "id", "name")
+ %fieldset.clear
+ = label_tag :ami_id, "Image ID: "
+ = text_field_tag :ami_id, params[:ami_id]
+ %fieldset.clear
+ = restful_submit_tag "Import", 'create', image_factory_image_imports_path, 'POST', :class => "submit"
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 7a448de..7510a05 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -38,6 +38,7 @@ en:
assistance_requests: Assistance Requests
define: Define
deployables: Deployables
+ image_imports: Image Imports
basic_template: Template Builder Basic Workflow
browse_packages: Browse Packages
builds: Builds
diff --git a/src/config/navigation.rb b/src/config/navigation.rb
index bcf3b3b..b6944a5 100644
--- a/src/config/navigation.rb
+++ b/src/config/navigation.rb
@@ -10,6 +10,7 @@ SimpleNavigation::Configuration.run do |navigation|
second_level.item :templates, t(:templates), image_factory_templates_path
second_level.item :assemblies, t(:assemblies), image_factory_assemblies_path
second_level.item :deployables, t(:deployables), image_factory_deployables_path
+ second_level.item :image_imports, t(:image_imports), new_image_factory_image_import_path
end
first_level.item :administration, t(:administration), admin_users_path, :highlights_on => /\/admin/ do |second_level|
second_level.item :users, t(:users), admin_users_path
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 313dd25..98bc4f8 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -43,6 +43,7 @@ ActionController::Routing::Routes.draw do |map|
map.namespace 'image_factory' do |r|
r.resources :assemblies
+ r.resources :image_imports
r.resources :deployables, :collection => { :multi_destroy => :delete }
r.resources :templates, :collection => {:collections => :get, :add_selected => :get, :metagroup_packages => :get, :remove_package => :get, :multi_destroy => :delete}
r.connect "/builds/update_status.:format", :controller => :builds, :action => :update_status
diff --git a/src/features/image_import.feature b/src/features/image_import.feature
new file mode 100644
index 0000000..697bb7d
--- /dev/null
+++ b/src/features/image_import.feature
@@ -0,0 +1,33 @@
+Feature: Import Images
+ In order to use other images in my cloud infrastructure
+ As a user
+ I want to import images from other providers
+
+ Background:
+ Given I am an authorised user
+ And I am logged in
+ And I am on the homepage
+ And there is a provider named "testprovider"
+ And there is a provider account named "provider1"
+ When I go to the new image factory image import page
+ Then I should be on the new image factory image import page
+ When I select "testprovider" from "provider"
+ And I press "Choose"
+ When I select "provider1" from "provider_account_id"
+ And I fill in "ami_id" with "img1"
+
+ Scenario: Import a new image
+ Given I press "Import"
+ Then I should see "Image successfully imported"
+ And I should be on the image factory templates page
+
+ Scenario: Import an already imported image
+ Given I press "Import"
+ When I go to the new image factory image import page
+ When I select "testprovider" from "provider"
+ And I press "Choose"
+ When I select "provider1" from "provider_account_id"
+ And I fill in "ami_id" with "img1"
+ And I press "Import"
+ Then I should see "Image 'img1' is already imported"
+ And I should be on the new image factory image import page
--
1.7.4.2
12 years, 6 months
removed builds link
by Jan Provazník
This patchset removes build link from template properties tab and clean ups
controller's action. Second patch disables build for image import in builds tab.
12 years, 6 months
[PATCH conductor] BZ 677350
by Tomas Sedovic
From: Tomas Sedovic <tsedovic(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=677350
Fixed the confirmation message when deleting pools.
---
src/app/views/resources/pools/_list.haml | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/app/views/resources/pools/_list.haml b/src/app/views/resources/pools/_list.haml
index 558ff19..1e7b3d7 100644
--- a/src/app/views/resources/pools/_list.haml
+++ b/src/app/views/resources/pools/_list.haml
@@ -29,7 +29,7 @@
alert('Please select any pool to be deleted before clicking Delete button.');
e.preventDefault();
} else {
- if (!confirm("Are you sure you want to delete this user?")) {
+ if (!confirm("Are you sure you want to delete this pool?")) {
e.preventDefault();
}
}
--
1.7.4
12 years, 6 months
[PATCH aggregator] ImageImports UI and Image model changes to adapt to ImageImports UI need
by Francesco Vollero
From: Francesco Vollero <fvollero(a)redhat.com>
---
.../image_factory/image_imports_controller.rb | 28 +++++++++++++++++
src/app/models/image.rb | 10 +++++-
src/app/models/image_warehouse_object.rb | 1 +
src/app/views/image_factory/image_imports/new.haml | 14 ++++++++
src/config/locales/en.yml | 1 +
src/config/navigation.rb | 1 +
src/config/routes.rb | 1 +
src/features/image_import.feature | 33 ++++++++++++++++++++
8 files changed, 87 insertions(+), 2 deletions(-)
create mode 100644 src/app/controllers/image_factory/image_imports_controller.rb
create mode 100644 src/app/views/image_factory/image_imports/new.haml
create mode 100644 src/features/image_import.feature
diff --git a/src/app/controllers/image_factory/image_imports_controller.rb b/src/app/controllers/image_factory/image_imports_controller.rb
new file mode 100644
index 0000000..d8f3afa
--- /dev/null
+++ b/src/app/controllers/image_factory/image_imports_controller.rb
@@ -0,0 +1,28 @@
+class ImageFactory::ImageImportsController < ApplicationController
+ #before_filter :require_user
+
+ def new
+ init_provider_vars
+ end
+
+ def create
+ begin
+ Image.import(ProviderAccount.find(params[:provider_account_id]), params[:ami_id])
+ flash[:notice]="Image successfully imported"
+ redirect_to image_factory_templates_path
+ rescue => e
+ init_provider_vars
+ flash.now[:error]=e.message
+ Rails.logger.error([e.message,e.backtrace].join("\n "))
+ render :new
+ end
+ end
+
+protected
+def init_provider_vars
+ @providers = Provider.list_for_user(current_user, Privilege::VIEW)
+ if params[:provider]
+ @accounts_related_to_provider = Provider.find(params[:provider]).provider_accounts
+ end
+end
+end
diff --git a/src/app/models/image.rb b/src/app/models/image.rb
index f15f2da..5e7c994 100644
--- a/src/app/models/image.rb
+++ b/src/app/models/image.rb
@@ -78,7 +78,7 @@ class Image < ActiveRecord::Base
# TODO: for now when build is finished we call upload automatically for all providers
def after_update
- if self.status_changed? and self.status == STATE_COMPLETED
+ if not self.new_record? and self.status_changed? and self.status == STATE_COMPLETED
safe_warehouse_sync
upload_to_all_providers_with_account
end
@@ -126,6 +126,9 @@ class Image < ActiveRecord::Base
end
def self.import(account, image_id)
+ if image_id.blank?
+ raise "image id should not be blank"
+ end
unless raw_image = account.connect.image(image_id)
raise "There is no image with '#{image_id}' id"
end
@@ -154,6 +157,8 @@ class Image < ActiveRecord::Base
:provider_type_id => account.provider.provider_type_id,
:template_id => template.id
)
+ image.generate_uuid
+ image.upload
image.save!
rep = ProviderImage.new(
@@ -162,9 +167,10 @@ class Image < ActiveRecord::Base
:provider_image_key => image_id,
:status => STATE_COMPLETED
)
+ rep.generate_uuid
+ rep.upload
rep.save!
- template.upload
end
image
end
diff --git a/src/app/models/image_warehouse_object.rb b/src/app/models/image_warehouse_object.rb
index 43f3b76..b88cc93 100644
--- a/src/app/models/image_warehouse_object.rb
+++ b/src/app/models/image_warehouse_object.rb
@@ -45,6 +45,7 @@ module ImageWarehouseObject
# TODO: for now there is no way how it check if bucket exists in warehouse
# so we try to create bucket everytime, if bucket exists, warehouse returns
# 500 Internal server error
+ raise "uuid is not set" unless self.uuid
warehouse.create_bucket(warehouse_bucket) rescue true
# TODO: we delete existing object if it exists
warehouse.bucket(warehouse_bucket).object(self.uuid).delete! rescue true
diff --git a/src/app/views/image_factory/image_imports/new.haml b/src/app/views/image_factory/image_imports/new.haml
new file mode 100644
index 0000000..1ca7826
--- /dev/null
+++ b/src/app/views/image_factory/image_imports/new.haml
@@ -0,0 +1,14 @@
+- form_tag do
+ %fieldset.clear
+ = label_tag :provider, "Provider: "
+ = select_tag "provider", options_from_collection_for_select(@providers, 'id', "name"),{:include_blank => true}
+ = restful_submit_tag "Choose", 'new',new_image_factory_image_import_path, 'GET', :class => 'button'
+ %fieldset.clear
+ - if @accounts_related_to_provider
+ = label_tag :provider_account_id, "Provider Account ID: "
+ = select_tag :provider_account_id, options_from_collection_for_select(@accounts_related_to_provider, "id", "name")
+ %fieldset.clear
+ = label_tag :ami_id, "Image ID: "
+ = text_field_tag :ami_id, params[:ami_id]
+ %fieldset.clear
+ = restful_submit_tag "Import", 'create', image_factory_image_imports_path, 'POST', :class => "submit"
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 7a448de..7510a05 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -38,6 +38,7 @@ en:
assistance_requests: Assistance Requests
define: Define
deployables: Deployables
+ image_imports: Image Imports
basic_template: Template Builder Basic Workflow
browse_packages: Browse Packages
builds: Builds
diff --git a/src/config/navigation.rb b/src/config/navigation.rb
index bcf3b3b..b6944a5 100644
--- a/src/config/navigation.rb
+++ b/src/config/navigation.rb
@@ -10,6 +10,7 @@ SimpleNavigation::Configuration.run do |navigation|
second_level.item :templates, t(:templates), image_factory_templates_path
second_level.item :assemblies, t(:assemblies), image_factory_assemblies_path
second_level.item :deployables, t(:deployables), image_factory_deployables_path
+ second_level.item :image_imports, t(:image_imports), new_image_factory_image_import_path
end
first_level.item :administration, t(:administration), admin_users_path, :highlights_on => /\/admin/ do |second_level|
second_level.item :users, t(:users), admin_users_path
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 313dd25..98bc4f8 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -43,6 +43,7 @@ ActionController::Routing::Routes.draw do |map|
map.namespace 'image_factory' do |r|
r.resources :assemblies
+ r.resources :image_imports
r.resources :deployables, :collection => { :multi_destroy => :delete }
r.resources :templates, :collection => {:collections => :get, :add_selected => :get, :metagroup_packages => :get, :remove_package => :get, :multi_destroy => :delete}
r.connect "/builds/update_status.:format", :controller => :builds, :action => :update_status
diff --git a/src/features/image_import.feature b/src/features/image_import.feature
new file mode 100644
index 0000000..697bb7d
--- /dev/null
+++ b/src/features/image_import.feature
@@ -0,0 +1,33 @@
+Feature: Import Images
+ In order to use other images in my cloud infrastructure
+ As a user
+ I want to import images from other providers
+
+ Background:
+ Given I am an authorised user
+ And I am logged in
+ And I am on the homepage
+ And there is a provider named "testprovider"
+ And there is a provider account named "provider1"
+ When I go to the new image factory image import page
+ Then I should be on the new image factory image import page
+ When I select "testprovider" from "provider"
+ And I press "Choose"
+ When I select "provider1" from "provider_account_id"
+ And I fill in "ami_id" with "img1"
+
+ Scenario: Import a new image
+ Given I press "Import"
+ Then I should see "Image successfully imported"
+ And I should be on the image factory templates page
+
+ Scenario: Import an already imported image
+ Given I press "Import"
+ When I go to the new image factory image import page
+ When I select "testprovider" from "provider"
+ And I press "Choose"
+ When I select "provider1" from "provider_account_id"
+ And I fill in "ami_id" with "img1"
+ And I press "Import"
+ Then I should see "Image 'img1' is already imported"
+ And I should be on the new image factory image import page
--
1.7.4.2
12 years, 6 months