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
Arnaud Véron
slapos.core
Commits
55314ef1
Commit
55314ef1
authored
Jul 24, 2023
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos/testing: Add partition info utilities
parent
e3cc3fec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
slapos/testing/testcase.py
slapos/testing/testcase.py
+33
-0
No files found.
slapos/testing/testcase.py
View file @
55314ef1
...
...
@@ -32,21 +32,27 @@ import glob
import
logging
import
os
import
shutil
import
sqlite3
import
unittest
import
warnings
from
six.moves.urllib.parse
import
urlparse
from
netaddr
import
valid_ipv6
from
.utils
import
getPortFromPath
from
.utils
import
ManagedResource
from
..slap.standalone
import
StandaloneSlapOS
from
..slap.standalone
import
SlapOSNodeCommandError
from
..slap.standalone
import
PathTooDeepError
from
..util
import
mkdir_p
from
..slap
import
ComputerPartition
from
.check_software
import
checkSoftware
from
..proxy.db_version
import
DB_VERSION
try
:
from
typing
import
Iterable
,
Tuple
,
Callable
,
Type
,
Dict
,
List
,
Optional
,
TypeVar
ManagedResourceType
=
TypeVar
(
"ManagedResourceType"
,
bound
=
ManagedResource
)
...
...
@@ -410,6 +416,10 @@ class SlapOSInstanceTestCase(unittest.TestCase):
cls
.
computer_partition_root_path
=
os
.
path
.
join
(
cls
.
slap
.
_instance_root
,
cls
.
computer_partition
.
getId
())
# the ipv6 of the instance
cls
.
computer_partition_ipv6_address
=
cls
.
getPartitionIPv6
(
cls
.
computer_partition
.
getId
())
@
classmethod
@
contextlib
.
contextmanager
def
_snapshotManager
(
cls
,
snapshot_name
):
...
...
@@ -643,3 +653,26 @@ class SlapOSInstanceTestCase(unittest.TestCase):
partition_reference
=
cls
.
default_partition_reference
,
partition_parameter_kw
=
cls
.
_instance_parameter_dict
,
state
=
state
)
@
classmethod
def
getPartitionId
(
cls
,
instance_name
):
query
=
"SELECT reference FROM partition%s WHERE partition_reference=?"
%
DB_VERSION
with
sqlite3
.
connect
(
os
.
path
.
join
(
cls
.
_base_directory
,
'var/proxy.db'
,
))
as
db
:
return
db
.
execute
(
query
,
(
instance_name
,)).
fetchall
()[
0
][
0
]
@
classmethod
def
getPartitionIPv6
(
cls
,
partition_id
):
query
=
"SELECT address FROM partition_network%s WHERE partition_reference=?"
%
DB_VERSION
with
sqlite3
.
connect
(
os
.
path
.
join
(
cls
.
_base_directory
,
'var/proxy.db'
,
))
as
db
:
rows
=
db
.
execute
(
query
,
(
partition_id
,)).
fetchall
()
# do not assume the partition's IPv6 address is the second one,
# instead find the first address that is IPv6
for
(
address
,)
in
rows
:
if
valid_ipv6
(
address
):
return
address
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