aboutsummaryrefslogtreecommitdiff
path: root/rumba/prototypes/irati.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-04-14 17:52:56 +0200
committerMarco Capitani <m.capitani@nextworks.it>2017-04-14 17:52:56 +0200
commit6eceae4bf7ee823d6eed276935741b7c107f6105 (patch)
tree27afa85981f5eec4cd12cc05366c5b511ca8e9a6 /rumba/prototypes/irati.py
parent2f423e0282975b753f6686654f3adc0f535d23d7 (diff)
downloadrumba-6eceae4bf7ee823d6eed276935741b7c107f6105.tar.gz
rumba-6eceae4bf7ee823d6eed276935741b7c107f6105.zip
Implemented several comments on MR 22:
+ Used paramiko for scp (implemented new method in ssh_support + removed (obsoleted) private key for access to vms + used setup_vlans from ssh_support
Diffstat (limited to 'rumba/prototypes/irati.py')
-rw-r--r--rumba/prototypes/irati.py56
1 files changed, 26 insertions, 30 deletions
diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py
index edc49c6..89c4fe4 100644
--- a/rumba/prototypes/irati.py
+++ b/rumba/prototypes/irati.py
@@ -31,9 +31,6 @@ import rumba.prototypes.irati_templates as irati_templates
# An experiment over the IRATI implementation
-from rumba import ssh_support
-
-
class Experiment(mod.Experiment):
@staticmethod
@@ -47,6 +44,7 @@ class Experiment(mod.Experiment):
def __init__(self, testbed, nodes=None):
mod.Experiment.__init__(self, testbed, nodes)
self.manager = False
+ self.conf_files = None
if self.testbed.username == 'root':
self.sudo = self.fake_sudo
@@ -94,7 +92,7 @@ class Experiment(mod.Experiment):
print("[IRATI experiment] start")
print("Setting up IRATI on the nodes...")
self.setup()
- self.write_conf()
+ self.conf_files = self.write_conf()
self.bootstrap_network()
self.run_experiment()
print("[IRATI experiment] end")
@@ -107,45 +105,34 @@ class Experiment(mod.Experiment):
:return:
"""
name = node.name
- gen_files_conf = 'shimeth.%(name)s.*.dif da.map %(name)s.ipcm.conf' % {
- 'name': name}
- if any(node in dif.members for dif in self.dif_ordering):
- gen_files_conf = ' '.join(
- [gen_files_conf, 'normal.%(name)s.*.dif' % {'name': name}])
+ gen_files_conf = self.conf_files[node] + ['da.map']
dir_path = os.path.dirname(os.path.abspath(__file__))
gen_files_bin = 'enroll.py'
- gen_files_conf_full = \
- ' '.join([self.conf_dir(x) for x in gen_files_conf.split()])
- gen_files_bin_full = os.path.join(dir_path, 'enroll.py')
+ gen_files_conf_full = [self.conf_dir(x) for x in gen_files_conf]
+ gen_files_bin_full = [os.path.join(dir_path, 'enroll.py')]
ipcm_components = ['scripting', 'console']
if self.manager:
ipcm_components.append('mad')
ipcm_components = ', '.join(ipcm_components)
- gen_files = ' '.join([gen_files_conf_full, gen_files_bin_full])
+ gen_files = gen_files_conf_full + gen_files_bin_full
- sshopts = ('-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
- ' -o IdentityFile=%s'
- % (os.path.join(dir_path, 'irati_rsa',)))
format_args = {'name': name,
'ssh': node.ssh_config.port,
'username': self.testbed.username,
'genfiles': gen_files,
- 'genfilesconf': gen_files_conf,
+ 'genfilesconf': ' '.join(gen_files_conf),
'genfilesbin': gen_files_bin,
- 'sshopts': sshopts,
'installpath': '/usr',
'verb': 'DBG',
'ipcmcomps': ipcm_components}
try:
- print('DEBUG: executing >> '
- 'scp %(sshopts)s -r -P %(ssh)s '
- '%(genfiles)s %(username)s@localhost:'
- % format_args)
- subprocess.check_call(('scp %(sshopts)s -r -P %(ssh)s '
- '%(genfiles)s %(username)s@localhost:'
- % format_args), shell=True)
+ # TODO: watch out for empty path...
+ ssh.copy_paths_to_testbed(self.testbed,
+ node.ssh_config,
+ gen_files,
+ '')
except subprocess.CalledProcessError as e:
raise Exception(str(e))
@@ -154,7 +141,8 @@ class Experiment(mod.Experiment):
cmds = [self.sudo('hostname %(name)s' % format_args),
self.sudo('chmod a+rw /dev/irati'),
self.sudo('mv %(genfilesconf)s /etc' % format_args),
- self.sudo('mv %(genfilesbin)s /usr/bin') % format_args]
+ self.sudo('mv %(genfilesbin)s /usr/bin') % format_args,
+ self.sudo('chmod a+x /usr/bin/enroll.py') % format_args]
# TODO: is the port up on the VM at this point?
@@ -167,7 +155,7 @@ class Experiment(mod.Experiment):
# print('Credentials:')
# print(node.ssh_config.hostname, node.ssh_config.port,
# self.testbed.username, self.testbed.password)
- ssh_support.execute_commands(self.testbed, node.ssh_config, cmds)
+ ssh.execute_commands(self.testbed, node.ssh_config, cmds)
def enroll_nodes(self):
"""Runs the enrollments one by one, respecting dependencies"""
@@ -198,9 +186,9 @@ class Experiment(mod.Experiment):
# print(e['enrollee'].ssh_config.hostname,
# e['enrollee'].ssh_config.port,
# self.testbed.username, self.testbed.password)
- ssh_support.execute_command(self.testbed,
- e['enrollee'].ssh_config,
- cmd)
+ ssh.execute_command(self.testbed,
+ e['enrollee'].ssh_config,
+ cmd)
def write_conf(self):
"""Write the configuration files"""
@@ -210,6 +198,7 @@ class Experiment(mod.Experiment):
ipcp2shim_map = {}
node2id_map = {}
mgmt_dif_name = 'NMS'
+ conf_files = {} # dict of per-nod conf files
# TODO: what format are the mappings registered in? Is this ok?
app_mappings = []
@@ -298,6 +287,8 @@ class Experiment(mod.Experiment):
},
indent=4, sort_keys=True))
fout.close()
+ conf_files.setdefault(node, []).append(
+ 'shimeth.%s.%s.dif' % (node.name, shim.name))
# Run over dif_ordering array, to make sure each IPCM config has
# the correct ordering for the ipcProcessesToCreate list of operations.
@@ -360,6 +351,8 @@ class Experiment(mod.Experiment):
node_file,
indent=4,
sort_keys=True)
+ conf_files.setdefault(node, []).append(
+ '%s.ipcm.conf' % (node.name,))
for dif in self.dif_ordering: # type: mod.DIF
dif_conf = difconfs.get(dif.name, None)
@@ -373,3 +366,6 @@ class Experiment(mod.Experiment):
dif_conf_file,
indent=4,
sort_keys=True)
+ conf_files.setdefault(node, []).append(
+ 'normal.%s.%s.dif' % (node.name, dif.name))
+ return conf_files