def openNode(self,
                 platform_id,
                 node_config_filename,
                 stream_definition_filename=DEFAULT_STREAM_DEF_FILENAME):
        """
        Opens up and parses the node configuration files.
        @param platform_id - id to associate with this set of Node Configuration Files
        @param nc_file - yaml file with information about the platform
        @raise NodeConfigurationException
        """
        self._platform_id = platform_id

        log.debug("%r: Open: %s", self._platform_id, node_config_filename)

        with open(node_config_filename,
                  'r') as nc_file, open(stream_definition_filename,
                                        'r') as sc_file:
            try:
                node_config = yaml.load(nc_file)
                stream_definitions = yaml.load(sc_file)
                self._node_yaml = NodeYAML.factory(node_config,
                                                   stream_definitions)
                self._node_yaml.validate()
            except Exception as e:
                import traceback
                traceback.print_exc()
                msg = "%s Cannot parse yaml node specific config file  : %s" % (
                    e, node_config_filename)
                raise NodeConfigurationFileException(msg=msg)
            except IOError as e:
                msg = "%s Cannot open node specific config file  : %s" % (
                    e, node_config_filename)
                raise NodeConfigurationFileException(msg=msg)
Exemple #2
0
    def _validate_node_port_info(self):
        port_oms_port_cntl_id = 'port_oms_port_cntl_id'
        for port_id, port_dict in self.node_port_info.iteritems():
            if not port_dict or not port_oms_port_cntl_id in port_dict:
                raise NodeConfigurationFileException(msg="%s is missing from %s" % (port_oms_port_cntl_id, port_id))

            if not isinstance(port_dict[port_oms_port_cntl_id], int):
                raise NodeConfigurationFileException(
                    msg="%s value is not an int for %s" % (port_oms_port_cntl_id, port_id))
Exemple #3
0
    def __init__(self, node_config_filename, stream_definitions=None):
        self._attributes = None
        try:
            node_config_string = resource_string(mi.platform.rsn.__name__, node_config_filename)
            node_config = yaml.load(node_config_string)
            self._node_yaml = NodeYAML.factory(node_config, stream_definitions)
            self._node_yaml.validate()

        except Exception as e:
            import traceback
            traceback.print_exc()
            msg = "%s Cannot parse yaml node specific config file  : %s" % (e, node_config_filename)
            raise NodeConfigurationFileException(msg=msg)
        except IOError as e:
            msg = "%s Cannot open node specific config file  : %s" % (e, node_config_filename)
            raise NodeConfigurationFileException(msg=msg)
Exemple #4
0
 def GetAttrFromParameter(self, parameter_name):
     if parameter_name in self._attrLookup:
         return self._attrLookup[parameter_name]
     else:
         raise NodeConfigurationFileException(
             msg="GetAttrFromParameter Cannot find parameter_name  : %s" %
             parameter_name)
Exemple #5
0
    def _validate_node_meta_data(self):
        nms_source = 'nms_source'
        oms_sample_rate = 'oms_sample_rate'
        meta_data = ['node_id_name',
                     'description',
                     'location',
                     'reference_designator',
                     ]

        for meta_data_item in meta_data:
            if not self.node_meta_data.get(meta_data_item, None):
                raise NodeConfigurationFileException(msg="%s is missing from config file" % meta_data_item)

        if not self.node_meta_data.get(nms_source, None):
            self.node_meta_data[nms_source] = 0

        if not self.node_meta_data.get(oms_sample_rate, None):
            self.node_meta_data[oms_sample_rate] = 60
Exemple #6
0
 def validate(self):
     raise NodeConfigurationFileException(msg="This a null configuration.")
Exemple #7
0
    def Open(self, platform_id, default_filename, node_config_filename):
        """
        Opens up and parses the node configuration files.
        Combines the information in defaultFile with the Node
        Specific information in the NodeConfigFile to create
        a dictionary of attributes and meta data used to read
        and parse data from the OMS Agent

        @param platform_id - id to associate with this set of Node Configuration Files
        @param default_file - yaml file with generic information used by many platforms
        @param node_config_file - yaml file with specific information about the platform

        @raise NodeConfigurationException
        """

        self._platform_id = platform_id

        log.debug("%r: Open: %s %s", self._platform_id, default_filename,
                  node_config_filename)

        try:
            default_config_file = open(default_filename, 'r')
        except Exception as e:
            raise NodeConfigurationFileException(
                msg="%s Cannot open default node config file : %s" %
                (str(e), default_filename))

        try:
            default_config = yaml.load(default_config_file)
        except Exception as e:
            raise NodeConfigurationFileException(
                msg="%s Cannot parse yaml  node config file : %s" %
                (str(e), default_filename))

        try:
            node_config_file = open(node_config_filename, 'r')
        except Exception as e:
            raise NodeConfigurationFileException(
                msg="%s Cannot open node specific config file  : %s" %
                (str(e), node_config_filename))

        try:
            node_config = yaml.load(node_config_file)
        except Exception as e:
            raise NodeConfigurationFileException(
                msg="%s Cannot parse yaml node specific config file  : %s" %
                (str(e), node_config_filename))

        self.node_meta_data = copy.deepcopy(node_config["node_meta_data"])

        #this will be the list of all monitored attributes for the node and active ports
        #first just load the node attributes directly
        self.attrs = copy.deepcopy(default_config["node_attributes"])

        self.port_configurations = copy.deepcopy(node_config["port_configs"])

        temp_port_attr = {}

        for portKey, port in self.port_configurations.iteritems():
            temp_port_attr = copy.deepcopy(default_config["port_attributes"])

            # go through and update the default port attributes for this port with specifics
            for port_attr_key, port_attribute in temp_port_attr.iteritems():
                port_attribute['attr_id'] = port[
                    'port_oms_prefix'] + ' ' + port_attribute['attr_id']
                port_attribute['ion_parameter_name'] = port[
                    'port_ion_prefix'] + '_' + port_attribute[
                        'ion_parameter_name']
                self.attrs[portKey + '_' + port_attr_key] = port_attribute

        self._parmLookup = {}
        self._attrLookup = {}
        self._scaleLookup = {}

        for attrKey, attr in self.attrs.iteritems():
            self._parmLookup[attr['attr_id']] = attr['ion_parameter_name']
            self._attrLookup[attr['ion_parameter_name']] = attr['attr_id']
            self._scaleLookup[attr['attr_id']] = attr['scale_factor']
Exemple #8
0
 def GetParameterFromAttr(self, attr_id):
     if attr_id in self._parmLookup:
         return self._parmLookup[attr_id]
     else:
         raise NodeConfigurationFileException(
             msg="GetParameterFromAttr Cannot find attr_id  : %s" % attr_id)
Exemple #9
0
 def GetOMSPortId(self, ui_port_name):
     for portKey, port in self.port_configurations.iteritems():
         if (port['port_ui_name'] == ui_port_name):
             return (port['port_oms_port_cntl_id'])
     raise NodeConfigurationFileException(
         msg="GetOMSPortId Cannot find ui_port_name  : %s" % ui_port_name)