当前位置: 首页>>代码示例>>Python>>正文


Python MySqlApp.secure方法代码示例

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


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

示例1: prepare

# 需要导入模块: from trove.guestagent.datastore.mysql.service import MySqlApp [as 别名]
# 或者: from trove.guestagent.datastore.mysql.service.MySqlApp import secure [as 别名]
    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,代码行数:62,代码来源:manager.py

示例2: prepare

# 需要导入模块: from trove.guestagent.datastore.mysql.service import MySqlApp [as 别名]
# 或者: from trove.guestagent.datastore.mysql.service.MySqlApp import secure [as 别名]
    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,代码行数:53,代码来源:manager.py

示例3: prepare

# 需要导入模块: from trove.guestagent.datastore.mysql.service import MySqlApp [as 别名]
# 或者: from trove.guestagent.datastore.mysql.service.MySqlApp import secure [as 别名]
    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,代码行数:52,代码来源:manager.py

示例4: test_secure_keep_root

# 需要导入模块: from trove.guestagent.datastore.mysql.service import MySqlApp [as 别名]
# 或者: from trove.guestagent.datastore.mysql.service.MySqlApp import secure [as 别名]
    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:VinodKrGupta,项目名称:trove,代码行数:19,代码来源:test_dbaas.py


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