[refs #847] remove old core code
This commit is contained in:
parent
fe516b1ad2
commit
0d9c095cbd
|
@ -93,13 +93,11 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
end
|
||||
|
||||
def cancel
|
||||
if @build_list.cancel
|
||||
notice = @build_list.new_core? ?
|
||||
t('layout.build_lists.will_be_canceled') :
|
||||
t('layout.build_lists.cancel_success')
|
||||
else
|
||||
notice = t('layout.build_lists.cancel_fail')
|
||||
end
|
||||
notice = if @build_list.cancel
|
||||
t('layout.build_lists.will_be_canceled')
|
||||
else
|
||||
t('layout.build_lists.cancel_fail')
|
||||
end
|
||||
redirect_to :back, :notice => notice
|
||||
end
|
||||
|
||||
|
@ -178,11 +176,12 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
@build_list = BuildList.find_by_bs_id!(params[:id])
|
||||
end
|
||||
|
||||
def authenticate_build_service!
|
||||
if request.remote_ip != APP_CONFIG['build_server_ip']
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
end
|
||||
# What is it?
|
||||
#def authenticate_build_service!
|
||||
# if request.remote_ip != APP_CONFIG['build_server_ip']
|
||||
# render :nothing => true, :status => 403
|
||||
# end
|
||||
#end
|
||||
|
||||
def publish
|
||||
@build_list.update_type = params[:build_list][:update_type] if params[:build_list][:update_type].present?
|
||||
|
@ -222,5 +221,4 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
redirect_to :back, :notice => t('layout.build_lists.reject_publish_fail')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -39,7 +39,6 @@ class BuildList < ActiveRecord::Base
|
|||
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_include_repos')) unless build_for_platform.repository_ids.include? ir.to_i
|
||||
}
|
||||
}
|
||||
|
||||
validate lambda {
|
||||
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_project')) unless save_to_repository.projects.exists?(project_id)
|
||||
}
|
||||
|
@ -128,7 +127,6 @@ class BuildList < ActiveRecord::Base
|
|||
serialize :results, Array
|
||||
|
||||
after_commit :place_build
|
||||
after_destroy :delete_container
|
||||
|
||||
state_machine :status, :initial => :waiting_for_response do
|
||||
|
||||
|
@ -148,8 +146,7 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
after_transition :on => :published, :do => [:set_version_and_tag, :actualize_packages]
|
||||
after_transition :on => :cancel, :do => [:cancel_job],
|
||||
:if => lambda { |build_list| build_list.new_core? }
|
||||
after_transition :on => :cancel, :do => :cancel_job
|
||||
|
||||
after_transition :on => [:published, :fail_publish, :build_error], :do => :notify_users
|
||||
after_transition :on => :build_success, :do => :notify_users,
|
||||
|
@ -181,20 +178,13 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
event :cancel do
|
||||
transition [:build_pending, :platform_pending] => :build_canceled, :if => lambda { |build_list|
|
||||
!build_list.new_core? && build_list.can_cancel? && BuildServer.delete_build_list(build_list.bs_id) == BuildServer::SUCCESS
|
||||
}
|
||||
transition [:build_pending, :build_started] => :build_canceling, :if => lambda { |build_list|
|
||||
build_list.new_core?
|
||||
}
|
||||
transition [:build_pending, :build_started] => :build_canceling
|
||||
end
|
||||
|
||||
# :build_canceling => :build_canceled - canceling from UI
|
||||
# :build_started => :build_canceled - canceling from worker by time-out (time_living has been expired)
|
||||
event :build_canceled do
|
||||
transition [:build_canceling, :build_started] => :build_canceled, :if => lambda { |build_list|
|
||||
build_list.new_core?
|
||||
}
|
||||
transition [:build_canceling, :build_started] => :build_canceled
|
||||
end
|
||||
|
||||
event :published do
|
||||
|
@ -206,12 +196,7 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
event :publish do
|
||||
transition [:success, :failed_publish] => :build_publish, :if => lambda { |build_list|
|
||||
!build_list.new_core? && BuildServer.publish_container(build_list.bs_id) == BuildServer::SUCCESS
|
||||
}
|
||||
transition [:success, :failed_publish] => :build_publish, :if => lambda { |build_list|
|
||||
build_list.new_core?
|
||||
}
|
||||
transition [:success, :failed_publish] => :build_publish
|
||||
transition [:success, :failed_publish] => :failed_publish
|
||||
end
|
||||
|
||||
|
@ -253,11 +238,7 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
#TODO: Share this checking on product owner.
|
||||
def can_cancel?
|
||||
if new_core?
|
||||
build_started? || build_pending?
|
||||
else
|
||||
[BUILD_PENDING, BuildServer::PLATFORM_PENDING].include?(status) && bs_id
|
||||
end
|
||||
build_started? || build_pending?
|
||||
end
|
||||
|
||||
def can_publish?
|
||||
|
@ -269,41 +250,12 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def add_to_queue
|
||||
if new_core?
|
||||
# TODO: Investigate: why 2 tasks will be created without checking @state
|
||||
unless @status
|
||||
add_job_to_abf_worker_queue
|
||||
update_column(:bs_id, id)
|
||||
end
|
||||
@status ||= BUILD_PENDING
|
||||
else
|
||||
# XML-RPC params:
|
||||
# - project_name
|
||||
# - project_version
|
||||
# - plname
|
||||
# - arch
|
||||
# - bplname
|
||||
# - update_type
|
||||
# - build_requires
|
||||
# - id_web
|
||||
# - include_repos
|
||||
# - priority
|
||||
# - git_project_address
|
||||
@status ||= BuildServer.add_build_list(
|
||||
project.name,
|
||||
project_version,
|
||||
save_to_platform.name,
|
||||
arch.name,
|
||||
(save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name),
|
||||
update_type,
|
||||
false,
|
||||
id,
|
||||
include_repos,
|
||||
priority,
|
||||
project.git_project_address(user)
|
||||
)
|
||||
# TODO: Investigate: why 2 tasks will be created without checking @state
|
||||
unless @status
|
||||
add_job_to_abf_worker_queue
|
||||
update_column(:bs_id, id)
|
||||
end
|
||||
@status
|
||||
@status ||= BUILD_PENDING
|
||||
end
|
||||
|
||||
def self.human_status(status)
|
||||
|
@ -459,14 +411,6 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
end # notify_users
|
||||
|
||||
def delete_container
|
||||
if can_cancel?
|
||||
BuildServer.delete_build_list bs_id
|
||||
else
|
||||
BuildServer.delete_container bs_id if bs_id # prevent error if bs_id does not set
|
||||
end
|
||||
end
|
||||
|
||||
def build_package(pkg_hash, package_type, prj)
|
||||
packages.create(pkg_hash) do |p|
|
||||
p.project = prj
|
||||
|
@ -475,5 +419,4 @@ class BuildList < ActiveRecord::Base
|
|||
yield p
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -64,7 +64,6 @@ class ProductBuildList < ActiveRecord::Base
|
|||
|
||||
after_create :add_job_to_abf_worker_queue
|
||||
before_destroy :can_destroy?
|
||||
after_destroy :xml_delete_iso_container
|
||||
|
||||
state_machine :status, :initial => :build_pending do
|
||||
|
||||
|
@ -75,7 +74,7 @@ class ProductBuildList < ActiveRecord::Base
|
|||
event :cancel do
|
||||
transition [:build_pending, :build_started] => :build_canceling
|
||||
end
|
||||
after_transition :on => :cancel, :do => [:cancel_job]
|
||||
after_transition :on => :cancel, :do => :cancel_job
|
||||
|
||||
# :build_canceling => :build_canceled - canceling from UI
|
||||
# :build_started => :build_canceled - canceling from worker by time-out (time_living has been expired)
|
||||
|
@ -162,18 +161,4 @@ class ProductBuildList < ActiveRecord::Base
|
|||
:user => {:uname => user.try(:uname), :email => user.try(:email)}
|
||||
}
|
||||
end
|
||||
|
||||
def xml_delete_iso_container
|
||||
# TODO: write new worker for delete
|
||||
if project
|
||||
raise "Failed to destroy product_build_list #{id} inside platform #{product.platform.name} (Not Implemented)."
|
||||
else
|
||||
result = ProductBuilder.delete_iso_container self
|
||||
if result == ProductBuilder::SUCCESS
|
||||
return true
|
||||
else
|
||||
raise "Failed to destroy product_build_list #{id} inside platform #{product.platform.name} with code #{result}."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -175,24 +175,6 @@ class Project < ActiveRecord::Base
|
|||
"%02d:%02d" % [average_build_time / 3600, average_build_time % 3600 / 60]
|
||||
end
|
||||
|
||||
def xml_rpc_create(repository)
|
||||
result = BuildServer.create_project name, repository.platform.name, repository.name, path
|
||||
if result == BuildServer::SUCCESS
|
||||
return true
|
||||
else
|
||||
raise "Failed to create project #{name} (repo #{repository.name}) inside platform #{repository.platform.name} in path #{path} with code #{result}."
|
||||
end
|
||||
end
|
||||
|
||||
def xml_rpc_destroy(repository)
|
||||
result = BuildServer.delete_project name, repository.platform.name
|
||||
if result == BuildServer::SUCCESS
|
||||
return true
|
||||
else
|
||||
raise "Failed to delete repository #{name} (repo main) inside platform #{owner.uname}_personal with code #{result}."
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_project_from_repository(repository)
|
||||
AbfWorker::BuildListsPublishTaskManager.destroy_project_from_repository self, repository
|
||||
end
|
||||
|
|
|
@ -40,13 +40,6 @@ set :workers_count, 4
|
|||
require './lib/recipes/resque'
|
||||
|
||||
namespace :deploy do
|
||||
task :stub_xml_rpc do
|
||||
path = File.join(release_path, 'config', 'environment.rb')
|
||||
code = %Q{\nrequire 'stub_xml_rpc'\n}
|
||||
puts "Stub XML RPC"
|
||||
run %Q{echo "#{code}" >> #{path}}
|
||||
end
|
||||
|
||||
task :symlink_all, :roles => :app do
|
||||
run "mkdir -p #{fetch :shared_path}/config"
|
||||
|
||||
|
|
|
@ -41,5 +41,3 @@ Rosa::Application.configure do
|
|||
# Log the query plan for queries taking more than this (works with SQLite, MySQL, and PostgreSQL)
|
||||
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
end
|
||||
|
||||
require 'stub_xml_rpc'
|
|
@ -65,5 +65,3 @@ Rosa::Application.configure do
|
|||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js)
|
||||
end
|
||||
|
||||
# require 'stub_xml_rpc'
|
||||
|
|
|
@ -42,5 +42,3 @@ Rosa::Application.configure do
|
|||
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
||||
config.assets.allow_debugging = true
|
||||
end
|
||||
|
||||
require 'stub_xml_rpc' # TODO stub XML calls through stubbers
|
||||
|
|
|
@ -11,7 +11,6 @@ en:
|
|||
'devise/sessions_controller': 'User Authentication'
|
||||
'devise/passwords_controller': 'Password recovery'
|
||||
'users/omniauth_callbacks_controller': 'External users authentication'
|
||||
rpc_controller: 'XML RPC'
|
||||
private_users_controller: 'access to private repositories'
|
||||
personal_repositories_controller: 'Personal repositories management'
|
||||
actions:
|
||||
|
|
|
@ -11,7 +11,6 @@ ru:
|
|||
'devise/sessions_controller': 'Аутентификация пользователей'
|
||||
'devise/passwords_controller': 'Восстановление пароля'
|
||||
'users/omniauth_callbacks_controller': 'Внешняя аутентификация пользователей'
|
||||
rpc_controller: 'XML RPC'
|
||||
private_users_controller: 'Доступ к приватным репозиториям'
|
||||
personal_repositories_controller: 'Управление персональными репозиториями'
|
||||
actions:
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
require 'xmlrpc/client'
|
||||
|
||||
class BuildServer
|
||||
|
||||
SUCCESS = 0
|
||||
ERROR = 1
|
||||
|
||||
|
@ -18,98 +15,4 @@ class BuildServer
|
|||
DEPENDENCIES_ERROR = 555
|
||||
BUILD_ERROR = 666
|
||||
BUILD_STARTED = 3000
|
||||
|
||||
def self.client
|
||||
@@client ||= XMLRPC::Client.new3('host' => APP_CONFIG['build_server_ip'], 'port' => APP_CONFIG['build_server_port'], 'path' => APP_CONFIG['build_server_path'])
|
||||
end
|
||||
|
||||
|
||||
def self.add_platform name, platforms_root_folder, distrib_type, repos = {:src => [], :rpm => []}
|
||||
self.client.call('add_platform', name, platforms_root_folder, repos, distrib_type)
|
||||
end
|
||||
|
||||
def self.delete_platform name
|
||||
self.client.call('delete_platform', name)
|
||||
rescue Timeout::Error => e # TODO remove this when core will be ready
|
||||
0
|
||||
end
|
||||
|
||||
def self.clone_platform new_name, old_name, new_root_folder
|
||||
self.client.call('clone_platform', new_name, old_name, new_root_folder)
|
||||
rescue Timeout::Error => e # TODO remove this when core will be ready
|
||||
0
|
||||
end
|
||||
|
||||
def self.create_repo name, platform_name
|
||||
self.client.call('create_repository', name, platform_name)
|
||||
end
|
||||
|
||||
def self.delete_repo name, platform_name
|
||||
self.client.call('delete_repository', name, platform_name)
|
||||
rescue Timeout::Error => e # TODO remove this when core will be ready
|
||||
0
|
||||
end
|
||||
|
||||
def self.clone_repo new_name, old_name, new_platform_name
|
||||
self.client.call('clone_repo', new_name, old_name, new_platform_name)
|
||||
rescue Timeout::Error => e # TODO remove this when core will be ready
|
||||
0
|
||||
end
|
||||
|
||||
|
||||
def self.publish_container container_id
|
||||
self.client.call('publish_container', container_id)
|
||||
end
|
||||
|
||||
def self.delete_container container_id
|
||||
self.client.call('delete_container', container_id)
|
||||
end
|
||||
|
||||
def self.create_project name, platform_name, repo_name, git_project_path
|
||||
self.client.call('create_project', name, platform_name, repo_name, git_project_path)
|
||||
end
|
||||
|
||||
def self.delete_project name, platform_name
|
||||
self.client.call('delete_project', name, platform_name)
|
||||
end
|
||||
|
||||
def self.add_to_repo name, repo_name
|
||||
self.client.call('add_to_repo', name, repo_name)
|
||||
end
|
||||
|
||||
def self.add_build_list project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_path
|
||||
include_repos_hash = {}.tap do |h|
|
||||
include_repos.each do |r|
|
||||
repo = Repository.find r
|
||||
h[repo.name] = repo.platform.public_downloads_url(nil, arch, repo.name)
|
||||
end
|
||||
end
|
||||
# raise include_repos_hash.inspect
|
||||
self.client.call('add_build_list', project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos_hash, priority, git_project_path)
|
||||
end
|
||||
|
||||
def self.delete_build_list idlist
|
||||
self.client.call('delete_build_list', idlist)
|
||||
end
|
||||
|
||||
def self.get_status
|
||||
self.client.call('get_status')
|
||||
end
|
||||
|
||||
def self.freeze platform_name
|
||||
self.client.call('freeze_platform', platform_name)
|
||||
end
|
||||
|
||||
# Repository key pair calls
|
||||
def self.import_gpg_key_pair key_pub, key_secret
|
||||
self.client.call('import_gpg_key_pair', key_pub, key_secret)
|
||||
end
|
||||
|
||||
def self.set_repository_key platform, repository, key_id
|
||||
self.client.call('set_repository_key', platform, repository, key_id)
|
||||
end
|
||||
|
||||
def self.rm_repository_key platform, repository
|
||||
self.client.call('rm_repository_key', platform, repository)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
require 'xmlrpc/client'
|
||||
|
||||
class ProductBuilder
|
||||
SUCCESS = 0
|
||||
ERROR = 1
|
||||
|
||||
def self.client(distrib_type)
|
||||
@@client ||= XMLRPC::Client.new3(:host => APP_CONFIG['product_builder_ip'][distrib_type], :port => APP_CONFIG['product_builder_port'], :path => APP_CONFIG['product_builder_path'])
|
||||
end
|
||||
|
||||
def self.create_product pbl # product_build_list
|
||||
self.client(pbl.product.platform.distrib_type).
|
||||
call('create_product', pbl.id.to_s, pbl.product.platform.name, pbl.product.ks, pbl.product.menu, pbl.product.build_script,
|
||||
pbl.product.counter, [], pbl.product.tar.exists? ? "#{pbl.base_url}#{pbl.product.tar.url}" : '')
|
||||
end
|
||||
|
||||
def self.delete_iso_container pbl # product_build_list
|
||||
self.client(pbl.product.platform.distrib_type).call('delete_iso_container', pbl.product.platform.name, pbl.id.to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
require 'xmlrpc/client'
|
||||
module XMLRPC
|
||||
class Client
|
||||
def call(*args)
|
||||
# raise args.inspect
|
||||
case
|
||||
when args.first == 'get_status'
|
||||
{'client_count' => 1, 'count_new_task' => 2, 'count_build_task' => 3}
|
||||
else; 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue