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

Python mysql_service.MySqlApp类代码示例

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

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



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

示例1: test_secure_keep_root

    def test_secure_keep_root(self):
        mock_conn = mock_sql_connection()

        when(mock_conn).execute(any()).thenReturn(None)
        when(utils).execute_with_timeout("sudo", any(str), "stop").thenReturn(None)
        # skip writing the file for now
        when(os.path).isfile(any()).thenReturn(False)
        when(utils).execute_with_timeout("sudo", "chmod", any(), any()).thenReturn(None)
        mock_status = mock()
        when(mock_status).wait_for_real_status_to_change_to(any(), any(), any()).thenReturn(True)
        app = MySqlApp(mock_status)
        when(app)._write_mycnf(any(), any()).thenReturn(True)
        app.secure("foo")
        verify(mock_conn, never).execute(TextClauseMatcher("root"))
开发者ID:ReVolly,项目名称:trove,代码行数:14,代码来源:test_dbaas.py


示例2: setUp

 def setUp(self):
     super(MySqlAppTest, self).setUp()
     self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
     self.orig_time_sleep = time.sleep
     util.init_db()
     self.FAKE_ID = randint(1, 10000)
     InstanceServiceStatus.create(instance_id=self.FAKE_ID, status=rd_instance.ServiceStatuses.NEW)
     self.appStatus = FakeAppStatus(self.FAKE_ID, rd_instance.ServiceStatuses.NEW)
     self.mySqlApp = MySqlApp(self.appStatus)
     time.sleep = Mock()
开发者ID:ReVolly,项目名称:trove,代码行数:10,代码来源:test_dbaas.py


示例3: test_secure_keep_root

    def test_secure_keep_root(self):
        mock_conn = mock_sql_connection()

        when(mock_conn).execute(any()).thenReturn(None)
        when(utils).execute_with_timeout("sudo", any(str), "stop").thenReturn(
            None)
        when(pkg).pkg_install("dbaas-mycnf", any()).thenReturn(None)
        # skip writing the file for now
        when(os.path).isfile(any()).thenReturn(False)
        when(utils).execute_with_timeout(
            "sudo", "chmod", any(), any()).thenReturn(None)
        MySqlAppMockTest.stub_file("/etc/mysql/my.cnf")
        MySqlAppMockTest.stub_file("/etc/dbaas/my.cnf/my.cnf.2048M")
        MySqlAppMockTest.stub_file("/tmp/my.cnf.tmp")
        mock_status = mock(MySqlAppStatus)
        when(mock_status).wait_for_real_status_to_change_to(
            any(), any(), any()).thenReturn(True)
        app = MySqlApp(mock_status)

        app.secure(2048)
        verify(mock_conn, never).execute(TextClauseMatcher('root'))
开发者ID:dfecker,项目名称:trove,代码行数:21,代码来源:test_dbaas.py


示例4: MySqlAppTest

class MySqlAppTest(testtools.TestCase):

    def setUp(self):
        super(MySqlAppTest, self).setUp()
        self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
        self.orig_time_sleep = time.sleep
        util.init_db()
        self.FAKE_ID = randint(1, 10000)
        InstanceServiceStatus.create(instance_id=self.FAKE_ID,
                                     status=rd_instance.ServiceStatuses.NEW)
        self.appStatus = FakeAppStatus(self.FAKE_ID,
                                       rd_instance.ServiceStatuses.NEW)
        self.mySqlApp = MySqlApp(self.appStatus)
        time.sleep = Mock()

    def tearDown(self):
        super(MySqlAppTest, self).tearDown()
        dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
        time.sleep = self.orig_time_sleep
        InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()

    def assert_reported_status(self, expected_status):
        service_status = InstanceServiceStatus.find_by(
            instance_id=self.FAKE_ID)
        self.assertEqual(expected_status, service_status.status)

    def mysql_starts_successfully(self):
        def start(update_db=False):
            self.appStatus.set_next_status(
                rd_instance.ServiceStatuses.RUNNING)

        self.mySqlApp.start_mysql.side_effect = start

    def mysql_starts_unsuccessfully(self):
        def start():
            raise RuntimeError("MySQL failed to start!")

        self.mySqlApp.start_mysql.side_effect = start

    def mysql_stops_successfully(self):
        def stop():
            self.appStatus.set_next_status(
                rd_instance.ServiceStatuses.SHUTDOWN)

        self.mySqlApp.stop_db.side_effect = stop

    def mysql_stops_unsuccessfully(self):
        def stop():
            raise RuntimeError("MySQL failed to stop!")

        self.mySqlApp.stop_db.side_effect = stop

    def test_stop_mysql(self):

        dbaas.utils.execute_with_timeout = Mock()
        self.appStatus.set_next_status(
            rd_instance.ServiceStatuses.SHUTDOWN)

        self.mySqlApp.stop_db()
        self.assert_reported_status(rd_instance.ServiceStatuses.NEW)

    def test_stop_mysql_with_db_update(self):

        dbaas.utils.execute_with_timeout = Mock()
        self.appStatus.set_next_status(
            rd_instance.ServiceStatuses.SHUTDOWN)

        self.mySqlApp.stop_db(True)
        self.assert_reported_status(rd_instance.ServiceStatuses.SHUTDOWN)

    def test_stop_mysql_error(self):

        dbaas.utils.execute_with_timeout = Mock()
        self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
        self.mySqlApp.state_change_wait_time = 1
        self.assertRaises(RuntimeError, self.mySqlApp.stop_db)

    def test_restart_is_successful(self):

        self.mySqlApp.start_mysql = Mock()
        self.mySqlApp.stop_db = Mock()
        self.mysql_stops_successfully()
        self.mysql_starts_successfully()

        self.mySqlApp.restart()

        self.assertTrue(self.mySqlApp.stop_db.called)
        self.assertTrue(self.mySqlApp.start_mysql.called)
        self.assert_reported_status(rd_instance.ServiceStatuses.RUNNING)

    def test_restart_mysql_wont_start_up(self):

        self.mySqlApp.start_mysql = Mock()
        self.mySqlApp.stop_db = Mock()
        self.mysql_stops_unsuccessfully()
        self.mysql_starts_unsuccessfully()

        self.assertRaises(RuntimeError, self.mySqlApp.restart)

        self.assertTrue(self.mySqlApp.stop_db.called)
#.........这里部分代码省略.........
开发者ID:dadu1688,项目名称:trove,代码行数:101,代码来源:test_dbaas.py


示例5: 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:ReVolly,项目名称:trove,代码行数:50,代码来源:mysql.py


示例6: reset_configuration

 def reset_configuration(self, context, configuration):
     app = MySqlApp(MySqlAppStatus.get())
     app.reset_configuration(configuration)
开发者ID:ReVolly,项目名称:trove,代码行数:3,代码来源:mysql.py


示例7: stop_db

 def stop_db(self, context, do_not_start_on_reboot=False):
     app = MySqlApp(MySqlAppStatus.get())
     app.stop_db(do_not_start_on_reboot=do_not_start_on_reboot)
开发者ID:ReVolly,项目名称:trove,代码行数:3,代码来源:mysql.py


示例8: start_db_with_conf_changes

 def start_db_with_conf_changes(self, context, config_contents):
     app = MySqlApp(MySqlAppStatus.get())
     app.start_db_with_conf_changes(config_contents)
开发者ID:ReVolly,项目名称:trove,代码行数:3,代码来源:mysql.py


示例9: restart

 def restart(self, context):
     app = MySqlApp(MySqlAppStatus.get())
     app.restart()
开发者ID:ReVolly,项目名称:trove,代码行数:3,代码来源:mysql.py


示例10: apply_overrides

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


示例11: update_overrides

 def update_overrides(self, context, overrides, remove=False):
     app = MySqlApp(MySqlAppStatus.get())
     app.update_overrides(overrides, remove=remove)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:3,代码来源:mysql.py


示例12: start_db_with_conf_changes

 def start_db_with_conf_changes(self, context, updated_memory_size):
     app = MySqlApp(MySqlAppStatus.get())
     app.start_db_with_conf_changes(updated_memory_size)
开发者ID:dfecker,项目名称:trove,代码行数:3,代码来源:mysql.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python mysql_service.MySqlAppStatus类代码示例发布时间:2022-05-27
下一篇:
Python dbaas.get_filesystem_volume_stats函数代码示例发布时间: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