Esempio n. 1
0
def copy_running_startup():
    cfg = cfgdb.Cfgdb()
    manager = OvsdbConnectionManager(settings.get('ovs_remote'),
                                     settings.get('ovs_schema'))
    manager.start()
    idl = manager.idl

    init_seq_no = idl.change_seqno
    # Wait until the connection is ready
    while True:
        idl.run()
        # print self.idl.change_seqno
        if init_seq_no != idl.change_seqno:
            break
        time.sleep(1)

    restschema = restparser.parseSchema(settings.get('ext_schema'))

    run_config_util = RunConfigUtil(idl, restschema)
    config = run_config_util.get_running_config()

    cfg.config = ovs.json.to_string(config)
    cfg.type = "startup"
    row, tbl_found = cfg.find_row_by_type("startup")
    if tbl_found:
        cfg.update_row(row)
    else:
        cfg.insert_row()

    cfg.close()
    return True