Beispiel #1
0
        def set_ports(pnode):
            platform_id = pnode.platform_id
            port_infos = rsn_oms.port.get_platform_ports(platform_id)
            if not isinstance(port_infos, dict):
                raise PlatformDriverException(
                    "%r: get_platform_ports response is not a dict: %s" % (
                    platform_id, port_infos))

            if log.isEnabledFor(logging.TRACE):
                log.trace("%r: port_infos: %s", platform_id, port_infos)

            if not platform_id in port_infos:
                raise PlatformDriverException(
                    "%r: get_platform_ports response does not include "
                    "platform_id: %s" % (platform_id, port_infos))

            ports = port_infos[platform_id]

            if not isinstance(ports, dict):
                raise PlatformDriverException(
                    "%r: get_platform_ports: entry for platform_id is "
                    "not a dict: %s" % (platform_id, ports))

            for port_id, dic in ports.iteritems():
                port = PortNode(port_id)
                port.set_state(dic['state'])
                pnode.add_port(port)

                # add connected instruments:
                instrs_res = rsn_oms.instr.get_connected_instruments(platform_id, port_id)
                if not isinstance(instrs_res, dict):
                    log.warn("%r: port_id=%r: get_connected_instruments "
                             "response is not a dict: %s" % (platform_id, port_id, instrs_res))
                    continue

                if log.isEnabledFor(logging.TRACE):
                    log.trace("%r: port_id=%r: get_connected_instruments "
                              "returned: %s" % (platform_id, port_id, instrs_res))

                if not platform_id in instrs_res:
                    raise PlatformDriverException(
                        "%r: port_id=%r: get_connected_instruments response"
                        "does not have entry for platform_id: %s" % (
                        platform_id, ports))

                if not port_id in instrs_res[platform_id]:
                    raise PlatformDriverException(
                        "%r: port_id=%r: get_connected_instruments response "
                        "for platform_id does not have entry for port_id: %s" % (
                        platform_id, port_id, instrs_res[platform_id]))

                instr = instrs_res[platform_id][port_id]
                for instrument_id, attrs in instr.iteritems():
                    port.add_instrument(InstrumentNode(instrument_id, attrs))
 def validate_driver_configuration(self, driver_config):
     """
     Driver config must include 'oms_uri' entry.
     """
     if 'oms_uri' not in driver_config:
         log.error("'oms_uri' not present in driver_config = %r", driver_config)
         raise PlatformDriverException(msg="driver_config does not indicate 'oms_uri'")
Beispiel #3
0
        def set_attributes(pnode):
            platform_id = pnode.platform_id
            attr_infos = rsn_oms.attr.get_platform_attributes(platform_id)
            if not isinstance(attr_infos, dict):
                raise PlatformDriverException(
                    "%r: get_platform_attributes returned: %s" % (
                    platform_id, attr_infos))

            if log.isEnabledFor(logging.TRACE):
                log.trace("%r: attr_infos: %s", platform_id, attr_infos)

            if not platform_id in attr_infos:
                raise PlatformDriverException(
                    "%r: get_platform_attributes response does not "
                    "include entry for platform_id: %s" %(
                    platform_id, attr_infos))

            ret_infos = attr_infos[platform_id]
            for attrName, attr_defn in ret_infos.iteritems():
                attr = AttrNode(attrName, attr_defn)
                pnode.add_attribute(attr)
Beispiel #4
0
    def validate_driver_configuration(self, driver_config):
        """
        Driver config must include 'oms_uri' entry.
        """
        if not 'oms_uri' in driver_config:
            msg = "%r: 'oms_uri' not present in driver_config = %s" % (
                self._platform_id, driver_config)
            log.error(msg)
            raise PlatformDriverException(msg=msg)

        # validate and process ports
        if not 'ports' in driver_config:
            msg = "%r: 'ports' not present in driver_config = %s" % (
                self._platform_id, driver_config)
            log.error(msg)
            raise PlatformDriverException(msg=msg)

        self._instr_port_map = {}
        ports = driver_config['ports']
        for port_id, port_attrs in ports.iteritems():
            if 'instruments' not in port_attrs:
                continue
            instruments = port_attrs['instruments']
            for instr_id, instr_attrs in instruments.iteritems():
                if instr_id in self._instr_port_map:
                    msg = "%r: instrument=%r already associated with port=%r" % (
                        self._platform_id, instr_id, port_id)
                    log.error(msg)
                    raise PlatformDriverException(msg=msg)
                self._instr_port_map[instr_id] = port_id
        log.debug("%r: _instr_port_map: %s", self._platform_id,
                  self._instr_port_map)

        # TODO(OOIION-1495) review the following added logic.
        # Per recent discussions there would be two main sources for platform
        # port information: 1- from ongoing deployment; 2- from direct port
        # configuration when no ongoing deployment available.
        """
Beispiel #5
0
    def validate_driver_configuration(self, driver_config):
        """
        Driver config must include 'oms_uri' entry.
        """
        if not 'oms_uri' in driver_config:
            log.error("'oms_uri' not present in driver_config = %s",
                      driver_config)
            raise PlatformDriverException(
                msg="driver_config does not indicate 'oms_uri'")

        # TODO(OOIION-1495) review the following added logic Commented out
        # for the moment. We need to determine where and how exactly port
        # information is maintained.
        """