def _raw_exchange_id(c, name, verf=None, cred=None, protect=None, flags=0): if verf is None: verf = c.verifier owner = client_owner4(verf, name) if protect is None: protect = state_protect4_a(SP4_NONE) return c.compound([op.exchange_id(owner, flags, protect, [c.impl_id])], cred)
def _simple_ops(t, env): """Produce a simple, valid ops sequence""" owner = client_owner4(env.c1.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) return [ op.exchange_id(owner, EXCHGID4_FLAG_USE_NON_PNFS, protect, [env.c1.impl_id]) ]
def _raw_exchange_id(c, name, verf=None, cred=None, protect=None, flags=0): if verf is None: verf = c.verifier owner = client_owner4(verf, name) if protect is None: protect = state_protect4_a(SP4_NONE) return c.compound([op.exchange_id(owner, flags, protect, [c.impl_id])], cred)
def testSupported1a(t, env): """EXCHANGE_ID with server only flag FLAGS: exchange_id all CODE: EID7 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, EXCHGID4_FLAG_USE_NON_PNFS | EXCHGID4_FLAG_CONFIRMED_R, protect, [c.impl_id])]) check(res, NFS4ERR_INVAL)
def testNoImplId(t, env): """Do a simple EXCHANGE_ID w/o setting client impl_id FLAGS: exchange_id all CODE: EID2 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, 0, protect, [])]) check(res)
def testNoImplId(t, env): """Do a simple EXCHANGE_ID w/o setting client impl_id FLAGS: exchange_id all CODE: EID2 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, 0, protect, [])]) check(res)
def testNotOnlyOp(t, env): """Check for NFS4ERR_NOT_ONLY_OP FLAGS: exchange_id all CODE: EID8 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, 0, protect, [c.impl_id]), op.putrootfh()]) # per draft 21 18.35.3, server MUST return NFS4ERR_NOT_ONLY_OP check(res, NFS4ERR_NOT_ONLY_OP)
def testUpdateNonexistant(t, env): """Do an EXCHANGE_ID update of a non-existant record FLAGS: exchange_id all CODE: EID6 """ # This is part of case 7 of draft 21 c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, EXCHGID4_FLAG_UPD_CONFIRMED_REC_A, protect, [c.impl_id])]) check(res, NFS4ERR_NOENT, "Update a non-existant record")
def testNotOnlyOp(t, env): """Check for NFS4ERR_NOT_ONLY_OP FLAGS: exchange_id all CODE: EID8 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound( [op.exchange_id(owner, 0, protect, [c.impl_id]), op.putrootfh()]) # per draft 21 18.35.3, server MUST return NFS4ERR_NOT_ONLY_OP check(res, NFS4ERR_NOT_ONLY_OP)
def testSupported(t, env): """Do a simple EXCHANGE_ID - no flags FLAGS: exchange_id all CODE: EID1 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, 0, protect, [c.impl_id])]) check(res) # per draft 21 13.1, server MUST set one of these bits if not (res.resarray[0].eir_flags & EXCHGID4_FLAG_MASK_PNFS): fail("server did not set any EXCHGID4_FLAG_USE_* bits")
def testSupported1a(t, env): """Do a simple EXCHANGE_ID - simple flag FLAGS: exchange_id all CODE: EID1a """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, EXCHGID4_FLAG_USE_NON_PNFS, protect, [c.impl_id])]) check(res) # per draft 21 13.1, server MUST set one of these bits if not (res.resarray[0].eir_flags & EXCHGID4_FLAG_MASK_PNFS): fail("server did not set any EXCHGID4_FLAG_USE_* bits")
def testUpdateNonexistant(t, env): """Do an EXCHANGE_ID update of a non-existant record FLAGS: exchange_id all CODE: EID6 """ # This is part of case 7 of draft 21 c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([ op.exchange_id(owner, EXCHGID4_FLAG_UPD_CONFIRMED_REC_A, protect, [c.impl_id]) ]) check(res, NFS4ERR_NOENT, "Update a non-existant record")
def testSupported1a(t, env): """EXCHANGE_ID with server only flag FLAGS: exchange_id all CODE: EID7 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([ op.exchange_id(owner, EXCHGID4_FLAG_USE_NON_PNFS | EXCHGID4_FLAG_CONFIRMED_R, protect, [c.impl_id]) ]) check(res, NFS4ERR_INVAL)
def testSupported2(t, env): """Do an EXCHANGE_ID from within a session FLAGS: exchange_id all CODE: EID1b """ c1 = env.c1.new_client("%s_1" % env.testname(t)) sess1 = c1.create_session() owner = client_owner4(sess1.c.verifier, "%s_2" % env.testname(t)) protect = state_protect4_a(SP4_NONE) res = sess1.compound([op.exchange_id(owner, EXCHGID4_FLAG_USE_PNFS_DS, protect, [sess1.c.impl_id])]) check(res) # per draft 21 13.1, server MUST set one of these bits if not (res.resarray[0].eir_flags & EXCHGID4_FLAG_MASK_PNFS): fail("server did not set any EXCHGID4_FLAG_USE_* bits")
def testBadFlags(t, env): """Using an undefined flag bit should return _INVAL draft21 18.35.3 line 26458: Bits not defined above should not be set in the eia_flags field. If they are, the server MUST reject the operation with NFS4ERR_INVAL. FLAGS: exchange_id all CODE: EID4 """ # STUB - want to send with various flags set c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, 4, protect, [c.impl_id])]) check(res, NFS4ERR_INVAL, "Using undefined flag bit 0x4")
def new_client(self, name, verf=None, cred=None, protect=None, flags=0, expect=NFS4_OK): """Establish a new client_id with the server""" if verf is None: verf = self.verifier owner = client_owner4(verf, name) if protect is None: protect = state_protect4_a(SP4_NONE) res = self.compound([op.exchange_id(owner, flags, protect, [self.impl_id])], cred) nfs4lib.check(res, expect) if expect == NFS4_OK: return ClientRecord(res.resarray[0], self, cred, protect) else: return None
def testBadFlags(t, env): """Using an undefined flag bit should return _INVAL draft21 18.35.3 line 26458: Bits not defined above should not be set in the eia_flags field. If they are, the server MUST reject the operation with NFS4ERR_INVAL. FLAGS: exchange_id all CODE: EID4 """ # STUB - want to send with various flags set c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) res = c.compound([op.exchange_id(owner, 4, protect, [c.impl_id])]) check(res, NFS4ERR_INVAL, "Using undefined flag bit 0x4")
def new_client(self, name, verf=None, cred=None, protect=None, flags=0, expect=NFS4_OK): """Establish a new client_id with the server""" if verf is None: verf = self.verifier owner = client_owner4(verf, name) if protect is None: protect = state_protect4_a(SP4_NONE) res = self.compound([op.exchange_id(owner, flags, protect, [self.impl_id])], cred) nfs4lib.check(res, expect) if expect == NFS4_OK: return ClientRecord(res.resarray[0], self, cred, protect) else: return None
def testSupported2(t, env): """Do an EXCHANGE_ID from within a session FLAGS: exchange_id all CODE: EID1b """ c1 = env.c1.new_client("%s_1" % env.testname(t)) sess1 = c1.create_session() owner = client_owner4(sess1.c.verifier, "%s_2" % env.testname(t)) protect = state_protect4_a(SP4_NONE) res = sess1.compound([ op.exchange_id(owner, EXCHGID4_FLAG_USE_PNFS_DS, protect, [sess1.c.impl_id]) ]) check(res) # per draft 21 13.1, server MUST set one of these bits if not (res.resarray[0].eir_flags & EXCHGID4_FLAG_MASK_PNFS): fail("server did not set any EXCHGID4_FLAG_USE_* bits")
def testLongArray(t, env): """Do a simple EXCHANGE_ID while setting impl_id array too long FLAGS: exchange_id all CODE: EID3 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) ops = [op.exchange_id(owner, 0, protect, [c.impl_id, c.impl_id])] xid = c.compound_async(ops, checks=False) try: res = c.listen(xid) print res except RPCAcceptError, e: if e.stat == GARBAGE_ARGS: # Legitimate return return else: raise
def testLongArray(t, env): """Do a simple EXCHANGE_ID while setting impl_id array too long FLAGS: exchange_id all CODE: EID3 """ c = env.c1 owner = client_owner4(c.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) ops = [op.exchange_id(owner, 0, protect, [c.impl_id, c.impl_id])] xid = c.compound_async(ops, checks=False) try: res = c.listen(xid) print res except RPCAcceptError, e: if e.stat == GARBAGE_ARGS: # Legitimate return return else: raise
def _simple_ops(t, env): """Produce a simple, valid ops sequence""" owner = client_owner4(env.c1.verifier, env.testname(t)) protect = state_protect4_a(SP4_NONE) return [op.exchange_id(owner, EXCHGID4_FLAG_USE_NON_PNFS, protect, [env.c1.impl_id])]