Skip to content

Commit

Permalink
新功能:代码部署增加分批部署主机功能。
Browse files Browse the repository at this point in the history
Bug fix:修复不能修改主机密码bug
  • Loading branch information
welliamcao committed Jul 13, 2017
1 parent 1b3ba3c commit 41970a1
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 73 deletions.
2 changes: 1 addition & 1 deletion OpsManage/templates/assets/assets_modf.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ <h1 class="page-header"><i class="fa fa-gears "></i> 资产修改</h1>
<div class="form-group">
<label class="col-sm-2 control-label">密码</label>
<div class="col-sm-6">
<input type="password" class="form-control" name="server_password" placeholder="Password" class="input-xlarge" value="{{ asset_body.passwd }}" />
<input type="password" class="form-control" name="server_passwd" placeholder="Password" class="input-xlarge" value="{{ asset_body.passwd }}" />
</div>
</div>
</div>
Expand Down
221 changes: 154 additions & 67 deletions OpsManage/templates/deploy/deploy_order_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,62 @@ <h1 class="page-header"><i class="fa fa-github"></i><code>{{order.order_project.
<div class="form-group">
<label class="col-sm-2 control-label">项目名称</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="project_name" value="{{order.order_project.project_name}}" class="input-xlarge" disabled/>
<input type="hidden" class="form-control" name="project_uuid" value="{{order.order_project.project_uuid}}" disabled/>
<input type="text" class="form-control" name="project_name" value="{{order.order_project.project_name}}" class="input-xlarge" readonly="readonly" />
<input type="hidden" class="form-control" name="project_uuid" value="{{order.order_project.project_uuid}}" readonly="readonly"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">目标服务器</label>
<div class="col-sm-6">
<select multiple class="selectpicker" data-live-search="true" name="project_server" id="project_server" required>
{% for ds in serverList %}
<option name="project_server" selected="selected" value="{{ds.server}}">{{ds.server}}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">更新主题</label>
<div class="col-sm-6">
<input class="form-control" value="{{order.order_subject}}" disabled>
<input class="form-control" value="{{order.order_subject}}" readonly="readonly">
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label">更新内容</label>
<div class="col-sm-6">
<textarea class="form-control" rows="3" disabled>{{order.order_content}}</textarea>
<textarea class="form-control" rows="3" readonly="readonly">{{order.order_content}}</textarea>
</div>
</div>
{% if order.order_project.project_model == 'branch' and order.order_project.project_repertory == 'git' %}
<div class="form-group">
<label class="col-sm-2 control-label">分支</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="project_branch" value="{{order.order_branch}}" class="input-xlarge" disabled/>
<input type="text" class="form-control" name="project_branch" value="{{order.order_branch}}" class="input-xlarge" readonly="readonly"/>
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label">更新版本</label>
<div class="col-sm-6">
<div class="input-group">
<input type="text" class="form-control " name="project_version" value="{{order.order_comid}}" disabled>
<input type="text" class="form-control " name="project_version" value="{{order.order_comid}}" readonly="readonly">
<span class="input-group-btn">
<button class="btn btn-success" type="button" data-toggle="modal" data-target="#myModal" >
查看
</button>
</span>
</div>
<!-- <input type="text" class="form-control" name="project_version" value="{{order.order_comid}}" class="input-xlarge" disabled/> -->
</div>
</div>
{% elif order.order_project.project_model == 'tag' and order.order_project.project_repertory == 'git' %}
<div class="form-group">
<label class="col-sm-2 control-label">Tag版本</label>
<div class="col-sm-6">
{% if order.order_tag %}
<input type="text" class="form-control" name="project_branch" value="{{order.order_tag}}" class="input-xlarge" disabled/>
<input type="text" class="form-control" name="project_branch" value="{{order.order_tag}}" class="input-xlarge" readonly="readonly"/>
{% else %}
<input type="text" class="form-control" name="project_branch" class="input-xlarge" disabled/>
<input type="text" class="form-control" name="project_branch" class="input-xlarge" readonly="readonly"/>
{% endif %}
</div>
</div>
Expand All @@ -77,7 +86,7 @@ <h1 class="page-header"><i class="fa fa-github"></i><code>{{order.order_project.
<label class="col-sm-2 control-label">更新版本</label>
<div class="col-sm-6">
<div class="input-group">
<input type="text" class="form-control " name="project_version" value="{{order.order_comid}}" disabled>
<input type="text" class="form-control " name="project_version" value="{{order.order_comid}}" readonly="readonly">
<span class="input-group-btn">
<button class="btn btn-success" type="button" data-toggle="modal" data-target="#myModal" >
查看
Expand All @@ -92,7 +101,7 @@ <h1 class="page-header"><i class="fa fa-github"></i><code>{{order.order_project.
<div class="form-group">
<label class="col-sm-2 control-label">部署指派</label>
<div class="col-sm-6">
<input class="form-control" value="{{order.order_audit}}" disabled>
<input class="form-control" value="{{order.order_audit}}" readonly="readonly">
</div>
</div>
<div class="form-group">
Expand Down Expand Up @@ -143,14 +152,15 @@ <h1 class="page-header"><i class="fa fa-github"></i><code>{{order.order_project.
<legend></legend>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<button type="button" class="btn btn-default disabled" >撤销部署</button>
{% if order.order_status == 0 %}
<button type="button" class="btn btn-default" onclick="runDeploy(this)" >开始部署</button>
<button type="button" class="btn btn-default disabled">完成部署</button>
<button type="button" class="btn btn-default" onclick="runDeploy(this)" >点击部署</button>
{% else %}
<button type="button" class="btn btn-default disabled">完成部署</button>
<button type="button" class="btn btn-default disabled">确认部署</button>
{% endif %}
</div>
</form>
</form>
</div>
<!-- /.col-lg-6 (nested) -->
<div class="col-lg-6">
Expand Down Expand Up @@ -178,32 +188,60 @@ <h1 class="page-header"><i class="fa fa-github"></i><code>{{order.order_project.
</div>
<!-- /.col-lg-12 -->
</div>
<!-- 模态框Modal-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width: 70%;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
&times;
</button>
<h4 class="modal-title" id="myModalLabel">
<code>{{order.order_project.project_name}}</code>项目<code>{{order.order_comid|slice:":7"}}</code>版本提交历史
</h4>
</div>
<div class="modal-body">
<div id="version_result">
<!-- 模态框Modal-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width: 70%;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
&times;
</button>
<h4 class="modal-title" id="myModalLabel">
<code>{{order.order_project.project_name}}</code>项目<code>{{order.order_comid|slice:":7"}}</code>版本提交历史
</h4>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary" onclick="getVersion(this,'{{order.order_branch}}','{{order.order_comid}}')">
点击查看
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
<div class="modal-body">
<div id="version_result">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary" onclick="getVersion(this,'{{order.order_branch}}','{{order.order_comid}}')">
点击查看
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>

<div class="modal fade" id="myDeployModal" tabindex="-1" role="dialog" aria-labelledby="myDeployModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×
</button>
<h4 class="modal-title" id="myDeployLabel">
部署进度
</h4>
</div>
<div class="modal-body">
<div id="noDeployServerList">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" onclick="finishDeploy(this)">
完成部署
</button>
<button type="button" class="btn btn-primary"
data-dismiss="modal">继续部署
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</div>


Expand Down Expand Up @@ -292,6 +330,35 @@ <h4 class="modal-title" id="myModalLabel">
{% 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);
Expand Down Expand Up @@ -322,33 +389,51 @@ <h4 class="modal-title" id="myModalLabel">
$("#result").append("<p>"+result["msg"]+"</p>");
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 += '<li>' + noDeployServer[i] +'</li>'
};
divStr = '<div class="group">' +
'<div>' +
'<p>下列服务器未部署,是否继续部署:</p>' +
'<ul>' + liStr +
'</ul>' +
'</div>' +
'</div>';
$('#noDeployServerList').html(divStr);
$(function () { $('#myDeployModal').modal({
keyboard: true
})});
};

}
}
}
Expand All @@ -357,11 +442,13 @@ <h4 class="modal-title" id="myModalLabel">

/* 轮训获取结果结束 */
$.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);
Expand Down
12 changes: 11 additions & 1 deletion OpsManage/templates/deploy/deploy_run.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ <h1 class="page-header"><i class="fa fa-github"></i><code>{{project.project_name
<input type="hidden" class="form-control" name="project_uuid" value="{{project.project_uuid}}" disabled/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">目标服务器</label>
<div class="col-sm-6">
<select multiple class="selectpicker" data-live-search="true" name="project_server" required>
{% for ds in serverList %}
<option name="project_server" selected="selected" value="{{ds.server}}">{{ds.server}}</option>
{% endfor %}
</select>
</div>
</div>
{% if project.project_model == 'branch' and project.project_repertory == 'git' %}
<div class="form-group">
<label class="col-sm-2 control-label">分支</label>
Expand Down Expand Up @@ -196,7 +206,7 @@ <h1 class="page-header"><i class="fa fa-github"></i><code>{{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"){
Expand Down
Loading

0 comments on commit 41970a1

Please sign in to comment.