def start(self): log.debug('starting') self.root = ConfigRoot(Voltha(**self.init_kw)) registry('grpc_server').register( add_VolthaGlobalServiceServicer_to_server, self) log.info('started') return self
def disable(self): self.log.info('disabling', device_id=self.device_id) self.stop_kpi_collection() # Get the latest device reference device = self.adapter_agent.get_device(self.device_id) # Update the operational status to UNKNOWN device.oper_status = OperStatus.UNKNOWN device.connect_status = ConnectStatus.UNREACHABLE self.adapter_agent.update_device(device) # Disable all child devices first self.adapter_agent.update_child_devices_state(self.device_id, admin_state=AdminState.DISABLED) # Remove the peer references from this device self.adapter_agent.delete_all_peer_references(self.device_id) # Set all ports to disabled self.adapter_agent.disable_all_ports(self.device_id) self.close_channel() self.log.info('disabled-grpc-channel') if self.ponsim_comm == 'frameio': # close the frameio port registry('frameio').close_port(self.io_port) self.log.info('disabled-frameio-port') self.log.info('disabled', device_id=device.id)
def disable(self): self.log.info('disabling', device_id=self.device_id) # Get the latest device reference device = self.adapter_agent.get_device(self.device_id) # Update the operational status to UNKNOWN device.oper_status = OperStatus.UNKNOWN device.connect_status = ConnectStatus.UNREACHABLE self.adapter_agent.update_device(device) # Remove the logical device logical_device = self.adapter_agent.get_logical_device( self.logical_device_id) self.adapter_agent.delete_logical_device(logical_device) # Disable all child devices first self.adapter_agent.update_child_devices_state(self.device_id, admin_state=AdminState.DISABLED) # Remove the peer references from this device self.adapter_agent.delete_all_peer_references(self.device_id) # Set all ports to disabled self.adapter_agent.disable_all_ports(self.device_id) # close the frameio port registry('frameio').close_port(self.io_port) # TODO: # 1) Remove all flows from the device # 2) Remove the device from ponsim self.log.info('disabled', device_id=device.id)
def __init__(self, log, stub, device_id, logical_device_id): self.log = log self.stub = stub self.device_id = device_id self.logical_device_id = logical_device_id self.logical_flows_proxy = registry('core').get_proxy( '/logical_devices/{}/flows'.format(self.logical_device_id)) self.flows_proxy = registry('core').get_proxy( '/devices/{}/flows'.format(self.device_id)) self.root_proxy = registry('core').get_proxy('/') self.fd_object = fd.FlowDecomposer()
def __init__(self, log, stub, device_id, logical_device_id): self.log = log self.stub = stub self.device_id = device_id self.logical_device_id = logical_device_id self.logical_flows_proxy = registry('core').get_proxy( '/logical_devices/{}/flows'.format(self.logical_device_id)) self.flows_proxy = registry('core').get_proxy( '/devices/{}/flows'.format(self.device_id)) self.root_proxy = registry('core').get_proxy('/') self.platform = BBSimOltPlatform(self.log)
def __init__(self, log, stub, device_id, logical_device_id, platform, resource_mgr): self.log = log self.stub = stub self.device_id = device_id self.logical_device_id = logical_device_id self.platform = platform self.logical_flows_proxy = registry('core').get_proxy( '/logical_devices/{}/flows'.format(self.logical_device_id)) self.flows_proxy = registry('core').get_proxy( '/devices/{}/flows'.format(self.device_id)) self.root_proxy = registry('core').get_proxy('/') self.resource_mgr = resource_mgr
def __init__(self, adapter, device_id): self.adapter = adapter self.adapter_agent = adapter.adapter_agent self.device_id = device_id self.log = structlog.get_logger(device_id=device_id) self.channel = None self.io_port = None self.logical_device_id = None self.nni_port = None self.ofp_port_no = None self.interface = registry('main').get_args().interface self.ponsim_comm = registry('main').get_args().ponsim_comm self.pm_metrics = None self.alarms = None self.frames = None
def __init__(self, **kwargs): super(OpenoltDevice, self).__init__() self.adapter_agent = kwargs['adapter_agent'] self.device_num = kwargs['device_num'] device = kwargs['device'] is_reconciliation = kwargs.get('reconciliation', False) self.device_id = device.id self.host_and_port = device.host_and_port self.log = structlog.get_logger(id=self.device_id, ip=self.host_and_port) self.proxy = registry('core').get_proxy('/') # Device already set in the event of reconciliation if not is_reconciliation: # It is a new device # Update device device.root = True device.serial_number = self.host_and_port # FIXME device.connect_status = ConnectStatus.UNREACHABLE device.oper_status = OperStatus.ACTIVATING self.adapter_agent.update_device(device) # If logical device does not exist create it if not device.parent_id: dpid = '00:00:' + self.ip_hex(self.host_and_port.split(":")[0]) # Create logical OF device ld = LogicalDevice( root_device_id=self.device_id, switch_features=ofp_switch_features( n_buffers=256, # TODO fake for now n_tables=2, # TODO ditto capabilities=( # TODO and ditto OFPC_FLOW_STATS | OFPC_TABLE_STATS | OFPC_PORT_STATS | OFPC_GROUP_STATS ) ), desc=ofp_desc( serial_num=device.serial_number ) ) ld_init = self.adapter_agent.create_logical_device(ld, dpid=dpid) self.logical_device_id = ld_init.id else: # logical device already exists self.logical_device_id = device.parent_id if is_reconciliation: self.adapter_agent.reconcile_logical_device( self.logical_device_id) # Initialize the OLT state machine self.machine = Machine(model=self, states=OpenoltDevice.states, transitions=OpenoltDevice.transitions, send_event=True, initial='state_null') self.go_state_init()
def __init__(self, config): self.config = config self.periodic_check_interval = config.get( 'periodic_check_interval', 15) self.periodic_checks = None self.event_bus = EventBusClient() self.instance_id = registry('main').get_args().instance_id
def _find_first_available_id(self, dpid=None): def _is_valid_mac_address(dpid): return re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", dpid) # If a dpid is provided then validate whether it is a MAC address switch_id = 1 if dpid: dpid = dpid.lower() if not _is_valid_mac_address(dpid): raise MacAddressError('Invalid-mac-address-format') switch_id = int(dpid.replace(':', ''), 16) logical_devices = self.root_proxy.get('/logical_devices') existing_ids = set(ld.id for ld in logical_devices) existing_datapath_ids = set(ld.datapath_id for ld in logical_devices) core_id = registry('core').core_store_id while True: ld_id, dp_id = create_cluster_logical_device_ids(core_id, switch_id) id_exists = dp_id in existing_datapath_ids or ld_id in \ existing_ids if not id_exists: return ld_id, dp_id else: if dpid: raise MacAddressError('Already-registered-mac-address') else: switch_id += 1
def __init__(self, device_id, adapter_agent, platform): self.log = structlog.get_logger() self.adapter_agent = adapter_agent self.device = self.adapter_agent.get_device(device_id) self.platform = platform self.logical_device_id = None self.device.root = True self.device.connect_status = ConnectStatus.UNREACHABLE self.device.oper_status = OperStatus.ACTIVATING self.adapter_agent.update_device(self.device) self.nni_intf_id = None self.proxy = registry('core').get_proxy('/') # Hash map OnuId -> OnuInfo self._onu_ids = {} # Hash map onu serial_number (string) -> OnuInfo self._onu_serial_numbers = {} # Hash map GemPortId -> OnuInfo self._onu_gemport_ids = {}
def onu_oper_down(self, intf_id, onu_id): onu_device = self.adapter_agent.get_child_device( self.device.id, parent_port_no=self.platform.intf_id_to_port_no( intf_id, Port.PON_OLT), onu_id=onu_id) if onu_device is None: self.log.error('onu not found', intf_id=intf_id, onu_id=onu_id) return onu_adapter_agent = \ registry('adapter_loader').get_agent(onu_device.adapter) if onu_adapter_agent is None: self.log.error('onu_adapter_agent-could-not-be-retrieved', onu_device=onu_device) return if onu_device.connect_status != ConnectStatus.UNREACHABLE: onu_device.connect_status = ConnectStatus.UNREACHABLE self.adapter_agent.update_device(onu_device) # Move to discovered state self.log.debug('onu-oper-state-is-down') if onu_device.oper_status != OperStatus.DISCOVERED: onu_device.oper_status = OperStatus.DISCOVERED self.adapter_agent.update_device(onu_device) # Set port oper state to Discovered self.__onu_ports_down(onu_device) onu_adapter_agent.update_interface(onu_device, {'oper_state': 'down'})
def __init__(self, adapter_agent, log, stub, device_id, logical_device_id, platform, resource_mgr): self.adapter_agent = adapter_agent self.log = log self.stub = stub self.device_id = device_id self.logical_device_id = logical_device_id self.platform = platform self.logical_flows_proxy = registry('core').get_proxy( '/logical_devices/{}/flows'.format(self.logical_device_id)) self.flows_proxy = registry('core').get_proxy( '/devices/{}/flows'.format(self.device_id)) self.root_proxy = registry('core').get_proxy('/') self.resource_mgr = resource_mgr self.tech_profile = dict() self._populate_tech_profile_per_pon_port()
def __init__(self, config): self.config = config self.periodic_check_interval = config.get('periodic_check_interval', 15) self.periodic_checks = None self.event_bus = EventBusClient() self.instance_id = registry('main').get_args().instance_id
def __init__(self, adapter, device_id): self.log = structlog.get_logger(device_id=device_id) self.log.debug('function-entry') self.adapter = adapter self.adapter_agent = adapter.adapter_agent self.parent_adapter = None self.parent_id = None self.device_id = device_id self.incoming_messages = DeferredQueue() self.event_messages = DeferredQueue() self.proxy_address = None self.tx_id = 0 self._enabled = False self.alarms = None self.pm_metrics = None self._omcc_version = OMCCVersion.Unknown self._total_tcont_count = 0 # From ANI-G ME self._qos_flexibility = 0 # From ONT2_G ME self._onu_indication = None self._unis = dict() # Port # -> UniPort self._pon = None # TODO: probably shouldnt be hardcoded, determine from olt maybe? self._pon_port_number = 100 self.logical_device_id = None self._heartbeat = HeartBeat.create(self, device_id) # Set up OpenOMCI environment self._onu_omci_device = None self._dev_info_loaded = False self._deferred = None self._in_sync_subscription = None self._connectivity_subscription = None self._capabilities_subscription = None self.mac_bridge_service_profile_entity_id = 0x201 self.gal_enet_profile_entity_id = 0x1 self._tp_service_specific_task = dict() self._tech_profile_download_done = dict() # Initialize KV store client self.args = registry('main').get_args() if self.args.backend == 'etcd': host, port = self.args.etcd.split(':', 1) self.kv_client = EtcdStore( host, port, TechProfile.KV_STORE_TECH_PROFILE_PATH_PREFIX) elif self.args.backend == 'consul': host, port = self.args.consul.split(':', 1) self.kv_client = ConsulStore( host, port, TechProfile.KV_STORE_TECH_PROFILE_PATH_PREFIX) else: self.log.error('Invalid-backend') raise Exception("Invalid-backend-for-kv-store") # Handle received ONU event messages reactor.callLater(0, self.handle_onu_events)
def get_device_adapter_agent(self, device): assert device.adapter != '' adapter_agent = registry('adapter_loader').get_agent(device.adapter) log.debug('get-device-adapter-agent', device=device, adapter_agent=adapter_agent) return adapter_agent
def __init__(self, device_id, host_and_port, extra_args, device_info): self.log = structlog.get_logger(id=device_id, ip=host_and_port) self.device_id = device_id self.host_and_port = host_and_port self.extra_args = extra_args self.device_info = device_info self.args = registry('main').get_args() # KV store's IP Address and PORT # host, port = '127.0.0.1', 8500 if self.args.backend == 'etcd': host, port = self.args.etcd.split(':', 1) self.kv_store = EtcdStore( host, port, AdtranOltResourceMgr.BASE_PATH_KV_STORE.format(device_id)) elif self.args.backend == 'consul': host, port = self.args.consul.split(':', 1) self.kv_store = ConsulStore( host, port, AdtranOltResourceMgr.BASE_PATH_KV_STORE.format(device_id)) else: self.log.error('Invalid-backend') raise Exception("Invalid-backend-for-kv-store") self.resource_mgr = AdtranPONResourceManager( self.device_info.technology, self.extra_args, self.device_id, self.args.backend, host, port) # Flag to indicate whether information fetched from device should # be used to initialize PON Resource Ranges self.use_device_info = False self.initialize_device_resource_range_and_pool()
def __init__(self, log, stub, device_id, logical_device_id, platform, resource_mgr, data_model): self.data_model = data_model self.log = log self.stub = stub self.device_id = device_id self.logical_device_id = logical_device_id self.platform = platform self.logical_flows_proxy = registry('core').get_proxy( '/logical_devices/{}/flows'.format(self.logical_device_id)) self.flows_proxy = registry('core').get_proxy( '/devices/{}/flows'.format(self.device_id)) self.resource_mgr = resource_mgr self.tech_profile = dict() self._populate_tech_profile_per_pon_port() self.retry_add_flow_list = []
def onu_oper_up(self, onu_indication): intf_id = onu_indication.intf_id onu_id = onu_indication.onu_id onu_device = self.adapter_agent.get_child_device( self.device.id, parent_port_no=self.platform.intf_id_to_port_no( intf_id, Port.PON_OLT), onu_id=onu_id) if onu_device is None: self.log.error('onu not found', intf_id=intf_id, onu_id=onu_id) return onu_adapter_agent = \ registry('adapter_loader').get_agent(onu_device.adapter) if onu_adapter_agent is None: self.log.error('onu_adapter_agent-could-not-be-retrieved', onu_device=onu_device) return if onu_device.connect_status != ConnectStatus.REACHABLE: onu_device.connect_status = ConnectStatus.REACHABLE self.adapter_agent.update_device(onu_device) if onu_device.oper_status != OperStatus.DISCOVERED: self.log.debug("ignore onu indication", intf_id=intf_id, onu_id=onu_id, state=onu_device.oper_status, msg_oper_state="up") return onu_adapter_agent.create_interface(onu_device, onu_indication)
def __init__(self, **kwargs): super(OpenoltDevice, self).__init__() self.adapter_agent = kwargs['adapter_agent'] self.device_num = kwargs['device_num'] device = kwargs['device'] is_reconciliation = kwargs.get('reconciliation', False) self.device_id = device.id self.host_and_port = device.host_and_port self.log = structlog.get_logger(id=self.device_id, ip=self.host_and_port) self.nni_oper_state = dict() #intf_id -> oper_state self.proxy = registry('core').get_proxy('/') # Device already set in the event of reconciliation if not is_reconciliation: # It is a new device # Update device device.root = True device.serial_number = self.host_and_port # FIXME device.connect_status = ConnectStatus.REACHABLE device.oper_status = OperStatus.ACTIVATING self.adapter_agent.update_device(device) # Initialize the OLT state machine self.machine = Machine(model=self, states=OpenoltDevice.states, transitions=OpenoltDevice.transitions, send_event=True, initial='down', ignore_invalid_triggers=True) self.machine.add_transition(trigger='olt_ind_up', source='down', dest='up') self.machine.add_transition(trigger='olt_ind_loss', source='up', dest='down') # Initialize gRPC self.channel = grpc.insecure_channel(self.host_and_port) self.channel_ready_future = grpc.channel_ready_future(self.channel) self.stub = openolt_pb2_grpc.OpenoltStub(self.channel) self.flow_mgr = OpenOltFlowMgr(self.log, self.stub) # Indications thread plcaholder (started by heartbeat thread) self.indications_thread = None self.indications_thread_active = False # Start heartbeat thread self.heartbeat_thread = threading.Thread(target=self.heartbeat) self.heartbeat_thread.setDaemon(True) self.heartbeat_thread_active = True self.heartbeat_miss = 0 self.heartbeat_signature = None self.heartbeat_thread.start() self.log.debug('openolt-device-created', device_id=self.device_id)
def add_uni_ports(self): """ Called after in-sync achieved and not in xPON mode""" # TODO: We have to methods adding UNI ports. Go to one # TODO: Should this be moved to the omci.py module for this ONU? # This is only for working WITHOUT xPON pptp_entities = self.openomci.onu_omci_device.configuration.pptp_entities device = self.adapter_agent.get_device(self.device_id) multi_uni = len(pptp_entities) > 1 uni_id = 0 for entity_id, pptp in pptp_entities.items(): intf_id = self.proxy_address.channel_id onu_id = self.proxy_address.onu_id uni_no = platform.mk_uni_port_num(intf_id, onu_id, uni_id=uni_id) uni_name = "uni-{}".format(uni_no) mac_bridge_port_num = uni_id + 1 uni_port = UniPort.create(self, uni_name, uni_no, uni_name) uni_port.entity_id = entity_id uni_port.enabled = True uni_port.mac_bridge_port_num = mac_bridge_port_num uni_port.add_logical_port(uni_port.port_number, multi_uni) self.log.debug("created-uni-port", uni=uni_port) self.adapter_agent.add_port(device.id, uni_port.get_port()) parent_device = self.adapter_agent.get_device(device.parent_id) parent_adapter_agent = registry('adapter_loader').get_agent( parent_device.adapter) if parent_adapter_agent is None: self.log.error('olt-adapter-agent-could-not-be-retrieved') parent_adapter_agent.add_port(device.parent_id, uni_port.get_port()) self._unis[uni_port.port_number] = uni_port self.openomci.onu_omci_device.alarm_synchronizer.set_alarm_params( onu_id=self.proxy_address.onu_id, uni_ports=self._unis.values()) # TODO: this should be in the PonPort class pon_port = self._pon.get_port() self.adapter_agent.delete_port_reference_from_parent( self.device_id, pon_port) # Find index where this ONU peer is (should almost always be zero) d = [ i for i, e in enumerate(pon_port.peers) if e.port_no == intf_id and e.device_id == device.parent_id ] if len(d) > 0: pon_port.peers[d[0]].port_no = uni_port.port_number self.adapter_agent.add_port_reference_to_parent( self.device_id, pon_port) self.adapter_agent.update_device(device) uni_port.enabled = True uni_id += 1
def _start_tracking_peers(self): try: while True: peers_map = yield registry('coordinator').recv_peers_map() log.info('peers-map-changed', peers_map=peers_map) yield self.update_grpc_client_map(peers_map) self.peers_map = peers_map except Exception, e: log.exception('exception', e=e)
def __init__(self, adapter, device_id): self.adapter = adapter self.adapter_agent = adapter.adapter_agent self.device_id = device_id self.log = structlog.get_logger(device_id=device_id) self.channel = None self.io_port = None self.logical_device_id = None self.interface = registry('main').get_args().interface
def do_state_down(self, event): self.log.debug("do_state_down") oper_state = OperStatus.UNKNOWN connect_state = ConnectStatus.UNREACHABLE # Propagating to the children # Children ports child_devices = self.adapter_agent.get_child_devices(self.device_id) for onu_device in child_devices: uni_no = platform.mk_uni_port_num( onu_device.proxy_address.channel_id, onu_device.proxy_address.onu_id) uni_name = self.port_name(uni_no, Port.ETHERNET_UNI, serial_number=onu_device.serial_number) if onu_device.adapter == 'brcm_openomci_onu': self.log.debug('using-brcm_openomci_onu, update_interface ' 'down') onu_adapter_agent = \ registry('adapter_loader').get_agent(onu_device.adapter) onu_adapter_agent.update_interface(onu_device, {'oper_state': 'down'}) self.onu_ports_down(onu_device, uni_no, uni_name, oper_state) # Children devices self.adapter_agent.update_child_devices_state( self.device_id, oper_status=oper_state, connect_status=connect_state) # Device Ports device_ports = self.adapter_agent.get_ports(self.device_id, Port.ETHERNET_NNI) logical_ports_ids = [port.label for port in device_ports] device_ports += self.adapter_agent.get_ports(self.device_id, Port.PON_OLT) for port in device_ports: port.oper_status = oper_state self.adapter_agent.add_port(self.device_id, port) # Device logical port for logical_port_id in logical_ports_ids: logical_port = self.adapter_agent.get_logical_port( self.logical_device_id, logical_port_id) logical_port.ofp_port.state = OFPPS_LINK_DOWN self.adapter_agent.update_logical_port(self.logical_device_id, logical_port) # Device device = self.adapter_agent.get_device(self.device_id) device.oper_status = oper_state device.connect_status = connect_state reactor.callLater(2, self.adapter_agent.update_device, device)
def _add_uni_port(self, entity_id): self.log.debug('function-entry') device = self.adapter_agent.get_device(self.device_id) parent_device = self.adapter_agent.get_device(device.parent_id) parent_adapter_agent = registry('adapter_loader').get_agent( parent_device.adapter) if parent_adapter_agent is None: self.log.error('openolt_adapter_agent-could-not-be-retrieved') # TODO: This knowledge is locked away in openolt. and it assumes one onu equals one uni... uni_no_start = platform.mk_uni_port_num(self._onu_indication.intf_id, self._onu_indication.onu_id) # TODO: Some or parts of this likely need to move to UniPort. especially the format stuff working_port = self._next_port_number uni_no = uni_no_start + working_port uni_name = "uni-{}".format(uni_no) mac_bridge_port_num = working_port + 1 self.log.debug('live-port-number-ready', uni_no=uni_no, uni_name=uni_name) uni_port = UniPort.create(self, uni_name, uni_no, uni_name, device.vlan, device.vlan) uni_port.entity_id = entity_id uni_port.enabled = True uni_port.mac_bridge_port_num = mac_bridge_port_num uni_port.add_logical_port(uni_port.port_number, subscriber_vlan=device.vlan) self.log.debug("created-uni-port", uni=uni_port) self.adapter_agent.add_port(device.id, uni_port.get_port()) parent_adapter_agent.add_port(device.parent_id, uni_port.get_port()) self._unis[uni_port.port_number] = uni_port # TODO: this should be in the PonPortclass pon_port = self._pon.get_port() self.adapter_agent.delete_port_reference_from_parent( self.device_id, pon_port) pon_port.peers.extend([ Port.PeerPort(device_id=device.parent_id, port_no=uni_port.port_number) ]) self._pon._port = pon_port self.adapter_agent.add_port_reference_to_parent( self.device_id, pon_port) self.adapter_agent.update_device(device)
def __init__(self, adaptor_agent, config): self.adaptor_agent = adaptor_agent self.config = config self.descriptor = Adapter( id=self.name, vendor='Microsemi / Celestica', version='0.1', config=AdapterConfig(log_level=LogLevel.INFO)) self.interface = registry('main').get_args().interface
def start(self, config_backend=None): log.debug('starting') if config_backend: if 'root' in config_backend: # This is going to block the entire reactor until loading is completed log.info('loading config from persisted backend') self.root = ConfigRoot.load(VolthaInstance, kv_store=config_backend) else: log.info('initializing new config') self.root = ConfigRoot(VolthaInstance(**self.init_kw), kv_store=config_backend) else: self.root = ConfigRoot(VolthaInstance(**self.init_kw)) registry('grpc_server').register( add_VolthaLocalServiceServicer_to_server, self) log.info('started') return self
def _set_adapter_agent(self): adapter_name = self._tmp_initial_data.adapter if adapter_name == '': proxy = self.core.get_proxy('/') known_device_types = dict( (dt.id, dt) for dt in proxy.get('/device_types')) device_type = known_device_types[self._tmp_initial_data.type] adapter_name = device_type.adapter assert adapter_name != '' self.adapter_agent = registry('adapter_loader').get_agent(adapter_name)
def delete(self): self.log.info('deleting', device_id=self.device_id) # Remove all child devices self.adapter_agent.delete_all_child_devices(self.device_id) self.close_channel() self.log.info('disabled-grpc-channel') if self.ponsim_comm == 'frameio': # close the frameio port registry('frameio').close_port(self.io_port) self.log.info('disabled-frameio-port') # TODO: # 1) Remove all flows from the device # 2) Remove the device from ponsim self.log.info('deleted', device_id=self.device_id)
def __init__(self, **kwargs): super(OpenoltDevice, self).__init__() self.admin_state = "up" self.adapter_agent = kwargs['adapter_agent'] self.device_num = kwargs['device_num'] device = kwargs['device'] self.platform_class = kwargs['support_classes']['platform'] self.resource_mgr_class = kwargs['support_classes']['resource_mgr'] self.flow_mgr_class = kwargs['support_classes']['flow_mgr'] self.alarm_mgr_class = kwargs['support_classes']['alarm_mgr'] self.stats_mgr_class = kwargs['support_classes']['stats_mgr'] self.bw_mgr_class = kwargs['support_classes']['bw_mgr'] is_reconciliation = kwargs.get('reconciliation', False) self.device_id = device.id self.host_and_port = device.host_and_port self.extra_args = device.extra_args self.log = structlog.get_logger(id=self.device_id, ip=self.host_and_port) self.proxy = registry('core').get_proxy('/') self.log.info('openolt-device-init') # default device id and device serial number. If device_info provides better results, they will be updated self.dpid = kwargs.get('dp_id') self.serial_number = self.host_and_port # FIXME # Device already set in the event of reconciliation if not is_reconciliation: self.log.info('updating-device') # It is a new device # Update device device.root = True device.connect_status = ConnectStatus.UNREACHABLE device.oper_status = OperStatus.ACTIVATING self.adapter_agent.update_device(device) # If logical device does exist use it, else create one after connecting to device if device.parent_id: # logical device already exists self.logical_device_id = device.parent_id if is_reconciliation: self.adapter_agent.reconcile_logical_device( self.logical_device_id) # Initialize the OLT state machine self.machine = Machine(model=self, states=OpenoltDevice.states, transitions=OpenoltDevice.transitions, send_event=True, initial='state_null') self.go_state_init()
def __init__(self): kafka_proxy = registry('kafka_proxy') if kafka_proxy and not kafka_proxy.is_faulty(): kafka_endpoint = kafka_proxy.kafka_endpoint log.debug('kafka-proxy-available', endpoint=kafka_endpoint) else: log.error('kafka-proxy-unavailable') return # Create Admin client self.admin_client = AdminClient({'bootstrap.servers': kafka_endpoint})
def __init__(self, adaptor_agent, config): self.adaptor_agent = adaptor_agent self.config = config self.olts = {} self.descriptor = Adapter( id=self.name, vendor='Microsemi / Celestica', version='0.1', config=AdapterConfig(log_level=LogLevel.INFO) ) self.interface = registry('main').get_args().interface
def __init__(self, adapter_name, adapter_cls): self.adapter_name = adapter_name self.adapter_cls = adapter_cls self.core = registry('core') self.adapter = None self.adapter_node_proxy = None self.root_proxy = self.core.get_proxy('/') self._rx_event_subscriptions = {} self._tx_event_subscriptions = {} self.event_bus = EventBusClient() self.packet_out_subscription = None self.log = structlog.get_logger(adapter_name=adapter_name) self._onu_detect_event_subscriptions = {}
def __init__(self, adapter_agent, config): self.adapter_agent = adapter_agent self.config = config self.descriptor = Adapter( id=self.name, vendor='Adtran, Inc.', version='0.13', config=AdapterConfig(log_level=LogLevel.INFO) ) log.debug('adtran_olt.__init__', adapter_agent=adapter_agent) self.devices_handlers = dict() # device_id -> AdtranOltHandler() self.interface = registry('main').get_args().interface self.logical_device_id_to_root_device_id = dict()
def startup_components(self): try: self.log.info('starting-internal-components', internal_host=self.args.internal_host_address, external_host=self.args.external_host_address, interface=self.args.interface, consul=self.args.consul, etcd=self.args.etcd) registry.register('main', self) if self.args.backend == 'consul': yield registry.register( 'coordinator', Coordinator( internal_host_address=self.args.internal_host_address, external_host_address=self.args.external_host_address, rest_port=self.args.rest_port, instance_id=self.instance_id, config=self.config, consul=self.args.consul) ).start() elif self.args.backend == 'etcd': yield registry.register( 'coordinator', CoordinatorEtcd( internal_host_address=self.args.internal_host_address, external_host_address=self.args.external_host_address, rest_port=self.args.rest_port, instance_id=self.instance_id, config=self.config, consul=self.args.consul, etcd=self.args.etcd) ).start() self.log.info('waiting-for-config-assignment') # Wait until we get a config id before we proceed self.core_store_id, store_prefix = \ yield registry('coordinator').get_core_store_id_and_prefix() self.log.info('store-id', core_store_id=self.core_store_id) # Update the logger to output the vcore id. self.log = update_logging(instance_id=self.instance_id, vcore_id=self.core_store_id) yield registry.register( 'grpc_server', VolthaGrpcServer(self.args.grpc_port) ).start() yield registry.register( 'core', VolthaCore( instance_id=self.instance_id, core_store_id = self.core_store_id, grpc_port=self.args.grpc_port, version=VERSION, log_level=LogLevel.INFO ) ).start(config_backend=load_backend(store_id=self.core_store_id, store_prefix=store_prefix, args=self.args)) init_rest_service(self.args.rest_port) yield registry.register( 'kafka_proxy', KafkaProxy( self.args.consul, self.args.kafka, config=self.config.get('kafka-proxy', {}) ) ).start() yield registry.register( 'frameio', FrameIOManager() ).start() yield registry.register( 'adapter_loader', AdapterLoader(config=self.config.get('adapter_loader', {})) ).start() yield registry.register( 'diag', Diagnostics(config=self.config.get('diagnostics', {})) ).start() if self.args.manhole_port is not None: self.start_manhole(self.args.manhole_port) # Now that all components are loaded, in the scenario where this # voltha instance is picking up an existing set of data (from a # voltha instance that dies/stopped) then we need to setup this # instance from where the previous one left yield registry('core').reconcile_data() # Now that the data is in memory and the reconcile process # within the core has completed (the reconciliation may still be # in progress with the adapters) we expose the NBI of voltha core yield registry('core').register_grpc_service() self.log.info('started-internal-services') except Exception as e: self.log.exception('Failure-to-start-all-components', e=e)