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
83f50f8a
Commit
83f50f8a
authored
Jan 23, 2012
by
Vincent Pelletier
Committed by
Romain Courteaud
Jan 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Silence a few pylint complaints.
parent
e6a071c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
+25
-10
slapos/format.py
slapos/format.py
+25
-10
No files found.
slapos/format.py
View file @
83f50f8a
...
@@ -157,8 +157,10 @@ def _getDict(instance):
...
@@ -157,8 +157,10 @@ def _getDict(instance):
class
Computer
:
class
Computer
:
"Object representing the computer"
"Object representing the computer"
instance_root
=
None
software_root
=
None
def
__init__
(
self
,
reference
,
bridge
=
None
,
addr
=
None
,
netmask
=
None
,
def
__init__
(
self
,
reference
,
bridge
=
None
,
addr
=
None
,
netmask
=
None
,
ipv6_interface
=
None
):
ipv6_interface
=
None
):
"""
"""
Attributes:
Attributes:
...
@@ -408,6 +410,7 @@ class Partition:
...
@@ -408,6 +410,7 @@ class Partition:
class
User
:
class
User
:
"User: represent and manipulate a user on the system."
"User: represent and manipulate a user on the system."
path
=
None
def
__init__
(
self
,
user_name
,
additional_group_list
=
None
):
def
__init__
(
self
,
user_name
,
additional_group_list
=
None
):
"""
"""
...
@@ -578,7 +581,7 @@ class Bridge:
...
@@ -578,7 +581,7 @@ class Bridge:
# Attach to TAP network interface, only if the bridge interface does not
# Attach to TAP network interface, only if the bridge interface does not
# report carrier
# report carrier
returncode
,
result
=
callAndRead
([
'ip'
,
'addr'
,
'list'
,
self
.
name
])
_
,
result
=
callAndRead
([
'ip'
,
'addr'
,
'list'
,
self
.
name
])
self
.
attach_to_tap
=
'DOWN'
in
result
.
split
(
'
\
n
'
,
1
)[
0
]
self
.
attach_to_tap
=
'DOWN'
in
result
.
split
(
'
\
n
'
,
1
)[
0
]
def
__getinitargs__
(
self
):
def
__getinitargs__
(
self
):
...
@@ -617,7 +620,7 @@ class Bridge:
...
@@ -617,7 +620,7 @@ class Bridge:
def
getInterfaceList
(
self
):
def
getInterfaceList
(
self
):
"""Returns list of interfaces already present on bridge"""
"""Returns list of interfaces already present on bridge"""
interface_list
=
[]
interface_list
=
[]
returncode
,
result
=
callAndRead
([
'brctl'
,
'show'
])
_
,
result
=
callAndRead
([
'brctl'
,
'show'
])
in_bridge
=
False
in_bridge
=
False
for
line
in
result
.
split
(
'
\
n
'
):
for
line
in
result
.
split
(
'
\
n
'
):
if
len
(
line
.
split
())
>
1
:
if
len
(
line
.
split
())
>
1
:
...
@@ -667,7 +670,7 @@ class Bridge:
...
@@ -667,7 +670,7 @@ class Bridge:
if
interface
!=
interface_name
:
if
interface
!=
interface_name
:
address_dict
=
netifaces
.
ifaddresses
(
interface
)
address_dict
=
netifaces
.
ifaddresses
(
interface
)
if
af
in
address_dict
:
if
af
in
address_dict
:
if
address
in
[
q
[
'addr'
].
split
(
'%'
)[
0
]
for
q
in
address_dict
[
af
]]:
if
address
in
[
q
[
'addr'
].
split
(
'%'
)[
0
]
for
q
in
address_dict
[
af
]]:
return
False
return
False
if
not
af
in
netifaces
.
ifaddresses
(
interface_name
)
or
not
address
in
[
q
[
'addr'
].
split
(
'%'
)[
0
]
for
q
in
netifaces
.
ifaddresses
(
interface_name
)[
af
]]:
if
not
af
in
netifaces
.
ifaddresses
(
interface_name
)
or
not
address
in
[
q
[
'addr'
].
split
(
'%'
)[
0
]
for
q
in
netifaces
.
ifaddresses
(
interface_name
)[
af
]]:
...
@@ -676,7 +679,7 @@ class Bridge:
...
@@ -676,7 +679,7 @@ class Bridge:
# wait few moments
# wait few moments
time
.
sleep
(
2
)
time
.
sleep
(
2
)
# check existence on interface
# check existence on interface
returncode
,
result
=
callAndRead
([
'ip'
,
'addr'
,
'list'
,
interface_name
])
_
,
result
=
callAndRead
([
'ip'
,
'addr'
,
'list'
,
interface_name
])
for
l
in
result
.
split
(
'
\
n
'
):
for
l
in
result
.
split
(
'
\
n
'
):
if
address
in
l
:
if
address
in
l
:
if
'tentative'
in
l
:
if
'tentative'
in
l
:
...
@@ -711,10 +714,10 @@ class Bridge:
...
@@ -711,10 +714,10 @@ class Bridge:
if
addr
is
None
:
if
addr
is
None
:
return
self
.
_generateRandomIPv4Address
(
netmask
)
return
self
.
_generateRandomIPv4Address
(
netmask
)
elif
dict
(
addr
=
addr
,
netmask
=
netmask
)
not
in
local_address_list
:
elif
dict
(
addr
=
addr
,
netmask
=
netmask
)
not
in
local_address_list
:
if
self
.
_addSystemAddress
(
addr
,
netmask
,
False
):
if
self
.
_addSystemAddress
(
addr
,
netmask
,
False
):
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
else
:
else
:
return
self
.
_generateRandomIPv4Address
(
netmask
)
return
self
.
_generateRandomIPv4Address
(
netmask
)
else
:
else
:
# confirmed to be configured
# confirmed to be configured
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
...
@@ -967,7 +970,19 @@ def run(config):
...
@@ -967,7 +970,19 @@ def run(config):
raise
raise
class
Config
:
class
Config
:
def
checkRequiredBinary
(
self
,
binary_list
):
key_file
=
None
cert_file
=
None
alter_network
=
None
alter_user
=
None
computer_xml
=
None
logger
=
None
log_file
=
None
verbose
=
None
dry_run
=
None
console
=
None
@
staticmethod
def
checkRequiredBinary
(
binary_list
):
missing_binary_list
=
[]
missing_binary_list
=
[]
for
b
in
binary_list
:
for
b
in
binary_list
:
try
:
try
:
...
...
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