コード例 #1
0
def test_create_entity(conn):
    dn = "Network=TL,Node=001"

    with closing(conn.cursor()) as cursor:
        entity = helpers_v4.create_entity(cursor, dn)

    assert not entity is None
    assert entity.name == "001"
コード例 #2
0
def create_entity(conn, dn):
    """
    :param conn: A psycopg2 connection to a Minerva Directory database.
    :param dn: The distinguished name of the entity.
    """
    dnparts = splitparts(dn)

    if len(dnparts) == 0:
        raise Exception("Invalid DN: '{0}'".format(dn))

    with closing(conn.cursor()) as cursor:
        entity = helpers_v4.create_entity(cursor, dn)

    conn.commit()

    return entity