本文整理汇总了Python中xapi.storage.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: epc_close
def epc_close(dbg, uri, cb):
log.debug("{}: Datapath.epc_close: uri == {}".format(dbg, uri))
sr, key = _parse_uri(uri)
opq = cb.volumeStartOperations(sr, 'w')
meta_path = cb.volumeMetadataGetPath(opq)
db = VHDMetabase(meta_path)
try:
with Lock(opq, 'gl', cb):
with db.write_context():
vdi = db.get_vdi_by_id(key)
vol_path = cb.volumeGetPath(opq, str(vdi.vhd.id))
if vdi.nonpersistent:
# truncate
VHDUtil.reset(dbg, vol_path)
db.update_vdi_nonpersistent(vdi.uuid, None)
except:
log.error(
("{}: Datapath.epc_close: failed to complete "
"close, {}").format(dbg, sys.exc_info()[1])
)
raise
finally:
db.close()
return None
示例2: volumeRename
def volumeRename(self, opq, old_name, new_name):
log.debug("volumeRename opq=%s old=%s new=%s" % (opq, old_name, new_name))
os.rename(os.path.join(opq, old_name),
os.path.join(opq, new_name))
os.rename(os.path.join(opq, new_name, old_name),
os.path.join(opq, new_name, new_name))
return os.path.join(opq, new_name, new_name)
示例3: attach
def attach(self, dbg, uri, domain):
# FIXME: add lvm activation code
u = urlparse.urlparse(uri)
(vgname, lvname, scsid) = self._getVgLvScsid(dbg, u.path)
log.debug("%s Vg=%s Lv=%s Scsid%s" % (dbg, vgname, lvname, scsid))
vg = self._vgOpen(dbg, vgname, "r", scsid)
lv = vg.lvFromName(lvname)
lv.activate()
vg.close()
cmd = ["/usr/bin/vhd-util", "query", "-n", u.path, "-P"]
output = call(dbg, cmd)
log.debug("%s output=%s" % (dbg, output))
output = output[:-1]
if output[-6:] == "parent":
log.debug("No Parent")
else:
output = output.replace("--", "-")
log.debug("%s" % output[-36:])
activation_file = "/var/run/nonpersistent/" + vgname + "/" + output[-36:]
if (not os.path.exists(activation_file)):
vg = self._vgOpen(dbg, vgname, "r", scsid)
lv = vg.lvFromName(output[-36:])
log.debug("Activating %s" % lv.getName())
lv.activate()
vg.close()
open(activation_file, 'a').close()
tap = tapdisk.create(dbg)
tapdisk.save_tapdisk_metadata(dbg, u.path, tap)
return {
'domain_uuid': '0',
'implementation': ['Tapdisk3', tap.block_device()],
}
示例4: stat
def stat(self, dbg, sr):
# SR path (sr) is file://<mnt_path>
# Get mnt_path by dropping url scheme
uri = urlparse.urlparse(sr)
mnt_path = "/%s/%s" % (uri.netloc, uri.path)
if not(os.path.isdir(mnt_path)) or not(os.path.ismount(mnt_path)):
raise xapi.storage.api.volume.Sr_not_attached(mnt_path)
# Get the filesystem size
statvfs = os.statvfs(mnt_path)
psize = statvfs.f_blocks * statvfs.f_frsize
fsize = statvfs.f_bfree * statvfs.f_frsize
log.debug("%s: statvfs says psize = %Ld" % (dbg, psize))
overprovision = \
VHDVolume.get_sr_provisioned_size(sr, gfs2.Callbacks()) / psize
return {
"sr": sr,
"name": "SR Name",
"description": "GFS2 SR",
"total_space": psize,
"free_space": fsize,
"overprovision": overprovision,
"datasources": [],
"clustered": True,
"health": ["Healthy", ""]
}
示例5: volumeCreate
def volumeCreate(self, opq, name, size):
log.debug("volumeCreate opq=%s name=%s size=%d" % (opq, name, size))
vol_dir = os.path.join(opq, name)
vol_path = os.path.join(vol_dir, name)
os.makedirs(vol_dir, mode=0755)
open(vol_path, 'a').close()
return vol_path
示例6: call
def call(dbg, cmd_args, error=True, simple=True, exp_rc=0):
"""[call dbg cmd_args] executes [cmd_args]
if [error] and exit code != exp_rc, log and throws a BackendError
if [simple], returns only stdout
"""
log.debug("{}: Running cmd {}".format(dbg, cmd_args))
p = subprocess.Popen(
cmd_args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True
)
stdout, stderr = p.communicate()
if error and p.returncode != exp_rc:
log.error(
"{}: {} exitted with code {}: {}".format(
dbg,
' '.join(cmd_args),
p.returncode,
stderr
)
)
# TODO: FIXME: Remove dependency on Xapi.
#raise xapi.InternalError("%s exitted with non-zero code %d: %s"
# % (" ".join(cmd_args), p.returncode, stderr))
if simple:
return stdout
return stdout, stderr, p.returncode
示例7: mount
def mount(dbg, dev_path):
# Ensure corosync+dlm are configured and running
inventory = xcp.environ.readInventory()
session = XenAPI.xapi_local()
session.xenapi.login_with_password("root", "")
this_host = session.xenapi.host.get_by_uuid(
inventory.get("INSTALLATION_UUID"))
log.debug("%s: setting up corosync and dlm on this host" % (dbg))
session.xenapi.host.call_plugin(
this_host, "gfs2setup", "gfs2Setup", {})
mnt_path = os.path.abspath(mountpoint_root + dev_path)
try:
os.makedirs(mnt_path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(mnt_path):
pass
else:
raise
if not os.path.ismount(mnt_path):
cmd = ["/usr/sbin/modprobe", "gfs2"]
call(dbg, cmd)
cmd = ["/usr/bin/mount", "-t", "gfs2", "-o",
"noatime,nodiratime", dev_path, mnt_path]
call(dbg, cmd)
return mnt_path
示例8: dlm_fence_daemon
def dlm_fence_daemon(node_id):
n = int(node_id)
log.debug("Starting dlm_fence_daemon on node_id=%d" % n)
wd = os.open("/dev/watchdog", os.O_WRONLY)
def dlm_fence_daemon_signal_handler(sig, frame):
log.debug("dlm_fence_daemon_signal_handler")
os.write(wd, "V")
os.close(wd)
log.debug("dlm_fence_daemon: exiting cleanly")
exit(0)
signal.signal(signal.SIGUSR1, dlm_fence_daemon_signal_handler)
demonize()
while True:
f = util.lock_file("SSSS", DLMREF_LOCK, "r+")
d = shelve.open(DLMREF)
klist = d.keys()
for key in klist:
bd = "/dev/" + key + "/sbd"
ret = block_read(bd, BLK_SIZE * 2 * n)
if ret == MSG_OK:
pass
elif ret == MSG_FENCE:
log.debug("dlm_fence_daemon: MSG_FENCE")
log.debug("dlm_fence_daemon: Setting WD timeout to 1 second")
s = struct.pack ("i", 1)
fcntl.ioctl(wd, 3221509894 , s)
log.debug("dlm_fence_daemon: writing MSG_FENCE_ACK")
ret = block_write(bd, BLK_SIZE * ((2 * n) + 1), MSG_FENCE_ACK)
log.debug("dlm_fence_daemon: MSG_FENCE_ACK sent")
# host will be fenced in 1 second
d.close()
util.unlock_file("SSSS", f)
os.write(wd, "w")
time.sleep(1)
示例9: dlm_fence_no_args
def dlm_fence_no_args():
log.debug("dlm_fence_no_args")
for line in sys.stdin:
log.debug("dlm_fence_no_args: %s" % line)
if line.startswith("node="):
node_id = int(int(line[5:]) % 4096)
dlm_fence_node(node_id)
示例10: dlm_fence_clear_by_id
def dlm_fence_clear_by_id(node_id, scsi_id):
n = int(node_id)
bd = "/dev/" + scsi_id + "/sbd"
log.debug("dlm_fence_clear_by_id: clearing node_id=%d, scsi_id=%s" %
(n, scsi_id))
ret = block_write(bd, BLK_SIZE * 2 * n, MSG_OK)
ret = block_write(bd, BLK_SIZE * ((2 * n) + 1), MSG_OK)
示例11: getUniqueIdentifier
def getUniqueIdentifier(self, opq):
log.debug("getUniqueIdentifier opq=%s" % opq)
meta_path = os.path.join(opq, "meta.json")
with open(meta_path, "r") as fd:
meta = json.load(fd)
value = meta["unique_id"]
return value
示例12: _getVgLvScsid
def _getVgLvScsid(self, dbg, path):
log.debug("%s path=%s" % (dbg, path))
parts = path.split("/")
vgname = parts[2]
lvname = parts[3]
with open("/var/run/nonpersistent/" + vgname + "/scsid", "r") as text_file:
scsid = text_file.read()
return (vgname, lvname, scsid)
示例13: dlm_fence_daemon_start
def dlm_fence_daemon_start(node_id):
import subprocess
args = ['/usr/libexec/xapi-storage-script/volume/org.xen.xapi.storage.gfs2/fence_tool.py',
"dlm_fence_daemon", str(node_id)]
dlm_fence_daemon = subprocess.Popen(args)
log.debug("dlm_fence_daemon_start: node_id=%d" % node_id)
with open("/var/run/sr-ref/dlm_fence_daemon.pickle", 'w+') as f:
pickle.dump(dlm_fence_daemon, f)
示例14: getPVName
def getPVName(dbg, sr):
try:
uri = getFromSRMetadata(dbg, sr, 'uri')
dev_path = blkinfo.get_device_path(dbg, uri)
cmd = ["readlink", "-f", dev_path]
output = call(dbg, cmd)
return output.rstrip()
except Exception,e:
log.debug("Exception raised in getting PV name: %s" %str(e))
示例15: volumeTryLock
def volumeTryLock(self, opq, name):
try:
log.debug("volumeLock opq=%s name=%s" % (opq, name))
vol_path = os.path.join(opq, name)
lock = open(vol_path, 'w+')
fcntl.flock(lock, fcntl.LOCK_EX| fcntl.LOCK_NB)
return lock
except IOError, e:
if e.errno in [errno.EACCES, errno.EAGAIN]:
return None
raise