def _deregister_feg_gw(location_docker_compose: str): with open(SNOWFLAKE_FEG_FILE) as f: hw_id = f.read().rstrip('\n') if not hw_id: print(f'Could not open test feg snowflake {SNOWFLAKE_FEG_FILE}') hw_id = dev_utils.get_gateway_hardware_id_from_docker( location_docker_compose=location_docker_compose, ) already_registered, registered_as = dev_utils.is_hw_id_registered( NETWORK_ID, hw_id, ) if not already_registered: print() print('===========================================') print('VM is not registered') print('===========================================') return dev_utils.cloud_delete(f'feg/{NETWORK_ID}/gateways/{registered_as}') print() print('=========================================') print(f'Feg Gateway {registered_as} successfully removed!') print('=========================================')
def _register_feg(): with lcd('docker'), hide('output', 'running', 'warnings'): hw_id = local( 'docker-compose exec magmad bash -c "cat /etc/snowflake"', capture=True, ) already_registered, registered_as = dev_utils.is_hw_id_registered( NETWORK_ID, hw_id, ) if already_registered: print() print(f'============================================') print(f'Feg is already registered as {registered_as}') print(f'============================================') return gw_id = dev_utils.get_next_available_gateway_id(NETWORK_ID) md_gw = dev_utils.construct_magmad_gateway_payload(gw_id, hw_id) gw_payload = FederationGateway( id=md_gw.id, name=md_gw.name, description=md_gw.description, device=md_gw.device, magmad=md_gw.magmad, tier=md_gw.tier, ) dev_utils.cloud_post(f'feg/{NETWORK_ID}/gateways', gw_payload) print() print(f'=====================================') print(f'Feg {gw_id} successfully provisioned!') print(f'=====================================')
def _register_agw(network_type: str): network_id = NIDS_BY_TYPE[network_type] hw_id = dev_utils.get_hardware_id_from_vagrant(vm_name='magma') already_registered, registered_as = dev_utils.is_hw_id_registered( network_id, hw_id, ) if already_registered: print() print(f'===========================================') print(f'VM is already registered as {registered_as}') print(f'===========================================') return gw_id = dev_utils.get_next_available_gateway_id(network_id) md_gw = dev_utils.construct_magmad_gateway_payload(gw_id, hw_id) gw_payload = LTEGateway( device=md_gw.device, id=gw_id, name=md_gw.name, description=md_gw.description, magmad=md_gw.magmad, tier=md_gw.tier, cellular=GatewayCellularConfig( epc=GatewayEPCConfig(ip_block='192.168.128.0/24', nat_enabled=True), ran=GatewayRANConfig(pci=260, transmit_enabled=True), ), connected_enodeb_serials=[], ) dev_utils.cloud_post(f'{network_type}/{network_id}/gateways', gw_payload) print() print(f'=========================================') print(f'Gateway {gw_id} successfully provisioned!') print(f'=========================================')
def _register_feg(location_docker_compose: str): with open(SNOWFLAKE_FEG_FILE) as f: hw_id = f.read().rstrip('\n') if not hw_id: print(f'Could not open test feg snowflake {SNOWFLAKE_FEG_FILE}') hw_id = dev_utils.get_gateway_hardware_id_from_docker( location_docker_compose=location_docker_compose, ) already_registered, registered_as = dev_utils.is_hw_id_registered( NETWORK_ID, hw_id, ) if already_registered: print() print('============================================') print(f'Feg is already registered as {registered_as}') print('============================================') return gw_id = dev_utils.get_next_available_gateway_id(NETWORK_ID) md_gw = dev_utils.construct_magmad_gateway_payload(gw_id, hw_id) gw_payload = FederationGateway( id=md_gw.id, name=md_gw.name, description=md_gw.description, device=md_gw.device, magmad=md_gw.magmad, tier=md_gw.tier, federation=FederationNetworkConfigs( hss=HssConfigs(server=HssServer( local_address='localhost:3767', address='localhost:3768', ), ), s6a=S6aConfigs( plmn_ids=[], server=DiamServerConfig( local_address='localhost:3767', address='localhost:3768', ), ), gx=GxConfig(servers=[ DiamServerConfig(address='localhost:3868', ), ], ), gy=GyConfig(servers=[ DiamServerConfig(address='localhost:3968', ), ], ), ), ) dev_utils.cloud_post(f'feg/{NETWORK_ID}/gateways', gw_payload) print() print('=====================================') print(f'Feg {gw_id} successfully provisioned!') print('=====================================')
def _deregister_agw(network_type: str): network_id = NIDS_BY_TYPE[network_type] hw_id = dev_utils.get_gateway_hardware_id_from_vagrant(vm_name='magma') already_registered, registered_as = dev_utils.is_hw_id_registered( network_id, hw_id, ) if not already_registered: print() print('===========================================') print(f'VM is not registered (hwid: {hw_id} )') print('===========================================') return dev_utils.cloud_delete(f'lte/{network_id}/gateways/{registered_as}') print() print('=========================================') print(f'AGW Gateway {registered_as} successfully removed!') print(f'(restart AGW services on magma vm)') print('=========================================')
def register_vm(): # Disable warnings about SSL verification since its a local VM urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Create the network if it doesn't yet exist # TODO: add cellular network configs if the network exists but the cellular # configs don't if not dev_utils.does_network_exist('test'): network_payload = LTENetwork( id='test', name='Test Network', description='Test Network', cellular=NetworkCellularConfig( epc=NetworkEPCConfig( lte_auth_amf='gAA=', lte_auth_op='EREREREREREREREREREREQ==', mcc='001', mnc='01', tac=1, relay_enabled=False, ), ran=NetworkRANConfig( bandwidth_mhz=20, tdd_config=NetworkTDDConfig( earfcndl=44590, subframe_assignment=2, special_subframe_pattern=7, ), ), ), dns=types.NetworkDNSConfig(enable_caching=True, local_ttl=60), ) dev_utils.cloud_post('lte', network_payload) dev_utils.create_tier_if_not_exists('test', 'default') hw_id = dev_utils.get_hardware_id_from_vagrant(vm_name='magma') already_registered, registered_as = dev_utils.is_hw_id_registered( 'test', hw_id) if already_registered: print() print(f'===========================================') print(f'VM is already registered as {registered_as}') print(f'===========================================') return gw_id = dev_utils.get_next_available_gateway_id('test') md_gw = dev_utils.construct_magmad_gateway_payload(gw_id, hw_id) gw_payload = LTEGateway( device=md_gw.device, id=gw_id, name=md_gw.name, description=md_gw.description, magmad=md_gw.magmad, tier=md_gw.tier, cellular=GatewayCellularConfig( epc=GatewayEPCConfig(ip_block='192.168.128.0/24', nat_enabled=True), ran=GatewayRANConfig(pci=260, transmit_enabled=True), ), connected_enodeb_serials=[], ) dev_utils.cloud_post('lte/test/gateways', gw_payload) print() print(f'=========================================') print(f'Gateway {gw_id} successfully provisioned!') print(f'=========================================')
def _register_agw( network_type: str, url: Optional[str] = None, admin_cert: Optional[types.ClientCert] = None, network_id: Optional[str] = None, ): network_id = network_id or NIDS_BY_TYPE[network_type] dev_utils.create_tier_if_not_exists( network_id, 'default', url=url, admin_cert=admin_cert, ) hw_id = dev_utils.get_gateway_hardware_id_from_vagrant(vm_name='magma') already_registered, registered_as = dev_utils.is_hw_id_registered( network_id, hw_id, url=url, admin_cert=admin_cert, ) if already_registered: print() print(f'===========================================') print(f'VM is already registered as {registered_as}') print(f'===========================================') return gw_id = dev_utils.get_next_available_gateway_id( network_id, url=url, admin_cert=admin_cert, ) md_gw = dev_utils.construct_magmad_gateway_payload(gw_id, hw_id) gw_payload = LTEGateway( device=md_gw.device, id=gw_id, name=md_gw.name, description=md_gw.description, magmad=md_gw.magmad, tier=md_gw.tier, cellular=GatewayCellularConfig( epc=GatewayEPCConfig( ip_block='192.168.128.0/24', nat_enabled=True, ), ran=GatewayRANConfig(pci=260, transmit_enabled=True), ), connected_enodeb_serials=[], ) dev_utils.cloud_post( f'lte/{network_id}/gateways', gw_payload, url=url, admin_cert=admin_cert, ) print() print(f'=========================================') print(f'Gateway {gw_id} successfully provisioned!') print(f'=========================================')