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
Iliya Manolov
slapos.toolbox
Commits
1b3e0bc8
Commit
1b3e0bc8
authored
Aug 14, 2013
by
Cédric de Saint Martin
Committed by
Cédric Le Ninivin
Sep 12, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for not-ready-yet main kvm instances.
parent
15c0e377
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 @
1b3e0bc8
...
@@ -51,18 +51,39 @@ def setRandomKey(ip):
...
@@ -51,18 +51,39 @@ def setRandomKey(ip):
Set a random key that will be stored inside of the virtual hard drive.
Set a random key that will be stored inside of the virtual hard drive.
"""
"""
random_key
=
''
.
join
(
random
.
SystemRandom
().
sample
(
string
.
ascii_lowercase
,
20
))
random_key
=
''
.
join
(
random
.
SystemRandom
().
sample
(
string
.
ascii_lowercase
,
20
))
connection
=
urllib
.
urlopen
(
'http://%s:10080/set?key=%s'
%
(
ip
,
random_key
))
for
i
in
range
(
0
,
60
):
if
connection
.
getcode
()
is
not
200
:
connection
=
urllib
.
urlopen
(
'http://%s:10080/set?key=%s'
%
(
ip
,
random_key
))
raise
Exception
(
'Bad return code when setting key in main instance.'
)
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
return
random_key
def
fetchKey
(
ip
):
def
fetchKey
(
ip
):
"""
"""
Fetch the key that had been set on original virtual hard drive.
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,
If doesn't exist (503), fail. If other error: retry after a few minutes,
fail after XX (2?) hours.
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
,
def
runTestCase
(
server_url
,
key_file
,
cert_file
,
computer_id
,
partition_id
,
software
,
computer_id
,
partition_id
,
software
,
...
@@ -108,23 +129,12 @@ def runTestCase(server_url, key_file, cert_file,
...
@@ -108,23 +129,12 @@ def runTestCase(server_url, key_file, cert_file,
logger
.
info
(
'Waiting for new main instance to be ready...'
)
logger
.
info
(
'Waiting for new main instance to be ready...'
)
new_ip
=
None
new_ip
=
None
while
not
new_ip
or
new_ip
==
'None'
or
new_ip
==
ip
:
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
)
time
.
sleep
(
60
)
new_ip
=
fetchMainInstanceIP
(
partition
,
software
,
kvm_rootinstance_name
)
new_ip
=
fetchMainInstanceIP
(
partition
,
software
,
kvm_rootinstance_name
)
logger
.
info
(
'New IP of instance is %s'
%
new_ip
)
logger
.
info
(
'New IP of instance is %s'
%
new_ip
)
new_key
=
None
new_key
=
fetchKey
(
new_ip
)
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.'
)
logger
.
info
(
'Key on this new instance is %s'
%
new_key
)
logger
.
info
(
'Key on this new instance is %s'
%
new_key
)
# Compare with original key. If same: success.
# 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