Automate VIRL simulation life cycle.
[csit.git] / resources / libraries / python / SetupFramework.py
index 47c609f..cb0d536 100644 (file)
@@ -84,11 +84,25 @@ def create_env_directory_at_node(node):
         logger.error('Virtualenv creation error: {0}'.format(stdout + stderr))
         raise Exception('Virtualenv setup failed')
 
+def install_dependencies(node):
+    """TEMPORARY FUNCTION TO INSTALL DEPENDENCIES ON NODES BEFORE THE VIRL
+    HOSTS HAVE ALL PREREQUISITES INSTALLED"""
+    logger.console('Installing prerequisites on {0}'.format(node['host']))
+    ssh = SSH()
+    ssh.connect(node)
+    (ret_code, stdout, stderr) = ssh.exec_command(
+            'sudo apt-get -y update; ' \
+            'sudo apt-get -y install python-virtualenv python-dev', timeout=120)
+    if 0 != ret_code:
+        logger.error('Failed to install prerequisites: {0}'.
+                format(stdout + stderr))
+        raise Exception('Virtualenv setup failed')
 
 def setup_node(args):
     tarball, remote_tarball, node = args
     copy_tarball_to_node(tarball, node)
     extract_tarball_at_node(remote_tarball, node)
+    install_dependencies(node)
     if node['type'] == NodeType.TG:
         create_env_directory_at_node(node)