Skip to content

Commit

Permalink
chore(agw): Delete unused class MobilityServiceRest (magma#12636)
Browse files Browse the repository at this point in the history
Signed-off-by: Cameron Voisey <cameron.voisey@tngtech.com>
  • Loading branch information
voisey authored and emakeev committed Aug 5, 2022
1 parent a994ebe commit d858803
Showing 1 changed file with 0 additions and 130 deletions.
130 changes: 0 additions & 130 deletions lte/gateway/python/integ_tests/common/mobility_service_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import time

import grpc
# from integ_tests.cloud.fixtures import GATEWAY_ID, NETWORK_ID
from integ_tests.gateway.rpc import get_gateway_hw_id, get_rpc_channel
from lte.protos.mobilityd_pb2 import IPAddress, IPBlock, RemoveIPBlockRequest
from lte.protos.mobilityd_pb2_grpc import MobilityServiceStub
Expand Down Expand Up @@ -194,132 +193,3 @@ def remove_all_ip_blocks(self):
def wait_for_changes(self):
""" All changes propagate immediately, no need to wait """
return


# class MobilityServiceRest(MobilityServiceClient):
# """
# Handle mobility actions by making REST calls to the cloud.
#
# Note that, while the gRPC API exposes support for multiple
# mobilityd IP blocks, the REST API does not. It supports
# only a single IP block. This class fails an assertion on attempts
# to add more than 1 block at a time.
# """
#
# def __init__(self, cloud_manager, gateway_services):
# """ Init the REST endpoint. """
# self._cloud_manager = cloud_manager
# self._gateway_services = gateway_services
#
# self._cloud_manager.create_network(NETWORK_ID)
# self._cloud_manager.register_gateway(
# NETWORK_ID,
# GATEWAY_ID,
# get_gateway_hw_id(),
# )
#
# # Create mobility gRPC stub to communicate directly with the gateway
# self._mobility_grpc = MobilityServiceGrpc()
#
# # Used for knowing when the gateway should restart after
# # Initialize to 0 so no restart is required by default
# self._last_change_time = 0
#
# def _get_gateway_config_from_cloud(self):
# """ Get the gateway config record. """
# gateway_config = self._cloud_manager \
# .gateways_api \
# .networks_network_id_gateways_gateway_id_configs_cellular_get(
# NETWORK_ID, GATEWAY_ID)
# return gateway_config
#
# def _update_mobilityd_ip_block(self, block):
# """
# Pull the full config record, update its ip_block, then push
# the updated record.
#
# Args:
# block (ipaddress.ip_network): address to update with
# """
# gateway_config = self._get_gateway_config_from_cloud()
#
# old_block = gateway_config.epc.ip_block
# new_block = block.with_prefixlen
#
# if old_block != new_block:
# gateway_config.epc.ip_block = new_block
# self._cloud_manager.gateways_api. \
# networks_network_id_gateways_gateway_id_configs_cellular_put(
# NETWORK_ID, GATEWAY_ID, gateway_config)
#
# def _delete_block(self):
# """
# Delete an IP block via the cloud REST API.
#
# TODO: not sure how to delete yet, see T19922441.
# """
# deleted_ip_placeholder = ipaddress.ip_network('0.0.0.0/32')
# self._update_mobilityd_ip_block(deleted_ip_placeholder)
#
# def _cloud_equal_gateway_ips(self):
# """
# Check that cloud IP networks match gateway IP networks.
#
# HACK: since we don't know how to delete ip blocks from the cloud yet,
# we can treat the following as equal:
# cloud: [0.0.0.0/32]
# gateway: []
#
# Returns:
# equal (bool): True if IP networks are equivalent; False otherwise
# """
# cloud_ips = self.list_added_blocks()
# gateway_ips = self._mobility_grpc.list_added_blocks()
# cloud_ips_set = self._ip_block_list_to_set(cloud_ips)
# gateway_ips_set = self._ip_block_list_to_set(gateway_ips)
#
# return cloud_ips_set == gateway_ips_set
#
# def _ip_block_list_to_set(self, ip_block_list):
# ip_set = {ip.with_prefixlen for ip in ip_block_list}
# ip_set.discard('0.0.0.0/32')
# return ip_set
#
# def add_ip_block(self, block):
# # to update gateway, remove old ip blocks and then add new one
# self._last_change_time = time.time()
# self._update_mobilityd_ip_block(block)
#
# def list_added_blocks(self):
# ip_block = self._get_gateway_config_from_cloud().epc.ip_block
# network = ipaddress.ip_network(ip_block)
# return [network]
#
# def remove_ip_blocks(self, blocks):
# removed_blocks = []
# for block in self.list_added_blocks():
# if block in blocks:
# self._last_change_time = time.time()
# self._delete_block()
# removed_blocks.append(block)
# return [removed_blocks]
#
# def get_subscriber_ip_table(self):
# # HACK: IP tables intentionally not exposed over the REST API
# ip_table = self._mobility_grpc.get_subscriber_ip_table()
# return ip_table
#
# def remove_all_ip_blocks(self):
# blocks = self.list_added_blocks()
# self.remove_ip_blocks(blocks)
#
# def wait_for_changes(self):
# if self._cloud_equal_gateway_ips():
# # Shouldn't wait, because gateway won't restart
# return
# print("Added IP block to cloud, waiting for gateway restart")
# self._gateway_services.wait_for_healthy_gateway(
# after_start_time=self._last_change_time)
# print("Gateway healthy after restart")
# assert(self._cloud_equal_gateway_ips())
#

0 comments on commit d858803

Please sign in to comment.