Пример #1
0
def init_topology():

    instances = gm.invoke_graph_instance_list()
    if instances['status'] != 200:
        logger.warning('Failed to invoker direct method', instances['payload'])
        return -1
    logger.info('========== Deleting {0} instance(s) =========='.format(
        len(instances['payload']['value'])))

    for i in range(len(instances['payload']['value'])):
        gm.invoke_graph_instance_deactivate(
            instances['payload']['value'][i]['name'])
        gm.invoke_graph_instance_delete(
            instances['payload']['value'][i]['name'])

    topologies = gm.invoke_graph_topology_list()
    if instances['status'] != 200:
        logger.warning('Failed to invoker direct method', instances['payload'])
        return -1
    logger.info('========== Deleting {0} topology =========='.format(
        len(topologies['payload']['value'])))

    for i in range(len(topologies['payload']['value'])):
        gm.invoke_graph_topology_delete(
            topologies['payload']['value'][i]['name'])

    logger.info('========== Setting default grpc topology =========='.format(
        len(topologies['payload']['value'])))
    ret = gm.invoke_graph_grpc_topology_set()

    return 1
Пример #2
0
def init_topology():
    """init_topology.

    Init LVA topologies
    """

    instances = gm.invoke_graph_instance_list()
    logger.info("instances %s", instances)
    if "error" in instances.keys():
        logger.warning(
            "[HttpOperationError] Probably caused by invalid IoTHub connection string. The server will terminate in 10 seconds."
        )
        time.sleep(10)
        sys.exit(-1)
    if instances["status"] != 200:
        logger.warning("Failed to invoke direct method: %s",
                       instances["payload"])
        return -1
    logger.info(
        "========== Deleting %s instance(s) ==========",
        len(instances["payload"]["value"]),
    )

    for i in range(len(instances["payload"]["value"])):
        gm.invoke_graph_instance_deactivate(
            instances["payload"]["value"][i]["name"])
        gm.invoke_graph_instance_delete(
            instances["payload"]["value"][i]["name"])

    topologies = gm.invoke_graph_topology_list()
    if instances["status"] != 200:
        logger.warning("Failed to invoker direct method: %s",
                       instances["payload"])
        return -1
    logger.info(
        "========== Deleting %s topology ==========",
        len(topologies["payload"]["value"]),
    )

    for i in range(len(topologies["payload"]["value"])):
        gm.invoke_graph_topology_delete(
            topologies["payload"]["value"][i]["name"])

    logger.info("========== Setting default grpc/http topology ==========")
    ret = gm.invoke_topology_set("grpc")
    ret = gm.invoke_topology_set("http")

    return 1
Пример #3
0
def init_topology():
    """init_topology.

    Init LVA topologies
    """

    instances = gm.invoke_graph_instance_list()
    logger.info("instances %s", instances)
    if instances["status"] != 200:
        logger.warning("Failed to invoke direct method: %s", instances["payload"])
        return -1
    logger.info(
        "========== Deleting %s instance(s) ==========",
        len(instances["payload"]["value"]),
    )

    for i in range(len(instances["payload"]["value"])):
        gm.invoke_graph_instance_deactivate(instances["payload"]["value"][i]["name"])
        gm.invoke_graph_instance_delete(instances["payload"]["value"][i]["name"])

    topologies = gm.invoke_graph_topology_list()
    if instances["status"] != 200:
        logger.warning("Failed to invoker direct method: %s", instances["payload"])
        return -1
    logger.info(
        "========== Deleting %s topology ==========",
        len(topologies["payload"]["value"]),
    )

    for i in range(len(topologies["payload"]["value"])):
        gm.invoke_graph_topology_delete(topologies["payload"]["value"][i]["name"])

    logger.info("========== Setting default grpc/http topology ==========")
    ret = gm.invoke_topology_set("grpc")
    ret = gm.invoke_topology_set("http")

    return 1