Example #1
0
def myvessels(request,
              get_form=False,
              action_summary="",
              action_detail="",
              remove_summary=""):
    try:
        user = _validate_and_get_geniuser(request)
    except LoggedInButFailedGetGeniUserError:
        return _show_failed_get_geniuser_page(request)

    # get_form of None means don't show the form to acquire vessels.
    if interface.get_available_vessel_credits(user) == 0:
        get_form = None
    elif get_form is False:
        get_form = forms.gen_get_form(user)

    # shared vessels that are used by others but which belong to this user (TODO)
    shvessels = []

    # this user's used vessels
    my_vessels_raw = interface.get_acquired_vessels(user)
    my_vessels = interface.get_vessel_infodict_list(my_vessels_raw)

    # this user's number of donations, max vessels, total vessels and free credits
    my_donations = interface.get_donations(user)
    my_max_vessels = interface.get_available_vessel_credits(user)
    my_free_vessel_credits = interface.get_free_vessel_credits_amount(user)
    my_total_vessel_credits = interface.get_total_vessel_credits(user)

    for vessel in my_vessels:
        if vessel["expires_in_seconds"] <= 0:
            # We shouldn't ever get here, but just in case, let's handle it.
            vessel["expires_in"] = "Expired"
        else:
            days = vessel["expires_in_seconds"] / (3600 * 24)
            hours = vessel["expires_in_seconds"] / 3600 % 24
            minutes = vessel["expires_in_seconds"] / 60 % 60
            vessel["expires_in"] = "%dd %dh %dm" % (days, hours, minutes)

    # return the used resources page constructed from a template
    return render_to_response('control/myvessels.html', {
        'username': user.username,
        'num_vessels': len(my_vessels),
        'my_vessels': my_vessels,
        'sh_vessels': shvessels,
        'get_form': get_form,
        'action_summary': action_summary,
        'action_detail': action_detail,
        'my_donations': len(my_donations),
        'my_max_vessels': my_max_vessels,
        'free_vessel_credits': my_free_vessel_credits,
        'total_vessel_credits': my_total_vessel_credits,
        'remove_summary': remove_summary
    },
                              context_instance=RequestContext(request))
Example #2
0
def myvessels(request, get_form=False, action_summary="", action_detail="", remove_summary=""):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  # get_form of None means don't show the form to acquire vessels.
  if interface.get_available_vessel_credits(user) == 0:
    get_form = None
  elif get_form is False:
    get_form = forms.gen_get_form(user)

  # shared vessels that are used by others but which belong to this user (TODO)
  shvessels = []

  # this user's used vessels
  my_vessels_raw = interface.get_acquired_vessels(user)
  my_vessels = interface.get_vessel_infodict_list(my_vessels_raw)
  
  # this user's number of donations, max vessels, total vessels and free credits
  my_donations = interface.get_donations(user)
  my_max_vessels = interface.get_available_vessel_credits(user)	
  my_free_vessel_credits = interface.get_free_vessel_credits_amount(user)
  my_total_vessel_credits = interface.get_total_vessel_credits(user)

  for vessel in my_vessels:
    if vessel["expires_in_seconds"] <= 0:
      # We shouldn't ever get here, but just in case, let's handle it.
      vessel["expires_in"] = "Expired"
    else:
      days = vessel["expires_in_seconds"] / (3600 * 24)
      hours = vessel["expires_in_seconds"] / 3600 % 24
      minutes = vessel["expires_in_seconds"] / 60 % 60
      vessel["expires_in"] = "%dd %dh %dm" % (days, hours, minutes)

  # return the used resources page constructed from a template
  return render_to_response('control/myvessels.html',
                            {'username' : user.username,
                             'num_vessels' : len(my_vessels),
                             'my_vessels' : my_vessels,
                             'sh_vessels' : shvessels,
                             'get_form' : get_form,
                             'action_summary' : action_summary,
                             'action_detail' : action_detail,
                             'my_donations' : len(my_donations),
                             'my_max_vessels' : my_max_vessels, 
                             'free_vessel_credits' : my_free_vessel_credits,
                             'total_vessel_credits' : my_total_vessel_credits,
                             'remove_summary' : remove_summary},
                        context_instance=RequestContext(request))
Example #3
0
 def get_resource_info(auth):
   """
   <Purpose>
     Gets a user's acquired vessels over XMLRPC.
   <Arguments>
     auth
       An authorization dict.
   <Exceptions>
     None.
   <Returns>
     A list of 'info' dictionaries, each 'infodict' contains vessel info.
   """
   geni_user = _auth(auth)
   user_vessels = interface.get_acquired_vessels(geni_user)
   return interface.get_vessel_infodict_list(user_vessels)
Example #4
0
 def get_resource_info(auth):
     """
 <Purpose>
   Gets a user's acquired vessels over XMLRPC.
 <Arguments>
   auth
     An authorization dict.
 <Exceptions>
   None.
 <Returns>
   A list of 'info' dictionaries, each 'infodict' contains vessel info.
 """
     geni_user = _auth(auth)
     user_vessels = interface.get_acquired_vessels(geni_user)
     return interface.get_vessel_infodict_list(user_vessels)
Example #5
0
      raise xmlrpclib.Fault(FAULTCODE_INVALIDREQUEST, "rspec has invalid values.")
      
    # The interface.acquire_vessels() call expects 'rand' instead of 'random'.
    if resource_type == 'random':
      resource_type = 'rand'
    
    try:
      acquired_vessels = interface.acquire_vessels(geni_user, num_vessels, resource_type)
    except UnableToAcquireResourcesError, err:
      raise xmlrpclib.Fault(FAULTCODE_UNABLETOACQUIRE, "Unable to fulfill vessel acquire request at this given time. Details: " + str(err))
    except InsufficientUserResourcesError, err:
      raise xmlrpclib.Fault(FAULTCODE_NOTENOUGHCREDITS, "You do not have enough vessel credits to acquire the number of vessels requested.")
    
    # since acquire_vessels returns a list of Vessel objects, we
    # need to convert them into a list of 'info' dictionaries.
    return interface.get_vessel_infodict_list(acquired_vessels)



  @staticmethod
  @log_function_call
  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
Example #6
0
            acquired_vessels = interface.acquire_vessels(
                geni_user, num_vessels, resource_type)
        except UnableToAcquireResourcesError, err:
            raise xmlrpclib.Fault(
                FAULTCODE_UNABLETOACQUIRE,
                "Unable to fulfill vessel acquire request at this given time. Details: "
                + str(err))
        except InsufficientUserResourcesError, err:
            raise xmlrpclib.Fault(
                FAULTCODE_NOTENOUGHCREDITS,
                "You do not have enough vessel credits to acquire the number of vessels requested."
            )

        # since acquire_vessels returns a list of Vessel objects, we
        # need to convert them into a list of 'info' dictionaries.
        return interface.get_vessel_infodict_list(acquired_vessels)

    @staticmethod
    @log_function_call
    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>