diff --git a/fabric_cf/actor/core/kernel/rpc_manager.py b/fabric_cf/actor/core/kernel/rpc_manager.py index fb262f31..691e3692 100644 --- a/fabric_cf/actor/core/kernel/rpc_manager.py +++ b/fabric_cf/actor/core/kernel/rpc_manager.py @@ -488,9 +488,9 @@ def do_dispatch_incoming_rpc(self, *, actor: ABCActorMixin, rpc: IncomingRPC): rpc.set_response_handler(response_handler=request.handler) actor.get_logger().debug(f"Inbound {rpc.get_request_type()} request from " - f"<{rpc.get_caller().get_name()}>:{rpc.get()}") + f"<{rpc.get_caller().get_name()}>:{rpc.get()}") - self.__log_sliver(reservation=rpc.get(), logger=actor.get_logger()) + #self.__log_sliver(reservation=rpc.get(), logger=actor.get_logger()) if rpc.get_request_type() == RPCRequestType.QueryResult: if request is None: @@ -564,7 +564,7 @@ def enqueue(self, *, rpc: RPCRequest): from fabric_cf.actor.core.container.globals import GlobalsSingleton logger = GlobalsSingleton.get().get_logger() logger.debug(f"Outbound {rpc.get_request_type()} : {rpc.get()}") - self.__log_sliver(reservation=rpc.get(), logger=logger) + #self.__log_sliver(reservation=rpc.get(), logger=logger) if not self.started: logger.warning("Ignoring RPC request: container is shutting down") return diff --git a/fabric_cf/actor/core/policy/broker_simpler_units_policy.py b/fabric_cf/actor/core/policy/broker_simpler_units_policy.py index 02bfa1e6..cac0a409 100644 --- a/fabric_cf/actor/core/policy/broker_simpler_units_policy.py +++ b/fabric_cf/actor/core/policy/broker_simpler_units_policy.py @@ -897,7 +897,7 @@ def __allocate_services(self, *, rid: ID, inv: NetworkServiceInventory, sliver: owner_switch.get_label_delegations()) else: delegation_id, delegated_label = InventoryForType.get_delegations(lab_cap_delegations= - owner_ns.get_label_delegations()) + owner_ns.get_label_delegations()) # Set the Subnet and gateway from the Owner Switch (a) existing_reservations = self.get_existing_reservations(node_id=owner_ns_id, diff --git a/fabric_cf/actor/core/policy/network_service_inventory.py b/fabric_cf/actor/core/policy/network_service_inventory.py index d5456b09..ac912b74 100644 --- a/fabric_cf/actor/core/policy/network_service_inventory.py +++ b/fabric_cf/actor/core/policy/network_service_inventory.py @@ -360,7 +360,7 @@ def allocate(self, *, rid: ID, requested_ns: NetworkServiceSliver, owner_ns: Net return requested_ns gateway_labels = self._assign_gateway_labels(ip_network=ip_network, subnet_list=subnet_list, - requested_ns_type=requested_ns.get_type()) + requested_ns=requested_ns) self.logger.debug(f"Gateway Labels: {gateway_labels}") @@ -487,25 +487,41 @@ def _get_allocated_sliver(self, reservation: ABCReservationMixin) -> NetworkServ self.logger.error("Could not find the allocated Sliver - should not reach here!") def _assign_gateway_labels(self, *, ip_network: Union[IPv4Network, IPv6Network], subnet_list: List, - requested_ns_type: str) -> Labels: + requested_ns: NetworkServiceSliver) -> Labels: """ Assign gateway labels based on the requested network service type. :param ip_network: The IP network from which subnets are derived, either IPv4Network or IPv6Network. :param subnet_list: A list of subnets derived from the ip_network. - :param requested_ns_type: The type of the requested network service. + :param requested_ns: Network Service sliver. :return: Gateway labels populated with the appropriate subnet and IP address. """ gateway_labels = Labels() - if requested_ns_type == ServiceType.FABNetv4: + if requested_ns.get_type() == ServiceType.FABNetv4: + # Allocate the requested network if available else allocate new network + if requested_ns.gateway and requested_ns.gateway.lab and requested_ns.gateway.lab.ipv4_subnet: + requested_subnet = IPv4Network(requested_ns.gateway.lab.ipv4_subnet) + if requested_subnet in subnet_list: + gateway_labels.ipv4_subnet = requested_subnet.with_prefixlen + gateway_labels.ipv4 = str(next(requested_subnet.hosts())) + return gateway_labels + gateway_labels.ipv4_subnet = subnet_list[0].with_prefixlen gateway_labels.ipv4 = str(list(subnet_list[0].hosts())[0]) - elif requested_ns_type == ServiceType.FABNetv4Ext: + elif requested_ns.get_type() == ServiceType.FABNetv4Ext: gateway_labels.ipv4_subnet = ip_network.with_prefixlen gateway_labels.ipv4 = str(subnet_list[0]) - elif requested_ns_type in Constants.L3_FABNETv6_SERVICES: + elif requested_ns.get_type() in Constants.L3_FABNETv6_SERVICES: + # Allocate the requested network if available else allocate new network + if requested_ns.gateway and requested_ns.gateway.lab and requested_ns.gateway.lab.ipv6_subnet: + requested_subnet = IPv6Network(requested_ns.gateway.lab.ipv6_subnet) + if requested_subnet in subnet_list: + gateway_labels.ipv6_subnet = requested_subnet.with_prefixlen + gateway_labels.ipv6 = str(next(requested_subnet.hosts())) + return gateway_labels + gateway_labels.ipv6_subnet = subnet_list[0].with_prefixlen gateway_labels.ipv6 = str(next(subnet_list[0].hosts())) diff --git a/fabric_cf/actor/core/proxies/kafka/kafka_authority_proxy.py b/fabric_cf/actor/core/proxies/kafka/kafka_authority_proxy.py index dd0d9475..b25c8649 100644 --- a/fabric_cf/actor/core/proxies/kafka/kafka_authority_proxy.py +++ b/fabric_cf/actor/core/proxies/kafka/kafka_authority_proxy.py @@ -154,5 +154,5 @@ def pass_authority_reservation(self, reservation: ABCReservationMixin, caller: A avro_reservation.resource_set = rset if self.logger: - self.logger.info(f"Outgoing Resource Set: {rset}") + self.logger.debug(f"Resource Set: {rset}") return avro_reservation diff --git a/fabric_cf/actor/core/proxies/kafka/kafka_retun.py b/fabric_cf/actor/core/proxies/kafka/kafka_retun.py index ecdad7cf..1ccd36dd 100644 --- a/fabric_cf/actor/core/proxies/kafka/kafka_retun.py +++ b/fabric_cf/actor/core/proxies/kafka/kafka_retun.py @@ -158,7 +158,7 @@ def pass_reservation(self, reservation: ABCServerReservation, auth: AuthToken) - avro_reservation.resource_set = rset if self.logger: - self.logger.info(f"Outgoing Resource Set: {rset}") + self.logger.info(f"Resource Set: {rset}") return avro_reservation @staticmethod