Skip to content

Commit

Permalink
das-toolbox-139: Singleton remote context manager
Browse files Browse the repository at this point in the history
  • Loading branch information
levisingularity committed Nov 27, 2024
1 parent 2c0af42 commit 3c6f69a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 5 additions & 9 deletions src/commands/config/config_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,8 @@ def _build_nodes(self, is_cluster: bool, port: int) -> List[Dict]:

nodes = []

join_current_server = self.prompt(
join_current_server = self.confirm(
f"Do you want to join the current server as an actual node on the network?",
hide_input=False,
type=bool,
default=True,
)

Expand Down Expand Up @@ -248,14 +246,12 @@ def _build_cluster(
}
)

remote_context_manager = RemoteContextManager(servers)
cluster_contexts = remote_context_manager.create_context()

return cluster_contexts
self._remote_context_manager.set_servers(servers)
return self._remote_context_manager.create_context()

def _destroy_contexts(self, servers: List[Dict]):
remote_context_manager = RemoteContextManager(servers)
remote_context_manager.remove_context()
self._remote_context_manager.set_servers(servers)
self._remote_context_manager.remove_context()

def _redis_nodes(self, redis_cluster, redis_port) -> List[Dict]:
redis_nodes = self._build_nodes(redis_cluster, redis_port)
Expand Down
6 changes: 4 additions & 2 deletions src/common/docker/remote_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class RemoteContextManager:
def __init__(
self,
servers: List[Dict],
servers: List[Dict] = [],
) -> None:
self._servers = servers

Expand Down Expand Up @@ -49,7 +49,9 @@ def create_context(self) -> List[AnyStr]:
server_username = server.get("username")

context_name = str(uuid4())
context_description = f"This context connects to {server_ip} and managed by das-cli"
context_description = (
f"This context connects to {server_ip} and managed by das-cli"
)
context_host = self._get_host(server_username, server_ip)
context_docker = self._get_context(
host=context_host,
Expand Down

0 comments on commit 3c6f69a

Please sign in to comment.