Skip to content

Commit

Permalink
Allow returning ReplyBodys from procs, pass CallContext to all procs
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanMilne committed Nov 6, 2020
1 parent 42a0670 commit fbe3468
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 241 deletions.
5 changes: 2 additions & 3 deletions shenaniganfs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import xdrlib
from typing import *

from shenaniganfs import rpchelp
from shenaniganfs.generated.rfc1831 import *
from shenaniganfs.transport import BaseTransport, SPLIT_MSG, TCPTransport
from shenaniganfs.transport import BaseTransport, Prog, SPLIT_MSG, TCPTransport

_T = TypeVar("T")

Expand Down Expand Up @@ -47,7 +46,7 @@ def success(self):
return True


class BaseClient(rpchelp.Prog):
class BaseClient(Prog):
transport: Optional[BaseTransport]

def __init__(self):
Expand Down
78 changes: 51 additions & 27 deletions shenaniganfs/generated/rfc1094.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ class ExportList(rpchelp.LinkedList): # exportlist
groups: typing.List[bytes] = rpchelp.rpc_field(GroupList)


from shenaniganfs import client
from shenaniganfs import client, transport


class NFS_PROGRAM_2_SERVER(rpchelp.Prog):
class NFS_PROGRAM_2_SERVER(transport.Prog):
prog = 100003
vers = 2
procs = {
Expand All @@ -308,75 +308,93 @@ class NFS_PROGRAM_2_SERVER(rpchelp.Prog):
}

@abc.abstractmethod
async def NULL(self) -> None:
async def NULL(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def GETATTR(self, arg_0: bytes) -> AttrStat:
async def GETATTR(self, call_ctx: transport.CallContext, arg_0: bytes) \
-> transport.ProcRet[AttrStat]:
raise NotImplementedError()

@abc.abstractmethod
async def SETATTR(self, arg_0: SattrArgs) -> AttrStat:
async def SETATTR(self, call_ctx: transport.CallContext, arg_0: SattrArgs) \
-> transport.ProcRet[AttrStat]:
raise NotImplementedError()

@abc.abstractmethod
async def ROOT(self) -> None:
async def ROOT(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def LOOKUP(self, arg_0: DiropArgs) -> DiropRes:
async def LOOKUP(self, call_ctx: transport.CallContext, arg_0: DiropArgs) \
-> transport.ProcRet[DiropRes]:
raise NotImplementedError()

@abc.abstractmethod
async def READLINK(self, arg_0: bytes) -> ReadlinkRes:
async def READLINK(self, call_ctx: transport.CallContext, arg_0: bytes) \
-> transport.ProcRet[ReadlinkRes]:
raise NotImplementedError()

@abc.abstractmethod
async def READ(self, arg_0: ReadArgs) -> ReadRes:
async def READ(self, call_ctx: transport.CallContext, arg_0: ReadArgs) \
-> transport.ProcRet[ReadRes]:
raise NotImplementedError()

@abc.abstractmethod
async def WRITECACHE(self) -> None:
async def WRITECACHE(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def WRITE(self, arg_0: WriteArgs) -> AttrStat:
async def WRITE(self, call_ctx: transport.CallContext, arg_0: WriteArgs) \
-> transport.ProcRet[AttrStat]:
raise NotImplementedError()

@abc.abstractmethod
async def CREATE(self, arg_0: CreateArgs) -> DiropRes:
async def CREATE(self, call_ctx: transport.CallContext, arg_0: CreateArgs) \
-> transport.ProcRet[DiropRes]:
raise NotImplementedError()

@abc.abstractmethod
async def REMOVE(self, arg_0: DiropArgs) -> typing.Union[Stat, int]:
async def REMOVE(self, call_ctx: transport.CallContext, arg_0: DiropArgs) \
-> transport.ProcRet[typing.Union[Stat, int]]:
raise NotImplementedError()

@abc.abstractmethod
async def RENAME(self, arg_0: RenameArgs) -> typing.Union[Stat, int]:
async def RENAME(self, call_ctx: transport.CallContext, arg_0: RenameArgs) \
-> transport.ProcRet[typing.Union[Stat, int]]:
raise NotImplementedError()

@abc.abstractmethod
async def LINK(self, arg_0: LinkArgs) -> typing.Union[Stat, int]:
async def LINK(self, call_ctx: transport.CallContext, arg_0: LinkArgs) \
-> transport.ProcRet[typing.Union[Stat, int]]:
raise NotImplementedError()

@abc.abstractmethod
async def SYMLINK(self, arg_0: SymlinkArgs) -> typing.Union[Stat, int]:
async def SYMLINK(self, call_ctx: transport.CallContext, arg_0: SymlinkArgs) \
-> transport.ProcRet[typing.Union[Stat, int]]:
raise NotImplementedError()

@abc.abstractmethod
async def MKDIR(self, arg_0: CreateArgs) -> DiropRes:
async def MKDIR(self, call_ctx: transport.CallContext, arg_0: CreateArgs) \
-> transport.ProcRet[DiropRes]:
raise NotImplementedError()

@abc.abstractmethod
async def RMDIR(self, arg_0: DiropArgs) -> typing.Union[Stat, int]:
async def RMDIR(self, call_ctx: transport.CallContext, arg_0: DiropArgs) \
-> transport.ProcRet[typing.Union[Stat, int]]:
raise NotImplementedError()

@abc.abstractmethod
async def READDIR(self, arg_0: ReaddirArgs) -> ReaddirRes:
async def READDIR(self, call_ctx: transport.CallContext, arg_0: ReaddirArgs) \
-> transport.ProcRet[ReaddirRes]:
raise NotImplementedError()

@abc.abstractmethod
async def STATFS(self, arg_0: bytes) -> StatfsRes:
async def STATFS(self, call_ctx: transport.CallContext, arg_0: bytes) \
-> transport.ProcRet[StatfsRes]:
raise NotImplementedError()


Expand Down Expand Up @@ -459,7 +477,7 @@ async def STATFS(self, arg_0: bytes) -> client.UnpackedRPCMsg[StatfsRes]:
return await self.send_call(17, arg_0)


class MOUNTPROG_1_SERVER(rpchelp.Prog):
class MOUNTPROG_1_SERVER(transport.Prog):
prog = 100005
vers = 1
procs = {
Expand All @@ -472,27 +490,33 @@ class MOUNTPROG_1_SERVER(rpchelp.Prog):
}

@abc.abstractmethod
async def NULL(self) -> None:
async def NULL(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def MNT(self, arg_0: bytes) -> FHStatus:
async def MNT(self, call_ctx: transport.CallContext, arg_0: bytes) \
-> transport.ProcRet[FHStatus]:
raise NotImplementedError()

@abc.abstractmethod
async def DUMP(self) -> typing.List[MountList]:
async def DUMP(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[typing.List[MountList]]:
raise NotImplementedError()

@abc.abstractmethod
async def UMNT(self, arg_0: bytes) -> None:
async def UMNT(self, call_ctx: transport.CallContext, arg_0: bytes) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def UMNTALL(self) -> None:
async def UMNTALL(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def EXPORT(self) -> typing.List[ExportList]:
async def EXPORT(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[typing.List[ExportList]]:
raise NotImplementedError()


Expand Down
90 changes: 59 additions & 31 deletions shenaniganfs/generated/rfc1813.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,10 @@ class ExportList(rpchelp.LinkedList): # exportlist
groups: typing.List[bytes] = rpchelp.rpc_field(GroupList)


from shenaniganfs import client
from shenaniganfs import client, transport


class NFS_PROGRAM_3_SERVER(rpchelp.Prog):
class NFS_PROGRAM_3_SERVER(transport.Prog):
prog = 100003
vers = 3
procs = {
Expand Down Expand Up @@ -940,91 +940,113 @@ class NFS_PROGRAM_3_SERVER(rpchelp.Prog):
}

@abc.abstractmethod
async def NULL(self) -> None:
async def NULL(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def GETATTR(self, arg_0: GETATTR3Args) -> GETATTR3Res:
async def GETATTR(self, call_ctx: transport.CallContext, arg_0: GETATTR3Args) \
-> transport.ProcRet[GETATTR3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def SETATTR(self, arg_0: SETATTR3Args) -> SETATTR3Res:
async def SETATTR(self, call_ctx: transport.CallContext, arg_0: SETATTR3Args) \
-> transport.ProcRet[SETATTR3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def LOOKUP(self, arg_0: LOOKUP3Args) -> LOOKUP3Res:
async def LOOKUP(self, call_ctx: transport.CallContext, arg_0: LOOKUP3Args) \
-> transport.ProcRet[LOOKUP3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def ACCESS(self, arg_0: ACCESS3Args) -> ACCESS3Res:
async def ACCESS(self, call_ctx: transport.CallContext, arg_0: ACCESS3Args) \
-> transport.ProcRet[ACCESS3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def READLINK(self, arg_0: READLINK3Args) -> READLINK3Res:
async def READLINK(self, call_ctx: transport.CallContext, arg_0: READLINK3Args) \
-> transport.ProcRet[READLINK3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def READ(self, arg_0: READ3Args) -> READ3Res:
async def READ(self, call_ctx: transport.CallContext, arg_0: READ3Args) \
-> transport.ProcRet[READ3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def WRITE(self, arg_0: WRITE3Args) -> WRITE3Res:
async def WRITE(self, call_ctx: transport.CallContext, arg_0: WRITE3Args) \
-> transport.ProcRet[WRITE3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def CREATE(self, arg_0: CREATE3Args) -> CREATE3Res:
async def CREATE(self, call_ctx: transport.CallContext, arg_0: CREATE3Args) \
-> transport.ProcRet[CREATE3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def MKDIR(self, arg_0: MKDIR3Args) -> MKDIR3Res:
async def MKDIR(self, call_ctx: transport.CallContext, arg_0: MKDIR3Args) \
-> transport.ProcRet[MKDIR3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def SYMLINK(self, arg_0: SYMLINK3Args) -> SYMLINK3Res:
async def SYMLINK(self, call_ctx: transport.CallContext, arg_0: SYMLINK3Args) \
-> transport.ProcRet[SYMLINK3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def MKNOD(self, arg_0: MKNOD3Args) -> MKNOD3Res:
async def MKNOD(self, call_ctx: transport.CallContext, arg_0: MKNOD3Args) \
-> transport.ProcRet[MKNOD3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def REMOVE(self, arg_0: REMOVE3Args) -> REMOVE3Res:
async def REMOVE(self, call_ctx: transport.CallContext, arg_0: REMOVE3Args) \
-> transport.ProcRet[REMOVE3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def RMDIR(self, arg_0: RMDIR3Args) -> RMDIR3Res:
async def RMDIR(self, call_ctx: transport.CallContext, arg_0: RMDIR3Args) \
-> transport.ProcRet[RMDIR3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def RENAME(self, arg_0: RENAME3Args) -> RENAME3Res:
async def RENAME(self, call_ctx: transport.CallContext, arg_0: RENAME3Args) \
-> transport.ProcRet[RENAME3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def LINK(self, arg_0: LINK3Args) -> LINK3Res:
async def LINK(self, call_ctx: transport.CallContext, arg_0: LINK3Args) \
-> transport.ProcRet[LINK3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def READDIR(self, arg_0: READDIR3Args) -> READDIR3Res:
async def READDIR(self, call_ctx: transport.CallContext, arg_0: READDIR3Args) \
-> transport.ProcRet[READDIR3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def READDIRPLUS(self, arg_0: READDIRPLUS3Args) -> READDIRPLUS3Res:
async def READDIRPLUS(self, call_ctx: transport.CallContext, arg_0: READDIRPLUS3Args) \
-> transport.ProcRet[READDIRPLUS3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def FSSTAT(self, arg_0: FSSTAT3Args) -> FSSTAT3Res:
async def FSSTAT(self, call_ctx: transport.CallContext, arg_0: FSSTAT3Args) \
-> transport.ProcRet[FSSTAT3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def FSINFO(self, arg_0: FSINFO3Args) -> FSINFO3Res:
async def FSINFO(self, call_ctx: transport.CallContext, arg_0: FSINFO3Args) \
-> transport.ProcRet[FSINFO3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def PATHCONF(self, arg_0: PATHCONF3Args) -> PATHCONF3Res:
async def PATHCONF(self, call_ctx: transport.CallContext, arg_0: PATHCONF3Args) \
-> transport.ProcRet[PATHCONF3Res]:
raise NotImplementedError()

@abc.abstractmethod
async def COMMIT(self, arg_0: COMMIT3Args) -> COMMIT3Res:
async def COMMIT(self, call_ctx: transport.CallContext, arg_0: COMMIT3Args) \
-> transport.ProcRet[COMMIT3Res]:
raise NotImplementedError()


Expand Down Expand Up @@ -1123,7 +1145,7 @@ async def COMMIT(self, arg_0: COMMIT3Args) -> client.UnpackedRPCMsg[COMMIT3Res]:
return await self.send_call(21, arg_0)


class MOUNT_PROGRAM_3_SERVER(rpchelp.Prog):
class MOUNT_PROGRAM_3_SERVER(transport.Prog):
prog = 100005
vers = 3
procs = {
Expand All @@ -1136,27 +1158,33 @@ class MOUNT_PROGRAM_3_SERVER(rpchelp.Prog):
}

@abc.abstractmethod
async def NULL(self) -> None:
async def NULL(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def MNT(self, arg_0: bytes) -> MountRes3:
async def MNT(self, call_ctx: transport.CallContext, arg_0: bytes) \
-> transport.ProcRet[MountRes3]:
raise NotImplementedError()

@abc.abstractmethod
async def DUMP(self) -> typing.List[MountList]:
async def DUMP(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[typing.List[MountList]]:
raise NotImplementedError()

@abc.abstractmethod
async def UMNT(self, arg_0: bytes) -> None:
async def UMNT(self, call_ctx: transport.CallContext, arg_0: bytes) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def UMNTALL(self) -> None:
async def UMNTALL(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[None]:
raise NotImplementedError()

@abc.abstractmethod
async def EXPORT(self) -> typing.List[ExportList]:
async def EXPORT(self, call_ctx: transport.CallContext) \
-> transport.ProcRet[typing.List[ExportList]]:
raise NotImplementedError()


Expand Down
Loading

0 comments on commit fbe3468

Please sign in to comment.