• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python service.MySqlAppStatus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trove.guestagent.datastore.mysql.service.MySqlAppStatus的典型用法代码示例。如果您正苦于以下问题:Python MySqlAppStatus类的具体用法?Python MySqlAppStatus怎么用?Python MySqlAppStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MySqlAppStatus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: prepare

    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, 'mysql', 'mysql',
                                   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 and restart.
            app.update_overrides("[mysqld]\ndatadir=%s/data\n"
                                 % mount_point)
            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.'))
开发者ID:cp16net,项目名称:trove,代码行数:60,代码来源:manager.py


示例2: MySqlAppStatusTest

class MySqlAppStatusTest(testtools.TestCase):

    def setUp(self):
        super(MySqlAppStatusTest, self).setUp()
        util.init_db()
        self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
        self.orig_load_mysqld_options = dbaas.load_mysqld_options
        self.orig_dbaas_os_path_exists = dbaas.os.path.exists
        self.orig_dbaas_time_sleep = dbaas.time.sleep
        self.FAKE_ID = randint(1, 10000)
        InstanceServiceStatus.create(instance_id=self.FAKE_ID,
                                     status=rd_instance.ServiceStatuses.NEW)
        dbaas.CONF.guest_id = self.FAKE_ID

    def tearDown(self):
        super(MySqlAppStatusTest, self).tearDown()
        dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
        dbaas.load_mysqld_options = self.orig_load_mysqld_options
        dbaas.os.path.exists = self.orig_dbaas_os_path_exists
        dbaas.time.sleep = self.orig_dbaas_time_sleep
        InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
        dbaas.CONF.guest_id = None

    def test_get_actual_db_status(self):

        dbaas.utils.execute_with_timeout = Mock(return_value=(None, None))

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(rd_instance.ServiceStatuses.RUNNING, status)

    def test_get_actual_db_status_error_shutdown(self):

        from trove.common.exception import ProcessExecutionError
        mocked = Mock(side_effect=ProcessExecutionError())
        dbaas.utils.execute_with_timeout = mocked
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=False)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(rd_instance.ServiceStatuses.SHUTDOWN, status)

    def test_get_actual_db_status_error_crashed(self):

        from trove.common.exception import ProcessExecutionError
        dbaas.utils.execute_with_timeout = MagicMock(
            side_effect=[ProcessExecutionError(), ("some output", None)])
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=True)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(rd_instance.ServiceStatuses.BLOCKED, status)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:57,代码来源:test_dbaas.py


示例3: prepare

    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 exiting data
                device.migrate_data(mount_point)
            #mount the volume
            device.mount(mount_point)
            LOG.debug("Mounted the volume.")
            app.start_mysql()
        if backup_info:
            self._perform_restore(backup_info, context,
                                  mount_point, 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('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.'))
开发者ID:promisejohn,项目名称:trove,代码行数:51,代码来源:manager.py


示例4: prepare

    def prepare(self, context, databases, memory_mb, users, device_path=None,
                mount_point=None, backup_id=None, config_contents=None,
                root_password=None):
        """Makes ready DBAAS on a Guest container."""
        MySqlAppStatus.get().begin_install()
        # status end_mysql_install set with secure()
        app = MySqlApp(MySqlAppStatus.get())
        restart_mysql = False
        if device_path:
            device = volume.VolumeDevice(device_path)
            device.format()
            #if a /var/lib/mysql folder exists, back it up.
            if os.path.exists(CONF.mount_point):
                #stop and do not update database
                app.stop_db()
                #rsync exiting data
                if not backup_id:
                    restart_mysql = True
                    device.migrate_data(CONF.mount_point)
            #mount the volume
            device.mount(mount_point)
            LOG.debug(_("Mounted the volume."))
            #check mysql was installed and stopped
            if restart_mysql:
                app.start_mysql()
        app.install_if_needed()
        if backup_id:
            self._perform_restore(backup_id, context, CONF.mount_point, app)
        LOG.info(_("Securing mysql now."))
        app.secure(config_contents)
        enable_root_on_restore = (backup_id and MySqlAdmin().is_root_enabled())
        if root_password and not backup_id:
            app.secure_root(secure_remote_root=True)
            MySqlAdmin().enable_root(root_password)
            MySqlAdmin().report_root_enabled(context)
        elif enable_root_on_restore:
            app.secure_root(secure_remote_root=False)
            MySqlAdmin().report_root_enabled(context)
        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)

        LOG.info('"prepare" call has finished.')
开发者ID:VinodKrGupta,项目名称:trove,代码行数:50,代码来源:manager.py


示例5: get_replication_snapshot

    def get_replication_snapshot(self, context, snapshot_info,
                                 replica_source_config=None):
        LOG.debug("Getting replication snapshot.")
        app = MySqlApp(MySqlAppStatus.get())

        replication = REPLICATION_STRATEGY_CLASS(context)
        replication.enable_as_master(app, replica_source_config)

        snapshot_id, log_position = (
            replication.snapshot_for_replication(context, app, None,
                                                 snapshot_info))

        mount_point = CONF.get(MANAGER).mount_point
        volume_stats = dbaas.get_filesystem_volume_stats(mount_point)

        replication_snapshot = {
            'dataset': {
                'datastore_manager': MANAGER,
                'dataset_size': volume_stats.get('used', 0.0),
                'volume_size': volume_stats.get('total', 0.0),
                'snapshot_id': snapshot_id
            },
            'replication_strategy': REPLICATION_STRATEGY,
            'master': replication.get_master_ref(app, snapshot_info),
            'log_position': log_position
        }

        return replication_snapshot
开发者ID:cp16net,项目名称:trove,代码行数:28,代码来源:manager.py


示例6: test_get_actual_db_status

    def test_get_actual_db_status(self):

        dbaas.utils.execute_with_timeout = Mock(return_value=(None, None))

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(rd_instance.ServiceStatuses.RUNNING, status)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:8,代码来源:test_dbaas.py


示例7: attach_replication_slave

 def attach_replication_slave(self, context, snapshot, slave_config):
     LOG.debug("Attaching replication snapshot.")
     app = MySqlApp(MySqlAppStatus.get())
     try:
         self._validate_slave_for_replication(context, snapshot)
         replication = REPLICATION_STRATEGY_CLASS(context)
         replication.enable_as_slave(app, snapshot, slave_config)
     except Exception:
         LOG.exception("Error enabling replication.")
         app.status.set_status(rd_instance.ServiceStatuses.FAILED)
         raise
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:11,代码来源:manager.py


示例8: test_get_actual_db_status_error_crashed

    def test_get_actual_db_status_error_crashed(self):

        from trove.common.exception import ProcessExecutionError
        dbaas.utils.execute_with_timeout = MagicMock(
            side_effect=[ProcessExecutionError(), ("some output", None)])
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=True)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(rd_instance.ServiceStatuses.BLOCKED, status)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:12,代码来源:test_dbaas.py


示例9: test_get_actual_db_status_error_shutdown

    def test_get_actual_db_status_error_shutdown(self):

        from trove.common.exception import ProcessExecutionError
        mocked = Mock(side_effect=ProcessExecutionError())
        dbaas.utils.execute_with_timeout = mocked
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=False)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(rd_instance.ServiceStatuses.SHUTDOWN, status)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:12,代码来源:test_dbaas.py


示例10: enable_as_master

 def enable_as_master(self, context, replica_source_config):
     LOG.debug("Calling enable_as_master.")
     app = MySqlApp(MySqlAppStatus.get())
     replication = REPLICATION_STRATEGY_CLASS(context)
     replication.enable_as_master(app, replica_source_config)
开发者ID:cp16net,项目名称:trove,代码行数:5,代码来源:manager.py


示例11: apply_overrides

 def apply_overrides(self, context, overrides):
     LOG.debug("Applying overrides (%s)." % overrides)
     app = MySqlApp(MySqlAppStatus.get())
     app.apply_overrides(overrides)
开发者ID:cp16net,项目名称:trove,代码行数:4,代码来源:manager.py


示例12: update_overrides

 def update_overrides(self, context, overrides, remove=False):
     app = MySqlApp(MySqlAppStatus.get())
     if remove:
         app.remove_overrides()
     app.update_overrides(overrides)
开发者ID:cp16net,项目名称:trove,代码行数:5,代码来源:manager.py


示例13: detach_replica

 def detach_replica(self, context):
     LOG.debug("Detaching replica.")
     app = MySqlApp(MySqlAppStatus.get())
     replication = REPLICATION_STRATEGY_CLASS(context)
     replication.detach_slave(app)
开发者ID:rumale,项目名称:trove,代码行数:5,代码来源:manager.py


示例14: get_latest_txn_id

 def get_latest_txn_id(self, context):
     LOG.debug("Calling get_latest_txn_id.")
     return MySqlApp(MySqlAppStatus.get()).get_latest_txn_id()
开发者ID:cp16net,项目名称:trove,代码行数:3,代码来源:manager.py


示例15: detach_replica

 def detach_replica(self, context, for_failover=False):
     LOG.debug("Detaching replica.")
     app = MySqlApp(MySqlAppStatus.get())
     replication = REPLICATION_STRATEGY_CLASS(context)
     replica_info = replication.detach_slave(app, for_failover)
     return replica_info
开发者ID:cp16net,项目名称:trove,代码行数:6,代码来源:manager.py


示例16: apply_overrides

 def apply_overrides(self, context, overrides):
     app = MySqlApp(MySqlAppStatus.get())
     app.apply_overrides(overrides)
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:3,代码来源:manager.py


示例17: update_overrides

 def update_overrides(self, context, overrides, remove=False):
     LOG.debug("Updating overrides (%s)." % overrides)
     app = MySqlApp(MySqlAppStatus.get())
     app.update_overrides(overrides, remove=remove)
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:4,代码来源:manager.py


示例18: _build_app

 def _build_app(self):
     return MariaDBApp(MySqlAppStatus.get())
开发者ID:Hopebaytech,项目名称:trove,代码行数:2,代码来源:mariadb_impl.py


示例19: get_txn_count

 def get_txn_count(self, context):
     LOG.debug("Calling get_txn_count")
     return MySqlApp(MySqlAppStatus.get()).get_txn_count()
开发者ID:cp16net,项目名称:trove,代码行数:3,代码来源:manager.py


示例20: get_last_txn

 def get_last_txn(self, context):
     LOG.debug("Calling get_last_txn")
     return MySqlApp(MySqlAppStatus.get()).get_last_txn()
开发者ID:cp16net,项目名称:trove,代码行数:3,代码来源:manager.py



注:本文中的trove.guestagent.datastore.mysql.service.MySqlAppStatus类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python service.RedisAppStatus类代码示例发布时间:2022-05-27
下一篇:
Python service.MySqlApp类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap