diff mbox

[pynfs,v2,04/16] move .x files to subdir 'xdrdef'

Message ID 1401976544-36374-5-git-send-email-dros@primarydata.com (mailing list archive)
State New, archived
Headers show

Commit Message

Weston Andros Adamson June 5, 2014, 1:55 p.m. UTC
In preparation for adding more .x files, clean up the main nfs4.1 dir
by moving these files (and autogenerated files) to a subdirectory.

Signed-off-by: Weston Andros Adamson <dros@primarydata.com>
---
 nfs4.1/block.py                             |  8 ++---
 nfs4.1/client41tests/environment.py         |  4 +--
 nfs4.1/config.py                            |  8 ++---
 nfs4.1/dataserver.py                        |  6 ++--
 nfs4.1/fs.py                                |  8 ++---
 nfs4.1/nfs4_ops.py                          |  4 +--
 nfs4.1/nfs4client.py                        | 11 +++---
 nfs4.1/nfs4commoncode.py                    | 10 +++---
 nfs4.1/nfs4lib.py                           | 54 ++++++++++++++---------------
 nfs4.1/nfs4server.py                        | 36 +++++++++----------
 nfs4.1/nfs4state.py                         |  6 ++--
 nfs4.1/server41tests/environment.py         |  4 +--
 nfs4.1/server41tests/st_block.py            |  4 +--
 nfs4.1/server41tests/st_compound.py         |  4 +--
 nfs4.1/server41tests/st_create_session.py   |  4 +--
 nfs4.1/server41tests/st_current_stateid.py  |  8 ++---
 nfs4.1/server41tests/st_debug.py            |  4 +--
 nfs4.1/server41tests/st_delegation.py       |  4 +--
 nfs4.1/server41tests/st_destroy_clientid.py |  2 +-
 nfs4.1/server41tests/st_destroy_session.py  |  4 +--
 nfs4.1/server41tests/st_exchange_id.py      |  4 +--
 nfs4.1/server41tests/st_getdevicelist.py    |  4 +--
 nfs4.1/server41tests/st_lookup.py           |  2 +-
 nfs4.1/server41tests/st_lookupp.py          |  2 +-
 nfs4.1/server41tests/st_open.py             |  8 ++---
 nfs4.1/server41tests/st_putfh.py            |  2 +-
 nfs4.1/server41tests/st_reboot.py           |  4 +--
 nfs4.1/server41tests/st_reclaim_complete.py |  2 +-
 nfs4.1/server41tests/st_rename.py           |  4 +--
 nfs4.1/server41tests/st_secinfo.py          |  4 +--
 nfs4.1/server41tests/st_secinfo_no_name.py  |  4 +--
 nfs4.1/server41tests/st_sequence.py         |  4 +--
 nfs4.1/server41tests/st_trunking.py         |  4 +--
 nfs4.1/server41tests/st_verify.py           |  2 +-
 nfs4.1/setup.py                             | 33 ++++++++++--------
 nfs4.1/testclient.py                        |  2 +-
 nfs4.1/testserver.py                        |  2 +-
 nfs4.1/xdrdef/__init__.py                   |  0
 nfs4.1/{ => xdrdef}/nfs4.x                  |  0
 nfs4.1/{ => xdrdef}/nfs4.x.diff             |  0
 nfs4.1/{ => xdrdef}/pnfs_block.x            |  0
 nfs4.1/{ => xdrdef}/sctrl.x                 |  0
 42 files changed, 141 insertions(+), 139 deletions(-)
 create mode 100644 nfs4.1/xdrdef/__init__.py
 rename nfs4.1/{ => xdrdef}/nfs4.x (100%)
 rename nfs4.1/{ => xdrdef}/nfs4.x.diff (100%)
 rename nfs4.1/{ => xdrdef}/pnfs_block.x (100%)
 rename nfs4.1/{ => xdrdef}/sctrl.x (100%)

diff --git a/nfs4.1/xdrdef/__init__.py b/nfs4.1/xdrdef/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/nfs4.1/nfs4.x b/nfs4.1/xdrdef/nfs4.x
similarity index 100%
rename from nfs4.1/nfs4.x
rename to nfs4.1/xdrdef/nfs4.x
diff --git a/nfs4.1/nfs4.x.diff b/nfs4.1/xdrdef/nfs4.x.diff
similarity index 100%
rename from nfs4.1/nfs4.x.diff
rename to nfs4.1/xdrdef/nfs4.x.diff
diff --git a/nfs4.1/pnfs_block.x b/nfs4.1/xdrdef/pnfs_block.x
similarity index 100%
rename from nfs4.1/pnfs_block.x
rename to nfs4.1/xdrdef/pnfs_block.x
diff --git a/nfs4.1/sctrl.x b/nfs4.1/xdrdef/sctrl.x
similarity index 100%
rename from nfs4.1/sctrl.x
rename to nfs4.1/xdrdef/sctrl.x
diff mbox

Patch

diff --git a/nfs4.1/block.py b/nfs4.1/block.py
index 2201550..f37bd9b 100644
--- a/nfs4.1/block.py
+++ b/nfs4.1/block.py
@@ -1,8 +1,8 @@ 
 from __future__ import with_statement
-from pnfs_block_pack import PNFS_BLOCKPacker as Packer
-from pnfs_block_pack import PNFS_BLOCKUnpacker as Unpacker
-from pnfs_block_type import *
-from pnfs_block_const import *
+from xdrdef.pnfs_block_pack import PNFS_BLOCKPacker as Packer
+from xdrdef.pnfs_block_pack import PNFS_BLOCKUnpacker as Unpacker
+from xdrdef.pnfs_block_type import *
+from xdrdef.pnfs_block_const import *
 
 import fs_base
 from threading import Lock
diff --git a/nfs4.1/client41tests/environment.py b/nfs4.1/client41tests/environment.py
index 84b7d38..225197f 100644
--- a/nfs4.1/client41tests/environment.py
+++ b/nfs4.1/client41tests/environment.py
@@ -10,8 +10,8 @@ 
 
 import time
 import testmod
-from nfs4_const import *
-from nfs4_type import *
+from xdrdef.nfs4_const import *
+from xdrdef.nfs4_type import *
 import rpc
 import nfs4client
 import os
diff --git a/nfs4.1/config.py b/nfs4.1/config.py
index 2238aee..4747f73 100644
--- a/nfs4.1/config.py
+++ b/nfs4.1/config.py
@@ -1,6 +1,6 @@ 
-from nfs4_type import server_owner4, nfs_impl_id4
-from nfs4_const import *
-import nfs4_const
+from xdrdef.nfs4_type import server_owner4, nfs_impl_id4
+from xdrdef.nfs4_const import *
+import xdrdef.nfs4_const
 import nfs4lib
 from copy import deepcopy
 import os
@@ -37,7 +37,7 @@  def _statcode(value):
     try:
         return int(value)
     except ValueError:
-        rv = getattr(nfs4_const, value, None)
+        rv = getattr(xdr.nfs4_const, value, None)
         if rv is None or nfsstat4.get(rv, None) != value:
             raise
         else:
diff --git a/nfs4.1/dataserver.py b/nfs4.1/dataserver.py
index 435ddd2..acca210 100644
--- a/nfs4.1/dataserver.py
+++ b/nfs4.1/dataserver.py
@@ -1,8 +1,8 @@ 
 import rpc
 import nfs4lib
-from nfs4_type import *
-from nfs4_pack import NFS4Packer
-from nfs4_const import *
+from xdrdef.nfs4_type import *
+from xdrdef.nfs4_pack import NFS4Packer
+from xdrdef.nfs4_const import *
 import time
 import logging
 import nfs4client
diff --git a/nfs4.1/fs.py b/nfs4.1/fs.py
index a63c5bf..3d63ce5 100644
--- a/nfs4.1/fs.py
+++ b/nfs4.1/fs.py
@@ -1,6 +1,6 @@ 
 from nfs4state import FileState
-from nfs4_const import *
-from nfs4_type import fsid4, layout4, layout_content4, nfsv4_1_file_layout4
+from xdrdef.nfs4_const import *
+from xdrdef.nfs4_type import fsid4, layout4, layout_content4, nfsv4_1_file_layout4
 import nfs4lib
 from nfs4lib import NFS4Error
 import struct
@@ -8,7 +8,7 @@  import logging
 from locking import Lock, RWLock
 from cStringIO import StringIO
 import time
-from nfs4_pack import NFS4Packer
+from xdrdef.nfs4_pack import NFS4Packer
 
 log_o = logging.getLogger("fs.obj")
 log_fs = logging.getLogger("fs")
@@ -1070,7 +1070,7 @@  class StubFS_Disk(FileSystem):
 
 ###################################################
 
-from pnfs_block_type import pnfs_block_extent4, pnfs_block_layout4
+from xdrdef.pnfs_block_type import pnfs_block_extent4, pnfs_block_layout4
 import block
 
 class my_ro_extent(object):
diff --git a/nfs4.1/nfs4_ops.py b/nfs4.1/nfs4_ops.py
index 75381b6..35a10ca 100644
--- a/nfs4.1/nfs4_ops.py
+++ b/nfs4.1/nfs4_ops.py
@@ -2,8 +2,8 @@ 
 <name>() that returns the appropriate *_argop4 structure, hiding
 this routine packing from the user.
 """
-import nfs4_type as _type
-import nfs4_const as _const
+import xdrdef.nfs4_type as _type
+import xdrdef.nfs4_const as _const
 
 # This string is our general function template
 code = """\
diff --git a/nfs4.1/nfs4client.py b/nfs4.1/nfs4client.py
index e750728..2aa0a2c 100644
--- a/nfs4.1/nfs4client.py
+++ b/nfs4.1/nfs4client.py
@@ -2,10 +2,9 @@  import use_local # HACK so don't have to rebuild constantly
 import rpc
 import nfs4lib
 from nfs4lib import NFS4Error, NFS4Replay, inc_u32
-import nfs4_type, nfs4_const
-from nfs4_type import *
-from nfs4_const import *
-from sctrl_pack import SCTRLPacker, SCTRLUnpacker
+from xdrdef.nfs4_type import *
+from xdrdef.nfs4_const import *
+from xdrdef.sctrl_pack import SCTRLPacker, SCTRLUnpacker
 import nfs4_ops as op
 import time, struct
 import threading
@@ -545,8 +544,8 @@  sec.init_cred(call)
 
 """ EXCHANGE_ID
 import nfs4client
-from nfs4_type import *
-from nfs4_const import *
+from xdrdef.nfs4_type import *
+from xdrdef.nfs4_const import *
 import nfs4_ops as op
 owner = client_owner4("12345678","MyClientName")
 protect = state_protect4_a(SP4_NONE)
diff --git a/nfs4.1/nfs4commoncode.py b/nfs4.1/nfs4commoncode.py
index 317f04c..cadd237 100644
--- a/nfs4.1/nfs4commoncode.py
+++ b/nfs4.1/nfs4commoncode.py
@@ -4,10 +4,10 @@ 
 """
 
 import nfs4lib
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 import sys
-import nfs4_type, nfs4_const
-from nfs4_type import *
+import xdrdef.nfs4_type, xdrdef.nfs4_const
+from xdrdef.nfs4_type import *
 
 _d = {"CompoundState" : "CompoundState",
       "PairedResults" : "PairedResults",
@@ -34,8 +34,8 @@  def %(encode_status)s_by_name(name, status, *args, **kwargs):
     name_l = name.lower()
     name_u = name.upper()
     try:
-        res4 = getattr(nfs4_type, name_u + "4res")(status, *args, **kwargs)
-        result = %(nfs_resop4)s(getattr(nfs4_const, "OP_" + name_u))
+        res4 = getattr(xdrdef.nfs4_type, name_u + "4res")(status, *args, **kwargs)
+        result = %(nfs_resop4)s(getattr(xdrdef.nfs4_const, "OP_" + name_u))
         setattr(result, %(mangle)s, res4)
         # STUB XXX 4.1 has messed with the naming conventions,
         #      and added prefixes to the "status" variable. Grrr.
diff --git a/nfs4.1/nfs4lib.py b/nfs4.1/nfs4lib.py
index d1edc10..116324a 100644
--- a/nfs4.1/nfs4lib.py
+++ b/nfs4.1/nfs4lib.py
@@ -1,8 +1,8 @@ 
 from __future__ import with_statement
 import rpc
-import nfs4_const
-import nfs4_pack
-import nfs4_type
+import xdrdef.nfs4_const
+from xdrdef.nfs4_pack import NFS4Packer, NFS4Unpacker
+import xdrdef.nfs4_type
 import nfs4_ops as op
 import time
 import collections
@@ -24,9 +24,9 @@  except ImportError:
             raise NotImplementedError("could not import Crypto.Cipher")
 
 # Special stateids
-state00 = nfs4_type.stateid4(0, "\0" * 12)
-state11 = nfs4_type.stateid4(0xffffffff, "\xff" * 12)
-state01 = nfs4_type.stateid4(1, "\0" * 12)
+state00 = xdrdef.nfs4_type.stateid4(0, "\0" * 12)
+state11 = xdrdef.nfs4_type.stateid4(0xffffffff, "\xff" * 12)
+state01 = xdrdef.nfs4_type.stateid4(1, "\0" * 12)
 
 import hashlib # Note this requires 2.5 or higher
 
@@ -105,9 +105,9 @@  def set_attrbit_dicts():
             { 1: "unpack_fattr4_type", 2: "unpack_fattr4_fh_expire_type", ...}
     """
     global attr2bitnum, bitnum2attr, bitnum2packer, bitnum2unpacker
-    for name in dir(nfs4_const):
+    for name in dir(xdrdef.nfs4_const):
         if name.startswith("FATTR4_"):
-            value = getattr(nfs4_const, name)
+            value = getattr(xdrdef.nfs4_const, name)
             # Sanity checking. Must be integer. 
             assert(type(value) is int)
             attrname = name[7:].lower()
@@ -130,9 +130,9 @@  def set_flags(name, search_string=None):
     mask = 0
     if search_string is None:
         search_string = "%s4_FLAG_" % name.upper()
-    for var in dir(nfs4_const):
+    for var in dir(xdrdef.nfs4_const):
         if var.startswith(search_string):
-            value = getattr(nfs4_const, var)
+            value = getattr(xdrdef.nfs4_const, var)
             flag_dict[value] = var
             mask |= value
     # Now we need to set the appropriate module level variable
@@ -187,7 +187,7 @@  class InvalidCompoundRes(NFSException):
         else:
             return "Invalid COMPOUND result"
 
-class FancyNFS4Packer(nfs4_pack.NFS4Packer):
+class FancyNFS4Packer(NFS4Packer):
     """Handle fattr4 and dirlist4 more cleanly than auto-generated methods"""
     def filter_bitmap4(self, data):
         out = []
@@ -208,11 +208,11 @@  class FancyNFS4Packer(nfs4_pack.NFS4Packer):
         for e in data.entries[::-1]:
             # print "handle", e
             # This reverses the direction of the list, so start with reversed
-            out = [nfs4_type.entry4(e.cookie, e.name, e.attrs, out)]
+            out = [xdrdef.nfs4_type.entry4(e.cookie, e.name, e.attrs, out)]
         # Must not modify original data structure
-        return nfs4_type.dirlist4(out, data.eof)
+        return xdrdef.nfs4_type.dirlist4(out, data.eof)
 
-class FancyNFS4Unpacker(nfs4_pack.NFS4Unpacker):
+class FancyNFS4Unpacker(NFS4Unpacker):
     def filter_bitmap4(self, data):
         """Put bitmap into single long, instead of array of 32bit chunks"""
         out = 0L
@@ -257,7 +257,7 @@  def dict2fattr(dict):
         getattr(packer, bitnum2packer[bitnum])(value)
         attr_vals += packer.get_buffer()
     attrmask = list2bitmap(attrs)
-    return nfs4_type.fattr4(attrmask, attr_vals); 
+    return xdrdef.nfs4_type.fattr4(attrmask, attr_vals); 
 
 def fattr2dict(obj):
     """Convert a fattr4 object to a dictionary with attribute name and values.
@@ -360,10 +360,10 @@  class SSVContext(object):
         """Compute getMIC token from given data"""
         # See draft26 2.10.9
         p = FancyNFS4Packer()
-        p.pack_ssv_mic_plain_tkn4(nfs4_type.ssv_mic_plain_tkn4(seqnum, data))
+        p.pack_ssv_mic_plain_tkn4(xdrdef.nfs4_type.ssv_mic_plain_tkn4(seqnum, data))
         hash = hmac.new(key, p.get_buffer(), self.hash).digest()
         p.reset()
-        p.pack_ssv_mic_tkn4(nfs4_type.ssv_mic_tkn4(seqnum, hash))
+        p.pack_ssv_mic_tkn4(xdrdef.nfs4_type.ssv_mic_tkn4(seqnum, hash))
         return p.get_buffer()
 
     def getMIC(self, data):
@@ -405,13 +405,13 @@  class SSVContext(object):
         p = FancyNFS4Packer()
         # We need to compute pad.  Easiest (though not fastest) way
         # is to pack w/o padding, determine padding needed, then repack.
-        input = nfs4_type.ssv_seal_plain_tkn4(cofounder, seqnum, data, "")
+        input = xdrdef.nfs4_type.ssv_seal_plain_tkn4(cofounder, seqnum, data, "")
         p.pack_ssv_seal_plain_tkn4(input)
         offset = len(p.get_buffer()) % blocksize
         if offset:
             pad = '\0' * (blocksize - offset)
             p.reset()
-            input = nfs4_type.ssv_seal_plain_tkn4(cofounder, seqnum, data, pad)
+            input = xdrdef.nfs4_type.ssv_seal_plain_tkn4(cofounder, seqnum, data, pad)
             p.pack_ssv_seal_plain_tkn4(input)
         plain_xdr = p.get_buffer()
         p.reset()
@@ -421,7 +421,7 @@  class SSVContext(object):
         encrypted = obj.encrypt(plain_xdr)
         dir = (SSV4_SUBKEY_MIC_I2T if self.local else SSV4_SUBKEY_MIC_T2I)
         hash = hmac.new(keys[dir], plain_xdr, self.hash).digest()
-        token = nfs4_type.ssv_seal_cipher_tkn4(seqnum, iv, encrypted, hash)
+        token = xdrdef.nfs4_type.ssv_seal_cipher_tkn4(seqnum, iv, encrypted, hash)
         p.pack_ssv_seal_cipher_tkn4(token)
         return p.get_buffer()
 
@@ -491,7 +491,7 @@  def get_nfstime(t=None):
         t = time.time()
     sec = int(t)
     nsec = int((t - sec) * 1000000000)
-    return nfs4_type.nfstime4(sec, nsec)
+    return xdrdef.nfs4_type.nfstime4(sec, nsec)
 
 def parse_nfs_url(url):
     """Parse [nfs://]host:port/path, format taken from rfc 2224
@@ -565,7 +565,7 @@  def attr_name(bitnum):
 class NFS4Error(Exception):
     def __init__(self, status, attrs=0L, lock_denied=None, tag=None, check_msg=None):
         self.status = status
-        self.name = nfs4_const.nfsstat4[status]
+        self.name = xdrdef.nfs4_const.nfsstat4[status]
         if check_msg is None:
             self.msg = "NFS4 error code: %s" % self.name
         else:
@@ -602,19 +602,19 @@  class NFS4Principal(object):
     def __ne__(self, other):
         return not self.__eq__(other)
 
-def check(res, expect=nfs4_const.NFS4_OK, msg=None):
+def check(res, expect=xdrdef.nfs4_const.NFS4_OK, msg=None):
     if res.status == expect:
         return
     if type(expect) is str:
         raise RuntimeError("You forgot to put 'msg=' in front "
                            "of check()'s string arg")
     # Get text representations
-    desired = nfs4_const.nfsstat4[expect]
-    received = nfs4_const.nfsstat4[res.status]
+    desired = xdrdef.nfs4_const.nfsstat4[expect]
+    received = xdrdef.nfs4_const.nfsstat4[res.status]
     if msg:
         failedop_name = msg
     elif res.resarray:
-        failedop_name = nfs4_const.nfs_opnum4[res.resarray[-1].resop]
+        failedop_name = xdrdef.nfs4_const.nfs_opnum4[res.resarray[-1].resop]
     else:
         failedop_name = 'Compound'
     msg = "%s should return %s, instead got %s" % \
@@ -647,7 +647,7 @@  class AttrConfig(object):
         self._s = (kind=="serv")
         self._fs = (kind=="fs")
     
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 
 A = AttrConfig
 attr_info = { FATTR4_SUPPORTED_ATTRS : A("r", "fs"),
diff --git a/nfs4.1/nfs4server.py b/nfs4.1/nfs4server.py
index 65fb9af..2ae99fe 100755
--- a/nfs4.1/nfs4server.py
+++ b/nfs4.1/nfs4server.py
@@ -4,10 +4,10 @@  import use_local # HACK so don't have to rebuild constantly
 import nfs4lib
 from nfs4lib import inc_u32, NFS4Error, NFS4Replay
 import rpc
-from nfs4_const import *
-from nfs4_type import *
-from sctrl_pack import SCTRLPacker, SCTRLUnpacker
-import sctrl_type, sctrl_const
+from xdrdef.nfs4_const import *
+from xdrdef.nfs4_type import *
+from xdrdef.sctrl_pack import SCTRLPacker, SCTRLUnpacker
+import xdrdef.sctrl_type, xdrdef.sctrl_const
 import traceback, threading
 from locking import Lock, Counter
 import time
@@ -620,7 +620,7 @@  class NFS4Server(rpc.Server):
             return rpc.GARBAGE_ARGS, None
         log_cfg.info(repr(args))
         # Handle the given control operation
-        opname = sctrl_const.ctrl_opnum.get(args.ctrlop, 'ctrl_illegal')
+        opname = xdrdef.sctrl_const.ctrl_opnum.get(args.ctrlop, 'ctrl_illegal')
         funct = getattr(self, opname.lower(), None)
         if funct is None:
             # This shouldn't happen
@@ -633,8 +633,8 @@  class NFS4Server(rpc.Server):
             raise
         # Now pack and return the result
         p = SCTRLPacker()
-        # res = sctrl_type.CTRLres(status, sctrl_type.resdata_t(args.ctrlop))
-        res = sctrl_type.CTRLres(status, result)
+        # res = xdrdef.sctrl_type.CTRLres(status, xdrdef.sctrl_type.resdata_t(args.ctrlop))
+        res = xdrdef.sctrl_type.CTRLres(status, result)
         p.pack_CTRLres(res)
         return rpc.SUCCESS, p.get_buffer()
 
@@ -1926,22 +1926,22 @@  class NFS4Server(rpc.Server):
 
     def ctrl_reset(self, arg):
         self.recording.reset()
-        return sctrl_const.CTRLSTAT_OK, sctrl_type.resdata_t(arg.ctrlop)
+        return xdrdef.sctrl_const.CTRLSTAT_OK, xdrdef.sctrl_type.resdata_t(arg.ctrlop)
 
     def ctrl_record(self, arg):
         self.recording.set_stamp(arg.stamp)
         self.recording.on = True
-        return sctrl_const.CTRLSTAT_OK, sctrl_type.resdata_t(arg.ctrlop)
+        return xdrdef.sctrl_const.CTRLSTAT_OK, xdrdef.sctrl_type.resdata_t(arg.ctrlop)
 
     def ctrl_pause(self, arg):
         self.recording.on = False
-        return sctrl_const.CTRLSTAT_OK, sctrl_type.resdata_t(arg.ctrlop)
+        return xdrdef.sctrl_const.CTRLSTAT_OK, xdrdef.sctrl_type.resdata_t(arg.ctrlop)
 
     def ctrl_grab(self, arg):
         queue = self.recording.queues.get(arg.stamp, None)
         if queue is None:
-            return sctrl_const.CTRLSTAT_NOT_AVAIL, \
-                   sctrl_type.resdata_t(arg.ctrlop, sctrl_type.GRABres([],[]))
+            return xdrdef.sctrl_const.CTRLSTAT_NOT_AVAIL, \
+                   xdrdef.sctrl_type.resdata_t(arg.ctrlop, xdrdef.sctrl_type.GRABres([],[]))
         max = arg.number
         if max == 0:
             max = len(queue)
@@ -1949,19 +1949,19 @@  class NFS4Server(rpc.Server):
         replies = []
         for i in range(max):
             call, reply = queue.pop()
-            if arg.dir & sctrl_const.DIR_CALL:
+            if arg.dir & xdrdef.sctrl_const.DIR_CALL:
                 calls.append(call)
-            if arg.dir & sctrl_const.DIR_REPLY:
+            if arg.dir & xdrdef.sctrl_const.DIR_REPLY:
                 replies.append(reply)
         print calls
         print replies
-        grabres = sctrl_type.GRABres(calls, replies)
-        return sctrl_const.CTRLSTAT_OK, \
-               sctrl_type.resdata_t(arg.ctrlop, grab = grabres)
+        grabres = xdrdef.sctrl_type.GRABres(calls, replies)
+        return xdrdef.sctrl_const.CTRLSTAT_OK, \
+               xdrdef.sctrl_type.resdata_t(arg.ctrlop, grab = grabres)
 
     def ctrl_illegal(self, arg):
         print "ILLEGAL"
-        return sctrl_const.CTRLSTAT_ILLEGAL, sctrl_type.resdata_t(arg.ctrlop)
+        return xdrdef.sctrl_const.CTRLSTAT_ILLEGAL, xdrdef.sctrl_type.resdata_t(arg.ctrlop)
         
     def op_setclientid(self, arg, env):
         return encode_status(NFS4ERR_NOTSUPP)
diff --git a/nfs4.1/nfs4state.py b/nfs4.1/nfs4state.py
index e8445e3..1294083 100644
--- a/nfs4.1/nfs4state.py
+++ b/nfs4.1/nfs4state.py
@@ -5,9 +5,9 @@  from locking import Lock
 import struct
 import nfs4lib
 from nfs4lib import NFS4Error
-#from nfs4_type import stateid4
-from nfs4_type import *
-from nfs4_const import *
+#from xdrdef.nfs4_type import stateid4
+from xdrdef.nfs4_type import *
+from xdrdef.nfs4_const import *
 import nfs4_ops as op
 import rpc
 import logging
diff --git a/nfs4.1/server41tests/environment.py b/nfs4.1/server41tests/environment.py
index b2df732..b8b05cf 100644
--- a/nfs4.1/server41tests/environment.py
+++ b/nfs4.1/server41tests/environment.py
@@ -10,8 +10,8 @@ 
 
 import time
 import testmod
-from nfs4_const import *
-from nfs4_type import *
+from xdrdef.nfs4_const import *
+from xdrdef.nfs4_type import *
 import rpc
 import nfs4client
 import sys
diff --git a/nfs4.1/server41tests/st_block.py b/nfs4.1/server41tests/st_block.py
index f62968e..432dbbf 100644
--- a/nfs4.1/server41tests/st_block.py
+++ b/nfs4.1/server41tests/st_block.py
@@ -1,5 +1,5 @@ 
-from nfs4_const import *
-from nfs4_type import *
+from xdrdef.nfs4_const import *
+from xdrdef.nfs4_type import *
 import nfs4_ops as op
 from environment import check, fail, create_file
 from block import Packer as BlockPacker, Unpacker as BlockUnpacker, \
diff --git a/nfs4.1/server41tests/st_compound.py b/nfs4.1/server41tests/st_compound.py
index c6a5ea9..0443a29 100644
--- a/nfs4.1/server41tests/st_compound.py
+++ b/nfs4.1/server41tests/st_compound.py
@@ -1,7 +1,7 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 import nfs4_ops as op
 from environment import check, fail, get_invalid_utf8strings
-from nfs4_type import *
+from xdrdef.nfs4_type import *
 from rpc import RPCAcceptError, GARBAGE_ARGS, RPCTimeout
 from nfs4lib import NFS4Error, hash_oids, encrypt_oids, FancyNFS4Packer
 
diff --git a/nfs4.1/server41tests/st_create_session.py b/nfs4.1/server41tests/st_create_session.py
index ae5ca27..4685eb0 100644
--- a/nfs4.1/server41tests/st_create_session.py
+++ b/nfs4.1/server41tests/st_create_session.py
@@ -1,7 +1,7 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 import nfs4_ops as op
 from environment import check, fail, create_file, open_file
-from nfs4_type import *
+from xdrdef.nfs4_type import *
 import random
 import nfs4lib
 import threading
diff --git a/nfs4.1/server41tests/st_current_stateid.py b/nfs4.1/server41tests/st_current_stateid.py
index 9a1adc4..b2e69c5 100644
--- a/nfs4.1/server41tests/st_current_stateid.py
+++ b/nfs4.1/server41tests/st_current_stateid.py
@@ -1,11 +1,11 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 
 from environment import check, checklist, fail, create_file, open_file, close_file
 from environment import open_create_file_op, use_obj
-from nfs4_type import open_owner4, openflag4, createhow4, open_claim4
-from nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4
-from nfs4_type import open_to_lock_owner4
+from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4
+from xdrdef.nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4
+from xdrdef.nfs4_type import open_to_lock_owner4
 import nfs4_ops as op
 import threading
 
diff --git a/nfs4.1/server41tests/st_debug.py b/nfs4.1/server41tests/st_debug.py
index aff6842..7bf6b5b 100644
--- a/nfs4.1/server41tests/st_debug.py
+++ b/nfs4.1/server41tests/st_debug.py
@@ -1,7 +1,7 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail, create_file
-from nfs4_type import open_owner4, openflag4, createhow4, open_claim4
+from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4
 import nfs4_ops as op
 import threading
 
diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
index 02ce719..5abc904 100644
--- a/nfs4.1/server41tests/st_delegation.py
+++ b/nfs4.1/server41tests/st_delegation.py
@@ -1,9 +1,9 @@ 
 from st_create_session import create_session
 from st_open import open_claim4
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 
 from environment import check, checklist, fail, create_file, open_file, close_file
-from nfs4_type import *
+from xdrdef.nfs4_type import *
 import nfs4_ops as op
 import nfs4lib
 import threading
diff --git a/nfs4.1/server41tests/st_destroy_clientid.py b/nfs4.1/server41tests/st_destroy_clientid.py
index 1b193cf..6b7042f 100644
--- a/nfs4.1/server41tests/st_destroy_clientid.py
+++ b/nfs4.1/server41tests/st_destroy_clientid.py
@@ -1,5 +1,5 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail
 import nfs4_ops as op
 import nfs4lib
diff --git a/nfs4.1/server41tests/st_destroy_session.py b/nfs4.1/server41tests/st_destroy_session.py
index f4f0762..e3c3424 100644
--- a/nfs4.1/server41tests/st_destroy_session.py
+++ b/nfs4.1/server41tests/st_destroy_session.py
@@ -1,7 +1,7 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, checklist, fail, create_file, open_file
-from nfs4_type import open_owner4, openflag4, createhow4, open_claim4
+from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4
 import nfs4_ops as op
 import threading
 import rpc
diff --git a/nfs4.1/server41tests/st_exchange_id.py b/nfs4.1/server41tests/st_exchange_id.py
index 956090f..39b8b0c 100644
--- a/nfs4.1/server41tests/st_exchange_id.py
+++ b/nfs4.1/server41tests/st_exchange_id.py
@@ -1,8 +1,8 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 import nfs4_ops as op
 import time
 from environment import check, checklist, fail
-from nfs4_type import *
+from xdrdef.nfs4_type import *
 from rpc import RPCAcceptError, GARBAGE_ARGS, RPCTimeout
 from nfs4lib import NFS4Error, hash_oids, encrypt_oids
 
diff --git a/nfs4.1/server41tests/st_getdevicelist.py b/nfs4.1/server41tests/st_getdevicelist.py
index 7a10c6c..df0107d 100644
--- a/nfs4.1/server41tests/st_getdevicelist.py
+++ b/nfs4.1/server41tests/st_getdevicelist.py
@@ -1,5 +1,5 @@ 
-from nfs4_const import *
-from nfs4_type import *
+from xdrdef.nfs4_const import *
+from xdrdef.nfs4_type import *
 from environment import check, fail, use_obj, open_file, create_file
 import nfs4_ops as op
 from block import Packer as BlockPacker, Unpacker as BlockUnpacker, \
diff --git a/nfs4.1/server41tests/st_lookup.py b/nfs4.1/server41tests/st_lookup.py
index 33e06b9..85ddcfe 100644
--- a/nfs4.1/server41tests/st_lookup.py
+++ b/nfs4.1/server41tests/st_lookup.py
@@ -1,4 +1,4 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail
 import nfs4_ops as op
 
diff --git a/nfs4.1/server41tests/st_lookupp.py b/nfs4.1/server41tests/st_lookupp.py
index 512ea6b..7aa7406 100644
--- a/nfs4.1/server41tests/st_lookupp.py
+++ b/nfs4.1/server41tests/st_lookupp.py
@@ -1,4 +1,4 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail, use_obj
 import nfs4_ops as op
 
diff --git a/nfs4.1/server41tests/st_open.py b/nfs4.1/server41tests/st_open.py
index 2ec646f..71e01fb 100644
--- a/nfs4.1/server41tests/st_open.py
+++ b/nfs4.1/server41tests/st_open.py
@@ -1,11 +1,11 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 
 from environment import check, checklist, fail, create_file, open_file, close_file
 from environment import open_create_file_op
-from nfs4_type import open_owner4, openflag4, createhow4, open_claim4
-from nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4
-from nfs4_type import open_to_lock_owner4
+from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4
+from xdrdef.nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4
+from xdrdef.nfs4_type import open_to_lock_owner4
 import nfs4_ops as op
 import threading
 
diff --git a/nfs4.1/server41tests/st_putfh.py b/nfs4.1/server41tests/st_putfh.py
index d7bc0be..6d96048 100644
--- a/nfs4.1/server41tests/st_putfh.py
+++ b/nfs4.1/server41tests/st_putfh.py
@@ -1,4 +1,4 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail, use_obj, create_confirm, close_file
 import nfs4_ops as op
 
diff --git a/nfs4.1/server41tests/st_reboot.py b/nfs4.1/server41tests/st_reboot.py
index bbfc40e..b778fd7 100644
--- a/nfs4.1/server41tests/st_reboot.py
+++ b/nfs4.1/server41tests/st_reboot.py
@@ -1,5 +1,5 @@ 
-from nfs4_const import *
-from nfs4_type import *
+from xdrdef.nfs4_const import *
+from xdrdef.nfs4_type import *
 from environment import check, checklist, fail, create_file, open_file, create_confirm
 import sys
 import os
diff --git a/nfs4.1/server41tests/st_reclaim_complete.py b/nfs4.1/server41tests/st_reclaim_complete.py
index f6baf09..1d9270f 100644
--- a/nfs4.1/server41tests/st_reclaim_complete.py
+++ b/nfs4.1/server41tests/st_reclaim_complete.py
@@ -1,5 +1,5 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail, open_file, create_file, create_confirm
 import nfs4_ops as op
 import nfs4lib
diff --git a/nfs4.1/server41tests/st_rename.py b/nfs4.1/server41tests/st_rename.py
index 943587c..51b6cd6 100644
--- a/nfs4.1/server41tests/st_rename.py
+++ b/nfs4.1/server41tests/st_rename.py
@@ -1,7 +1,7 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, checklist, fail, maketree, rename_obj, get_invalid_utf8strings, create_obj, create_confirm, link, use_obj, create_file
 import nfs4_ops as op
-from nfs4_type import *
+from xdrdef.nfs4_type import *
 
 def testValidDir(t, env):
     """RENAME : normal operation
diff --git a/nfs4.1/server41tests/st_secinfo.py b/nfs4.1/server41tests/st_secinfo.py
index d9a1e98..b676edc 100644
--- a/nfs4.1/server41tests/st_secinfo.py
+++ b/nfs4.1/server41tests/st_secinfo.py
@@ -1,7 +1,7 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail, use_obj, bad_sessionid, create_file
-from nfs4_type import channel_attrs4
+from xdrdef.nfs4_type import channel_attrs4
 import nfs4_ops as op
 import nfs4lib
 
diff --git a/nfs4.1/server41tests/st_secinfo_no_name.py b/nfs4.1/server41tests/st_secinfo_no_name.py
index ada4853..2f8ee1b 100644
--- a/nfs4.1/server41tests/st_secinfo_no_name.py
+++ b/nfs4.1/server41tests/st_secinfo_no_name.py
@@ -1,7 +1,7 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail, bad_sessionid, create_file
-from nfs4_type import channel_attrs4
+from xdrdef.nfs4_type import channel_attrs4
 import nfs4_ops as op
 import nfs4lib
 
diff --git a/nfs4.1/server41tests/st_sequence.py b/nfs4.1/server41tests/st_sequence.py
index 96f5e42..e21bf7d 100644
--- a/nfs4.1/server41tests/st_sequence.py
+++ b/nfs4.1/server41tests/st_sequence.py
@@ -1,7 +1,7 @@ 
 from st_create_session import create_session
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 from environment import check, fail, bad_sessionid, create_file
-from nfs4_type import channel_attrs4
+from xdrdef.nfs4_type import channel_attrs4
 import nfs4_ops as op
 import nfs4lib
 
diff --git a/nfs4.1/server41tests/st_trunking.py b/nfs4.1/server41tests/st_trunking.py
index b984425..142b924 100644
--- a/nfs4.1/server41tests/st_trunking.py
+++ b/nfs4.1/server41tests/st_trunking.py
@@ -1,7 +1,7 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 import nfs4_ops as op
 from environment import check, fail
-from nfs4_type import *
+from xdrdef.nfs4_type import *
 import random
 import nfs4lib
 import threading
diff --git a/nfs4.1/server41tests/st_verify.py b/nfs4.1/server41tests/st_verify.py
index a1bc5ca..cfb3809 100644
--- a/nfs4.1/server41tests/st_verify.py
+++ b/nfs4.1/server41tests/st_verify.py
@@ -1,4 +1,4 @@ 
-from nfs4_const import *
+from xdrdef.nfs4_const import *
 import nfs4_ops as op
 from environment import check, checklist, get_invalid_clientid, makeStaleId, \
     do_getattrdict, use_obj
diff --git a/nfs4.1/setup.py b/nfs4.1/setup.py
index e73a1d0..5c3a0df 100644
--- a/nfs4.1/setup.py
+++ b/nfs4.1/setup.py
@@ -31,22 +31,25 @@  class build_py(_build_py):
                 self.build_module(module, module_file, package)
 
     def expand_xdr(self, dir):
+        print "expand = %r" % dir
         cwd = os.getcwd()
-        try:
-            if dir:
-                os.chdir(dir)
-            xdr_files = glob(os.path.join(dir, "*.x"))
-            for f in xdr_files:
-                # Can conditionalize this
-                # XXX need some way to pass options here
-                xdrgen.run(f)
-                try:
-                    os.remove("parser.out")
-                    os.remove("parsetab.py")
-                except:
-                    print "Remove parse* failed"
-        finally:
-            os.chdir(cwd)
+        xdrdir = os.path.join(cwd, dir, 'xdrdef')
+        print "xdrdir = %r" % xdrdir
+        if os.path.exists(xdrdir):
+            try:
+                os.chdir(xdrdir)
+                xdr_files = glob(os.path.join(xdrdir, "*.x"))
+                for f in xdr_files:
+                    # Can conditionalize this
+                    # XXX need some way to pass options here
+                    xdrgen.run(f)
+                    try:
+                        os.remove("parser.out")
+                        os.remove("parsetab.py")
+                    except:
+                        print "Remove parse* failed"
+            finally:
+                os.chdir(cwd)
 
 setup(name = "nfs4",
       version = "0.0.0", # import this?
diff --git a/nfs4.1/testclient.py b/nfs4.1/testclient.py
index 9189c60..95e90e1 100755
--- a/nfs4.1/testclient.py
+++ b/nfs4.1/testclient.py
@@ -193,7 +193,7 @@  def run_filter(test, options):
 
 def printflags(list):
     """Print all legal flag names, which are given in list"""
-    from nfs4_const import nfs_opnum4
+    from xdrdef.nfs4_const import nfs_opnum4
     command_names = [s.lower()[3:].replace('_', '') \
                      for s in nfs_opnum4.values()]
     list.sort()
diff --git a/nfs4.1/testserver.py b/nfs4.1/testserver.py
index 61e308c..7c10fe6 100755
--- a/nfs4.1/testserver.py
+++ b/nfs4.1/testserver.py
@@ -190,7 +190,7 @@  def run_filter(test, options):
 
 def printflags(list):
     """Print all legal flag names, which are given in list"""
-    from nfs4_const import nfs_opnum4
+    from xdrdef.nfs4_const import nfs_opnum4
     command_names = [s.lower()[3:].replace('_', '') \
                      for s in nfs_opnum4.values()]
     list.sort()