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
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)
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
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)
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)
def get(self, request, *args, **kwargs): k = K8sTask() k.namespace = self.kwargs.get('name') k.delete_namespace() return redirect("/task/namespace")
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