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
Labels
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
feebb113
Commit
feebb113
authored
Feb 01, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split mammoth run() function
parent
77b561ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
93 deletions
+111
-93
slapos/format.py
slapos/format.py
+111
-93
No files found.
slapos/format.py
View file @
feebb113
...
...
@@ -935,15 +935,13 @@ class Parser(OptionParser):
return
options
,
args
[
0
]
def
run
(
config
):
# Define the computer
if
config
.
input_definition_file
:
filepath
=
os
.
path
.
abspath
(
config
.
input_definition_file
)
config
.
logger
.
info
(
'Using definition file %r'
%
filepath
)
def
parse_computer_definition
(
config
,
definition_path
):
config
.
logger
.
info
(
'Using definition file %r'
%
definition_path
)
computer_definition
=
ConfigParser
.
RawConfigParser
({
'software_user'
:
'slapsoft'
,
})
computer_definition
.
read
(
file
path
)
computer_definition
.
read
(
definition_
path
)
interface
=
None
address
=
None
netmask
=
None
...
...
@@ -980,18 +978,21 @@ def run(config):
tap
=
tap
,
))
computer
.
partition_list
=
partition_list
else
:
# no definition file, figure out computer
if
os
.
path
.
exists
(
config
.
computer_xml
):
config
.
logger
.
info
(
'Loading previous computer data from %r'
%
(
config
.
computer_xml
,
))
computer
=
Computer
.
load
(
config
.
computer_xml
,
reference
=
config
.
computer_id
,
ipv6_interface
=
config
.
ipv6_interface
)
return
computer
def
parse_computer_xml
(
config
,
xml_path
):
if
os
.
path
.
exists
(
xml_path
):
config
.
logger
.
info
(
'Loading previous computer data from %r'
%
xml_path
)
computer
=
Computer
.
load
(
xml_path
,
reference
=
config
.
computer_id
,
ipv6_interface
=
config
.
ipv6_interface
)
# Connect to the interface defined by the configuration
computer
.
interface
=
Interface
(
config
.
interface_name
,
config
.
ipv4_local_network
,
config
.
ipv6_interface
)
else
:
# If no pre-existent configuration found, creating
a new computer object
# If no pre-existent configuration found, create
a new computer object
config
.
logger
.
warning
(
'Creating new data computer with id %r'
%
(
config
.
computer_id
,
))
computer
=
Computer
(
...
...
@@ -1030,6 +1031,16 @@ def run(config):
tap
=
tap
,
))
return
computer
def
run
(
config
):
if
config
.
input_definition_file
:
computer
=
parse_computer_definition
(
config
,
config
.
input_definition_file
)
else
:
# no definition file, figure out computer
computer
=
parse_computer_xml
(
config
,
config
.
computer_xml
)
computer
.
instance_root
=
config
.
instance_root
computer
.
software_root
=
config
.
software_root
config
.
logger
.
info
(
'Updating computer'
)
...
...
@@ -1056,9 +1067,9 @@ def run(config):
computer_definition
.
set
(
section
,
'network_interface'
,
partition
.
tap
.
name
)
computer_definition
.
set
(
section
,
'pathname'
,
partition
.
reference
)
partition_number
+=
1
filepath
=
os
.
path
.
abspath
(
config
.
output_definition_file
)
co
mputer_definition
.
write
(
open
(
filepath
,
'w'
)
)
config
.
logger
.
info
(
'Stored computer definition in %r'
%
filepath
)
computer_definition
.
write
(
open
(
config
.
output_definition_file
,
'w'
)
)
co
nfig
.
logger
.
info
(
'Stored computer definition in %r'
%
config
.
output_definition_file
)
computer
.
construct
(
alter_user
=
config
.
alter_user
,
alter_network
=
config
.
alter_network
,
create_tap
=
config
.
create_tap
)
...
...
@@ -1181,6 +1192,7 @@ class Config(object):
self
.
checkRequiredBinary
([[
'tunctl'
,
'-d'
]])
if
self
.
alter_network
:
self
.
checkRequiredBinary
([
'ip'
])
# Required, even for dry run
if
self
.
alter_network
and
self
.
create_tap
:
self
.
checkRequiredBinary
([
'brctl'
])
...
...
@@ -1237,6 +1249,12 @@ class Config(object):
# Calculate path once
self
.
computer_xml
=
os
.
path
.
abspath
(
self
.
computer_xml
)
if
self
.
input_definition_file
:
self
.
input_definition_file
=
os
.
path
.
abspath
(
self
.
input_definition_file
)
if
self
.
output_definition_file
:
self
.
output_definition_file
=
os
.
path
.
abspath
(
self
.
output_definition_file
)
def
tracing_monkeypatch
(
config
):
...
...
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