def rename_obj(sess, oldpath, newpath): olddir = lookup_obj(sess, oldpath[:-1]) newdir = lookup_obj(sess, newpath[:-1]) ops = [op.putfh(olddir), op.savefh()] ops += [op.putfh(newdir)] ops += [op.rename(oldpath[-1], newpath[-1])] return sess.compound(ops)
def rename_obj(sess, oldpath, newpath): # Set (sfh) to olddir ops = use_obj(oldpath[:-1]) + [op.savefh()] # Set (cfh) to newdir ops += use_obj(newpath[:-1]) # Call rename ops += [op.rename(oldpath[-1], newpath[-1])] return sess.compound(ops)
def testReplayCache007(t, env): """Send two successful non-idempotent compounds with same seqid and False cache_this FLAGS: sequence all CODE: SEQ10b """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, "%s_1" % env.testname(t)) check(res) ops = env.home + [op.savefh(),\ op.rename("%s_1" % env.testname(t), "%s_2" % env.testname(t))] res1 = sess1.compound(ops, cache_this=False) check(res1, NFS4_OK) res2 = sess1.compound(ops, seq_delta=0, cache_this=False) check(res2, NFS4ERR_RETRY_UNCACHED_REP)
def testReplayCache004(t, env): """Send two unsuccessful non-idempotent compounds with same seqid FLAGS: sequence all CODE: SEQ9d """ c1 = env.c1.new_client(env.testname(t)) sess1 = c1.create_session() ops = [op.putrootfh(), op.savefh(), op.rename("", "foo")] res1 = sess1.compound(ops, cache_this=True) check(res1, NFS4ERR_INVAL) res2 = sess1.compound(ops, seq_delta=0) check(res2, NFS4ERR_INVAL) res1.tag = res2.tag = "" if not nfs4lib.test_equal(res1, res2): fail("Replay results not equal")
def testOpenSaveFHLookupRestoreFHClose(t, env): """test current state id processing by having OPEN, SAVEFH, LOOKUP, RESTOREFH and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID10 """ sess1 = env.c1.new_client_session(env.testname(t)) fname = env.testname(t) open_op = open_create_file_op(sess1, fname, open_create=OPEN4_CREATE) lookup_op = env.home res = sess1.compound(lookup_op + [op.getfh()]) check(res) fh = res.resarray[-1].object res = sess1.compound(open_op + [op.savefh(), op.putfh(fh), op.restorefh(), op.close(0, current_stateid)]) check(res)
def testReplayCache002(t, env): """Send two successful non-idempotent compounds with same seqid FLAGS: sequence all CODE: SEQ9b """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, "%s_1" % env.testname(t)) check(res) ops = env.home + [op.savefh(),\ op.rename("%s_1" % env.testname(t), "%s_2" % env.testname(t))] res1 = sess1.compound(ops, cache_this=True) check(res1) res2 = sess1.compound(ops, seq_delta=0) check(res2) res1.tag = res2.tag = "" if not nfs4lib.test_equal(res1, res2): fail("Replay results not equal")
def link(sess, old, new): ops = use_obj(old) + [op.savefh()] ops += use_obj(new[:-1]) ops += [op.link(new[-1])] return sess.compound(ops)