[PATCH conductor 3/3] Merge in new provider type model fix
by Richard Su
---
.../image_factory/templates_controller.rb | 21 ++++++++++++-------
src/spec/factories/provider.rb | 2 +-
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/app/controllers/image_factory/templates_controller.rb b/src/app/controllers/image_factory/templates_controller.rb
index 901e7c9..096a9c5 100644
--- a/src/app/controllers/image_factory/templates_controller.rb
+++ b/src/app/controllers/image_factory/templates_controller.rb
@@ -206,25 +206,30 @@ class ImageFactory::TemplatesController < ApplicationController
@targets_not_built = {}
@target_build_status = {}
- Image.available_targets.each do |id, target|
- @targets_not_built[id] = target
+ Provider.all.each do |p|
+ @targets_not_built[p.provider_type.id] = p.provider_type.name
end
-
+
tpl.images.each do |img|
- @target_build_status[img.target] = img.status
- @targets_not_built.delete(img.target)
+ @target_build_status[img.provider_type.name] = img.status
+ @targets_not_built.delete(img.provider_type_id)
img.provider_images.each do |pimg|
- @imaged_provider_types[pimg.provider_id] = img.target
+ @imaged_provider_types[pimg.provider_id] = img.provider_type.id
end
end
@targets_not_built = @targets_not_built.invert
- @providers_not_uploaded = Provider.find_all_by_provider_type((a)imaged_provider_types.values.uniq)
+ @providers_to_delete = {}
+ @providers_not_uploaded = Provider.find_all_by_provider_type_id((a)imaged_provider_types.values.uniq)
@providers_not_uploaded.each do |provider|
if @imaged_provider_types.has_key?(provider.id)
- @providers_not_uploaded.delete(provider)
+ @providers_to_delete[provider] = provider
end
end
+
+ @providers_to_delete.keys.each do |p|
+ @providers_not_uploaded.delete(p)
+ end
@images = tpl.images
end
diff --git a/src/spec/factories/provider.rb b/src/spec/factories/provider.rb
index 1d1992a..34f3011 100644
--- a/src/spec/factories/provider.rb
+++ b/src/spec/factories/provider.rb
@@ -28,7 +28,7 @@ end
Factory.define :ec2_provider_no_builds, :parent => :provider do |p|
p.name 'amazon-ec2-no-builds'
- p.provider_type '1'
+ p.provider_type { ProviderType.find_by_codename("ec2") }
p.url 'http://localhost:3002/api'
p.hardware_profiles { |hp| [hp.association(:ec2_hwp1)] }
p.after_create { |p| p.realms << Factory(:realm4, :provider => p) }
--
1.7.4
12 years, 9 months
[PATCH conductor 2/3] UI interface to select specific providers to upload build images to
by Richard Su
---
.../controllers/image_factory/builds_controller.rb | 7 +++++
.../image_factory/templates_controller.rb | 14 +++++++++-
src/app/models/image.rb | 4 +-
src/app/views/image_factory/templates/_builds.haml | 25 ++++++++++++++-----
src/config/routes.rb | 2 +-
5 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/src/app/controllers/image_factory/builds_controller.rb b/src/app/controllers/image_factory/builds_controller.rb
index 01f05bd..6d335df 100644
--- a/src/app/controllers/image_factory/builds_controller.rb
+++ b/src/app/controllers/image_factory/builds_controller.rb
@@ -44,6 +44,13 @@ class ImageFactory::BuildsController < ApplicationController
render :action => 'new'
end
end
+
+ def upload_or_delete
+ @tpl = Template.find(params[:template_id])
+ # FIXME: add logic to upload image
+ # or delete image depending on which button was used
+ redirect_to image_factory_template_path(@tpl, :details_tab => 'builds')
+ end
def edit
# FIXME: is @tpl defined here? do we need check_permission here?
diff --git a/src/app/controllers/image_factory/templates_controller.rb b/src/app/controllers/image_factory/templates_controller.rb
index a38fe0d..901e7c9 100644
--- a/src/app/controllers/image_factory/templates_controller.rb
+++ b/src/app/controllers/image_factory/templates_controller.rb
@@ -196,20 +196,30 @@ class ImageFactory::TemplatesController < ApplicationController
def load_images(tpl)
@images_header = [
+ {:name => '', :sort_attr => 'select'},
{:name => 'ARCH', :sort_attr => 'templates.architecture'},
{:name => 'PROVIDER', :sort_attr => 'provider'},
{:name => 'STATUS', :sort_attr => 'status'},
{:name => 'UPLOADED?', :sort_attr => 'images.uploaded'},
]
-
@imaged_provider_types = {}
+ @targets_not_built = {}
+ @target_build_status = {}
+
+ Image.available_targets.each do |id, target|
+ @targets_not_built[id] = target
+ end
+
tpl.images.each do |img|
+ @target_build_status[img.target] = img.status
+ @targets_not_built.delete(img.target)
img.provider_images.each do |pimg|
@imaged_provider_types[pimg.provider_id] = img.target
end
end
+ @targets_not_built = @targets_not_built.invert
- @providers_not_uploaded = Provider.find_all_by_provider_type((a)imaged_provider_types.keys.uniq)
+ @providers_not_uploaded = Provider.find_all_by_provider_type((a)imaged_provider_types.values.uniq)
@providers_not_uploaded.each do |provider|
if @imaged_provider_types.has_key?(provider.id)
@providers_not_uploaded.delete(provider)
diff --git a/src/app/models/image.rb b/src/app/models/image.rb
index cfa15e4..dad94f3 100644
--- a/src/app/models/image.rb
+++ b/src/app/models/image.rb
@@ -83,7 +83,7 @@ class Image < ActiveRecord::Base
unless provider = Provider.find_by_target_with_account(target.id)
raise "There is no provider for '#{target.name}' type with valid account."
end
-
+
img = nil
Image.transaction do
img = Image.create!(
@@ -94,7 +94,7 @@ class Image < ActiveRecord::Base
)
ProviderImage.create!(
:image_id => img.id,
- :provider_id => provider
+ :provider_id => provider.id
)
end
return img
diff --git a/src/app/views/image_factory/templates/_builds.haml b/src/app/views/image_factory/templates/_builds.haml
index a9822f0..f1a98c8 100644
--- a/src/app/views/image_factory/templates/_builds.haml
+++ b/src/app/views/image_factory/templates/_builds.haml
@@ -3,11 +3,20 @@ Builds for
= @tpl.platform_version
, template "#{(a)tpl.name}"
-- form_tag :action => "" do
+- form_tag(image_factory_builds_path, { :action => 'create', :method => :post }) do
+ = hidden_field_tag :template_id, @tpl.id
+ New Build for
+ = select( "targets", "", options_for_select(@targets_not_built))
+ = submit_tag "Go", :name => "build"
+
+- form_tag(upload_or_delete_image_factory_builds_path, { :action => "destroy", :method => :post }) do
+ = hidden_field_tag :template_id, @tpl.id
/= restful_submit_tag "Cancel Job", :name => "job_details", :disabled => true, :class => "icon"
/= restful_submit_tag "Show Job Details", :name => "job_details", :disabled => true, :class => "icon"
/= restful_submit_tag "Show Job Log", :name => "job_log", :disabled => true, :class => "icon"
/= restful_submit_tag "Clear Job History", :name => "job_history", :disabled => true, :class => "icon"
+ = submit_tag "Upload", :name => "upload"
+ = submit_tag "Delete", :name => "delete"
%table
= sortable_table_header(@images_header)
@@ -19,13 +28,15 @@ Builds for
- @images.each do |img|
- img.provider_images.each do |pimg|
%tr
+ %td= check_box_tag 'selected[]', pimg.provider_id, @url_params[:select] == 'all', :id => "selected_#{pimg.provider_id}"
%td= img.template.architecture
%td= pimg.provider.nil? ? '' : pimg.provider.name
%td= img.status
%td= pimg.uploaded? ? 'yes' : 'no'
- - @providers_not_uploaded.each do |provider|
- %tr
- %td= @tpl.architecture
- %td= provider.name
- %td= img.status
- %td no
\ No newline at end of file
+ - @providers_not_uploaded.each do |provider|
+ %tr
+ %td= check_box_tag 'selected[]', provider.id, @url_params[:select] == 'all', :id => "selected_#{provider.id}"
+ %td= @tpl.architecture
+ %td= provider.name
+ %td= @target_build_status[provider.provider_type]
+ %td no
\ No newline at end of file
diff --git a/src/config/routes.rb b/src/config/routes.rb
index c936726..b64713f 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -45,7 +45,7 @@ ActionController::Routing::Routes.draw do |map|
r.resources :assemblies
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.resources :builds
+ r.resources :builds, :collection => { :upload_or_delete => :delete }
end
map.namespace 'admin' do |r|
--
1.7.4
12 years, 9 months
[PATCH conductor 1/3] Task #433 Create UI to show which providers an image has been uploaded to
by Richard Su
Renamed "Images" tab to "Builds"
Table columns now matches cloud-engine-templates-details-images.png mockup.
Table shows builds that have been completed and uploaded, and additional
providers that a completed build can be uploaded to. The additional provider's
provider type would have to match the build's target.
Note the Arch column may be redundant because the Architecture is specified
per template and not per build.
---
.../controllers/image_factory/builds_controller.rb | 2 +-
.../image_factory/templates_controller.rb | 27 +++++++++++++----
src/app/views/image_factory/templates/_builds.haml | 31 ++++++++++++++++++++
src/app/views/image_factory/templates/_images.haml | 20 -------------
src/features/step_definitions/template_steps.rb | 6 +++-
src/features/support/paths.rb | 2 +-
src/features/template.feature | 13 ++++++++
src/spec/factories/provider.rb | 8 +++++
8 files changed, 79 insertions(+), 30 deletions(-)
create mode 100644 src/app/views/image_factory/templates/_builds.haml
delete mode 100644 src/app/views/image_factory/templates/_images.haml
diff --git a/src/app/controllers/image_factory/builds_controller.rb b/src/app/controllers/image_factory/builds_controller.rb
index ac0a3e2..01f05bd 100644
--- a/src/app/controllers/image_factory/builds_controller.rb
+++ b/src/app/controllers/image_factory/builds_controller.rb
@@ -38,7 +38,7 @@ class ImageFactory::BuildsController < ApplicationController
end
flash[:warning] = 'Warning: ' + warnings.join unless warnings.empty?
if errors.empty?
- redirect_to image_factory_template_path(@tpl, :details_tab => 'images')
+ redirect_to image_factory_template_path(@tpl, :details_tab => 'builds')
else
flash_error('Error while trying to build image', errors)
render :action => 'new'
diff --git a/src/app/controllers/image_factory/templates_controller.rb b/src/app/controllers/image_factory/templates_controller.rb
index 5f905fa..a38fe0d 100644
--- a/src/app/controllers/image_factory/templates_controller.rb
+++ b/src/app/controllers/image_factory/templates_controller.rb
@@ -25,9 +25,9 @@ class ImageFactory::TemplatesController < ApplicationController
@tpl = Template.find(params[:id])
require_privilege(Privilege::VIEW, @tpl)
@url_params = params.clone
- @tab_captions = ['Properties', 'Images']
+ @tab_captions = ['Properties', 'Builds']
@details_tab = params[:details_tab].blank? ? 'properties' : params[:details_tab]
- load_images(@tpl) if @details_tab == 'images'
+ load_images(@tpl) if @details_tab == 'builds'
respond_to do |format|
format.js do
if @url_params.delete :details_pane
@@ -196,12 +196,26 @@ class ImageFactory::TemplatesController < ApplicationController
def load_images(tpl)
@images_header = [
- {:name => 'NAME', :sort_attr => 'templates.name'},
- {:name => 'OS', :sort_attr => 'templates.platform'},
- {:name => 'VERSION', :sort_attr => 'templates.platform_version'},
{:name => 'ARCH', :sort_attr => 'templates.architecture'},
+ {:name => 'PROVIDER', :sort_attr => 'provider'},
{:name => 'STATUS', :sort_attr => 'status'},
- ]
+ {:name => 'UPLOADED?', :sort_attr => 'images.uploaded'},
+ ]
+
+ @imaged_provider_types = {}
+ tpl.images.each do |img|
+ img.provider_images.each do |pimg|
+ @imaged_provider_types[pimg.provider_id] = img.target
+ end
+ end
+
+ @providers_not_uploaded = Provider.find_all_by_provider_type((a)imaged_provider_types.keys.uniq)
+ @providers_not_uploaded.each do |provider|
+ if @imaged_provider_types.has_key?(provider.id)
+ @providers_not_uploaded.delete(provider)
+ end
+ end
+
@images = tpl.images
end
@@ -283,4 +297,3 @@ class ImageFactory::TemplatesController < ApplicationController
end
end
-
diff --git a/src/app/views/image_factory/templates/_builds.haml b/src/app/views/image_factory/templates/_builds.haml
new file mode 100644
index 0000000..a9822f0
--- /dev/null
+++ b/src/app/views/image_factory/templates/_builds.haml
@@ -0,0 +1,31 @@
+Builds for
+= @tpl.platform
+= @tpl.platform_version
+, template "#{(a)tpl.name}"
+
+- form_tag :action => "" do
+ /= restful_submit_tag "Cancel Job", :name => "job_details", :disabled => true, :class => "icon"
+ /= restful_submit_tag "Show Job Details", :name => "job_details", :disabled => true, :class => "icon"
+ /= restful_submit_tag "Show Job Log", :name => "job_log", :disabled => true, :class => "icon"
+ /= restful_submit_tag "Clear Job History", :name => "job_history", :disabled => true, :class => "icon"
+
+ %table
+ = sortable_table_header(@images_header)
+ %tbody
+ - if @images.empty?
+ %tr
+ %td{:colspan => 5} No Builds
+ - else
+ - @images.each do |img|
+ - img.provider_images.each do |pimg|
+ %tr
+ %td= img.template.architecture
+ %td= pimg.provider.nil? ? '' : pimg.provider.name
+ %td= img.status
+ %td= pimg.uploaded? ? 'yes' : 'no'
+ - @providers_not_uploaded.each do |provider|
+ %tr
+ %td= @tpl.architecture
+ %td= provider.name
+ %td= img.status
+ %td no
\ No newline at end of file
diff --git a/src/app/views/image_factory/templates/_images.haml b/src/app/views/image_factory/templates/_images.haml
deleted file mode 100644
index 3fb1046..0000000
--- a/src/app/views/image_factory/templates/_images.haml
+++ /dev/null
@@ -1,20 +0,0 @@
-- form_tag :action => "" do
- /= restful_submit_tag "Cancel Job", :name => "job_details", :disabled => true, :class => "icon"
- /= restful_submit_tag "Show Job Details", :name => "job_details", :disabled => true, :class => "icon"
- /= restful_submit_tag "Show Job Log", :name => "job_log", :disabled => true, :class => "icon"
- /= restful_submit_tag "Clear Job History", :name => "job_history", :disabled => true, :class => "icon"
-
- %table
- = sortable_table_header(@images_header)
- %tbody
- - if @images.empty?
- %tr
- %td{:colspan => 5} No Images
- - else
- - @images.each do |img|
- %tr
- %td= img.template.name
- %td= img.template.platform
- %td= img.template.platform_version
- %td= img.template.architecture
- %td= img.status
diff --git a/src/features/step_definitions/template_steps.rb b/src/features/step_definitions/template_steps.rb
index 3491eb4..69a6928 100644
--- a/src/features/step_definitions/template_steps.rb
+++ b/src/features/step_definitions/template_steps.rb
@@ -91,7 +91,6 @@ end
When /^I choose this template$/ do
click_link((a)template.name)
end
-
Given /^there is Amazon AWS provider account$/ do
account = Factory.build(:ec2_provider_account)
account.save!
@@ -101,6 +100,11 @@ Given /^there is Amazon AWS build for this template$/ do
Image.build(@template, ProviderType.find_by_codename("ec2"))
end
+Given /^there is Amazon AWS provider with no builds$/ do
+ provider = Factory.build(:ec2_provider_no_builds)
+ provider.save!
+end
+
Given /^there is an imported template$/ do
@template = Factory.build :template, :name => name, :imported => true
@template.save!
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index c123cba..5af9b34 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -81,7 +81,7 @@ module NavigationHelpers
url_for new_build_path
when /the template builds page/
- url_for image_factory_template_path(@template, :details_tab => 'images')
+ url_for image_factory_template_path(@template, :details_tab => 'builds')
when /the templates page/
templates_path
diff --git a/src/features/template.feature b/src/features/template.feature
index 336b194..4fe8e9a 100644
--- a/src/features/template.feature
+++ b/src/features/template.feature
@@ -105,6 +105,19 @@ Feature: Manage Templates
# test that we see a collection (collections are loaded by default)
And I should see an input "conductor"
+ Scenario: See upload status
+ Given there is a "mock1" template
+ And there is Amazon AWS provider account
+ And there is Amazon AWS build for this template
+ And there is Amazon AWS provider with no builds
+ And I am on the image factory templates page
+ When I choose this template
+ And I follow "Builds"
+ Then I should see the following:
+ | ARCH | PROVIDERS | STATUS | UPLOADED? |
+ | x86_64 | amazon-ec2 | queued | no |
+ | x86_64 | amazon-ec2-no-builds | queued | no |
+
Scenario: Build template
Given there is a "mock1" template
And there is Amazon AWS provider account
diff --git a/src/spec/factories/provider.rb b/src/spec/factories/provider.rb
index 03f8773..1d1992a 100644
--- a/src/spec/factories/provider.rb
+++ b/src/spec/factories/provider.rb
@@ -25,3 +25,11 @@ Factory.define :ec2_provider, :parent => :provider do |p|
p.hardware_profiles { |hp| [hp.association(:ec2_hwp1)] }
p.after_create { |p| p.realms << Factory(:realm4, :provider => p) }
end
+
+Factory.define :ec2_provider_no_builds, :parent => :provider do |p|
+ p.name 'amazon-ec2-no-builds'
+ p.provider_type '1'
+ p.url 'http://localhost:3002/api'
+ p.hardware_profiles { |hp| [hp.association(:ec2_hwp1)] }
+ p.after_create { |p| p.realms << Factory(:realm4, :provider => p) }
+end
--
1.7.4
12 years, 9 months
[PATCH 1/2] Task #433 Create UI to show which providers an image has been uploaded to
by Richard Su
Renamed "Images" tab to "Builds"
Table columns now matches cloud-engine-templates-details-images.png mockup.
Table shows builds that have been completed and uploaded, and additional
providers that a completed build can be uploaded to. The additional provider's
provider type would have to match the build's target.
Note the Arch column may be redundant because the Architecture is specified
per template and not per build.
---
.../controllers/image_factory/builds_controller.rb | 2 +-
.../image_factory/templates_controller.rb | 27 +++++++++++++----
src/app/views/image_factory/templates/_builds.haml | 31 ++++++++++++++++++++
src/app/views/image_factory/templates/_images.haml | 20 -------------
src/features/step_definitions/template_steps.rb | 6 +++-
src/features/support/paths.rb | 2 +-
src/features/template.feature | 13 ++++++++
src/spec/factories/provider.rb | 8 +++++
8 files changed, 79 insertions(+), 30 deletions(-)
create mode 100644 src/app/views/image_factory/templates/_builds.haml
delete mode 100644 src/app/views/image_factory/templates/_images.haml
diff --git a/src/app/controllers/image_factory/builds_controller.rb b/src/app/controllers/image_factory/builds_controller.rb
index ac0a3e2..01f05bd 100644
--- a/src/app/controllers/image_factory/builds_controller.rb
+++ b/src/app/controllers/image_factory/builds_controller.rb
@@ -38,7 +38,7 @@ class ImageFactory::BuildsController < ApplicationController
end
flash[:warning] = 'Warning: ' + warnings.join unless warnings.empty?
if errors.empty?
- redirect_to image_factory_template_path(@tpl, :details_tab => 'images')
+ redirect_to image_factory_template_path(@tpl, :details_tab => 'builds')
else
flash_error('Error while trying to build image', errors)
render :action => 'new'
diff --git a/src/app/controllers/image_factory/templates_controller.rb b/src/app/controllers/image_factory/templates_controller.rb
index 5f905fa..a38fe0d 100644
--- a/src/app/controllers/image_factory/templates_controller.rb
+++ b/src/app/controllers/image_factory/templates_controller.rb
@@ -25,9 +25,9 @@ class ImageFactory::TemplatesController < ApplicationController
@tpl = Template.find(params[:id])
require_privilege(Privilege::VIEW, @tpl)
@url_params = params.clone
- @tab_captions = ['Properties', 'Images']
+ @tab_captions = ['Properties', 'Builds']
@details_tab = params[:details_tab].blank? ? 'properties' : params[:details_tab]
- load_images(@tpl) if @details_tab == 'images'
+ load_images(@tpl) if @details_tab == 'builds'
respond_to do |format|
format.js do
if @url_params.delete :details_pane
@@ -196,12 +196,26 @@ class ImageFactory::TemplatesController < ApplicationController
def load_images(tpl)
@images_header = [
- {:name => 'NAME', :sort_attr => 'templates.name'},
- {:name => 'OS', :sort_attr => 'templates.platform'},
- {:name => 'VERSION', :sort_attr => 'templates.platform_version'},
{:name => 'ARCH', :sort_attr => 'templates.architecture'},
+ {:name => 'PROVIDER', :sort_attr => 'provider'},
{:name => 'STATUS', :sort_attr => 'status'},
- ]
+ {:name => 'UPLOADED?', :sort_attr => 'images.uploaded'},
+ ]
+
+ @imaged_provider_types = {}
+ tpl.images.each do |img|
+ img.provider_images.each do |pimg|
+ @imaged_provider_types[pimg.provider_id] = img.target
+ end
+ end
+
+ @providers_not_uploaded = Provider.find_all_by_provider_type((a)imaged_provider_types.keys.uniq)
+ @providers_not_uploaded.each do |provider|
+ if @imaged_provider_types.has_key?(provider.id)
+ @providers_not_uploaded.delete(provider)
+ end
+ end
+
@images = tpl.images
end
@@ -283,4 +297,3 @@ class ImageFactory::TemplatesController < ApplicationController
end
end
-
diff --git a/src/app/views/image_factory/templates/_builds.haml b/src/app/views/image_factory/templates/_builds.haml
new file mode 100644
index 0000000..a9822f0
--- /dev/null
+++ b/src/app/views/image_factory/templates/_builds.haml
@@ -0,0 +1,31 @@
+Builds for
+= @tpl.platform
+= @tpl.platform_version
+, template "#{(a)tpl.name}"
+
+- form_tag :action => "" do
+ /= restful_submit_tag "Cancel Job", :name => "job_details", :disabled => true, :class => "icon"
+ /= restful_submit_tag "Show Job Details", :name => "job_details", :disabled => true, :class => "icon"
+ /= restful_submit_tag "Show Job Log", :name => "job_log", :disabled => true, :class => "icon"
+ /= restful_submit_tag "Clear Job History", :name => "job_history", :disabled => true, :class => "icon"
+
+ %table
+ = sortable_table_header(@images_header)
+ %tbody
+ - if @images.empty?
+ %tr
+ %td{:colspan => 5} No Builds
+ - else
+ - @images.each do |img|
+ - img.provider_images.each do |pimg|
+ %tr
+ %td= img.template.architecture
+ %td= pimg.provider.nil? ? '' : pimg.provider.name
+ %td= img.status
+ %td= pimg.uploaded? ? 'yes' : 'no'
+ - @providers_not_uploaded.each do |provider|
+ %tr
+ %td= @tpl.architecture
+ %td= provider.name
+ %td= img.status
+ %td no
\ No newline at end of file
diff --git a/src/app/views/image_factory/templates/_images.haml b/src/app/views/image_factory/templates/_images.haml
deleted file mode 100644
index 3fb1046..0000000
--- a/src/app/views/image_factory/templates/_images.haml
+++ /dev/null
@@ -1,20 +0,0 @@
-- form_tag :action => "" do
- /= restful_submit_tag "Cancel Job", :name => "job_details", :disabled => true, :class => "icon"
- /= restful_submit_tag "Show Job Details", :name => "job_details", :disabled => true, :class => "icon"
- /= restful_submit_tag "Show Job Log", :name => "job_log", :disabled => true, :class => "icon"
- /= restful_submit_tag "Clear Job History", :name => "job_history", :disabled => true, :class => "icon"
-
- %table
- = sortable_table_header(@images_header)
- %tbody
- - if @images.empty?
- %tr
- %td{:colspan => 5} No Images
- - else
- - @images.each do |img|
- %tr
- %td= img.template.name
- %td= img.template.platform
- %td= img.template.platform_version
- %td= img.template.architecture
- %td= img.status
diff --git a/src/features/step_definitions/template_steps.rb b/src/features/step_definitions/template_steps.rb
index 3491eb4..69a6928 100644
--- a/src/features/step_definitions/template_steps.rb
+++ b/src/features/step_definitions/template_steps.rb
@@ -91,7 +91,6 @@ end
When /^I choose this template$/ do
click_link((a)template.name)
end
-
Given /^there is Amazon AWS provider account$/ do
account = Factory.build(:ec2_provider_account)
account.save!
@@ -101,6 +100,11 @@ Given /^there is Amazon AWS build for this template$/ do
Image.build(@template, ProviderType.find_by_codename("ec2"))
end
+Given /^there is Amazon AWS provider with no builds$/ do
+ provider = Factory.build(:ec2_provider_no_builds)
+ provider.save!
+end
+
Given /^there is an imported template$/ do
@template = Factory.build :template, :name => name, :imported => true
@template.save!
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index c123cba..5af9b34 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -81,7 +81,7 @@ module NavigationHelpers
url_for new_build_path
when /the template builds page/
- url_for image_factory_template_path(@template, :details_tab => 'images')
+ url_for image_factory_template_path(@template, :details_tab => 'builds')
when /the templates page/
templates_path
diff --git a/src/features/template.feature b/src/features/template.feature
index 336b194..4fe8e9a 100644
--- a/src/features/template.feature
+++ b/src/features/template.feature
@@ -105,6 +105,19 @@ Feature: Manage Templates
# test that we see a collection (collections are loaded by default)
And I should see an input "conductor"
+ Scenario: See upload status
+ Given there is a "mock1" template
+ And there is Amazon AWS provider account
+ And there is Amazon AWS build for this template
+ And there is Amazon AWS provider with no builds
+ And I am on the image factory templates page
+ When I choose this template
+ And I follow "Builds"
+ Then I should see the following:
+ | ARCH | PROVIDERS | STATUS | UPLOADED? |
+ | x86_64 | amazon-ec2 | queued | no |
+ | x86_64 | amazon-ec2-no-builds | queued | no |
+
Scenario: Build template
Given there is a "mock1" template
And there is Amazon AWS provider account
diff --git a/src/spec/factories/provider.rb b/src/spec/factories/provider.rb
index 03f8773..1d1992a 100644
--- a/src/spec/factories/provider.rb
+++ b/src/spec/factories/provider.rb
@@ -25,3 +25,11 @@ Factory.define :ec2_provider, :parent => :provider do |p|
p.hardware_profiles { |hp| [hp.association(:ec2_hwp1)] }
p.after_create { |p| p.realms << Factory(:realm4, :provider => p) }
end
+
+Factory.define :ec2_provider_no_builds, :parent => :provider do |p|
+ p.name 'amazon-ec2-no-builds'
+ p.provider_type '1'
+ p.url 'http://localhost:3002/api'
+ p.hardware_profiles { |hp| [hp.association(:ec2_hwp1)] }
+ p.after_create { |p| p.realms << Factory(:realm4, :provider => p) }
+end
--
1.7.4
12 years, 9 months
Stateful Vs Stateless Instances Findings
by Ian Main
We had a meeting this morning and we managed to hash some things out on
this subject. Here is the result. I am posting this to both
aeolus-devel and deltacloud-devel as it impacts both.
Stateful vs Stateless instances and the cloud
---------------------------------------------
In an effort to support private cloud, we had to sort out what to do about
'stateful' instances. We're defining a stateful instance as one where
the image for the instance does not get destroyed when the instance is
stopped and it is possible to restart it with the same state.
Also, the model that Aeolus Conductor is using regarding images is the
same as ec2, where a given image can be used to launch as many instances
as needed. This is not the same as the model used by many private cloud
providers where an image is used directly by a instance/VM and it is
not possible for it to be used by multiple running instances.
We want to tackle these questions in two different phases. Stateless
cloud on supported providers is presently the most important requirement,
but we will need both soon.
STATELESS CLOUD
---------------
The way that some providers (such as rhevm and vmware) launch instances
now are not what we need. Cloud launch must start an instance in
such a way that it can perform multiple launches from the same image.
To support that what really needs to happen is that prior to launch the
image needs to be either cloned or snapshotted.
Below are a couple of ways we thought of to do this:
- Deltacloud API provider driver start call must clone disk on startup
if the provider does not already do that.
- On destroy, API must clean up cloned disk image if the provider does
not already do it.
- On shutdown, the API leaves the disk alone.
OR
- Deltacloud API provides instrospection into the driver and specifies
whether or not an instance start will clone the disk for us.
- It also needs to specify if the storage needs to be destroyed on
instance shutdown (some clouds do, some don't).
- Deltacloud API provides APIs for performing the clone and then cleanup
of cloned images.
- It is then up to the client to perform the right sequence of actions
to get the desired behavior.
Either of these will work and allow us to make the Conductor model
consistent with existing public cloud providers.
STATEFUL CLOUD INSTANCES
------------------------
Stateful instances have the ability to be stopped without destroying the
disk image and then resumed from the same state. In order to support
this we need:
Condor:
- Condor must have "suspend"/stop/restart support.
- Image must be built to target stateful - we need a toggle at image
build time and at launch time.
Deltacloud API:
- Deltacloud API must support stop that does not cleanup disk image but
only if available.
- Introspection as to whether or not a stop is valid. Currently
stop/destroy is the same op on ec2, but 'stop' should be invalid. Stop is
only valid for stateful instances. Destroy cleans up disk image. This is
to act as introspection as to whether the instance is stateful or not.
This may not be needed depending on how we support disk clone/cleanup as
defined above.
Conductor:
- If an instance on a stateful-only cloud is designated stateless, we must
track that extra condition in the conductor (because stateful/stateless
will act the same). This lets us know if we need to clean up disk
images etc.
- We could provide a 'stateful/stateless' toggle at launch time that
warned the user there is no match and they must build a stateful instance
for it to work.
Thanks!
Ian
12 years, 9 months
[PATCH 2/2] UI interface to select specific providers to upload build images to
by Richard Su
---
.../controllers/image_factory/builds_controller.rb | 7 +++++
.../image_factory/templates_controller.rb | 14 +++++++++-
src/app/models/image.rb | 4 +-
src/app/views/image_factory/templates/_builds.haml | 25 ++++++++++++++-----
src/config/routes.rb | 2 +-
5 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/src/app/controllers/image_factory/builds_controller.rb b/src/app/controllers/image_factory/builds_controller.rb
index 01f05bd..6d335df 100644
--- a/src/app/controllers/image_factory/builds_controller.rb
+++ b/src/app/controllers/image_factory/builds_controller.rb
@@ -44,6 +44,13 @@ class ImageFactory::BuildsController < ApplicationController
render :action => 'new'
end
end
+
+ def upload_or_delete
+ @tpl = Template.find(params[:template_id])
+ # FIXME: add logic to upload image
+ # or delete image depending on which button was used
+ redirect_to image_factory_template_path(@tpl, :details_tab => 'builds')
+ end
def edit
# FIXME: is @tpl defined here? do we need check_permission here?
diff --git a/src/app/controllers/image_factory/templates_controller.rb b/src/app/controllers/image_factory/templates_controller.rb
index a38fe0d..901e7c9 100644
--- a/src/app/controllers/image_factory/templates_controller.rb
+++ b/src/app/controllers/image_factory/templates_controller.rb
@@ -196,20 +196,30 @@ class ImageFactory::TemplatesController < ApplicationController
def load_images(tpl)
@images_header = [
+ {:name => '', :sort_attr => 'select'},
{:name => 'ARCH', :sort_attr => 'templates.architecture'},
{:name => 'PROVIDER', :sort_attr => 'provider'},
{:name => 'STATUS', :sort_attr => 'status'},
{:name => 'UPLOADED?', :sort_attr => 'images.uploaded'},
]
-
@imaged_provider_types = {}
+ @targets_not_built = {}
+ @target_build_status = {}
+
+ Image.available_targets.each do |id, target|
+ @targets_not_built[id] = target
+ end
+
tpl.images.each do |img|
+ @target_build_status[img.target] = img.status
+ @targets_not_built.delete(img.target)
img.provider_images.each do |pimg|
@imaged_provider_types[pimg.provider_id] = img.target
end
end
+ @targets_not_built = @targets_not_built.invert
- @providers_not_uploaded = Provider.find_all_by_provider_type((a)imaged_provider_types.keys.uniq)
+ @providers_not_uploaded = Provider.find_all_by_provider_type((a)imaged_provider_types.values.uniq)
@providers_not_uploaded.each do |provider|
if @imaged_provider_types.has_key?(provider.id)
@providers_not_uploaded.delete(provider)
diff --git a/src/app/models/image.rb b/src/app/models/image.rb
index cfa15e4..dad94f3 100644
--- a/src/app/models/image.rb
+++ b/src/app/models/image.rb
@@ -83,7 +83,7 @@ class Image < ActiveRecord::Base
unless provider = Provider.find_by_target_with_account(target.id)
raise "There is no provider for '#{target.name}' type with valid account."
end
-
+
img = nil
Image.transaction do
img = Image.create!(
@@ -94,7 +94,7 @@ class Image < ActiveRecord::Base
)
ProviderImage.create!(
:image_id => img.id,
- :provider_id => provider
+ :provider_id => provider.id
)
end
return img
diff --git a/src/app/views/image_factory/templates/_builds.haml b/src/app/views/image_factory/templates/_builds.haml
index a9822f0..f1a98c8 100644
--- a/src/app/views/image_factory/templates/_builds.haml
+++ b/src/app/views/image_factory/templates/_builds.haml
@@ -3,11 +3,20 @@ Builds for
= @tpl.platform_version
, template "#{(a)tpl.name}"
-- form_tag :action => "" do
+- form_tag(image_factory_builds_path, { :action => 'create', :method => :post }) do
+ = hidden_field_tag :template_id, @tpl.id
+ New Build for
+ = select( "targets", "", options_for_select(@targets_not_built))
+ = submit_tag "Go", :name => "build"
+
+- form_tag(upload_or_delete_image_factory_builds_path, { :action => "destroy", :method => :post }) do
+ = hidden_field_tag :template_id, @tpl.id
/= restful_submit_tag "Cancel Job", :name => "job_details", :disabled => true, :class => "icon"
/= restful_submit_tag "Show Job Details", :name => "job_details", :disabled => true, :class => "icon"
/= restful_submit_tag "Show Job Log", :name => "job_log", :disabled => true, :class => "icon"
/= restful_submit_tag "Clear Job History", :name => "job_history", :disabled => true, :class => "icon"
+ = submit_tag "Upload", :name => "upload"
+ = submit_tag "Delete", :name => "delete"
%table
= sortable_table_header(@images_header)
@@ -19,13 +28,15 @@ Builds for
- @images.each do |img|
- img.provider_images.each do |pimg|
%tr
+ %td= check_box_tag 'selected[]', pimg.provider_id, @url_params[:select] == 'all', :id => "selected_#{pimg.provider_id}"
%td= img.template.architecture
%td= pimg.provider.nil? ? '' : pimg.provider.name
%td= img.status
%td= pimg.uploaded? ? 'yes' : 'no'
- - @providers_not_uploaded.each do |provider|
- %tr
- %td= @tpl.architecture
- %td= provider.name
- %td= img.status
- %td no
\ No newline at end of file
+ - @providers_not_uploaded.each do |provider|
+ %tr
+ %td= check_box_tag 'selected[]', provider.id, @url_params[:select] == 'all', :id => "selected_#{provider.id}"
+ %td= @tpl.architecture
+ %td= provider.name
+ %td= @target_build_status[provider.provider_type]
+ %td no
\ No newline at end of file
diff --git a/src/config/routes.rb b/src/config/routes.rb
index c936726..b64713f 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -45,7 +45,7 @@ ActionController::Routing::Routes.draw do |map|
r.resources :assemblies
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.resources :builds
+ r.resources :builds, :collection => { :upload_or_delete => :delete }
end
map.namespace 'admin' do |r|
--
1.7.4
12 years, 9 months
Changes for task 433 and 434
by Richard Su
I am resending my patches. Tomas helped me rebase them correctly. Thanks
Tomas. Can someone help with acking them?
There are two parts.
The first is for task 433.
An "UPLOADED?" column was added to the Builds template tab to indicate
if the build has been uploaded to the provider. If there are multiple providers
for the same target (provider type) then those will also appear in the table
with their uploaded status regardless of whether a build has been made for them.
They way to test this is create two providers for ec2 and trigger a build for
just one.
The second is for task 434 which adds an additional column to select
providers to upload an existing image. The hook to upload the image will need
to be done at a future sprint when the new image factory is ready.
It also contains a new form element to initiate a build. The select drop down
will only show targets that haven't been built. Try creating a mock provider
and you should see it appear in the select.
The html doesn't exactly match the mock ups. I would appreciate any
advice on how to get it there.
Thanks,
Richard
12 years, 9 months
[PATCH conductor] Delayed Job
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
Delayed_job is used for running background tasks (for now copying ssh key to
running instance). Because it runs as separate process we need to start it when
starting appliance.
Delayed_job package version 2.0.6 should be added to our rpm and can be
downloaded from koji: http://koji.fedoraproject.org/koji/taskinfo?taskID=2863673
---
aeolus-conductor.spec.in | 8 ++
conf/conductor-delayed_job | 72 ++++++++++++++++++++
src/Rakefile | 7 ++
src/config/environment.rb | 1 +
src/config/initializers/delayed_job.rb | 2 +
.../migrate/20110124103216_create_delayed_jobs.rb | 21 ++++++
src/script/delayed_job | 5 ++
7 files changed, 116 insertions(+), 0 deletions(-)
create mode 100755 conf/conductor-delayed_job
create mode 100644 src/config/initializers/delayed_job.rb
create mode 100644 src/db/migrate/20110124103216_create_delayed_jobs.rb
create mode 100755 src/script/delayed_job
diff --git a/aeolus-conductor.spec.in b/aeolus-conductor.spec.in
index 45bbe9f..7af22c1 100644
--- a/aeolus-conductor.spec.in
+++ b/aeolus-conductor.spec.in
@@ -33,6 +33,7 @@ Requires: rubygem(deltacloud-image-builder-agent)
Requires: rubygem(imagebuilder-console)
Requires: rubygem(rack-restful_submit)
Requires: rubygem(sunspot_rails)
+Requires: rubygem(delayed_job)
Requires: postgresql
Requires: postgresql-server
Requires: ruby-postgres
@@ -123,6 +124,7 @@ mv %{buildroot}/%{app_root}/doc %{buildroot}/%{app_root}/test %{buildroot}/%{doc
%{__cp} conf/conductor-dbomatic %{buildroot}%{_initrddir}
%{__cp} conf/conductor-condor_refreshd %{buildroot}%{_initrddir}
%{__cp} conf/conductor-image_builder_service %{buildroot}%{_initrddir}
+%{__cp} conf/conductor-delayed_job %{buildroot}%{_initrddir}
%{__cp} conf/aeolus-conductor-httpd.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/aeolus-conductor.conf
%{__cp} conf/aeolus-conductor.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/aeolus-conductor
%{__cp} conf/aeolus-conductor.sysconf %{buildroot}%{_sysconfdir}/sysconfig/aeolus-conductor
@@ -153,6 +155,7 @@ touch %{buildroot}%{_localstatedir}/log/%{name}/dbomatic.log
touch %{buildroot}%{_localstatedir}/run/%{name}/event_log_position
touch %{buildroot}%{_localstatedir}/log/%{name}/condor_refreshd.log
touch %{buildroot}%{_localstatedir}/log/%{name}/image_builder_service.log
+touch %{buildroot}%{app_root}/log/delayed_job.log
# remove the files not needed for the installation
%{__rm} -f %{buildroot}%{app_root}/vendor/plugins/will_paginate/.gitignore
@@ -186,6 +189,7 @@ getent passwd aeolus >/dev/null || \
/sbin/chkconfig --add conductor-dbomatic
/sbin/chkconfig --add conductor-condor_refreshd
/sbin/chkconfig --add conductor-image_builder_service
+/sbin/chkconfig --add conductor-delayed_job
%preun daemons
if [ $1 = 0 ]; then
@@ -197,6 +201,8 @@ if [ $1 = 0 ]; then
/sbin/chkconfig --del conductor-condor_refreshd
/sbin/service conductor-image_builder_service stop > /dev/null 2>&1
/sbin/chkconfig --del conductor-image_builder_service
+/sbin/service conductor-delayed_job stop > /dev/null 2>&1
+/sbin/chkconfig --del conductor-delayed_job
fi
%files
@@ -217,6 +223,7 @@ fi
%{_initrddir}/conductor-dbomatic
%{_initrddir}/conductor-condor_refreshd
%{_initrddir}/conductor-image_builder_service
+%{_initrddir}/conductor-delayed_job
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/aeolus-conductor
%config(noreplace) %{_sysconfdir}/sysconfig/conductor-rails
@@ -224,6 +231,7 @@ fi
%attr(-, aeolus, aeolus) %{_localstatedir}/lib/%{name}
%attr(-, aeolus, aeolus) %{_localstatedir}/run/%{name}
%attr(-, aeolus, aeolus) %{_localstatedir}/log/%{name}
+%attr(-, aeolus, aeolus) %{app_root}/log/delayed_job.log
%doc AUTHORS COPYING
%files doc
diff --git a/conf/conductor-delayed_job b/conf/conductor-delayed_job
new file mode 100755
index 0000000..b0fdc2f
--- /dev/null
+++ b/conf/conductor-delayed_job
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+#
+# conductor-delayed_job startup script for conductor-delayed_job
+#
+# chkconfig: - 99 01
+# description: conductor-delayed_job is service for running conductor
+# background jobs
+
+[ -r /etc/sysconfig/conductor-rails ] && . /etc/sysconfig/conductor-rails
+
+[ -r /etc/sysconfig/aeolus-conductor ] && . /etc/sysconfig/aeolus-conductor
+
+RAILS_ENV="${RAILS_ENV:-production}"
+CONDUCTOR_DIR="${CONDUCTOR_DIR:-/usr/share/aeolus-conductor}"
+AEOLUS_USER="${AEOLUS_USER:-aeolus}"
+DJOB_LOCKFILE="${DJOB_LOCKFILE:-/var/lock/subsys/conductor-delayed_job}"
+DJOB_PIDFILE="${DJOB_PIDFILE:-/var/run/aeolus-conductor/}"
+
+DJOB_PATH=$CONDUCTOR_DIR/script/
+DJOB_PROG=delayed_job
+
+. /etc/init.d/functions
+
+start() {
+ echo -n "Starting conductor-delayed_job: "
+
+ daemon --user=$AEOLUS_USER $DJOB_PATH/$DJOB_PROG start --pid-dir=$DJOB_PIDFILE
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ] && touch $DJOB_LOCKFILE ; then
+ echo_success
+ echo
+ else
+ echo_failure
+ echo
+ fi
+}
+
+stop() {
+ echo -n "Shutting down conductor-delayed_job: "
+ $DJOB_PATH/$DJOB_PROG stop --pid-dir=$DJOB_PIDFILE
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ] && rm -f $DJOB_LOCKFILE ; then
+ echo_success
+ echo
+ else
+ echo_failure
+ echo
+ fi
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ force-reload)
+ restart
+ ;;
+ *)
+ echo "Usage: conductor-delayed_job {start|stop|restart}"
+ exit 1
+ ;;
+esac
+
+exit $RETVAL
diff --git a/src/Rakefile b/src/Rakefile
index f2d8d21..ad7f788 100644
--- a/src/Rakefile
+++ b/src/Rakefile
@@ -12,4 +12,11 @@ begin
rescue LoadError
end
+begin
+ #gem 'delayed_job', :version => '~>2.0.4'
+ require 'delayed/tasks'
+rescue LoadError
+ STDERR.puts "Run `rake gems:install` to install delayed_job"
+end
+
require 'tasks/rails'
diff --git a/src/config/environment.rb b/src/config/environment.rb
index 986cfe4..cedcb32 100644
--- a/src/config/environment.rb
+++ b/src/config/environment.rb
@@ -54,6 +54,7 @@ Rails::Initializer.run do |config|
config.gem "rb-inotify"
config.gem 'rack-restful_submit', :version => '1.1.2'
config.gem 'sunspot_rails', :lib => 'sunspot/rails'
+ config.gem 'delayed_job', :version => '~>2.0.4'
config.middleware.swap Rack::MethodOverride, 'Rack::RestfulSubmit'
diff --git a/src/config/initializers/delayed_job.rb b/src/config/initializers/delayed_job.rb
new file mode 100644
index 0000000..a8684b4
--- /dev/null
+++ b/src/config/initializers/delayed_job.rb
@@ -0,0 +1,2 @@
+Delayed::Worker.backend = :active_record
+Delayed::Worker.max_attempts = 1
diff --git a/src/db/migrate/20110124103216_create_delayed_jobs.rb b/src/db/migrate/20110124103216_create_delayed_jobs.rb
new file mode 100644
index 0000000..943ff9b
--- /dev/null
+++ b/src/db/migrate/20110124103216_create_delayed_jobs.rb
@@ -0,0 +1,21 @@
+class CreateDelayedJobs < ActiveRecord::Migration
+ def self.up
+ create_table :delayed_jobs, :force => true do |table|
+ table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
+ table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
+ table.text :handler # YAML-encoded string of the object that will do work
+ table.text :last_error # reason for last failure (See Note below)
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
+ table.datetime :locked_at # Set when a client is working on this object
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
+ table.string :locked_by # Who is working on this object (if locked)
+ table.timestamps
+ end
+
+ add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
+ end
+
+ def self.down
+ drop_table :delayed_jobs
+ end
+end
diff --git a/src/script/delayed_job b/src/script/delayed_job
new file mode 100755
index 0000000..edf1959
--- /dev/null
+++ b/src/script/delayed_job
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
+require 'delayed/command'
+Delayed::Command.new(ARGV).daemonize
--
1.7.4
12 years, 9 months
[PATCH conductor] delayed_job init script fix
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
status cmd was missing, so service wasn't stop on aeolus-cleanup
---
conf/conductor-delayed_job | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/conf/conductor-delayed_job b/conf/conductor-delayed_job
index b0fdc2f..9b7f517 100755
--- a/conf/conductor-delayed_job
+++ b/conf/conductor-delayed_job
@@ -15,17 +15,18 @@ RAILS_ENV="${RAILS_ENV:-production}"
CONDUCTOR_DIR="${CONDUCTOR_DIR:-/usr/share/aeolus-conductor}"
AEOLUS_USER="${AEOLUS_USER:-aeolus}"
DJOB_LOCKFILE="${DJOB_LOCKFILE:-/var/lock/subsys/conductor-delayed_job}"
-DJOB_PIDFILE="${DJOB_PIDFILE:-/var/run/aeolus-conductor/}"
+DJOB_PIDDIR="${DJOB_PIDDIR:-/var/run/aeolus-conductor/}"
DJOB_PATH=$CONDUCTOR_DIR/script/
DJOB_PROG=delayed_job
+DJOB_PIDFILE=$DJOB_PIDDIR/$DJOB_PROG.pid
. /etc/init.d/functions
start() {
echo -n "Starting conductor-delayed_job: "
- daemon --user=$AEOLUS_USER $DJOB_PATH/$DJOB_PROG start --pid-dir=$DJOB_PIDFILE
+ daemon --user=$AEOLUS_USER $DJOB_PATH/$DJOB_PROG start --pid-dir=$DJOB_PIDDIR
RETVAL=$?
if [ $RETVAL -eq 0 ] && touch $DJOB_LOCKFILE ; then
echo_success
@@ -38,7 +39,7 @@ start() {
stop() {
echo -n "Shutting down conductor-delayed_job: "
- $DJOB_PATH/$DJOB_PROG stop --pid-dir=$DJOB_PIDFILE
+ $DJOB_PATH/$DJOB_PROG stop --pid-dir=$DJOB_PIDDIR
RETVAL=$?
if [ $RETVAL -eq 0 ] && rm -f $DJOB_LOCKFILE ; then
echo_success
@@ -60,11 +61,15 @@ case "$1" in
stop
start
;;
+ status)
+ status -p $DJOB_PIDFILE $DJOB_PROG
+ RETVAL=$?
+ ;;
force-reload)
restart
;;
*)
- echo "Usage: conductor-delayed_job {start|stop|restart}"
+ echo "Usage: conductor-delayed_job {start|stop|restart|status}"
exit 1
;;
esac
--
1.7.4
12 years, 9 months
Small fixes
by Tomas Sedovic
These patches fix two small glitches that were introduced recently.
12 years, 9 months