2006-12-02 02:17:50 +00:00
|
|
|
|
|
|
|
from foolscap.schema import StringConstraint, ListOf, TupleOf, Any, Nothing
|
|
|
|
from foolscap import RemoteInterface
|
|
|
|
|
2006-12-02 23:26:26 +00:00
|
|
|
Nodeid = StringConstraint(20) # binary format 20-byte SHA1 hash
|
|
|
|
PBURL = StringConstraint(150)
|
|
|
|
Verifierid = StringConstraint(20)
|
2006-12-02 23:03:09 +00:00
|
|
|
ShareData = StringConstraint(20000)
|
2006-12-03 00:25:57 +00:00
|
|
|
# these four are here because Foolscap does not yet support the kind of
|
2006-12-02 02:17:50 +00:00
|
|
|
# restriction I really want to apply to these.
|
2006-12-02 23:03:09 +00:00
|
|
|
RIClient_ = Any()
|
|
|
|
Referenceable_ = Any()
|
|
|
|
RIBucketWriter_ = Any()
|
2006-12-03 00:25:57 +00:00
|
|
|
RIBucketReader_ = Any()
|
2006-12-04 02:07:41 +00:00
|
|
|
RIMutableDirectoryNode_ = Any()
|
|
|
|
RIMutableFileNode_ = Any()
|
2006-12-02 02:17:50 +00:00
|
|
|
|
|
|
|
class RIQueenRoster(RemoteInterface):
|
|
|
|
def hello(nodeid=Nodeid, node=RIClient_, pburl=PBURL):
|
2006-12-04 02:07:41 +00:00
|
|
|
return RIMutableDirectoryNode_ # the virtual drive root
|
2006-12-02 02:17:50 +00:00
|
|
|
|
|
|
|
class RIClient(RemoteInterface):
|
|
|
|
def get_service(name=str):
|
|
|
|
return Referenceable_
|
|
|
|
def add_peers(new_peers=ListOf(TupleOf(Nodeid, PBURL), maxLength=100)):
|
2006-12-02 23:03:09 +00:00
|
|
|
return Nothing()
|
2006-12-02 02:17:50 +00:00
|
|
|
def lost_peers(lost_peers=ListOf(Nodeid)):
|
2006-12-02 23:03:09 +00:00
|
|
|
return Nothing()
|
2006-12-02 02:17:50 +00:00
|
|
|
|
|
|
|
class RIStorageServer(RemoteInterface):
|
2006-12-02 23:26:26 +00:00
|
|
|
def allocate_bucket(verifierid=Verifierid, bucket_num=int, size=int,
|
2006-12-04 02:07:41 +00:00
|
|
|
leaser=Nodeid, canary=Referenceable_):
|
|
|
|
# if the canary is lost before close(), the bucket is deleted
|
2006-12-02 02:17:50 +00:00
|
|
|
return RIBucketWriter_
|
2006-12-03 10:01:43 +00:00
|
|
|
def get_buckets(verifierid=Verifierid):
|
|
|
|
return ListOf(TupleOf(int, RIBucketReader_))
|
2006-12-02 02:17:50 +00:00
|
|
|
|
|
|
|
class RIBucketWriter(RemoteInterface):
|
2006-12-02 23:03:09 +00:00
|
|
|
def write(data=ShareData):
|
|
|
|
return Nothing()
|
2006-12-02 02:17:50 +00:00
|
|
|
|
|
|
|
def close():
|
2006-12-02 23:03:09 +00:00
|
|
|
return Nothing()
|
2006-12-02 02:17:50 +00:00
|
|
|
|
|
|
|
|
2006-12-03 00:25:57 +00:00
|
|
|
class RIBucketReader(RemoteInterface):
|
|
|
|
def read():
|
|
|
|
return ShareData
|
|
|
|
|
|
|
|
|
2006-12-04 02:07:41 +00:00
|
|
|
class RIMutableDirectoryNode(RemoteInterface):
|
|
|
|
def list():
|
|
|
|
return ListOf( TupleOf(str, # name, relative to directory
|
|
|
|
(RIMutableDirectoryNode_, Verifierid)),
|
|
|
|
maxLength=100,
|
|
|
|
)
|
|
|
|
|
2006-12-04 11:03:29 +00:00
|
|
|
def get(name=str):
|
|
|
|
return (RIMutableDirectoryNode_, Verifierid)
|
|
|
|
|
2006-12-04 02:07:41 +00:00
|
|
|
def add_directory(name=str):
|
|
|
|
return RIMutableDirectoryNode_
|
|
|
|
|
|
|
|
def add_file(name=str, data=Verifierid):
|
|
|
|
return Nothing()
|
|
|
|
|
|
|
|
def remove(name=str):
|
|
|
|
return Nothing()
|
|
|
|
|
|
|
|
# need more to move directories
|