Ejemplo n.º 1
0
 def release_resources(auth, vesselhandle_list):
   """
   <Purpose>
     Release resources for a user over XMLRPC.
   <Arguments>
     auth
       An authorization dict.
     vesselhandle_list
       A list of vessel handles
   <Exceptions>
     Raises xmlrpclib Fault objects:
       FAULTCODE_INVALIDREQUEST if a user provides invalid vessel handles.
   <Returns>
     0 on success. Raises a fault otherwise.
   """
   geni_user = _auth(auth)
 
   if not isinstance(vesselhandle_list, list):
     raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, "Invalid data type for handle list.")
   
   # since we're given a list of vessel 'handles', we need to convert them to a 
   # list of actual Vessel objects; as release_vessels_of_user expects Vessel objs.
   try:
     list_of_vessel_objs = interface.get_vessel_list(vesselhandle_list)
   except DoesNotExistError, err:
     # given handle refers to a non-existant vessel
     raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, str(err))
Ejemplo n.º 2
0
    def release_resources(auth, vesselhandle_list):
        """
    <Purpose>
      Release resources for a user over XMLRPC.
    <Arguments>
      auth
        An authorization dict.
      vesselhandle_list
        A list of vessel handles
    <Exceptions>
      Raises xmlrpclib Fault objects:
        FAULTCODE_INVALIDREQUEST if a user provides invalid vessel handles.
    <Returns>
      0 on success. Raises a fault otherwise.
    """
        geni_user = _auth(auth)

        if not isinstance(vesselhandle_list, list):
            raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, "Invalid data type for handle list.")

        # since we're given a list of vessel 'handles', we need to convert them to a
        # list of actual Vessel objects; as release_vessels_of_user expects Vessel objs.
        try:
            list_of_vessel_objs = interface.get_vessel_list(vesselhandle_list)
        except DoesNotExistError, err:
            # given handle refers to a non-existant vessel
            raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, str(err))
Ejemplo n.º 3
0
  def renew_resources(auth, vesselhandle_list):
    """
    <Purpose>
      Renew resources for a user over XMLRPC. Renewal changes the expiration
      time to the maximum allowed.
    <Arguments>
      auth
        An authorization dict.
      vesselhandle_list
        A list of vessel handles
    <Exceptions>
      Raises xmlrpclib Fault objects with fault codes:
        FAULTCODE_INVALIDREQUEST if a user provides invalid vessel handles.
        FAULTCODE_NOTENOUGHCREDITS if user has insufficient vessel credits to complete request.
    <Returns>
      0 on success. Raises a fault otherwise.
    """
    geni_user = _auth(auth)
  
    if not isinstance(vesselhandle_list, list):
      raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, "Invalid data type for handle list.")
    
    for handle in vesselhandle_list:
      if not isinstance(handle, str):
        raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, 
                              "Invalid data type for handle. Expected str, received " + str(type(handle)))

    # since we're given a list of vessel 'handles', we need to convert them to a 
    # list of actual Vessel objects.
    try:
      list_of_vessel_objs = interface.get_vessel_list(vesselhandle_list)
    except DoesNotExistError, err:
      # The handle refers to a non-existent vessel.
      raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, str(err))
Ejemplo n.º 4
0
def renew_resource(request):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  # The request must be via POST. If not, bounce user back to My Vessels page.
  if not request.method == 'POST':
    return myvessels(request)
  
  if not request.POST.get('handle', ''):
    return myvessels(request)
  
  action_summary = ""
  action_detail = ""
  
  try:
    # Convert handle to vessel object.
    # Raises a DoesNotExistError if the vessel does not exist. This is more
    # likely to be an error than an expected case, so we let it bubble up.
    vessel_handle_list = [request.POST['handle']]
    vessel_to_renew = interface.get_vessel_list(vessel_handle_list)
  except DoesNotExistError:
    action_summary = "Unable to renew vessel: The vessel you are trying to delete does not exist."
  except InvalidRequestError, err:
    action_summary = "Unable to renew vessel."
    action_detail += str(err)
Ejemplo n.º 5
0
def del_resource(request):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  # the request must be via POST. if not, bounce user back to My Vessels page
  if not request.method == 'POST':
    return myvessels(request)

  if not request.POST['handle']:
    return myvessels(request)
  
  # vessel_handle needs to be a list (even though we only add one handle), 
  # since get_vessel_list expects a list.
  vessel_handle = []
  vessel_handle.append(request.POST['handle'])
  remove_summary = ""
  
  try:
    # convert handle to vessel
    vessel_to_release = interface.get_vessel_list(vessel_handle)
  except DoesNotExistError:
    remove_summary = "Unable to remove vessel. The vessel you are trying to remove does not exist."
  except InvalidRequestError, err:
    remove_summary = "Unable to remove vessel. " + str(err)
Ejemplo n.º 6
0
def renew_resource(request):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  # The request must be via POST. If not, bounce user back to My Vessels page.
  if not request.method == 'POST':
    return myvessels(request)
  
  if not request.POST.get('handle', ''):
    return myvessels(request)
  
  action_summary = ""
  action_detail = ""
  
  try:
    # Convert handle to vessel object.
    # Raises a DoesNotExistError if the vessel does not exist. This is more
    # likely to be an error than an expected case, so we let it bubble up.
    vessel_handle_list = [request.POST['handle']]
    vessel_to_renew = interface.get_vessel_list(vessel_handle_list)
  except DoesNotExistError:
    action_summary = "Unable to renew vessel: The vessel you are trying to delete does not exist."
  except InvalidRequestError, err:
    action_summary = "Unable to renew vessel."
    action_detail += str(err)
Ejemplo n.º 7
0
def del_resource(request):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  # the request must be via POST. if not, bounce user back to My Vessels page
  if not request.method == 'POST':
    return myvessels(request)

  if not request.POST['handle']:
    return myvessels(request)
  
  # vessel_handle needs to be a list (even though we only add one handle), 
  # since get_vessel_list expects a list.
  vessel_handle = []
  vessel_handle.append(request.POST['handle'])
  remove_summary = ""
  
  try:
    # convert handle to vessel
    vessel_to_release = interface.get_vessel_list(vessel_handle)
  except DoesNotExistError:
    remove_summary = "Unable to remove vessel. The vessel you are trying to remove does not exist."
  except InvalidRequestError, err:
    remove_summary = "Unable to remove vessel. " + str(err)
Ejemplo n.º 8
0
    def acquire_specific_vessels(auth, vesselhandle_list):
        """
    <Purpose>
      Acquires specific vessels for a user. This will be best effort. Zero or
      more of the vessels may be acquired. The list, however, cannot include
      more vessels than the maximum number the user is allowed to acquire.
    <Arguments>
      auth
        An authorization dict.
      vesselhandle_list
        A list of vessel handles.
    <Exceptions>
      Raises xmlrpclib Fault objects:
        FAULTCODE_INTERNALERROR for internal errors.
        FAULTCODE_INVALIDREQUEST for bad user input.
        FAULTCODE_NOTENOUGHCREDITS if user has insufficient vessel credits to complete request.
    <Returns>
      A list of 'info' dictionaries, each 'infodict' contains acquired vessel info.
    """
        geni_user = _auth(auth)

        if not isinstance(vesselhandle_list, list):
            raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST,
                                  "Invalid data type for handle list.")

        # Remove duplicates to avoid race condition where the database is
        # updated simultaneously for the same vessel, raising a duplicate
        # key error.
        vesselhandle_list = list(set(vesselhandle_list))

        # since we're given a list of vessel 'handles', we need to convert them to a
        # list of actual Vessel objects; as release_vessels_of_user expects Vessel objs.
        try:
            list_of_vessel_objs = interface.get_vessel_list(vesselhandle_list)
        except DoesNotExistError, err:
            # given handle refers to a non-existant vessel
            raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, str(err))
Ejemplo n.º 9
0
    def acquire_specific_vessels(auth, vesselhandle_list):
        """
    <Purpose>
      Acquires specific vessels for a user. This will be best effort. Zero or
      more of the vessels may be acquired. The list, however, cannot include
      more vessels than the maximum number the user is allowed to acquire.
    <Arguments>
      auth
        An authorization dict.
      vesselhandle_list
        A list of vessel handles.
    <Exceptions>
      Raises xmlrpclib Fault objects:
        FAULTCODE_INTERNALERROR for internal errors.
        FAULTCODE_INVALIDREQUEST for bad user input.
        FAULTCODE_NOTENOUGHCREDITS if user has insufficient vessel credits to complete request.
    <Returns>
      A list of 'info' dictionaries, each 'infodict' contains acquired vessel info.
    """
        geni_user = _auth(auth)

        if not isinstance(vesselhandle_list, list):
            raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, "Invalid data type for handle list.")

        # Remove duplicates to avoid race condition where the database is
        # updated simultaneously for the same vessel, raising a duplicate
        # key error.
        vesselhandle_list = list(set(vesselhandle_list))

        # since we're given a list of vessel 'handles', we need to convert them to a
        # list of actual Vessel objects; as release_vessels_of_user expects Vessel objs.
        try:
            list_of_vessel_objs = interface.get_vessel_list(vesselhandle_list)
        except DoesNotExistError, err:
            # given handle refers to a non-existant vessel
            raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, str(err))