Revision 305a7297
b/lib/backend.py | ||
---|---|---|
887 | 887 |
Args: |
888 | 888 |
name: The name of the OS to look for |
889 | 889 |
search_path: List of dirs to search (defaults to constants.OS_SEARCH_PATH) |
890 |
|
|
890 |
|
|
891 | 891 |
Returns: |
892 | 892 |
The base_dir the OS resides in |
893 | 893 |
|
... | ... | |
919 | 919 |
try: |
920 | 920 |
st = os.stat(api_file) |
921 | 921 |
except EnvironmentError, err: |
922 |
raise errors.InvalidOS(name, "'ganeti_api_version' file not" |
|
922 |
raise errors.InvalidOS(name, os_dir, "'ganeti_api_version' file not"
|
|
923 | 923 |
" found (%s)" % _ErrnoOrStr(err)) |
924 | 924 |
|
925 | 925 |
if not stat.S_ISREG(stat.S_IFMT(st.st_mode)): |
926 |
raise errors.InvalidOS(name, "'ganeti_api_version' file is not" |
|
926 |
raise errors.InvalidOS(name, os_dir, "'ganeti_api_version' file is not"
|
|
927 | 927 |
" a regular file") |
928 | 928 |
|
929 | 929 |
try: |
... | ... | |
933 | 933 |
finally: |
934 | 934 |
f.close() |
935 | 935 |
except EnvironmentError, err: |
936 |
raise errors.InvalidOS(name, "error while reading the" |
|
936 |
raise errors.InvalidOS(name, os_dir, "error while reading the"
|
|
937 | 937 |
" API version (%s)" % _ErrnoOrStr(err)) |
938 | 938 |
|
939 | 939 |
api_version = api_version.strip() |
940 | 940 |
try: |
941 | 941 |
api_version = int(api_version) |
942 | 942 |
except (TypeError, ValueError), err: |
943 |
raise errors.InvalidOS(name, "API version is not integer (%s)" % str(err)) |
|
943 |
raise errors.InvalidOS(name, os_dir, |
|
944 |
"API version is not integer (%s)" % str(err)) |
|
944 | 945 |
|
945 | 946 |
return api_version |
946 | 947 |
|
... | ... | |
1000 | 1001 |
raise errors.InvalidOS(name, "OS not found in base dir %s" % base_dir) |
1001 | 1002 |
|
1002 | 1003 |
if base_dir is None: |
1003 |
raise errors.InvalidOS(name, "OS dir not found in search path") |
|
1004 |
raise errors.InvalidOS(name, None, "OS dir not found in search path")
|
|
1004 | 1005 |
|
1005 | 1006 |
os_dir = os.path.sep.join([base_dir, name]) |
1006 | 1007 |
api_version = _OSOndiskVersion(name, os_dir) |
1007 | 1008 |
|
1008 | 1009 |
if api_version != constants.OS_API_VERSION: |
1009 |
raise errors.InvalidOS(name, "API version mismatch (found %s want %s)" |
|
1010 |
raise errors.InvalidOS(name, os_dir, "API version mismatch" |
|
1011 |
" (found %s want %s)" |
|
1010 | 1012 |
% (api_version, constants.OS_API_VERSION)) |
1011 | 1013 |
|
1012 | 1014 |
# OS Scripts dictionary, we will populate it with the actual script names |
... | ... | |
1018 | 1020 |
try: |
1019 | 1021 |
st = os.stat(os_scripts[script]) |
1020 | 1022 |
except EnvironmentError, err: |
1021 |
raise errors.InvalidOS(name, "'%s' script missing (%s)" % |
|
1023 |
raise errors.InvalidOS(name, os_dir, "'%s' script missing (%s)" %
|
|
1022 | 1024 |
(script, _ErrnoOrStr(err))) |
1023 | 1025 |
|
1024 | 1026 |
if stat.S_IMODE(st.st_mode) & stat.S_IXUSR != stat.S_IXUSR: |
1025 |
raise errors.InvalidOS(name, "'%s' script not executable" % script) |
|
1027 |
raise errors.InvalidOS(name, os_dir, "'%s' script not executable" % |
|
1028 |
script) |
|
1026 | 1029 |
|
1027 | 1030 |
if not stat.S_ISREG(stat.S_IFMT(st.st_mode)): |
1028 |
raise errors.InvalidOS(name, "'%s' is not a regular file" % script) |
|
1031 |
raise errors.InvalidOS(name, os_dir, "'%s' is not a regular file" % |
|
1032 |
script) |
|
1029 | 1033 |
|
1030 | 1034 |
|
1031 | 1035 |
return objects.OS(name=name, path=os_dir, |
b/lib/constants.py | ||
---|---|---|
25 | 25 |
|
26 | 26 |
# various versions |
27 | 27 |
CONFIG_VERSION = 3 |
28 |
PROTOCOL_VERSION = 2
|
|
28 |
PROTOCOL_VERSION = 3
|
|
29 | 29 |
RELEASE_VERSION = _autoconf.PACKAGE_VERSION |
30 | 30 |
OS_API_VERSION = 5 |
31 | 31 |
EXPORT_VERSION = 0 |
b/lib/errors.py | ||
---|---|---|
104 | 104 |
This is raised when an OS exists on the master (or is otherwise |
105 | 105 |
requested to the code) but not on the target node. |
106 | 106 |
|
107 |
This exception has two arguments:
|
|
107 |
This exception has three arguments:
|
|
108 | 108 |
- the name of the os |
109 |
- the source directory, if any |
|
109 | 110 |
- the reason why we consider this an invalid OS (text of error message) |
110 | 111 |
|
111 | 112 |
""" |
b/lib/rpc.py | ||
---|---|---|
607 | 607 |
if data: |
608 | 608 |
if isinstance(data, dict): |
609 | 609 |
nr.append(objects.OS.FromDict(data)) |
610 |
elif isinstance(data, tuple) and len(data) == 2:
|
|
611 |
nr.append(errors.InvalidOS(data[0], data[1])) |
|
610 |
elif isinstance(data, tuple) and len(data) == 3:
|
|
611 |
nr.append(errors.InvalidOS(data[0], data[1], data[2]))
|
|
612 | 612 |
else: |
613 | 613 |
raise errors.ProgrammerError("Invalid data from" |
614 | 614 |
" xcserver.os_diagnose") |
... | ... | |
631 | 631 |
data = result[node_name] |
632 | 632 |
if isinstance(data, dict): |
633 | 633 |
new_result[node_name] = objects.OS.FromDict(data) |
634 |
elif isinstance(data, tuple) and len(data) == 2:
|
|
635 |
new_result[node_name] = errors.InvalidOS(data[0], data[1]) |
|
634 |
elif isinstance(data, tuple) and len(data) == 3:
|
|
635 |
new_result[node_name] = errors.InvalidOS(data[0], data[1], data[2])
|
|
636 | 636 |
else: |
637 | 637 |
new_result[node_name] = data |
638 | 638 |
return new_result |
b/scripts/gnt-os | ||
---|---|---|
114 | 114 |
if isinstance(nos[0], objects.OS): |
115 | 115 |
nodes_valid.append(node_name) |
116 | 116 |
elif isinstance(nos[0], errors.InvalidOS): |
117 |
nodes_bad[node_name] = nos[0].args[1] |
|
117 |
nodes_bad[node_name] = ("%s (path: %s)" % |
|
118 |
(nos[0].args[2], nos[0].args[1])) |
|
118 | 119 |
else: |
119 | 120 |
nodes_bad[node_name] = "os dir not found" |
120 | 121 |
|
... | ... | |
128 | 129 |
logger.ToStdout(format % (max_name, os_name, max_node, status, "")) |
129 | 130 |
nodes_valid = utils.NiceSort(nodes_valid) |
130 | 131 |
for node_name in nodes_valid: |
131 |
logger.ToStdout(format % (max_name, "", max_node, node_name,
|
|
132 |
"valid (%s)" % all_os[os_name][node_name][0].path)) |
|
132 |
logger.ToStdout(format % (max_name, "", max_node, node_name, |
|
133 |
"valid (path: %s)" % all_os[os_name][node_name][0].path))
|
|
133 | 134 |
nbk = utils.NiceSort(nodes_bad.keys()) |
134 | 135 |
for node_name in nbk: |
135 | 136 |
logger.ToStdout(format % (max_name, "", max_node, |
Also available in: Unified diff