示例#1
0
文件: metadata.py 项目: raw-db/ldb-wn
def list_schemas(user, module):
    ldbconfig = user_storage.ldbconfig(user)
    s, o = safecommands.getstatusoutput("LDBCONFIG=\"%s\" %s list_extents %s" % (ldbconfig, ODL_BIN, module))
    if s != 0:
        logging.error("Failed with error: %s" % o.strip())
        raise MetadataException("Failed during list_schemas")
    schemas = []
    for l in o.strip().splitlines():
        schemas.append(l[len(module)+2:])   # Skip 'Module::'
    print schemas
    return schemas
示例#2
0
文件: metadata.py 项目: raw-db/ldb-wn
def register_shore_schema(user, module, name, schema):
    ldbconfig = user_storage.ldbconfig(user)
    raw_types_to_odl = RawTypesToOdl(name, schema)
    odl = raw_types_to_odl.to_odl()

    f = tempfile.NamedTemporaryFile(delete=False, suffix='.odl')
    f.write("module %s {" % module)
    f.write(odl)
    f.write("};")
    f.close()

    logging.info("Create schema and data entries in %s Shore from ODL file %s ..." % (user, f.name))
    s, o = safecommands.getstatusoutput("LDBCONFIG=\"%s\" %s shore_append %s" % (ldbconfig, ODL_BIN, f.name))
    if s != 0:
        raise MetadataException("Failed during shore_insert of ODL file %s" % f.name)
    logging.info("...done")