Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
implement copy protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrajewski committed Aug 12, 2024
1 parent 67d5a2d commit e8a2a58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions catalystwan/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,5 +553,13 @@ def validate_responses(self) -> bool:
def validate_responses(self, value: bool):
self._validate_responses = value

def __copy__(self) -> ManagerSession:
return ManagerSession(
base_url=self.base_url,
auth=self._auth,
subdomain=self.subdomain,
logger=self.logger,
)

def __str__(self) -> str:
return f"ManagerSession(session_type={self.session_type}, auth={self._auth})"
7 changes: 4 additions & 3 deletions catalystwan/workflows/tenant_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import logging
from copy import copy
from datetime import datetime
from pathlib import Path
from typing import Dict, List
Expand Down Expand Up @@ -127,9 +128,9 @@ def migration_preconditions_check(
logger.info("Checking if migrated devices can reach target validator...")
conn_check = False
if origin_session.session_type == SessionType.PROVIDER:
origin_session.subdomain = tenant.subdomain
origin_session.logout()
with origin_session.login() as provider_as_tenant_session:
as_tenant = copy(origin_session)
as_tenant.subdomain = tenant.subdomain
with as_tenant.login() as provider_as_tenant_session:
conn_check = check_control_connectivity_from_edge_devices(provider_as_tenant_session, validator)
else:
conn_check = check_control_connectivity_from_edge_devices(origin_session, validator)
Expand Down

0 comments on commit e8a2a58

Please sign in to comment.