Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-ganeti
Commits
b07a9f05
Commit
b07a9f05
authored
17 years ago
by
Guido Trotter
Browse files
Options
Downloads
Patches
Plain Diff
Refactor DiagnoseOS
The new version debugs Hidden OSes as well. Reviewed-by: iustinp
parent
0c434948
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/gnt-os
+56
-16
56 additions, 16 deletions
scripts/gnt-os
with
56 additions
and
16 deletions
scripts/gnt-os
+
56
−
16
View file @
b07a9f05
...
@@ -66,6 +66,38 @@ def ListOS(opts, args):
...
@@ -66,6 +66,38 @@ def ListOS(opts, args):
return
0
return
0
def
_DiagnoseOSValid
(
obj
):
"""
Verify whether an OS diagnose object represents a valid OS
Args:
obj: an diagnostic object as returned by OpDiagnoseOS
Returns:
bool: OS validity status
"""
if
isinstance
(
obj
,
objects
.
OS
):
return
True
elif
isinstance
(
obj
,
errors
.
InvalidOS
):
return
False
else
:
raise
errors
.
ProgrammerError
(
'
unknown OS diagnose type
'
)
def
_DiagnoseOSStatus
(
obj
):
"""
Generate a status message for an OS diagnose object.
Args:
obj: an diagnostic object as returned by OpDiagnoseOS
Returns:
string: a description of the OS status
"""
if
_DiagnoseOSValid
(
obj
):
return
"
valid (path: %s)
"
%
obj
.
path
else
:
return
"
%s (path: %s)
"
%
(
obj
.
args
[
2
],
obj
.
args
[
1
])
def
DiagnoseOS
(
opts
,
args
):
def
DiagnoseOS
(
opts
,
args
):
"""
Analyse all OSes on this cluster.
"""
Analyse all OSes on this cluster.
...
@@ -106,18 +138,18 @@ def DiagnoseOS(opts, args):
...
@@ -106,18 +138,18 @@ def DiagnoseOS(opts, args):
'
Details
'
))
'
Details
'
))
for
os_name
in
all_os
:
for
os_name
in
all_os
:
nodes_valid
=
[]
nodes_valid
=
{}
nodes_bad
=
{}
nodes_bad
=
{}
for
node_name
in
node_data
:
for
node_name
in
node_data
:
if
node_name
in
all_os
[
os_name
]:
if
node_name
in
all_os
[
os_name
]:
n
os
=
all_os
[
os_name
][
node_name
]
first_
os
=
all_os
[
os_name
][
node_name
]
.
pop
(
0
)
if
isinstance
(
nos
[
0
],
objects
.
OS
):
first_os_status
=
_DiagnoseOSStatus
(
first_os
)
nodes_valid
.
append
(
node_name
)
if
_DiagnoseOSValid
(
first_os
):
elif
isinstance
(
nos
[
0
],
errors
.
InvalidOS
):
nodes_valid
[
node_name
]
=
first_os_status
nodes_bad
[
node_name
]
=
(
"
%s (path: %s)
"
%
else
:
(
nos
[
0
].
args
[
2
],
nos
[
0
].
args
[
1
]))
nodes_bad
[
node_name
]
=
first_os_status
else
:
else
:
nodes_bad
[
node_name
]
=
"
os dir
not found
"
nodes_bad
[
node_name
]
=
"
OS
not found
"
if
nodes_valid
and
not
nodes_bad
:
if
nodes_valid
and
not
nodes_bad
:
status
=
"
valid
"
status
=
"
valid
"
...
@@ -126,15 +158,23 @@ def DiagnoseOS(opts, args):
...
@@ -126,15 +158,23 @@ def DiagnoseOS(opts, args):
else
:
else
:
status
=
"
partial valid
"
status
=
"
partial valid
"
def
_OutputNodeHiddenOSStatus
(
dobj_list
):
for
dobj
in
dobj_list
:
logger
.
ToStdout
(
format
%
(
max_name
,
""
,
max_node
,
""
,
"
[hidden] %s
"
%
_DiagnoseOSStatus
(
dobj
)))
def
_OutputPerNodeOSStatus
(
status_map
):
map_k
=
utils
.
NiceSort
(
status_map
.
keys
())
for
node_name
in
map_k
:
logger
.
ToStdout
(
format
%
(
max_name
,
""
,
max_node
,
node_name
,
status_map
[
node_name
]))
if
node_name
in
all_os
[
os_name
]:
_OutputNodeHiddenOSStatus
(
all_os
[
os_name
][
node_name
])
logger
.
ToStdout
(
format
%
(
max_name
,
os_name
,
max_node
,
status
,
""
))
logger
.
ToStdout
(
format
%
(
max_name
,
os_name
,
max_node
,
status
,
""
))
nodes_valid
=
utils
.
NiceSort
(
nodes_valid
)
_OutputPerNodeOSStatus
(
nodes_valid
)
for
node_name
in
nodes_valid
:
_OutputPerNodeOSStatus
(
nodes_bad
)
logger
.
ToStdout
(
format
%
(
max_name
,
""
,
max_node
,
node_name
,
"
valid (path: %s)
"
%
all_os
[
os_name
][
node_name
][
0
].
path
))
nbk
=
utils
.
NiceSort
(
nodes_bad
.
keys
())
for
node_name
in
nbk
:
logger
.
ToStdout
(
format
%
(
max_name
,
""
,
max_node
,
node_name
,
nodes_bad
[
node_name
]))
commands
=
{
commands
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment