本文整理汇总了Python中trove.guestagent.datastore.experimental.vertica.system.shell_execute函数的典型用法代码示例。如果您正苦于以下问题:Python shell_execute函数的具体用法?Python shell_execute怎么用?Python shell_execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shell_execute函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: stop_db
def stop_db(self, update_db=False, do_not_start_on_reboot=False):
"""Stop the database."""
LOG.info(_("Stopping Vertica."))
if do_not_start_on_reboot:
self._disable_db_on_boot()
try:
# Stop vertica-agent service
command = (system.VERTICA_AGENT_SERVICE_COMMAND % "stop")
system.shell_execute(command)
# Using Vertica adminTools to stop db.
db_password = self._get_database_password()
stop_db_command = (system.STOP_DB % (DB_NAME, db_password))
out, err = system.shell_execute(system.STATUS_ACTIVE_DB, "dbadmin")
if out.strip() == DB_NAME:
system.shell_execute(stop_db_command, "dbadmin")
if not self.status._is_restarting:
if not self.status.wait_for_real_status_to_change_to(
rd_instance.ServiceStatuses.SHUTDOWN,
self.state_change_wait_time, update_db):
LOG.error(_("Could not stop Vertica."))
self.status.end_restart()
raise RuntimeError("Could not stop Vertica!")
LOG.debug("Database stopped.")
else:
LOG.debug("Database is not running.")
except exception.ProcessExecutionError:
LOG.exception(_("Failed to stop database."))
raise RuntimeError("Could not stop database.")
开发者ID:magictour,项目名称:trove,代码行数:29,代码来源:service.py
示例2: authorize_public_keys
def authorize_public_keys(self, user, public_keys):
"""Adds public key to authorized_keys for user."""
LOG.debug("public keys to be added for user: %s." % (user))
user_home_directory = os.path.expanduser('~' + user)
authorized_file_name = user_home_directory + '/.ssh/authorized_keys'
try:
read_key_cmd = ("cat %(file)s" % {'file': authorized_file_name})
out, err = system.shell_execute(read_key_cmd)
public_keys.append(out.strip())
except exception.ProcessExecutionError:
LOG.debug("Cannot read authorized_keys.")
all_keys = '\n'.join(public_keys) + "\n"
try:
with tempfile.NamedTemporaryFile(delete=False) as tempkeyfile:
tempkeyfile.write(all_keys)
copy_key_cmd = (("install -o %(user)s -m 600 %(source)s %(target)s"
) % {'user': user, 'source': tempkeyfile.name,
'target': authorized_file_name})
system.shell_execute(copy_key_cmd)
os.remove(tempkeyfile.name)
except exception.ProcessExecutionError:
LOG.exception(_("Cannot install public keys."))
os.remove(tempkeyfile.name)
raise
开发者ID:magictour,项目名称:trove,代码行数:26,代码来源:service.py
示例3: _disable_db_on_boot
def _disable_db_on_boot(self):
try:
command = (system.SET_RESTART_POLICY % (DB_NAME, "never"))
system.shell_execute(command, "dbadmin")
command = (system.VERTICA_AGENT_SERVICE_COMMAND % "disable")
system.shell_execute(command)
except exception.ProcessExecutionError:
LOG.exception(_("Failed to disable db on boot."))
raise RuntimeError("Could not disable db on boot.")
开发者ID:magictour,项目名称:trove,代码行数:9,代码来源:service.py
示例4: _export_conf_to_members
def _export_conf_to_members(self, members):
"""This method exports conf files to other members."""
try:
for member in members:
COPY_CMD = (system.SEND_CONF_TO_SERVER % (system.VERTICA_CONF,
member,
system.VERTICA_CONF))
system.shell_execute(COPY_CMD)
except exception.ProcessExecutionError:
LOG.exception(_("Cannot export configuration."))
raise
开发者ID:magictour,项目名称:trove,代码行数:11,代码来源:service.py
示例5: update_vertica
def update_vertica(self, command, members=netutils.get_my_ipv4()):
LOG.info(_("Calling update_vertica with command %s") % command)
try:
update_vertica_cmd = (system.UPDATE_VERTICA % (command, members,
MOUNT_POINT))
system.shell_execute(update_vertica_cmd)
except exception.ProcessExecutionError:
LOG.exception(_("update_vertica failed."))
raise RuntimeError(_("update_vertica failed."))
# self._generate_database_password()
LOG.info(_("update_vertica completed."))
开发者ID:melvinj1123,项目名称:trove,代码行数:11,代码来源:service.py
示例6: install_vertica
def install_vertica(self, members=netutils.get_my_ipv4()):
"""Prepare the guest machine with a Vertica db creation."""
LOG.info(_("Installing Vertica Server."))
try:
# Create db after install
install_vertica_cmd = (system.INSTALL_VERTICA % (members,
MOUNT_POINT))
system.shell_execute(install_vertica_cmd)
except exception.ProcessExecutionError:
LOG.exception(_("install_vertica failed."))
self._generate_database_password()
LOG.info(_("install_vertica completed."))
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:12,代码来源:service.py
示例7: prepare_for_install_vertica
def prepare_for_install_vertica(self):
"""This method executes preparatory methods before
executing install_vertica.
"""
command = ("VERT_DBA_USR=dbadmin VERT_DBA_HOME=/home/dbadmin "
"VERT_DBA_GRP=verticadba /opt/vertica/oss/python/bin/python"
" -m vertica.local_coerce")
try:
self._set_readahead_for_disks()
system.shell_execute(command)
except exception.ProcessExecutionError:
LOG.exception(_("Failed to prepare for install_vertica."))
raise
开发者ID:magictour,项目名称:trove,代码行数:13,代码来源:service.py
示例8: create_db
def create_db(self, members=netutils.get_my_ipv4()):
"""Prepare the guest machine with a Vertica db creation."""
LOG.info(_("Creating database on Vertica host."))
try:
# Create db after install
db_password = self._get_database_password()
create_db_command = (system.CREATE_DB % (members, DB_NAME,
MOUNT_POINT, MOUNT_POINT,
db_password))
system.shell_execute(create_db_command, "dbadmin")
except Exception:
LOG.exception(_("Vertica database create failed."))
LOG.info(_("Vertica database create completed."))
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:13,代码来源:service.py
示例9: add_db_to_node
def add_db_to_node(self, members=netutils.get_my_ipv4()):
"""Add db to host with admintools"""
LOG.info(_("Calling admintools to add DB to host"))
try:
# Create db after install
db_password = self._get_database_password()
create_db_command = (system.ADD_DB_TO_NODE % (members,
DB_NAME,
db_password))
system.shell_execute(create_db_command, "dbadmin")
except exception.ProcessExecutionError:
# Give vertica some time to get the node up, won't be available
# by the time adminTools -t db_add_node completes
LOG.info(_("adminTools failed as expected - wait for node"))
self.wait_for_node_status()
LOG.info(_("Vertica add db to host completed."))
开发者ID:melvinj1123,项目名称:trove,代码行数:16,代码来源:service.py
示例10: write_config
def write_config(self, config,
unlink_function=os.unlink,
temp_function=tempfile.NamedTemporaryFile):
"""Write the configuration contents to vertica.cnf file."""
LOG.debug('Defining config holder at %s.' % system.VERTICA_CONF)
tempfile = temp_function(delete=False)
try:
config.write(tempfile)
tempfile.close()
command = (("install -o root -g root -m 644 %(source)s %(target)s"
) % {'source': tempfile.name,
'target': system.VERTICA_CONF})
system.shell_execute(command)
unlink_function(tempfile.name)
except Exception:
unlink_function(tempfile.name)
raise
开发者ID:magictour,项目名称:trove,代码行数:17,代码来源:service.py
示例11: get_public_keys
def get_public_keys(self, user):
"""Generates key (if not found), and sends public key for user."""
LOG.debug("Public keys requested for user: %s." % user)
user_home_directory = os.path.expanduser('~' + user)
public_key_file_name = user_home_directory + '/.ssh/id_rsa.pub'
try:
key_generate_command = (system.SSH_KEY_GEN % user_home_directory)
system.shell_execute(key_generate_command, user)
except exception.ProcessExecutionError:
LOG.debug("Cannot generate key.")
try:
read_key_cmd = ("cat %(file)s" % {'file': public_key_file_name})
out, err = system.shell_execute(read_key_cmd)
except exception.ProcessExecutionError:
LOG.exception(_("Cannot read public key."))
raise
return out.strip()
开发者ID:magictour,项目名称:trove,代码行数:19,代码来源:service.py
示例12: remove_db_from_node
def remove_db_from_node(self, members=netutils.get_my_ipv4()):
"""Remove db from node with admintools"""
LOG.info(_("Removing db from node"))
try:
# Create db after install
db_password = self._get_database_password()
create_db_command = (system.REMOVE_DB_FROM_NODE % (members,
DB_NAME,
db_password))
system.shell_execute(create_db_command, "dbadmin")
except exception.ProcessExecutionError:
# Give vertica some time to get the node up, won't be available
# by the time adminTools -t db_add_node completes
LOG.info(_("adminTools failed as expected - wait for node"))
# Give vertica some time to take the node down - it won't be available
# by the time adminTools -t db_add_node completes
self.wait_for_node_status()
LOG.info(_("Vertica remove host from db completed."))
开发者ID:melvinj1123,项目名称:trove,代码行数:19,代码来源:service.py
示例13: is_root_enabled
def is_root_enabled(self):
"""Return True if root access is enabled else False."""
LOG.debug("Checking is root enabled.")
try:
out, err = system.shell_execute(system.USER_EXISTS %
(self._get_database_password(),
'root'), 'dbadmin')
if err:
LOG.error(err)
raise RuntimeError(_("Failed to query for root user."))
except exception.ProcessExecutionError:
raise RuntimeError(_("Failed to query for root user."))
return out.rstrip() == "1"
开发者ID:magictour,项目名称:trove,代码行数:13,代码来源:service.py
示例14: _get_actual_db_status
def _get_actual_db_status(self):
"""Get the status of dbaas and report it back."""
try:
out, err = system.shell_execute(system.STATUS_ACTIVE_DB,
"dbadmin")
if out.strip() == DB_NAME:
# UP status is confirmed
LOG.info(_("Service Status is RUNNING."))
return rd_instance.ServiceStatuses.RUNNING
else:
LOG.info(_("Service Status is SHUTDOWN."))
return rd_instance.ServiceStatuses.SHUTDOWN
except exception.ProcessExecutionError:
LOG.exception(_("Failed to get database status."))
return rd_instance.ServiceStatuses.CRASHED
开发者ID:magictour,项目名称:trove,代码行数:15,代码来源:service.py
注:本文中的trove.guestagent.datastore.experimental.vertica.system.shell_execute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论