# See the License for the specific language governing permissions and
# limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
from subprocess import Popen, PIPE, call
from multiprocessing import Pool
from tempfile import NamedTemporaryFile
from os.path import basename
from subprocess import Popen, PIPE, call
from multiprocessing import Pool
from tempfile import NamedTemporaryFile
from os.path import basename
-from ssh import SSH
-from constants import Constants as con
-from topology import NodeType
+
+from resources.libraries.python.ssh import SSH
+from resources.libraries.python.constants import Constants as con
+from resources.libraries.python.topology import NodeType
stdout=PIPE, stderr=PIPE)
(stdout, stderr) = proc.communicate()
stdout=PIPE, stderr=PIPE)
(stdout, stderr) = proc.communicate()
logger.console('Extracting tarball to {0} on {1}'.format(
con.REMOTE_FW_DIR, node['host']))
ssh = SSH()
logger.console('Extracting tarball to {0} on {1}'.format(
con.REMOTE_FW_DIR, node['host']))
ssh = SSH()
cmd = 'sudo rm -rf {1}; mkdir {1} ; tar -zxf {0} -C {1}; ' \
'rm -f {0}'.format(tarball, con.REMOTE_FW_DIR)
cmd = 'sudo rm -rf {1}; mkdir {1} ; tar -zxf {0} -C {1}; ' \
'rm -f {0}'.format(tarball, con.REMOTE_FW_DIR)
- (ret_code, stdout, stderr) = ssh.exec_command(cmd, timeout=30)
+ (ret_code, _, stderr) = ssh.exec_command(cmd, timeout=30)
if 0 != ret_code:
logger.error('Unpack error: {0}'.format(stderr))
raise Exception('Failed to unpack {0} at node {1}'.format(
if 0 != ret_code:
logger.error('Unpack error: {0}'.format(stderr))
raise Exception('Failed to unpack {0} at node {1}'.format(
- 'cd {0} && rm -rf env && virtualenv env && '
- '. env/bin/activate && '
- 'pip install -r requirements.txt'.format(con.REMOTE_FW_DIR))
+ 'cd {0} && rm -rf env && virtualenv env && . env/bin/activate && '
+ 'pip install -r requirements.txt'
+ .format(con.REMOTE_FW_DIR), timeout=100)
if 0 != ret_code:
logger.error('Virtualenv creation error: {0}'.format(stdout + stderr))
raise Exception('Virtualenv setup failed')
if 0 != ret_code:
logger.error('Virtualenv creation error: {0}'.format(stdout + stderr))
raise Exception('Virtualenv setup failed')
+ """Run all set-up methods for a node.
+
+ This method is used as map_async parameter. It receives tuple with all
+ parameters as passed to map_async function.
+
+ :param args: All parameters needed to setup one node.
+ :type args: tuple
+ :return: nothing
+ """
tarball, remote_tarball, node = args
copy_tarball_to_node(tarball, node)
extract_tarball_at_node(remote_tarball, node)
if node['type'] == NodeType.TG:
create_env_directory_at_node(node)
tarball, remote_tarball, node = args
copy_tarball_to_node(tarball, node)
extract_tarball_at_node(remote_tarball, node)
if node['type'] == NodeType.TG:
create_env_directory_at_node(node)
"""Setup suite run on topology nodes.
Many VAT/CLI based tests need the scripts at remote hosts before executing
"""Setup suite run on topology nodes.
Many VAT/CLI based tests need the scripts at remote hosts before executing
log_level = BuiltIn().set_log_level('NONE')
params = ((tarball, remote_tarball, node) for node in nodes.values())
pool = Pool(processes=len(nodes))
log_level = BuiltIn().set_log_level('NONE')
params = ((tarball, remote_tarball, node) for node in nodes.values())
pool = Pool(processes=len(nodes))
BuiltIn().set_log_level(log_level)
logger.trace('Test framework copied to all topology nodes')
delete_local_tarball(tarball)
BuiltIn().set_log_level(log_level)
logger.trace('Test framework copied to all topology nodes')
delete_local_tarball(tarball)