示例#1
0
    def get_attribute_values(self, attrs):
        """
        """
        log.debug("get_attribute_values: attrs=%s", attrs)

        if not isinstance(attrs, (list, tuple)):
            raise PlatformException('get_attribute_values: attrs argument must be a '
                                    'list [(attrName, from_time), ...]. Given: %s', attrs)

        # convert the ION system time from_time to NTP, as this is the time
        # format used by the RSN OMS interface:
        attrs_ntp = [(attr_id, ion_ts_2_ntp(from_time))
                     for (attr_id, from_time) in attrs]

        try:
            retval = self._rsn_oms.attr.get_platform_attribute_values(self._platform_id,
                                                                      attrs_ntp)
        except Exception as e:
            raise PlatformConnectionException(msg="Cannot get_platform_attribute_values: %s" % str(e))

        if not self._platform_id in retval:
            raise PlatformException("Unexpected: response does not include "
                                    "requested platform '%s'" % self._platform_id)

        attr_values = retval[self._platform_id]

        # reported timestamps are already in NTP. Just return the dict:
        return attr_values
示例#2
0
    def get_attribute_values(self, attrs):
        """
        """
        log.debug("get_attribute_values: attrs=%s", attrs)

        if not isinstance(attrs, (list, tuple)):
            raise PlatformException(
                'get_attribute_values: attrs argument must be a '
                'list [(attrName, from_time), ...]. Given: %s', attrs)

        # convert the ION system time from_time to NTP, as this is the time
        # format used by the RSN OMS interface:
        attrs_ntp = [(attr_id, ion_ts_2_ntp(from_time))
                     for (attr_id, from_time) in attrs]

        try:
            retval = self._rsn_oms.attr.get_platform_attribute_values(
                self._platform_id, attrs_ntp)
        except Exception as e:
            raise PlatformConnectionException(
                msg="Cannot get_platform_attribute_values: %s" % str(e))

        if not self._platform_id in retval:
            raise PlatformException("Unexpected: response does not include "
                                    "requested platform '%s'" %
                                    self._platform_id)

        attr_values = retval[self._platform_id]

        # reported timestamps are already in NTP. Just return the dict:
        return attr_values
    def get_attribute_values(self, attrs):
        """
        """
        log.debug("get_attribute_values: attrs=%s", attrs)

        if not isinstance(attrs, (list, tuple)):
            raise PlatformException('get_attribute_values: attrs argument must be a '
                                    'list [(attrName, from_time), ...]. Given: %s', attrs)

        if self._rsn_oms is None:
            raise PlatformConnectionException("Cannot get_platform_attribute_values: _rsn_oms object required (created via connect() call)")

        # convert the ION system time from_time to NTP, as this is the time
        # format used by the RSN OMS interface:
        
        # also convert the ION parameter names to RSN attribute IDs
        attrs_ntp = [(self.nodeCfgFile.GetAttrFromParameter(attr_id), ion_ts_2_ntp(from_time))
                     for (attr_id, from_time) in attrs]
        
        
        
        
        log.debug("get_attribute_values(ntp): attrs=%s", attrs_ntp)

        try:
            retval = self._rsn_oms.attr.get_platform_attribute_values(self._platform_id,
                                                                      attrs_ntp)
        except Exception as e:
            raise PlatformConnectionException(msg="Cannot get_platform_attribute_values: %s" % str(e))

        if not self._platform_id in retval:
            raise PlatformException("Unexpected: response does not include "
                                    "requested platform '%s'" % self._platform_id)

        attr_values = retval[self._platform_id]
        
        attrs_return = {}
        
        #convert back to ION parameter name and scale from OMS to ION
        for key in attr_values :
            newAttrList = []
            scaleFactor = self.nodeCfgFile.GetScaleFactorFromAttr(key)
            for v, ts in attr_values[key]:
                newAttrList.append((v*scaleFactor,ts))
            attrs_return[self.nodeCfgFile.GetParameterFromAttr(key)] = newAttrList
            
        log.debug("Back to ION=%s", attrs_return)

        

        # reported timestamps are already in NTP. Just return the dict:
        return attrs_return
    def get_attribute_values(self, attr_names, from_time):
        """
        """
        if log.isEnabledFor(logging.DEBUG):
            log.debug("get_attribute_values: attr_names=%s from_time=%s" % (
                str(attr_names), from_time))

        self._assert_rsn_oms()

        # OOIION-631 convert the system time from_time to NTP, which is used by
        # the RSN OMS interface:
        ntp_from_time = ion_ts_2_ntp(from_time)
        retval = self._rsn_oms.get_platform_attribute_values(self._platform_id, attr_names, ntp_from_time)

        if not self._platform_id in retval:
            raise PlatformException("Unexpected: response does not include "
                                    "requested platform '%s'" % self._platform_id)

        attr_values = retval[self._platform_id]

        # OOIION-631 the reported timestamps are in NTP; do conversion to system time

        if log.isEnabledFor(logging.TRACE):
            log.trace("get_attribute_values: response before conversion = %s" %
                      str(attr_values))

        conv_attr_values = {}  # the converted dictionary to return
        for attr_name, array in attr_values.iteritems():
            conv_array = []
            for (val, ntp_time) in array:

                if isinstance(ntp_time, (float, int)):
                    # do conversion:
                    sys_ts = ntp_2_ion_ts(ntp_time)
                else:
                    # NO conversion; just keep whatever the returned value is --
                    # normally an error code in str format:
                    sys_ts = ntp_time

                conv_array.append((val, sys_ts))

            conv_attr_values[attr_name] = conv_array

        if log.isEnabledFor(logging.TRACE):
            log.trace("get_attribute_values: response  after conversion = %s" %
                      str(conv_attr_values))

        return conv_attr_values
    def get_attribute_values(self, attrs):
        """
        """
        log.debug("get_attribute_values: attrs=%s", attrs)

        self._assert_rsn_oms()

        # convert the ION system time from_time to NTP, as this is the time
        # format used by the RSN OMS interface:
        attrs_ntp = [(attr_id, ion_ts_2_ntp(from_time))
                     for (attr_id, from_time) in attrs]

        retval = self._rsn_oms.get_platform_attribute_values(self._platform_id,
                                                             attrs_ntp)

        if not self._platform_id in retval:
            raise PlatformException("Unexpected: response does not include "
                                    "requested platform '%s'" % self._platform_id)

        attr_values = retval[self._platform_id]

        # reported timestamps are already in NTP. Just return the dict:
        return attr_values
示例#6
0
    def get_attribute_values(self, attr_names, from_time):
        """
        """
        if log.isEnabledFor(logging.DEBUG):
            log.debug("get_attribute_values: attr_names=%s from_time=%s" %
                      (str(attr_names), from_time))

        self._assert_rsn_oms()

        # convert the ION system time from_time to NTP, as this is the time
        # format used by the RSN OMS interface:
        ntp_from_time = ion_ts_2_ntp(from_time)
        retval = self._rsn_oms.get_platform_attribute_values(
            self._platform_id, attr_names, ntp_from_time)

        if not self._platform_id in retval:
            raise PlatformException("Unexpected: response does not include "
                                    "requested platform '%s'" %
                                    self._platform_id)

        attr_values = retval[self._platform_id]

        # reported timestamps are already in NTP. Just return the dict:
        return attr_values
    def get_attribute_values(self, attr_names, from_time):
        """
        """
        if log.isEnabledFor(logging.DEBUG):
            log.debug("get_attribute_values: attr_names=%s from_time=%s" % (
                str(attr_names), from_time))

        self._assert_rsn_oms()

        # convert the ION system time from_time to NTP, as this is the time
        # format used by the RSN OMS interface:
        ntp_from_time = ion_ts_2_ntp(from_time)
        retval = self._rsn_oms.get_platform_attribute_values(self._platform_id,
                                                             attr_names,
                                                             ntp_from_time)

        if not self._platform_id in retval:
            raise PlatformException("Unexpected: response does not include "
                                    "requested platform '%s'" % self._platform_id)

        attr_values = retval[self._platform_id]

        # reported timestamps are already in NTP. Just return the dict:
        return attr_values
示例#8
0
 def test_ion_ts_and_ntp_conversion(self):
     sys_time = get_ion_ts()
     ntp_time = ion_ts_2_ntp(sys_time)
     sys2_time = ntp_2_ion_ts(ntp_time)
     self.assertEquals(sys_time, sys2_time)
示例#9
0
 def test_ion_ts_and_ntp_conversion(self):
     sys_time = get_ion_ts()
     ntp_time = ion_ts_2_ntp(sys_time)
     sys2_time = ntp_2_ion_ts(ntp_time)
     self.assertEquals(sys_time, sys2_time)