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
9181210a
Commit
9181210a
authored
Jun 02, 2017
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: fixing tests
parent
2b90fc01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
slapos/format.py
slapos/format.py
+10
-8
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+8
-8
No files found.
slapos/format.py
View file @
9181210a
...
...
@@ -256,7 +256,7 @@ class CGroupManager(object):
self
.
software_gid
=
computer
.
software_gid
def
allowed
(
self
):
return
os
.
path
.
exists
(
"/sys/fs/cgroup/cpuset/cpuset.cpus"
)
:
return
os
.
path
.
exists
(
"/sys/fs/cgroup/cpuset/cpuset.cpus"
)
def
format
(
self
):
"""Build CGROUP tree to fit SlapOS needs.
...
...
@@ -408,10 +408,10 @@ class Computer(object):
self
.
tap_gateway_interface
=
tap_gateway_interface
# Used to be static attributes of the class object - didn't make sense (Marco again)
assert
instance_root
is
not
None
and
software_root
is
not
None
,
assert
instance_root
is
not
None
and
software_root
is
not
None
,
\
"Computer's instance_root and software_root must not be empty!"
self
.
software_root
=
instanc
e_root
self
.
instance_root
=
softwar
e_root
self
.
software_root
=
softwar
e_root
self
.
instance_root
=
instanc
e_root
self
.
instance_storage_home
=
instance_storage_home
# The following properties are updated on update() method
...
...
@@ -550,7 +550,7 @@ class Computer(object):
archive
.
writestr
(
saved_filename
,
xml_content
,
zipfile
.
ZIP_DEFLATED
)
@
classmethod
def
load
(
cls
,
path_to_xml
,
reference
,
ipv6_interface
,
tap_gateway_interface
def
load
(
cls
,
path_to_xml
,
reference
,
ipv6_interface
,
tap_gateway_interface
,
instance_root
=
None
,
software_root
=
None
):
"""
Create a computer object from a valid xml file.
...
...
@@ -758,6 +758,8 @@ class Computer(object):
partition
.
tap
.
ipv4_gateway
=
gateway_addr_dict
[
'addr'
]
partition
.
tap
.
ipv4_network
=
gateway_addr_dict
[
'network'
]
partition
.
tap
.
createRoutes
()
if
alter_network
and
partition
.
tun
is
not
None
:
# create TUN interface per partition as well
partition
.
tun
.
createWithOwner
(
owner
)
partition
.
tun
.
createRoutes
()
...
...
@@ -1219,9 +1221,9 @@ class Interface(object):
if
self
.
isBridge
():
callAndRead
([
'brctl'
,
'addif'
,
self
.
name
,
tap
.
name
])
else
:
self
.
logger
.
warning
(
"Interface slapos.cfg:interface_name={} is not a bridge. "
"TUN/TAP interface {} might not have internet connection."
""
.
format
(
self
.
name
,
tap
.
name
))
logger
.
warning
(
"Interface slapos.cfg:interface_name={} is not a bridge. "
"TUN/TAP interface {} might not have internet connection."
""
.
format
(
self
.
name
,
tap
.
name
))
def
_addSystemAddress
(
self
,
address
,
netmask
,
ipv6
=
True
):
"""Adds system address to interface
...
...
slapos/tests/slapformat.py
View file @
9181210a
...
...
@@ -325,12 +325,12 @@ class SlapformatMixin(unittest.TestCase):
class
TestComputer
(
SlapformatMixin
):
def
test_getAddress_empty_computer
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
)
computer
=
slapos
.
format
.
Computer
(
'computer'
,
instance_root
=
'/instance_root'
,
software_root
=
'software_root'
)
self
.
assertEqual
(
computer
.
getAddress
(),
{
'netmask'
:
None
,
'addr'
:
None
})
@
unittest
.
skip
(
"Not implemented"
)
def
test_construct_empty
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
)
computer
=
slapos
.
format
.
Computer
(
'computer'
,
instance_root
=
'/instance_root'
,
software_root
=
'software_root'
)
computer
.
format
()
@
unittest
.
skip
(
"Not implemented"
)
...
...
@@ -368,8 +368,9 @@ class TestComputer(SlapformatMixin):
"makedirs('/software_root', 493)"
,
"chmod('/software_root', 493)"
],
self
.
test_result
.
bucket
)
self
.
assertEqual
([
'ip addr list bridge'
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
assertEqualCommands
(
[
'ip addr list bridge'
],
self
.
fakeCallAndRead
.
external_command_list
)
@
unittest
.
skip
(
"Not implemented"
)
def
test_construct_empty_prepared_no_alter_network
(
self
):
...
...
@@ -462,12 +463,10 @@ class TestComputer(SlapformatMixin):
logger
=
self
.
logger
,
name
=
'bridge'
,
ipv4_local_network
=
'127.0.0.1/16'
),
partition_list
=
[
slapos
.
format
.
Partition
(
'partition'
,
'/part_path'
,
slapos
.
format
.
User
(
'testuser'
),
[],
tap
=
None
),
'partition'
,
'/part_path'
,
slapos
.
format
.
User
(
'testuser'
),
[],
tap
=
slapos
.
format
.
Tap
(
'tap'
)
),
])
global
USER_LIST
USER_LIST
=
[
'testuser'
]
partition
.
tap
=
slapos
.
format
.
Tap
(
'tap'
)
computer
.
partition_list
=
[
partition
]
global
INTERFACE_DICT
INTERFACE_DICT
[
'bridge'
]
=
{
socket
.
AF_INET
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
...
...
@@ -501,8 +500,9 @@ class TestComputer(SlapformatMixin):
computer
=
slapos
.
format
.
Computer
(
'computer'
,
instance_root
=
'/instance_root'
,
software_root
=
'/software_root'
,
tap_gateway_interface
=
'eth1'
,
interface
=
slapos
.
format
.
Interface
(
logger
=
self
.
logger
,
name
=
'iface'
,
ipv4_local_network
=
'127.0.0.1/16'
,
tap_gateway_interface
=
'eth1'
),
logger
=
self
.
logger
,
name
=
'iface'
,
ipv4_local_network
=
'127.0.0.1/16'
),
partition_list
=
[
slapos
.
format
.
Partition
(
'partition'
,
'/part_path'
,
slapos
.
format
.
User
(
'testuser'
),
[],
tap
=
None
),
...
...
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