Beispiel #1
0
def update_stores(username=None):
    """ Update stores to use current datadir specifications """
    if username is not None:
        users = [username]
    else:
        users = [x.get('name') for x in data_service.query('user', wpublic=1)]

    drivers = load_default_drivers()
    for user in users:
        with identity.as_user(user):
            _update_mounts(drivers)
Beispiel #2
0
def init_stores(username=None):
    """Esnure stores are initialized with correct values and tag order
    """
    if username is not None:
        users = [username]
    else:
        users = [x.get('name') for x in data_service.query('user', wpublic=1)]

    drivers = load_default_drivers()

    for user in users:
        with identity.as_user(user):
            _create_root_mount(drivers)
Beispiel #3
0
def move_stores(from_store, to_store, username=None):
    """ Update stores to use current datadir specifications """
    if username is not None:
        users = [username]
    else:
        users = [x.get('name') for x in data_service.query('user', wpublic=1)]

    from bq.core.service import service_registry
    file_service = service_registry.find_service("mnt")
    drivers = load_default_drivers()
    for user in users:
        print("MOVING %s -> %s for %s ", from_store, to_store, user)
        with identity.as_user(user):
            file_service.move(from_store, to_store)
Beispiel #4
0
    def _find_store(self, resource):
        """return a store(mount)  by the resource

        case 1: Anonymous user:  resource must be published
        case 2: User == resource owner : should be one of the users stores
        case 3: User != resource owner : user has read permission

        We has N store prefix and we want to find the longest match for the target string (searchurl)
        """
        #  This should have been checked before we ever get here:
        #  Currently all service check accessibility before arriving here.
        #  so we can simply find the store using the resource's owner.

        # identity functions need to either accept URI we should move to using UNIQ codes for all embedded URI
        # i.e. <image uniq="00-AAA" owner="00-CCC" ../>
        owner_uri = resource.get('owner')
        owner = load_uri(owner_uri)

        # Is this enough context? Should the whole operation be carried out as the user or just the store lookup?
        with identity.as_user(owner):
            store, driver = self.valid_store_ref(resource)
        return store, driver