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
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
Show 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:
It "formats" the machine by:
-
creating users and groups
-
creating users and groups
-
creating bridge interface
-
creating and bridging TAP and TUN interfaces
-
creating needed tap interfaces
-
creating needed directories with proper ownership and permissions
-
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
In the end, a report is posted to SlapOS Master and files
`.slapos-resources`
are
configured SlapOS server.
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.
This program shall be only run by root.
Requirements
Requirements
------------
------------
...
@@ -25,5 +29,4 @@ Binaries:
...
@@ -25,5 +29,4 @@ Binaries:
*
brctl
*
brctl
*
groupadd
*
groupadd
*
ip
*
ip
*
tunctl
*
useradd
*
useradd
slapos/cli/format.py
View file @
5f3a0128
...
@@ -58,7 +58,7 @@ class FormatCommand(ConfigCommand):
...
@@ -58,7 +58,7 @@ class FormatCommand(ConfigCommand):
ap
.
add_argument
(
'-o'
,
'--output_definition_file'
,
ap
.
add_argument
(
'-o'
,
'--output_definition_file'
,
help
=
"Path to file to write definition of computer from "
help
=
"Path to file to write definition of computer from "
"declaration
.
"
)
"declaration
(obsolete: will be written to .slapos-resources)
"
)
ap
.
add_argument
(
'--alter_user'
,
ap
.
add_argument
(
'--alter_user'
,
choices
=
[
'True'
,
'False'
],
choices
=
[
'True'
,
'False'
],
...
@@ -89,8 +89,7 @@ class FormatCommand(ConfigCommand):
...
@@ -89,8 +89,7 @@ class FormatCommand(ConfigCommand):
def
take_action
(
self
,
args
):
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
configp
=
self
.
fetch_config
(
args
)
conf
=
FormatConfig
(
logger
=
self
.
app
.
log
)
conf
=
FormatConfig
()
conf
.
mergeConfig
(
args
,
configp
)
conf
.
mergeConfig
(
args
,
configp
)
# Parse if we have to check if running from root
# Parse if we have to check if running from root
...
@@ -98,6 +97,9 @@ class FormatCommand(ConfigCommand):
...
@@ -98,6 +97,9 @@ class FormatCommand(ConfigCommand):
if
string_to_boolean
(
getattr
(
conf
,
'root_check'
,
'True'
).
lower
()):
if
string_to_boolean
(
getattr
(
conf
,
'root_check'
,
'True'
).
lower
()):
check_root_user
(
self
)
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
:
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.
# This block is called again if "slapos node boot" failed.
# Don't add a handler again, otherwise the output becomes double.
# Don't add a handler again, otherwise the output becomes double.
...
@@ -119,3 +121,6 @@ class FormatCommand(ConfigCommand):
...
@@ -119,3 +121,6 @@ class FormatCommand(ConfigCommand):
tracing_monkeypatch
(
conf
)
tracing_monkeypatch
(
conf
)
do_format
(
conf
=
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):
...
@@ -234,11 +234,19 @@ class SlapformatMixin(unittest.TestCase):
config
=
FakeConfig
()
config
=
FakeConfig
()
config
.
dry_run
=
True
config
.
dry_run
=
True
config
.
verbose
=
True
config
.
verbose
=
True
# XXX: we shouldn't use global singleton locally
logger
=
logging
.
getLogger
(
'testcatch'
)
logger
=
logging
.
getLogger
(
'testcatch'
)
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
setLevel
(
logging
.
DEBUG
)
self
.
test_result
=
TestLoggerHandler
()
self
.
test_result
=
TestLoggerHandler
()
logger
.
addHandler
(
self
.
test_result
)
logger
.
addHandler
(
self
.
test_result
)
# XXX: and we shouldn't pass references to it
config
.
logger
=
logger
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'
,
self
.
partition
=
slapos
.
format
.
Partition
(
'partition'
,
'/part_path'
,
slapos
.
format
.
User
(
'testuser'
),
[],
None
)
slapos
.
format
.
User
(
'testuser'
),
[],
None
)
global
USER_LIST
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