Beispiel #1
0
    def attach(self, dbg, configuration):
        uri = configuration['uri']
        log.debug('{}: SR.attach: config={}, uri={}'.format(
            dbg, configuration, uri))

        nfs_uri = urlparse.urlsplit(uri)
        if nfs_uri.scheme != 'nfs':
            raise ValueError('Incorrect URI scheme')

        nfs_server = '{0}:{1}'.format(nfs_uri.netloc, nfs_uri.path)

        sr_uuid = configuration['sr_uuid']
        mnt_path = self._mount_path(sr_uuid)
        sr_dir = os.path.join(mnt_path, sr_uuid)
        sr = urlparse.urlunsplit(('file', '', sr_dir, None, None))

        if os.path.exists(mnt_path) and os.path.ismount(mnt_path):
            log.debug("%s: SR.attach: uri=%s ALREADY ATTACHED" % (dbg, uri))
            return sr

        log.debug("%s: SR.attach: uri=%s NOT ATTACHED YET" % (dbg, uri))
        # Mount the file system
        mnt_path = self._mount(dbg, nfs_server, sr_uuid)

        if not os.path.exists(sr_dir) or not os.path.isdir(sr_dir):
            raise ValueError('SR directory doesn\'t exist')

        # Start GC for this host
        COWCoalesce.start_gc(dbg, 'nfs-ng', sr)

        return sr
Beispiel #2
0
    def attach(self, dbg, configuration):
        uri = configuration['file-uri']
        log.debug('{}: SR.attach: config={}, uri={}'.format(
            dbg, configuration, uri))

        sr = urlparse.urlparse(uri).path

        # Start GC for this host
        COWCoalesce.start_gc(dbg, 'filebased', sr)

        return sr
Beispiel #3
0
    def detach(self, dbg, sr):
        # stop GC
        try:
            COWCoalesce.stop_gc(dbg, 'nfs-ng', sr)
        except:
            log.debug('GC already stopped')

        # Unmount the FS
        sr_path = urlparse.urlparse(sr).path
        mnt_path = os.path.dirname(sr_path)
        self._unmount(dbg, mnt_path)
        os.rmdir(mnt_path)
Beispiel #4
0
    def attach(self, dbg, configuration):
        uri = configuration['device']
        log.debug('{}: SR.attach: config={}, uri={}'.format(
            dbg, configuration, uri))

        dev_path = urlparse.urlparse(uri).path

        sr = self._mount_path(configuration['sr_uuid'])

        # SR.attach is idempotent
        if os.path.ismount(sr):
            log.debug('{}: SR.attach: already mounted on {}'.format(dbg, sr))
            return sr

        # Mount the ext4 filesystem
        util.mkdir_p(sr)
        ext4_mount(dbg, dev_path, sr)
        log.debug('{}: SR.attach: mounted on {}'.format(dbg, sr))

        # Start GC for this host
        COWCoalesce.start_gc(dbg, 'ext4-ng', sr)

        return sr
Beispiel #5
0
 def _detach(self, dbg, sr):
     # stop GC
     try:
         COWCoalesce.stop_gc(dbg, 'ext4-ng', sr)
     except:
         log.debug('GC already stopped')
Beispiel #6
0
 def detach(self, dbg, sr):
     # stop GC
     try:
         COWCoalesce.stop_gc(dbg, 'filebased', sr)
     except:
         log.debug('GC already stopped')