Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #28 from YoLoveLife/devel
Browse files Browse the repository at this point in the history
DB complete
  • Loading branch information
YoLoveLife authored Oct 16, 2017
2 parents 435552c + 6d22e21 commit b79a255
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions apps/execute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ 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'))
return super(UpdateHostAPI,self).get(request,*args,**kwargs)


Expand All @@ -36,5 +36,5 @@ def get(self, request, *args, **kwargs):
# dbdetail = db.dbdetail.all()[0]
playbook = PlayBook.objects.get(id = 3)
bas = DBAnsibleService(hostlist = [db.host] )
bas.run(tasklist=playbook.tasks.all().order_by('-sort'),hostlist=[db.host])
bas.run(tasklist=playbook.tasks.all().order_by('-sort'),db=db)
return super(CatchDBStatusAPI,self).get(request, *args, **kwargs)
4 changes: 2 additions & 2 deletions apps/execute/callback/catch/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ def __init__(self):
super(BasicResultCallback,self).__init__()

def v2_runner_on_ok(self, result, **kwargs):
super(BasicResultCallback,self).v2_runner_on_ok(result._result['msg'],**kwargs)
super(BasicResultCallback,self).v2_runner_on_ok(result,**kwargs)

def v2_runner_on_unreachable(self, result):
super(BasicResultCallback,self).v2_runner_on_unreachable()
super(BasicResultCallback,self).v2_runner_on_unreachable(result)

def v2_runner_on_failed(self, result, ignore_errors=False):
super(BasicResultCallback,self).v2_runner_on_failed(result,ignore_errors)
11 changes: 6 additions & 5 deletions apps/execute/service/catch/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ class BasicAnsibleService(AnsibleService):
def __init__(self,hostlist):
self.maker = Maker()
self.maker.inventory_maker(hostlist)
self.hostlist = hostlist
super(BasicAnsibleService,self).__init__(self.maker.filename)

def run(self,hostlist,tasklist):
def run(self,tasklist):
callback = ResultCallback()
self.push_callback(callback)
super(BasicAnsibleService,self).run(tasklist,self.maker)
if callback.status == 1 :
list = callback.ResultExtract()
self.update(list,hostlist)
self.update(list)
else:
for host in hostlist:
for host in self.hostlist:
host.status = callback.status
host.save()

def update(self,list,hostlist):
for host in hostlist:
def update(self,list):
for host in self.hostlist:
host.coreness = list[0]
host.memory = list[1]
host.root_disk = list[2]
Expand Down
20 changes: 10 additions & 10 deletions apps/execute/service/catch/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
# Email [email protected]
from execute.service import AnsibleService
from execute.callback.catch.basic import BasicResultCallback
from execute.models import Callback
from inventory.maker import Maker
__metaclass__ = type
class DBAnsibleService(AnsibleService):
def __init__(self,hostlist):
self.maker = Maker()
self.hostlist = hostlist
self.maker.inventory_maker(hostlist)
super(DBAnsibleService,self).__init__(self.maker.filename)

def run(self,hostlist,tasklist):
def run(self,db,tasklist):
callback = BasicResultCallback()
self.push_callback(callback)

super(DBAnsibleService,self).run(tasklist,self.maker)

list = callback.ResultExtract()
self.update(list,hostlist)
self.update(list,db)

def update(self,list,hostlist):
for host in hostlist:
host.coreness = list[0]
host.memory = list[1]
host.root_disk = list[2]
host.hostname = list[3]
host.save()
def update(self,list,db):
detail = db.dbdetail.get()
detail.com_insert = list[0].strip()
detail.com_update = list[1].strip()
detail.max_connections = list[2].strip()
detail.thread_running = list[3].strip()
detail.save()
2 changes: 1 addition & 1 deletion apps/validate/views/loginout.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.contrib.auth.mixins import LoginRequiredMixin

class ValidateLoginView(FormView):
template_name= 'validate/login.html'
template_name = 'validate/login.html'
form_class= forms.LoginForm
redirect_field_name='yo'

Expand Down

0 comments on commit b79a255

Please sign in to comment.