【OpenStack】源码级深入了解删除虚拟机操作

本文详细解析了虚拟机的多种状态及其在删除过程中的不同操作方式,包括ACTIVE、BUILDING、PAUSED等关键状态,并说明了在删除虚拟机时会根据其状态采取不同的处理策略,如完全释放资源或保留部分资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先看一下虚拟机有多少种状态:(/nova/compute/vmstates.py)

 1 ACTIVE = 'active'  # VM is running
 2 BUILDING = 'building'  # VM only exists in DB
 3 PAUSED = 'paused'
 4 SUSPENDED = 'suspended'  # VM is suspended to disk.
 5 STOPPED = 'stopped'  # VM is powered off, the disk image is still there.
 6 RESCUED = 'rescued'  # A rescue image is running with the original VM image
 7 # attached.
 8 RESIZED = 'resized'  # a VM with the new size is active. The user is expected
 9 # to manually confirm or revert.
10 
11 SOFT_DELETED = 'soft-delete'  # VM is marked as deleted but the disk images are
12 # still available to restore.
13 DELETED = 'deleted'  # VM is permanently deleted.
14 
15 ERROR = 'error'
16 
17 SHELVED = 'shelved'  # VM is powered off, resources still on hypervisor
18 SHELVED_OFFLOADED = 'shelved_offloaded'  # VM and associated resources are
19 # not on hypervisor
20 
21 ALLOW_SOFT_REBOOT = [ACTIVE]  # states we can soft reboot from
22 ALLOW_HARD_REBOOT = ALLOW_SOFT_REBOOT + [STOPPED, PAUSED, SUSPENDED, ERROR]
23 # states we allow hard reboot from
24 
25 ALLOW_TRIGGER_CRASH_DUMP = [ACTIVE, PAUSED, RESCUED, RESIZED, ERROR]
26 # states we allow to trigger crash dump
27 
28 ALLOW_RESOURCE_REMOVAL = [DELETED, SHELVED_OFFLOADED]
29 # states we allow resources to be freed in

 

在删除虚拟机时,会根据虚拟机状态来进行不同的操作。可以看出deleted和shelved_offloaded两种状态下虚拟机资源完全释放,而shelved

转载于:https://www.cnblogs.com/puyangsky/p/5527441.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值