Exemplo n.º 1
0
    def multi_update(vol, users, usergateways, acquisitiongateways,
                     replicagateways):
        v_id = vol.volume_id
        db.delete_volume(v_id)
        logging.info(users)

        for user in users:
            fields = {}

            if v_id in user.volumes_o:
                new_volumes_o = user.volumes_o
                new_volumes_o.remove(v_id)
                fields['volumes_o'] = new_volumes_o

            if v_id in user.volumes_rw:
                new_volumes_rw = user.volumes_rw
                new_volumes_rw.remove(v_id)
                fields['volumes_rw'] = new_volumes_rw

            if v_id in user.volumes_r:
                new_volumes_r = user.volumes_r
                new_volumes_r.remove(v_id)
                fields['volumes_r'] = new_volumes_r

            if fields:
                db.update_user(user.email, **fields)

        for ug in usergateways:
            fields = {}
            fields['volume_id'] = 0
            db.update_user_gateway(ug.g_id, **fields)

        for ag in acquisitiongateways:
            logging.info(ag)
            fields = {}
            new_ids = ag.volume_ids.remove(v_id)
            if not new_ids:
                fields['volume_ids'] = []
            else:
                fields['volume_ids'] = new_ids
            db.update_acquisition_gateway(ag.g_id, **fields)

        for rg in replicagateways:
            fields = {}
            new_ids = rg.volume_ids.remove(v_id)
            if not new_ids:
                fields['volume_ids'] = []
            else:
                fields['volume_ids'] = new_ids
            db.update_replica_gateway(rg.g_id, **fields)

        # Clear initial data session variable to prevent stale tables in ag.views.viewgateway and rg.views.viewgateway
        session.pop("rg_initial_data" + str(v_id), None)
        session.pop("ag_initial_data" + str(v_id), None)
        # Clear initial data session variable to prevent stale data in volume settings, change rgs, and change ags.
        session.pop("volume_initial_ags" + str(v_id), None)
        session.pop("volume_initial_rgs" + str(v_id), None)
Exemplo n.º 2
0
def delete_volume(name, **attrs):
    """
   Delete a Volume.  Every file and directory within the Volume
   will also be deleted.
   
   Positional arguments:
      name (str)
         The name of the Volume to delete.

   Returns:
      If successful, returns True.  Raises an exception on failure.
      This method is idemopotent--it returns True if the Volume 
      does not exist.
   
   Authorization:
      An administrator can delete any Volume.
      A user can only delete a Volume (s)he owns.
   
   Remarks:
      Be sure to revoke the Volume's metadata key pair after 
      calling this method.  Syntool will do this automatically.
   """
    return storage.delete_volume(name, **attrs)
Exemplo n.º 3
0
def delete_volume(name, **attrs):
    """
   Delete a Volume.  Every file and directory within the Volume
   will also be deleted.
   
   Positional arguments:
      name (str)
         The name of the Volume to delete.

   Returns:
      If successful, returns True.  Raises an exception on failure.
      This method is idemopotent--it returns True if the Volume 
      does not exist.
   
   Authorization:
      An administrator can delete any Volume.
      A user can only delete a Volume (s)he owns.
   
   Remarks:
      Be sure to revoke the Volume's metadata key pair after 
      calling this method.  Syntool will do this automatically.
   """
    return storage.delete_volume(name, **attrs)