Skip to content

Commit 7d2bb2d

Browse files
authored
Merge pull request #87 from fabric-testbed/rel1.7
Rel1.7 - changes
2 parents 8c67f6e + 3cfeb52 commit 7d2bb2d

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

fabrictestbed/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "1.6.9"
1+
__version__ = "1.7.0"
22
__VERSION__ = __version__

fabrictestbed/slice_manager/slice_manager.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ def __load_tokens(self, refresh: bool = True):
157157
refresh_token = os.environ.get(Constants.CILOGON_REFRESH_TOKEN)
158158
# Renew the tokens to ensure any project_id changes are taken into account
159159
if refresh and self.auto_refresh:
160-
if refresh_token is None:
161-
raise SliceManagerException(f"Unable to refresh tokens: no refresh token found!")
162160
self.refresh_tokens(refresh_token=refresh_token)
163161

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

281279
def create(self, *, slice_name: str, ssh_key: Union[str, List[str]], topology: ExperimentTopology = None,
282-
slice_graph: str = None,
280+
slice_graph: str = None, lease_start_time: str = None,
283281
lease_end_time: str = None) -> Tuple[Status, Union[SliceManagerException, List[Sliver]]]:
284282
"""
285283
Create a slice
286284
@param slice_name slice name
287285
@param ssh_key SSH Key(s)
288286
@param topology Experiment topology
289287
@param slice_graph Slice Graph string
288+
@param lease_start_time Lease Start Time
290289
@param lease_end_time Lease End Time
291290
@return Tuple containing Status and Exception/Json containing slivers created
292291
"""
@@ -306,7 +305,8 @@ def create(self, *, slice_name: str, ssh_key: Union[str, List[str]], topology: E
306305
if self.__should_renew():
307306
self.__load_tokens()
308307
return self.oc_proxy.create(token=self.get_id_token(), slice_name=slice_name, ssh_key=ssh_key,
309-
topology=topology, slice_graph=slice_graph, lease_end_time=lease_end_time)
308+
topology=topology, slice_graph=slice_graph, lease_end_time=lease_end_time,
309+
lease_start_time=lease_start_time)
310310
except Exception as e:
311311
error_message = Utils.extract_error_message(exception=e)
312312
return Status.FAILURE, SliceManagerException(error_message)
@@ -433,18 +433,24 @@ def slivers(self, *, slice_object: Slice,
433433
error_message = Utils.extract_error_message(exception=e)
434434
return Status.FAILURE, SliceManagerException(error_message)
435435

436-
def resources(self, *, level: int = 1,
437-
force_refresh: bool = False) -> Tuple[Status, Union[SliceManagerException, AdvertisedTopology]]:
436+
def resources(self, *, level: int = 1, force_refresh: bool = False, start: datetime = None, end: datetime = None,
437+
includes: List[str] = None,
438+
excludes: List[str] = None) -> Tuple[Status, Union[SliceManagerException, AdvertisedTopology]]:
438439
"""
439440
Get resources
440441
@param level level
441442
@param force_refresh force_refresh
443+
@param start start time
444+
@param end end time
445+
@param includes list of sites to include
446+
@param excludes list of sites to exclude
442447
@return Tuple containing Status and Exception/Json containing Resources
443448
"""
444449
try:
445450
if self.__should_renew():
446451
self.__load_tokens()
447-
return self.oc_proxy.resources(token=self.get_id_token(), level=level, force_refresh=force_refresh)
452+
return self.oc_proxy.resources(token=self.get_id_token(), level=level, force_refresh=force_refresh,
453+
start=start, end=end, includes=includes, excludes=excludes)
448454
except Exception as e:
449455
error_message = Utils.extract_error_message(exception=e)
450456
return Status.FAILURE, SliceManagerException(error_message)
@@ -623,4 +629,22 @@ def get_project_info(self, project_name: str = "all", project_id: str = "all", u
623629
return core_api_proxy.get_user_projects(project_name=project_name, project_id=project_id, uuid=uuid)
624630
except Exception as e:
625631
error_message = Utils.extract_error_message(exception=e)
626-
raise SliceManagerException(error_message)
632+
raise SliceManagerException(error_message)
633+
634+
def get_metrics_overview(self, excluded_projects: List[str] = None,
635+
authenticated: bool = False) -> Tuple[Status, Union[list, Exception]]:
636+
"""
637+
Get Metrics overview
638+
@param excluded_projects: excluded_projects
639+
@param authenticated: Specific user metrics
640+
@return list of metrics
641+
"""
642+
try:
643+
token = None
644+
if authenticated and self.__should_renew():
645+
self.__load_tokens()
646+
token = self.get_id_token()
647+
return self.oc_proxy.get_metrics_overview(token=token, excluded_projects=excluded_projects)
648+
except Exception as e:
649+
error_message = Utils.extract_error_message(exception=e)
650+
return Status.FAILURE, SliceManagerException(error_message)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies = [
2020
"fabric_fss_utils>=1.5.1",
2121
"click",
2222
"fabric-credmgr-client==1.6.1",
23-
"fabric-orchestrator-client==1.6.1",
23+
"fabric-orchestrator-client==1.7.0",
2424
"paramiko"
2525
]
2626

0 commit comments

Comments
 (0)