print "Directories and files will be created" print "under <server><prefix>/nfs4st/" print print "<prefix> defaults to /, e.g. the directory nfs4st is" print "created directly under the server root" sys.exit(1) if __name__ == "__main__": if len(sys.argv) < 2: usage() parse_result = nfs4lib.parse_nfs_url(sys.argv[1]) if not parse_result: usage() (host, portstring, directory) = parse_result if portstring: port = int(portstring) else: port = nfs4lib.NFS_PORT if not directory: directory = "/" directory = os.path.join(directory, "nfs4st_tree") ncl = nfs4lib.create_client(host, 2049, "udp", uid=0, gid=0) main(ncl, directory)
else: parse_result = nfs4lib.parse_nfs_url(args[0]) if not parse_result: usage() (host, portstring, directory) = parse_result if portstring: port = int(portstring) else: port = nfs4lib.NFS_PORT if not directory: directory = "/" ncl = nfs4lib.create_client(host, port, transport, **kwargs) c = ClientApp(ncl, directory, pythonmode, debuglevel) commands = [] if commandstring: commands = commandstring.split(";") for command in commands: try: c.onecmd(command) except nfs4lib.BadCompoundRes, e: print e while 1: # do_* methods should preferrable handle errors themself. They can provide # much better error messages. This try-clause is a last resort.
#!/usr/bin/env python2 import nfs4lib ncl = nfs4lib.create_client("citi-1", 2049, "udp") operations = [] operations.append(ncl.putrootfh_op()) operations.extend(ncl.lookup_path(["nfs4st", "doc", "README"])) res = ncl.compound(operations)
print "Directories and files will be created" print "under <server><prefix>/nfs4st/" print print "<prefix> defaults to /, e.g. the directory nfs4st is" print "created directly under the server root" sys.exit(1) if __name__ == "__main__": if len(sys.argv) < 2: usage() parse_result = nfs4lib.parse_nfs_url(sys.argv[1]) if not parse_result: usage() (host, portstring, directory) = parse_result if portstring: port = int(portstring) else: port = nfs4lib.NFS_PORT if not directory: directory = "/" directory = os.path.join(directory, "nfs4st") ncl = nfs4lib.create_client(host, port, "auto", uid=0, gid=0) main(ncl, directory)