def __init__(self, opts): self._lock = Lock() self.opts = opts self.c1 = nfs4client.NFS4Client(opts.server, opts.port, opts.minorversion) self.c2 = nfs4client.NFS4Client(opts.server, opts.port, opts.minorversion) self.c3 = nfs4client.NFS4Client(opts.server, opts.port, opts.minorversion) self.c4 = nfs4client.NFS4Client(opts.server, opts.port, opts.minorversion) s1 = rpc.security.instance(opts.flavor) if opts.flavor == rpc.AUTH_NONE: self.cred1 = s1.init_cred() elif opts.flavor == rpc.AUTH_SYS: self.cred1 = s1.init_cred(uid=opts.uid, gid=opts.gid, name=opts.machinename) elif opts.flavor == rpc.RPCSEC_GSS: call = self.c1.make_call_function(self.c1.c1, 0, self.c1.default_prog, self.c1.default_vers) krb5_cred = AuthGss().init_cred(call, target="nfs@%s" % opts.server) krb5_cred.service = opts.service self.cred1 = krb5_cred self.c1.set_cred(self.cred1) self.c2.set_cred(self.cred1) self.c3.set_cred(self.cred1) self.c4.set_cred(self.cred1) self.cred2 = AuthSys().init_cred(uid=1111, gid=37, name="shampoo") opts.home = opts.path + ['tmp'] self.c1.homedir = opts.home self.c2.homedir = opts.home self.c3.homedir = opts.home self.c4.homedir = opts.home # Put this after client creation, to ensure _last_verf bigger than # any natural client verifiers self.timestamp = int(time.time()) self._last_verf = self.timestamp + 1 self.filedata = "This is the file test data." self.linkdata = "/etc/X11" self.longname = "a" * 512 log.info("Created client to %s, %i" % (opts.server, opts.port))
def connect(self): # only support root with AUTH_SYS for now s1 = rpc.security.instance(rpc.AUTH_SYS) self.cred1 = s1.init_cred(uid=0, gid=0) self.c1 = nfs4client.NFS4Client(self.server, self.port) self.c1.set_cred(self.cred1) self.c1.null() c = self.c1.new_client("DS.init_%s" % self.server) # This is a hack to ensure MDS/DS communication path is at least # as wide as the client/MDS channel (at least for linux client) fore_attrs = channel_attrs4(0, 16384, 16384, 2868, 8, 8, []) self.sess = c.create_session(fore_attrs=fore_attrs) self.make_root()