Files
cursor_ai/modules/ssh.py

50 lines
2.1 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Основной модуль SSH клиента для миграции 1С
Объединяет базовые SSH операции, PostgreSQL и 1С кластер
"""
from .ssh_base import SSHBase
from .postgresql import PostgreSQLOperations
from .c1_cluster import C1ClusterOperations
class ssh(SSHBase, PostgreSQLOperations, C1ClusterOperations):
"""
Класс SSH клиента с поддержкой PostgreSQL и 1С кластера
Наследует функциональность от:
- SSHBase: базовые SSH операции (connect, cmd, close)
- PostgreSQLOperations: операции с PostgreSQL
- C1ClusterOperations: операции с кластером 1С
"""
def __init__(self, hostname: str = "test", port: int = 22222, username: str = "root",
pkey_file: str = "/root/.ssh/id_rsa", host_keys: str = "~/.ssh/known_hosts") -> None:
"""
Инициализация SSH клиента
Args:
hostname: Имя хоста или IP адрес
port: Порт SSH (int)
username: Имя пользователя
pkey_file: Путь к приватному ключу
host_keys: Путь к файлу known_hosts
"""
# Инициализируем базовый SSH класс
SSHBase.__init__(self, hostname, port, username, pkey_file, host_keys)
# Инициализируем модули операций
PostgreSQLOperations.__init__(self, self)
C1ClusterOperations.__init__(self, self, "", "", "")
def set_c1_config(self, srv_1c: str, c1_claster_user: str, c1_claster_pass: str) -> None:
"""
Установка конфигурации кластера 1С
Args:
srv_1c: Имя LXC контейнера с 1С
c1_claster_user: Пользователь кластера 1С
c1_claster_pass: Пароль кластера 1С
"""
self.set_srv_1c(srv_1c)
self.set_cluster_credentials(c1_claster_user, c1_claster_pass)