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
Léo-Paul Géneau
slapos.core
Commits
9ebe136f
Commit
9ebe136f
authored
Feb 01, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extracted write_computer_definition()
parent
c8c8f1b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
slapos/format.py
slapos/format.py
+22
-20
No files found.
slapos/format.py
View file @
9ebe136f
...
@@ -1039,6 +1039,27 @@ def parse_computer_xml(config, xml_path):
...
@@ -1039,6 +1039,27 @@ def parse_computer_xml(config, xml_path):
return
computer
return
computer
def
write_computer_definition
(
config
,
computer
):
computer_definition
=
ConfigParser
.
RawConfigParser
()
computer_definition
.
add_section
(
'computer'
)
if
computer
.
address
is
not
None
and
computer
.
netmask
is
not
None
:
computer_definition
.
set
(
'computer'
,
'address'
,
'/'
.
join
(
[
computer
.
address
,
computer
.
netmask
]))
for
partition_number
,
partition
in
enumerate
(
computer
.
partition_list
):
section
=
'partition_%s'
%
partition_number
computer_definition
.
add_section
(
section
)
address_list
=
[]
for
address
in
partition
.
address_list
:
address_list
.
append
(
'/'
.
join
([
address
[
'addr'
],
address
[
'netmask'
]]))
computer_definition
.
set
(
section
,
'address'
,
' '
.
join
(
address_list
))
computer_definition
.
set
(
section
,
'user'
,
partition
.
user
.
name
)
computer_definition
.
set
(
section
,
'user'
,
partition
.
user
.
name
)
computer_definition
.
set
(
section
,
'network_interface'
,
partition
.
tap
.
name
)
computer_definition
.
set
(
section
,
'pathname'
,
partition
.
reference
)
computer_definition
.
write
(
open
(
config
.
output_definition_file
,
'w'
))
config
.
logger
.
info
(
'Stored computer definition in %r'
%
config
.
output_definition_file
)
def
run
(
config
):
def
run
(
config
):
if
config
.
input_definition_file
:
if
config
.
input_definition_file
:
computer
=
parse_computer_definition
(
config
,
config
.
input_definition_file
)
computer
=
parse_computer_definition
(
config
,
config
.
input_definition_file
)
...
@@ -1054,26 +1075,7 @@ def run(config):
...
@@ -1054,26 +1075,7 @@ def run(config):
computer
.
netmask
=
address
[
'netmask'
]
computer
.
netmask
=
address
[
'netmask'
]
if
config
.
output_definition_file
:
if
config
.
output_definition_file
:
computer_definition
=
ConfigParser
.
RawConfigParser
()
write_computer_definition
(
config
,
computer
)
computer_definition
.
add_section
(
'computer'
)
if
computer
.
address
is
not
None
and
computer
.
netmask
is
not
None
:
computer_definition
.
set
(
'computer'
,
'address'
,
'/'
.
join
(
[
computer
.
address
,
computer
.
netmask
]))
partition_number
=
0
for
partition
in
computer
.
partition_list
:
section
=
'partition_%s'
%
partition_number
computer_definition
.
add_section
(
section
)
address_list
=
[]
for
address
in
partition
.
address_list
:
address_list
.
append
(
'/'
.
join
([
address
[
'addr'
],
address
[
'netmask'
]]))
computer_definition
.
set
(
section
,
'address'
,
' '
.
join
(
address_list
))
computer_definition
.
set
(
section
,
'user'
,
partition
.
user
.
name
)
computer_definition
.
set
(
section
,
'user'
,
partition
.
user
.
name
)
computer_definition
.
set
(
section
,
'network_interface'
,
partition
.
tap
.
name
)
computer_definition
.
set
(
section
,
'pathname'
,
partition
.
reference
)
partition_number
+=
1
computer_definition
.
write
(
open
(
config
.
output_definition_file
,
'w'
))
config
.
logger
.
info
(
'Stored computer definition in %r'
%
config
.
output_definition_file
)
computer
.
construct
(
alter_user
=
config
.
alter_user
,
computer
.
construct
(
alter_user
=
config
.
alter_user
,
alter_network
=
config
.
alter_network
,
create_tap
=
config
.
create_tap
)
alter_network
=
config
.
alter_network
,
create_tap
=
config
.
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