diff --git a/OpsManage/templates/assets/assets_modf.html b/OpsManage/templates/assets/assets_modf.html index 41a79f1a..d0103a3b 100755 --- a/OpsManage/templates/assets/assets_modf.html +++ b/OpsManage/templates/assets/assets_modf.html @@ -243,7 +243,7 @@
{{order.order_project.
-
-
+
+
+
+
+
+
+
+
-
+
-
+
{% if order.order_project.project_model == 'branch' and order.order_project.project_repertory == 'git' %}
-
+
@@ -51,14 +61,13 @@ {{order.order_project.
-
+
-
{% elif order.order_project.project_model == 'tag' and order.order_project.project_repertory == 'git' %}
@@ -66,9 +75,9 @@ {{order.order_project.
{% if order.order_tag %}
-
+
{% else %}
-
+
{% endif %}
@@ -77,7 +86,7 @@ {{order.order_project.
-
+
-
-
@@ -292,6 +330,35 @@
{% endif %}
{% if order.order_status == 0 %}
+ function finishDeploy(obj){
+ $.ajax({
+ type: 'POST',
+ url: '/deploy_order/',
+ data: {
+ "id":{{order.id}},
+ "model":'finish',
+ "order_status":3
+ },
+ success:function(response){
+ if (response["code"] == "200"){
+ window.wxc.xcConfirm("部署完成", window.wxc.xcConfirm.typeEnum.success);
+ location.reload();
+// $('#permOrder').remove();
+// btnObj.attr('disabled',true);
+
+ }
+ else{
+ window.wxc.xcConfirm("部署成功,但是未能更新工单状态", window.wxc.xcConfirm.typeEnum.error);
+ }
+
+ },
+ error:function(response){
+ window.wxc.xcConfirm("部署失败", window.wxc.xcConfirm.typeEnum.error);
+ clearInterval(interval);
+ }
+ });
+ }
+
function runDeploy(obj) {
var btnObj = $(obj);
btnObj.attr('disabled',true);
@@ -322,33 +389,51 @@
$("#result").append("
"+result["msg"]+"
");
if (result["msg"].indexOf("[Done]") == 0){
clearInterval(interval);
- /* 更新数据库-更新完成 */
- $.ajax({
- type: 'POST',
- url: '/deploy_order/',
- data: {
- "id":{{order.id}},
- "model":'finish',
- "order_status":3
- },
- success:function(response){
- if (response["code"] == "200"){
- window.wxc.xcConfirm("部署成功", window.wxc.xcConfirm.typeEnum.success);
- $('#permOrder').remove();
- btnObj.attr('disabled',true);
-
- }
- else{
- window.wxc.xcConfirm("部署成功,但是未能更新工单状态", window.wxc.xcConfirm.typeEnum.error);
- }
-
- },
- error:function(response){
- window.wxc.xcConfirm("部署失败", window.wxc.xcConfirm.typeEnum.error);
- clearInterval(interval);
- }
- });
-
+ /* 更新数据库-更新完成 */
+ if (noDeployServer.length == 0){
+ $.ajax({
+ type: 'POST',
+ url: '/deploy_order/',
+ data: {
+ "id":{{order.id}},
+ "model":'finish',
+ "order_status":3
+ },
+ success:function(response){
+ if (response["code"] == "200"){
+ window.wxc.xcConfirm("部署完成", window.wxc.xcConfirm.typeEnum.success);
+ $('#permOrder').remove();
+ btnObj.attr('disabled',true);
+ }
+ else{
+ window.wxc.xcConfirm("部署成功,但是未能更新工单状态", window.wxc.xcConfirm.typeEnum.error);
+ }
+
+ },
+ error:function(response){
+ window.wxc.xcConfirm("部署失败", window.wxc.xcConfirm.typeEnum.error);
+ clearInterval(interval);
+ }
+ });
+ }
+ else{
+ var liStr = '';
+ for (var i = 0; i < noDeployServer.length; ++i) {
+ liStr += '' + noDeployServer[i] +' '
+ };
+ divStr = '' +
+ '' +
+ '下列服务器未部署,是否继续部署:
' +
+ '' + liStr +
+ '
' +
+ '' +
+ '';
+ $('#noDeployServerList').html(divStr);
+ $(function () { $('#myDeployModal').modal({
+ keyboard: true
+ })});
+ };
+
}
}
}
@@ -357,11 +442,13 @@
/* 轮训获取结果结束 */
$.ajax({
+ cache:false,
url:'/deploy_run/{{order.order_project.id}}/', //请求地址
type:"POST", //提交类似
- data:post_data, //提交参数
+ data:$("#deployRun").serialize(), //提交参数
success:function(response){
btnObj.removeAttr('disabled');
+ noDeployServer = response["data"];
if (response["code"] == "500"){
clearInterval(interval);
window.wxc.xcConfirm(response["msg"], window.wxc.xcConfirm.typeEnum.error);
diff --git a/OpsManage/templates/deploy/deploy_run.html b/OpsManage/templates/deploy/deploy_run.html
index df3ef871..193c4f08 100755
--- a/OpsManage/templates/deploy/deploy_run.html
+++ b/OpsManage/templates/deploy/deploy_run.html
@@ -26,6 +26,16 @@ {{project.project_name
+
+
+
+
+
+
{% if project.project_model == 'branch' and project.project_repertory == 'git' %}
@@ -196,7 +206,7 @@ {{project.project_name
$.ajax({
url:'/deploy_run/'+"{{project.id}}/", //请求地址
type:"POST", //提交类似
- data:post_data, //提交参数
+ data:$("#deployRun").serialize(), //提交参数
success:function(response){
btnObj.removeAttr('disabled');
if (response["code"] == "500"){
diff --git a/OpsManage/views/deploy.py b/OpsManage/views/deploy.py
index f171df85..3d888167 100755
--- a/OpsManage/views/deploy.py
+++ b/OpsManage/views/deploy.py
@@ -119,7 +119,6 @@ def deploy_modf(request,pid):
if ipList:
tagret_server_list = [ s.server for s in tagret_server ]
postServerList = []
- print tagret_server_list
for sid in ipList:
try:
server = Server_Assets.objects.get(id=sid)
@@ -223,11 +222,17 @@ def deploy_run(request,pid):
version.pull(path=project.project_repo_dir)
vList = version.log(path=project.project_repo_dir, number=50)
return render_to_response('deploy/deploy_run.html',{"user":request.user,
- "project":project,
+ "project":project,"serverList":serverList,
"bList":bList,"vList":vList},
context_instance=RequestContext(request))
elif request.method == "POST":
+ if request.POST.getlist('project_server',None):
+ serverList = [ Project_Number.objects.get(project=project,server=ds) for ds in request.POST.getlist('project_server') ]
+ allServerList = [ ds.server for ds in Project_Number.objects.filter(project=project) ]
+ #获取项目目标服务器列表与分批部署服务器(post提交)列表的差集
+ tmpServer = [ i for i in allServerList if i not in request.POST.getlist('project_server') ]
+ else:return JsonResponse({'msg':"项目部署失败:未选择目标服务器","code":500,'data':[]})
if DsRedis.OpsProject.get(redisKey=project.project_uuid+"-locked") is None:#判断该项目是否有人在部署
#给项目部署加上锁
DsRedis.OpsProject.set(redisKey=project.project_uuid+"-locked",value=request.user)
@@ -335,7 +340,7 @@ def deploy_run(request,pid):
recordProject.delay(project_user=str(request.user),project_id=project.id,
project_name=project.project_name,project_content="部署项目",
project_branch=bName)
- return JsonResponse({'msg':"项目部署成功","code":200,'data':[]})
+ return JsonResponse({'msg':"项目部署成功","code":200,'data':tmpServer})
else:
return JsonResponse({'msg':"项目部署失败:{user}正在部署改项目,请稍后再提交部署。".format(user=DsRedis.OpsProject.get(redisKey=project.project_uuid+"-locked")),"code":500,'data':[]})
@@ -434,12 +439,13 @@ def deploy_order_status(request,pid):
if request.method == "GET":
try:
order= Project_Order.objects.get(id=pid)
+ serverList = Project_Number.objects.filter(project=order.order_project)
if order.order_audit == str(request.user):order.order_perm = 'pass'
except:
return render_to_response('deploy/deploy_ask.html',{"user":request.user,
"errorInfo":"工单不存在,可能已经被删除."},
context_instance=RequestContext(request))
- return render_to_response('deploy/deploy_order_status.html',{"user":request.user,"order":order},
+ return render_to_response('deploy/deploy_order_status.html',{"user":request.user,"order":order,"serverList":serverList},
context_instance=RequestContext(request))