Revision 3ecf6786 lib/backend.py
b/lib/backend.py | ||
---|---|---|
346 | 346 |
|
347 | 347 |
iinfo = hypervisor.GetHypervisor().GetAllInstancesInfo() |
348 | 348 |
if iinfo: |
349 |
for name, id, memory, vcpus, state, times in iinfo: |
|
349 |
for name, inst_id, memory, vcpus, state, times in iinfo:
|
|
350 | 350 |
output[name] = { |
351 | 351 |
'memory': memory, |
352 | 352 |
'vcpus': vcpus, |
... | ... | |
729 | 729 |
for dsk in disks: |
730 | 730 |
rbd = _RecursiveFindBD(dsk) |
731 | 731 |
if rbd is None: |
732 |
raise errors.BlockDeviceError, "Can't find device %s" % str(dsk)
|
|
732 |
raise errors.BlockDeviceError("Can't find device %s" % str(dsk))
|
|
733 | 733 |
stats.append(rbd.CombinedSyncStatus()) |
734 | 734 |
return stats |
735 | 735 |
|
... | ... | |
847 | 847 |
try: |
848 | 848 |
st = os.stat(api_file) |
849 | 849 |
except EnvironmentError, err: |
850 |
raise errors.InvalidOS, (name, "'ganeti_api_version' file not"
|
|
851 |
" found (%s)" % _ErrnoOrStr(err))
|
|
850 |
raise errors.InvalidOS(name, "'ganeti_api_version' file not" |
|
851 |
" found (%s)" % _ErrnoOrStr(err)) |
|
852 | 852 |
|
853 | 853 |
if not stat.S_ISREG(stat.S_IFMT(st.st_mode)): |
854 |
raise errors.InvalidOS, (name, "'ganeti_api_version' file is not"
|
|
855 |
" a regular file")
|
|
854 |
raise errors.InvalidOS(name, "'ganeti_api_version' file is not" |
|
855 |
" a regular file") |
|
856 | 856 |
|
857 | 857 |
try: |
858 | 858 |
f = open(api_file) |
... | ... | |
861 | 861 |
finally: |
862 | 862 |
f.close() |
863 | 863 |
except EnvironmentError, err: |
864 |
raise errors.InvalidOS, (name, "error while reading the"
|
|
865 |
" API version (%s)" % _ErrnoOrStr(err))
|
|
864 |
raise errors.InvalidOS(name, "error while reading the" |
|
865 |
" API version (%s)" % _ErrnoOrStr(err)) |
|
866 | 866 |
|
867 | 867 |
api_version = api_version.strip() |
868 | 868 |
try: |
869 | 869 |
api_version = int(api_version) |
870 | 870 |
except (TypeError, ValueError), err: |
871 |
raise errors.InvalidOS, (name, "API version is not integer (%s)" % |
|
872 |
str(err)) |
|
871 |
raise errors.InvalidOS(name, "API version is not integer (%s)" % str(err)) |
|
873 | 872 |
|
874 | 873 |
return api_version |
875 | 874 |
|
... | ... | |
920 | 919 |
api_version = _OSOndiskVersion(name, os_dir) |
921 | 920 |
|
922 | 921 |
if api_version != constants.OS_API_VERSION: |
923 |
raise errors.InvalidOS, (name, "API version mismatch (found %s want %s)"
|
|
924 |
% (api_version, constants.OS_API_VERSION))
|
|
922 |
raise errors.InvalidOS(name, "API version mismatch (found %s want %s)" |
|
923 |
% (api_version, constants.OS_API_VERSION)) |
|
925 | 924 |
|
926 | 925 |
# OS Scripts dictionary, we will populate it with the actual script names |
927 | 926 |
os_scripts = {'create': '', 'export': '', 'import': ''} |
... | ... | |
932 | 931 |
try: |
933 | 932 |
st = os.stat(os_scripts[script]) |
934 | 933 |
except EnvironmentError, err: |
935 |
raise errors.InvalidOS, (name, "'%s' script missing (%s)" %
|
|
936 |
(script, _ErrnoOrStr(err)))
|
|
934 |
raise errors.InvalidOS(name, "'%s' script missing (%s)" % |
|
935 |
(script, _ErrnoOrStr(err))) |
|
937 | 936 |
|
938 | 937 |
if stat.S_IMODE(st.st_mode) & stat.S_IXUSR != stat.S_IXUSR: |
939 |
raise errors.InvalidOS, (name, "'%s' script not executable" % script)
|
|
938 |
raise errors.InvalidOS(name, "'%s' script not executable" % script) |
|
940 | 939 |
|
941 | 940 |
if not stat.S_ISREG(stat.S_IFMT(st.st_mode)): |
942 |
raise errors.InvalidOS, (name, "'%s' is not a regular file" % script)
|
|
941 |
raise errors.InvalidOS(name, "'%s' is not a regular file" % script) |
|
943 | 942 |
|
944 | 943 |
|
945 | 944 |
return objects.OS(name=name, path=os_dir, |
... | ... | |
980 | 979 |
else: |
981 | 980 |
return None |
982 | 981 |
else: |
983 |
raise errors.ProgrammerError, ("Cannot snapshot non-lvm block device"
|
|
984 |
"'%s' of type '%s'" %
|
|
985 |
(disk.unique_id, disk.dev_type))
|
|
982 |
raise errors.ProgrammerError("Cannot snapshot non-lvm block device" |
|
983 |
"'%s' of type '%s'" % |
|
984 |
(disk.unique_id, disk.dev_type)) |
|
986 | 985 |
|
987 | 986 |
|
988 | 987 |
def ExportSnapshot(disk, dest_node, instance): |
... | ... | |
1155 | 1154 |
|
1156 | 1155 |
real_os_dev = _RecursiveFindBD(os_device) |
1157 | 1156 |
if real_os_dev is None: |
1158 |
raise errors.BlockDeviceError, ("Block device '%s' is not set up" %
|
|
1159 |
str(os_device))
|
|
1157 |
raise errors.BlockDeviceError("Block device '%s' is not set up" % |
|
1158 |
str(os_device)) |
|
1160 | 1159 |
real_os_dev.Open() |
1161 | 1160 |
|
1162 | 1161 |
real_swap_dev = _RecursiveFindBD(swap_device) |
1163 | 1162 |
if real_swap_dev is None: |
1164 |
raise errors.BlockDeviceError, ("Block device '%s' is not set up" %
|
|
1165 |
str(swap_device))
|
|
1163 |
raise errors.BlockDeviceError("Block device '%s' is not set up" % |
|
1164 |
str(swap_device)) |
|
1166 | 1165 |
real_swap_dev.Open() |
1167 | 1166 |
|
1168 | 1167 |
logfile = "%s/import-%s-%s-%s.log" % (constants.LOG_OS_DIR, instance.os, |
... | ... | |
1302 | 1301 |
elif phase == constants.HOOKS_PHASE_POST: |
1303 | 1302 |
suffix = "post" |
1304 | 1303 |
else: |
1305 |
raise errors.ProgrammerError, ("Unknown hooks phase: '%s'" % phase)
|
|
1304 |
raise errors.ProgrammerError("Unknown hooks phase: '%s'" % phase) |
|
1306 | 1305 |
rr = [] |
1307 | 1306 |
|
1308 | 1307 |
subdir = "%s-%s.d" % (hpath, suffix) |
Also available in: Unified diff