This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from YoLoveLife/devel
完成资产信息获取功能
- Loading branch information
Showing
28 changed files
with
146 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding:utf-8 -*- | ||
import models,serializers | ||
from rest_framework import generics | ||
from rest_framework.permissions import IsAuthenticated | ||
from execute.service.catch.basic import BasicAnsibleService | ||
from operation.models import PlayBook | ||
from manager.models import Host | ||
from service.catch.basic import BasicAnsibleService | ||
class UpdateHostAPI(generics.ListAPIView): | ||
serializer_class = serializers.ExecuteSerializer | ||
permission_classes = [IsAuthenticated] | ||
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import models | ||
from rest_framework import serializers | ||
class ExecuteSerializer(serializers.HyperlinkedModelSerializer): | ||
class Meta: | ||
model = models.Callback | ||
fields = ('id') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
# -*- coding:utf-8 -*- | ||
from execute.service import AnsibleService | ||
from execute.callback.catch import basic | ||
|
||
from execute.models import Callback | ||
from inventory.maker import Maker | ||
__metaclass__ = type | ||
class BasicAnsibleService(AnsibleService): | ||
|
||
def __init__(self,name): | ||
super(BasicAnsibleService,self).__init__(self,name) | ||
def __init__(self,hostlist): | ||
maker = Maker() | ||
self.maker = maker | ||
self.maker.inventory_maker(hostlist) | ||
super(BasicAnsibleService,self).__init__(maker.filename) | ||
|
||
def run(self,hostlist,tasklist): | ||
self.push_callback(basic.BasicResultCallback()) | ||
return super(BasicAnsibleService,self).run(hostlist,tasklist) | ||
callback = basic.BasicResultCallback() | ||
self.push_callback(callback) | ||
super(BasicAnsibleService,self).run(tasklist,self.maker) | ||
list = callback.ResultExtract() | ||
self.update(list,hostlist) | ||
|
||
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() | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.conf.urls import url | ||
from .. import api | ||
urlpatterns=[ | ||
# Resource update api | ||
url(r'^v1/update/host/(?P<pk>[0-9]+)/', api.UpdateHostAPI.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 10 15:38 | ||
# Author Yo | ||
# Email [email protected] | ||
from django.conf.urls import url | ||
from ..views import group,host,storage,dashboard | ||
urlpatterns = [ | ||
#Resource dashboard url | ||
# url(r'^dashboard/$', dashboard.ManagerDashboardView.as_view(), name='dashboard'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
MUDULE_OPTION = { | ||
MODULE_OPTION = { | ||
'0':'none', | ||
'1': 'shell', | ||
'2': 'copy', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.