Exemple #1
0
    def registerShredRequest(self, data):
        def vbtomb(vb):
            mb = vbtos(vb) / (1024 * 1024 / 512)
            tvb, todd = stovb(mb * (1024 * 1024 / 512))
            if tvb != vb or todd != 0:
                logger.info("vb %s != %s (%s)" % \
                    (stovb(mb * (1024 * 1024 / 512)), vb, mb))
                raise xmlrpclib.Fault(errno.EINVAL, 'EINVAL')
            return mb

        self.event_record.lock()
        try:
            eventid, dextid, pdskid, offset, capacity = \
                mand_keys(data, 'eventid', 'dextid', 'pdskid', 'offset', \
                'capacity')
            if self.event_record.event_exist(eventid):
                self.event_record.unlock()
                return 0
            local_path = '%s/%08x' % (VAS_PDSK_DIR, pdskid)
            # XXX wait for ssvr_reporter creating symlinks.
            execute_retry_not_path_exist("false", local_path, 16)
            self.__start_shredder(eventid, local_path, vbtomb(offset), \
                vbtomb(capacity), dextid, pdskid)
            self.event_record.add_event(eventid, EVENT_STATUS['PROGRESS'])
            self.event_record.unlock()
        except xmlrpclib.Fault:
            self.event_record.unlock()
            raise
        except Exception:
            self.event_record.unlock()
            logger.error(traceback.format_exc())
            raise xmlrpclib.Fault(500, 'Internal Server Error')
        return 0
Exemple #2
0
 def do(self):
     assert(len(self.components) > 0)
     name = getSnapshotOriginDevName(self.lvolid)
     path = getDmDevPath(name)
     if not os.path.exists(path):
         c = self.components[0]
         command = "echo 0 %s snapshot-origin %s | dmsetup create %s" % \
             (gtos(self.capacity), c.path, name)
         execute_retry_not_path_exist(command, path, DMSETUP_RETRY_TIMES)
     self.path = path
Exemple #3
0
 def do(self):
     assert(len(self.components) > 0)
     name = getSnapshotDevName(self.lvolid)
     path = getDmDevPath(name)
     if not os.path.exists(path):
         origin_path = getSnapshotOriginOriginPath( \
             self.snapshot_origin_lvolid)
         origin_size = blockdev_getsize(origin_path)
         c = self.components[0]
         command = \
             "echo 0 %s snapshot %s %s P %u | dmsetup create --readonly %s" \
             % (origin_size, origin_path, c.path, SNAPSHOT_CHUNK_SIZE, name)
         execute_retry_not_path_exist(command, path, DMSETUP_RETRY_TIMES)
     self.path = path
Exemple #4
0
 def do(self):
     assert len(self.components) == 1
     c = self.components[0]
     assert c.iscsi_ref != None
     name = getDextDevName(self.dext_ssvrid, self.lvolid)
     path = getDmDevPath(name)
     if not os.path.exists(path):
         command = "echo 0 %s linear %s %s | dmsetup create %s" % (
             vbtos(self.capacity),
             c.path,
             vbtos(self.dext_offset),
             name,
         )
         execute_retry_not_path_exist(command, path, DMSETUP_RETRY_TIMES)
     self.path = path
     os.close(c.iscsi_ref)
     c.iscsi_ref = None
Exemple #5
0
 def do(self):
     assert(len(self.components) > 0)
     s = ""
     offset = 0
     total_sectors = gtos(self.capacity)
     for c in self.components:
         assert c.path
         real_size = executecommand("blockdev --getsize %s" % c.path)
         c_sectors = min([int(real_size), total_sectors - offset])
         s += "%d %d linear %s 0\\n" % (offset, c_sectors, c.path)
         offset += c_sectors
     name = getLinearDevName(self.lvolid)
     path = getLinearDevPath(self.lvolid)
     if not os.path.exists(path):
         command = "echo -e \"%s\" | dmsetup create %s" % (s, name)
         execute_retry_not_path_exist(command, path, DMSETUP_RETRY_TIMES)
     self.path = path