1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from virtualization.constants import StateType
17
18
19
20
21
23 """
24 This class represents the state of a virtual instance. It provides
25 abstraction to categorize the state into running, stopped, paused, or
26 crashed.
27 """
28
30 """
31 Create a new state. If state_type is None, this state is assumed to be
32 stopped. If state_type is not None, it must be a StateType type.
33 """
34 self.__state_type = state_type
35
37 """
38 Returns the state type used to create this instance.
39 """
40 return self.__state_type
41
50
52 """
53 Returns true if this object represents a paused instance.
54 """
55 return self.__state_type == StateType.PAUSED
56
58 """
59 Returns true if this object represents a stopped instance.
60 """
61 return self.__state_type == None or \
62 self.__state_type == StateType.SHUTOFF
63
65 """
66 Returns true if this object represents a crashed instance.
67 """
68 return self.__state_type == StateType.CRASHED
69