镜像同步

dev_library
daiao 6 years ago
parent ab054713bf
commit e234a2e57f

@ -346,13 +346,13 @@ class ManagementsController < ApplicationController
if mirror.blank? if mirror.blank?
raise("choose_update_mirror exception") raise("choose_update_mirror exception")
end end
shixun_tomcat = Redmine::Configuration['shixun_tomcat'] #shixun_tomcat = Redmine::Configuration['shixun_tomcat']
params = {imageName: mirror.name, imageID: old_id, flag: flag} #params = {imageName: mirror.name, imageID: old_id, flag: flag}
uri = "#{shixun_tomcat}/bridge/docker/updateImage" #uri = "#{shixun_tomcat}/bridge/docker/updateImage"
res = uri_exec uri, params #res = uri_exec uri, params
if (res && res['code'] != 0) # if (res && res['code'] != 0)
raise("choose_update_mirror exception") raise("choose_update_mirror exception")
end #end
if flag == 0 if flag == 0
mirror.update_attributes(:mirrorID => change_id, :status => 0) mirror.update_attributes(:mirrorID => change_id, :status => 0)
# 用户操作的的行为需要记录 user_id 中间层操作的行为user_id = -1 # 用户操作的的行为需要记录 user_id 中间层操作的行为user_id = -1
@ -720,20 +720,25 @@ class ManagementsController < ApplicationController
shixun_tomcat = Redmine::Configuration['shixun_tomcat'] shixun_tomcat = Redmine::Configuration['shixun_tomcat']
params = {imageName: @mirror.name} params = {imageName: @mirror.name}
# 主从节点同步镜像 # 主从节点同步镜像
uri = "#{shixun_tomcat}/bridge/docker/syncImage" #uri = "#{shixun_tomcat}/bridge/docker/syncImage"
res = uri_exec uri, params #res = uri_exec uri, params
if (res && res['code'] != 0) #if (res && res['code'] != 0)
raise("Synchronize Mirror exception") # raise("Synchronize Mirror exception")
end #end
end end
if @_params[:type_name] != @mirror.type_name if @_params[:type_name] != @mirror.type_name
MirrorOperationRecord.create!(:mirror_repository_id => @mirror.id, :status => 5, :user_id => User.current.id, :old_tag => @mirror.type_name, :new_tag => @_params[:type_name]) MirrorOperationRecord.create!(:mirror_repository_id => @mirror.id, :status => 5,
:user_id => User.current.id, :old_tag => @mirror.type_name,
:new_tag => @_params[:type_name])
elsif @_params[:status].to_i != @mirror.status elsif @_params[:status].to_i != @mirror.status
MirrorOperationRecord.create!(:mirror_repository_id => @mirror.id, :status => 6, :user_id => User.current.id, :old_tag => @mirror.status, :new_tag => @_params[:status]) MirrorOperationRecord.create!(:mirror_repository_id => @mirror.id, :status => 6,
:user_id => User.current.id, :old_tag => @mirror.status,
:new_tag => @_params[:status])
end end
@mirror.update_attributes(:description => @_params[:description], :status => @_params[:status], :main_type => @_params[:mirror_type], @mirror.update_attributes(:description => @_params[:description], :status => @_params[:status],
:type_name => @_params[:type_name], :resource_limit => @_params[:mirror_resource_limit], :cpu_limit => @_params[:mirror_cpu_limit], :main_type => @_params[:mirror_type], :type_name => @_params[:type_name],
:memory_limit => @_params[:mirror_memory_limit], :time_limit => @_params[:mirror_time_limit]) :resource_limit => @_params[:mirror_resource_limit], :cpu_limit => @_params[:mirror_cpu_limit],
:memory_limit => @_params[:mirror_memory_limit], :time_limit => @_params[:mirror_time_limit])
@index = MirrorRepository.order("created_at desc").map(&:id).index(@mirror.id) @index = MirrorRepository.order("created_at desc").map(&:id).index(@mirror.id)
respond_to do |format| respond_to do |format|
format.js format.js

Loading…
Cancel
Save