Beispiel #1
0
 def getattr(self, path, fh=None):
     full_path = self._full_path(path)
     channel = grpc.insecure_channel(ip, options=(('grpc.enable_http_proxy', 0),))
     stub = account_pb2_grpc.ReplyStub(channel)
     st = stub.getattr(account_pb2.getattrRequest(path=path, fh=fh))
     return dict((key, getattr(st, key)) for key in ('st_atime', 'st_ctime',
                  'st_gid', 'st_mode', 'st_mtime', 'st_nlink', 'st_size', 'st_uid'))
def mkdirReq(newDirectory):
    mkdir = Filesystem(
        newDirectory)  #didn't want to make new class called mkidr
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.mkdir(account_pb2.mkdirRequest(path=mkdir.fsPath))
    print("Client received: " + response.message)
Beispiel #3
0
def handleCreationRequest():
    creds = getCredentials()
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.Creation(
        account_pb2.CreationRequest(name=creds.user, password=creds.pword))
    print("Client received: " + response.message)
def handleFilesystemRequest():
    dir = getDirectory()
    directory = Filesystem(dir)
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.MountFs(
        account_pb2.FilesystemRequest(fsPath=directory.fsPath))
    print("Client received: " + response.message)
Beispiel #5
0
def handleLoginRequest():
    loginReq = getLoginReq()
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.Login(
        account_pb2.LoginRequest(name=loginReq.user,
                                 password=loginReq.pword,
                                 message="Login Attempt"))
    print("Client recieved: " + response.message)
Beispiel #6
0
def handleCreationTolerance(user, phash, token, expiry):
    creds = CreationTolerance(user, phash, token, expiry)
    channel = grpc.insecure_channel(backupIP,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.CreationTolerance(
        account_pb2.CreationToleranceRequest(user=creds.user,
                                             phash=creds.phash,
                                             token=creds.token,
                                             expiry=creds.expiry))
    print("Primary received: " + response.message)
Beispiel #7
0
def handleDeleteRequest():
    deleteReq = getDeleteReq()
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.Delete(
        account_pb2.DeleteRequest(name=deleteReq.user,
                                  password=deleteReq.pword,
                                  authentication=deleteReq.authentication,
                                  message="Deletion Attempt"))
    print("Client recieved: " + response.message)
Beispiel #8
0
def handleUpdateRequest():
    updateReq = getUpdateReq()
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.Update(
        account_pb2.UpdateRequest(name=updateReq.user,
                                  password=updateReq.pword,
                                  newPassword=updateReq.newpword,
                                  authentication=updateReq.authentication,
                                  message="Update Attempt"))
    print("Client recieved: " + response.message)
Beispiel #9
0
def handleAdminUpdateRequest(adminCreds):
    updateReq = getAdminUpdateReq()
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.AdminUpdate(
        account_pb2.AdminUpdateRequest(adminUser=updateReq.adminUser,
                                       token=adminCreds.token,
                                       name=updateReq.name,
                                       newName=updateReq.newName,
                                       newPass=updateReq.newPass,
                                       message="User update."))
    print("Client recieved: " + response.message)
def lsReq():
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.ls(account_pb2.ClientSysCallRequest())
    print("Client received: " + response.message)
def fullPathReq():
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.fullPath(account_pb2.FullPathReq(partial="/test/"))
    print("Client received: " + response.path)
Beispiel #12
0
 def _full_path(self, partial):
     channel = grpc.insecure_channel(ip, options=(('grpc.enable_http_proxy', 0),))
     stub = account_pb2_grpc.ReplyStub(channel)
     path = stub.fullPath(account_pb2.FullPathReq(fullPath=partial))
     return path.message
Beispiel #13
0
def handleMountRequest():
    channel = grpc.insecure_channel(ip,
                                    options=(('grpc.enable_http_proxy', 0), ))
    stub = account_pb2_grpc.ReplyStub(channel)
    response = stub.Mount(account_pb2.MountReq(ip=ip, path='/fuse'))
    print("Client received: " + response.msg)