mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
M #-: Fix VM state for az/ec2/one/packet drivers (#4582)
This commit is contained in:
parent
617d9395bc
commit
67aed63360
@ -80,6 +80,15 @@ class AzureDriver
|
||||
IMAGE_PUBLISHER IMAGE_OFFER IMAGE_SKU IMAGE_VERSION
|
||||
]
|
||||
|
||||
STATE_MAP = {
|
||||
'starting' => 'RUNNING',
|
||||
'running' => 'RUNNING',
|
||||
'stopping' => 'POWEROFF',
|
||||
'stopped' => 'POWEROFF',
|
||||
'deallocating' => 'POWEROFF',
|
||||
'deallocated' => 'POWEROFF'
|
||||
}
|
||||
|
||||
DEFAULTS = {
|
||||
:rgroup_name_format => 'one-%<NAME>s-%<ID>s',
|
||||
:cache_expire => 120
|
||||
@ -636,17 +645,8 @@ class AzureDriver
|
||||
@rgroup_name, i.name
|
||||
)
|
||||
az_state = az_inst_view.statuses[-1].code.split('/').last
|
||||
case az_state
|
||||
when 'running', 'starting'
|
||||
# return VM_STATE[:active]
|
||||
'RUNNING'
|
||||
when 'suspended', 'stopping'
|
||||
# return VM_STATE[:paused]
|
||||
'SHUTDOWN'
|
||||
else
|
||||
# return VM_STATE[:unknown]
|
||||
'UNKNOWN'
|
||||
end
|
||||
|
||||
STATE_MAP[az_state] || 'UNKNOWN'
|
||||
end
|
||||
|
||||
def get_cpu_num(instance)
|
||||
|
@ -243,6 +243,13 @@ class EC2Driver
|
||||
:cache_expire => 120
|
||||
}
|
||||
|
||||
STATE_MAP = {
|
||||
'pending' => 'RUNNING',
|
||||
'running' => 'RUNNING',
|
||||
'shutting-down' => 'POWEROFF',
|
||||
'terminated' => 'POWEROFF'
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# EC2 constructor, loads credentials and endpoint
|
||||
# @param [String] name of host in OpenNebula
|
||||
@ -607,16 +614,9 @@ class EC2Driver
|
||||
# Return state of the instance (ONE state)
|
||||
def vm_state(instance)
|
||||
if !instance.exists?
|
||||
'DELETED'
|
||||
'UNKNOWN'
|
||||
else
|
||||
case instance.state.name
|
||||
when 'pending', 'running'
|
||||
'RUNNING'
|
||||
when 'shutting-down', 'terminated'
|
||||
'SHUTDOWN'
|
||||
else
|
||||
'UNKNOWN'
|
||||
end
|
||||
STATE_MAP[instance.state.name] || 'UNKNOWN'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -224,16 +224,16 @@ class One2OneDriver
|
||||
when 'ACTIVE'
|
||||
case vm.lcm_state_str
|
||||
when /_FAILURE$/ || 'UNKNOWN'
|
||||
'FAILED'
|
||||
'FAILURE'
|
||||
else
|
||||
'RUNNING'
|
||||
end
|
||||
when 'STOPPED' || 'SUSPENDED'
|
||||
'STOPPED'
|
||||
'SUSPENDED'
|
||||
when 'DONE' || 'POWEROFF' || 'UNDEPLOYED'
|
||||
'DONE'
|
||||
'POWEROFF'
|
||||
when 'FAILED' || 'CLONING_FAILURE'
|
||||
'FAILED'
|
||||
'FAILURE'
|
||||
else
|
||||
'UNKNOWN'
|
||||
end
|
||||
|
@ -73,6 +73,17 @@ class PacketDriver
|
||||
:billing_cycle => 'BILLING_CYCLE'
|
||||
}
|
||||
|
||||
STATE_MAP = {
|
||||
:pending => 'RUNNING',
|
||||
:provisioning => 'RUNNING',
|
||||
:powering_on => 'RUNNING',
|
||||
:active => 'RUNNING',
|
||||
:rebooting => 'RUNNING',
|
||||
:powering_off => 'POWEROFF',
|
||||
:inactive => 'POWEROFF',
|
||||
:failed => 'FAILURE'
|
||||
}
|
||||
|
||||
DEFAULTS = {
|
||||
:cache_expire => 120
|
||||
}
|
||||
@ -316,20 +327,9 @@ class PacketDriver
|
||||
|
||||
def vm_state(device)
|
||||
if device.nil?
|
||||
'DELETED'
|
||||
'UNKNOWN'
|
||||
else
|
||||
case device.state
|
||||
when :pending, :provisioning, :powering_on
|
||||
'BOOT'
|
||||
when :active, :rebooting
|
||||
'RUNNING'
|
||||
when :powering_off, :inactive
|
||||
'SHUTDOWN'
|
||||
when :failed
|
||||
'SHUTDOWN'
|
||||
else
|
||||
'UNKNOWN'
|
||||
end
|
||||
STATE_MAP[device.state] || 'UNKNOWN'
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user