@@ -157,8 +157,6 @@ def __load_tokens(self, refresh: bool = True):
157
157
refresh_token = os .environ .get (Constants .CILOGON_REFRESH_TOKEN )
158
158
# Renew the tokens to ensure any project_id changes are taken into account
159
159
if refresh and self .auto_refresh :
160
- if refresh_token is None :
161
- raise SliceManagerException (f"Unable to refresh tokens: no refresh token found!" )
162
160
self .refresh_tokens (refresh_token = refresh_token )
163
161
164
162
def get_refresh_token (self ) -> str :
@@ -279,14 +277,15 @@ def clear_token_cache(self, *, file_name: str = None):
279
277
return Status .FAILURE , f"Failed to clear token cache: { Utils .extract_error_message (exception = exception )} "
280
278
281
279
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 ,
283
281
lease_end_time : str = None ) -> Tuple [Status , Union [SliceManagerException , List [Sliver ]]]:
284
282
"""
285
283
Create a slice
286
284
@param slice_name slice name
287
285
@param ssh_key SSH Key(s)
288
286
@param topology Experiment topology
289
287
@param slice_graph Slice Graph string
288
+ @param lease_start_time Lease Start Time
290
289
@param lease_end_time Lease End Time
291
290
@return Tuple containing Status and Exception/Json containing slivers created
292
291
"""
@@ -306,7 +305,8 @@ def create(self, *, slice_name: str, ssh_key: Union[str, List[str]], topology: E
306
305
if self .__should_renew ():
307
306
self .__load_tokens ()
308
307
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 )
310
310
except Exception as e :
311
311
error_message = Utils .extract_error_message (exception = e )
312
312
return Status .FAILURE , SliceManagerException (error_message )
@@ -433,18 +433,24 @@ def slivers(self, *, slice_object: Slice,
433
433
error_message = Utils .extract_error_message (exception = e )
434
434
return Status .FAILURE , SliceManagerException (error_message )
435
435
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 ]]:
438
439
"""
439
440
Get resources
440
441
@param level level
441
442
@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
442
447
@return Tuple containing Status and Exception/Json containing Resources
443
448
"""
444
449
try :
445
450
if self .__should_renew ():
446
451
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 )
448
454
except Exception as e :
449
455
error_message = Utils .extract_error_message (exception = e )
450
456
return Status .FAILURE , SliceManagerException (error_message )
@@ -623,4 +629,22 @@ def get_project_info(self, project_name: str = "all", project_id: str = "all", u
623
629
return core_api_proxy .get_user_projects (project_name = project_name , project_id = project_id , uuid = uuid )
624
630
except Exception as e :
625
631
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 )
0 commit comments