Create directory for platform before clone. Fix created directory permissions. Increase timeout during XML RPC clone. Switch off cascade XML RPC requests during platform destroy. Refs #207

This commit is contained in:
Pavel Chipiga 2012-02-23 00:57:43 +02:00 committed by Vladimir Sharshov
parent 9015b971aa
commit 07093c0d1d
5 changed files with 19 additions and 4 deletions

View File

@ -18,6 +18,7 @@ class Platform < ActiveRecord::Base
validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ }
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
before_create :create_directory, :if => lambda {Thread.current[:skip]} # TODO remove this when core will be ready
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
before_destroy :xml_rpc_destroy
# before_update :check_freezing
@ -131,9 +132,13 @@ class Platform < ActiveRecord::Base
end
end
def create_directory
system("sudo mkdir -p -m 0777 #{path}")
end
def mount_directory_for_rsync
# umount_directory_for_rsync # TODO ignore errors
system("sudo mkdir -p #{mount_path}")
system("sudo mkdir -p -m 0777 #{mount_path}")
system("sudo mount --bind #{path} #{mount_path}")
Arch.all.each do |arch|
str = "country=Russian Federation,city=Moscow,latitude=52.18,longitude=48.88,bw=1GB,version=2011,arch=#{arch.name},type=distrib,url=#{public_downloads_url}\n"
@ -153,6 +158,10 @@ class Platform < ActiveRecord::Base
end
end
def destroy
with_skip {super} # avoid cascade XML RPC requests
end
protected
def build_path(dir)

View File

@ -6,7 +6,7 @@ class ProjectToRepository < ActiveRecord::Base
delegate :path, :to => :project
after_create lambda { project.xml_rpc_create(repository) }, :unless => lambda {Thread.current[:skip]}
after_destroy lambda { project.xml_rpc_destroy(repository) }
after_destroy lambda { project.xml_rpc_destroy(repository) }, :unless => lambda {Thread.current[:skip]}
# after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? }
validate :one_project_in_platform_repositories

View File

@ -11,7 +11,7 @@ class Repository < ActiveRecord::Base
scope :recent, order("name ASC")
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
before_destroy :xml_rpc_destroy
before_destroy :xml_rpc_destroy, :unless => lambda {Thread.current[:skip]}
attr_accessible :description, :name

View File

@ -49,10 +49,12 @@ class BuildServer
end
def self.clone_repo new_name, old_name, new_platform_name
tmp = self.client.timeout # TODO remove this when core will be ready
self.client.timeout = 30.minutes
self.client.call('clone_repo', new_name, old_name, new_platform_name)
self.client.timeout = tmp
end
def self.publish_container container_id
self.client.call('publish_container', container_id)
end

View File

@ -5,6 +5,10 @@ module Modules
extend ActiveSupport::Concern
included do
def create_directory
true
end
def mount_directory_for_rsync
true
end