Ejemplo n.º 1
0
    def make_proto(self, pm_config=None):
        if pm_config is None:
            pm_config = PmConfigs(id=self.device_id,
                                  default_freq=self.default_freq,
                                  grouped=self.grouped,
                                  freq_override=self.freq_override)
        metrics = set()

        if self._heartbeat is not None:
            if self.grouped:
                pm_health_stats = PmGroupConfig(group_name='Heartbeat',
                                                group_freq=OnuPmMetrics.DEFAULT_HEARTBEAT_FREQUENCY,
                                                enabled=OnuPmMetrics.DEFAULT_HEARTBEAT_ENABLED)
                self.pm_group_metrics[pm_health_stats.group_name] = pm_health_stats
            else:
                pm_health_stats = pm_config

            # Add metrics to the PM Group (or as individual metrics_
            for m in sorted(self.health_metrics_config):
                pm = self.health_metrics_config[m]
                if not self.grouped:
                    if pm.name in metrics:
                        continue
                    metrics.add(pm.name)

                pm_health_stats.metrics.extend([PmConfig(name=pm.name,
                                                         type=pm.type,
                                                         enabled=pm.enabled)])
            if self.grouped:
                pm_config.groups.extend([pm_health_stats])

        # TODO Add PON Port PM
        # TODO Add UNI Port PM
        pm_config = self.omci_pm.make_proto(pm_config)
        return pm_config
Ejemplo n.º 2
0
    def make_proto(self):
        pm_config = PmConfigs(id=self.id, default_freq=self.default_freq,
                              grouped=False, freq_override=False)

        for m in sorted(self.pon_metrics_config):
            pm = self.pon_metrics_config[m]  # Either will do they're the same
            pm_config.metrics.extend([PmConfig(name=pm.name, type=pm.type,
                                               enabled=pm.enabled)])
        return pm_config
Ejemplo n.º 3
0
    def make_proto(self):
        pm_config = PmConfigs(id=self.id,
                              default_freq=self.default_freq,
                              grouped=True,
                              freq_override=False)
        for m in self.pm_group_names:
            pm_config.groups.extend([self.pm_group_metrics[m].config])

        return pm_config
Ejemplo n.º 4
0
    def ListDevicePmConfigs(self, request, context):
        log.info('grpc-request', request=request)

        if '/' in request.id:
            context.set_details('Malformed device id \'{}\''.format(
                request.id))
            context.set_code(StatusCode.INVALID_ARGUMENT)
            return PmConfigs()

        try:
            pm_configs = self.root.get('/devices/{}/pm_configs'.format(
                request.id))
            pm_configs.id = request.id
            log.info('device-for-pms', pm_configs=pm_configs)
            return pm_configs
        except KeyError:
            context.set_details('Device \'{}\' not found'.format(request.id))
            context.set_code(StatusCode.NOT_FOUND)
            return PmConfigs()
Ejemplo n.º 5
0
 def make_proto(self):
     pm_config = PmConfigs(
         id=self.id,
         default_freq=self.default_freq,
         grouped = False,
         freq_override = False)
     for m in sorted(self.pon_metrics):
         pm=self.pon_metrics[m]
         pm_config.metrics.extend([PmConfig(name=pm.config.name,
                                            type=pm.config.type,
                                            enabled=pm.config.enabled)])
     return pm_config
Ejemplo n.º 6
0
    def ListDevicePmConfigs(self, request, context):
        log.info('grpc-request', request=request)

        try:
            instance_id = self.dispatcher.instance_id_by_device_id(request.id)
        except KeyError:
            context.set_details('Device \'{}\' not found'.format(request.id))
            context.set_code(StatusCode.NOT_FOUND)
            return PmConfigs()

        return self.dispatcher.dispatch(instance_id, VolthaLocalServiceStub,
                                        'ListDevicePmConfigs', request,
                                        context)
Ejemplo n.º 7
0
    def make_proto(self):
        pm_config = PmConfigs(id=self.id, default_freq=self.default_freq,
                              grouped=self.grouped,
                              freq_override=self.freq_override)
        metrics = set()

        if self.grouped:
            pm_omci_stats = PmGroupConfig(group_name='OMCI',
                                          group_freq=self.default_freq,
                                          enabled=True)

            pm_health_stats = PmGroupConfig(group_name='Heartbeat',
                                            group_freq=self.default_freq,
                                            enabled=True)
            # TODO Add PON Port PM
            # TODO Add UNI Port PM
        else:
            pm_omci_stats = pm_config
            pm_health_stats = pm_config
            # TODO Add PON Port PM
            # TODO Add UNI Port PM

        for m in sorted(self.omci_metrics_config):
            pm = self.omci_metrics_config[m]
            if not self.grouped:
                if pm.name in metrics:
                    continue
                metrics.add(pm.name)

            pm_omci_stats.metrics.extend([PmConfig(name=pm.name,
                                                   type=pm.type,
                                                   enabled=pm.enabled)])

        for m in sorted(self.health_metrics_config):
            pm = self.health_metrics_config[m]
            if not self.grouped:
                if pm.name in metrics:
                    continue
                metrics.add(pm.name)

            pm_health_stats.metrics.extend([PmConfig(name=pm.name,
                                                     type=pm.type,
                                                     enabled=pm.enabled)])

        return pm_config
Ejemplo n.º 8
0
    def make_proto(self):
        pm_config = PmConfigs(id=self.id, default_freq=self.default_freq,
                              grouped=self.grouped,
                              freq_override=self.freq_override)
        metrics = set()

        if self.grouped:
            pm_ether_stats = PmGroupConfig(group_name='Ethernet',
                                           group_freq=self.default_freq,
                                           enabled=True)

            pm_pon_stats = PmGroupConfig(group_name='PON',
                                         group_freq=self.default_freq,
                                         enabled=True)

            pm_ont_stats = PmGroupConfig(group_name='ONT',
                                         group_freq=self.default_freq,
                                         enabled=True)

            pm_gem_stats = PmGroupConfig(group_name='GEM',
                                         group_freq=self.default_freq,
                                         enabled=True)
        else:
            pm_ether_stats = pm_config
            pm_pon_stats = pm_config
            pm_ont_stats = pm_config
            pm_gem_stats = pm_config

        for m in sorted(self.nni_metrics_config):
            pm = self.nni_metrics_config[m]
            if not self.grouped:
                if pm.name in metrics:
                    continue
                metrics.add(pm.name)
            pm_ether_stats.metrics.extend([PmConfig(name=pm.name,
                                                    type=pm.type,
                                                    enabled=pm.enabled)])

        for m in sorted(self.pon_metrics_config):
            pm = self.pon_metrics_config[m]
            if not self.grouped:
                if pm.name in metrics:
                    continue
                metrics.add(pm.name)
            pm_pon_stats.metrics.extend([PmConfig(name=pm.name,
                                                  type=pm.type,
                                                  enabled=pm.enabled)])

        for m in sorted(self.onu_metrics_config):
            pm = self.onu_metrics_config[m]
            if not self.grouped:
                if pm.name in metrics:
                    continue
                metrics.add(pm.name)
            pm_ont_stats.metrics.extend([PmConfig(name=pm.name,
                                                  type=pm.type,
                                                  enabled=pm.enabled)])

        for m in sorted(self.gem_metrics_config):
            pm = self.gem_metrics_config[m]
            if not self.grouped:
                if pm.name in metrics:
                    continue
                metrics.add(pm.name)
            pm_gem_stats.metrics.extend([PmConfig(name=pm.name,
                                                  type=pm.type,
                                                  enabled=pm.enabled)])
        if self.grouped:
            pm_config.groups.extend([pm_ether_stats,
                                     pm_pon_stats,
                                     pm_ont_stats,
                                     pm_gem_stats])
        return pm_config
Ejemplo n.º 9
0
    def make_proto(self, pm_config=None):
        if pm_config is None:
            pm_config = PmConfigs(id=self.device_id,
                                  default_freq=self.default_freq,
                                  grouped=self.grouped,
                                  freq_override=self.freq_override)
        metrics = set()
        have_nni = self._nni_ports is not None and len(self._nni_ports) > 0
        have_pon = self._pon_ports is not None and len(self._pon_ports) > 0

        if self.grouped:
            if have_nni:
                pm_ether_stats = PmGroupConfig(group_name='Ethernet',
                                               group_freq=self.default_freq,
                                               enabled=True)
            else:
                pm_ether_stats = None

            if have_pon:
                pm_pon_stats = PmGroupConfig(group_name='PON',
                                             group_freq=self.default_freq,
                                             enabled=True)

                pm_ont_stats = PmGroupConfig(group_name='ONT',
                                             group_freq=self.default_freq,
                                             enabled=True)

                pm_gem_stats = PmGroupConfig(group_name='GEM',
                                             group_freq=self.default_freq,
                                             enabled=True)
            else:
                pm_pon_stats = None
                pm_ont_stats = None
                pm_gem_stats = None

        else:
            pm_ether_stats = pm_config if have_nni else None
            pm_pon_stats = pm_config if have_pon else None
            pm_ont_stats = pm_config if have_pon else None
            pm_gem_stats = pm_config if have_pon else None

        if have_nni:
            for m in sorted(self.nni_metrics_config):
                pm = self.nni_metrics_config[m]
                if not self.grouped:
                    if pm.name in metrics:
                        continue
                    metrics.add(pm.name)
                pm_ether_stats.metrics.extend(
                    [PmConfig(name=pm.name, type=pm.type, enabled=pm.enabled)])
        if have_pon:
            for m in sorted(self.pon_metrics_config):
                pm = self.pon_metrics_config[m]
                if not self.grouped:
                    if pm.name in metrics:
                        continue
                    metrics.add(pm.name)
                pm_pon_stats.metrics.extend(
                    [PmConfig(name=pm.name, type=pm.type, enabled=pm.enabled)])

            for m in sorted(self.onu_metrics_config):
                pm = self.onu_metrics_config[m]
                if not self.grouped:
                    if pm.name in metrics:
                        continue
                    metrics.add(pm.name)
                pm_ont_stats.metrics.extend(
                    [PmConfig(name=pm.name, type=pm.type, enabled=pm.enabled)])

            for m in sorted(self.gem_metrics_config):
                pm = self.gem_metrics_config[m]
                if not self.grouped:
                    if pm.name in metrics:
                        continue
                    metrics.add(pm.name)
                pm_gem_stats.metrics.extend(
                    [PmConfig(name=pm.name, type=pm.type, enabled=pm.enabled)])
        if self.grouped:
            pm_groups = [
                stats for stats in (pm_ether_stats, pm_pon_stats, pm_ont_stats,
                                    pm_gem_stats) if stats is not None
            ]
            pm_config.groups.extend(pm_groups)

        return pm_config