Commit 69387caa authored by garciadeblas's avatar garciadeblas
Browse files

Update structure of sample_ee_vnf

parent 0cc5a2e1
Loading
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -22,15 +22,10 @@ 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 HTTP python library
python3 -m pip install requests
# Install libraries from requirementsy to execute command remotely by ssh
echo "Installing requirements"
python3 -m pip install -r requirements.txt
# Install MySQL library
python3 -m pip install mysql-connector-python
+0 −0

Empty file added.

+1 −22
Original line number Diff line number Diff line
@@ -22,35 +22,14 @@

import logging
import asyncio
import asyncssh
import time


from mysql.connector import connect, Error

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


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
async def mysql_query(host: str, user: str, password: str, retries: int, query: str
                           ) -> (int, str):
    """
        Execute a query to a MySQL database.
+1 −0
Original line number Diff line number Diff line
osm_ee @ git+https://osm.etsi.org/gitlab/vnf-onboarding/docker-api-fe.git@master#egg=version_subpkg&subdirectory=osm_ee
Loading