"""File to handle all web interaction with DHCP records""" from flask import request from flask.ext.restful import Resource from flask.ext.restful import abort from flask.ext.restful import reqparse from flask.ext.restful import url_for from marmoset import config as config_reader from marmoset import dhcp from marmoset import validation config = config_reader.load_config() additional_statements_str = config['DHCPConfig'].get('additional_statements') additional_statements = additional_statements_str.split(',') parser = reqparse.RequestParser() parser.add_argument('mac', type=str, required=True) parser.add_argument('ip_address', type=str, required=True) parser.add_argument('gateway', type=str, required=False, default=None) parser.add_argument('networkmask', type=str, required=False, default=None) for additional_statement in additional_statements: parser.add_argument(additional_statement, type=str, required=False) class DhcpCollection(Resource): """Collection class to dal with all DHCP records""" def get(self): """Returns all DHCP records"""
"""File to handle all web interaction with DHCP records""" from flask import request from flask.ext.restful import Resource from flask.ext.restful import abort from flask.ext.restful import reqparse from flask.ext.restful import url_for from marmoset import config as config_reader from marmoset import dhcp from marmoset import validation config = config_reader.load_config() additional_statements_str = config['DHCPConfig'].get('additional_statements') additional_statements = additional_statements_str.split(',') parser = reqparse.RequestParser() parser.add_argument('mac', type=str, required=True) parser.add_argument('ip_address', type=str, required=True) parser.add_argument('gateway', type=str, required=False, default=None) parser.add_argument('networkmask', type=str, required=False, default=None) for additional_statement in additional_statements: parser.add_argument(additional_statement, type=str, required=False) class DhcpCollection(Resource): """Collection class to dal with all DHCP records""" def get(self): """Returns all DHCP records""" return [vars(c) for c in dhcp.DhcpConfig.all()]
def run(config_file=None): cfg = config.load_config(config_file) cli.parse(cfg)