Skip to content

Commit

Permalink
Merge pull request #87 from fabric-testbed/rel1.7
Browse files Browse the repository at this point in the history
Rel1.7 - changes
  • Loading branch information
kthare10 authored Jul 18, 2024
2 parents 8c67f6e + 3cfeb52 commit 7d2bb2d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fabrictestbed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.6.9"
__version__ = "1.7.0"
__VERSION__ = __version__
40 changes: 32 additions & 8 deletions fabrictestbed/slice_manager/slice_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ def __load_tokens(self, refresh: bool = True):
refresh_token = os.environ.get(Constants.CILOGON_REFRESH_TOKEN)
# Renew the tokens to ensure any project_id changes are taken into account
if refresh and self.auto_refresh:
if refresh_token is None:
raise SliceManagerException(f"Unable to refresh tokens: no refresh token found!")
self.refresh_tokens(refresh_token=refresh_token)

def get_refresh_token(self) -> str:
Expand Down Expand Up @@ -279,14 +277,15 @@ def clear_token_cache(self, *, file_name: str = None):
return Status.FAILURE, f"Failed to clear token cache: {Utils.extract_error_message(exception=exception)}"

def create(self, *, slice_name: str, ssh_key: Union[str, List[str]], topology: ExperimentTopology = None,
slice_graph: str = None,
slice_graph: str = None, lease_start_time: str = None,
lease_end_time: str = None) -> Tuple[Status, Union[SliceManagerException, List[Sliver]]]:
"""
Create a slice
@param slice_name slice name
@param ssh_key SSH Key(s)
@param topology Experiment topology
@param slice_graph Slice Graph string
@param lease_start_time Lease Start Time
@param lease_end_time Lease End Time
@return Tuple containing Status and Exception/Json containing slivers created
"""
Expand All @@ -306,7 +305,8 @@ def create(self, *, slice_name: str, ssh_key: Union[str, List[str]], topology: E
if self.__should_renew():
self.__load_tokens()
return self.oc_proxy.create(token=self.get_id_token(), slice_name=slice_name, ssh_key=ssh_key,
topology=topology, slice_graph=slice_graph, lease_end_time=lease_end_time)
topology=topology, slice_graph=slice_graph, lease_end_time=lease_end_time,
lease_start_time=lease_start_time)
except Exception as e:
error_message = Utils.extract_error_message(exception=e)
return Status.FAILURE, SliceManagerException(error_message)
Expand Down Expand Up @@ -433,18 +433,24 @@ def slivers(self, *, slice_object: Slice,
error_message = Utils.extract_error_message(exception=e)
return Status.FAILURE, SliceManagerException(error_message)

def resources(self, *, level: int = 1,
force_refresh: bool = False) -> Tuple[Status, Union[SliceManagerException, AdvertisedTopology]]:
def resources(self, *, level: int = 1, force_refresh: bool = False, start: datetime = None, end: datetime = None,
includes: List[str] = None,
excludes: List[str] = None) -> Tuple[Status, Union[SliceManagerException, AdvertisedTopology]]:
"""
Get resources
@param level level
@param force_refresh force_refresh
@param start start time
@param end end time
@param includes list of sites to include
@param excludes list of sites to exclude
@return Tuple containing Status and Exception/Json containing Resources
"""
try:
if self.__should_renew():
self.__load_tokens()
return self.oc_proxy.resources(token=self.get_id_token(), level=level, force_refresh=force_refresh)
return self.oc_proxy.resources(token=self.get_id_token(), level=level, force_refresh=force_refresh,
start=start, end=end, includes=includes, excludes=excludes)
except Exception as e:
error_message = Utils.extract_error_message(exception=e)
return Status.FAILURE, SliceManagerException(error_message)
Expand Down Expand Up @@ -623,4 +629,22 @@ def get_project_info(self, project_name: str = "all", project_id: str = "all", u
return core_api_proxy.get_user_projects(project_name=project_name, project_id=project_id, uuid=uuid)
except Exception as e:
error_message = Utils.extract_error_message(exception=e)
raise SliceManagerException(error_message)
raise SliceManagerException(error_message)

def get_metrics_overview(self, excluded_projects: List[str] = None,
authenticated: bool = False) -> Tuple[Status, Union[list, Exception]]:
"""
Get Metrics overview
@param excluded_projects: excluded_projects
@param authenticated: Specific user metrics
@return list of metrics
"""
try:
token = None
if authenticated and self.__should_renew():
self.__load_tokens()
token = self.get_id_token()
return self.oc_proxy.get_metrics_overview(token=token, excluded_projects=excluded_projects)
except Exception as e:
error_message = Utils.extract_error_message(exception=e)
return Status.FAILURE, SliceManagerException(error_message)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies = [
"fabric_fss_utils>=1.5.1",
"click",
"fabric-credmgr-client==1.6.1",
"fabric-orchestrator-client==1.6.1",
"fabric-orchestrator-client==1.7.0",
"paramiko"
]

Expand Down

0 comments on commit 7d2bb2d

Please sign in to comment.