volume.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:bay 作者: eventbrite 项目源码 文件源码
def destroy(app, host, name):
    """
    Destroys a single volume
    """
    task = Task("Destroying volume {}".format(name))
    # Run GC first to clean up stopped containers
    from .gc import GarbageCollector
    GarbageCollector(host).gc_all(task)
    # Remove the volume
    formation = FormationIntrospector(host, app.containers).introspect()
    instance_conflicts = [instance.container.name for instance in formation.get_instances_using_volume(name)]
    if instance_conflicts:
        task.finish(status="Volume {} is in use by container(s): {}".format(
            name, ",".join(instance_conflicts)), status_flavor=Task.FLAVOR_BAD)
    else:
        try:
            host.client.remove_volume(name)
        except NotFound:
            task.add_extra_info("There is no volume called {}".format(name))
            task.finish(status="Not found", status_flavor=Task.FLAVOR_BAD)
        else:
            task.finish(status="Done", status_flavor=Task.FLAVOR_GOOD)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号