Fix the version of urllib
[bottlenecks.git] / utils / env_prepare / moon_prepare.py
1 #!/usr/bin/env python
2 ##############################################################################
3 # Copyright (c) 2018 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 import utils.infra_setup.passwordless_SSH.ssh as localssh
11
12
13 def moon_envprepare(host_info):
14     if ("password") in host_info:
15         client = localssh.SSH(user=host_info["user"],
16                               host=host_info["ip"],
17                               password=host_info["password"])
18     else:
19         client = localssh.SSH(user=host_info["user"],
20                               host=host_info["ip"],
21                               key_filename=host_info["keyfile"])
22     with open("/home/opnfv/bottlenecks/utils/env_prepare/moon_prepare.bash",
23               "rb") as stdin_file:
24         client.run("cat > ~/bottlenecks_envprepare.bash", stdin=stdin_file)
25     client.execute("sudo bash ~/bottlenecks_envprepare.bash")