当前位置: 首页>>代码示例>>Python>>正文


Python Account.umount_ssh_dir方法代码示例

本文整理汇总了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)
开发者ID:nfvproject,项目名称:NodeManager,代码行数:47,代码来源:sliver_lxc.py

示例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()
开发者ID:dreibh,项目名称:planetlab-lxc-nodemanager,代码行数:86,代码来源:sliver_lxc.py


注:本文中的account.Account.umount_ssh_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。