本文整理汇总了Python中utils.execute_local_command函数的典型用法代码示例。如果您正苦于以下问题:Python execute_local_command函数的具体用法?Python execute_local_command怎么用?Python execute_local_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute_local_command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_running
def is_running(self, **kwargs):
service_name = self._get_sysvinit_name(**kwargs)
arguments = [
'chkconfig',
service_name,
'status'
]
utils.execute_local_command(arguments)
示例2: on_boot_disable
def on_boot_disable(self, **kwargs):
service_name = self._get_sysvinit_name(**kwargs)
arguments = [
'chkconfig',
service_name,
'off'
]
utils.execute_local_command(arguments)
示例3: restart
def restart(self, **kwargs):
service_name = self._get_sysvinit_name(**kwargs)
arguments = [
'service',
service_name,
'restart'
]
utils.execute_local_command(arguments)
示例4: zap
def zap(dev = None, **kwargs):
"""
Destroy the partition table and content of a given disk.
"""
if dev is not None:
log.warning("Depricated use of function, use kwargs")
dev = kwargs.get("dev", dev)
if dev == None:
raise Error('Cannot find', dev)
if not os.path.exists(dev):
raise Error('Cannot find', dev)
dmode = os.stat(dev).st_mode
mdl = model.model(**kwargs)
osdc = osd.osd_ctrl(mdl)
if not stat.S_ISBLK(dmode) or osdc.is_partition(dev):
raise Error('not full block device; cannot zap', dev)
try:
log.debug('Zapping partition table on %s', dev)
# try to wipe out any GPT partition table backups. sgdisk
# isn't too thorough.
lba_size = 4096
size = 33 * lba_size
with file(dev, 'wb') as dev_file:
dev_file.seek(-size, os.SEEK_END)
dev_file.write(size*'\0')
utils.execute_local_command(
[
util_which.which_sgdisk.path,
'--zap-all',
'--',
dev,
],
)
utils.execute_local_command(
[
util_which.which_sgdisk.path,
'--clear',
'--mbrtogpt',
'--',
dev,
],
)
_update_partition('-d', dev, 'zapped')
except subprocess.CalledProcessError as e:
raise Error(e)
return True
示例5: _update_partition
def _update_partition(action, dev, description):
# try to make sure the kernel refreshes the table. note
# that if this gets ebusy, we are probably racing with
# udev because it already updated it.. ignore failure here.
# On RHEL and CentOS distros, calling partprobe forces a reboot of the
# server. Since we are not resizing partitons so we rely on calling
# partx
utils.execute_local_command(
[
constants._path_partprobe,
dev,
],
)
示例6: retrive_osd_details
def retrive_osd_details(device_name):
osd_details = {}
if device_name is None:
return None
try:
tmpd = tempfile.mkdtemp()
try:
out_mnt = utils.execute_local_command(['mount',device_name,tmpd])
if out_mnt['retcode'] == 0:
osd_details = _retrive_osd_details_from_dir(tmpd)
finally:
utils.execute_local_command(['umount',tmpd])
finally:
os.rmdir(tmpd)
return osd_details
示例7: _execute
def _execute(self,arguments):
prefix = [
"sudo",
"-u",
"ceph"
]
return utils.execute_local_command(prefix + arguments)
示例8: auth_add
def auth_add(self, keyring_type):
"""
Authorise keyring
"""
keyringobj = keyring.keyring_facard(self.model)
keyringobj.key_type = keyring_type
if not keyringobj.present():
raise Error("rgw keyring not found")
q = mdl_query.mdl_query(self.model)
if q.mon_is() and q.mon_quorum() is False:
raise Error("mon daemon is not in quorum")
arguments = [
"ceph",
"auth",
"import",
"-i",
keyringobj.keyring_path_get()
]
output = utils.execute_local_command(arguments)
if output["retcode"] != 0:
raise Error("Failed executing '%s' Error rc=%s, stdout=%s stderr=%s" % (
" ".join(arguments),
output["retcode"],
output["stdout"],
output["stderr"])
)
return True
示例9: auth_del
def auth_del(self, **kwargs):
"""
Remove Authorised keyring
"""
self.model.kargs_apply(**kwargs)
u = mdl_updater.model_updater(m)
u.hostname_refresh()
if m.cluster_name == None:
u.defaults_refresh()
self.cluster_name = m.cluster_name
u.load_confg(m.cluster_name)
u.mon_members_refresh()
q = mdl_query.mdl_query(m)
if not q.mon_is():
raise Error("Not ruining a mon daemon")
u.mon_status()
if not q.mon_quorum():
raise Error("mon daemon is not in quorum")
arguments = [
"ceph",
"auth",
"del",
self.keyring_name
]
cmd_out = utils.execute_local_command(arguments)
return True
示例10: auth_add
def auth_add(self, **kwargs):
"""
Authorise keyring
"""
self.model.kargs_apply(**kwargs)
u = mdl_updater.model_updater(self.model)
u.hostname_refresh()
if self.model.cluster_name == None:
u.defaults_refresh()
keyring_path = self.get_path_keyring()
if not os.path.isfile(keyring_path):
raise Error("rgw keyring not found")
u.load_confg(self.model.cluster_name)
u.mon_members_refresh()
q = mdl_query.mdl_query(self.model)
if not q.mon_is():
raise Error("Not ruining a mon daemon")
u.mon_status()
if not q.mon_quorum():
raise Error("mon daemon is not in quorum")
arguments = [
"ceph",
"auth",
"import",
"-i",
keyring_path
]
cmd_out = utils.execute_local_command(arguments)
return True
示例11: _pool_adder
def _pool_adder(self, name, **kwargs):
pg_num = kwargs.get("pg_num", 8)
pgp_num = kwargs.get("pgp_num", pg_num)
pool_type = kwargs.get("pool_type")
er_profile = kwargs.get("erasure_code_profile")
crush_ruleset_name = kwargs.get("crush_ruleset")
arguments = [
'ceph',
'osd',
'pool',
'create',
name,
str(pg_num)
]
if pgp_num != None:
arguments.append(str(pgp_num))
if pool_type == "replicated":
arguments.append("replicated")
if pool_type == "erasure":
arguments.append("erasure")
arguments.append("erasure-code-profile=%s" % (er_profile))
if crush_ruleset_name != None:
arguments.append(crush_ruleset_name)
output = utils.execute_local_command(arguments)
if output["retcode"] != 0:
raise Error("Failed executing '%s' Error rc=%s, stdout=%s stderr=%s" % (
" ".join(arguments),
output["retcode"],
output["stdout"],
output["stderr"]))
示例12: _remove_rgw_keyring
def _remove_rgw_keyring(self):
self._set_rgw_path_lib()
if not os.path.isdir(self.rgw_path_lib):
return
rgw_path_keyring = os.path.join(self.rgw_path_lib, 'keyring')
path_bootstrap_keyring = keyring._get_path_keyring_rgw(self.model.cluster_name)
arguments = [
'ceph',
'--connect-timeout',
'5',
'--cluster', self.model.cluster_name,
'--name', 'client.bootstrap-rgw',
'--keyring', path_bootstrap_keyring,
'auth', 'del', 'client.{name}'.format(name=self.rgw_name),
]
output = utils.execute_local_command(arguments)
if output["retcode"] != 0:
raise Error("Failed executing '%s' Error rc=%s, stdout=%s stderr=%s" % (
" ".join(arguments),
output["retcode"],
output["stdout"],
output["stderr"])
)
示例13: activate_partition
def activate_partition(self, partition, **kwargs):
dmcrypt = kwargs.get("dmcrypt")
dmcrypt_key_dir = kwargs.get("dmcrypt_key_dir")
arguments = [
'ceph-disk',
'-v',
'activate',
'--mark-init',
self.model.init,
'--mount',
]
if dmcrypt is not None:
arguments.append("--dmcrypt")
if dmcrypt_key_dir is not None:
arguments.append("--dmcrypt-key-dir")
arguments.append(dmcrypt_key_dir)
arguments.append(partition)
output = utils.execute_local_command(arguments)
if output["retcode"] != 0:
raise Error("Failed executing '%s' Error rc=%s, stdout=%s stderr=%s" % (
" ".join(arguments),
output["retcode"],
output["stdout"],
output["stderr"])
)
return True
示例14: unmount_osd
def unmount_osd(self):
for part in self.model.partitions_osd:
disk = self.model.part_pairent.get(part)
if disk is None:
continue
disk_details = self.model.lsblk.get(disk)
if disk_details is None:
continue
all_parts = disk_details.get('PARTITION')
if all_parts is None:
continue
part_details = all_parts.get(part)
if part_details is None:
continue
mountpoint = part_details.get("MOUNTPOINT")
if mountpoint is None:
continue
arguments = [
"umount",
mountpoint
]
output = utils.execute_local_command(arguments)
if output["retcode"] != 0:
raise Error("Failed executing '%s' Error rc=%s, stdout=%s stderr=%s" % (
" ".join(arguments),
output["retcode"],
output["stdout"],
output["stderr"]
))
示例15: partition_table_refresh
def partition_table_refresh(self):
for disk_name in self.model.lsblk.keys():
arguments = [
'parted',
disk_name,
'print'
]
log.debug("Running:%s" % (" ".join(arguments)))
output = utils.execute_local_command(arguments)
if output["retcode"] != 0:
raise Error("Failed executing '%s' Error rc=%s, stdout=%s stderr=%s" % (
" ".join(arguments),
output["retcode"],
output["stdout"],
output["stderr"]
))
part_type = None
for line in output["stdout"].split('\n'):
split_line = line.split(':')
if split_line[0] != 'Partition Table':
continue
part_type = ":".join(split_line[1:]).strip()
if part_type is None:
continue
self.model.lsblk[disk_name]["PARTTABLE"] = part_type