def mount_volume(self, context, device_path=None, mount_point=None): device = volume.VolumeDevice(device_path) device.mount(mount_point, write_to_fstab=False) LOG.debug("Mounted the device %s at the mount point %s." % (device_path, mount_point))
def unmount_volume(self, context, device_path=None, mount_point=None): device = volume.VolumeDevice(device_path) device.unmount(mount_point) LOG.debug("Unmounted the device %s from the mount point %s." % (device_path, mount_point))
def _set_readahead_for_disks(self): """This method sets readhead size for disks as needed by Vertica.""" device = volume.VolumeDevice(CONF.device_path) device.set_readahead_size(CONF.vertica.readahead_size) LOG.debug("Set readhead size as required by Vertica.")
def resize_fs(self, context, device_path=None, mount_point=None): device = volume.VolumeDevice(device_path) device.resize_fs(mount_point) LOG.debug("Resized the filesystem at %s." % mount_point)
def setUp(self): super(VolumeDeviceTest, self).setUp() self.volumeDevice = volume.VolumeDevice('/dev/vdb')
def do_prepare(self, context, packages, databases, memory_mb, users, device_path, mount_point, backup_info, config_contents, root_password, overrides, cluster_config, snapshot): """This is called from prepare in the base class.""" self.app.install_if_needed(packages) self.app.init_storage_structure(mount_point) if config_contents or device_path or backup_info: # FIXME(pmalik) Once the cassandra bug # https://issues.apache.org/jira/browse/CASSANDRA-2356 # is fixed, this code may have to be revisited. # # Cassandra generates system keyspaces on the first start. # The stored properties include the 'cluster_name', which once # saved cannot be easily changed without removing the system # tables. It is crucial that the service does not boot up in # the middle of the configuration procedure. # We wait here for the service to come up, stop it properly and # remove the generated keyspaces before proceeding with # configuration. If it does not start up within the time limit # we assume it is not going to and proceed with configuration # right away. LOG.debug("Waiting for database first boot.") if (self.app.status.wait_for_real_status_to_change_to( trove_instance.ServiceStatuses.RUNNING, CONF.state_change_wait_time, False)): LOG.debug("Stopping database prior to initial configuration.") self.app.stop_db() self.app._remove_system_tables() LOG.debug("Starting initial configuration.") if config_contents: LOG.debug("Applying configuration.") self.app.configuration_manager.save_configuration( config_contents) cluster_name = None if cluster_config: cluster_name = cluster_config.get('id', None) self.app.apply_initial_guestagent_configuration( cluster_name=cluster_name) if cluster_config: self.app.write_cluster_topology(cluster_config['dc'], cluster_config['rack'], prefer_local=True) if device_path: LOG.debug("Preparing data volume.") device = volume.VolumeDevice(device_path) # unmount if device is already mounted device.unmount_device(device_path) device.format() if os.path.exists(mount_point): # rsync exiting data LOG.debug("Migrating existing data.") device.migrate_data(mount_point) # mount the volume LOG.debug("Mounting new volume.") device.mount(mount_point) if not cluster_config: if backup_info: self._perform_restore(backup_info, context, mount_point) LOG.debug("Starting database with configuration changes.") self.app.start_db(update_db=False) if not self.app.has_user_config(): LOG.debug("Securing superuser access.") self.app.secure() self.app.restart() self._admin = self.app.build_admin() if not cluster_config and self.is_root_enabled(context): self.status.report_root(context)
def unmount_volume(self, context, device_path=None, mount_point=None): LOG.debug("Unmounting the volume.") device = volume.VolumeDevice(device_path) device.unmount(mount_point) LOG.debug("Unmounted the volume.")
def prepare(self, context, packages, databases, memory_mb, users, device_path=None, mount_point=None, backup_info=None, config_contents=None, root_password=None, overrides=None, cluster_config=None, snapshot=None): """Makes ready DBAAS on a Guest container.""" MySqlAppStatus.get().begin_install() # status end_mysql_install set with secure() app = MySqlApp(MySqlAppStatus.get()) app.install_if_needed(packages) if device_path: # stop and do not update database app.stop_db() device = volume.VolumeDevice(device_path) # unmount if device is already mounted device.unmount_device(device_path) device.format() if os.path.exists(mount_point): # rsync existing data to a "data" sub-directory # on the new volume device.migrate_data(mount_point, target_subdir="data") # mount the volume device.mount(mount_point) operating_system.chown( mount_point, service.MYSQL_OWNER, service.MYSQL_OWNER, recursive=False, as_root=True) LOG.debug("Mounted the volume at %s." % mount_point) # We need to temporarily update the default my.cnf so that # mysql will start after the volume is mounted. Later on it # will be changed based on the config template # (see MySqlApp.secure()) and restart. app.set_data_dir(mount_point + '/data') app.start_mysql() if backup_info: self._perform_restore(backup_info, context, mount_point + "/data", app) LOG.debug("Securing MySQL now.") app.secure(config_contents, overrides) enable_root_on_restore = (backup_info and MySqlAdmin().is_root_enabled()) if root_password and not backup_info: app.secure_root(secure_remote_root=True) MySqlAdmin().enable_root(root_password) elif enable_root_on_restore: app.secure_root(secure_remote_root=False) MySqlAppStatus.get().report_root(context, 'root') else: app.secure_root(secure_remote_root=True) app.complete_install_or_restart() if databases: self.create_database(context, databases) if users: self.create_user(context, users) if snapshot: self.attach_replica(context, snapshot, snapshot['config']) LOG.info(_('Completed setup of MySQL database instance.'))
def prepare(self, context, packages, databases, memory_mb, users, device_path=None, mount_point=None, backup_info=None, config_contents=None, root_password=None, overrides=None, cluster_config=None): """Makes ready DBAAS on a Guest container.""" LOG.debug("Prepare MongoDB instance") self.status.begin_install() self.app.install_if_needed(packages) self.app.stop_db() self.app.clear_storage() mount_point = system.MONGODB_MOUNT_POINT if device_path: device = volume.VolumeDevice(device_path) # unmount if device is already mounted device.unmount_device(device_path) device.format() if os.path.exists(system.MONGODB_MOUNT_POINT): device.migrate_data(mount_point) device.mount(mount_point) operating_system.update_owner('mongodb', 'mongodb', mount_point) LOG.debug("Mounted the volume %(path)s as %(mount)s" % { 'path': device_path, "mount": mount_point }) conf_changes = self.get_config_changes(cluster_config, mount_point) config_contents = self.app.update_config_contents( config_contents, conf_changes) if cluster_config is None: self.app.start_db_with_conf_changes(config_contents) else: if cluster_config['instance_type'] == "query_router": self.app.reset_configuration( {'config_contents': config_contents}) self.app.write_mongos_upstart() self.app.status.is_query_router = True # don't start mongos until add_config_servers is invoked elif cluster_config['instance_type'] == "config_server": self.app.status.is_config_server = True self.app.start_db_with_conf_changes(config_contents) elif cluster_config['instance_type'] == "member": self.app.start_db_with_conf_changes(config_contents) else: LOG.error("Bad cluster configuration; instance type given " "as %s" % cluster_config['instance_type']) self.status.set_status(ds_instance.ServiceStatuses.FAILED) return self.status.set_status(ds_instance.ServiceStatuses.BUILD_PENDING) LOG.info(_('"prepare" call has finished.'))
def mount_volume(self, context, device_path=None, mount_point=None): LOG.debug("Mounting the volume.") device = volume.VolumeDevice(device_path) device.mount(mount_point, write_to_fstab=False) LOG.debug("Mounted the volume.")
def prepare(self, context, packages, databases, memory_mb, users, device_path=None, mount_point=None, backup_info=None, config_contents=None, root_password=None, overrides=None, cluster_config=None, snapshot=None): """Makes ready DBAAS on a Guest container.""" LOG.debug("Preparing MongoDB instance.") self.app.status.begin_install() self.app.install_if_needed(packages) self.app.wait_for_start() self.app.stop_db() self.app.clear_storage() mount_point = system.MONGODB_MOUNT_POINT if device_path: device = volume.VolumeDevice(device_path) # unmount if device is already mounted device.unmount_device(device_path) device.format() if os.path.exists(system.MONGODB_MOUNT_POINT): device.migrate_data(mount_point) device.mount(mount_point) operating_system.chown(mount_point, system.MONGO_USER, system.MONGO_USER, as_root=True) LOG.debug("Mounted the volume %(path)s as %(mount)s." % { 'path': device_path, "mount": mount_point }) if config_contents: # Save resolved configuration template first. self.app.configuration_manager.save_configuration(config_contents) # Apply guestagent specific configuration changes. self.app.apply_initial_guestagent_configuration( cluster_config, mount_point) if not cluster_config: # Create the Trove admin user. self.app.secure() # Don't start mongos until add_config_servers is invoked, # don't start members as they should already be running. if not (self.app.is_query_router or self.app.is_cluster_member): self.app.start_db(update_db=True) if not cluster_config and backup_info: self._perform_restore(backup_info, context, mount_point, self.app) if service.MongoDBAdmin().is_root_enabled(): self.app.status.report_root(context, 'root') if not cluster_config and root_password: LOG.debug('Root password provided. Enabling root.') service.MongoDBAdmin().enable_root(root_password) if not cluster_config: if databases: self.create_database(context, databases) if users: self.create_user(context, users) if cluster_config: self.app.status.set_status( ds_instance.ServiceStatuses.BUILD_PENDING) else: self.app.complete_install_or_restart() LOG.info(_('Completed setup of MongoDB database instance.'))
def resize_fs(self, context, device_path=None, mount_point=None): """Resize the filesystem as specified by device_path at mount_point.""" device = volume.VolumeDevice(device_path) device.resize_fs(mount_point) LOG.debug( "Resized the filesystem at {mount}.".format(mount=mount_point))
def unmount_volume(self, context, device_path=None, mount_point=None): """Unmount the volume as specified by device_path from mount_point.""" device = volume.VolumeDevice(device_path) device.unmount(mount_point) LOG.debug("Unmounted device {device} from mount point {mount}.".format( device=device_path, mount=mount_point))
def mount_volume(self, context, device_path=None, mount_point=None): """Mount the volume as specified by device_path to mount_point.""" device = volume.VolumeDevice(device_path) device.mount(mount_point, write_to_fstab=False) LOG.debug("Mounted device {device} at mount point {mount}.".format( device=device_path, mount=mount_point))
def unmount_volume(self, context, device_path=None, mount_point=None): LOG.debug("Unmounting the device %(path)s from the mount point " "%(mount_point)s.", {'path': device_path, 'mount_point': mount_point}) device = volume.VolumeDevice(device_path) device.unmount(mount_point)