Esempio n. 1
0
    def do_prepare(
        self,
        context,
        packages,
        databases,
        memory_mb,
        users,
        device_path,
        mount_point,
        backup_info,
        config_contents,
        root_password,
        overrides,
        cluster_config,
        snapshot,
    ):
        pgutil.PG_ADMIN = self.PG_BUILTIN_ADMIN
        self.install(context, packages)
        self.stop_db(context)
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.configuration_manager.save_configuration(config_contents)
        self.apply_initial_guestagent_configuration()
        self.start_db(context)

        if backup_info:
            backup.restore(context, backup_info, "/tmp")
            pgutil.PG_ADMIN = self.ADMIN_USER
        else:
            self._secure(context)
Esempio n. 2
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info, config_contents,
                   root_password, overrides, cluster_config, snapshot):
        pgutil.PG_ADMIN = self.PG_BUILTIN_ADMIN
        self.install(context, packages)
        self.stop_db(context)
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.configuration_manager.save_configuration(config_contents)
        self.apply_initial_guestagent_configuration()

        if backup_info:
            pgutil.PG_ADMIN = self.ADMIN_USER
            backup.restore(context, backup_info, '/tmp')
            pgutil.PG_ADMIN = self.ADMIN_USER

        if snapshot:
            LOG.info("Found snapshot info: " + str(snapshot))
            self.attach_replica(context, snapshot, snapshot['config'])

        self.start_db(context)

        if not backup_info:
            self._secure(context)

        if root_password and not backup_info:
            self.enable_root(context, root_password)
Esempio n. 3
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info, config_contents,
                   root_password, overrides, cluster_config, snapshot):
        pgutil.PG_ADMIN = self.PG_BUILTIN_ADMIN
        self.install(context, packages)
        self.stop_db(context)
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.configuration_manager.save_configuration(config_contents)
        self.apply_initial_guestagent_configuration()

        if backup_info:
            pgutil.PG_ADMIN = self.ADMIN_USER
            backup.restore(context, backup_info, '/tmp')
            pgutil.PG_ADMIN = self.ADMIN_USER

        if snapshot:
            LOG.info("Found snapshot info: " + str(snapshot))
            self.attach_replica(context, snapshot, snapshot['config'])

        self.start_db(context)

        if not backup_info:
            self._secure(context)

        if root_password and not backup_info:
            self.enable_root(context, root_password)
Esempio n. 4
0
 def _perform_restore(self, backup_info, context, restore_location, app):
     LOG.info(_("Restoring database from backup %s.") % backup_info["id"])
     try:
         backup.restore(context, backup_info, restore_location)
     except Exception:
         LOG.exception(_("Error performing restore from backup %s.") % backup_info["id"])
         app.status.set_status(rd_instance.ServiceStatuses.FAILED)
         raise
     LOG.info(_("Restored database successfully."))
Esempio n. 5
0
 def _perform_restore(self, backup_id, context, restore_location, app):
     LOG.info(_("Restoring database from backup %s" % backup_id))
     try:
         backup.restore(context, backup_id, restore_location)
     except Exception as e:
         LOG.error(e)
         LOG.error("Error performing restore from backup %s", backup_id)
         app.status.set_status(rd_models.ServiceStatuses.FAILED)
         raise
     LOG.info(_("Restored database successfully"))
Esempio n. 6
0
 def _perform_restore(self, backup_info, context, restore_location, app):
     LOG.info("Restoring database from backup %s.", backup_info['id'])
     try:
         backup.restore(context, backup_info, restore_location)
     except Exception:
         LOG.exception("Error performing restore from backup %s.",
                       backup_info['id'])
         self.status.set_status(ds_instance.ServiceStatuses.FAILED)
         raise
     LOG.info("Restored database successfully.")
Esempio n. 7
0
 def _perform_restore(self, backup_id, context, restore_location, app):
     LOG.info(_("Restoring database from backup %s") % backup_id)
     try:
         backup.restore(context, backup_id, restore_location)
     except Exception as e:
         LOG.error(e)
         LOG.error("Error performing restore from backup %s", backup_id)
         app.status.set_status(rd_models.ServiceStatuses.FAILED)
         raise
     LOG.info(_("Restored database successfully"))
Esempio n. 8
0
 def _perform_restore(self, backup_info, context, restore_location, app):
     LOG.info(_("Restoring database from backup %s") % backup_info['id'])
     try:
         backup.restore(context, backup_info, restore_location)
     except Exception as e:
         LOG.error(e)
         LOG.error(_("Error performing restore from backup %s") %
                   backup_info['id'])
         self.status.set_status(ds_instance.ServiceStatuses.FAILED)
         raise
     LOG.info(_("Restored database successfully"))
Esempio n. 9
0
 def _perform_restore(self, backup_info, context, restore_location):
     try:
         backup.restore(context, backup_info, restore_location)
         if self._appstatus.is_running:
             raise RuntimeError("Cannot reset the cluster name."
                                "The service is still running.")
         self._app.stop_db()
     except Exception as exp:
         LOG.error("backup_info[id] = %s.", backup_info['id'])
         self._app.status.set_status(ServiceStatuses.FAILED)
         raise exp
     LOG.info("Restored database successfully.")
Esempio n. 10
0
 def _perform_restore(self, backup_info, context, restore_location, app):
     LOG.info(_("Restoring database from backup %s.") % backup_info['id'])
     try:
         backup.restore(context, backup_info, restore_location)
     except Exception:
         LOG.exception(_("Error performing restore from backup %s.") %
                       backup_info['id'])
         app.status.set_status(ds_instance.ServiceStatuses.FAILED)
         raise
     self.admin.delete_conf_cache()
     self.app.paths.update_db_name(self.admin.database_name)
     LOG.info(_("Restored database successfully."))
Esempio n. 11
0
 def _perform_restore(self, backup_info, context, restore_location):
     LOG.info("Restoring database from backup %s.", backup_info['id'])
     try:
         backup.restore(context, backup_info, restore_location)
         self.app._apply_post_restore_updates(backup_info)
     except Exception as e:
         LOG.error(e)
         LOG.error("Error performing restore from backup %s.",
                   backup_info['id'])
         self.app.status.set_status(trove_instance.ServiceStatuses.FAILED)
         raise
     LOG.info("Restored database successfully.")
Esempio n. 12
0
 def _perform_restore(self, backup_info, context, restore_location):
     LOG.info(_("Restoring database from backup %s.") % backup_info['id'])
     try:
         backup.restore(context, backup_info, restore_location)
         self.app._apply_post_restore_updates(backup_info)
     except Exception as e:
         LOG.error(e)
         LOG.error(_("Error performing restore from backup %s.") %
                   backup_info['id'])
         self.app.status.set_status(trove_instance.ServiceStatuses.FAILED)
         raise
     LOG.info(_("Restored database successfully."))
Esempio n. 13
0
 def _perform_restore(self, backup_info, context, restore_location, app):
     LOG.info(_("Restoring database from backup %s.") % backup_info['id'])
     try:
         backup.restore(context, backup_info, restore_location)
     except Exception:
         LOG.exception(
             _("Error performing restore from backup %s.") %
             backup_info['id'])
         app.status.set_status(ds_instance.ServiceStatuses.FAILED)
         raise
     self.admin.delete_conf_cache()
     self.app.paths.update_db_name(self.admin.database_name)
     LOG.info(_("Restored database successfully."))
Esempio n. 14
0
 def _perform_restore(self, backup_info, context, restore_location):
     """
     Restores all CouchDB databases and their documents from the
     backup.
     """
     LOG.info("Restoring database from backup %s", backup_info['id'])
     try:
         backup.restore(context, backup_info, restore_location)
     except Exception:
         LOG.exception("Error performing restore from backup %s",
                       backup_info['id'])
         self.status.set_status(rd_instance.ServiceStatuses.FAILED)
         raise
     LOG.info("Restored database successfully")
Esempio n. 15
0
 def _perform_restore(self, backup_info, context, restore_location):
     """
     Restores all couchbase buckets and their documents from the
     backup.
     """
     LOG.info(_("Restoring database from backup %s") % backup_info["id"])
     try:
         backup.restore(context, backup_info, restore_location)
     except Exception as e:
         LOG.error(_("Error performing restore from backup %s") % backup_info["id"])
         LOG.error(e)
         self.status.set_status(rd_instance.ServiceStatuses.FAILED)
         raise
     LOG.info(_("Restored database successfully"))
Esempio n. 16
0
    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
    ):
        self.install(context, packages)
        PgSqlAppStatus.get().begin_restart()
        self.stop_db(context)
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.reset_configuration(context, config_contents)
        self.set_db_to_listen(context)
        self.start_db(context)

        if backup_info:
            backup.restore(context, backup_info, '/tmp')

        if root_password and not backup_info:
            self.enable_root(context, root_password)

        PgSqlAppStatus.get().end_install_or_restart()

        if databases:
            self.create_database(context, databases)

        if users:
            self.create_user(context, users)
Esempio n. 17
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info, config_contents,
                   root_password, overrides, cluster_config, snapshot):
        self.install(context, packages)
        self.stop_db(context)
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.reset_configuration(context, config_contents)
        self.set_db_to_listen(context)
        self.start_db(context)

        if backup_info:
            backup.restore(context, backup_info, '/tmp')

        if root_password and not backup_info:
            self.enable_root(context, root_password)
Esempio n. 18
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info, config_contents,
                   root_password, overrides, cluster_config, snapshot):
        self.install(context, packages)
        self.stop_db(context)
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.reset_configuration(context, config_contents)
        self.set_db_to_listen(context)
        self.start_db(context)

        if backup_info:
            backup.restore(context, backup_info, '/tmp')

        if root_password and not backup_info:
            self.enable_root(context, root_password)
Esempio n. 19
0
    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,
    ):
        self.install(context, packages)
        PgSqlAppStatus.get().begin_restart()
        self.stop_db(context)
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                if not backup_info:
                    device.migrate_data(mount_point)
            device.mount(mount_point)
        self.reset_configuration(context, config_contents)
        self.set_db_to_listen(context)
        self.start_db(context)

        if backup_info:
            backup.restore(context, backup_info, '/tmp')

        if root_password and not backup_info:
            self.enable_root(context, root_password)

        PgSqlAppStatus.get().end_install_or_restart()

        if databases:
            self.create_database(context, databases)

        if users:
            self.create_user(context, users)
Esempio n. 20
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info, config_contents,
                   root_password, overrides, cluster_config, snapshot):
        pgutil.PG_ADMIN = self.PG_BUILTIN_ADMIN
        self.install(context, packages)
        self.stop_db(context)
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.configuration_manager.save_configuration(config_contents)
        self.apply_initial_guestagent_configuration()
        self.start_db(context)

        if backup_info:
            backup.restore(context, backup_info, '/tmp')
            pgutil.PG_ADMIN = self.ADMIN_USER
        else:
            self._secure(context)
Esempio n. 21
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info, config_contents,
                   root_password, overrides, cluster_config, snapshot):
        self.app.install(context, packages)
        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()

        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.configuration_manager.save_configuration(config_contents)
        self.app.apply_initial_guestagent_configuration()

        os_admin = models.PostgreSQLUser(self.app.ADMIN_USER)

        if backup_info:
            backup.restore(context, backup_info, '/tmp')
            self.app.set_current_admin_user(os_admin)

        if snapshot:
            LOG.info("Found snapshot info: " + str(snapshot))
            self.attach_replica(context, snapshot, snapshot['config'])

        self.app.start_db()

        if not backup_info:
            self.app.secure(context)

        self._admin = PgSqlAdmin(os_admin)

        if not cluster_config and self.is_root_enabled(context):
            self.status.report_root(context, self.app.default_superuser_name)
Esempio n. 22
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info, config_contents,
                   root_password, overrides, cluster_config, snapshot):
        self.app.install(context, packages)
        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()

        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            if os.path.exists(mount_point):
                device.migrate_data(mount_point)
            device.mount(mount_point)
        self.configuration_manager.save_configuration(config_contents)
        self.app.apply_initial_guestagent_configuration()

        os_admin = models.PostgreSQLUser(self.app.ADMIN_USER)

        if backup_info:
            backup.restore(context, backup_info, '/tmp')
            self.app.set_current_admin_user(os_admin)

        if snapshot:
            LOG.info("Found snapshot info: " + str(snapshot))
            self.attach_replica(context, snapshot, snapshot['config'])

        self.app.start_db()

        if not backup_info:
            self.app.secure(context)

        self._admin = PgSqlAdmin(os_admin)

        if not cluster_config and self.is_root_enabled(context):
            self.status.report_root(context, self.app.default_superuser_name)