Exemplo n.º 1
0
    def rpc_get_config (self, unused_session, rpc, source_elm, unused_filter_elm):
        assert source_elm is not None
        if source_elm.find("nc:running", namespaces=NSMAP) is None:
            raise ncerror.RPCSvrMissingElement(rpc, ncutil.elm("nc:running"))

        config = ncutil.elm("data")

        if self.is_tfm:
            profile_elm = ncutil.elm("j:scan-profile")
            config.append(profile_elm)
            profile_elm.append(ncutil.leaf_elm("j:channel-spacing",
                                               self.device.get_channel_spacing()))
            profile_elm.append(ncutil.leaf_elm("j:frequency-start",
                                               self.device.get_start_freq()))
            profile_elm.append(ncutil.leaf_elm("j:frequency-end",
                                               self.device.get_stop_freq()))
        else:
            for idx in range(1, 17):
                profile_elm = ncutil.elm("j:channel-profile")
                config.append(profile_elm)
                profile_elm.append(ncutil.leaf_elm("j:profile-index", idx))

                channels = self.device.get_channel_profile(idx)
                for freqs, freqe in channels:
                    channel_elm = ncutil.subelm(profile_elm, "j:channel")
                    range_elm = ncutil.subelm(channel_elm, "j:range")
                    range_elm.append(ncutil.leaf_elm("j:frequency-start", freqs))
                    range_elm.append(ncutil.leaf_elm("j:frequency-end", freqe))
        return config
Exemplo n.º 2
0
    def rpc_full_itu_scan (self, unused_session, rpc, *params):
        # No input values yet
        try:
            if len(params) > 2:
                raise ncerror.RPCSvrInvalidValue(rpc, message="Too many parameters")
            # XXX Should be able to use "j:high-resolution" but it fails
            hires = self._rpc_param_get_boolean(rpc, "high-resolution", False, params)
            power_only = not self._rpc_param_get_boolean(rpc, "detect-presence", False, params)
            if power_only:
                points = self._run_device_method(rpc, self.device.get_itu_power_scan, hires)
            else:
                points = self._run_device_method(rpc, self.device.get_itu_scan, hires)

            result = ncutil.elm("data")
            for tup in points:
                ptelm = ncutil.subelm(result, "j:point")
                ptelm.append(ncutil.leaf_elm("j:frequency", tup[0]))
                if power_only:
                    ptelm.append(ncutil.leaf_elm("j:power", "{:.2f}".format(tup[1].dBm)))
                else:
                    ptelm.append(ncutil.leaf_elm("j:power", "{:.2f}".format(tup[2].dBm)))
                    ptelm.append(ncutil.leaf_elm("j:channel-presence", tup[1]))
            return result
        except jerror.OCMError as ocmerr:
            logger.error("Got OCM error in full itu scan: %s: %s", str(ocmerr),
                         traceback.format_exc())
        except Exception as err:
            logger.error("Got error in full itu scan: %s: %s", str(err),
                         traceback.format_exc())
            raise
Exemplo n.º 3
0
    def _rpc_full_scan (self, method, rpc, *params):
        # No input values yet
        if params:
            logging.error("%s: _rpc_full_scan got unexpected params", str(self))
            raise ncerror.RPCSvrErrBadMsg(rpc)

        rv = self._run_device_method(rpc, method)

        result = ncutil.elm("data")
        for port, points in rv:
            portelm = ncutil.elm("j:port")
            result.append(portelm)
            portelm.append(ncutil.leaf_elm("j:port-index", port))
            for freq, power in points:
                ptelm = ncutil.subelm(portelm, "j:point")
                ptelm.append(ncutil.leaf_elm("j:frequency", freq))
                ptelm.append(ncutil.leaf_elm("j:power", "{:.2f}".format(power.dBm)))
        return result
Exemplo n.º 4
0
 def nc_append_capabilities (self, caps):
     ncutil.subelm(caps, "capability").text = NSMAP['j']
Exemplo n.º 5
0
 def nc_append_capabilities(self, capabilities):  # pylint: disable=W0613
     """The server should append any capabilities it supports to capabilities"""
     util.subelm(
         capabilities,
         "capability").text = "urn:ietf:params:netconf:capability:xpath:1.0"
     util.subelm(capabilities, "capability").text = NSMAP["sys"]
Exemplo n.º 6
0
 def nc_append_capabilities(self, caps):
     ncutil.subelm(caps, "capability").text = MODEL_NS