コード例 #1
0
ファイル: eph.py プロジェクト: notbrain/scalarizr
    def create(self, volume, snapshot, tranzit_path, complete_cb=None):
        try:
            if snapshot.id in self._state_map:
                raise StorageError('Snapshot %s is already %s. Cannot create it again' % (
                                snapshot.id, self._state_map[snapshot.id]))

            clear_queue(self._upload_queue)

            if not os.path.exists(self._pigz_bin):
                if linux.os['family'] == 'Debian' and linux.os['release'] >= (10, 4):
                    pkgmgr.installed('pigz')
                elif linux.os['family'] == 'RedHat' and linux.os['release'] >= (6, 0):
                    pkgmgr.epel_repository()
                    pkgmgr.installed('pigz')


            self._chunks_md5 = {}
            self._state_map[snapshot.id] = Snapshot.CREATING
            #self.prepare_tranzit_vol(volume.tranzit_vol)
            snap_lv = self._lvm.create_lv_snapshot(volume.device, self.SNAPSHOT_LV_NAME, extents='100%FREE')
            self._logger.info('Created LVM snapshot %s for volume %s', snap_lv, volume.device)
            self._return_ev.clear()
            t = threading.Thread(name='%s creator' % snapshot.id, target=self._create,
                                                    args=(volume, snapshot, snap_lv, tranzit_path, complete_cb))
            t.start()
            self._return_ev.wait()
        except:
            if complete_cb:
                complete_cb()
            raise
        snapshot.snap_strategy = 'data'
        snapshot.path = os.path.join(volume.snap_backend['path'],
                                                                '%s.%s' % (snapshot.id, self.MANIFEST_NAME))
        return snapshot
コード例 #2
0
 def _gzip_bin(self):
     if self.try_pigz:
         mgr = pkgmgr.package_mgr()
         if not mgr.info('pigz')['installed']:
             try:
                 pkgmgr.epel_repository()
                 mgr.installed("pigz")
             except:
                 LOG.debug("PIGZ install with epel failed, using gzip."\
                                   " Caught %s", repr(sys.exc_info()[1]))
             else:
                 return self.pigz_bin
         else:
             return self.pigz_bin
     return self.gzip_bin
コード例 #3
0
    def create(self, volume, snapshot, tranzit_path, complete_cb=None):
        try:
            if snapshot.id in self._state_map:
                raise StorageError(
                    'Snapshot %s is already %s. Cannot create it again' %
                    (snapshot.id, self._state_map[snapshot.id]))

            clear_queue(self._upload_queue)

            if not os.path.exists(self._pigz_bin):
                if linux.os['family'] == 'Debian' and linux.os['release'] >= (
                        10, 4):
                    pkgmgr.installed('pigz')
                elif linux.os['family'] == 'RedHat' and linux.os[
                        'release'] >= (6, 0):
                    pkgmgr.epel_repository()
                    pkgmgr.installed('pigz')

            self._chunks_md5 = {}
            self._state_map[snapshot.id] = Snapshot.CREATING
            #self.prepare_tranzit_vol(volume.tranzit_vol)
            snap_lv = self._lvm.create_lv_snapshot(volume.device,
                                                   self.SNAPSHOT_LV_NAME,
                                                   extents='100%FREE')
            self._logger.info('Created LVM snapshot %s for volume %s', snap_lv,
                              volume.device)
            self._return_ev.clear()
            t = threading.Thread(name='%s creator' % snapshot.id,
                                 target=self._create,
                                 args=(volume, snapshot, snap_lv, tranzit_path,
                                       complete_cb))
            t.start()
            self._return_ev.wait()
        except:
            if complete_cb:
                complete_cb()
            raise
        snapshot.snap_strategy = 'data'
        snapshot.path = os.path.join(
            volume.snap_backend['path'],
            '%s.%s' % (snapshot.id, self.MANIFEST_NAME))
        return snapshot
コード例 #4
0
ファイル: largetransfer.py プロジェクト: ck1981/scalarizr
 def _check_pigz(self):
     try:
         pkgmgr.check_software(['pigz'])
     except pkgmgr.SoftwareError:
         pkgmgr.epel_repository()
         pkgmgr.installed('pigz', updatedb=True)
コード例 #5
0
ファイル: test_pkgmgr.py プロジェクト: chenleji/scalarizr
def test_epel_repository(system, install, info):
    info.return_value = {'installed': None}
    pkgmgr.epel_repository()
    install.assert_called_once_with(pkgmgr.EPEL_RPM_URL)
コード例 #6
0
def test_epel_repository(system, install, info):
    info.return_value = {'installed': None}
    pkgmgr.epel_repository()
    install.assert_called_once_with(pkgmgr.EPEL_RPM_URL)