Skip to content

Commit

Permalink
flush
Browse files Browse the repository at this point in the history
  • Loading branch information
YoLoveLife committed Sep 22, 2017
1 parent ae38633 commit d5d7870
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ travis & django TestCase</br>

如果你关注:自动化运维、运维资源管理等内容 :star: 我,[分享](http://www.yolovelife.com)给其他的运维人员</br>
如果你关注:django开发、rest-framework等内容 :star: 我,[分享](http://www.yolovelife.com)给其他的开发者</br>
求求你们 :star: 我吧!!!求求你们 :star: 我吧!!!求求你们 :star: 我吧!!!</br>
求求你们 :star: 我吧!!! 求求你们 :star: 我吧!!! 求求你们 :star: 我吧!!!</br>

*关于我开发中遇到的问题 我会写在issues当中供有需要的朋友 :mag: 查询*</br>
*这些问题都是在查询了诸多资料并亲身尝试大量解决方案 :grimacing: 最后得出的结论*</br>
Expand Down
6 changes: 6 additions & 0 deletions apps/application/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class DB(models.Model):
datadir=models.CharField(max_length=100,default='/storage/mysql')
softlib=models.ForeignKey(Softlib,default=1,)
# online=models.BooleanField(default=False)

class DBControl(models.Model):
id = models.AutoField(primary_key=True)
db = models.ForeignKey(DB,default=1,related_name='dbcontrols')


#
#
# class Java(models.Model):
Expand Down
9 changes: 7 additions & 2 deletions apps/execute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
from manager.models import Host
from service.catch.basic import BasicAnsibleService
class UpdateHostAPI(generics.ListAPIView):
serializer_class = serializers.ExecuteSerializer
serializer_class = serializers.UpdateHostSerializer
permission_classes = [IsAuthenticated]

def get_queryset(self):
return Host.objects.filter(id=self.kwargs['pk'])

def get(self, request, *args, **kwargs):
host = Host.objects.get(id=self.kwargs['pk'])
playbook = PlayBook.objects.get(id=1)
bas = BasicAnsibleService(hostlist=[host])
bas.run(tasklist=playbook.tasks.all().order_by('-sort'),hostlist=[host])
bas.run(tasklist=playbook.tasks.all().order_by('-sort'),hostlist=[host])
return super(UpdateHostAPI,self).get(request,*args,**kwargs)
9 changes: 5 additions & 4 deletions apps/execute/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import models
from manager import models
from rest_framework import serializers
class ExecuteSerializer(serializers.HyperlinkedModelSerializer):

class UpdateHostSerializer(serializers.ModelSerializer):
class Meta:
model = models.Callback
fields = ('id')
model=models.Host
fields = ('id','service_ip')
5 changes: 2 additions & 3 deletions apps/execute/service/catch/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
__metaclass__ = type
class BasicAnsibleService(AnsibleService):
def __init__(self,hostlist):
maker = Maker()
self.maker = maker
self.maker = Maker()
self.maker.inventory_maker(hostlist)
super(BasicAnsibleService,self).__init__(maker.filename)
super(BasicAnsibleService,self).__init__(self.maker.filename)

def run(self,hostlist,tasklist):
callback = basic.BasicResultCallback()
Expand Down
22 changes: 22 additions & 0 deletions apps/manager/templates/manager/detail_host.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ <h3 class="box-title"><i class="fa fa-cogs"></i>配置信息</h3>
</div>
</div>
</div>
<div class="col-md-1">
<button class="btn btn-app" id="flush_host">
<i class="fa fa-plus"></i> 刷新主机信息
</button>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -277,5 +282,22 @@ <h3 class="box-title"><i class="fa fa-life-ring"></i>应用信息</h3>
function historyBack() {
window.history.go(-1);
}
$(document).ready(function () {
})
.on('click','#flush_host',function () {
$.ajax({
mimeType: 'text/html; charset=utf-8', // ! Need set mimeType only when run from local file
url: '/api-execute/v1/update/host/{{ host.id }}/',
type: 'GET',
success: function(data) {
location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
},
dataType: "html",
async: false
});
})
</script>
{% endblock %}
5 changes: 0 additions & 5 deletions apps/manager/templates/manager/host.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ <h3 class="box-title">主机列表</h3>
<th data-field="server_position">服务器位置</th>
<th data-field="info">用途</th>
<th data-field="id" data-formatter="detailFormatter">细节</th>
<th data-field="id" data-formatter="flushFormatter">刷新</th>
</tr>
</thead>
<tbody id="hosttbody">
Expand Down Expand Up @@ -101,10 +100,6 @@ <h3 class="box-title" style="text-align: center">主机信息</h3>
var label_a='<a class="btn btn-default" href="/manager/host/'+value+'/detail/">'+'<i class="fa fa-paperclip"></i>'+'</a>';
return [label_a].join('');
}
function flushFormatter(value,row,index) {
var label_a='<a class="btn btn-default" href="/api-execute/v1/update/host/'+value+'/">'+'<i class="fa fa-refresh"></i>'+'</a>';
return [label_a].join('');
}
$(document).ready(function () {
$('.select2').select2();
var table=$('#host_tb').bootstrapTable({
Expand Down
14 changes: 14 additions & 0 deletions apps/static/less/manager.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,18 @@
dt,dd{
text-align: left;
}
}
#loading{
width:170px;
height:25px;
border:3px solid #C3DAF9;
position:absolute;
top:300px;
left:600px;
z-index:10000;
background-color:#F7F9FC;
line-height:25px;
vertical-align:middle;
font-size:11pt;
display:none;
}

0 comments on commit d5d7870

Please sign in to comment.