Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Łukasz Nowak
slapos.toolbox
Commits
52feb940
Commit
52feb940
authored
Aug 14, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for not-ready-yet main kvm instances.
parent
ef40d960
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
17 deletions
+27
-17
slapos/runkvmresiliencytestsuite/kvmresiliencytestsuite.py
slapos/runkvmresiliencytestsuite/kvmresiliencytestsuite.py
+27
-17
No files found.
slapos/runkvmresiliencytestsuite/kvmresiliencytestsuite.py
View file @
52feb940
...
...
@@ -51,18 +51,39 @@ def setRandomKey(ip):
Set a random key that will be stored inside of the virtual hard drive.
"""
random_key
=
''
.
join
(
random
.
SystemRandom
().
sample
(
string
.
ascii_lowercase
,
20
))
connection
=
urllib
.
urlopen
(
'http://%s:10080/set?key=%s'
%
(
ip
,
random_key
))
if
connection
.
getcode
()
is
not
200
:
raise
Exception
(
'Bad return code when setting key in main instance.'
)
for
i
in
range
(
0
,
60
):
connection
=
urllib
.
urlopen
(
'http://%s:10080/set?key=%s'
%
(
ip
,
random_key
))
if
connection
.
getcode
()
is
200
:
break
else
:
logger
.
info
(
'Impossible to connect to virtual machine to set key. sleeping...'
)
time
.
sleep
(
60
)
if
i
is
59
:
raise
Exception
(
'Bad return code when setting key in main instance, after trying for 60 minutes.'
)
return
random_key
def
fetchKey
(
ip
):
"""
Fetch the key that had been set on original virtual hard drive.
If doesn't exist (503), fail. If other error: retry after a few minutes,
fail after XX (2?) hours.
"""
return
urllib
.
urlopen
(
'http://%s:10080/get'
%
ip
).
read
().
strip
()
new_key
=
None
for
i
in
range
(
0
,
10
):
try
:
new_key
=
urllib
.
urlopen
(
'http://%s:10080/get'
%
ip
).
read
().
strip
()
break
except
IOError
:
logger
.
error
(
'Server in new KVM does not answer.'
)
time
.
sleep
(
60
)
if
not
new_key
:
raise
Exception
(
'Server in new KVM does not answer for too long.'
)
return
new_key
def
runTestCase
(
server_url
,
key_file
,
cert_file
,
computer_id
,
partition_id
,
software
,
...
...
@@ -108,23 +129,12 @@ def runTestCase(server_url, key_file, cert_file,
logger
.
info
(
'Waiting for new main instance to be ready...'
)
new_ip
=
None
while
not
new_ip
or
new_ip
==
'None'
or
new_ip
==
ip
:
logger
.
info
(
'Not ready yet.
New
IP is %s'
%
new_ip
)
logger
.
info
(
'Not ready yet.
SlapOS says main
IP is %s'
%
new_ip
)
time
.
sleep
(
60
)
new_ip
=
fetchMainInstanceIP
(
partition
,
software
,
kvm_rootinstance_name
)
logger
.
info
(
'New IP of instance is %s'
%
new_ip
)
new_key
=
None
for
i
in
range
(
0
,
10
):
try
:
new_key
=
fetchKey
(
new_ip
)
break
except
IOError
:
logger
.
error
(
'Server in new KVM does not answer.'
)
time
.
sleep
(
60
)
if
not
new_key
:
raise
Exception
(
'Server in new KVM does not answer for too long.'
)
new_key
=
fetchKey
(
new_ip
)
logger
.
info
(
'Key on this new instance is %s'
%
new_key
)
# Compare with original key. If same: success.
...
...
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