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
60edf71e
Commit
60edf71e
authored
17 years ago
by
Michael Hanselmann
Browse files
Options
Downloads
Patches
Plain Diff
Implement --dry-run for cfgupgrade.
Reviewed-by: iustinp
parent
cf62a272
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/cfgupgrade
+10
-3
10 additions, 3 deletions
tools/cfgupgrade
with
10 additions
and
3 deletions
tools/cfgupgrade
+
10
−
3
View file @
60edf71e
...
...
@@ -130,7 +130,7 @@ def _WriteFindGlobal(module, name):
return
_BaseFindGlobal
(
module
,
name
)
def
WriteConfig
(
path
,
data
):
def
WriteConfig
(
path
,
data
,
dry_run
):
"""
Writes the configuration file.
"""
...
...
@@ -155,7 +155,10 @@ def WriteConfig(path, data):
dumper
=
cPickle
.
Pickler
(
f
,
cPickle
.
HIGHEST_PROTOCOL
)
dumper
.
dump
(
data
)
f
.
flush
()
os
.
rename
(
name
,
path
)
if
dry_run
:
os
.
unlink
(
name
)
else
:
os
.
rename
(
name
,
path
)
except
:
os
.
unlink
(
name
)
raise
...
...
@@ -189,6 +192,10 @@ def UpdateFromVersion2To3(cfg):
if
__name__
==
"
__main__
"
:
# Option parsing
parser
=
optparse
.
OptionParser
()
parser
.
add_option
(
'
--dry-run
'
,
dest
=
'
dry_run
'
,
action
=
"
store_true
"
,
help
=
"
Try to do the conversion, but don
'
t write
"
"
output file
"
)
parser
.
add_option
(
'
--verbose
'
,
dest
=
'
verbose
'
,
action
=
"
store_true
"
,
help
=
"
Verbose output
"
)
...
...
@@ -208,4 +215,4 @@ if __name__ == "__main__":
import
pprint
pprint
.
pprint
(
config
)
WriteConfig
(
cfg_file
,
config
)
WriteConfig
(
cfg_file
,
config
,
options
.
dry_run
)
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