Пример #1
0
def add_new_device():
    """
    Adds a new device to the physical layer
    """
    LOG.info("Accessing URL %s", request.url)
    now_ts = time.time()
    error_log = []
    if not request.data:
        err_msg = "No device data in body"
        abort(400, err_msg)

    LOG.debug(request.data)
    data = ast.literal_eval(request.data)

    # get config manager
    from landscaper.utilities import configuration
    conf_manager = configuration.ConfigurationManager()
    conf_manager.add_section('physical_layer')
    conf_manager.add_section('general')

    # save file to disk
    from landscaper.collector.cimi_physicalhost_collector import CimiPhysicalCollector
    cimi_updater = CimiPhysicalCollector(None, conf_manager, None, None)
    cimi_updater.generate_files(data)

    if error_log:
        err_msg = "Error with the following nodes:" + str(error_log)
        abort(400, err_msg)

    return Response(status=201, mimetype=MIME)
Пример #2
0
def add_new_service():
    """
    Adds a new service to the graph
    """
    LOG.info("Accessing URL %s", request.url)
    now_ts = time.time()
    error_log = []
    if not request.data:
        err_msg = "No device data in body"
        abort(400, err_msg)

    LOG.debug(request.data)
    data = ast.literal_eval(request.data)

    if error_log:
        err_msg = "Error with the following nodes:" + str(error_log)
        abort(400, err_msg)

    return Response(status=201, mimetype=MIME)