create container for BuildList

This commit is contained in:
Vokhmin Alexey V 2013-01-25 21:24:46 +04:00
parent fab38fbaba
commit f4c3d23d7c
9 changed files with 62 additions and 8 deletions

View File

@ -5,7 +5,7 @@ class Projects::BuildListsController < Projects::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :search, :log] if APP_CONFIG['anonymous_access'] skip_before_filter :authenticate_user!, :only => [:show, :index, :search, :log] if APP_CONFIG['anonymous_access']
before_filter :find_build_list, :only => [:show, :publish, :cancel, :update, :log] before_filter :find_build_list, :only => [:show, :publish, :cancel, :update, :log, :create_container]
load_and_authorize_resource :project, :only => NESTED_ACTIONS load_and_authorize_resource :project, :only => NESTED_ACTIONS
load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true
@ -89,6 +89,11 @@ class Projects::BuildListsController < Projects::BaseController
end end
end end
def create_container
AbfWorker::BuildListsPublishTaskManager.create_container_for @build_list
redirect_to :back, :notice => t('layout.build_lists.container_will_be_created')
end
def cancel def cancel
notice = if @build_list.cancel notice = if @build_list.cancel
t('layout.build_lists.will_be_canceled') t('layout.build_lists.will_be_canceled')

View File

@ -77,11 +77,7 @@ module BuildListsHelper
end end
def container_url def container_url
if @build_list.new_core? "http://#{request.host_with_port}/downloads#{@build_list.container_path}".html_safe
@build_list.container_path
else
"http://#{request.host_with_port}/downloads#{@build_list.container_path}".html_safe
end
end end
def build_list_log_url(log_type) def build_list_log_url(log_type)

View File

@ -84,7 +84,7 @@ class Ability
can(:publish, BuildList) do |build_list| can(:publish, BuildList) do |build_list|
build_list.save_to_repository.publish_without_qa ? can?(:write, build_list.project) : local_admin?(build_list.save_to_platform) build_list.save_to_repository.publish_without_qa ? can?(:write, build_list.project) : local_admin?(build_list.save_to_platform)
end end
can(:reject_publish, BuildList) do |build_list| can([:reject_publish, :create_container], BuildList) do |build_list|
local_admin?(build_list.save_to_platform) local_admin?(build_list.save_to_platform)
end end
can(:cancel, BuildList) {|build_list| can?(:write, build_list.project)} can(:cancel, BuildList) {|build_list| can?(:write, build_list.project)}

View File

@ -14,6 +14,8 @@
[@build_list.save_to_platform, @build_list.save_to_repository])] [@build_list.save_to_platform, @build_list.save_to_repository])]
- elsif @build_list.container_path.present? - elsif @build_list.container_path.present?
= link_to container_url, container_url = link_to container_url, container_url
- elsif @build_list.container_path == ''
= t("layout.build_lists.creating")
.both .both
.leftlist= t("activerecord.attributes.build_list.bs_id") .leftlist= t("activerecord.attributes.build_list.bs_id")
@ -89,6 +91,9 @@
- if @build_list.can_cancel? && can?(:cancel, @build_list) - if @build_list.can_cancel? && can?(:cancel, @build_list)
= link_to t("layout.build_lists.cancel"), cancel_build_list_path(@build_list), = link_to t("layout.build_lists.cancel"), cancel_build_list_path(@build_list),
:method => :put, :confirm => t("layout.confirm"), :class => 'button' :method => :put, :confirm => t("layout.confirm"), :class => 'button'
- if @build_list.success? && can?(:create_container, @build_list)
= link_to t("layout.build_lists.create_container"), create_container_build_list_path(@build_list),
:method => :put, :confirm => t("layout.confirm"), :class => 'button'
- if @build_list.can_publish? && @build_list.save_to_platform.released && @build_list.advisory.nil? && can?(:publish, @build_list) - if @build_list.can_publish? && @build_list.save_to_platform.released && @build_list.advisory.nil? && can?(:publish, @build_list)
#advisory_block #advisory_block

View File

@ -47,6 +47,7 @@ en:
layout: layout:
build_lists: build_lists:
create_container: Create container
platform_deleted: platform has been deleted platform_deleted: platform has been deleted
filter_header: Filter filter_header: Filter
current: Curent current: Curent
@ -64,6 +65,8 @@ en:
cancel: Cancel build cancel: Cancel build
cancel_success: 'Build canceled' cancel_success: 'Build canceled'
will_be_canceled: 'Build will be canceled...' will_be_canceled: 'Build will be canceled...'
container_will_be_created: 'Container will be created...'
creating: 'creating...'
publish_success: 'Build published' publish_success: 'Build published'
cancel_fail: 'Errors during build cancelation!' cancel_fail: 'Errors during build cancelation!'
publish_fail: 'Errors during build publishing!' publish_fail: 'Errors during build publishing!'

View File

@ -46,6 +46,7 @@ ru:
layout: layout:
build_lists: build_lists:
create_container: Создать контейнер
platform_deleted: платформа была удалена platform_deleted: платформа была удалена
filter_header: Фильтр filter_header: Фильтр
current: Текущие current: Текущие
@ -62,6 +63,8 @@ ru:
show: Просмотр show: Просмотр
cancel: Отменить сборку cancel: Отменить сборку
will_be_canceled: 'Сборка будет отменена...' will_be_canceled: 'Сборка будет отменена...'
container_will_be_created: 'Контейнер будет создан...'
creating: 'создается...'
cancel_success: 'Сборка отменена.' cancel_success: 'Сборка отменена.'
cancel_fail: 'При отмене сборки произошла ошибка!' cancel_fail: 'При отмене сборки произошла ошибка!'
publish_success: 'Сборка поставлена в очередь на публикацию.' publish_success: 'Сборка поставлена в очередь на публикацию.'

View File

@ -210,6 +210,7 @@ Rosa::Application.routes.draw do
resources :build_lists, :only => [:index, :show, :update] do resources :build_lists, :only => [:index, :show, :update] do
member do member do
put :cancel put :cancel
put :create_container
get :log get :log
end end
collection { post :search } collection { post :search }

View File

@ -65,6 +65,42 @@ module AbfWorker
def redis def redis
Resque.redis Resque.redis
end end
def create_container_for(build_list)
platform_path = "#{build_list.save_to_platform.path}/container/#{build_list.id}"
return if File.directory?(platform_path)
system "mkdir -p #{platform_path}"
build_list.update_attributes(:container_path => '')
packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}}
packages[:sources] = build_list.packages.by_package_type('source').pluck(:sha1).compact
packages[:binaries][build_list.arch.name.to_sym] = build_list.packages.by_package_type('binary').pluck(:sha1).compact
Resque.push(
'publish_worker_default',
'class' => 'AbfWorker::PublishWorkerDefault',
'args' => [{
:id => build_list.id,
:arch => build_list.arch.name,
:distrib_type => build_list.build_for_platform.distrib_type,
:platform => {
:platform_path => platform_path,
:released => build_list.save_to_platform.released
},
:repository => {
:name => build_list.save_to_repository.name,
:id => build_list.save_to_repository.id
},
:type => :publish,
:time_living => 9600 # 160 min
:packages => packages,
:old_packages => {:sources => [], :binaries => {:x86_64 => [], :i586 => []}},
:build_list_ids => [build_list.id],
:projects_for_cleanup => [],
:extra => {:create_container => true}
})]
)
end
end end
private private

View File

@ -9,7 +9,12 @@ module AbfWorker
if options['type'] == 'resign' if options['type'] == 'resign'
AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id'] AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id']
else else
update_rpm_builds options, status if options['extra']['create_container'] # Container has been created
bl = BuildList.find(options['id'])
bl.update_attributes(:container_path => "/#{bl.save_to_platform.name}/container/#{bl.id}")
else
update_rpm_builds options, status
end
end end
end end