Beispiel #1
0
 def get(self, request, *args, **kwargs):
     k = K8sTask()
     k.user = self.request.user.username
     k.namespace = self.kwargs.get('namespace')
     k.delete_job(self.kwargs.get('name'))
     time.sleep(1)
     return redirect("/task")
Beispiel #2
0
 def get_context_data(self, **kwargs):
     k = K8sTask()
     k.user = self.request.user.username
     context = super().get_context_data(**kwargs)
     context['k'] = k
     context['len'] = len(k.get_user_namespace())
     return context
Beispiel #3
0
 def form_valid(self, form):
     # This method is called when valid form data has been POSTed.
     # It should return an HttpResponse.
     k = K8sTask()
     k.user = self.request.user.username
     k.namespace = form.cleaned_data['namespace']
     k.create_namespace()
     return super().form_valid(form)
Beispiel #4
0
 def get_context_data(self, **kwargs):
     k = K8sTask()
     k.user = self.request.user.username
     k.namespace = self.kwargs.get('namespace')
     context = super().get_context_data(**kwargs)
     context['result'] = k.log_job(name=self.kwargs.get('name'))
     context['info'] = k.info_job(name=self.kwargs.get('name'))
     context['pod'] = k.get_pod_with_job(self.kwargs.get('name'))
     return context
Beispiel #5
0
 def form_valid(self, form):
     # This method is called when valid form data has been POSTed.
     # It should return an HttpResponse.
     # TODO: The Namespace function will be remove
     k = K8sTask()
     k.user = self.request.user.username
     k.namespace = self.request.user.username
     k.create_namespace()
     return super().form_valid(form)
Beispiel #6
0
 def form_valid(self, form):
     # This method is called when valid form data has been POSTed.
     # It should return an HttpResponse.
     cmd = form.cleaned_data['cmd'].split(' ')
     k = K8sTask()
     k.user = self.request.user.username
     k.namespace = form.cleaned_data['namespace']
     k.create_job(
         name=form.cleaned_data['name'],
         image=form.cleaned_data['image'],
         cmd=cmd,
         path=form.cleaned_data['path'],
     )
     return super().form_valid(form)
Beispiel #7
0
 def get(self, request, *args, **kwargs):
     k = K8sTask()
     k.namespace = self.kwargs.get('name')
     k.delete_namespace()
     return redirect("/task/namespace")
Beispiel #8
0
 def get_context_data(self, **kwargs):
     k = K8sTask()
     k.user = self.request.user.username
     context = super().get_context_data(**kwargs)
     context['k'] = k
     return context