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
Ivan Tyagov
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
Hide 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):
# where we expect to create them. If so, ask the use to manually remove them.
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
)
sys
.
exit
(
1
)
...
...
@@ -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
)
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):
key_file
=
os
.
path
.
join
(
user_certificate_repository_path
,
'key'
)
cert_file
=
os
.
path
.
join
(
user_certificate_repository_path
,
'certificate'
)
for
src
,
dst
in
[
(
conf
.
key
,
key_file
),
(
conf
.
certificate
,
cert_file
)
]:
for
src
,
dst
in
[(
conf
.
key
,
key_file
),
(
conf
.
certificate
,
cert_file
)]:
conf
.
logger
.
info
(
'Copying to %r, and setting minimum privileges'
,
dst
)
if
not
dry_run
:
with
open
(
dst
,
'w'
)
as
destination
:
...
...
@@ -231,8 +229,8 @@ def slapconfig(conf):
os
.
mkdir
(
certificate_repository_path
,
0o711
)
# Put slapos configuration file
slap_conf_file
=
os
.
path
.
join
(
slap_conf_dir
,
'slapos.cfg'
)
conf
.
logger
.
info
(
'Creating slap configuration: %s'
,
slap_conf_file
)
config_path
=
os
.
path
.
join
(
slap_conf_dir
,
'slapos.cfg'
)
conf
.
logger
.
info
(
'Creating slap configuration: %s'
,
config_path
)
# Get example configuration file
slapos_cfg_example
=
get_slapos_conf_example
()
...
...
@@ -241,26 +239,26 @@ def slapconfig(conf):
os
.
remove
(
slapos_cfg_example
)
for
section
,
key
,
value
in
[
(
'slapos'
,
'computer_id'
,
conf
.
computer_id
),
(
'slapos'
,
'master_url'
,
conf
.
master_url
),
(
'slapos'
,
'key_file'
,
key_file
),
(
'slapos'
,
'cert_file'
,
cert_file
),
(
'slapos'
,
'certificate_repository_path'
,
certificate_repository_path
),
(
'slapformat'
,
'interface_name'
,
conf
.
interface_name
),
(
'slapformat'
,
'ipv4_local_network'
,
conf
.
ipv4_local_network
),
(
'slapformat'
,
'partition_amount'
,
conf
.
partition_number
),
(
'slapformat'
,
'create_tap'
,
conf
.
create_tap
)
]:
(
'slapos'
,
'computer_id'
,
conf
.
computer_id
),
(
'slapos'
,
'master_url'
,
conf
.
master_url
),
(
'slapos'
,
'key_file'
,
key_file
),
(
'slapos'
,
'cert_file'
,
cert_file
),
(
'slapos'
,
'certificate_repository_path'
,
certificate_repository_path
),
(
'slapformat'
,
'interface_name'
,
conf
.
interface_name
),
(
'slapformat'
,
'ipv4_local_network'
,
conf
.
ipv4_local_network
),
(
'slapformat'
,
'partition_amount'
,
conf
.
partition_number
),
(
'slapformat'
,
'create_tap'
,
conf
.
create_tap
)
]:
new_configp
.
set
(
section
,
key
,
value
)
if
conf
.
ipv6_interface
:
new_configp
.
set
(
'slapformat'
,
'ipv6_interface'
,
conf
.
ipv6_interface
)
if
not
dry_run
:
with
open
(
slap_conf_file
,
'w'
)
as
fout
:
with
open
(
config_path
,
'w'
)
as
fout
:
new_configp
.
write
(
fout
)
conf
.
logger
.
info
(
'SlapOS configuration
: DONE'
)
conf
.
logger
.
info
(
'SlapOS configuration
written to %s'
,
config_path
)
class
RegisterConfig
(
object
):
...
...
slapos/format.py
View file @
ae837389
...
...
@@ -301,8 +301,7 @@ class Computer(object):
self
.
backup_xml
(
path_to_archive
,
path_to_xml
)
except
:
# give up trying
logger
.
warning
(
"Can't backup %s: %s"
%
(
path_to_xml
,
traceback
.
format_exc
()))
logger
.
exception
(
"Can't backup %s:"
,
path_to_xml
)
with
open
(
path_to_xml
,
'wb'
)
as
fout
:
fout
.
write
(
new_pretty_xml
)
...
...
@@ -985,7 +984,7 @@ def parse_computer_xml(conf, xml_path):
ipv6_interface
=
conf
.
ipv6_interface
)
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
,
reference
=
conf
.
computer_id
,
ipv6_interface
=
conf
.
ipv6_interface
)
...
...
@@ -993,7 +992,7 @@ def parse_computer_xml(conf, xml_path):
computer
.
interface
=
interface
else
:
# 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
(
reference
=
conf
.
computer_id
,
interface
=
interface
,
...
...
@@ -1005,13 +1004,15 @@ def parse_computer_xml(conf, xml_path):
partition_amount
=
int
(
conf
.
partition_amount
)
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'
%
(
partition_amount
-
existing_partition_amount
))
if
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
):
# add new partitions
...
...
@@ -1092,7 +1093,7 @@ def do_format(conf):
logger
=
conf
.
logger
)
conf
.
logger
.
info
(
'Posting information to %r'
%
conf
.
master_url
)
computer
.
send
(
conf
)
conf
.
logger
.
info
(
'slap
format successfully prepared
computer.'
)
conf
.
logger
.
info
(
'slap
os successfully prepared the
computer.'
)
class
FormatConfig
(
object
):
...
...
@@ -1232,7 +1233,7 @@ class FormatConfig(object):
file_location
)
sys
.
exit
(
1
)
self
.
logger
.
info
(
"Started."
)
self
.
logger
.
debug
(
'Started.'
)
if
self
.
dry_run
:
self
.
logger
.
info
(
"Dry-run mode enabled."
)
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