Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstraer los servidores #57

Open
marcosrmartin opened this issue Jun 7, 2024 · 2 comments
Open

Abstraer los servidores #57

marcosrmartin opened this issue Jun 7, 2024 · 2 comments
Labels
question Further information is requested

Comments

@marcosrmartin
Copy link
Owner

Hay código que puede introducir a error introduciendo posibles casuísticas manejando servidores y dificultando la lógica. Es decir hay varias funcionalidades que se podrían mejorar subiendo el nivel de abstracción, sobre todo en métodos que "rotan". Por ejemplo:

En controlador de puertos #36:

rest = [NGINX, HTTPD]
rest.remove(running)

def swap_to_container(self, container):
if container == NGINX:
self.__remove_port(HTTPD, UDP)
self.__remove_port(HTTPD, TCP)
self.__add_port(NGINX, UDP)
self.__add_port(NGINX, TCP)
logger.info(f"Forwardind port changed from {PORT[HTTPD]} -> {PORT[NGINX]}")
else:
self.__remove_port(NGINX, UDP)
self.__remove_port(NGINX, TCP)
self.__add_port(HTTPD, UDP)
self.__add_port(HTTPD, TCP)
logger.info(f"Forwardind port changed from {PORT[NGINX]} -> {PORT[HTTPD]}")

ports = {NGINX:{}, HTTPD:{}}
f_ports = self.firebus.getForwardPorts(self.zone)
for container in (NGINX, HTTPD):

En controlador de contenedores #37:

self.port_bindings_httpd = {PORT[PROXY]:PORT[HTTPD]}
self.port_bindings_nginx = {PORT[PROXY]:PORT[NGINX]}

ports = self.port_bindings_nginx if container_name == NGINX.lower() else self.port_bindings_httpd

En el controlador del MTD #35:

def switch(self):
old_container = self.container_controller.active_container
if self.container_controller.active_container.name == NGINX.lower():
logger.info("Rotating from NGINX -> HTTPD")
self.container_controller.create_container(HTTPD.lower())
self.port_controller.swap_to_container(HTTPD)
self.container_controller.remove_container(old_container)
container = HTTPD
elif self.container_controller.active_container.name == HTTPD.lower():
logger.info("Rotating from HTTPD -> NGINX")
self.container_controller.create_container(NGINX.lower())
self.port_controller.swap_to_container(NGINX)
self.container_controller.remove_container(old_container)
container = NGINX
else:
logger.error(f"MTD rotation failed cause of: {str(e)}")
raise ValueError(f"MTD rotation failed cause of: {str(e)}")

@marcosrmartin marcosrmartin added the question Further information is requested label Jun 7, 2024
@marcosrmartin
Copy link
Owner Author

Tendría sentido arreglar esto @JJ? (refiriéndome al tiempo). He tirado del hilo al implementar los test y pensar si hacer para swap_to_container, que comparte problema con el resto.

@JJ
Copy link
Contributor

JJ commented Jul 2, 2024

Bueno, habría que formular un poco mejor el problema. Ahora mismo tiene como título la solución, "abstraer los servidores".
Yo creo que la idea principal que había detrás es que se puedan usar diferentes servidores como parte del perfil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants