-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove duplicate get_cloud_connection methods (#1114)
Signed-off-by: Christian Berendt <[email protected]>
- Loading branch information
Showing
4 changed files
with
25 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from functools import lru_cache | ||
import keystoneauth1 | ||
import openstack | ||
|
||
|
||
@lru_cache | ||
def get_cloud_connection(profile="admin"): | ||
try: | ||
conn = openstack.connect(cloud=profile) | ||
except keystoneauth1.exceptions.auth_plugins.MissingRequiredOptions: | ||
pass | ||
|
||
return conn | ||
|
||
|
||
@lru_cache | ||
def get_cloud_project(project_id): | ||
conn = get_cloud_connection() | ||
return conn.identity.get_project(project_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters