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
Labels
Merge Requests
21
Merge Requests
21
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
5f3a0128
Commit
5f3a0128
authored
May 23, 2017
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve the local-binding of logger
parent
e186fa8f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
11 deletions
+27
-11
slapos/README.format.md
slapos/README.format.md
+11
-8
slapos/cli/format.py
slapos/cli/format.py
+8
-3
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+8
-0
No files found.
slapos/README.format.md
View file @
5f3a0128
f
ormat
======
SlapOS F
ormat
======
=======
slapformat is an application to prepare SlapOS ready node (machine).
slap.format is an application to prepare SlapOS-ready node (machine). SlapOS-ready
means that SlapOS package was installed and you edited
`/etc/opt/slapos/slapos.cfg`
where you define for example SlapOS master URL, certificates and networking.
It "formats" the machine by:
-
creating users and groups
-
creating bridge interface
-
creating needed tap interfaces
-
creating and bridging TAP and TUN interfaces
-
creating needed directories with proper ownership and permissions
-
creating custom cgroup groups for better resource controlling
In the end special report is generated and information are posted to
configured SlapOS server.
In the end, a report is posted to SlapOS Master and files
`.slapos-resources`
are
created per-partition so each partition knows what interfaces, network ranges and
other computer resources are assigned to it.
This program shall be only run by root.
Requirements
------------
...
...
@@ -25,5 +29,4 @@ Binaries:
*
brctl
*
groupadd
*
ip
*
tunctl
*
useradd
slapos/cli/format.py
View file @
5f3a0128
...
...
@@ -58,7 +58,7 @@ class FormatCommand(ConfigCommand):
ap
.
add_argument
(
'-o'
,
'--output_definition_file'
,
help
=
"Path to file to write definition of computer from "
"declaration
.
"
)
"declaration
(obsolete: will be written to .slapos-resources)
"
)
ap
.
add_argument
(
'--alter_user'
,
choices
=
[
'True'
,
'False'
],
...
...
@@ -89,8 +89,7 @@ class FormatCommand(ConfigCommand):
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
conf
=
FormatConfig
(
logger
=
self
.
app
.
log
)
conf
=
FormatConfig
()
conf
.
mergeConfig
(
args
,
configp
)
# Parse if we have to check if running from root
...
...
@@ -98,6 +97,9 @@ class FormatCommand(ConfigCommand):
if
string_to_boolean
(
getattr
(
conf
,
'root_check'
,
'True'
).
lower
()):
check_root_user
(
self
)
# Configuring locally-bound logger is obsolete - use standard logging module
app_logger
=
self
.
app
.
log
# backup original logger
self
.
app
.
log
=
logging
.
getLogger
(
'slapos.format'
)
# and replace it with module logger
if
len
(
self
.
app
.
log
.
handlers
)
==
0
and
not
self
.
app
.
options
.
log_file
and
conf
.
log_file
:
# This block is called again if "slapos node boot" failed.
# Don't add a handler again, otherwise the output becomes double.
...
...
@@ -119,3 +121,6 @@ class FormatCommand(ConfigCommand):
tracing_monkeypatch
(
conf
)
do_format
(
conf
=
conf
)
# restore original logger
self
.
app
.
log
=
app_logger
slapos/tests/slapformat.py
View file @
5f3a0128
...
...
@@ -234,11 +234,19 @@ class SlapformatMixin(unittest.TestCase):
config
=
FakeConfig
()
config
.
dry_run
=
True
config
.
verbose
=
True
# XXX: we shouldn't use global singleton locally
logger
=
logging
.
getLogger
(
'testcatch'
)
logger
.
setLevel
(
logging
.
DEBUG
)
self
.
test_result
=
TestLoggerHandler
()
logger
.
addHandler
(
self
.
test_result
)
# XXX: and we shouldn't pass references to it
config
.
logger
=
logger
# This is the logger used in slapformat
logger
=
logging
.
getLogger
(
'slapos.format'
)
# Set it up for test purposes
logger
.
setLevel
(
logging
.
DEBUG
)
self
.
test_result
=
TestLoggerHandler
()
logger
.
addHandler
(
self
.
test_result
)
self
.
partition
=
slapos
.
format
.
Partition
(
'partition'
,
'/part_path'
,
slapos
.
format
.
User
(
'testuser'
),
[],
None
)
global
USER_LIST
...
...
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