def vcp_upgrade(request): obj = models.VcenterConfiguration.objects.latest('id') if request.method == 'POST': form = VcenterConfigurationForm(request.POST, instance=obj) if form.is_valid(): if not form.is_update_needed(): return JsonResp( request, error=True, message=_("There are No updates available at this time.")) else: form.vcp_action = 'UPGRADE' try: form.save() return JsonResp( request, message=_("The plugin has been successfully upgraded"), ) except CallTimeout: return JsonResp( request, message=_( "The plugin could not be installed because of timeout." " Most probably the port provided was incorrect"), ) except ValidationErrors as e: handle_middleware_validation(form, e) return JsonResp(request, form=form)
def vcp_home(request): aux_enable_https = models.VcenterAuxSettings.objects.latest('id') obj = models.VcenterConfiguration.objects.latest('id') if request.method == 'POST': form = VcenterConfigurationForm(request.POST, instance=obj) if form.is_valid(): form.vcp_action = 'INSTALL' try: form.save() return JsonResp( request, message=_("The plugin has been successfully installed"), ) except CallTimeout: return JsonResp( request, message=_( "The plugin could not be installed because of timeout." " Most probably the port provided was incorrect"), ) except ValidationErrors as e: handle_middleware_validation(form, e) return JsonResp(request, form=form) else: form = VcenterConfigurationForm(instance=obj) if obj.vc_installed: form.fields['vc_ip'].widget.attrs['readonly'] = True return render(request, "vcp/index.html", { 'form': form, 'aux_enable_https': aux_enable_https, })
def vcp_uninstall(request): obj = models.VcenterConfiguration.objects.latest('id') if request.method == 'POST': form = VcenterConfigurationForm(request.POST, instance=obj) if form.is_valid(): form.vcp_action = 'UNINSTALL' try: form.save() # TODO: THE UI DISPLAYS OLD CREDENTIALS AFTER UN-INSTALLATION, THAT NEEDS BE CHANGED return JsonResp( request, message=_("The plugin has been successfully uninstalled"), ) except CallTimeout: return JsonResp( request, message=_( "The plugin could not be installed because of timeout." " Most probably the port provided was incorrect"), ) except ValidationErrors as e: handle_middleware_validation(form, e) return JsonResp(request, form=form)
def vcp_repair(request): obj = models.VcenterConfiguration.objects.latest('id') if request.method == 'POST': form = VcenterConfigurationForm(request.POST, instance=obj) if form.is_valid(): form.vcp_action = 'REPAIR' try: form.save() return JsonResp( request, message=_("The plugin has been successfully installed"), ) except CallTimeout: return JsonResp( request, message=_( "The plugin could not be installed because of timeout." " Most probably the port provided was incorrect"), ) except ValidationErrors as e: handle_middleware_validation(form, e) return JsonResp(request, form=form)