Skip to content

Commit 4354536

Browse files
authored
Merge pull request #424 from fabric-testbed/pci-rescan-only-fpga
Pci rescan only fpga
2 parents b02ec4f + 0c02924 commit 4354536

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

fabric_cf/actor/fim/plugins/broker/aggregate_bqm_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def occupied_vlans(db: ABCDatabase, node_id: str, component_name: str, start: da
119119
return result
120120

121121
@staticmethod
122-
def occupied_link_capacity(*, db: ABCDatabase, node_id: str, start: datetime, end: datetime) -> Capacities:
122+
def occupied_link_capacity(*, db: ABCDatabase, node_id: str, start: datetime, end: datetime) -> str:
123123
"""
124124
Compute the total bandwidth capacity occupied on a given link node within a specific time window.
125125
@@ -149,7 +149,7 @@ def occupied_link_capacity(*, db: ABCDatabase, node_id: str, start: datetime, en
149149

150150
bw_used = existing.get(node_id, 0)
151151
if bw_used:
152-
return Capacities(bw=bw_used).to_dict()
152+
return Capacities(bw=bw_used).to_json()
153153

154154
@staticmethod
155155
def occupied_node_capacity(*, db: ABCDatabase, node_id: str, start: datetime,

fabric_cf/orchestrator/core/orchestrator_handler.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def get_logger(self):
8181

8282
def __authorize_request(self, *, id_token: str, action_id: ActionId,
8383
resource: BaseSliver or ExperimentTopology = None,
84-
lease_end_time: datetime = None) -> FabricToken:
84+
lease_end_time: datetime = None,
85+
poa_operation: str = None) -> FabricToken:
8586
"""
8687
Authorize request
8788
:param id_token:
@@ -96,6 +97,11 @@ def __authorize_request(self, *, id_token: str, action_id: ActionId,
9697

9798
if fabric_token.subject is None:
9899
raise OrchestratorException(http_error_code=UNAUTHORIZED, message="Invalid token")
100+
project_uuid, tags, project_name = fabric_token.first_project
101+
if action_id == ActionId.POA and poa_operation and poa_operation == "rescan" and project_uuid and \
102+
tags and "Component.FPGA" not in tags:
103+
raise OrchestratorException(http_error_code=UNAUTHORIZED,
104+
message="POA rescan not authorized - missing permissions Component.FPGA")
99105
return fabric_token
100106

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

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

926-
fabric_token = self.__authorize_request(id_token=token, action_id=ActionId.POA)
932+
fabric_token = self.__authorize_request(id_token=token, action_id=ActionId.POA,
933+
poa_operation=poa.operation)
927934
user_id = fabric_token.uuid
928935
project, tags, project_name = fabric_token.first_project
929936

0 commit comments

Comments
 (0)