Skip to content

Commit

Permalink
ajaxrsync
Browse files Browse the repository at this point in the history
  • Loading branch information
xilu0 committed Mar 30, 2018
1 parent 351187f commit 36b0416
Show file tree
Hide file tree
Showing 50 changed files with 1,229 additions and 783 deletions.
685 changes: 356 additions & 329 deletions .idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from python-nginx:3.6-1.13
copy . /opt/dashboard/
workdir /opt/dashboard
run pip install -r requirements.txt
17 changes: 13 additions & 4 deletions dashboard/k8s/app.py → dashboard/k8s/application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.http import JsonResponse,HttpResponse
from django.shortcuts import render
from django.views import View
from django.views.generic.base import TemplateView
from pprint import pprint
from kubernetes import config,client
import time
Expand Down Expand Up @@ -246,7 +247,7 @@ def post(self,request,*args,**kwargs):
podslist=list_namespace_pods(namespace='default',labelKey=labelKey,labelValue=labelValue)
return render(request,template_name='dashboard/kubernetes/application.html',context={"service":service,"deployment":deployment, 'podlist':podslist.items})

class application(View):
class application_list(View):
def get(self,request,*args,**kwargs):
config.load_kube_config()
k8s_api = client.AppsV1beta2Api()
Expand All @@ -256,9 +257,9 @@ def post(self,request):
return

class application_detail(View):
def get(self,request):
name=request.GET.get('name')
namespace=request.GET.get('namespace')
def post(self,request):
name=request.POST.get('name')
namespace=request.POST.get('namespace')
deployment=getDeployment(name,namespace)
service=getService(name,namespace)
for key in deployment.metadata.labels:
Expand All @@ -279,6 +280,14 @@ def post(self,request):
return HttpResponse(s1status.to_dict())


class application_form(TemplateView):
template_name = "dashboard/kubernetes/appAdd.html"






if __name__=='__main__':
pass

Expand Down
6 changes: 3 additions & 3 deletions dashboard/k8s/configmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def get(self,request):
return render(request,template_name='dashboard/kubernetes/configmaps.html',context={"configmaps":configmaps})

class configmap_detail(View):
def get(self,request):
name=request.GET.get('name')
namespace=request.GET.get('namespace')
def post(self,request):
name=request.POST.get('name')
namespace=request.POST.get('namespace')
config.load_kube_config()
api=client.CoreV1Api()
configmap=api.read_namespaced_config_map(name,namespace).to_dict()
Expand Down
6 changes: 3 additions & 3 deletions dashboard/k8s/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,17 @@ def list_namespace_pods(namespace, label_selector):
v1podList = k8s_api.list_namespaced_pod(namespace, include_uninitialized=include_uninitialized,label_selector=label_selector)
return v1podList

deploymenyName=request.GET.get('name')
deploymenyName=request.POST.get('name')
print('部署名称:%s' % deploymenyName)
namespace=request.GET.get('namespace')
namespace=request.POST.get('namespace')
v1deployment=getDeployment(deploymenyName,namespace)
for k,v in v1deployment.spec.selector.match_labels.items():
label=k+'='+v
print('容器组选择标签:',label)
podlist=list_namespace_pods(namespace,label)
# print('容器组列表:\n',podlist)
# pprint('部署信息:\n', v1deployment.to_dict())
return render(request,'dashboard/kubernetes/appDetail.html',{'deployment':v1deployment.to_dict(),'podlist':podlist.items})
return render(request,'dashboard/kubernetes/deployment.html',{'deployment':v1deployment.to_dict(),'podlist':podlist.items})

class deployment_read(View):
def post(self,request):
Expand Down
4 changes: 4 additions & 0 deletions dashboard/k8s/endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.views.generic.base import TemplateView

class endpoint_list(TemplateView):
template_name = "dashboard/kubernetes/endpoints.html"
14 changes: 14 additions & 0 deletions dashboard/k8s/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,17 @@ def get(request):
# return JsonResponse(event,safe=False)
return HttpResponse(event)

class list_event_all(View):
def post(self,request):
config.load_kube_config()
api=client.CoreV1Api()
events=api.list_event_for_all_namespaces().items
# print(events)
return render(request,template_name='dashboard/tables/events.html',context={'events':events})
def get(self,request):
config.load_kube_config()
api=client.CoreV1Api()
events=api.list_event_for_all_namespaces().items
# print(events)
return render(request,template_name='dashboard/kubernetes/events.html',context={'events':events})

4 changes: 4 additions & 0 deletions dashboard/k8s/ingress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.views.generic.base import TemplateView

class ingress_list(TemplateView):
template_name = "dashboard/kubernetes/ingresses.html"
20 changes: 2 additions & 18 deletions dashboard/k8s/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,14 @@ def get(self,request):
# return HttpResponse('ok')

class namespace_detail(View):
def get(self,request):
name=request.GET.get('name')
def post(self,request):
name=request.POST.get('name')
config.load_kube_config()
api=client.CoreV1Api()
namespace=api.read_namespace(name=name)
pprint(namespace)
return render(request,template_name='dashboard/kubernetes/namespace.html',context={'namespace':namespace.to_dict()})

class list_event_all(View):
def post(self,request):
config.load_kube_config()
api=client.CoreV1Api()
events=api.list_event_for_all_namespaces().items
# print(events)
return render(request,template_name='dashboard/tables/events.html',context={'events':events})
def get(self,request):
config.load_kube_config()
api=client.CoreV1Api()
events=api.list_event_for_all_namespaces().items
# print(events)
return render(request,template_name='dashboard/kubernetes/events.html',context={'events':events})



if __name__=='__main__':
def get():
config.load_kube_config()
Expand Down
4 changes: 2 additions & 2 deletions dashboard/k8s/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def get(self,request):
return render(request,template_name='dashboard/kubernetes/nodes.html',context={'nodes':nodes})

class node_detail(View):
def get(self,request):
name=request.GET.get('name')
def post(self,request):
name=request.POST.get('name')
config.load_kube_config()
api=client.CoreV1Api()
node=api.read_node(name).to_dict()
Expand Down
10 changes: 10 additions & 0 deletions dashboard/k8s/persistentvolume.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import time
from kubernetes import client,config
from pprint import pprint
from django.views import View
from django.views.generic.base import TemplateView
from django.shortcuts import render
from django.http import HttpResponse

class persistentvolume_list(TemplateView):
template_name = "dashboard/kubernetes/persistentvolume.html"
5 changes: 3 additions & 2 deletions dashboard/k8s/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from kubernetes import config,client

def pod_detail(request):
podName=request.GET.get('name')
namespace=request.GET.get('namespace')
podName=request.POST.get('name')
namespace=request.POST.get('namespace')
# print('podNma:%s,namespace:%s'% podName,namespace)
resp=podStatus(podName,namespace).to_dict()
pprint(resp)
return render(request,template_name='dashboard/kubernetes/podDetail.html',context=resp)

def podStatus(name,namespace):
config.load_kube_config()
k8s_api=client.CoreV1Api()
Expand Down
4 changes: 4 additions & 0 deletions dashboard/k8s/role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.views.generic.base import TemplateView

class role_list(TemplateView):
template_name = "dashboard/kubernetes/roles.html"
6 changes: 3 additions & 3 deletions dashboard/k8s/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def get(self,request):
return render(request,template_name='dashboard/kubernetes/secrets.html',context={"secrets":secrets})

class secret_detail(View):
def get(self,request):
name=request.GET.get('name')
namespace=request.GET.get('namespace')
def post(self,request):
name=request.POST.get('name')
namespace=request.POST.get('namespace')
print(namespace,name)
api=client.CoreV1Api()
secret=api.read_namespaced_secret(name=name,namespace=namespace).to_dict()
Expand Down
13 changes: 7 additions & 6 deletions dashboard/k8s/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def list_namespace_pods(namespace,label_selector):
v1podList=k8s_api.list_namespaced_pod(namespace,include_uninitialized=include_uninitialized,label_selector=label_selector)
return v1podList

class service_detail(View):
class service_modify(View):
def post(self,request):
config.load_kube_config()
k8s_api = client.CoreV1Api()
Expand All @@ -25,11 +25,13 @@ def post(self,request):
resp.metadata.creation_timestamp=resp.metadata.creation_timestamp.strftime('%Y-%m-%d %H:%M:%S')
return JsonResponse(resp.to_str(),safe=False)

def get(self,request):

class service_detail(View):
def post(self,request):
config.load_kube_config()
k8s_api = client.CoreV1Api()
name = request.GET.get("name")
namespace = request.GET.get("namespace")
name = request.POST.get("name")
namespace = request.POST.get("namespace")
print(name, namespace)
resp = k8s_api.read_namespaced_service(name, namespace, exact=True)
pprint(resp)
Expand All @@ -39,8 +41,7 @@ def get(self,request):
print(label_selector)
podlist = list_namespace_pods(namespace, label_selector).items
print(podlist)
return render(request, 'dashboard/kubernetes/serviceDetail.html',
context={'service': resp.to_dict(), 'podlist': podlist})
return render(request, 'dashboard/kubernetes/serviceDetail.html',context={'service': resp.to_dict(), 'podlist': podlist})


def service_delete(request):
Expand Down
4 changes: 4 additions & 0 deletions dashboard/k8s/serviceaccount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.views.generic.base import TemplateView

class serviceacount_list(TemplateView):
template_name = "dashboard/kubernetes/serviceaccounts.html"
Loading

0 comments on commit 36b0416

Please sign in to comment.