本文整理汇总了Python中xapi.storage.common.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_if_gfs2
def find_if_gfs2(impl, dbg, uri):
srs = []
dev_path = blkinfo.get_device_path(dbg, uri)
unique_id = get_unique_id_from_dev_path(dev_path)
if blkinfo.get_format(dbg, dev_path) == "LVM2_member":
gfs2_dev_path = "/dev/" + unique_id + "/gfs2"
# activate gfs2 LV
cmd = ["/usr/sbin/lvchange", "-ay", unique_id + "/gfs2"]
call(dbg, cmd)
if blkinfo.get_format(dbg, gfs2_dev_path) == "gfs2":
mount = False
try:
mnt_path = getSRMountPath(dbg, gfs2_dev_path)
except:
#mount path doesn't exist
mount = True
mnt_path = mount_local(dbg, gfs2_dev_path)
# stat takes sr_path which is
# file://<mnt_path>
sr_path = "file://%s" % mnt_path
srs.append(impl.stat(dbg, sr_path))
if mount == True:
umount(dbg, mnt_path)
# deactivate gfs2 LV
cmd = ["/usr/sbin/lvchange", "-an", unique_id + "/gfs2"]
call(dbg, cmd)
return srs
示例2: sync_leaf_coalesce
def sync_leaf_coalesce(key, parent_key, conn, cb, opq):
print ("leaf_coalesce_snapshot key=%s" % key)
key_path = cb.volumeGetPath(opq, key)
parent_path = cb.volumeGetPath(opq, parent_key)
res = conn.execute("select parent from VDI where rowid = (?)",
(int(parent_key),)).fetchall()
p_parent = res[0][0]
print p_parent
if p_parent:
p_parent = int(p_parent)
else:
p_parent = "?"
tap_ctl_pause(key, conn, cb, opq)
cmd = ["/usr/bin/vhd-util", "coalesce", "-n", key_path]
call("GC", cmd)
cb.volumeDestroy(opq, key)
base_path = cb.volumeRename(opq, parent_key, key)
res = conn.execute("delete from VDI where rowid = (?)", (int(parent_key),))
res = conn.execute("update VDI set parent = (?) where rowid = (?)",
(p_parent, int(key),) )
conn.commit()
tap_ctl_unpause(key, conn, cb, opq)
示例3: create
def create(dbg, base_device):
try:
return DeviceMapper(dbg, base_device)
except:
call(dbg, ["dmsetup", "create", name_of_device(
base_device), "--table", table(base_device)])
return DeviceMapper(dbg, base_device)
示例4: create
def create(dbg, path):
"""Creates a new loop device backed by the given file"""
# losetup will resolve paths and 'find' needs to use string equality
path = os.path.realpath(path)
call(dbg, ["losetup", "-f", path])
return find(dbg, path)
示例5: 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
示例6: pause
def pause(self, dbg):
call(dbg,
["tap-ctl",
"pause",
"-m",
str(self.minor),
"-p",
str(self.pid)])
示例7: waitForDevice
def waitForDevice(dbg):
# Wait for new device(s) to appear
cmd = ["/usr/sbin/udevadm", "settle"]
call(dbg, cmd)
# FIXME: For some reason, udevadm settle isn't sufficient
# to ensure the device is present. Why not?
time.sleep(10)
示例8: open
def open(self, dbg, f, o_direct=True):
assert (isinstance(f, image.Vhd) or isinstance(f, image.Raw))
args = ["tap-ctl", "open", "-m", str(self.minor),
"-p", str(self.pid), "-a", str(f)]
if not o_direct:
args.append("-D")
call(dbg, args)
self.f = f
示例9: destroy
def destroy(self, dbg):
self.pause(dbg)
call(dbg,
["tap-ctl",
"destroy",
"-m",
str(self.minor),
"-p",
str(self.pid)])
示例10: close
def close(self, dbg):
call(dbg,
["tap-ctl",
"close",
"-m",
str(self.minor),
"-p",
str(self.pid)])
self.f = None
示例11: create
def create(dbg, sr, name, description, size, cb):
vol_name = str(uuid.uuid4()) + ".vhd"
opq = cb.volumeStartOperations(sr, 'w')
vol_path = cb.volumeCreate(opq, vol_name, size)
cb.volumeActivateLocal(opq, vol_name)
# Calculate virtual size (round up size to nearest MiB)
size = int(size)
size_mib = size / 1048576
if size % 1048576 != 0:
size_mib = size_mib + 1
vsize = size_mib * 1048576
# Create the VHD
cmd = ["/usr/bin/vhd-util", "create", "-n", vol_path,
"-s", str(size_mib)]
call(dbg, cmd)
cb.volumeDeactivateLocal(opq, vol_name)
# Fetch physical utilisation
psize = cb.volumeGetPhysSize(opq, vol_name)
# Save metadata
meta_path = cb.volumeMetadataGetPath(opq)
cb.volumeStopOperations(opq)
d = shelve.open(meta_path)
meta = {
"name": name,
"description": description,
"vsize": vsize,
"keys": {},
"childrens": [],
"parent": "None"
}
d[vol_name] = meta
d.close()
return {
"key": vol_name,
"uuid": vol_name,
"name": name,
"description": description,
"read_write": True,
"virtual_size": vsize,
"physical_utilisation": psize,
"uri": ["vhd+file://" + vol_path],
"keys": {},
}
示例12: mount_local
def mount_local(dbg, dev_path):
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/bin/mount", "-t", "gfs2", "-o",
"noatime,nodiratime,lockproto=lock_nolock", dev_path, mnt_path]
call(dbg, cmd)
return mnt_path
示例13: create
def create(dbg):
output = call(dbg, ["tap-ctl", "spawn"]).strip()
pid = int(output)
output = call(dbg, ["tap-ctl", "allocate"]).strip()
prefix = blktap2_prefix
minor = None
if output.startswith(prefix):
minor = int(output[len(prefix):])
if minor is None:
os.kill(pid, signal.SIGQUIT)
raise xapi.InternalError("tap-ctl allocate returned unexpected " +
"output: %s" % (output))
call(dbg, ["tap-ctl", "attach", "-m", str(minor), "-p", str(pid)])
return Tapdisk(minor, pid, None)
示例14: waitForDevice
def waitForDevice(dbg, keys):
# Wait for new device(s) to appear
cmd = ["/usr/sbin/udevadm", "settle"]
call(dbg, cmd)
# FIXME: For some reason, udevadm settle isn't sufficient
# to ensure the device is present. Why not?
for i in range(1,10):
time.sleep(1)
if keys['scsiid'] != None:
try:
os.stat(DEV_PATH_ROOT + keys['scsiid'])
return
except:
log.debug("%s: Waiting for device to appear" % dbg)
示例15: create
def create(dbg, sr, name, description, size, cb):
# Calculate virtual size (round up size to nearest MiB)
size = int(size)
size_mib = size / 1048576
if size % 1048576 != 0:
size_mib = size_mib + 1
vsize = size_mib * 1048576
opq = cb.volumeStartOperations(sr, 'w')
meta_path = cb.volumeMetadataGetPath(opq)
vol_uuid = str(uuid.uuid4())
conn = connectSQLite3(meta_path)
with write_context(conn):
res = conn.execute("insert into VDI(snap, name, description, uuid, vsize) values (?, ?, ?, ?, ?)",
(0, name, description, vol_uuid, str(vsize)))
vol_name = str(res.lastrowid)
vol_path = cb.volumeCreate(opq, vol_name, size)
cb.volumeActivateLocal(opq, vol_name)
# Create the VHD
cmd = ["/usr/bin/vhd-util", "create", "-n", vol_path,
"-s", str(size_mib)]
call(dbg, cmd)
cb.volumeDeactivateLocal(opq, vol_name)
# Fetch physical utilisation
psize = cb.volumeGetPhysSize(opq, vol_name)
vol_uri = cb.getVolumeURI(opq, vol_name)
cb.volumeStopOperations(opq)
conn.close()
return {
"key": vol_name,
"uuid": vol_uuid,
"name": name,
"description": description,
"read_write": True,
"virtual_size": vsize,
"physical_utilisation": psize,
"uri": [DP_URI_PREFIX + vol_uri],
"keys": {},
}