示例#1
0
  /**
   * TODO
   *
   * @param attributes TODO
   * @param attributeName TODO
   * @return TODO
   */
  private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network
          .rev151010.physical.node.instance.Attribute
      getPhysicalNodeAttribute(
          List<
                  org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical
                      .network.rev151010.physical.node.instance.Attribute>
              attributes,
          AttributeName attributeName) {
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network
            .rev151010.physical.node.instance.Attribute
        attribute : attributes) {
      if (attribute.getAttributeName().equals(attributeName)) {
        return attribute;
      }
    }

    return null;
  }
示例#2
0
  /**
   * TODO
   *
   * @param attribute TODO
   * @param physicalResourceRequirement TODO
   * @return TODO
   */
  private boolean checkPhysicalNodeAttributeSatisfied(
      org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network
              .rev151010.physical.node.instance.Attribute
          attribute,
      org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network
              .rev151010.virtual.node.instance.PhysicalResourceRequirement
          physicalResourceRequirement)
      throws VNMappingException {
    ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction();

    InstanceIdentifier<PhysicalNodeAttributeDefinition> physicalNodeAttributeDefinitionIid =
        InstanceIdentifier.builder(PhysicalNodeAttributeDefinitions.class)
            .child(
                PhysicalNodeAttributeDefinition.class,
                new PhysicalNodeAttributeDefinitionKey(attribute.getAttributeName()))
            .build();
    Optional<PhysicalNodeAttributeDefinition> result;

    try {
      result =
          readOnlyTransaction
              .read(LogicalDatastoreType.CONFIGURATION, physicalNodeAttributeDefinitionIid)
              .get();
    } catch (InterruptedException exception) {
      throw new VNMappingException(
          "Can not read the physical node attribute definition "
              + "with attribute name "
              + attribute.getAttributeName().getValue()
              + ".");
    } catch (ExecutionException exception) {
      throw new VNMappingException(
          "Can not read the physical node attribute definition "
              + "with attribute name "
              + attribute.getAttributeName().getValue()
              + ".");
    }

    if (!result.isPresent()) {
      throw new VNMappingException(
          "The physical node attribute definition with attribute name "
              + attribute.getAttributeName().getValue()
              + " does not exist.");
    }

    PhysicalNodeAttributeDefinition physicalNodeAttributeDefinition = result.get();
    List<AttributeMatchPatterns.AttributeMatchPattern> attributeMatchPatterns =
        physicalNodeAttributeDefinition.getAttributeMatchPatterns().getAttributeMatchPattern();
    org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network
            .rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern
        attributeMatchPattern = physicalResourceRequirement.getAttributeMatchPattern();

    if (!checkAttributeMatchPatternSpecified(attributeMatchPatterns, attributeMatchPattern)) {
      throw new VNMappingException(
          "The attribute match pattern "
              + attributeMatchPattern
              + " is not specified in the physical node attribute definition "
              + "with attribute name "
              + attribute.getAttributeName().getValue()
              + ".");
    }

    switch (physicalNodeAttributeDefinition.getAttributeValueType()) {
      case String:
        return checkAttributeStringValueSatisfied(
            attribute.getAttributeValue().getStringValue(),
            physicalResourceRequirement.getAttributeValue().getStringValue(),
            attributeMatchPattern);

      case Int:
        return checkAttributeIntegerValueSatisfied(
            attribute.getAttributeValue().getIntValue(),
            physicalResourceRequirement.getAttributeValue().getIntValue(),
            attributeMatchPattern);

      case Range:
        return checkAttributeRangeValueSatisfied(
            attribute.getAttributeValue().getIntValue(),
            physicalResourceRequirement.getAttributeValue().getRangeValue(),
            attributeMatchPattern);

      default:
        throw new VNMappingException(
            "Unsupported physical node attribute value type "
                + physicalNodeAttributeDefinition.getAttributeValueType()
                + ".");
        //                break;
    }

    //        return false;
  }