示例#1
0
 def _do(self):
     assert(len(self.components) > 0)
     path = getMirrorDevPath(self.lvolid)
     if not os.path.exists(path):
         do_assemble = False
         mirrordevs = ""
         for c in self.components:
             blockdev_getsize(c.path) # XXX is this necessary?
             if c.mirror_status == MIRROR_STATUS['ALLOCATED']:
                 mirrordevs += " " + c.path
             elif c.mirror_status == MIRROR_STATUS['INSYNC']:
                 mirrordevs += " " + c.path
                 do_assemble = True
         mdcommand = ""
         if do_assemble:
             mdcommand = "mdadm --assemble %s %s %s" % \
                 (path, MDADM_ASSEMBLE_OPTIONS, mirrordevs)
             executemdadm(mdcommand)
         else: # all extents are ALLOCATED. do --create
             mdcommand = \
                 "mdadm --create %s %s --assume-clean --raid-devices=%d %s" \
                     % (path, MDADM_CREATE_OPTIONS, len(self.components), \
                     mirrordevs)
             executemdadm(mdcommand)
         blockdev_getsize(path) # XXX is this necessary?
     self.path = path
示例#2
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