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
18
Merge Requests
18
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
28d88471
Commit
28d88471
authored
Feb 01, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor style, indentation
parent
9ebe136f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
26 deletions
+20
-26
slapos/format.py
slapos/format.py
+20
-26
No files found.
slapos/format.py
View file @
28d88471
...
@@ -77,11 +77,9 @@ class OS(object):
...
@@ -77,11 +77,9 @@ class OS(object):
def
wrapper
(
*
args
,
**
kw
):
def
wrapper
(
*
args
,
**
kw
):
if
self
.
_verbose
:
if
self
.
_verbose
:
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
,
self
.
_logger
.
debug
(
'%s(%s)'
%
(
name
,
', '
.
join
(
arg_list
)))
', '
.
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
)
...
@@ -105,7 +103,7 @@ class NoAddressOnInterface(Exception):
...
@@ -105,7 +103,7 @@ class NoAddressOnInterface(Exception):
def
__init__
(
self
,
interface
):
def
__init__
(
self
,
interface
):
super
(
NoAddressOnInterface
,
self
).
__init__
(
super
(
NoAddressOnInterface
,
self
).
__init__
(
'No IPv6 found on interface %s to construct IPv6 with.'
%
(
interface
,
)
'No IPv6 found on interface %s to construct IPv6 with.'
%
interface
)
)
...
@@ -130,7 +128,7 @@ def callAndRead(argument_list, raise_on_error=True):
...
@@ -130,7 +128,7 @@ def callAndRead(argument_list, raise_on_error=True):
result
=
popen
.
communicate
()[
0
]
result
=
popen
.
communicate
()[
0
]
if
raise_on_error
and
popen
.
returncode
!=
0
:
if
raise_on_error
and
popen
.
returncode
!=
0
:
raise
ValueError
(
'Issue while invoking %r, result was:
\
n
%s'
%
(
raise
ValueError
(
'Issue while invoking %r, result was:
\
n
%s'
%
(
argument_list
,
result
))
argument_list
,
result
))
return
popen
.
returncode
,
result
return
popen
.
returncode
,
result
...
@@ -238,8 +236,7 @@ class Computer(object):
...
@@ -238,8 +236,7 @@ class Computer(object):
return
self
.
interface
.
addAddr
()
return
self
.
interface
.
addAddr
()
# Can't find address
# Can't find address
raise
NoAddressOnInterface
(
'No valid IPv6 found on %s.'
%
raise
NoAddressOnInterface
(
'No valid IPv6 found on %s.'
%
self
.
interface
.
name
)
self
.
interface
.
name
)
def
send
(
self
,
config
):
def
send
(
self
,
config
):
"""
"""
...
@@ -754,7 +751,8 @@ class Interface(object):
...
@@ -754,7 +751,8 @@ class Interface(object):
if
not
af
in
netifaces
.
ifaddresses
(
interface_name
)
\
if
not
af
in
netifaces
.
ifaddresses
(
interface_name
)
\
or
not
address
in
[
q
[
'addr'
].
split
(
'%'
)[
0
]
or
not
address
in
[
q
[
'addr'
].
split
(
'%'
)[
0
]
for
q
in
netifaces
.
ifaddresses
(
interface_name
)[
af
]]:
for
q
in
netifaces
.
ifaddresses
(
interface_name
)[
af
]
]:
# add an address
# add an address
callAndRead
([
'ip'
,
'addr'
,
'add'
,
address_string
,
'dev'
,
interface_name
])
callAndRead
([
'ip'
,
'addr'
,
'add'
,
address_string
,
'dev'
,
interface_name
])
...
@@ -770,8 +768,7 @@ class Interface(object):
...
@@ -770,8 +768,7 @@ class Interface(object):
if
address
in
l
:
if
address
in
l
:
if
'tentative'
in
l
:
if
'tentative'
in
l
:
# duplicate, remove
# duplicate, remove
callAndRead
([
'ip'
,
'addr'
,
'del'
,
address_string
,
'dev'
,
callAndRead
([
'ip'
,
'addr'
,
'del'
,
address_string
,
'dev'
,
interface_name
])
interface_name
])
return
False
return
False
# found and clean
# found and clean
return
True
return
True
...
@@ -951,8 +948,7 @@ def parse_computer_definition(config, definition_path):
...
@@ -951,8 +948,7 @@ def parse_computer_definition(config, definition_path):
address
=
None
address
=
None
netmask
=
None
netmask
=
None
if
computer_definition
.
has_option
(
'computer'
,
'address'
):
if
computer_definition
.
has_option
(
'computer'
,
'address'
):
address
,
netmask
=
computer_definition
.
get
(
'computer'
,
address
,
netmask
=
computer_definition
.
get
(
'computer'
,
'address'
).
split
(
'/'
)
'address'
).
split
(
'/'
)
if
config
.
alter_network
and
config
.
interface_name
is
not
None
\
if
config
.
alter_network
and
config
.
interface_name
is
not
None
\
and
config
.
ipv4_local_network
is
not
None
:
and
config
.
ipv4_local_network
is
not
None
:
interface
=
Interface
(
config
.
interface_name
,
config
.
ipv4_local_network
,
interface
=
Interface
(
config
.
interface_name
,
config
.
ipv4_local_network
,
...
@@ -974,19 +970,17 @@ def parse_computer_definition(config, definition_path):
...
@@ -974,19 +970,17 @@ def parse_computer_definition(config, definition_path):
address
,
netmask
=
a
.
split
(
'/'
)
address
,
netmask
=
a
.
split
(
'/'
)
address_list
.
append
(
dict
(
addr
=
address
,
netmask
=
netmask
))
address_list
.
append
(
dict
(
addr
=
address
,
netmask
=
netmask
))
tap
=
Tap
(
computer_definition
.
get
(
section
,
'network_interface'
))
tap
=
Tap
(
computer_definition
.
get
(
section
,
'network_interface'
))
partition_list
.
append
(
Partition
(
reference
=
computer_definition
.
get
(
partition
=
Partition
(
reference
=
computer_definition
.
get
(
section
,
'pathname'
),
section
,
'pathname'
),
path
=
os
.
path
.
join
(
config
.
instance_root
,
path
=
os
.
path
.
join
(
config
.
instance_root
,
computer_definition
.
get
(
computer_definition
.
get
(
section
,
'pathname'
)),
section
,
'pathname'
)),
user
=
user
,
user
=
user
,
address_list
=
address_list
,
address_list
=
address_list
,
tap
=
tap
)
tap
=
tap
,
partition_list
.
append
(
partition
)
))
computer
.
partition_list
=
partition_list
computer
.
partition_list
=
partition_list
return
computer
return
computer
def
parse_computer_xml
(
config
,
xml_path
):
def
parse_computer_xml
(
config
,
xml_path
):
if
os
.
path
.
exists
(
xml_path
):
if
os
.
path
.
exists
(
xml_path
):
config
.
logger
.
info
(
'Loading previous computer data from %r'
%
xml_path
)
config
.
logger
.
info
(
'Loading previous computer data from %r'
%
xml_path
)
...
@@ -998,8 +992,7 @@ def parse_computer_xml(config, xml_path):
...
@@ -998,8 +992,7 @@ def parse_computer_xml(config, xml_path):
config
.
ipv6_interface
)
config
.
ipv6_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
config
.
logger
.
warning
(
'Creating new data computer with id %r'
%
(
config
.
logger
.
warning
(
'Creating new data computer with id %r'
%
config
.
computer_id
)
config
.
computer_id
,
))
computer
=
Computer
(
computer
=
Computer
(
reference
=
config
.
computer_id
,
reference
=
config
.
computer_id
,
interface
=
Interface
(
config
.
interface_name
,
config
.
ipv4_local_network
,
interface
=
Interface
(
config
.
interface_name
,
config
.
ipv4_local_network
,
...
@@ -1078,7 +1071,8 @@ def run(config):
...
@@ -1078,7 +1071,8 @@ def run(config):
write_computer_definition
(
config
,
computer
)
write_computer_definition
(
config
,
computer
)
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
)
# Dumping and sending to the erp5 the current configuration
# Dumping and sending to the erp5 the current configuration
if
not
config
.
dry_run
:
if
not
config
.
dry_run
:
...
...
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