summaryrefslogtreecommitdiffstats
path: root/utils/env_prepare/moon_prepare.py
blob: 41739454fa5f5adce12979f368de185f733a10d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
##############################################################################
# Copyright (c) 2018 Huawei Technologies Co.,Ltd and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import utils.infra_setup.passwordless_SSH.ssh as localssh


def moon_envprepare(host_info):
    if ("password") in host_info:
        client = localssh.SSH(user=host_info["user"],
                              host=host_info["ip"],
                              password=host_info["password"])
    else:
        client = localssh.SSH(user=host_info["user"],
                              host=host_info["ip"],
                              key_filename=host_info["keyfile"])
    with open("/home/opnfv/bottlenecks/utils/env_prepare/moon_prepare.bash",
              "rb") as stdin_file:
        client.run("cat > ~/bottlenecks_envprepare.bash", stdin=stdin_file)
    client.execute("sudo bash ~/bottlenecks_envprepare.bash")