Domain#state_reason added. "#{state} beacause #{reason}." possible

This commit is contained in:
Denis Knauf 2013-03-18 15:37:19 +01:00
parent 99a5d5de4d
commit 51b911c7f7

View file

@ -76,10 +76,10 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Error 'Misc I/O Error' Error 'misc I/O Error'
EOF 'End-of-file from server' EOF 'end-of-file from server'
KeepAlive 'Keepalive timer triggered' KeepAlive 'keepalive timer triggered'
Client 'Client requested it' Client 'client requested it'
Last '--' Last '--'
end end
end end
@ -88,7 +88,7 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unkown 'the reason is unknown' Unkown 'unknown reason'
Last '--' Last '--'
end end
end end
@ -97,7 +97,7 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unkown 'the reason is unknown' Unkown 'unknown reason'
Last '--' Last '--'
end end
end end
@ -106,7 +106,7 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unkown 'the reason is unknown' Unkown 'unknown reason'
Last '--' Last '--'
end end
end end
@ -115,7 +115,7 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unkown 'the reason is unknown' Unkown 'unknown reason'
Last '--' Last '--'
end end
end end
@ -124,7 +124,7 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unkown 'the reason is unknown' Unkown 'unknown reason'
Last '--' Last '--'
end end
end end
@ -133,7 +133,7 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unkown 'the reason is unknown' Unkown 'unknown reason'
User 'paused on user request' User 'paused on user request'
Migration 'paused for offline migration' Migration 'paused for offline migration'
Save 'paused for save' Save 'paused for save'
@ -151,7 +151,7 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unknown 'the reason is unknown' Unknown 'unknown reason'
Booted 'normal startup from boot' Booted 'normal startup from boot'
Migrated 'migrated from another host' Migrated 'migrated from another host'
Restored 'restored from a state file' Restored 'restored from a state file'
@ -168,7 +168,7 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unkown 'the reason is unknown' Unkown 'unknown reason'
User 'shutting down on user request' User 'shutting down on user request'
Last '--' Last '--'
end end
@ -178,30 +178,30 @@ module Libvirt
enum_fields :comment enum_fields :comment
start_at 0 start_at 0
enum do enum do
Unkown 'the reason is unknown' Unkown 'unknown reason'
Shutdown 'normal shutdown' Shutdown 'normal shutdown'
Destroyed 'forced poweroff' Destroyed 'forced poweroff'
Crashed 'domain crashed' Crashed 'domain crashed'
Migrated 'migrated to another host' Migrated 'migrated to another host'
Saved 'saved to a file' Saved 'saved to a file'
Failed 'domain failed to start' Failed 'domain failed to start'
FromSnapshot 'restoed from a snapshot which was taken while domain was shutoff' FromSnapshot 'restored from a snapshot which was taken while domain was shutoff'
Last '--' Last '--'
end end
end end
class State < Enum class State < Enum
enum_fields :commend, :reasons enum_fields :comment, :reasons
start_at 0 start_at 0
enum do enum do
Nostate 'no state', NostateReason Nostate 'No state', NostateReason
Running 'the domain is running', RunningReason Running 'The domain is running', RunningReason
Blocked 'the domain is blocked on resource', BlockedReason Blocked 'The domain is blocked on resource', BlockedReason
Paused 'the domain is paused by user', PausedReason Paused 'The domain is paused by user', PausedReason
Shutdown 'the domain is being shut down', ShutdownReason Shutdown 'The domain is being shut down', ShutdownReason
Shutoff 'the domain is shut off', ShutoffReason Shutoff 'The domain is shut off', ShutoffReason
Crashed 'the domain is crashed', CrashedReason Crashed 'The domain is crashed', CrashedReason
PMSuspended 'the domain is suspended by guest power management', PMSuspendedReason PMSuspended 'The domain is suspended by guest power management', PMSuspendedReason
Last '--' Last '--'
end end
@ -215,8 +215,12 @@ module Libvirt
end end
end end
def state_reason
State[self.state]
end
def inspect def inspect
state, reason = State[self.state] state, reason = state_reason
"#<#{self.class.name}: #{uuid} #{name} #{state.title}[#{reason.title}]>" "#<#{self.class.name}: #{uuid} #{name} #{state.title}[#{reason.title}]>"
end end
end end