def addhost(request): """ Add a new host from an okconfig template """ c = {} c['messages'] = [] c['errors'] = [] # If there is a problem with the okconfig setup, lets display an error if not okconfig.is_valid(): return verify_okconfig(request) if request.method == 'GET': f = forms.AddHostForm(initial=request.GET) elif request.method == 'POST': f = forms.AddHostForm(request.POST) if f.is_valid(): host_name = f.cleaned_data['host_name'] group_name = f.cleaned_data['group_name'] address = f.cleaned_data['address'] templates = f.cleaned_data['templates'] #description = f.cleaned_data['description'] force = f.cleaned_data['force'] try: c['filelist'] = okconfig.addhost(host_name=host_name, group_name=group_name, address=address, force=force, templates=templates) c['host_name'] = host_name return addcomplete(request, c) except Exception, e: c['errors'].append("error adding host: %s" % e) else: c['errors'].append('Could not validate input')
def addhost(request): c = {} c['messages'] = [] c['errors'] = [] # If there is a problem with the okconfig setup, lets display an error if not okconfig.is_valid(): return verify_okconfig(request) if request.method == 'GET': f = forms.AddHostForm(initial=request.GET) elif request.method == 'POST': f = forms.AddHostForm(request.POST) if f.is_valid(): host_name = f.cleaned_data['host_name'] group_name = f.cleaned_data['group_name'] address = f.cleaned_data['address'] templates = f.cleaned_data['templates'] #description = f.cleaned_data['description'] force = f.cleaned_data['force'] try: c['filelist'] = okconfig.addhost(host_name=host_name,group_name=group_name,address=address,force=force,templates=templates) c['host_name'] = host_name return HttpResponseRedirect( reverse('adagios.okconfig_.views.edit', args=[host_name] ) ) except Exception, e: c['errors'].append( "error adding host: %s" % e ) else: c['errors'].append( 'Could not validate input')
def addhost(request): """ Add a new host from an okconfig template """ c = {} c['messages'] = [] c['errors'] = [] # If there is a problem with the okconfig setup, lets display an error if not okconfig.is_valid(): return verify_okconfig(request) if request.method == 'GET': f = forms.AddHostForm(initial=request.GET) elif request.method == 'POST': f = forms.AddHostForm(request.POST) if f.is_valid(): host_name = f.cleaned_data['host_name'] group_name = f.cleaned_data['group_name'] address = f.cleaned_data['address'] templates = f.cleaned_data['templates'] #description = f.cleaned_data['description'] force = f.cleaned_data['force'] try: c['filelist'] = okconfig.addhost(host_name=host_name, group_name=group_name, address=address, force=force, templates=templates) c['host_name'] = host_name return addcomplete(request, c) except Exception as e: c['errors'].append(_("error adding host: %s") % e) else: c['errors'].append(_('Could not validate input')) else: raise Exception("Sorry i only support GET or POST") c['form'] = f return render_to_response('addhost.html', c, context_instance=RequestContext(request))