Skip to content

Commit 9fa7b41

Browse files
committed
changes to request specific subnet for fabnet services
1 parent faa6d20 commit 9fa7b41

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

fabric_cf/actor/core/kernel/rpc_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ def do_dispatch_incoming_rpc(self, *, actor: ABCActorMixin, rpc: IncomingRPC):
488488
rpc.set_response_handler(response_handler=request.handler)
489489

490490
actor.get_logger().debug(f"Inbound {rpc.get_request_type()} request from "
491-
f"<{rpc.get_caller().get_name()}>:{rpc.get()}")
491+
f"<{rpc.get_caller().get_name()}>:{rpc.get()}")
492492

493-
self.__log_sliver(reservation=rpc.get(), logger=actor.get_logger())
493+
#self.__log_sliver(reservation=rpc.get(), logger=actor.get_logger())
494494

495495
if rpc.get_request_type() == RPCRequestType.QueryResult:
496496
if request is None:
@@ -564,7 +564,7 @@ def enqueue(self, *, rpc: RPCRequest):
564564
from fabric_cf.actor.core.container.globals import GlobalsSingleton
565565
logger = GlobalsSingleton.get().get_logger()
566566
logger.debug(f"Outbound {rpc.get_request_type()} : {rpc.get()}")
567-
self.__log_sliver(reservation=rpc.get(), logger=logger)
567+
#self.__log_sliver(reservation=rpc.get(), logger=logger)
568568
if not self.started:
569569
logger.warning("Ignoring RPC request: container is shutting down")
570570
return

fabric_cf/actor/core/policy/broker_simpler_units_policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ def __allocate_services(self, *, rid: ID, inv: NetworkServiceInventory, sliver:
897897
owner_switch.get_label_delegations())
898898
else:
899899
delegation_id, delegated_label = InventoryForType.get_delegations(lab_cap_delegations=
900-
owner_ns.get_label_delegations())
900+
owner_ns.get_label_delegations())
901901

902902
# Set the Subnet and gateway from the Owner Switch (a)
903903
existing_reservations = self.get_existing_reservations(node_id=owner_ns_id,

fabric_cf/actor/core/policy/network_service_inventory.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def allocate(self, *, rid: ID, requested_ns: NetworkServiceSliver, owner_ns: Net
360360
return requested_ns
361361

362362
gateway_labels = self._assign_gateway_labels(ip_network=ip_network, subnet_list=subnet_list,
363-
requested_ns_type=requested_ns.get_type())
363+
requested_ns=requested_ns)
364364

365365
self.logger.debug(f"Gateway Labels: {gateway_labels}")
366366

@@ -487,25 +487,41 @@ def _get_allocated_sliver(self, reservation: ABCReservationMixin) -> NetworkServ
487487
self.logger.error("Could not find the allocated Sliver - should not reach here!")
488488

489489
def _assign_gateway_labels(self, *, ip_network: Union[IPv4Network, IPv6Network], subnet_list: List,
490-
requested_ns_type: str) -> Labels:
490+
requested_ns: NetworkServiceSliver) -> Labels:
491491
"""
492492
Assign gateway labels based on the requested network service type.
493493
494494
:param ip_network: The IP network from which subnets are derived, either IPv4Network or IPv6Network.
495495
:param subnet_list: A list of subnets derived from the ip_network.
496-
:param requested_ns_type: The type of the requested network service.
496+
:param requested_ns: Network Service sliver.
497497
:return: Gateway labels populated with the appropriate subnet and IP address.
498498
"""
499499
gateway_labels = Labels()
500-
if requested_ns_type == ServiceType.FABNetv4:
500+
if requested_ns.get_type() == ServiceType.FABNetv4:
501+
# Allocate the requested network if available else allocate new network
502+
if requested_ns.gateway and requested_ns.gateway.lab and requested_ns.gateway.lab.ipv4_subnet:
503+
requested_subnet = IPv4Network(requested_ns.gateway.lab.ipv4_subnet)
504+
if requested_subnet in subnet_list:
505+
gateway_labels.ipv4_subnet = requested_subnet.with_prefixlen
506+
gateway_labels.ipv4 = str(next(requested_subnet.hosts()))
507+
return gateway_labels
508+
501509
gateway_labels.ipv4_subnet = subnet_list[0].with_prefixlen
502510
gateway_labels.ipv4 = str(list(subnet_list[0].hosts())[0])
503511

504-
elif requested_ns_type == ServiceType.FABNetv4Ext:
512+
elif requested_ns.get_type() == ServiceType.FABNetv4Ext:
505513
gateway_labels.ipv4_subnet = ip_network.with_prefixlen
506514
gateway_labels.ipv4 = str(subnet_list[0])
507515

508-
elif requested_ns_type in Constants.L3_FABNETv6_SERVICES:
516+
elif requested_ns.get_type() in Constants.L3_FABNETv6_SERVICES:
517+
# Allocate the requested network if available else allocate new network
518+
if requested_ns.gateway and requested_ns.gateway.lab and requested_ns.gateway.lab.ipv6_subnet:
519+
requested_subnet = IPv6Network(requested_ns.gateway.lab.ipv6_subnet)
520+
if requested_subnet in subnet_list:
521+
gateway_labels.ipv6_subnet = requested_subnet.with_prefixlen
522+
gateway_labels.ipv6 = str(next(requested_subnet.hosts()))
523+
return gateway_labels
524+
509525
gateway_labels.ipv6_subnet = subnet_list[0].with_prefixlen
510526
gateway_labels.ipv6 = str(next(subnet_list[0].hosts()))
511527

fabric_cf/actor/core/proxies/kafka/kafka_authority_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,5 @@ def pass_authority_reservation(self, reservation: ABCReservationMixin, caller: A
154154

155155
avro_reservation.resource_set = rset
156156
if self.logger:
157-
self.logger.info(f"Outgoing Resource Set: {rset}")
157+
self.logger.debug(f"Resource Set: {rset}")
158158
return avro_reservation

fabric_cf/actor/core/proxies/kafka/kafka_retun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def pass_reservation(self, reservation: ABCServerReservation, auth: AuthToken) -
158158

159159
avro_reservation.resource_set = rset
160160
if self.logger:
161-
self.logger.info(f"Outgoing Resource Set: {rset}")
161+
self.logger.info(f"Resource Set: {rset}")
162162
return avro_reservation
163163

164164
@staticmethod

0 commit comments

Comments
 (0)