X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=RO%2Fosm_ro%2Fconsole_proxy_thread.py;fp=RO%2Fosm_ro%2Fconsole_proxy_thread.py;h=0000000000000000000000000000000000000000;hb=9f40121f66e644ddf700720d8d4bdf464f6dd414;hp=0c4489918e95573cd2fbd11a582c3070919d4751;hpb=aed948dcfe3e1586c184fd31abacbd3b89eb2a2d;p=osm%2FRO.git diff --git a/RO/osm_ro/console_proxy_thread.py b/RO/osm_ro/console_proxy_thread.py deleted file mode 100644 index 0c448991..00000000 --- a/RO/osm_ro/console_proxy_thread.py +++ /dev/null @@ -1,188 +0,0 @@ -# -*- coding: utf-8 -*- - -## -# Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U. -# This file is part of openmano -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact with: nfvlabs@tid.es -## - -''' -Implement like a proxy for TCP/IP in a separated thread. -It creates two sockets to bypass the TCP/IP packets among the fix console -server specified at class construction (console_host, console_port) -and a client that connect against the (host, port) specified also at construction - - --------------------- ------------------------------- - | OPENMANO | | VIM | -client 1 ----> | ConsoleProxyThread | ------> | Console server | -client 2 ----> | (host, port) | ------> |(console_host, console_server)| - ... -------------------- ------------------------------ -''' -__author__="Alfonso Tierno" -__date__ ="$19-nov-2015 09:07:15$" - -import socket -import select -import threading -import logging - - -class ConsoleProxyException(Exception): - '''raise when an exception has found''' -class ConsoleProxyExceptionPortUsed(ConsoleProxyException): - '''raise when the port is used''' - -class ConsoleProxyThread(threading.Thread): - buffer_size = 4096 - check_finish = 1 #frequency to check if requested to end in seconds - - def __init__(self, host, port, console_host, console_port, log_level=None): - try: - threading.Thread.__init__(self) - self.console_host = console_host - self.console_port = console_port - self.host = host - self.port = port - self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self.server.bind((host, port)) - self.server.listen(200) - #TODO timeout in a lock section can be used to autoterminate the thread - #when inactivity and timeout