本文整理汇总了Python中system.osi.is_mounted函数的典型用法代码示例。如果您正苦于以下问题:Python is_mounted函数的具体用法?Python is_mounted怎么用?Python is_mounted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_mounted函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: umount_root
def umount_root(root_pool_mnt):
if is_mounted(root_pool_mnt):
run_command([UMOUNT, "-l", root_pool_mnt])
for i in range(10):
if not is_mounted(root_pool_mnt):
return run_command([RMDIR, root_pool_mnt])
time.sleep(1)
run_command([UMOUNT, "-f", root_pool_mnt])
if os.path.exists(root_pool_mnt):
return run_command([RMDIR, root_pool_mnt])
return True
示例2: umount_root
def umount_root(root_pool_mnt):
if (is_mounted(root_pool_mnt)):
run_command([UMOUNT, '-l', root_pool_mnt])
for i in range(10):
if (not is_mounted(root_pool_mnt)):
return run_command([RMDIR, root_pool_mnt])
time.sleep(1)
run_command([UMOUNT, '-f', root_pool_mnt])
if (os.path.exists(root_pool_mnt)):
return run_command([RMDIR, root_pool_mnt])
return True
示例3: mount_source
def mount_source(source_ip, source_share):
mnt_pt = ('/mnt/backup/%s_%s' % (source_ip, source_share))
if (is_mounted(mnt_pt)):
return True
if (not os.path.isdir(mnt_pt)):
os.makedirs(mnt_pt)
cmd = [MOUNT, '%s:%s' % (source_ip, source_share), mnt_pt]
return run_command(cmd)
示例4: mount_share
def mount_share(share, mnt_pt):
if (is_mounted(mnt_pt)):
return
mount_root(share.pool)
pool_device = ('/dev/%s' % share.pool.disk_set.first().name)
subvol_str = 'subvol=%s' % share.subvol_name
create_tmp_dir(mnt_pt)
mnt_cmd = [MOUNT, '-t', 'btrfs', '-o', subvol_str, pool_device, mnt_pt]
return run_command(mnt_cmd)
示例5: mount_share
def mount_share(share, mnt_pt):
if (is_mounted(mnt_pt)):
return
mount_root(share["pool"])
pool_device = ('/dev/%s' % share["pool"]["disks"][0]["name"])
subvol_str = 'subvol=%s' % share["subvol_name"]
create_tmp_dir(mnt_pt)
mnt_cmd = [MOUNT, '-t', 'btrfs', '-o', subvol_str, pool_device, mnt_pt]
return run_command(mnt_cmd)
示例6: mount_share
def mount_share(share, pool_device, mnt_pt):
if is_mounted(mnt_pt):
return
pool_device = "/dev/%s" % pool_device
mount_root(share.pool, pool_device)
subvol_str = "subvol=%s" % share.subvol_name
create_tmp_dir(mnt_pt)
mnt_cmd = [MOUNT, "-t", "btrfs", "-o", subvol_str, pool_device, mnt_pt]
return run_command(mnt_cmd)
示例7: remove_snap
def remove_snap(pool, pool_device, share_name, snap_name):
root_mnt = mount_root(pool, pool_device)
snap_path = "%s/.snapshots/%s/%s" % (root_mnt, share_name, snap_name)
if not os.path.exists(snap_path):
return remove_snap_old(pool, pool_device, share_name, snap_name)
if is_mounted(snap_path):
umount_root(snap_path)
if is_subvol(snap_path):
return run_command([BTRFS, "subvolume", "delete", snap_path])
return True
示例8: remove_snap
def remove_snap(pool, pool_device, share_name, snap_name):
root_mnt = mount_root(pool, pool_device)
snap_path = ('%s/.snapshots/%s/%s' %
(root_mnt, share_name, snap_name))
if (not os.path.exists(snap_path)):
return remove_snap_old(pool, pool_device, share_name, snap_name)
if (is_mounted(snap_path)):
umount_root(snap_path)
if (is_subvol(snap_path)):
return run_command([BTRFS, 'subvolume', 'delete', snap_path])
return True
示例9: mount_snap
def mount_snap(share, snap_name, snap_mnt=None):
pool_device = "/dev/%s" % share.pool.disk_set.first().name
share_path = "%s%s" % (DEFAULT_MNT_DIR, share.name)
rel_snap_path = ".snapshots/%s/%s" % (share.name, snap_name)
snap_path = "%s%s/%s" % (DEFAULT_MNT_DIR, share.pool.name, rel_snap_path)
if snap_mnt is None:
snap_mnt = "%s/.%s" % (share_path, snap_name)
if is_mounted(snap_mnt):
return
mount_share(share, share_path)
if is_subvol(snap_path):
create_tmp_dir(snap_mnt)
return run_command([MOUNT, "-o", "subvol=%s" % rel_snap_path, pool_device, snap_mnt])
示例10: mount_snap
def mount_snap(share, snap_name, snap_mnt=None):
pool_device = ('/dev/%s' % share.pool.disk_set.first().name)
share_path = ('%s%s' % (DEFAULT_MNT_DIR, share.name))
rel_snap_path = ('.snapshots/%s/%s' % (share.name, snap_name))
snap_path = ('%s%s/%s' %
(DEFAULT_MNT_DIR, share.pool.name, rel_snap_path))
if (snap_mnt is None):
snap_mnt = ('%s/.%s' % (share_path, snap_name))
if (is_mounted(snap_mnt)):
return
mount_share(share, share_path)
if (is_subvol(snap_path)):
create_tmp_dir(snap_mnt)
return run_command([MOUNT, '-o', 'subvol=%s' % rel_snap_path,
pool_device, snap_mnt])
示例11: remove_snap
def remove_snap(pool, share_name, snap_name):
root_mnt = mount_root(pool)
snap_path = "%s/.snapshots/%s/%s" % (root_mnt, share_name, snap_name)
if is_mounted(snap_path):
umount_root(snap_path)
if is_subvol(snap_path):
qgroup = "0/%s" % share_id(pool, snap_name)
run_command([BTRFS, "subvolume", "delete", snap_path], log=True)
return qgroup_destroy(qgroup, root_mnt)
else:
o, e, rc = run_command([BTRFS, "subvolume", "list", "-s", root_mnt])
for l in o:
# just give the first match.
if re.match("ID.*%s$" % snap_name, l) is not None:
snap = "%s/%s" % (root_mnt, l.split()[-1])
return run_command([BTRFS, "subvolume", "delete", snap], log=True)
示例12: remove_snap
def remove_snap(pool, share_name, snap_name):
root_mnt = mount_root(pool)
snap_path = ('%s/.snapshots/%s/%s' %
(root_mnt, share_name, snap_name))
if (is_mounted(snap_path)):
umount_root(snap_path)
if (is_subvol(snap_path)):
qgroup = ('0/%s' % share_id(pool, snap_name))
run_command([BTRFS, 'subvolume', 'delete', snap_path], log=True)
return qgroup_destroy(qgroup, root_mnt)
else:
o, e, rc = run_command([BTRFS, 'subvolume', 'list', '-s', root_mnt])
for l in o:
#just give the first match.
if (re.match('ID.*%s$' % snap_name, l) is not None):
snap = '%s/%s' % (root_mnt, l.split()[-1])
return run_command([BTRFS, 'subvolume', 'delete', snap], log=True)
示例13: remove_snap
def remove_snap(pool, pool_device, share_name, snap_name):
root_mnt = mount_root(pool, pool_device)
snap_path = ('%s/.snapshots/%s/%s' %
(root_mnt, share_name, snap_name))
if (is_mounted(snap_path)):
umount_root(snap_path)
if (is_subvol(snap_path)):
qgroup = ('0/%s' % share_id(pool, pool_device, snap_name))
run_command([BTRFS, 'subvolume', 'delete', snap_path], log=True)
return qgroup_destroy(qgroup, root_mnt)
else:
o, e, rc = run_command([BTRFS, 'subvolume', 'list', '-s', root_mnt])
snap = None
for l in o:
#just give the first match.
if (re.match('ID.*%s$' % snap_name, l) is not None):
snap = '%s/%s' % (root_mnt, l.split()[-1])
break
e_msg = ('This snapshot(%s) was created outside of Rockstor. If you '
'really want to delete it, you can do so manually with this '
'command: btrfs subvol delete %s' % (snap_name, snap))
raise Exception(e_msg)
示例14: umount_root
def umount_root(root_pool_mnt):
if (not os.path.exists(root_pool_mnt)):
return
try:
o, e, rc = run_command([UMOUNT, '-l', root_pool_mnt])
except CommandException as ce:
if (ce.rc == 32):
for l in ce.err:
l = l.strip()
if (re.search('not mounted$', l) is not None):
return
raise ce
for i in range(20):
if (not is_mounted(root_pool_mnt)):
toggle_path_rw(root_pool_mnt, rw=True)
run_command([RMDIR, root_pool_mnt])
return
time.sleep(2)
run_command([UMOUNT, '-f', root_pool_mnt])
toggle_path_rw(root_pool_mnt, rw=True)
run_command([RMDIR, root_pool_mnt])
return
示例15: set_property
def set_property(mnt_pt, name, val, mount=True):
if (mount is not True or is_mounted(mnt_pt)):
cmd = [BTRFS, 'property', 'set', mnt_pt, name, val]
return run_command(cmd)