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
7bca53e4
Commit
7bca53e4
authored
16 years ago
by
Michael Hanselmann
Browse files
Options
Downloads
Patches
Plain Diff
ganeti-watcher: Replace custom exceptions with ganeti.error.*
Reviewed-by: iustinp
parent
2fb96d39
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemons/ganeti-watcher
+9
-12
9 additions, 12 deletions
daemons/ganeti-watcher
lib/errors.py
+6
-0
6 additions, 0 deletions
lib/errors.py
with
15 additions
and
12 deletions
daemons/ganeti-watcher
+
9
−
12
View file @
7bca53e4
...
...
@@ -53,11 +53,7 @@ KEY_RESTART_WHEN = "restart_when"
KEY_BOOT_ID
=
"
bootid
"
class
Error
(
Exception
):
"""
Generic custom error class.
"""
class
NotMasterError
(
Error
):
class
NotMasterError
(
errors
.
GenericError
):
"""
Exception raised when this host is not the master.
"""
...
...
@@ -84,11 +80,12 @@ def DoCmd(cmd):
res
=
utils
.
RunCmd
(
cmd
)
if
res
.
failed
:
raise
Error
(
"
Command %s failed:
\n
%s
\n
stdout:
\n
%sstderr:
\n
%s
"
%
(
repr
(
cmd
),
Indent
(
res
.
fail_reason
),
Indent
(
res
.
stdout
),
Indent
(
res
.
stderr
)))
msg
=
(
"
Command %s failed:
\n
%s
\n
stdout:
\n
%sstderr:
\n
%s
"
%
(
repr
(
cmd
),
Indent
(
res
.
fail_reason
),
Indent
(
res
.
stdout
),
Indent
(
res
.
stderr
)))
raise
errors
.
CommandError
(
msg
)
return
res
...
...
@@ -101,7 +98,7 @@ def LockFile(fd):
fcntl
.
flock
(
fd
,
fcntl
.
LOCK_EX
|
fcntl
.
LOCK_NB
)
except
IOError
,
err
:
if
err
.
errno
==
errno
.
EAGAIN
:
raise
Standard
Error
(
"
File already locked
"
)
raise
errors
.
Lock
Error
(
"
File already locked
"
)
raise
...
...
@@ -112,7 +109,7 @@ class WatcherState(object):
def
__init__
(
self
):
"""
Open, lock, read and parse the file.
Raises
StandardError
on lock contention.
Raises
exception
on lock contention.
"""
# The two-step dance below is necessary to allow both opening existing
...
...
This diff is collapsed.
Click to expand it.
lib/errors.py
+
6
−
0
View file @
7bca53e4
...
...
@@ -210,3 +210,9 @@ class TagError(GenericError):
The argument to this exception will show the exact error.
"""
class
CommandError
(
GenericError
):
"""
External command error.
"""
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