Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
a530a20d
Commit
a530a20d
authored
May 08, 2012
by
John Giannelos
Browse files
Started fixing kamaki changes which broke snf-burnin
parent
a7e07d74
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/tools/burnin.py
View file @
a530a20d
...
...
@@ -53,7 +53,9 @@ from IPy import IP
from
multiprocessing
import
Process
,
Queue
from
random
import
choice
from
kamaki.client
import
Client
,
ClientError
from
kamaki.clients
import
ClientError
,
ComputeClient
,
CycladesClient
from
kamaki.config
import
Config
from
vncauthproxy.d3des
import
generate_response
as
d3des_generate_response
# Use backported unittest functionality if Python < 2.7
...
...
@@ -83,7 +85,10 @@ log.setLevel(logging.INFO)
class
UnauthorizedTestCase
(
unittest
.
TestCase
):
def
test_unauthorized_access
(
self
):
"""Test access without a valid token fails"""
c
=
Client
(
API
,
"123"
)
falseToken
=
'12345'
conf
=
Config
()
conf
.
set
(
'compute_token'
,
falseToken
)
with
self
.
assertRaises
(
ClientError
)
as
cm
:
c
.
list_servers
()
self
.
assertEqual
(
cm
.
exception
.
status
,
401
)
...
...
@@ -95,7 +100,10 @@ class ImagesTestCase(unittest.TestCase):
def
setUpClass
(
cls
):
"""Initialize kamaki, get (detailed) list of images"""
log
.
info
(
"Getting simple and detailed list of images"
)
cls
.
client
=
Client
(
API
,
TOKEN
)
conf
=
Config
()
conf
.
set
(
'compute_token'
,
TOKEN
)
cls
.
client
=
ComputeClient
(
conf
)
cls
.
images
=
cls
.
client
.
list_images
()
cls
.
dimages
=
cls
.
client
.
list_images
(
detail
=
True
)
...
...
@@ -120,7 +128,7 @@ class ImagesTestCase(unittest.TestCase):
def
test_005_image_metadata
(
self
):
"""Test every image has specific metadata defined"""
keys
=
frozenset
([
"
OS
"
,
"description"
,
"size"
])
keys
=
frozenset
([
"
os
"
,
"description"
,
"size"
])
for
i
in
self
.
dimages
:
self
.
assertTrue
(
keys
.
issubset
(
i
[
"metadata"
][
"values"
].
keys
()))
...
...
@@ -131,7 +139,10 @@ class FlavorsTestCase(unittest.TestCase):
def
setUpClass
(
cls
):
"""Initialize kamaki, get (detailed) list of flavors"""
log
.
info
(
"Getting simple and detailed list of flavors"
)
cls
.
client
=
Client
(
API
,
TOKEN
)
conf
=
Config
()
conf
.
set
(
'compute_token'
,
TOKEN
)
cls
.
client
=
ComputeClient
(
conf
)
cls
.
flavors
=
cls
.
client
.
list_flavors
()
cls
.
dflavors
=
cls
.
client
.
list_flavors
(
detail
=
True
)
...
...
@@ -172,7 +183,10 @@ class ServersTestCase(unittest.TestCase):
def
setUpClass
(
cls
):
"""Initialize kamaki, get (detailed) list of servers"""
log
.
info
(
"Getting simple and detailed list of servers"
)
cls
.
client
=
Client
(
API
,
TOKEN
)
conf
=
Config
()
conf
.
set
(
'compute_token'
,
TOKEN
)
cls
.
client
=
ComputeClient
(
conf
)
cls
.
servers
=
cls
.
client
.
list_servers
()
cls
.
dservers
=
cls
.
client
.
list_servers
(
detail
=
True
)
...
...
@@ -199,10 +213,15 @@ class SpawnServerTestCase(unittest.TestCase):
def
setUpClass
(
cls
):
"""Initialize a kamaki instance"""
log
.
info
(
"Spawning server for image `%s'"
,
cls
.
imagename
)
cls
.
client
=
Client
(
API
,
TOKEN
)
conf
=
Config
()
conf
.
set
(
'compute_token'
,
TOKEN
)
cls
.
client
=
ComputeClient
(
conf
)
def
_get_ipv4
(
self
,
server
):
"""Get the public IPv4 of a server from the detailed server info"""
details
=
public_addrs
=
filter
(
lambda
x
:
x
[
"id"
]
==
"public"
,
server
[
"addresses"
][
"values"
])
self
.
assertEqual
(
len
(
public_addrs
),
1
)
...
...
@@ -223,9 +242,9 @@ class SpawnServerTestCase(unittest.TestCase):
def
_connect_loginname
(
self
,
os
):
"""Return the login name for connections based on the server OS"""
if
os
in
(
"
u
buntu"
,
"
k
ubuntu"
,
"
f
edora"
):
if
os
in
(
"
U
buntu"
,
"
K
ubuntu"
,
"
F
edora"
):
return
"user"
elif
os
==
"windows"
:
elif
os
in
(
"windows"
,
"windows_alpha1"
)
:
return
"Administrator"
else
:
return
"root"
...
...
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