def _validate_ooi_reference_designator(self, device_id, device_port):
     ooi_rd = OOIReferenceDesignator(device_port.reference_designator)
     if ooi_rd.error:
         log.warning(
             "Invalid OOIReferenceDesignator ( %s ) specified for device %s",
             device_port.reference_designator, device_id)
     if not ooi_rd.port:
         log.warning(
             "Invalid OOIReferenceDesignator ( %s ) specified for device %s, could not retrieve port",
             device_port.reference_designator, device_id)
예제 #2
0
 def _parse_AttributeReportSubsites(self, row):
     ooi_rd = OOIReferenceDesignator(row['Subsite'])
     if ooi_rd.error or not ooi_rd.rd_type == "asset" or not ooi_rd.rd_subtype == "subsite":
         msg = "invalid_rd: %s is not a subsite designator" % (ooi_rd.rd)
         self.warnings.append((ooi_rd.rd, msg))
         return
     self._add_object_attribute('subsite',
                                ooi_rd.rd,
                                row['Attribute'],
                                row['AttributeValue'],
                                name=row['Subsite_Name'])
예제 #3
0
 def _parse_AttributeReportPorts(self, row):
     ooi_rd = OOIReferenceDesignator(row['Port'])
     if ooi_rd.error or not ooi_rd.rd_type == "asset" or not ooi_rd.rd_subtype == "port":
         msg = "invalid_rd: %s is not a port designator" % (ooi_rd.rd)
         self.warnings.append((ooi_rd.rd, msg))
         return
     self._add_object_attribute('port',
                                ooi_rd.rd,
                                row['Attribute'],
                                row['AttributeValue'],
                                mapping={})
예제 #4
0
 def _parse_AttributeReportReferenceDesignator(self, row):
     ooi_rd = OOIReferenceDesignator(row['Reference_Designator'])
     if ooi_rd.error or not ooi_rd.rd_type == "asset" or not ooi_rd.rd_subtype == "instrument":
         msg = "invalid_rd: %s is not an instrument designator" % (
             ooi_rd.rd)
         self.warnings.append((ooi_rd.rd, msg))
         return
     self._add_object_attribute('instrument',
                                ooi_rd.rd,
                                row['Attribute'],
                                row['AttributeValue'],
                                mapping={},
                                Class=row['Class'])
예제 #5
0
 def _parse_AttributeReportClass(self, row):
     ooi_rd = OOIReferenceDesignator(row['Class'])
     if ooi_rd.error or not ooi_rd.rd_type == "inst_class":
         msg = "invalid_rd: %s is not an instrument class reference designator" % (
             ooi_rd.rd)
         self.warnings.append((ooi_rd.rd, msg))
         return
     self._add_object_attribute('class',
                                ooi_rd.rd,
                                row['Attribute'],
                                row['AttributeValue'],
                                mapping={},
                                Class_Name=row['Class_Name'])
예제 #6
0
 def _parse_AttributeReportArrays(self, row):
     ooi_rd = OOIReferenceDesignator(row['Array'])
     if ooi_rd.error or not ooi_rd.rd_type == "asset" or not ooi_rd.rd_subtype == "array":
         msg = "invalid_rd: %s is not an array reference designator" % (
             ooi_rd.rd)
         self.warnings.append((ooi_rd.rd, msg))
         return
     self._add_object_attribute('array',
                                ooi_rd.rd,
                                row['Attribute'],
                                row['AttributeValue'],
                                mapping={'Array_Name': 'name'},
                                Array_Name=row['Array_Name'])
예제 #7
0
 def _parse_AttributeReportNodes(self, row):
     ooi_rd = OOIReferenceDesignator(row['Node'])
     if ooi_rd.error or not ooi_rd.rd_type == "asset" or not ooi_rd.rd_subtype == "node":
         msg = "invalid_rd: %s is not a node designator" % (ooi_rd.rd)
         self.warnings.append((ooi_rd.rd, msg))
         return
     # TODO: Create a default name by structure (subsite name + node type name)
     nodetypes = self.get_type_assets('nodetype')
     self._add_object_attribute(
         'node',
         ooi_rd.rd,
         row['Attribute'],
         row['AttributeValue'],
         mapping={},
         Node_Type=row['Node_Type'],
         Node_Site_Sequence=row['Node_Site_Sequence'])
예제 #8
0
 def _parse_AttributeReportDataProducts(self, row):
     key = row['Data_Product_Identifier'] + "_L" + row['Data_Product_Level']
     ooi_rd = OOIReferenceDesignator(key)
     if ooi_rd.error or not ooi_rd.rd_type == "dataproduct" or not ooi_rd.rd_subtype == "level":
         msg = "invalid_rd: %s is not a data product reference designator" % (
             ooi_rd.rd)
         self.warnings.append((ooi_rd.rd, msg))
         return
     self._add_object_attribute(
         'data_product_type',
         row['Data_Product_Identifier'],
         row['Attribute'],
         row['AttributeValue'],
         mapping={},
         Data_Product_Name=row['Data_Product_Name'],
         Data_Product_Level=row['Data_Product_Level'])
예제 #9
0
    def test_reference_designator(self):
        for rd, attrs in self.rd_list:
            ooi_rd = OOIReferenceDesignator(rd)
            is_valid = attrs.get("valid", True)

            str(ooi_rd)
            repr(ooi_rd)

            self.assertEquals(ooi_rd.error, not is_valid)
            if not is_valid:
                continue

            rd_type = attrs["rdtype"]

            self.assertEquals(ooi_rd.rd_type, rd_type)

            if rd_type == "asset":
                rd_subtype = attrs["rdsub"]
                self.assertEquals(ooi_rd.rd_subtype, rd_subtype)
                if rd_subtype == "instrument":
                    self.assertEquals(ooi_rd.inst_rd, rd[:27])
                    self.assertEquals(ooi_rd.series_rd, rd[18:24])
                    self.assertEquals(ooi_rd.subseries_rd, rd[18:24] + "01")

                if rd_subtype in ("instrument", "port"):
                    self.assertEquals(ooi_rd.port_rd, rd[:17])

                if rd_subtype in ("instrument", "port", "node"):
                    self.assertEquals(ooi_rd.node_rd, rd[:14])

                if rd_subtype in ("instrument", "port", "node", "subsite"):
                    self.assertEquals(ooi_rd.subsite_rd, rd[:8])

                if rd_subtype in ("instrument", "port", "node", "subsite",
                                  "site"):
                    self.assertEquals(ooi_rd.site_rd, rd[:4])
                    self.assertEquals(ooi_rd.array, rd[:2])

                mio = attrs["mio"]
                self.assertEquals(ooi_rd.marine_io, mio)

            elif rd_type == "inst_class":
                self.assertEquals(ooi_rd.inst_class, rd[:5])

            elif rd_type == "dataproduct":
                self.assertEquals(ooi_rd.dataproduct, rd[:7])
예제 #10
0
    def test_get_agent_definition(self):
        loader = IONLoader()
        ooi_loader = OOILoader(None,
                               asset_path='res/preload/r2_ioc/ooi_assets',
                               mapping_path=OOI_MAPPING_DOC)
        loader.ooi_loader = ooi_loader
        loader.ooi_loader.extract_ooi_assets()

        inst_objs = ooi_loader.get_type_assets("instrument")
        node_objs = ooi_loader.get_type_assets("node")
        loader._get_resource_obj = Mock(
            return_value=IonObject(RT.ExternalDatasetAgent))

        # for ooi_id in sorted(inst_objs):
        #     ooi_rd = OOIReferenceDesignator(ooi_id)
        #     agent_id, agent_obj = loader._get_agent_definition(ooi_rd)
        #     log.info("RD: %s, agent_id: %s", ooi_id, agent_id)

        checks = [
            # Check some mapping override cases
            ("CP01CNSM-MF004-03-DOSTAD999", "DART_DOSTA_D_CSTL"),
            ("CP01CNSM-RI003-05-FLORTD999", "DART_FLORT_D_CSTL"),
            ("CP02PMUO-RI001-01-ADCPSL999", "DART_ADCPS_L_CSTL"),

            # Check some default cases
            ("GA03FLMB-RI001-03-DOSTAD999", "DART_DOSTA_D"),
            ("GA03FLMB-RI001-01-FLORTD999", "DART_FLORT_D"),
            ("GA03FLMB-RI001-04-ADCPSL999", "DART_ADCPS_L"),

            # Check some cases without mapping (using default)
            ("GI05MOAS-GL001-01-FLORDM999", "DART_FLORD_M"),
        ]

        for ooi_id, expected_agent_id in checks:
            ooi_rd = OOIReferenceDesignator(ooi_id)
            agent_id, agent_obj = loader._get_agent_definition(ooi_rd)
            self.assertEquals(agent_id, expected_agent_id)
예제 #11
0
    def _validate_reference_designator(self, port_assignments):
        #validate that each reference designator is valid / parseable
        # otherwise the platform cannot pull out the port number for power mgmt
        if not port_assignments:
            return

        if not isinstance(port_assignments, dict):
            log.error(
                'Deployment for device has invalid port assignments.  device id: %s ',
                self._get_device()._id)
            return

        for device_id, platform_port in port_assignments.iteritems():
            if platform_port.type_ != OT.PlatformPort:
                log.error(
                    'Deployment for device has invalid port assignments for device.  device id: %s',
                    device_id)
            ooi_rd = OOIReferenceDesignator(platform_port.reference_designator)
            if ooi_rd.error:
                log.error(
                    'Agent configuration includes a invalid reference designator for a device in this deployment.  device id: %s  reference designator: %s',
                    device_id, platform_port.reference_designator)

        return
예제 #12
0
 def get_marine_io(self, ooi_rd_str):
     ooi_rd = OOIReferenceDesignator(ooi_rd_str)
     if ooi_rd.error:
         return None
     else:
         return ooi_rd.marine_io