Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VeRDi
concerto
Commits
74f0e70a
Commit
74f0e70a
authored
Oct 23, 2019
by
Maverick Chardet
Browse files
Simplified reserve_g5k file
Fixed wrong variable name in ssh scalability test
parent
7ebea4df
Changes
2
Hide whitespace changes
Inline
Side-by-side
experiment_utilities/reserve_g5k.py
View file @
74f0e70a
#!/usr/bin/env python
import
logging
import
time
import
yaml
class
G5kReservation
:
@
staticmethod
def
_g5k_deploy
(
g5k_config
,
force_deploy
=
False
,
**
kwargs
):
def
_g5k_deploy
(
self
,
g5k_config
,
force_deploy
=
False
):
from
enoslib.infra.enos_g5k.provider
import
G5k
from
enoslib.infra.enos_g5k.configuration
import
Configuration
provider
=
G5k
(
Configuration
.
from_dictionnary
(
g5k_config
))
roles
,
networks
=
provider
.
init
(
force_deploy
=
force_deploy
)
env
=
{
'roles'
:
roles
,
'networks'
:
networks
}
logging
.
info
(
'Wait 30 seconds for iface to be ready...'
)
time
.
sleep
(
30
)
return
env
,
provider
@
staticmethod
def
_allocate
(
conf
,
provider
=
'g5k'
,
force_deployment
=
False
):
env
=
{}
self
.
_g5k_job
=
G5k
(
Configuration
.
from_dictionnary
(
g5k_config
))
self
.
_roles
,
self
.
_networks
=
self
.
_g5k_job
.
init
(
force_deploy
=
force_deploy
)
# logging.info('Wait 30 seconds for iface to be ready...')
# time.sleep(30)
def
_allocate
(
self
,
conf
,
force_deployment
=
False
):
if
isinstance
(
conf
,
str
):
# Get the config object from a yaml file
with
open
(
conf
)
as
f
:
config
=
yaml
.
load
(
f
)
elif
isinstance
(
conf
,
dict
):
# Get the config object from a dict
config
=
conf
else
:
# Data format error
raise
Exception
(
'conf is type {!r} while it should be a yaml file or a dict'
.
format
(
type
(
conf
)))
env
[
'db'
]
=
config
.
get
(
'database'
,
'mariadb'
)
env
[
'monitoring'
]
=
config
.
get
(
'monitoring'
,
False
)
env
[
'config'
]
=
config
self
.
_config
=
config
# Claim resources on Grid'5000
if
not
(
provider
==
'g5k'
and
'g5k'
in
config
):
raise
Exception
(
'The provider {!r} is not supported or it lacks a configuration'
.
format
(
provider
))
env
[
'provider'
]
=
'g5k'
updated_env
,
g5k_job
=
G5kReservation
.
_g5k_deploy
(
config
[
'g5k'
],
force_deploy
=
force_deployment
)
env
.
update
(
updated_env
)
return
env
,
g5k_job
if
'g5k'
not
in
config
:
raise
Exception
(
"'g5k' key missing in configuration!"
)
self
.
_g5k_deploy
(
config
[
'g5k'
],
force_deploy
=
force_deployment
)
@
staticmethod
def
_get_ip
(
g5k_address
):
from
subprocess
import
run
,
PIPE
ip
=
run
(
"dig +short %s"
%
g5k_address
,
shell
=
True
,
stdout
=
PIPE
).
stdout
.
decode
(
'utf-8'
).
strip
(
'
\r\n
'
)
return
ip
@
staticmethod
...
...
@@ -57,23 +39,23 @@ class G5kReservation:
return
{
"address"
:
g5k_address
,
"ip"
:
G5kReservation
.
_get_ip
(
g5k_address
)}
def
__init__
(
self
,
conf
,
force_deployment
=
True
,
destroy
=
False
):
from
execo.action
import
Put
,
Get
,
Remote
from
execo.host
import
Host
from
json
import
dump
self
.
_env
,
self
.
_g5k_job
=
G5kReservation
.
_allocate
(
conf
,
'g5k'
,
force_deployment
)
self
.
_config
=
None
self
.
_g5k_job
=
None
self
.
_roles
=
None
self
.
_networks
=
None
self
.
_destroy
=
destroy
self
.
_allocate
(
conf
,
force_deployment
)
self
.
_alive
=
True
def
get_roles
(
self
):
if
not
self
.
_alive
:
raise
Exception
(
"G5k reservation not alive!"
)
return
self
.
_
env
[
'
roles
'
]
.
keys
()
return
self
.
_roles
.
keys
()
def
get_hosts_info
(
self
,
role
):
if
not
self
.
_alive
:
raise
Exception
(
"G5k reservation not alive!"
)
return
[
G5kReservation
.
_get_host_dict
(
host
.
address
)
for
host
in
self
.
_
env
[
'
roles
'
]
[
role
]]
return
[
G5kReservation
.
_get_host_dict
(
host
.
address
)
for
host
in
self
.
_roles
[
role
]]
def
terminate
(
self
):
if
not
self
.
_alive
:
...
...
tests/ssh_scalability/reserve_and_test.py
View file @
74f0e70a
...
...
@@ -16,7 +16,7 @@ EXP_DIR = '%s/%s' % (ROOT_DIR, EXP_DIR_IN_GIT)
DEFAULT_WORKING_DIRECTORY
=
'.'
def
run_experiment
(
list_nb_remote_ssh
,
nb_repeat
,
conf
,
working_directory
=
DEFAULT_WORKING_DIRECTORY
,
def
run_experiment
(
list_nb_remote_ssh
,
nb_repeat
s
,
conf
,
working_directory
=
DEFAULT_WORKING_DIRECTORY
,
force_deployment
=
True
,
destroy
=
False
):
from
json
import
dump
...
...
@@ -29,7 +29,7 @@ def run_experiment(list_nb_remote_ssh, nb_repeat, conf, working_directory=DEFAUL
"remote_hosts"
:
remote_machines
,
"concerto_host"
:
concerto_machine
,
"list_nb_remote_ssh"
:
list_nb_remote_ssh
,
"nb_repeat"
:
nb_repeat
"nb_repeat
s
"
:
nb_repeat
s
}
with
open
(
working_directory
+
"/concerto_config.json"
,
"w"
)
as
concerto_config_file
:
dump
(
concerto_config
,
concerto_config_file
)
...
...
@@ -62,7 +62,7 @@ def run_experiment(list_nb_remote_ssh, nb_repeat, conf, working_directory=DEFAUL
)
def
perform_experiment
(
list_nb_remote_ssh
,
nb_repeat
):
def
perform_experiment
(
list_nb_remote_ssh
,
nb_repeat
s
):
import
yaml
from
os
import
makedirs
...
...
@@ -76,7 +76,7 @@ def perform_experiment(list_nb_remote_ssh, nb_repeat):
with
open
(
wd
+
'/g5k_config.yaml'
,
'w'
)
as
g5k_config_file
:
yaml
.
dump
(
conf
,
g5k_config_file
)
run_experiment
(
list_nb_remote_ssh
,
nb_repeat
,
conf
,
wd
)
run_experiment
(
list_nb_remote_ssh
,
nb_repeat
s
,
conf
,
wd
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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