Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fabric_cf/actor/fim/plugins/broker/aggregate_bqm_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def occupied_vlans(db: ABCDatabase, node_id: str, component_name: str, start: da
return result

@staticmethod
def occupied_link_capacity(*, db: ABCDatabase, node_id: str, start: datetime, end: datetime) -> Capacities:
def occupied_link_capacity(*, db: ABCDatabase, node_id: str, start: datetime, end: datetime) -> str:
"""
Compute the total bandwidth capacity occupied on a given link node within a specific time window.

Expand Down Expand Up @@ -149,7 +149,7 @@ def occupied_link_capacity(*, db: ABCDatabase, node_id: str, start: datetime, en

bw_used = existing.get(node_id, 0)
if bw_used:
return Capacities(bw=bw_used).to_dict()
return Capacities(bw=bw_used).to_json()

@staticmethod
def occupied_node_capacity(*, db: ABCDatabase, node_id: str, start: datetime,
Expand Down
11 changes: 9 additions & 2 deletions fabric_cf/orchestrator/core/orchestrator_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def get_logger(self):

def __authorize_request(self, *, id_token: str, action_id: ActionId,
resource: BaseSliver or ExperimentTopology = None,
lease_end_time: datetime = None) -> FabricToken:
lease_end_time: datetime = None,
poa_operation: str = None) -> FabricToken:
"""
Authorize request
:param id_token:
Expand All @@ -96,6 +97,11 @@ def __authorize_request(self, *, id_token: str, action_id: ActionId,

if fabric_token.subject is None:
raise OrchestratorException(http_error_code=UNAUTHORIZED, message="Invalid token")
project_uuid, tags, project_name = fabric_token.first_project
if action_id == ActionId.POA and poa_operation and poa_operation == "rescan" and project_uuid and \
tags and "Component.FPGA" not in tags:
raise OrchestratorException(http_error_code=UNAUTHORIZED,
message="POA rescan not authorized - missing permissions Component.FPGA")
return fabric_token

def get_broker(self, *, controller: ABCMgmtControllerMixin) -> ID:
Expand Down Expand Up @@ -923,7 +929,8 @@ def poa(self, *, token: str, sliver_id: str, poa: PoaAvro) -> tuple[str, str]:

rid = ID(uid=sliver_id) if sliver_id is not None else None

fabric_token = self.__authorize_request(id_token=token, action_id=ActionId.POA)
fabric_token = self.__authorize_request(id_token=token, action_id=ActionId.POA,
poa_operation=poa.operation)
user_id = fabric_token.uuid
project, tags, project_name = fabric_token.first_project

Expand Down