Example #1
0
 def _setup_vol_groups(self):
     LOG.info("Attempting to setup volume groups for nova volume management.")
     mp = dict()
     backing_file = self.cfg.get('nova', 'volume_backing_file')
     # check if we need to have a default backing file
     if not backing_file:
         backing_file = sh.joinpths(self.appdir, 'nova-volumes-backing-file')
     vol_group = self.cfg.get('nova', 'volume_group')
     backing_file_size = utils.to_bytes(self.cfg.get('nova', 'volume_backing_file_size'))
     mp['VOLUME_GROUP'] = vol_group
     mp['VOLUME_BACKING_FILE'] = backing_file
     mp['VOLUME_BACKING_FILE_SIZE'] = backing_file_size
     try:
         utils.execute_template(*VG_CHECK_CMD, params=mp)
         LOG.warn("Volume group already exists: %s" % (vol_group))
     except exceptions.ProcessExecutionError as err:
         # Check that the error from VG_CHECK is an expected error
         if err.exit_code != 5:
             raise
         LOG.info("Need to create volume group: %s" % (vol_group))
         sh.touch_file(backing_file, die_if_there=False, file_size=backing_file_size)
         vg_dev_result = utils.execute_template(*VG_DEV_CMD, params=mp)
         if vg_dev_result and vg_dev_result[0]:
             LOG.debug("VG dev result: %s" % (vg_dev_result))
             # Strip the newlines out of the stdout (which is in the first
             # element of the first (and only) tuple in the response
             (sysout, _) = vg_dev_result[0]
             mp['DEV'] = sysout.replace('\n', '')
             utils.execute_template(*VG_CREATE_CMD, params=mp)
     # One way or another, we should have the volume group, Now check the
     # logical volumes
     self._process_lvs(mp)
     # Finish off by restarting tgt, and ignore any errors
     utils.execute_template(*RESTART_TGT_CMD, check_exit_code=False)
Example #2
0
 def _create_data_location(self):
     loop_size = self.cfg.get('swift', 'loopback_disk_size')
     if not loop_size:
         loop_size = DEF_LOOP_SIZE
     else:
         loop_size = utils.to_bytes(loop_size)
     sh.create_loopback_file(fname=self.fs_image,
                             size=loop_size,
                             fs_type=FS_TYPE)
     self.tracewriter.file_touched(self.fs_image)
     sh.mount_loopback_file(self.fs_image, self.fs_dev, FS_TYPE)
     sh.chown_r(self.fs_dev, sh.geteuid(), sh.getegid())
Example #3
0
 def _create_data_location(self):
     loop_size = self.cfg.get('swift', 'loopback_disk_size')
     if not loop_size:
         loop_size = DEF_LOOP_SIZE
     else:
         loop_size = utils.to_bytes(loop_size)
     sh.create_loopback_file(fname=self.fs_image,
                             size=loop_size,
                             fs_type=FS_TYPE)
     self.tracewriter.file_touched(self.fs_image)
     sh.mount_loopback_file(self.fs_image, self.fs_dev, FS_TYPE)
     sh.chown_r(self.fs_dev, sh.geteuid(), sh.getegid())
Example #4
0
 def _setup_vol_groups(self):
     LOG.info(
         "Attempting to setup volume groups for nova volume management.")
     mp = dict()
     backing_file = self.cfg.getdefaulted(
         'nova', 'volume_backing_file',
         sh.joinpths(self.app_dir, 'nova-volumes-backing-file'))
     vol_group = self.cfg.getdefaulted('nova', 'volume_group',
                                       'nova-volumes')
     backing_file_size = utils.to_bytes(
         self.cfg.getdefaulted('nova', 'volume_backing_file_size', '2052M'))
     mp['VOLUME_GROUP'] = vol_group
     mp['VOLUME_BACKING_FILE'] = backing_file
     mp['VOLUME_BACKING_FILE_SIZE'] = backing_file_size
     try:
         utils.execute_template(*VG_CHECK_CMD, params=mp)
         LOG.warn("Volume group already exists: %r" % (vol_group))
     except exceptions.ProcessExecutionError as err:
         # Check that the error from VG_CHECK is an expected error
         if err.exit_code != 5:
             raise
         LOG.info("Need to create volume group: %r" % (vol_group))
         sh.touch_file(backing_file,
                       die_if_there=False,
                       file_size=backing_file_size)
         vg_dev_result = utils.execute_template(*VG_DEV_CMD, params=mp)
         if vg_dev_result and vg_dev_result[0]:
             LOG.debug("VG dev result: %s" % (vg_dev_result))
             # Strip the newlines out of the stdout (which is in the first
             # element of the first (and only) tuple in the response
             (sysout, _) = vg_dev_result[0]
             mp['DEV'] = sysout.replace('\n', '')
             utils.execute_template(*VG_CREATE_CMD, params=mp)
     # One way or another, we should have the volume group, Now check the
     # logical volumes
     self._process_lvs(mp)
     # Finish off by restarting tgt, and ignore any errors
     cmdrestart = self.distro.get_command('iscsi', 'restart', quiet=True)
     if cmdrestart:
         sh.execute(*cmdrestart, run_as_root=True, check_exit_code=False)