Revision 155d6c75
b/lib/cmdlib.py | ||
---|---|---|
1958 | 1958 |
|
1959 | 1959 |
""" |
1960 | 1960 |
instance = self.instance |
1961 |
ins_l = rpc.call_instance_list([instance.primary_node]) |
|
1962 |
ins_l = ins_l[instance.primary_node] |
|
1963 |
if not type(ins_l) is list: |
|
1964 |
raise errors.OpExecError("Can't contact node '%s'" % |
|
1965 |
instance.primary_node) |
|
1961 |
_SafeShutdownInstanceDisks(instance, self.cfg) |
|
1966 | 1962 |
|
1967 |
if self.instance.name in ins_l: |
|
1968 |
raise errors.OpExecError("Instance is running, can't shutdown" |
|
1969 |
" block devices.") |
|
1970 | 1963 |
|
1971 |
_ShutdownInstanceDisks(instance, self.cfg) |
|
1964 |
def _SafeShutdownInstanceDisks(instance, cfg): |
|
1965 |
"""Shutdown block devices of an instance. |
|
1966 |
|
|
1967 |
This function checks if an instance is running, before calling |
|
1968 |
_ShutdownInstanceDisks. |
|
1969 |
|
|
1970 |
""" |
|
1971 |
ins_l = rpc.call_instance_list([instance.primary_node]) |
|
1972 |
ins_l = ins_l[instance.primary_node] |
|
1973 |
if not type(ins_l) is list: |
|
1974 |
raise errors.OpExecError("Can't contact node '%s'" % |
|
1975 |
instance.primary_node) |
|
1976 |
|
|
1977 |
if instance.name in ins_l: |
|
1978 |
raise errors.OpExecError("Instance is running, can't shutdown" |
|
1979 |
" block devices.") |
|
1980 |
|
|
1981 |
_ShutdownInstanceDisks(instance, cfg) |
|
1972 | 1982 |
|
1973 | 1983 |
|
1974 | 1984 |
def _ShutdownInstanceDisks(instance, cfg, ignore_primary=False): |
Also available in: Unified diff