本文整理汇总了Python中account.Account.umount_ssh_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Account.umount_ssh_dir方法的具体用法?Python Account.umount_ssh_dir怎么用?Python Account.umount_ssh_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.Account
的用法示例。
在下文中一共展示了Account.umount_ssh_dir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: destroy
# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import umount_ssh_dir [as 别名]
def destroy(name):
# umount .ssh directory - only if mounted
Account.umount_ssh_dir(name)
logger.verbose ('sliver_lxc: %s destroy'%(name))
conn = Sliver_Libvirt.getConnection(Sliver_LXC.TYPE)
containerDir = Sliver_LXC.CON_BASE_DIR + '/%s'%(name)
try:
# Destroy libvirt domain
dom = conn.lookupByName(name)
except:
logger.verbose('sliver_lxc: Domain %s does not exist!' % name)
try:
dom.destroy()
except:
logger.verbose('sliver_lxc: Domain %s not running... continuing.' % name)
try:
dom.undefine()
except:
logger.verbose('sliver_lxc: Domain %s is not defined... continuing.' % name)
# Remove user after destroy domain to force logout
command = ['/usr/sbin/userdel', '-f', '-r', name]
logger.log_call(command, timeout=15*60)
if os.path.exists(os.path.join(containerDir,"vsys")):
# Slivers with vsys running will fail the subvolume delete.
# A more permanent solution may be to ensure that the vsys module
# is called before the sliver is destroyed.
logger.log("destroying vsys directory and restarting vsys")
logger.log_call(["rm", "-fR", os.path.join(containerDir, "vsys")])
logger.log_call(["/etc/init.d/vsys", "restart", ])
# Remove rootfs of destroyed domain
command = ['btrfs', 'subvolume', 'delete', containerDir]
logger.log_call(command, timeout=60)
if os.path.exists(containerDir):
# oh no, it's still here...
logger.log("WARNING: failed to destroy container %s" % containerDir)
logger.verbose('sliver_libvirt: %s destroyed.'%name)
示例2: destroy
# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import umount_ssh_dir [as 别名]
def destroy(name):
# umount .ssh directory - only if mounted
Account.umount_ssh_dir(name)
logger.verbose ('sliver_lxc: {} destroy'.format(name))
conn = Sliver_Libvirt.getConnection(Sliver_LXC.TYPE)
containerDir = os.path.join(Sliver_LXC.CON_BASE_DIR, name)
try:
# Destroy libvirt domain
dom = conn.lookupByName(name)
except:
logger.verbose('sliver_lxc.destroy: Domain {} does not exist!'.format(name))
return
# Slivers with vsys running will fail the subvolume delete
# removeSliverFromVsys return True if it stops vsys, telling us to start it again later
vsys_stopped = removeSliverFromVsys (name)
try:
logger.log("sliver_lxc.destroy: destroying domain {}".format(name))
dom.destroy()
except:
logger.verbose("sliver_lxc.destroy: Domain {} not running... continuing.".format(name))
try:
logger.log("sliver_lxc.destroy: undefining domain {}".format(name))
dom.undefine()
except:
logger.verbose('sliver_lxc.destroy: Domain {} is not defined... continuing.'.format(name))
# Remove user after destroy domain to force logout
command = ['/usr/sbin/userdel', '-f', '-r', name]
logger.log_call(command)
# Remove rootfs of destroyed domain
command = ['/usr/bin/rm', '-rf', containerDir]
logger.log_call(command, timeout=BTRFS_TIMEOUT)
# ???
logger.log("-TMP-ls-l {}".format(name))
command = ['ls', '-lR', containerDir]
logger.log_call(command)
logger.log("-TMP-vsys-status")
command = ['/usr/bin/systemctl', 'status', 'vsys']
logger.log_call(command)
# ???
# Remove rootfs of destroyed domain
command = ['btrfs', 'subvolume', 'delete', containerDir]
logger.log_call(command, timeout=BTRFS_TIMEOUT)
# For some reason I am seeing this :
#log_call: running command btrfs subvolume delete /vservers/inri_sl1
#log_call: ERROR: cannot delete '/vservers/inri_sl1' - Device or resource busy
#log_call: Delete subvolume '/vservers/inri_sl1'
#log_call:end command (btrfs subvolume delete /vservers/inri_sl1) returned with code 1
#
# something must have an open handle to a file in there, but I can't find out what it is
# the following code aims at gathering data on what is going on in the system at this point in time
# note that some time later (typically when the sliver gets re-created) the same
# attempt at deleting the subvolume does work
# also lsof never shows anything relevant; this is painful..
if not os.path.exists(containerDir):
logger.log('sliver_lxc.destroy: {} cleanly destroyed.'.format(name))
else:
# we're in /
#logger.log("-TMP-cwd {} : {}".format(name, os.getcwd()))
# also lsof never shows anything relevant; this is painful..
#logger.log("-TMP-lsof {}".format(name))
#command = ['lsof']
#logger.log_call(command)
logger.log("-TMP-ls-l {}".format(name))
command = ['ls', '-lR', containerDir]
logger.log_call(command)
logger.log("-TMP-lsof")
command = ['lsof']
logger.log_call(command)
if os.path.exists(containerDir):
logger.log('sliver_lxc.destroy: ERROR could not cleanly destroy {} - giving up'.format(name))
if vsys_stopped:
vsysStartService()