def create(self, sr_uuid, size): if self._checkmount(): raise xs_errors.XenError('SRExists') # Check none of the devices already in use by other PBDs if util.test_hostPBD_devs(self.session, sr_uuid, self.root): raise xs_errors.XenError('SRInUse') # Check serial number entry in SR records for dev in self.root.split(','): if util.test_scsiserial(self.session, dev): raise xs_errors.XenError('SRInUse') if not lvutil._checkVG(self.vgname): lvutil.createVG(self.root, self.vgname) if lvutil._checkLV(self.remotepath): raise xs_errors.XenError('SRExists') try: numdevs = len(self.root.split(',')) cmd = ["lvcreate", "-n", sr_uuid] if numdevs > 1: lowest = -1 for dev in self.root.split(','): stats = lvutil._getPVstats(dev) if lowest < 0 or stats['freespace'] < lowest: lowest = stats['freespace'] size_mb = (lowest / (1024 * 1024)) * numdevs # Add stripe parameter to command cmd += ["-i", str(numdevs), "-I", "2048"] else: stats = lvutil._getVGstats(self.vgname) size_mb = stats['freespace'] / (1024 * 1024) assert (size_mb > 0) cmd += ["-L", str(size_mb), self.vgname] text = util.pread(cmd) cmd = ["lvchange", "-ay", self.remotepath] text = util.pread(cmd) except util.CommandException as inst: raise xs_errors.XenError('LVMCreate', \ opterr='lv operation, error %d' % inst.code) except AssertionError: raise xs_errors.XenError('SRNoSpace', \ opterr='Insufficient space in VG %s' % self.vgname) try: util.pread2(["mkfs.ext4", "-F", self.remotepath]) except util.CommandException as inst: raise xs_errors.XenError('LVMFilesystem', \ opterr='mkfs failed error %d' % inst.code) #Update serial number string scsiutil.add_serial_record(self.session, self.sr_ref, \ scsiutil.devlist_to_serialstring(self.root.split(',')))
def create(self, sr_uuid, size): # THIS DRIVER IS DEPRECATED. RAISE. raise Exception( 'The `ext4` SR type is deprecated since XCP-ng 8.1.\n' 'Use the main `ext` driver instead. It will create an EXT4 filesystem now, ' 'not EXT3 anymore as it used to.') if self._checkmount(): raise xs_errors.XenError('SRExists') # Check none of the devices already in use by other PBDs if util.test_hostPBD_devs(self.session, sr_uuid, self.root): raise xs_errors.XenError('SRInUse') # Check serial number entry in SR records for dev in self.root.split(','): if util.test_scsiserial(self.session, dev): raise xs_errors.XenError('SRInUse') if not lvutil._checkVG(self.vgname): lvutil.createVG(self.root, self.vgname) if lvutil._checkLV(self.remotepath): raise xs_errors.XenError('SRExists') try: numdevs = len(self.root.split(',')) cmd = ["lvcreate", "-n", sr_uuid] if numdevs > 1: lowest = -1 for dev in self.root.split(','): stats = lvutil._getPVstats(dev) if lowest < 0 or stats['freespace'] < lowest: lowest = stats['freespace'] size_mb = (lowest / (1024 * 1024)) * numdevs # Add stripe parameter to command cmd += ["-i", str(numdevs), "-I", "2048"] else: stats = lvutil._getVGstats(self.vgname) size_mb = stats['freespace'] / (1024 * 1024) assert (size_mb > 0) cmd += ["-L", str(size_mb), self.vgname] text = util.pread(cmd) cmd = ["lvchange", "-ay", self.remotepath] text = util.pread(cmd) except util.CommandException, inst: raise xs_errors.XenError('LVMCreate', \ opterr='lv operation, error %d' % inst.code)
def create(self, sr_uuid, size): if self._checkmount(): raise xs_errors.XenError('SRExists') # Check none of the devices already in use by other PBDs if util.test_hostPBD_devs(self.session, sr_uuid, self.root): raise xs_errors.XenError('SRInUse') # Check serial number entry in SR records for dev in self.root.split(','): if util.test_scsiserial(self.session, dev): raise xs_errors.XenError('SRInUse') if not lvutil._checkVG(self.vgname): lvutil.createVG(self.root, self.vgname) if lvutil._checkLV(self.remotepath): raise xs_errors.XenError('SRExists') try: numdevs = len(self.root.split(',')) cmd = ["lvcreate", "-n", sr_uuid] if numdevs > 1: lowest = -1 for dev in self.root.split(','): stats = lvutil._getPVstats(dev) if lowest < 0 or stats['freespace'] < lowest: lowest = stats['freespace'] size_mb = (lowest / (1024 * 1024)) * numdevs # Add stripe parameter to command cmd += ["-i", str(numdevs), "-I", "2048"] else: stats = lvutil._getVGstats(self.vgname) size_mb = stats['freespace'] / (1024 * 1024) assert(size_mb > 0) cmd += ["-L", str(size_mb), self.vgname] text = util.pread(cmd) cmd = ["lvchange", "-ay", self.remotepath] text = util.pread(cmd) except util.CommandException, inst: raise xs_errors.XenError('LVMCreate', \ opterr='lv operation, error %d' % inst.code)
# One of the PV args failed, delete SR try: cmd = ["vgremove", self.vgname] util.pread2(cmd) except: pass raise xs_errors.XenError('LVMGroupCreate') if lvutil._checkLV(self.remotepath): raise xs_errors.XenError('SRExists') try: numdevs = len(self.root.split(',')) cmd = ["lvcreate", "-n", sr_uuid] if numdevs > 1: lowest = -1 for dev in self.root.split(','): stats = lvutil._getPVstats(dev) if lowest < 0 or stats['freespace'] < lowest: lowest = stats['freespace'] size_mb = (lowest / (1024 * 1024)) * numdevs # Add stripe parameter to command cmd += ["-i", str(numdevs), "-I", "2048"] else: stats = lvutil._getVGstats(self.vgname) size_mb = stats['freespace'] / (1024 * 1024) assert(size_mb > 0) cmd += ["-L", str(size_mb), self.vgname] text = util.pread(cmd) cmd = ["lvchange", "-ay", self.remotepath] text = util.pread(cmd)