-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Python-chi 1.0 context module Added the following new methods: - list_sites(show: [None, “widget”, “text”] = None) -> [str] - use_site(site_name: str = DEFAULT_SITE) -> None - use_project(project_id: str = None) -> None - choose_site() -> None, displays a dropdown widget to choose the site - choose_project() -> None, displays a dropdown widget to choose the project - check_credentials() -> None, prints authentication metadata - set_log_level(debug: Bool), sets openstack debug logging to true, including HTTP request logs - _is_ipynb() -> Bool, checks if the code is running within an ipy notebook. Used to determine whether to execute widgets * Added custom exceptions Raised when argument is not valid. These errors might be fixed by checking hardware catalog or documentation. Examples where this might be seen are: - Site name is not valid - Node type is not valid - e.g. Resource does not exist Raised when a request has valid arguments, but the resources are being used incorrectly, or can’t be used as requested. This type of error might depend on the time the notebook is run, due to the shared nature of the testbed. Examples: - Nodes matching filters (e.g. node_type) are unavailable - Cannot allocate FIP - Allocation expires soon - Allocation has insufficient SUs for request Raised when an error occurs with some Chameleon resource. For example, if your node is having hardware issues, and so fails to provision, this will be raised. Replaced thrown exceptions with their appropriate custom exception accross all modules. * Python-chi 1.0 context module Added the following new methods: - list_sites(show: [None, “widget”, “text”] = None) -> [str] - list_projects(show: [None, “widget”, “text”] = None) -> [str] - use_site(site_name: str = DEFAULT_SITE) -> None - use_project(project_id: str = None) -> None - choose_site() -> None, displays a dropdown widget to choose the site - choose_project() -> None, displays a dropdown widget to choose the project - check_credentials() -> None, prints authentication metadata - set_log_level(debug: str), changes logging level to either ERROR or DEBUG, including HTTP request logs if the latter is chosen * Changed one more exception * Python-chi 1.0 context module Added the following new methods: - list_sites(show: [None, “widget”, “text”] = None) -> [str] - list_projects(show: [None, “widget”, “text”] = None) -> [str] - use_site(site_name: str = DEFAULT_SITE) -> None - use_project(project_id: str = None) -> None - choose_site() -> None, displays a dropdown widget to choose the site - choose_project() -> None, displays a dropdown widget to choose the project - check_credentials() -> None, prints authentication metadata - set_log_level(debug: str), changes logging level to either ERROR or DEBUG, including HTTP request logs if the latter is chosen * typo --------- Co-authored-by: Soufiane Jounaid <[email protected]> Co-authored-by: Soufiane Jounaid <[email protected]> Co-authored-by: Mark Powers <[email protected]>
- Loading branch information
1 parent
81ba5fe
commit 00a5005
Showing
7 changed files
with
74 additions
and
38 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 |
---|---|---|
|
@@ -16,7 +16,11 @@ | |
import requests | ||
|
||
from . import jupyterhub | ||
from .exception import CHIValueError, ResourceError | ||
|
||
import openstack | ||
import ipywidgets as widgets | ||
import requests | ||
import logging | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
@@ -286,7 +290,7 @@ def list_sites(show: Optional[str] = None) -> List[str]: | |
"user_support_contact": "[email protected]", | ||
} | ||
if not _sites: | ||
raise ValueError("No sites returned.") | ||
raise ResourceError("No sites returned.") | ||
|
||
if show == None: | ||
return _sites | ||
|
@@ -323,7 +327,7 @@ def list_sites(show: Optional[str] = None) -> List[str]: | |
print(f" Location: {site['location']}") | ||
print(f" User Support Contact: {site['user_support_contact']}") | ||
else: | ||
raise ValueError("Invalid value for 'show' parameter.") | ||
raise CHIValueError("Invalid value for 'show' parameter.") | ||
|
||
|
||
def use_site(site_name: str) -> None: | ||
|
@@ -368,7 +372,7 @@ def use_site(site_name: str) -> None: | |
|
||
site = _sites.get(site_name) | ||
if not site: | ||
raise ValueError( | ||
raise CHIValueError( | ||
( | ||
f'No site named "{site_name}" exists! Possible values: ' | ||
", ".join(_sites.keys()) | ||
|
@@ -445,7 +449,7 @@ def list_projects(show: str = None) -> List[str]: | |
elif show == None: | ||
return list(project_names) | ||
else: | ||
raise ValueError("Invalid value for 'show' parameter.") | ||
raise CHIValueError("Invalid value for 'show' parameter.") | ||
|
||
def use_project(project: str) -> None: | ||
""" | ||
|
@@ -503,7 +507,7 @@ def set_log_level(level: str = "ERROR") -> None: | |
openstack.enable_logging(debug=False, http_debug=False) | ||
LOG.setLevel(logging.ERROR) | ||
else: | ||
raise ValueError("Invalid log level value, please choose between 'ERROR' and 'DEBUG'") | ||
raise CHIValueError("Invalid log level value, please choose between 'ERROR' and 'DEBUG'") | ||
|
||
def session(): | ||
"""Get a Keystone Session object suitable for authenticating a client. | ||
|
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class CHIValueError(Exception): | ||
"""Raised when argument is not valid. These errors might be fixed by | ||
checking hardware catalog or documentation. Examples where this might | ||
be seen are: | ||
- Site name is not valid | ||
- Node type is not valid | ||
- Resource does not exist | ||
""" | ||
def __init__(self, message): | ||
super().__init__(message) | ||
|
||
|
||
class ResourceError(Exception): | ||
"""Raised when a request has valid arguments, but the resources are | ||
being used incorrectly, or can not be used as requested. This type | ||
of error might depend on the time the request is run, due to the | ||
shared nature of the testbed.""" | ||
def __init__(self, message): | ||
super().__init__(message) | ||
|
||
|
||
class ServiceError(Exception): | ||
"""Raised when an error occurs with some Chameleon resource. | ||
For example, if your node is having hardware issues, and so | ||
fails to provision, this will be raised.""" | ||
def __init__(self, message): | ||
super().__init__(message) |
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
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