Ejemplo n.º 1
0
    def GetCapacities(self, request, context):
        try:
            response = self.generate_response(message="Capacities retrieved", code=1, total_used=eos.get_used_capacity(), total_capacity=eos.get_total_capacity())
        except:
            response =  self.generate_response(message="Unable to retrieve capacities", code=-1)

        eos.report(action="retrived capacities", response=response)
        return response
Ejemplo n.º 2
0
    def Unmanage(self, request, context):
        try:
            eos.unmanage(request)
            response = self.generate_response(message="Successfully unmanaged share", code=1)
        except ValueError:
            response = self.generate_response(message="Could not unmanage share", code=-1)

        eos.report(action="unmanaged", response=response)
        return response
Ejemplo n.º 3
0
    def ShrinkShare(self, request, context):
        try:
            eos.change_share_size(request)
            response = self.generate_response(message="Share shrinkage successful", code=1)
        except:
             response =  self.generate_response(message="Share shrinkage unsuccessful", code=-1)

        eos.report(action="shrunk", response=response)
        return response
Ejemplo n.º 4
0
    def ExtendShare(self, request, context):
        try:
            eos.change_share_size(request)
            response = self.generate_response(message="Share extension successful", code=1)
        except ValueError:
            self.generate_response(message="Share extension unsuccessful", code=-1)

        eos.report(action='extended', response=response)
        return response
Ejemplo n.º 5
0
    def ManageExisting(self, request, context):
        quota = eos.manage_existing(request)
        
        if int(request.quota) < 0:
           response = self.generate_response(message="Could not manage share", code=-1)
        else:
           response = self.generate_response(message="Successfully managed share", code=1, new_share_quota=quota)

        eos.report(action='managed', response=response)
        return response
Ejemplo n.º 6
0
    def DeleteShare(self, request, context):
        old_share_location = eos.delete_share(request)
        
        if os.path.isdir(old_share_location):
           response = self.generate_response(message="Could not delete share", code=-1)
        else:
           response = self.generate_response(message="Share successfully deleted", code=1)

        eos.report(action='deleted', response=response)
        return response
Ejemplo n.º 7
0
 def CreateShare(self, request, context):       
     share_location = eos.create_share(request)
     
     if not os.path.isdir(share_location):
        response = self.generate_response(message="Could not create share", code=-1)
     else:
        response = self.generate_response(message="Share successfully created", code=1, new_share_path=share_location)
     
     eos.report(action='added', response=response)
     return response
Ejemplo n.º 8
0
    def DeleteShare(self, request, context):
        response = eos_pb2.Response()

        if request.id in shares:
           del shares[request.id]
           response.msg = "success"
           response.response_code = 1
        else:
           response.msg = "error"
           response.response_code = -1

        #print("Share (" + new_share["id"]  + ") removed with " +  response.msg + ". Code: " + str(response.response_code))
        eos.report(action='removed', id=request.id, response=response, shares=shares)

        return response
Ejemplo n.º 9
0
    def CreateShare(self, request, context):
        response = eos_pb2.Response()
        
        new_share = eos.create_share(request)
        #shares.append(new_share) 
        
        if new_share["id"] in shares: #don't want to overwrite any existing shares
           response.msg = "error"
           response.response_code = -1
        else:
           shares[new_share["id"]] = new_share
           response.msg = "success"
           response.response_code = 1

        #print("Share (" + new_share["id"]  + ") added with " +  response.msg + ". Code: " + str(response.response_code))
        #print("\n~ Available Shares [TOTAL: " + str(len(shares)) + " Shares] ~")
        #print(shares)
        #print("\n") 
        
        eos.report(action='added', id=new_share["id"], response=response, shares=shares)

        return response