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
Arnaud Véron
slapos.core
Commits
ae837389
Commit
ae837389
authored
Jun 26, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed error messages and logging levels
parent
4cabab29
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
32 deletions
+31
-32
slapos/cli/configure_client.py
slapos/cli/configure_client.py
+2
-2
slapos/cli/register.py
slapos/cli/register.py
+16
-18
slapos/format.py
slapos/format.py
+13
-12
No files found.
slapos/cli/configure_client.py
View file @
ae837389
...
@@ -72,7 +72,7 @@ def do_configure_client(logger, master_url_web, token, config_path, master_url):
...
@@ -72,7 +72,7 @@ def do_configure_client(logger, master_url_web, token, config_path, master_url):
# where we expect to create them. If so, ask the use to manually remove them.
# where we expect to create them. If so, ask the use to manually remove them.
if
os
.
path
.
exists
(
config_path
):
if
os
.
path
.
exists
(
config_path
):
logger
.
critical
(
'There is file in %s. '
logger
.
critical
(
'There is
a
file in %s. '
'Please remove it before creating a new configuration.'
,
config_path
)
'Please remove it before creating a new configuration.'
,
config_path
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
@@ -119,4 +119,4 @@ def do_configure_client(logger, master_url_web, token, config_path, master_url):
...
@@ -119,4 +119,4 @@ def do_configure_client(logger, master_url_web, token, config_path, master_url):
logger
.
debug
(
'Writing key to %s'
,
key_path
)
logger
.
debug
(
'Writing key to %s'
,
key_path
)
fout
.
write
(
key
)
fout
.
write
(
key
)
logger
.
info
(
'SlapOS client configuration
: DONE'
)
logger
.
info
(
'SlapOS client configuration
written to %s'
,
config_path
)
slapos/cli/register.py
View file @
ae837389
...
@@ -213,10 +213,8 @@ def slapconfig(conf):
...
@@ -213,10 +213,8 @@ def slapconfig(conf):
key_file
=
os
.
path
.
join
(
user_certificate_repository_path
,
'key'
)
key_file
=
os
.
path
.
join
(
user_certificate_repository_path
,
'key'
)
cert_file
=
os
.
path
.
join
(
user_certificate_repository_path
,
'certificate'
)
cert_file
=
os
.
path
.
join
(
user_certificate_repository_path
,
'certificate'
)
for
src
,
dst
in
[
(
conf
.
key
,
key_file
),
for
src
,
dst
in
[(
conf
.
key
,
key_file
),
(
conf
.
certificate
,
cert_file
)]:
(
conf
.
certificate
,
cert_file
)
]:
conf
.
logger
.
info
(
'Copying to %r, and setting minimum privileges'
,
dst
)
conf
.
logger
.
info
(
'Copying to %r, and setting minimum privileges'
,
dst
)
if
not
dry_run
:
if
not
dry_run
:
with
open
(
dst
,
'w'
)
as
destination
:
with
open
(
dst
,
'w'
)
as
destination
:
...
@@ -231,8 +229,8 @@ def slapconfig(conf):
...
@@ -231,8 +229,8 @@ def slapconfig(conf):
os
.
mkdir
(
certificate_repository_path
,
0o711
)
os
.
mkdir
(
certificate_repository_path
,
0o711
)
# Put slapos configuration file
# Put slapos configuration file
slap_conf_file
=
os
.
path
.
join
(
slap_conf_dir
,
'slapos.cfg'
)
config_path
=
os
.
path
.
join
(
slap_conf_dir
,
'slapos.cfg'
)
conf
.
logger
.
info
(
'Creating slap configuration: %s'
,
slap_conf_file
)
conf
.
logger
.
info
(
'Creating slap configuration: %s'
,
config_path
)
# Get example configuration file
# Get example configuration file
slapos_cfg_example
=
get_slapos_conf_example
()
slapos_cfg_example
=
get_slapos_conf_example
()
...
@@ -257,10 +255,10 @@ def slapconfig(conf):
...
@@ -257,10 +255,10 @@ def slapconfig(conf):
new_configp
.
set
(
'slapformat'
,
'ipv6_interface'
,
conf
.
ipv6_interface
)
new_configp
.
set
(
'slapformat'
,
'ipv6_interface'
,
conf
.
ipv6_interface
)
if
not
dry_run
:
if
not
dry_run
:
with
open
(
slap_conf_file
,
'w'
)
as
fout
:
with
open
(
config_path
,
'w'
)
as
fout
:
new_configp
.
write
(
fout
)
new_configp
.
write
(
fout
)
conf
.
logger
.
info
(
'SlapOS configuration
: DONE'
)
conf
.
logger
.
info
(
'SlapOS configuration
written to %s'
,
config_path
)
class
RegisterConfig
(
object
):
class
RegisterConfig
(
object
):
...
...
slapos/format.py
View file @
ae837389
...
@@ -301,8 +301,7 @@ class Computer(object):
...
@@ -301,8 +301,7 @@ class Computer(object):
self
.
backup_xml
(
path_to_archive
,
path_to_xml
)
self
.
backup_xml
(
path_to_archive
,
path_to_xml
)
except
:
except
:
# give up trying
# give up trying
logger
.
warning
(
"Can't backup %s: %s"
%
logger
.
exception
(
"Can't backup %s:"
,
path_to_xml
)
(
path_to_xml
,
traceback
.
format_exc
()))
with
open
(
path_to_xml
,
'wb'
)
as
fout
:
with
open
(
path_to_xml
,
'wb'
)
as
fout
:
fout
.
write
(
new_pretty_xml
)
fout
.
write
(
new_pretty_xml
)
...
@@ -985,7 +984,7 @@ def parse_computer_xml(conf, xml_path):
...
@@ -985,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
.
info
(
'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
)
...
@@ -993,7 +992,7 @@ def parse_computer_xml(conf, xml_path):
...
@@ -993,7 +992,7 @@ def parse_computer_xml(conf, xml_path):
computer
.
interface
=
interface
computer
.
interface
=
interface
else
:
else
:
# If no pre-existent configuration found, create a new computer object
# If no pre-existent configuration found, create a new computer object
conf
.
logger
.
warning
(
'Creating new
data computer with id %r'
%
conf
.
computer_id
)
conf
.
logger
.
warning
(
'Creating new
computer data with id %r'
,
conf
.
computer_id
)
computer
=
Computer
(
computer
=
Computer
(
reference
=
conf
.
computer_id
,
reference
=
conf
.
computer_id
,
interface
=
interface
,
interface
=
interface
,
...
@@ -1005,13 +1004,15 @@ def parse_computer_xml(conf, xml_path):
...
@@ -1005,13 +1004,15 @@ def parse_computer_xml(conf, xml_path):
partition_amount
=
int
(
conf
.
partition_amount
)
partition_amount
=
int
(
conf
.
partition_amount
)
existing_partition_amount
=
len
(
computer
.
partition_list
)
existing_partition_amount
=
len
(
computer
.
partition_list
)
if
partition_amount
<
existing_partition_amount
:
raise
ValueError
(
'Requested amount of computer partitions (%s) is lower '
'then already configured (%s), cannot continue'
%
(
partition_amount
,
existing_partition_amount
))
conf
.
logger
.
info
(
'Adding %s new partitions'
%
if
partition_amount
<
existing_partition_amount
:
(
partition_amount
-
existing_partition_amount
))
conf
.
logger
.
critical
(
'Requested amount of computer partitions (%s) is lower '
'than already configured (%s), cannot continue'
,
partition_amount
,
existing_partition_amount
)
sys
.
exit
(
1
)
elif
partition_amount
>
existing_partition_amount
:
conf
.
logger
.
info
(
'Adding %s new partitions'
,
partition_amount
-
existing_partition_amount
)
for
i
in
range
(
existing_partition_amount
,
partition_amount
):
for
i
in
range
(
existing_partition_amount
,
partition_amount
):
# add new partitions
# add new partitions
...
@@ -1092,7 +1093,7 @@ def do_format(conf):
...
@@ -1092,7 +1093,7 @@ def do_format(conf):
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
(
'slap
format successfully prepared
computer.'
)
conf
.
logger
.
info
(
'slap
os successfully prepared the
computer.'
)
class
FormatConfig
(
object
):
class
FormatConfig
(
object
):
...
@@ -1232,7 +1233,7 @@ class FormatConfig(object):
...
@@ -1232,7 +1233,7 @@ class FormatConfig(object):
file_location
)
file_location
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
self
.
logger
.
info
(
"Started."
)
self
.
logger
.
debug
(
'Started.'
)
if
self
.
dry_run
:
if
self
.
dry_run
:
self
.
logger
.
info
(
"Dry-run mode enabled."
)
self
.
logger
.
info
(
"Dry-run mode enabled."
)
if
self
.
create_tap
:
if
self
.
create_tap
:
...
...
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