Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Leymonerie
slapos.core
Commits
5fbb22ab
Commit
5fbb22ab
authored
Apr 18, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli refactoring: node format
parent
d0b40e71
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
198 additions
and
136 deletions
+198
-136
setup.py
setup.py
+1
-0
slapos/cli/format.py
slapos/cli/format.py
+76
-0
slapos/format.py
slapos/format.py
+121
-136
No files found.
setup.py
View file @
5fbb22ab
...
...
@@ -75,6 +75,7 @@ setup(name=name,
'slapos.cli'
:
[
'cache lookup = slapos.cli.cache:CacheLookupCommand'
,
'node bang = slapos.cli.bang:BangCommand'
,
'node format = slapos.cli.format:FormatCommand'
,
]
},
test_suite
=
"slapos.tests"
,
...
...
slapos/cli/format.py
0 → 100644
View file @
5fbb22ab
# -*- coding: utf-8 -*-
import
logging
import
sys
from
slapos.cli.config
import
ConfigCommand
from
slapos.format
import
do_format
,
FormatConfig
,
tracing_monkeypatch
,
UsageError
class
FormatCommand
(
ConfigCommand
):
log
=
logging
.
getLogger
(
'slapformat'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
FormatCommand
,
self
).
get_parser
(
prog_name
)
ap
.
add_argument
(
'-x'
,
'--computer_xml'
,
help
=
"Path to file with computer's XML. If does not exists, will be created"
,
default
=
None
)
ap
.
add_argument
(
'--computer_json'
,
help
=
"Path to a JSON version of the computer's XML (for development only)."
,
default
=
None
)
ap
.
add_argument
(
'-l'
,
'--log_file'
,
help
=
"The path to the log file used by the script."
)
ap
.
add_argument
(
'-i'
,
'--input_definition_file'
,
help
=
"Path to file to read definition of computer instead of "
"declaration. Using definition file allows to disable "
"'discovery' of machine services and allows to define computer "
"configuration in fully controlled manner."
)
ap
.
add_argument
(
'-o'
,
'--output_definition_file'
,
help
=
"Path to file to write definition of computer from "
"declaration."
)
ap
.
add_argument
(
'-n'
,
'--dry_run'
,
help
=
"Don't actually do anything."
,
default
=
False
,
action
=
"store_true"
)
ap
.
add_argument
(
'--alter_user'
,
choices
=
[
'True'
,
'False'
],
help
=
"Shall slapformat alter user database [default: True]"
)
ap
.
add_argument
(
'--alter_network'
,
choices
=
[
'True'
,
'False'
],
help
=
"Shall slapformat alter network configuration [default: True]"
)
ap
.
add_argument
(
'--now'
,
help
=
"Launch slapformat without delay"
,
default
=
False
,
action
=
"store_true"
)
return
ap
def
take_action
(
self
,
args
):
configuration_parser
=
self
.
fetch_config
(
args
)
config
=
FormatConfig
(
logger
=
self
.
log
)
try
:
config
.
setConfig
(
args
,
configuration_parser
)
except
UsageError
as
err
:
sys
.
stderr
.
write
(
err
.
message
+
'
\
n
'
)
sys
.
stderr
.
write
(
"For help use --help
\
n
"
)
sys
.
exit
(
1
)
tracing_monkeypatch
(
config
)
try
:
do_format
(
config
=
config
)
except
:
self
.
log
.
exception
(
'Uncaught exception:'
)
raise
slapos/format.py
View file @
5fbb22ab
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment