Commit fc548e3b authored by garciadeblas's avatar garciadeblas
Browse files

Revert "Update structure of sample_ee_vnf"



This reverts commit f28e6739.

Signed-off-by: default avatargarciadeblas <gerardo.garciadeblas@telefonica.com>
parent 138cf529
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -22,10 +22,15 @@ apt-get install -y software-properties-common
apt-add-repository --yes --update ppa:ansible/ansible
apt install -y ansible

# Install library to execute command remotely by ssh
echo "Installing asynssh"
python3 -m pip install asyncssh

# Install ping system command
apt install -y iputils-ping

# Install libraries from requirementsy to execute command remotely by ssh
echo "Installing requirements"
python3 -m pip install -r requirements.txt
# Install HTTP python library
python3 -m pip install requests

# Install MySQL library
python3 -m pip install mysql-connector-python
+22 −1
Original line number Diff line number Diff line
@@ -22,14 +22,35 @@

import logging
import asyncio
import asyncssh
import time


from mysql.connector import connect, Error

logger = logging.getLogger("osm_ee.vnf")


async def mysql_query(host: str, user: str, password: str, retries: int, query: str
async def ssh_exec(host: str, user: str, command: str
                           ) -> (int, str):
    """
        Execute a remote command via SSH.
    """

    try:
        async with asyncssh.connect(host,
                                    username=user,
                                    known_hosts=None) as conn:
            logger.debug("Executing command '{}'".format(command))
            result = await conn.run(command)
            logger.debug("Result: {}".format(result))
            return result.exit_status, result.stderr
    except Exception as e:
        logger.error("Error: {}".format(repr(e)))
        return -1, str(e)


def mysql_query(host: str, user: str, password: str, retries: int, query: str
                           ) -> (int, str):
    """
        Execute a query to a MySQL database.
+0 −0

Empty file deleted.

Loading