Skip to content

Commit

Permalink
Do not recreate client if not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmet committed Mar 12, 2024
1 parent 290f44a commit 2b641b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions runner_manager/backend/vsphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@ class VsphereBackend(BaseBackend):

@property
def client(self) -> VsphereClient:
# Create the vSphere client if it wasn't already
# created in the class instance
if not hasattr(self, "_client"):
self._create_client()
return self._client

def _create_client(self):
session = Session()
session.verify = self.config.verify_ssl
client = create_vsphere_client(
self._client = create_vsphere_client(
server=self.config.server,
username=self.config.username,
password=self.config.password,
session=session,
)
return client

def get_folder(self, datacenter_name, folder_name):
"""
Expand Down
1 change: 0 additions & 1 deletion runner_manager/models/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ class VsphereConfig(BackendConfig):
server: str
username: str
password: str
bearer_token: Optional[str] = None
verify_ssl: bool = False


Expand Down

0 comments on commit 2b641b3

Please sign in to comment.