예제 #1
0
 def resize_fs(device_path):
     """Resize the filesystem on the specified device"""
     VolumeHelper._check_device_exists(device_path)
     try:
         utils.execute("sudo", "resize2fs", device_path)
     except ProcessExecutionError as err:
         LOG.error(err)
         raise GuestError("Error resizing the filesystem: %s"
                                    % device_path)
예제 #2
0
 def resize_fs(self):
     """Resize the filesystem on the specified device"""
     self._check_device_exists()
     try:
         utils.execute("sudo", "resize2fs", self.device_path)
     except ProcessExecutionError as err:
         LOG.error(err)
         raise GuestError("Error resizing the filesystem: %s" %
                          self.device_path)
예제 #3
0
 def migrate_data(device_path, mysql_base):
     """ Synchronize the data from the mysql directory to the new volume """
     utils.execute("sudo", "mkdir", "-p", TMP_MOUNT_POINT)
     VolumeHelper.mount(device_path, TMP_MOUNT_POINT)
     if not mysql_base[-1] == '/':
         mysql_base = "%s/" % mysql_base
     utils.execute("sudo", "rsync", "--safe-links", "--perms",
                   "--recursive", "--owner", "--group", "--xattrs",
                   "--sparse", mysql_base, TMP_MOUNT_POINT)
     VolumeHelper.unmount(device_path)
예제 #4
0
 def migrate_data(self, mysql_base):
     """ Synchronize the data from the mysql directory to the new volume """
     # Use sudo to have access to this spot.
     utils.execute("sudo", "mkdir", "-p", TMP_MOUNT_POINT)
     self._tmp_mount(TMP_MOUNT_POINT)
     if not mysql_base[-1] == '/':
         mysql_base = "%s/" % mysql_base
     utils.execute("sudo", "rsync", "--safe-links", "--perms",
                   "--recursive", "--owner", "--group", "--xattrs",
                   "--sparse", mysql_base, TMP_MOUNT_POINT)
     self.unmount()
예제 #5
0
파일: volume.py 프로젝트: DJohnstone/trove
 def migrate_data(self, mysql_base):
     """ Synchronize the data from the mysql directory to the new volume """
     # Use sudo to have access to this spot.
     utils.execute("sudo", "mkdir", "-p", TMP_MOUNT_POINT)
     self._tmp_mount(TMP_MOUNT_POINT)
     if not mysql_base[-1] == '/':
         mysql_base = "%s/" % mysql_base
     utils.execute("sudo", "rsync", "--safe-links", "--perms",
                   "--recursive", "--owner", "--group", "--xattrs",
                   "--sparse", mysql_base, TMP_MOUNT_POINT)
     self.unmount()
예제 #6
0
 def write_to_fstab(self):
     fstab_line = ("%s\t%s\t%s\t%s\t0\t0" %
                   (self.device_path, self.mount_point, self.volume_fstype,
                    self.mount_options))
     LOG.debug("Writing new line to fstab:%s" % fstab_line)
     utils.execute("sudo", "cp", "/etc/fstab", "/etc/fstab.orig")
     utils.execute("sudo", "cp", "/etc/fstab", "/tmp/newfstab")
     utils.execute("sudo", "chmod", "666", "/tmp/newfstab")
     with open("/tmp/newfstab", 'a') as new_fstab:
         new_fstab.write("\n" + fstab_line)
     utils.execute("sudo", "chmod", "640", "/tmp/newfstab")
     utils.execute("sudo", "mv", "/tmp/newfstab", "/etc/fstab")
예제 #7
0
파일: volume.py 프로젝트: DJohnstone/trove
 def write_to_fstab(self):
     fstab_line = ("%s\t%s\t%s\t%s\t0\t0" %
                   (self.device_path, self.mount_point, self.volume_fstype,
                    self.mount_options))
     LOG.debug("Writing new line to fstab:%s" % fstab_line)
     utils.execute("sudo", "cp", "/etc/fstab", "/etc/fstab.orig")
     utils.execute("sudo", "cp", "/etc/fstab", "/tmp/newfstab")
     utils.execute("sudo", "chmod", "666", "/tmp/newfstab")
     with open("/tmp/newfstab", 'a') as new_fstab:
         new_fstab.write("\n" + fstab_line)
     utils.execute("sudo", "chmod", "640", "/tmp/newfstab")
     utils.execute("sudo", "mv", "/tmp/newfstab", "/etc/fstab")
예제 #8
0
    def _check_device_exists(device_path):
        """Check that the device path exists.

        Verify that the device path has actually been created and can report
        it's size, only then can it be available for formatting, retry
        num_tries to account for the time lag.
        """
        try:
            num_tries = CONFIG.get('num_tries', 3)
            utils.execute('sudo', 'blockdev', '--getsize64', device_path,
                          attempts=num_tries)
        except ProcessExecutionError:
            raise GuestError("InvalidDevicePath(path=%s)" % device_path)
예제 #9
0
    def pkg_install(self, package_name, time_out):
        """Installs a package."""
        try:
            utils.execute("apt-get", "update", run_as_root=True,
                          root_helper="sudo")
        except ProcessExecutionError as e:
            LOG.error(_("Error updating the apt sources"))

        result = self._install(package_name, time_out)
        if result != OK:
            if result == RUN_DPKG_FIRST:
                self._fix(time_out)
            result = self._install(package_name, time_out)
            if result != OK:
                raise PkgPackageStateError("Package %s is in a bad state."
                                           % package_name)
예제 #10
0
    def _check_device_exists(self):
        """Check that the device path exists.

        Verify that the device path has actually been created and can report
        it's size, only then can it be available for formatting, retry
        num_tries to account for the time lag.
        """
        try:
            num_tries = CONFIG.get('num_tries', 3)
            utils.execute('sudo',
                          'blockdev',
                          '--getsize64',
                          self.device_path,
                          attempts=num_tries)
        except ProcessExecutionError:
            raise GuestError("InvalidDevicePath(path=%s)" % self.device_path)
예제 #11
0
파일: pkg.py 프로젝트: tanisdeluna/reddwarf
def pkg_install(package_name, time_out):
    """Installs a package."""
    try:
        utils.execute("apt-get",
                      "update",
                      run_as_root=True,
                      root_helper="sudo")
    except ProcessExecutionError as e:
        LOG.error(_("Error updating the apt sources"))

    result = _install(package_name, time_out)
    if result != OK:
        if result == RUN_DPKG_FIRST:
            _fix(time_out)
        result = _install(package_name, time_out)
        if result != OK:
            raise PkgPackageStateError("Package %s is in a bad state." %
                                       package_name)
예제 #12
0
파일: dbaas.py 프로젝트: cp16net/reddwarf-1
def load_mysqld_options():
    try:
        out, err = utils.execute("/usr/sbin/mysqld", "--print-defaults",
                                 run_as_root=True)
        arglist = re.split("\n", out)[1].split()
        args = {}
        for item in arglist:
            if "=" in item:
                key, value = item.split("=")
                args[key.lstrip("--")] = value
            else:
                args[item.lstrip("--")] = None
        return args
    except ProcessExecutionError as e:
        return None
예제 #13
0
def load_mysqld_options():
    try:
        out, err = utils.execute("/usr/sbin/mysqld",
                                 "--print-defaults",
                                 run_as_root=True)
        arglist = re.split("\n", out)[1].split()
        args = {}
        for item in arglist:
            if "=" in item:
                key, value = item.split("=")
                args[key.lstrip("--")] = value
            else:
                args[item.lstrip("--")] = None
        return args
    except ProcessExecutionError as e:
        return None
예제 #14
0
파일: base.py 프로젝트: DJohnstone/trove
 def _run_prepare(self):
     if hasattr(self, 'prepare_cmd'):
         LOG.info("Running innobackupex prepare...")
         self.prep_retcode = utils.execute(self.prepare_cmd,
                                           shell=True)
         LOG.info("Innobackupex prepare finished successfully")
예제 #15
0
 def _run_prepare(self):
     if hasattr(self, 'prepare_cmd'):
         LOG.info("Running innobackupex prepare...")
         self.prep_retcode = utils.execute(self.prepare_cmd, shell=True)
         LOG.info("Innobackupex prepare finished successfully")