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
Lisa Casino
slapos.core
Commits
9c61e87e
Commit
9c61e87e
authored
Jun 27, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format: some logger syntax, levels and messages
parent
476245d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
slapos/format.py
slapos/format.py
+14
-14
No files found.
slapos/format.py
View file @
9c61e87e
...
@@ -81,7 +81,7 @@ class OS(object):
...
@@ -81,7 +81,7 @@ class OS(object):
arg_list
=
[
repr
(
x
)
for
x
in
args
]
+
[
arg_list
=
[
repr
(
x
)
for
x
in
args
]
+
[
'%s=%r'
%
(
x
,
y
)
for
x
,
y
in
kw
.
iteritems
()
'%s=%r'
%
(
x
,
y
)
for
x
,
y
in
kw
.
iteritems
()
]
]
self
.
_logger
.
debug
(
'%s(%s)'
%
(
name
,
', '
.
join
(
arg_list
)
))
self
.
_logger
.
debug
(
'%s(%s)'
,
name
,
', '
.
join
(
arg_list
))
if
not
self
.
_dry_run
:
if
not
self
.
_dry_run
:
getattr
(
self
.
_os
,
name
)(
*
args
,
**
kw
)
getattr
(
self
.
_os
,
name
)(
*
args
,
**
kw
)
setattr
(
self
,
name
,
wrapper
)
setattr
(
self
,
name
,
wrapper
)
...
@@ -855,7 +855,7 @@ class Interface(object):
...
@@ -855,7 +855,7 @@ class Interface(object):
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
else
:
else
:
self
.
logger
.
warning
(
'Impossible to add old local IPv4 %s. Generating '
self
.
logger
.
warning
(
'Impossible to add old local IPv4 %s. Generating '
'new IPv4 address.'
%
addr
)
'new IPv4 address.'
,
addr
)
return
self
.
_generateRandomIPv4Address
(
netmask
)
return
self
.
_generateRandomIPv4Address
(
netmask
)
else
:
else
:
# confirmed to be configured
# confirmed to be configured
...
@@ -913,7 +913,7 @@ class Interface(object):
...
@@ -913,7 +913,7 @@ class Interface(object):
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
else
:
else
:
self
.
logger
.
warning
(
'Impossible to add old public IPv6 %s. '
self
.
logger
.
warning
(
'Impossible to add old public IPv6 %s. '
'Generating new IPv6 address.'
%
addr
)
'Generating new IPv6 address.'
,
addr
)
# Try 10 times to add address, raise in case if not possible
# Try 10 times to add address, raise in case if not possible
try_num
=
10
try_num
=
10
...
@@ -933,7 +933,7 @@ class Interface(object):
...
@@ -933,7 +933,7 @@ class Interface(object):
def
parse_computer_definition
(
conf
,
definition_path
):
def
parse_computer_definition
(
conf
,
definition_path
):
conf
.
logger
.
info
(
'Using definition file %r'
%
definition_path
)
conf
.
logger
.
info
(
'Using definition file %r'
,
definition_path
)
computer_definition
=
ConfigParser
.
RawConfigParser
({
computer_definition
=
ConfigParser
.
RawConfigParser
({
'software_user'
:
'slapsoft'
,
'software_user'
:
'slapsoft'
,
})
})
...
@@ -984,7 +984,7 @@ def parse_computer_xml(conf, xml_path):
...
@@ -984,7 +984,7 @@ def parse_computer_xml(conf, xml_path):
ipv6_interface
=
conf
.
ipv6_interface
)
ipv6_interface
=
conf
.
ipv6_interface
)
if
os
.
path
.
exists
(
xml_path
):
if
os
.
path
.
exists
(
xml_path
):
conf
.
logger
.
debug
(
'Loading previous computer data from %r'
%
xml_path
)
conf
.
logger
.
debug
(
'Loading previous computer data from %r'
,
xml_path
)
computer
=
Computer
.
load
(
xml_path
,
computer
=
Computer
.
load
(
xml_path
,
reference
=
conf
.
computer_id
,
reference
=
conf
.
computer_id
,
ipv6_interface
=
conf
.
ipv6_interface
)
ipv6_interface
=
conf
.
ipv6_interface
)
...
@@ -1046,7 +1046,7 @@ def write_computer_definition(conf, computer):
...
@@ -1046,7 +1046,7 @@ def write_computer_definition(conf, computer):
computer_definition
.
set
(
section
,
'network_interface'
,
partition
.
tap
.
name
)
computer_definition
.
set
(
section
,
'network_interface'
,
partition
.
tap
.
name
)
computer_definition
.
set
(
section
,
'pathname'
,
partition
.
reference
)
computer_definition
.
set
(
section
,
'pathname'
,
partition
.
reference
)
computer_definition
.
write
(
open
(
conf
.
output_definition_file
,
'w'
))
computer_definition
.
write
(
open
(
conf
.
output_definition_file
,
'w'
))
conf
.
logger
.
info
(
'Stored computer definition in %r'
%
conf
.
output_definition_file
)
conf
.
logger
.
info
(
'Stored computer definition in %r'
,
conf
.
output_definition_file
)
def
random_delay
(
conf
):
def
random_delay
(
conf
):
...
@@ -1056,7 +1056,7 @@ def random_delay(conf):
...
@@ -1056,7 +1056,7 @@ def random_delay(conf):
if
not
conf
.
now
:
if
not
conf
.
now
:
duration
=
float
(
60
*
60
)
*
random
.
random
()
duration
=
float
(
60
*
60
)
*
random
.
random
()
conf
.
logger
.
info
(
'Sleeping for %s seconds. To disable this feature, '
conf
.
logger
.
info
(
'Sleeping for %s seconds. To disable this feature, '
'use with --now parameter in manual.'
%
duration
)
'use with --now parameter in manual.'
,
duration
)
time
.
sleep
(
duration
)
time
.
sleep
(
duration
)
...
@@ -1071,7 +1071,7 @@ def do_format(conf):
...
@@ -1071,7 +1071,7 @@ def do_format(conf):
computer
.
instance_root
=
conf
.
instance_root
computer
.
instance_root
=
conf
.
instance_root
computer
.
software_root
=
conf
.
software_root
computer
.
software_root
=
conf
.
software_root
conf
.
logger
.
info
(
'Updating
computer'
)
conf
.
logger
.
info
(
'Updating
node %s'
,
conf
.
computer_id
)
address
=
computer
.
getAddress
(
conf
.
create_tap
)
address
=
computer
.
getAddress
(
conf
.
create_tap
)
computer
.
address
=
address
[
'addr'
]
computer
.
address
=
address
[
'addr'
]
computer
.
netmask
=
address
[
'netmask'
]
computer
.
netmask
=
address
[
'netmask'
]
...
@@ -1091,7 +1091,7 @@ def do_format(conf):
...
@@ -1091,7 +1091,7 @@ def do_format(conf):
computer
.
dump
(
path_to_xml
=
conf
.
computer_xml
,
computer
.
dump
(
path_to_xml
=
conf
.
computer_xml
,
path_to_json
=
conf
.
computer_json
,
path_to_json
=
conf
.
computer_json
,
logger
=
conf
.
logger
)
logger
=
conf
.
logger
)
conf
.
logger
.
info
(
'Posting information to %r'
%
conf
.
master_url
)
conf
.
logger
.
info
(
'Posting information to %r'
,
conf
.
master_url
)
computer
.
send
(
conf
)
computer
.
send
(
conf
)
conf
.
logger
.
info
(
'slapos successfully prepared the computer.'
)
conf
.
logger
.
info
(
'slapos successfully prepared the computer.'
)
...
@@ -1216,7 +1216,7 @@ class FormatConfig(object):
...
@@ -1216,7 +1216,7 @@ class FormatConfig(object):
message
=
"Root rights are needed"
message
=
"Root rights are needed"
self
.
logger
.
error
(
message
)
self
.
logger
.
error
(
message
)
sys
.
stderr
.
write
(
message
+
'
\
n
'
)
sys
.
stderr
.
write
(
message
+
'
\
n
'
)
sys
.
exit
()
sys
.
exit
(
1
)
# Check mandatory options
# Check mandatory options
for
parameter
in
(
'computer_id'
,
'instance_root'
,
'master_url'
,
for
parameter
in
(
'computer_id'
,
'instance_root'
,
'master_url'
,
...
@@ -1229,7 +1229,7 @@ class FormatConfig(object):
...
@@ -1229,7 +1229,7 @@ class FormatConfig(object):
file_location
=
getattr
(
self
,
attribute
,
None
)
file_location
=
getattr
(
self
,
attribute
,
None
)
if
file_location
is
not
None
:
if
file_location
is
not
None
:
if
not
os
.
path
.
exists
(
file_location
):
if
not
os
.
path
.
exists
(
file_location
):
self
.
logger
.
fatal
(
'File %r does not exist or is not readable.'
%
self
.
logger
.
critical
(
'File %r does not exist or is not readable.'
,
file_location
)
file_location
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
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