Esempio n. 1
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):
        """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})

        if mount_point:
            config_contents = self.app.update_config_contents(
                config_contents, {
                    'dbpath': mount_point,
                })

        self.app.start_db_with_conf_changes(config_contents)
        LOG.info(_('"prepare" call has finished.'))
Esempio n. 2
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):
     """
     This is called when the trove instance first comes online.
     It is the first rpc message passed from the task manager.
     prepare handles all the base configuration of the redis instance.
     """
     try:
         app = RedisApp(RedisAppStatus.get())
         RedisAppStatus.get().begin_install()
         if device_path:
             device = volume.VolumeDevice(device_path)
             # unmount if device is already mounted
             device.unmount_device(device_path)
             device.format()
             device.mount(mount_point)
             operating_system.update_owner('redis', 'redis', mount_point)
             LOG.debug('Mounted the volume.')
         app.install_if_needed(packages)
         LOG.info(_('Writing redis configuration.'))
         app.write_config(config_contents)
         app.restart()
         LOG.info(_('Redis instance has been setup and configured.'))
     except Exception:
         LOG.exception(_("Error setting up Redis instance."))
         app.status.set_status(rd_instance.ServiceStatuses.FAILED)
         raise RuntimeError("prepare call has failed.")
Esempio n. 3
0
 def initial_setup(self):
     self.ip_address = operating_system.get_ip_address()
     mount_point = CONF.couchbase.mount_point
     try:
         LOG.info(_('Couchbase Server change data dir path.'))
         operating_system.update_owner('couchbase', 'couchbase',
                                       mount_point)
         pwd = CouchbaseRootAccess.get_password()
         utils.execute_with_timeout((system.cmd_node_init % {
             'data_path': mount_point,
             'IP': self.ip_address,
             'PWD': pwd
         }),
                                    shell=True)
         utils.execute_with_timeout(system.cmd_rm_old_data_dir, shell=True)
         LOG.debug('Couchbase Server initialize cluster.')
         utils.execute_with_timeout((system.cmd_cluster_init % {
             'IP': self.ip_address,
             'PWD': pwd
         }),
                                    shell=True)
         utils.execute_with_timeout(system.cmd_set_swappiness, shell=True)
         utils.execute_with_timeout(system.cmd_update_sysctl_conf,
                                    shell=True)
         LOG.info(_('Couchbase Server initial setup finished.'))
     except exception.ProcessExecutionError:
         LOG.exception(_('Error performing initial Couchbase setup.'))
         raise RuntimeError("Couchbase Server initial setup failed")
Esempio n. 4
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):
     """
     This is called when the trove instance first comes online.
     It is the first rpc message passed from the task manager.
     prepare handles all the base configuration of the redis instance.
     """
     try:
         app = RedisApp(RedisAppStatus.get())
         RedisAppStatus.get().begin_install()
         if device_path:
             device = volume.VolumeDevice(device_path)
             # unmount if device is already mounted
             device.unmount_device(device_path)
             device.format()
             device.mount(mount_point)
             operating_system.update_owner('redis', 'redis', mount_point)
             LOG.debug('Mounted the volume.')
         app.install_if_needed(packages)
         LOG.info(_('Securing redis now.'))
         app.write_config(config_contents)
         app.restart()
         LOG.info(_('"prepare" redis call has finished.'))
     except Exception as e:
         LOG.error(e)
         app.status.set_status(rd_instance.ServiceStatuses.FAILED)
         raise RuntimeError("prepare call has failed.")
Esempio n. 5
0
 def initial_setup(self):
     self.ip_address = netutils.get_my_ipv4()
     mount_point = CONF.couchbase.mount_point
     try:
         LOG.info(_('Couchbase Server change data dir path.'))
         operating_system.update_owner('couchbase',
                                       'couchbase',
                                       mount_point)
         pwd = CouchbaseRootAccess.get_password()
         utils.execute_with_timeout(
             (system.cmd_node_init
              % {'data_path': mount_point,
                 'IP': self.ip_address,
                 'PWD': pwd}), shell=True)
         operating_system.remove(system.INSTANCE_DATA_DIR, force=True,
                                 as_root=True)
         LOG.debug('Couchbase Server initialize cluster.')
         utils.execute_with_timeout(
             (system.cmd_cluster_init
              % {'IP': self.ip_address, 'PWD': pwd}),
             shell=True)
         utils.execute_with_timeout(system.cmd_set_swappiness, shell=True)
         utils.execute_with_timeout(system.cmd_update_sysctl_conf,
                                    shell=True)
         LOG.info(_('Couchbase Server initial setup finished.'))
     except exception.ProcessExecutionError:
         LOG.exception(_('Error performing initial Couchbase setup.'))
         raise RuntimeError("Couchbase Server initial setup failed")
Esempio n. 6
0
 def initial_setup(self):
     self.ip_address = operating_system.get_ip_address()
     mount_point = CONF.couchbase.mount_point
     try:
         LOG.info(_('Couchbase Server change data dir path'))
         operating_system.update_owner('couchbase',
                                       'couchbase',
                                       mount_point)
         pwd = CouchbaseRootAccess.get_password()
         utils.execute_with_timeout(
             (system.cmd_node_init
              % {'data_path': mount_point,
                 'IP': self.ip_address,
                 'PWD': pwd}), shell=True)
         utils.execute_with_timeout(
             system.cmd_rm_old_data_dir, shell=True)
         LOG.info(_('Couchbase Server initialize cluster'))
         utils.execute_with_timeout(
             (system.cmd_cluster_init
              % {'IP': self.ip_address, 'PWD': pwd}),
             shell=True)
         utils.execute_with_timeout(system.cmd_set_swappiness, shell=True)
         utils.execute_with_timeout(system.cmd_update_sysctl_conf,
                                    shell=True)
         LOG.info(_('Couchbase Server initial setup finished'))
     except exception.ProcessExecutionError as e:
         LOG.error(_('Process execution error %s') % e)
         raise RuntimeError("Couchbase Server initial setup failed")
Esempio n. 7
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):
        """Makes ready DBAAS on a Guest container."""

        LOG.debug("Preparing 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(system.MONGO_USER,
                                          system.MONGO_USER, 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(_('Completed setup of MongoDB database instance.'))
Esempio n. 8
0
 def change_permissions(self):
     """
     When CouchDB is installed, a default user 'couchdb' is created.
     Inorder to start/stop/restart CouchDB service as the current
     OS user, add this user to the 'couchdb' group and provide read/
     write access to the 'couchdb' group.
     """
     try:
         LOG.debug("Changing permissions.")
         operating_system.update_owner('couchdb', 'couchdb',
                                       COUCHDB_LIB_DIR)
         operating_system.update_owner('couchdb', 'couchdb',
                                       COUCHDB_LOG_DIR)
         operating_system.update_owner('couchdb', 'couchdb',
                                       COUCHDB_BIN_DIR)
         operating_system.update_owner('couchdb', 'couchdb',
                                       COUCHDB_CONFIG_DIR)
         operating_system.chmod(COUCHDB_LIB_DIR,
                                FileMode.ADD_GRP_RW,
                                as_root=True)
         operating_system.chmod(COUCHDB_LOG_DIR,
                                FileMode.ADD_GRP_RW,
                                as_root=True)
         operating_system.chmod(COUCHDB_BIN_DIR,
                                FileMode.ADD_GRP_RW,
                                as_root=True)
         operating_system.chmod(COUCHDB_CONFIG_DIR,
                                FileMode.ADD_GRP_RW,
                                as_root=True)
         self.execute_change_permission_commands(
             system.UPDATE_GROUP_MEMBERSHIP)
         LOG.debug("Successfully changed permissions.")
     except exception.ProcessExecutionError:
         LOG.exception(_("Error changing permissions."))
Esempio n. 9
0
 def change_permissions(self):
     """
     When CouchDB is installed, a default user 'couchdb' is created.
     Inorder to start/stop/restart CouchDB service as the current
     OS user, add this user to the 'couchdb' group and provide read/
     write access to the 'couchdb' group.
     """
     try:
         LOG.debug("Changing permissions.")
         operating_system.update_owner(
             'couchdb', 'couchdb', COUCHDB_LIB_DIR
         )
         operating_system.update_owner(
             'couchdb', 'couchdb', COUCHDB_LOG_DIR
         )
         operating_system.update_owner(
             'couchdb', 'couchdb', COUCHDB_BIN_DIR
         )
         operating_system.update_owner(
             'couchdb', 'couchdb', COUCHDB_CONFIG_DIR
         )
         operating_system.chmod(COUCHDB_LIB_DIR, FileMode.ADD_GRP_RW,
                                as_root=True)
         operating_system.chmod(COUCHDB_LOG_DIR, FileMode.ADD_GRP_RW,
                                as_root=True)
         operating_system.chmod(COUCHDB_BIN_DIR, FileMode.ADD_GRP_RW,
                                as_root=True)
         operating_system.chmod(COUCHDB_CONFIG_DIR, FileMode.ADD_GRP_RW,
                                as_root=True)
         self.execute_change_permission_commands(
             system.UPDATE_GROUP_MEMBERSHIP
         )
         LOG.debug("Successfully changed permissions.")
     except exception.ProcessExecutionError:
         LOG.exception(_("Error changing permissions."))
Esempio n. 10
0
 def change_permissions(self):
     """
     When CouchDB is installed, a default user 'couchdb' is created.
     Inorder to start/stop/restart CouchDB service as the current
     OS user, add this user to the 'couchdb' group and provide read/
     write access to the 'couchdb' group.
     """
     try:
         LOG.debug("Changing permissions.")
         operating_system.update_owner(
             'couchdb', 'couchdb', COUCHDB_LIB_DIR
         )
         operating_system.update_owner(
             'couchdb', 'couchdb', COUCHDB_LOG_DIR
         )
         operating_system.update_owner(
             'couchdb', 'couchdb', COUCHDB_BIN_DIR
         )
         operating_system.update_owner(
             'couchdb', 'couchdb', COUCHDB_CONFIG_DIR
         )
         self.execute_change_permission_commands(
             system.UPDATE_LIB_DIR_PERMISSIONS %
             {'libdir': COUCHDB_LIB_DIR}
         )
         self.execute_change_permission_commands(
             system.UPDATE_LOG_DIR_PERMISSIONS %
             {'logdir': COUCHDB_LOG_DIR}
         )
         self.execute_change_permission_commands(
             system.UPDATE_BIN_DIR_PERMISSIONS %
             {'bindir': COUCHDB_BIN_DIR}
         )
         self.execute_change_permission_commands(
             system.UPDATE_CONF_DIR_PERMISSIONS %
             {'confdir': COUCHDB_CONFIG_DIR}
         )
         self.execute_change_permission_commands(
             system.UPDATE_GROUP_MEMBERSHIP
         )
         LOG.debug("Successfully changed permissions.")
     except exception.ProcessExecutionError:
         LOG.exception(_("Error changing permissions."))