本文整理汇总了Python中trove.guestagent.datastore.mysql.service.MySqlApp类的典型用法代码示例。如果您正苦于以下问题:Python MySqlApp类的具体用法?Python MySqlApp怎么用?Python MySqlApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MySqlApp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _read_log_position
def _read_log_position(self):
backup_var_file = ('%s/backup_variables.txt' %
MySqlApp.get_data_dir())
if operating_system.exists(backup_var_file):
try:
LOG.info(_("Reading log position from %s") % backup_var_file)
backup_vars = operating_system.read_file(
backup_var_file,
stream_codecs.PropertiesCodec(delimiter='='),
as_root=True)
binlog_position = backup_vars['binlog_position']
binlog_file, binlog_pos = binlog_position.split(':')
return {
'log_file': binlog_file,
'log_position': int(binlog_pos)
}
except Exception as ex:
LOG.exception(ex)
raise self.UnableToDetermineBinlogPosition(
{'binlog_file': backup_var_file})
else:
LOG.info(_("Log position detail not available. "
"Using default values."))
return {'log_file': '',
'log_position': 4}
开发者ID:Tesora,项目名称:tesora-trove,代码行数:25,代码来源:mysql_ee_binlog.py
示例2: cmd
def cmd(self):
cmd = ('sudo innobackupex'
' --stream=xbstream'
' %(extra_opts)s ' +
MySqlApp.get_data_dir() +
' 2>/tmp/innobackupex.log'
)
return cmd + self.zip_cmd + self.encrypt_cmd
开发者ID:bbgw,项目名称:trove,代码行数:8,代码来源:mysql_impl.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)
# 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,代码行数:17,代码来源:test_dbaas.py
示例4: cmd
def cmd(self):
cmd = ("sudo innobackupex"
" --stream=xbstream"
" %(extra_opts)s " +
self.user_and_pass +
MySqlApp.get_data_dir() +
" 2>/tmp/innobackupex.log"
)
return cmd + self.zip_cmd + self.encrypt_cmd
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:9,代码来源:mysql_impl.py
示例5: cmd
def cmd(self):
cmd = ('sudo innobackupex'
' --stream=xbstream'
' --incremental'
' --incremental-lsn=%(lsn)s'
' %(extra_opts)s ' +
self.user_and_pass +
MySqlApp.get_data_dir() +
' 2>/tmp/innobackupex.log')
return cmd + self.zip_cmd + self.encrypt_cmd
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:10,代码来源:mysql_impl.py
示例6: cmd
def cmd(self):
cmd = ("sudo innobackupex"
" --stream=xbstream"
" --incremental"
" --incremental-lsn=%(lsn)s"
" %(extra_opts)s " +
self.user_and_pass +
MySqlApp.get_data_dir() +
" 2>" + self.log_file_path)
return cmd + self.zip_cmd + self.encrypt_cmd
开发者ID:Tesora,项目名称:tesora-trove,代码行数:10,代码来源:mysql_impl.py
示例7: setUp
def setUp(self):
super(MySqlAppTest, self).setUp()
self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
self.orig_time_sleep = dbaas.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)
dbaas.time.sleep = Mock()
开发者ID:VinodKrGupta,项目名称:trove,代码行数:12,代码来源:test_dbaas.py
示例8: _read_last_master_gtid
def _read_last_master_gtid(self):
INFO_FILE = ('%s/xtrabackup_binlog_info' % MySqlApp.get_data_dir())
LOG.info(_("Setting read permissions on %s") % INFO_FILE)
operating_system.chmod(INFO_FILE, FileMode.ADD_READ_ALL, as_root=True)
LOG.info(_("Reading last master GTID from %s") % INFO_FILE)
try:
with open(INFO_FILE, 'rb') as f:
row = f.read().split('\t')
return row[2]
except (IOError, IndexError) as ex:
LOG.exception(ex)
raise self.UnableToDetermineLastMasterGTID(
{'binlog_file': INFO_FILE})
开发者ID:Hopebaytech,项目名称:trove,代码行数:13,代码来源:mysql_gtid.py
示例9: _read_log_position
def _read_log_position(self):
INFO_FILE = ('%s/xtrabackup_binlog_info' % MySqlApp.get_data_dir())
LOG.info(_("Setting read permissions on %s") % INFO_FILE)
operating_system.chmod(INFO_FILE, FileMode.ADD_READ_ALL, as_root=True)
LOG.info(_("Reading log position from %s") % INFO_FILE)
try:
with open(INFO_FILE, 'rb') as f:
row = csv.reader(f, delimiter='\t',
skipinitialspace=True).next()
return {
'log_file': row[0],
'log_position': int(row[1])
}
except (IOError, IndexError) as ex:
LOG.exception(ex)
raise self.UnableToDetermineBinlogPosition(
{'info_file': INFO_FILE})
开发者ID:magictour,项目名称:trove,代码行数:17,代码来源:mysql_binlog.py
示例10: setUp
def setUp(self):
super(MySqlAppTest, self).setUp()
self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
self.orig_time_sleep = dbaas.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)
mysql_service = {'cmd_start': Mock(),
'cmd_stop': Mock(),
'cmd_enable': Mock(),
'cmd_disable': Mock(),
'bin': Mock()}
dbaas.operating_system.service_discovery = Mock(return_value=
mysql_service)
dbaas.time.sleep = Mock()
开发者ID:adamfokken,项目名称:trove,代码行数:19,代码来源:test_dbaas.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: 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:cp16net,项目名称:trove,代码行数:3,代码来源:manager.py
示例14: 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:cp16net,项目名称:trove,代码行数:3,代码来源:manager.py
示例15: restart
def restart(self, context):
app = MySqlApp(MySqlAppStatus.get())
app.restart()
开发者ID:cp16net,项目名称:trove,代码行数:3,代码来源:manager.py
示例16: 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
示例17: user_and_pass
def user_and_pass(self):
return (" --user=%(user)s --password='%(password)s' " %
{'user': ADMIN_USER_NAME,
'password': MySqlApp.get_auth_password()})
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:4,代码来源:mysql_impl.py
示例18: 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
示例19: apply_overrides
def apply_overrides(self, context, overrides):
app = MySqlApp(MySqlAppStatus.get())
app.apply_overrides(overrides)
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:3,代码来源:manager.py
示例20: make_read_only
def make_read_only(self, context, read_only):
LOG.debug("Executing make_read_only(%s)" % read_only)
app = MySqlApp(MySqlAppStatus.get())
app.make_read_only(read_only)
开发者ID:cp16net,项目名称:trove,代码行数:4,代码来源:manager.py
注:本文中的trove.guestagent.datastore.mysql.service.MySqlApp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论