def add_schema(self): """ Add a new schema to NIPAP and returns its data. """ s = Schema() if 'name' in request.params: s.name = request.params['name'] if 'description' in request.params: s.description = request.params['description'] if 'vrf' in request.params: if request.params['vrf'].strip() == '': s.vrf = None else: s.vrf = request.params['vrf'] try: s.save() except NipapError, e: return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
def add(self): """ Add a new schema. """ c.action = 'add' if 'action' in request.params: if request.params['action'] == 'add': s = Schema() s.name = request.params['name'] s.description = request.params['description'] if request.params['vrf'].strip() == '': s.vrf = None else: s.vrf = request.params['vrf'] s.save() redirect(url(controller='schema', action='list')) return render('/schema_add.html')
def add_schema(arg, opts): """ Add schema to NIPAP """ s = Schema() s.name = opts.get('name') s.description = opts.get('description') s.vrf = opts.get('vrf') try: s.save() except pynipap.NipapError, e: print >> sys.stderr, "Could not add schema to NIPAP: %s" % e.message sys.exit(1)