本文整理汇总了Python中storlever.lib.command.check_output函数的典型用法代码示例。如果您正苦于以下问题:Python check_output函数的具体用法?Python check_output怎么用?Python check_output使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_output函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: set_ip_config
def set_ip_config(self, ip=None, netmask=None, gateway=None, user="unknown"):
if ip is None:
ip = self.conf.get("IPADDR", "")
if netmask is None:
netmask = self.conf.get("NETMASK", "")
if gateway is None:
gateway = self.conf.get("GATEWAY", "")
self.conf["IPADDR"] = ip
self.conf["NETMASK"] = netmask
self.conf["GATEWAY"] = gateway
self.conf["BOOTPROTO"] = "none"
# write to config file
self.conf.apply_to(self.conf_file_path)
# restart this interface
if self.ifconfig_interface.is_up():
check_output([IFDOWN, self.name])
check_output([IFUP, self.name])
# log the operation
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"Network interface (%s) is configured with (IP:%s, Netmask:%s, \
Gateway:%s) by user(%s)" %
(self.name, ip, netmask, gateway, user))
开发者ID:OpenSight,项目名称:StorLever,代码行数:27,代码来源:netif.py
示例2: create_target
def create_target(self, iqn, operator="unkown"):
target_conf ={
"iqn": iqn,
"initiator_addr_list": [],
"initiator_name_list": [],
"incominguser_list": [],
"outgoinguser_list": [],
}
target_conf = self.target_conf_schema.validate(target_conf)
with self.lock:
tgt_conf = self._load_conf()
# check duplicate
for target_conf in tgt_conf["target_list"]:
if target_conf["iqn"] == iqn:
raise StorLeverError("Target (iqn:%s) Already exist" % iqn, 400)
tgt_conf["target_list"].append(target_conf)
# save new conf
self._save_conf(tgt_conf)
self._sync_to_system_conf(tgt_conf)
try:
check_output([TGTADMIN_CMD, "--execute"])
except StorLeverError:
pass
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"tgt target (iqn:%s) config is added by operator(%s)" %
(iqn, operator))
开发者ID:OpenSight,项目名称:StorLever,代码行数:31,代码来源:tgtmgr.py
示例3: delete
def delete(self, md_name):
"""
Destroy a RAID device.
WARNING This will zero the superblock of all members of the RAID array..
CLI Example:
.. code-block:: bash
salt '*' raid.destroy /dev/md0
"""
md = MD(md_name, self._lock)
md_device = _md_name_to_dev_file(md_name)
stop_cmd = '/sbin/mdadm --stop {0}'.format(md_device)
zero_cmd = '/sbin/mdadm --zero-superblock {0}'
with self._lock:
check_output(stop_cmd.split())
for _, member in md.members.iteritems():
try:
check_output(zero_cmd.format(member['device']).split())
except StorLeverError:
logger.log(logging.WARNING, logger.LOG_TYPE_ERROR,
"Failed zero superblock of device {0}".format(md_device),
exc_info=True)
self._update_mdadm_conf()
self.refresh()
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"MD {0} removed successfully".format(md_device))
开发者ID:OpenSight,项目名称:StorLever,代码行数:32,代码来源:md.py
示例4: quota_group_set
def quota_group_set(self, group,
block_softlimit=0,
block_hardlimit=0,
inode_softlimit=0,
inode_hardlimit=0,
operator="unknown"):
if not self.is_available():
raise StorLeverError("File system is unavailable", 500)
setquota_agrs = [
SETQUOTA_BIN,
"-g",
group,
str(block_softlimit),
str(block_hardlimit),
str(inode_softlimit),
str(inode_hardlimit),
self.fs_conf["mount_point"]
]
check_output(setquota_agrs)
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"File System(%s) quota for group(%s) is changed to "
"(%d,%d,%d,%d)"
" by user(%s)" %
(self.name, group,
block_softlimit, block_hardlimit,
inode_softlimit, inode_hardlimit,
operator))
开发者ID:OpenSight,项目名称:StorLever,代码行数:28,代码来源:fs.py
示例5: add_component
def add_component(self, device):
add_cmd = '/sbin/mdadm {0} --add {1}'.format(self.dev_file, device)
with self._lock:
check_output(add_cmd.split())
self.refresh()
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"Block device {0} added to MD {1} successfully".format(device, self.dev_file))
开发者ID:OpenSight,项目名称:StorLever,代码行数:7,代码来源:md.py
示例6: grow_raid
def grow_raid(self, device):
grow_cmd = '/sbin/mdadm --grow {0} --raid-device={1}'.format(self.dev_file, device)
with self._lock:
check_output(grow_cmd.split())
self.refresh()
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"MD {0} grows successfully with block device {1}".format(self.dev_file, device))
开发者ID:OpenSight,项目名称:StorLever,代码行数:7,代码来源:md.py
示例7: get_module_info
def get_module_info(self, module_name):
""" get the specific module info/state in the storlever Manager layer
"""
if module_name not in self.managed_modules:
raise StorLeverError("Module(%s) Not Found" % (module_name), 404)
module_conf = self.managed_modules[module_name]
deps_info_list = []
for rpm in module_conf["rpms"]:
installed = True
try:
check_output([RPM_CMD, "-q", rpm])
except StorLeverCmdError:
installed = False
deps_info_list.append({
"name": rpm,
"type": "rpm",
"installed": installed
})
for file_path in module_conf["extra_files"]:
deps_info_list.append({
"name": file_path,
"type": "file",
"installed": os.path.exists(file_path)
})
module_info = {
"module_name": module_conf["module_name"],
"requires": deps_info_list,
"comment": module_conf["comment"],
}
return module_info
开发者ID:OpenSight,项目名称:StorLever,代码行数:32,代码来源:modulemgr.py
示例8: get_smart_info
def get_smart_info(self):
if self.dev_file == "":
raise StorLeverError("scsi_id (%s) has not be recognized" % self.scsi_id, 400)
output = check_output([SMARTCTL_CMD, "-i", "-T", "verypermissive", self.dev_file])
smart_enabled = False
auto_offline_enabled = False
if "SMART support is: Enabled" in output:
smart_enabled = True
output = check_output([SMARTCTL_CMD, "-a", "-T", "verypermissive", self.dev_file])
if "Auto Offline Data Collection: Enabled" in output:
auto_offline_enabled = True
# filter the copyright
lines = output.splitlines()
for index, line in enumerate(lines):
if line == "":
break
else:
index = 0
detail = "\n".join(lines[index + 1:])
info = {
"smart_enabled": smart_enabled,
"auto_offline_enabled": auto_offline_enabled,
"detail": detail
}
return info
开发者ID:ntvis,项目名称:StorLever,代码行数:28,代码来源:scsimgr.py
示例9: set_selinux_state
def set_selinux_state(self, state, user="unknown"):
state_str_to_int = {
"enforcing": 1,
"permissive": 0,
"disabled": 0
}
param = state_str_to_int.get(state)
if param is not None:
old_state = check_output(["/usr/sbin/getenforce"]).lower().strip()
if old_state != "disabled":
check_output(["/usr/sbin/setenforce", str(param)])
if not os.path.exists(SELINUX_CONF_DIR):
os.makedirs(SELINUX_CONF_DIR)
conf_path = os.path.join(SELINUX_CONF_DIR, SELINUX_CONF_FILE)
conf = properties()
conf.delete("SELINUX")
conf.apply_to(conf_path)
with open(conf_path, "r") as f:
content = f.read()
if content.endswith("\n") or len(content) == 0:
content += "SELINUX=%s\n" % state
else:
content += "\nSELINUX=%s\n" % state
with open(conf_path, "w") as f:
f.write(content)
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"selinux state is set to %s by user(%s)" %
(state, user))
开发者ID:OpenSight,项目名称:StorLever,代码行数:30,代码来源:sysinfo.py
示例10: _is_nfs_service_available
def _is_nfs_service_available(ip, mount_options):
proto = Nfs._get_nfs_transport_proto(mount_options)
if proto == "": # detect automatically
cmd = [RPCINFO_CMD, "-s", ip]
try:
result = check_output(cmd)
if "nfs" in result:
return True
except StorLeverCmdError as e:
if e.return_code == 1:
pass
else:
raise
else:
if proto == "udp":
cmd = [RPCINFO_CMD, "-u", ip, "nfs"]
elif proto == "tcp":
cmd = [RPCINFO_CMD, "-t", ip, "nfs"]
try:
result = check_output(cmd)
return True
except StorLeverCmdError as e:
if e.return_code == 1:
pass
else:
raise
return False
开发者ID:OpenSight,项目名称:StorLever,代码行数:27,代码来源:nfs.py
示例11: discovery
def discovery(self, portal, iface_name=None):
# delete the config for this dicovery
try:
check_output([ISCSIADM_CMD, "-m", "discoverydb", "-t", "st",
"-p", portal, "-o", "delete"])
except StorLeverError:
pass
# discovery process
cmd = [ISCSIADM_CMD, "-m", "discovery", "-t", "st", "-p", portal]
if iface_name is not None:
cmd.append("-I")
cmd.append(iface_name)
outlines = check_output(cmd, input_ret=[2, 6, 7, 21, 22]).splitlines()
result = []
for line in outlines:
line_list = line.split()
target = line_list[1]
portal, sep, tag = line_list[0].partition(",")
result.append({
"portal": portal,
"target": target
})
return result
开发者ID:OpenSight,项目名称:StorLever,代码行数:27,代码来源:initiatormgr.py
示例12: set_state
def set_state(self, state, operator="unkown"):
if state == "offline":
check_output([TGTADMIN_CMD, "--offline", self.iqn])
elif state == "ready":
check_output([TGTADMIN_CMD, "--ready", self.iqn])
else:
raise StorLeverError("state (%s) is not supported" %
(state), 400)
开发者ID:OpenSight,项目名称:StorLever,代码行数:8,代码来源:target.py
示例13: group_del_by_name
def group_del_by_name(self, name, user="unknown"):
if name == "root":
raise StorLeverError("cannot del group root", 400)
cmds = ["/usr/sbin/groupdel"]
cmds.append(name)
check_output(cmds, input_ret=[2, 6, 8])
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"System group %s is deleted by user(%s)" %
(name, user))
开发者ID:OpenSight,项目名称:StorLever,代码行数:9,代码来源:usermgr.py
示例14: remove_component
def remove_component(self, device):
fail_cmd = '/sbin/mdadm {0} --fail {1}'.format(self.dev_file, device)
remove_cmd = '/sbin/mdadm {0} --remove {1}'.format(self.dev_file, device)
with self._lock:
check_output(fail_cmd.split())
check_output(remove_cmd.split())
self.refresh()
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"Block device {0} detached from MD {1} created successfully".format(device, self.dev_file))
开发者ID:OpenSight,项目名称:StorLever,代码行数:9,代码来源:md.py
示例15: move
def move(self, dst_device=None, lv_name=None):
cmd = ["pvmove", "-b"]
if lv_name:
cmd.append("-n")
cmd.append(lv_name)
cmd.append(self.dev_file)
if dst_device:
cmd.append(dst_device)
check_output(cmd)
开发者ID:dulton,项目名称:StorLever,代码行数:9,代码来源:lvm.py
示例16: safe_delete
def safe_delete(self):
# flush dev's buf first
try:
if self.dev_file != "":
check_output([BLOCKDEV_CMD, "--flushbufs", self.dev_file])
except Exception:
pass
delete_path = os.path.join("/sys/class/scsi_device/", self.scsi_id, "device/delete")
write_file_entry(delete_path, "1\n")
开发者ID:ntvis,项目名称:StorLever,代码行数:9,代码来源:scsimgr.py
示例17: group_add
def group_add(self, name, gid=None, user="unknown"):
cmds = ["/usr/sbin/groupadd"]
if gid is not None:
cmds.append("-g")
cmds.append("%d" % int(gid))
cmds.append(name)
check_output(cmds, input_ret=[2, 3, 4, 9])
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"New system group %s is created by user(%s)" %
(name, user))
开发者ID:OpenSight,项目名称:StorLever,代码行数:10,代码来源:usermgr.py
示例18: mount
def mount(self):
# check nfs service available on the remote host
ip, path = Nfs._parse_dev_file(self.fs_conf["dev_file"])
if not Nfs._is_nfs_service_available(ip, self.mount_options):
raise StorLeverError("NFS service on %s is not available" % ip, 400)
check_output(["/bin/mount", "-t", self.fs_conf["type"],
"-o", self.mount_options,
self.fs_conf["dev_file"], self.fs_conf["mount_point"]],
input_ret=[32])
开发者ID:OpenSight,项目名称:StorLever,代码行数:10,代码来源:nfs.py
示例19: up
def up(self, user="unknown"):
self.conf["ONBOOT"] = "yes"
self.save_conf()
check_output([IFUP, self.name])
# log the operation
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"Network interface (%s) is up by user(%s)" %
(self.name, user))
开发者ID:OpenSight,项目名称:StorLever,代码行数:10,代码来源:netif.py
示例20: set_conf
def set_conf(self, name, value, operator="unkown"):
name = str(name).strip()
value = str(value).strip()
check_output([ISCSIADM_CMD, "-m", "iface", "-I", self.iscsi_ifacename, "-o", "update",
"-n", name, "-v", value], input_ret=[2, 6, 7, 21, 22])
self._refresh_property()
logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
"iscsi initiator iface (%s) conf (%s:%s) is updated by operator(%s)" %
(self.iscsi_ifacename, name, value, operator))
开发者ID:OpenSight,项目名称:StorLever,代码行数:11,代码来源:iface.py
注:本文中的storlever.lib.command.check_output函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论