return null;
}
- val String targetSchemaNodeName = result.QName.localName;
var boolean fromUses = (result as DataSchemaNode).addedByUses
var Iterator<UsesNode> groupingUses = grouping.uses.iterator;
- while (fromUses) {
- if (groupingUses.hasNext()) {
- grouping = findNodeInSchemaContext(schemaContext, groupingUses.next().groupingPath.path) as GroupingDefinition;
- result = grouping.getDataChildByName(targetSchemaNodeName);
- fromUses = (result as DataSchemaNode).addedByUses;
- } else {
- throw new NullPointerException("Failed to generate code for augment in " + parentUsesNode);
+ while (groupingUses.hasNext && fromUses) {
+ result = findOriginalTargetFromGrouping(targetPath, groupingUses.next);
+ if (result != null) {
+ fromUses = (result as DataSchemaNode).addedByUses
}
}
+ if (fromUses) {
+ throw new NullPointerException("Failed to generate code for augment in " + parentUsesNode);
+ }
return result as DataSchemaNode
}
val caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode)
caseTypeBuilder.addImplementsType(refChoiceType)
genCtx.get(module).addCaseType(caseNode.path, caseTypeBuilder)
+ genCtx.get(module).addChoiceToCaseMapping(refChoiceType, caseTypeBuilder,caseNode)
val Set<DataSchemaNode> caseChildNodes = caseNode.childNodes
if (caseChildNodes !== null) {
var Object parentNode = null
throw new IllegalArgumentException("Failed to find parent type of choice " + targetNode);
}
- if (caseNode instanceof DataNodeContainer) {
- val DataNodeContainer dataNodeCase = caseNode as DataNodeContainer;
- val Set<DataSchemaNode> childNodes = dataNodeCase.childNodes;
- if (childNodes !== null) {
- resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType, childNodes);
- }
- } else {
- val ChoiceCaseNode node = targetNode.getCaseNodeByName(caseNode.getQName().getLocalName());
- val Set<DataSchemaNode> childNodes = node.childNodes;
- if (childNodes !== null) {
- resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType, childNodes);
- }
+ var ChoiceCaseNode node = null;
+ if (caseNode instanceof ChoiceCaseNode) {
+ node = caseNode as ChoiceCaseNode;
+ } else {
+ node = targetNode.getCaseNodeByName(caseNode.getQName().getLocalName());
+ }
+ val Set<DataSchemaNode> childNodes = node.childNodes;
+ if (childNodes !== null) {
+ resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType, childNodes);
}
-
genCtx.get(module).addCaseType(caseNode.path, caseTypeBuilder)
+ genCtx.get(module).addChoiceToCaseMapping(targetType, caseTypeBuilder,node);
}
}
if(pathArguments.hasNext()) {
currentArg = pathArguments.next();
} else {
- return Optional.absent();
+ return currentContainer;
}
}
if(ChildOf.class.isAssignableFrom(currentArg.getType()) && BindingReflections.isAugmentationChild(currentArg.getType())) {
import java.lang.reflect.Field;
import java.util.Map;
-
-import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec;
-import org.opendaylight.yangtools.yang.data.impl.codec.InstanceIdentifierCodec;
import org.opendaylight.yangtools.yang.binding.BindingCodec;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec;
+import org.opendaylight.yangtools.yang.data.impl.codec.InstanceIdentifierCodec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public static final String CLASS_TO_CASE_MAP = "CLASS_TO_CASE";
public static final String COMPOSITE_TO_CASE = "COMPOSITE_TO_CASE";
public static final String AUGMENTATION_CODEC = "AUGMENTATION_CODEC";
+ public static final String DISPATCH_CODEC = "DISPATCH_CODEC";
public static void setIdentifierCodec(Class<?> obj,InstanceIdentifierCodec codec) {
Field instanceIdField;
}
}
+ public static void setDispatchCodec(Class<? extends BindingCodec<?,?>> codec,
+ BindingCodec<?, ?> dispatchCodec) {
+ Field instanceIdField;
+ try {
+ instanceIdField = codec.getField(DISPATCH_CODEC);
+ instanceIdField.set(null, dispatchCodec);
+ } catch (NoSuchFieldException e) {
+ LOG.debug("BUG: dispatch codec is not needed for {}",codec.getName(),e);
+ } catch (SecurityException | IllegalAccessException e) {
+ LOG.error("Dispatch codec could not be set for {}",codec.getName(),e);
+ }
+ }
+
public static void setAugmentationCodec(Class<? extends BindingCodec<?,?>> dataCodec,
BindingCodec<?,?> augmentableCodec) {
Field instanceIdField;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
+import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Objects;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
import org.opendaylight.yangtools.yang.binding.Augmentable;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
GeneratorListener {
private static final Logger LOG = LoggerFactory.getLogger(LazyGeneratedCodecRegistry.class);
- private static final LateMixinCodec NOT_READY_CODEC = new LateMixinCodec();
// Concrete class to codecs
private static final Map<Class<?>, DataContainerCodec<?>> containerCodecs = Collections
@SuppressWarnings("rawtypes")
private static final Map<Type, WeakReference<Class>> typeToClass = new ConcurrentHashMap<>();
- @SuppressWarnings("rawtypes")
- private static final ConcurrentMap<Type, ChoiceCaseCodecImpl> typeToCaseCodecs = new ConcurrentHashMap<>();
+ private static final ConcurrentMap<Type, ChoiceCaseNode> caseTypeToCaseSchema = new ConcurrentHashMap<>();
private static final Map<SchemaPath, Type> pathToType = new ConcurrentHashMap<>();
private static final Map<List<QName>, Type> pathToInstantiatedType = new ConcurrentHashMap<>();
.<Type, Type> create());
private final InstanceIdentifierCodec instanceIdentifierCodec = new InstanceIdentifierCodecImpl(this);
- private final CaseClassMapFacade classToCaseRawCodec = new CaseClassMapFacade();
private final IdentityCompositeCodec identityRefCodec = new IdentityCompositeCodec();
private final ClassLoadingStrategy classLoadingStrategy;
private final AbstractTransformerGenerator generator;
return potential;
}
ConcreteType typeref = Types.typeForClass(caseClass);
- ChoiceCaseCodecImpl caseCodec = typeToCaseCodecs.get(typeref);
+ ChoiceCaseNode caseSchema = caseTypeToCaseSchema.get(typeref);
- Preconditions.checkState(caseCodec != null, "Case Codec was not created proactivelly for %s",
- caseClass.getName());
- Preconditions.checkState(caseCodec.getSchema() != null, "Case schema is not available for %s",
- caseClass.getName());
- Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseCodec.getSchema());
+ Preconditions.checkState(caseSchema != null, "Case schema is not available for %s", caseClass.getName());
+ Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseSchema);
BindingCodec newInstance = newInstanceOf(newCodec);
- caseCodec.setDelegate(newInstance);
+ @SuppressWarnings("unchecked")
+ ChoiceCaseCodecImpl caseCodec = new ChoiceCaseCodecImpl(caseClass, caseSchema, newInstance);
caseCodecs.put(caseClass, caseCodec);
-
- for (Entry<Class<?>, PublicChoiceCodecImpl<?>> choice : choiceCodecs.entrySet()) {
- if (choice.getKey().isAssignableFrom(caseClass)) {
- choice.getValue().cases.put(caseClass, caseCodec);
- }
- }
return caseCodec;
}
synchronized (choiceToCases) {
choiceToCases.putAll(context.getChoiceToCases());
}
- captureCases(context.getCases(), schemaContext);
- }
-
- private void captureCases(final Map<SchemaPath, GeneratedTypeBuilder> cases, final SchemaContext module) {
- for (Entry<SchemaPath, GeneratedTypeBuilder> caseNode : cases.entrySet()) {
- ReferencedTypeImpl typeref = new ReferencedTypeImpl(caseNode.getValue().getPackageName(), caseNode
- .getValue().getName());
-
- pathToType.put(caseNode.getKey(), caseNode.getValue());
-
- ChoiceCaseNode node = (ChoiceCaseNode) SchemaContextUtil.findDataSchemaNode(module, caseNode.getKey());
-
- if (node == null) {
- LOG.warn("Failed to find YANG SchemaNode for {}, with path {} was not found in context.",
- typeref.getFullyQualifiedName(), caseNode.getKey());
- @SuppressWarnings("rawtypes")
- ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl();
- typeToCaseCodecs.putIfAbsent(typeref, value);
- continue;
- }
- @SuppressWarnings("rawtypes")
- ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node);
- typeToCaseCodecs.putIfAbsent(typeref, value);
+ synchronized (caseTypeToCaseSchema) {
+ caseTypeToCaseSchema.putAll(context.getCaseTypeToSchemas());
}
}
Preconditions.checkState(oldCodec == null);
BindingCodec<Map<QName, Object>, Object> delegate = newInstanceOf(choiceCodec);
PublicChoiceCodecImpl<?> newCodec = new PublicChoiceCodecImpl(delegate);
+ DispatchChoiceCodecImpl dispatchCodec = new DispatchChoiceCodecImpl(choiceClass);
choiceCodecs.put(choiceClass, newCodec);
- CodecMapping.setClassToCaseMap(choiceCodec, classToCaseRawCodec);
- CodecMapping.setCompositeNodeToCaseMap(choiceCodec, newCodec.getCompositeToCase());
-
- tryToCreateCasesCodecs(schema);
-
- }
-
- @Deprecated
- private void tryToCreateCasesCodecs(final ChoiceNode schema) {
- for (ChoiceCaseNode choiceCase : schema.getCases()) {
- ChoiceCaseNode caseNode = choiceCase;
- if (caseNode.isAddedByUses()) {
- DataSchemaNode origCaseNode = SchemaContextUtil.findOriginal(caseNode, currentSchema);
- if (origCaseNode instanceof ChoiceCaseNode) {
- caseNode = (ChoiceCaseNode) origCaseNode;
- }
- }
- SchemaPath path = caseNode.getPath();
-
- Type type;
- if (path != null && (type = pathToType.get(path)) != null) {
- ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
- @SuppressWarnings("rawtypes")
- ChoiceCaseCodecImpl partialCodec = typeToCaseCodecs.get(typeref);
- if (partialCodec.getSchema() == null) {
- partialCodec.setSchema(caseNode);
- }
- try {
- Class<?> caseClass = classLoadingStrategy.loadClass(type.getFullyQualifiedName());
- getCaseCodecFor(caseClass);
- } catch (ClassNotFoundException e) {
- LOG.trace("Could not proactivelly create case codec for {}", type, e);
- }
- }
- }
-
+ CodecMapping.setDispatchCodec(choiceCodec, dispatchCodec);
}
@Override
@SuppressWarnings("rawtypes")
private static class ChoiceCaseCodecImpl<T extends DataContainer> implements ChoiceCaseCodec<T>, //
Delegator<BindingCodec>, LocationAwareBindingCodec<Node<?>, ValueWithQName<T>> {
- private boolean augmenting;
- private boolean uses;
- private BindingCodec delegate;
-
- private Set<String> validNames;
- private Set<QName> validQNames;
- private ChoiceCaseNode schema;
- private Set<InstanceIdentifier<?>> applicableLocations;
+ private final BindingCodec delegate;
+ private final ChoiceCaseNode schema;
+ private final Map<InstanceIdentifier<?>, ChoiceCaseNode> instantiatedLocations;
+ private final Class<?> dataType;
@Override
public boolean isApplicable(final InstanceIdentifier location) {
- return applicableLocations.contains(location);
+ return instantiatedLocations.containsKey(location);
}
- public void setSchema(final ChoiceCaseNode caseNode) {
+ public ChoiceCaseCodecImpl(final Class<?> caseClass, final ChoiceCaseNode caseNode,
+ final BindingCodec newInstance) {
+ this.delegate = newInstance;
+ this.dataType = caseClass;
this.schema = caseNode;
- validNames = new HashSet<>();
- validQNames = new HashSet<>();
- for (DataSchemaNode node : caseNode.getChildNodes()) {
- QName qname = node.getQName();
- validQNames.add(qname);
- validNames.add(qname.getLocalName());
- }
- augmenting = caseNode.isAugmenting();
- uses = caseNode.isAddedByUses();
- applicableLocations = new HashSet<>();
- }
-
- public ChoiceCaseCodecImpl() {
- this.delegate = NOT_READY_CODEC;
- }
-
- public ChoiceCaseCodecImpl(final ChoiceCaseNode caseNode) {
- this.delegate = NOT_READY_CODEC;
- setSchema(caseNode);
+ instantiatedLocations = new HashMap<>();
}
@Override
@Override
public ValueWithQName<T> deserialize(final Node<?> input, final InstanceIdentifier<?> bindingIdentifier) {
- throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
+ if (input == null) {
+ return null;
+ }
+ QName qname = input.getNodeType();
+ synchronized (instantiatedLocations) {
+ ChoiceCaseNode instantiation = instantiatedLocations.get(bindingIdentifier);
+ if (instantiation != null) {
+ qname = instantiatedLocations.get(bindingIdentifier).getQName();
+ }
+ }
+ @SuppressWarnings("unchecked")
+ T value = (T) getDelegate().deserialize(new SimpleEntry(qname, input), bindingIdentifier);
+ return new ValueWithQName<T>(qname, value);
}
@Override
return delegate;
}
- public void setDelegate(final BindingCodec delegate) {
- this.delegate = delegate;
- }
-
public ChoiceCaseNode getSchema() {
return schema;
}
@Override
+ @Deprecated
public boolean isAcceptable(final Node<?> input) {
- if (input instanceof CompositeNode) {
- if (augmenting && !uses) {
- return checkAugmenting((CompositeNode) input);
- } else {
- return checkLocal((CompositeNode) input);
+ return checkAgainstSchema(schema, input);
+ }
+
+ private static boolean checkAgainstSchema(final ChoiceCaseNode schema, final Node<?> node) {
+ if (node instanceof CompositeNode) {
+ CompositeNode input = (CompositeNode) node;
+ for (Node<?> childNode : input.getValue()) {
+ QName child = childNode.getNodeType();
+ if (schema.getDataChildByName(child) != null) {
+ return true;
+ }
}
}
return false;
}
- @SuppressWarnings("deprecation")
- private boolean checkLocal(final CompositeNode input) {
- QName parent = input.getNodeType();
- for (Node<?> childNode : input.getChildren()) {
- QName child = childNode.getNodeType();
- if (!Objects.equals(parent.getNamespace(), child.getNamespace())
- || !Objects.equals(parent.getRevision(), child.getRevision())) {
- continue;
- }
- if (validNames.contains(child.getLocalName())) {
- return true;
- }
+ @Override
+ public Class<?> getDataType() {
+ return dataType;
+ }
+
+ public void adaptForPath(final InstanceIdentifier<?> augTarget, final ChoiceCaseNode choiceCaseNode) {
+ synchronized (instantiatedLocations) {
+ instantiatedLocations.put(augTarget, choiceCaseNode);
}
- return false;
}
- @SuppressWarnings("deprecation")
- private boolean checkAugmenting(final CompositeNode input) {
- for (Node<?> child : input.getChildren()) {
- if (validQNames.contains(child.getNodeType())) {
- return true;
- }
+ public boolean isAcceptable(final InstanceIdentifier path, final CompositeNode input) {
+ ChoiceCaseNode instantiatedSchema = null;
+ synchronized (instantiatedLocations) {
+ instantiatedSchema = instantiatedLocations.get(path);
}
- return false;
+ if (instantiatedSchema == null) {
+ return false;
+ }
+ return checkAgainstSchema(instantiatedSchema, input);
}
- @Override
- public Class<?> getDataType() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Not implemented Yet.");
+ protected boolean isAugmenting(final QName choiceName,final QName proposedQName) {
+ if (schema.isAugmenting()) {
+ return true;
+ }
+ // Choice QName
+ QName parentQName = Iterables.get(schema.getPath().getPathTowardsRoot(), 1);
+ if (!parentQName.getNamespace().equals(schema.getQName().getNamespace())) {
+ return true;
+ }
+ if (!parentQName.equals(choiceName)) {
+ // This item is instantiation of choice via uses in other YANG module
+ if(choiceName.getNamespace().equals(schema.getQName())) {
+ // Original definition of grouping is in same namespace
+ // as original definition of case
+ // so for sure case is introduced via instantiation of grouping
+ return false;
+ }
+ // Since we are still here, that means case has same namespace
+ // as its parent, which is instantiation of grouping
+ // but case namespace is different from parent node
+ // so it is augmentation.
+ return true;
+ }
+ return false;
}
}
private final BindingCodec<Map<QName, Object>, Object> delegate;
- @SuppressWarnings("rawtypes")
- private final Map<Class, ChoiceCaseCodecImpl<?>> cases = Collections
- .synchronizedMap(new WeakHashMap<Class, ChoiceCaseCodecImpl<?>>());
-
- private final CaseCompositeNodeMapFacade CompositeToCase;
-
public PublicChoiceCodecImpl(final BindingCodec<Map<QName, Object>, Object> delegate) {
this.delegate = delegate;
- this.CompositeToCase = new CaseCompositeNodeMapFacade(cases);
}
@Override
throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
}
- public CaseCompositeNodeMapFacade getCompositeToCase() {
- return CompositeToCase;
- }
-
@Override
public BindingCodec<Map<QName, Object>, Object> getDelegate() {
return delegate;
}
- @SuppressWarnings("unused")
- private class DispatchChoiceCodecImpl extends LocationAwareDispatchCodec<ChoiceCaseCodecImpl<?>> {
-
- @Override
- public Object deserialize(final Object input,
- @SuppressWarnings("rawtypes") final InstanceIdentifier bindingIdentifier) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Object serialize(final Object input) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected ChoiceCaseCodecImpl<?> tryToLoadImplementation(final Class<? extends DataContainer> inputType) {
- return getCaseCodecFor(inputType);
- }
-
- @Override
- protected void tryToLoadImplementations() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void adaptForPathImpl(final InstanceIdentifier<?> path, final DataNodeContainer ctx) {
- // TODO Auto-generated method stub
+ class DispatchChoiceCodecImpl extends LocationAwareDispatchCodec<ChoiceCaseCodecImpl<?>> {
+ private final Class<?> choiceType;
+ private final QName choiceName;
+ private DispatchChoiceCodecImpl(final Class<?> type) {
+ choiceType = type;
+ choiceName = BindingReflections.findQName(type);
}
- }
-
- @SuppressWarnings("rawtypes")
- private class CaseClassMapFacade extends MapFacadeBase {
@Override
- public Set<Entry<Class, BindingCodec<Object, Object>>> entrySet() {
- return Collections.emptySet();
- }
-
- @Override
- public BindingCodec get(final Object key) {
- if (key instanceof Class) {
- Class cls = (Class) key;
- // bindingClassEncountered(cls);
- ChoiceCaseCodecImpl caseCodec = getCaseCodecFor(cls);
- return caseCodec.getDelegate();
- }
- return null;
- }
- }
-
- @SuppressWarnings("rawtypes")
- private static class CaseCompositeNodeMapFacade extends MapFacadeBase<CompositeNode> {
-
- final Map<Class, ChoiceCaseCodecImpl<?>> choiceCases;
-
- public CaseCompositeNodeMapFacade(final Map<Class, ChoiceCaseCodecImpl<?>> choiceCases) {
- this.choiceCases = choiceCases;
- }
+ public Object deserialize(final Object input, @SuppressWarnings("rawtypes") final InstanceIdentifier path) {
+ adaptForPath(path);
- @Override
- public BindingCodec get(final Object key) {
- if (!(key instanceof CompositeNode)) {
- return null;
- }
- for (Entry<Class, ChoiceCaseCodecImpl<?>> entry : choiceCases.entrySet()) {
- ChoiceCaseCodecImpl<?> codec = entry.getValue();
- if (codec.isAcceptable((CompositeNode) key)) {
- return codec.getDelegate();
+ if (input instanceof CompositeNode) {
+ List<Entry<Class, ChoiceCaseCodecImpl<?>>> codecs = new ArrayList<>(getImplementations().entrySet());
+ for (Entry<Class, ChoiceCaseCodecImpl<?>> codec : codecs) {
+ ChoiceCaseCodecImpl<?> caseCodec = codec.getValue();
+ if (caseCodec.isAcceptable(path, (CompositeNode) input)) {
+ ValueWithQName<?> value = caseCodec.deserialize((CompositeNode) input, path);
+ if (value != null) {
+ return value.getValue();
+ }
+ return null;
+ }
}
}
return null;
}
- }
-
- /**
- * This map is used as only facade for
- * {@link org.opendaylight.yangtools.yang.binding.BindingCodec} in different
- * classloaders to retrieve codec dynamicly based on provided key.
- *
- * @param <T>
- * Key type
- */
- @SuppressWarnings("rawtypes")
- private abstract static class MapFacadeBase<T> implements Map<T, BindingCodec<?, ?>> {
-
- @Override
- public boolean containsKey(final Object key) {
- return get(key) != null;
- }
-
- @Override
- public void clear() {
- throw notModifiable();
- }
-
- @Override
- public boolean equals(final Object obj) {
- return super.equals(obj);
- }
-
+ @SuppressWarnings("unchecked")
@Override
- public BindingCodec remove(final Object key) {
- return null;
+ public Object serialize(final Object input) {
+ Preconditions.checkArgument(input instanceof Map.Entry<?, ?>, "Input must be QName, Value");
+ @SuppressWarnings("rawtypes")
+ QName derivedQName = (QName) ((Map.Entry) input).getKey();
+ @SuppressWarnings("rawtypes")
+ Object inputValue = ((Map.Entry) input).getValue();
+ Preconditions.checkArgument(inputValue instanceof DataObject);
+ Class<? extends DataContainer> inputType = ((DataObject) inputValue).getImplementedInterface();
+ ChoiceCaseCodecImpl<?> codec = tryToLoadImplementation(inputType);
+ Preconditions.checkState(codec != null, "Unable to get codec for %s", inputType);
+ if (codec.isAugmenting(choiceName,derivedQName)) {
+ // If choice is augmenting we use QName which defined this
+ // augmentation
+ return codec.getDelegate().serialize(new ValueWithQName<>(codec.getSchema().getQName(), inputValue));
+ }
+ return codec.getDelegate().serialize(input);
}
- @Override
- public int size() {
- return 0;
- }
- @Override
- public Collection<BindingCodec<?, ?>> values() {
- return Collections.emptySet();
- }
- private UnsupportedOperationException notModifiable() {
- return new UnsupportedOperationException("Not externally modifiable.");
+ @SuppressWarnings("rawtypes")
+ protected Optional<ChoiceCaseCodecImpl> tryToLoadImplementation(final Type potential) {
+ try {
+ @SuppressWarnings("unchecked")
+ Class<? extends DataContainer> clazz = (Class<? extends DataContainer>) classLoadingStrategy
+ .loadClass(potential);
+ ChoiceCaseCodecImpl codec = tryToLoadImplementation(clazz);
+ addImplementation(codec);
+ return Optional.of(codec);
+ } catch (ClassNotFoundException e) {
+ LOG.warn("Failed to find class for choice {}", potential, e);
+ }
+ return Optional.absent();
}
@Override
- public BindingCodec<Map<QName, Object>, Object> put(final T key, final BindingCodec<?, ?> value) {
- throw notModifiable();
+ protected ChoiceCaseCodecImpl<?> tryToLoadImplementation(final Class<? extends DataContainer> inputType) {
+ ChoiceCaseCodecImpl<?> codec = getCaseCodecFor(inputType);
+ addImplementation(codec);
+ return codec;
}
@Override
- public void putAll(final Map<? extends T, ? extends BindingCodec<?, ?>> m) {
- throw notModifiable();
+ protected void tryToLoadImplementations() {
+ Type type = referencedType(choiceType);
+ Collection<Type> potentialCases;
+ synchronized (choiceToCases) {
+ potentialCases = choiceToCases.get(type);
+ }
+ for (Type potential : potentialCases) {
+ try {
+ tryToLoadImplementation(potential);
+ } catch (CodeGenerationException e) {
+ LOG.warn("Failed to proactively generate choice code for {}", type, e);
+ }
+ }
}
@Override
- public int hashCode() {
- return super.hashCode();
+ protected void adaptForPathImpl(final InstanceIdentifier<?> augTarget, final DataNodeContainer ctxNode) {
+ Optional<ChoiceNode> newChoice = findInstantiatedChoice(ctxNode, choiceName);
+ tryToLoadImplementations();
+ Preconditions.checkState(newChoice.isPresent(), "BUG: Unable to find instantiated choice node in schema.");
+ for (@SuppressWarnings("rawtypes")
+ Entry<Class, ChoiceCaseCodecImpl<?>> codec : getImplementations().entrySet()) {
+ ChoiceCaseCodecImpl<?> caseCodec = codec.getValue();
+ Optional<ChoiceCaseNode> instantiatedSchema = findInstantiatedCase(newChoice.get(),
+ caseCodec.getSchema());
+ if (instantiatedSchema.isPresent()) {
+ caseCodec.adaptForPath(augTarget, instantiatedSchema.get());
+ }
+ }
}
- @Override
- public boolean isEmpty() {
- return true;
- }
+ private Optional<ChoiceNode> findInstantiatedChoice(final DataNodeContainer ctxNode, final QName choiceName) {
+ DataSchemaNode potential = ctxNode.getDataChildByName(choiceName);
+ if (potential == null) {
+ potential = ctxNode.getDataChildByName(choiceName.getLocalName());
+ }
- @Override
- public Set<T> keySet() {
- return Collections.emptySet();
- }
+ if (potential instanceof ChoiceNode) {
+ return Optional.of((ChoiceNode) potential);
+ }
- @Override
- public Set<Entry<T, BindingCodec<?, ?>>> entrySet() {
- return Collections.emptySet();
+ return Optional.absent();
}
- @Override
- public boolean containsValue(final Object value) {
- return false;
+ private Optional<ChoiceCaseNode> findInstantiatedCase(final ChoiceNode newChoice, final ChoiceCaseNode schema) {
+ ChoiceCaseNode potential = newChoice.getCaseNodeByName(schema.getQName());
+ if (potential != null) {
+ return Optional.of(potential);
+ }
+ // FIXME: Probably requires more extensive check
+ // e.g. we have one choice and two augmentations from different
+ // modules using same local name
+ // but different namespace / contents
+ return Optional.fromNullable(newChoice.getCaseNodeByName(schema.getQName().getLocalName()));
}
}
*
* Adaptation consists of:
* <ol>
- * <li> scan of available (valid) augmentations for
- * current location
+ * <li>scan of available (valid) augmentations for current location
* <li>lookup for Java classes derived from this augmentations
* <li>generation of missing codecs
* <li>updating Augmentation codecs to work with new location
InstanceIdentifier augPath = augTarget.augmentation(augType);
try {
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = getInstanceIdentifierCodec().serialize(augPath);
- if(domPath == null) {
- LOG.error("Unable to serialize instance identifier for {}",augPath);
+ org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = getInstanceIdentifierCodec()
+ .serialize(augPath);
+ if (domPath == null) {
+ LOG.error("Unable to serialize instance identifier for {}", augPath);
}
} catch (Exception e) {
- LOG.error("Unable to serialize instance identifiers for {}",augPath,e);
+ LOG.error("Unable to serialize instance identifiers for {}", augPath, e);
}
}
} else {
- // Omits warning for empty augmentations since they are not represented in data
- if(!aug.getChildNodes().isEmpty()) {
+ // Omits warning for empty augmentations since they are not
+ // represented in data
+ if (!aug.getChildNodes().isEmpty()) {
LOG.warn("Could not find generated type for augmentation {} with children {}", aug,
- aug.getChildNodes());
+ aug.getChildNodes());
}
}
}
}
-
-
private Type getTypeForAugmentation(final AugmentationSchema aug) {
Optional<AugmentationSchema> currentAug = Optional.of(aug);
while (currentAug.isPresent()) {
}
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private static class LateMixinCodec implements BindingCodec, Delegator<BindingCodec> {
-
- private BindingCodec delegate;
-
- @Override
- public BindingCodec getDelegate() {
- if (delegate == null) {
- throw new IllegalStateException("Codec not initialized yet.");
- }
- return delegate;
- }
-
- @Override
- public Object deserialize(final Object input) {
- return getDelegate().deserialize(input);
- }
-
- @Override
- public Object deserialize(final Object input, final InstanceIdentifier bindingIdentifier) {
- return getDelegate().deserialize(input, bindingIdentifier);
- }
-
- @Override
- public Object serialize(final Object input) {
- return getDelegate().serialize(input);
- }
-
- }
-
@SuppressWarnings("rawtypes")
private static class AugmentationCodecWrapper<T extends Augmentation<?>> implements AugmentationCodec<T>,
Delegator<BindingCodec>, LocationAwareBindingCodec<Node<?>, ValueWithQName<T>> {
*/
package org.opendaylight.yangtools.sal.binding.generator.impl;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
public final class ModuleContext {
private GeneratedTypeBuilder moduleNode;
private final List<GeneratedTOBuilder> genTOs = new ArrayList<GeneratedTOBuilder>();
private final BiMap<Type,AugmentationSchema> typeToAugmentation = HashBiMap.create();
private final Multimap<Type, Type> choiceToCases = HashMultimap.create();
+ private final BiMap<Type,ChoiceCaseNode> caseTypeToSchema = HashBiMap.create();
private final Multimap<Type, Type> augmentableToAugmentations = HashMultimap.create();
augmentableToAugmentations.put(target,augmentation);
}
+ public void addChoiceToCaseMapping(Type choiceType, Type caseType, ChoiceCaseNode schema) {
+ choiceToCases.put(choiceType, caseType);
+ caseTypeToSchema.put(caseType, schema);
+ }
+
+ public BiMap<Type, ChoiceCaseNode> getCaseTypeToSchemas() {
+ return caseTypeToSchema;
+ }
+
}
//staticQNameField(inputType);
staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
staticField(it, IDENTITYREF_CODEC, BindingCodec)
- staticField(it, CLASS_TO_CASE_MAP, Map)
- staticField(it, COMPOSITE_TO_CASE, Map)
+ staticField(it, DISPATCH_CODEC, BindingCodec)
//staticField(it,QNAME_TO_CASE_MAP,BindingCodec)
implementsType(BINDING_CODEC)
method(List, "toDomStatic", #[QName, Object]) [
if($2 == null) {
return null;
}
- «DataObject.name» _baValue = («DataObject.name») $2;
- Class _baClass = _baValue.getImplementedInterface();
- «BINDING_CODEC.name» _codec = «CLASS_TO_CASE_MAP».get(_baClass);
- if(_codec == null) {
- return null;
+ if («DISPATCH_CODEC» == null) {
+ throw new «IllegalStateException.name»("Implementation of codec was not initialized.");
}
- java.util.Map.Entry _input = new «SimpleEntry.name»($1,_baValue);
- Object _ret = _codec.serialize(_input);
+ java.util.Map.Entry _input = new «SimpleEntry.name»($1,$2);
+ Object _ret = «DISPATCH_CODEC».serialize(_input);
////System.out.println("«typeSpec.name»#toDomStatic: " + _ret);
return («List.name») _ret;
}
modifiers = PUBLIC + FINAL + STATIC
bodyChecked = '''
{
- «BINDING_CODEC.name» _codec = («BINDING_CODEC.name») «COMPOSITE_TO_CASE».get($2);
- if(_codec != null) {
- return _codec.deserialize(new «SimpleEntry.name»($1,$2),$3);
+ if («DISPATCH_CODEC» == null) {
+ throw new «IllegalStateException.name»("Implementation of codec was not initialized.");
}
- return null;
+ return «DISPATCH_CODEC».deserialize($2,$3);
}
'''
]
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.sal.binding.generator.impl;
+
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Before;
+
+public abstract class AbstractTypesTest {
+
+ private final URL testSourcesDirUrl;
+ protected Set<File> testModels;
+
+ AbstractTypesTest(final URL testSourcesDirUrl) {
+ this.testSourcesDirUrl = testSourcesDirUrl;
+ }
+
+ @Before
+ public void loadTestResources() throws URISyntaxException {
+ File testSourcesDir = new File(testSourcesDirUrl.toURI());
+ File[] testFiles = Preconditions.checkNotNull(testSourcesDir.listFiles(), testSourcesDir
+ + " does not denote a directory");
+ testModels = new HashSet<>();
+ for (File file : testFiles) {
+ if (file.isFile()) {
+ testModels.add(file);
+ }
+ }
+ }
+
+}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
+import java.io.IOException;
import java.util.List;
-import java.util.Set;
-
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-public class AugmentRelativeXPathTest {
-
- private final static List<File> augmentModels = new ArrayList<>();
- private final static URL augmentFolderPath = AugmentedTypeTest.class
- .getResource("/augment-relative-xpath-models");
-
- @BeforeClass
- public static void loadTestResources() throws URISyntaxException {
- final File augFolder = new File(augmentFolderPath.toURI());
+public class AugmentRelativeXPathTest extends AbstractTypesTest {
- for (final File fileEntry : augFolder.listFiles()) {
- if (fileEntry.isFile()) {
- augmentModels.add(fileEntry);
- }
- }
+ public AugmentRelativeXPathTest() {
+ super(AugmentRelativeXPathTest.class.getResource("/augment-relative-xpath-models"));
}
@Test
- public void AugmentationWithRelativeXPathTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(augmentModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void AugmentationWithRelativeXPathTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
for (final Type type : genTypes) {
if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
gtInterfaceKey = (GeneratedTransferObject) type;
- } else if (type.getName().equals("Interface") && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("Interface")
+ && type.getPackageName().contains("augment._abstract.topology")) {
gtInterface = (GeneratedType) type;
} else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
gtTunnel = (GeneratedType) type;
- } else if (type.getName().equals("TunnelKey") && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("TunnelKey")
+ && type.getPackageName().contains("augment._abstract.topology")) {
gtTunnelKey = (GeneratedTransferObject) type;
}
}
// 'Interface
- assertNotNull("gtInterface is null", gtInterface);
+ assertNotNull("Interface is null", gtInterface);
final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();
- assertNotNull("gtInterfaceMethods is null", gtInterfaceMethods);
+ assertNotNull("Interface methods are null", gtInterfaceMethods);
MethodSignature getIfcKeyMethod = null;
for (final MethodSignature method : gtInterfaceMethods) {
if (method.getName().equals("getKey")) {
break;
}
}
- assertNotNull("getIfcKeyMethod is null", getIfcKeyMethod);
- assertNotNull("getIfcKeyMethod.getReturnType() is null", getIfcKeyMethod.getReturnType());
- assertFalse("getIfcKeyMethod.getReturnType() should not be Void",
- getIfcKeyMethod.getReturnType().equals("java.lang.Void"));
- assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey",
- getIfcKeyMethod.getReturnType().getName().equals("InterfaceKey"));
+ assertNotNull("getKey method is null", getIfcKeyMethod);
+ assertNotNull("getKey method return type is null", getIfcKeyMethod.getReturnType());
+ assertTrue("getKey method return type name must be InterfaceKey", getIfcKeyMethod.getReturnType().getName()
+ .equals("InterfaceKey"));
// 'InterfaceKey'
- assertNotNull("gtInterfaceKey is null", gtInterfaceKey);
+ assertNotNull("InterfaceKey is null", gtInterfaceKey);
final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
- assertNotNull("properties is null", properties);
+ assertNotNull("InterfaceKey properties are null", properties);
GeneratedProperty gtInterfaceId = null;
for (final GeneratedProperty property : properties) {
if (property.getName().equals("interfaceId")) {
break;
}
}
- assertNotNull("gtInterfaceId is null", gtInterfaceId);
- assertNotNull("gtInterfaceId.getReturnType() is null", gtInterfaceId.getReturnType());
- assertFalse("gtInterfaceId.getReturnType() should not be Void",
- gtInterfaceId.getReturnType().equals("java.lang.Void"));
- assertTrue("gtInterfaceId.getReturnType().getName() must be String",
+ assertNotNull("interfaceId is null", gtInterfaceId);
+ assertNotNull("interfaceId return type is null", gtInterfaceId.getReturnType());
+ assertTrue("interfaceId return type name must be String",
gtInterfaceId.getReturnType().getName().equals("String"));
// 'Tunnel'
- assertNotNull("gtTunnel is null", gtTunnel);
+ assertNotNull("Tunnel is null", gtTunnel);
final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
- assertNotNull("tunnelMethods is null", tunnelMethods);
+ assertNotNull("Tunnel methods are null", tunnelMethods);
MethodSignature getTunnelKeyMethod = null;
for (MethodSignature method : tunnelMethods) {
if (method.getName().equals("getKey")) {
break;
}
}
- assertNotNull("getTunnelKeyMethod is null", getTunnelKeyMethod);
- assertNotNull("getTunnelKeyMethod.getReturnType()",
- getTunnelKeyMethod.getReturnType());
- assertFalse("getTunnelKeyMethod.getReturnType() should not be Void",
- getTunnelKeyMethod.getReturnType().equals("java.lang.Void"));
- assertTrue("getTunnelKeyMethod.getReturnType().getName() must be TunnelKey",
- getTunnelKeyMethod.getReturnType().getName().equals("TunnelKey"));
+ assertNotNull("getKey method is null", getTunnelKeyMethod);
+ assertNotNull("getKey method return type", getTunnelKeyMethod.getReturnType());
+ assertTrue("getKey method return type name must be TunnelKey", getTunnelKeyMethod.getReturnType().getName()
+ .equals("TunnelKey"));
// 'TunnelKey'
- assertNotNull("gtTunnelKey is null", gtTunnelKey);
+ assertNotNull("TunnelKey is null", gtTunnelKey);
final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();
- assertNotNull("tunnelKeyProperties is null", tunnelKeyProperties);
+ assertNotNull("TunnelKey properties are null", tunnelKeyProperties);
GeneratedProperty gtTunnelId = null;
for (final GeneratedProperty property : tunnelKeyProperties) {
gtTunnelId = property;
}
}
- assertNotNull("gtTunnelId is null", gtTunnelId);
- assertNotNull("gtTunnelId.getReturnType() is null",
- gtTunnelId.getReturnType());
- assertFalse("gtTunnelId.getReturnType() should not be Void",
- gtTunnelId.getReturnType().equals("java.lang.Void"));
- assertTrue("gtTunnelId.getReturnType().getName() must be Uri",
- gtTunnelId.getReturnType().getName().equals("Uri"));
+ assertNotNull("tunnelId is null", gtTunnelId);
+ assertNotNull("tunnelId return type is null", gtTunnelId.getReturnType());
+ assertTrue("tunnelId return type name must be Uri", gtTunnelId.getReturnType().getName().equals("Uri"));
}
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
+import java.io.IOException;
import java.util.List;
-import java.util.Set;
-
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-public class AugmentedTypeTest {
-
- private final static List<File> augmentModels = new ArrayList<>();
- private final static URL augmentFolderPath = AugmentedTypeTest.class
- .getResource("/augment-test-models");
-
- @BeforeClass
- public static void loadTestResources() throws URISyntaxException {
- final File augFolder = new File(augmentFolderPath.toURI());
+public class AugmentedTypeTest extends AbstractTypesTest {
- for (final File fileEntry : augFolder.listFiles()) {
- if (fileEntry.isFile()) {
- augmentModels.add(fileEntry);
- }
- }
+ public AugmentedTypeTest() {
+ super(AugmentedTypeTest.class.getResource("/augment-test-models"));
}
@Test
- public void augmentedAbstractTopologyTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(augmentModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void augmentedAbstractTopologyTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
for (final Type type : genTypes) {
if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
gtInterfaceKey = (GeneratedTransferObject) type;
- } else if (type.getName().equals("Interface") && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("Interface")
+ && type.getPackageName().contains("augment._abstract.topology")) {
gtInterface = (GeneratedType) type;
} else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
gtTunnel = (GeneratedType) type;
- } else if (type.getName().equals("TunnelKey") && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("TunnelKey")
+ && type.getPackageName().contains("augment._abstract.topology")) {
gtTunnelKey = (GeneratedTransferObject) type;
- } else if (type.getName().equals("NetworkLink2") && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("NetworkLink2")
+ && type.getPackageName().contains("augment._abstract.topology")) {
gtNetworkLink2 = (GeneratedType) type;
}
}
assertNotNull("getIfcKeyMethod.getReturnType() is null", getIfcKeyMethod.getReturnType());
assertFalse("getIfcKeyMethod.getReturnType() should not be Void",
getIfcKeyMethod.getReturnType().equals("java.lang.Void"));
- assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey",
- getIfcKeyMethod.getReturnType().getName().equals("InterfaceKey"));
+ assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey", getIfcKeyMethod.getReturnType()
+ .getName().equals("InterfaceKey"));
MethodSignature getHigherLayerIfMethod = null;
for (final MethodSignature method : gtInterfaceMethods) {
break;
}
}
- assertNotNull("getHigherLayerIfMethod is null", getHigherLayerIfMethod);
- assertNotNull("getHigherLayerIfMethod.getReturnType() is null",
- getHigherLayerIfMethod.getReturnType());
- assertFalse("getHigherLayerIfMethod.getReturnType() should not be Void",
- getHigherLayerIfMethod.getReturnType().equals("java.lang.Void"));
- assertTrue("getHigherLayerIfMethod.getReturnType().getName() must be List",
- getHigherLayerIfMethod.getReturnType().getName().equals("List"));
+ assertNotNull("getHigherLayerIf method is null", getHigherLayerIfMethod);
+ assertNotNull("getHigherLayerIf method return type is null", getHigherLayerIfMethod.getReturnType());
+ assertTrue("getHigherLayerIf method return type name must be List", getHigherLayerIfMethod.getReturnType()
+ .getName().equals("List"));
// 'InterfaceKey'
- assertNotNull("gtInterfaceKey is null", gtInterfaceKey);
+ assertNotNull("InterfaceKey is null", gtInterfaceKey);
final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
assertNotNull("properties is null", properties);
GeneratedProperty gtInterfaceId = null;
break;
}
}
- assertNotNull("gtInterfaceId is null", gtInterfaceId);
- assertNotNull("gtInterfaceId.getReturnType() is null", gtInterfaceId.getReturnType());
- assertFalse("gtInterfaceId.getReturnType() should not be Void",
- gtInterfaceId.getReturnType().equals("java.lang.Void"));
- assertTrue("gtInterfaceId.getReturnType().getName() must be String",
+ assertNotNull("interfaceId is null", gtInterfaceId);
+ assertNotNull("interfaceId return type is null", gtInterfaceId.getReturnType());
+ assertTrue("interfaceId return type name must be String",
gtInterfaceId.getReturnType().getName().equals("String"));
// 'Tunnel'
- assertNotNull("gtTunnel is null", gtTunnel);
+ assertNotNull("Tunnel is null", gtTunnel);
final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
- assertNotNull("tunnelMethods is null", tunnelMethods);
+ assertNotNull("Tunnel methods are null", tunnelMethods);
MethodSignature getTunnelKeyMethod = null;
for (MethodSignature method : tunnelMethods) {
if (method.getName().equals("getKey")) {
break;
}
}
- assertNotNull("getTunnelKeyMethod is null", getTunnelKeyMethod);
- assertNotNull("getTunnelKeyMethod.getReturnType()",
- getTunnelKeyMethod.getReturnType());
- assertFalse("getTunnelKeyMethod.getReturnType() should not be Void",
- getTunnelKeyMethod.getReturnType().equals("java.lang.Void"));
- assertTrue("getTunnelKeyMethod.getReturnType().getName() must be TunnelKey",
- getTunnelKeyMethod.getReturnType().getName().equals("TunnelKey"));
+ assertNotNull("getKey method of Tunnel is null", getTunnelKeyMethod);
+ assertNotNull("getKey method return type is null", getTunnelKeyMethod.getReturnType());
+ assertTrue("getKey method return type name must be TunnelKey", getTunnelKeyMethod.getReturnType().getName()
+ .equals("TunnelKey"));
// 'TunnelKey'
- assertNotNull("gtTunnelKey is null", gtTunnelKey);
+ assertNotNull("TunnelKey is null", gtTunnelKey);
final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();
- assertNotNull("tunnelKeyProperties is null", tunnelKeyProperties);
+ assertNotNull("TunnelKey properties are null", tunnelKeyProperties);
GeneratedProperty gtTunnelId = null;
for (final GeneratedProperty property : tunnelKeyProperties) {
gtTunnelId = property;
}
}
- assertNotNull("gtTunnelId is null", gtTunnelId);
- assertNotNull("gtTunnelId.getReturnType() is null",
- gtTunnelId.getReturnType());
- assertFalse("gtTunnelId.getReturnType() should not be Void",
- gtTunnelId.getReturnType().equals("java.lang.Void"));
- assertTrue("gtTunnelId.getReturnType().getName() must be Integer",
- gtTunnelId.getReturnType().getName().equals("Integer"));
+ assertNotNull("tunnelId is null", gtTunnelId);
+ assertNotNull("tunnelId return type is null", gtTunnelId.getReturnType());
+ assertTrue("tunnelId returnType name must be Integer", gtTunnelId.getReturnType().getName().equals("Integer"));
// 'NetworkLink2'
- assertNotNull("gtNetworkLink2 is null", gtNetworkLink2);
+ assertNotNull("NetworkLink2 is null", gtNetworkLink2);
final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
- assertNotNull("networkLink2Methods is null", networkLink2Methods);
-
-// FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP
-// MethodSignature getIfcMethod = null;
-// for (MethodSignature method : networkLink2Methods) {
-// if (method.getName().equals("getInterface")) {
-// getIfcMethod = method;
-// break;
-// }
-// }
-//
-// assertNotNull("getIfcMethod is null", getIfcMethod);
-// assertNotNull("getIfcMethod.getReturnType() is null", getIfcMethod.getReturnType());
-// assertFalse("getIfcMethod.getReturnType() should not be Void", getIfcMethod.getReturnType().equals("java.lang.Void"));
-// assertTrue("getIfcMethod.getReturnType().getName() must be String", getIfcMethod.getReturnType().getName().equals("String"));
+ assertNotNull("NetworkLink2 methods are null", networkLink2Methods);
+
+ MethodSignature getIfcMethod = null;
+ for (MethodSignature method : networkLink2Methods) {
+ if (method.getName().equals("getInterface")) {
+ getIfcMethod = method;
+ break;
+ }
+ }
+
+ assertNotNull("getInterface method is null", getIfcMethod);
+ assertNotNull("getInterface method return type is null", getIfcMethod.getReturnType());
+ assertTrue("getInterface method return type name must be String", getIfcMethod.getReturnType().getName()
+ .equals("String"));
}
@Test
public void augmentedTopologyTunnelsTest() {
}
+
}
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class BinaryTypeTest {
}
@Test
- public void binaryTypeTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void binaryTypeTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class BitAndUnionTOEnclosingTest {
private static List<Type> genTypes = null;
private static GeneratedType parentContainer = null;
- public static void parseResources() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public static void parseResources() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@BeforeClass
- public static void loadTestResources() throws URISyntaxException {
+ public static void loadTestResources() throws IOException, URISyntaxException {
final File listModelFile = new File(ExtendedTypedefTest.class.getResource("/bit_and_union.yang").toURI());
testModels.add(listModelFile);
parseResources();
import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsInterface;
import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
+import java.io.IOException;
import java.util.List;
-import java.util.Set;
-
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-public class ChoiceCaseGenTypesTest {
-
- private final static List<File> yangModels = new ArrayList<>();
- private final static URL yangModelsFolder = AugmentedTypeTest.class.getResource("/choice-case-type-test-models")
- ;
+public class ChoiceCaseGenTypesTest extends AbstractTypesTest {
- @BeforeClass
- public static void loadTestResources() throws URISyntaxException {
- final File augFolder = new File(yangModelsFolder.toURI());
- for (final File fileEntry : augFolder.listFiles()) {
- if (fileEntry.isFile()) {
- yangModels.add(fileEntry);
- }
- }
+ public ChoiceCaseGenTypesTest() {
+ super(ChoiceCaseGenTypesTest.class.getResource("/choice-case-type-test-models"));
}
- private static GeneratedType checkGeneratedType(List<Type> genTypes, String genTypeName, String packageName,
- int occurences) {
+ private GeneratedType checkGeneratedType(List<Type> genTypes, String genTypeName, String packageName, int occurences) {
GeneratedType searchedGenType = null;
int searchedGenTypeCounter = 0;
for (Type type : genTypes) {
}
- private static GeneratedType checkGeneratedType(List<Type> genTypes, String genTypeName, String packageName) {
+ private GeneratedType checkGeneratedType(List<Type> genTypes, String genTypeName, String packageName) {
return checkGeneratedType(genTypes, genTypeName, packageName, 1);
}
@Test
- public void choiceCaseResolvingTypeTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
-
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void choiceCaseResolvingTypeTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
genType = checkGeneratedType(genTypes, "LeafAugCase", pcgPref
+ ".netconf.state.datastores.datastore.locks.lock.type"); // choice
- // FIXME
containsMethods(genType, new NameTypePattern("getLeafAugCase", "String"));
containsInterface("LockType", genType);
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class ControllerTest {
}
@Test
- public void controllerAugmentationTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(controllerModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void controllerAugmentationTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(controllerModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.sal.binding.yang.types.BaseYangTypes;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class ExtendedTypedefTest {
}
@Test
- public void constantGenerationTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void constantGenerationTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GenEnumResolvingTest {
- private SchemaContext resolveSchemaContextFromFiles(
- final URI... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
+ private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+ final YangContextParser parser = new YangParserImpl();
final List<File> inputFiles = new ArrayList<File>();
for (int i = 0; i < yangFiles.length; ++i) {
inputFiles.add(new File(yangFiles[i]));
}
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
+ return parser.parseFiles(inputFiles);
}
@Test
- public void testLeafEnumResolving() throws URISyntaxException {
- final URI ietfInterfacesPath = getClass().getResource(
- "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();
- final URI ifTypePath = getClass().getResource(
- "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
- final URI yangTypesPath = getClass().getResource(
- "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
-
- final SchemaContext context = resolveSchemaContextFromFiles(
- ietfInterfacesPath, ifTypePath, yangTypesPath);
+ public void testLeafEnumResolving() throws URISyntaxException, IOException {
+ final URI ietfInterfacesPath = getClass().getResource("/enum-test-models/ietf-interfaces@2012-11-15.yang")
+ .toURI();
+ final URI ifTypePath = getClass().getResource("/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
+ final URI yangTypesPath = getClass().getResource("/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
+
+ final SchemaContext context = resolveSchemaContextFromFiles(ietfInterfacesPath, ifTypePath, yangTypesPath);
assertTrue(context != null);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
}
}
- assertNotNull("Generated Type Interface is not present in list of " +
- "Generated Types", genInterface);
+ assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
Enumeration linkUpDownTrapEnable = null;
Enumeration operStatus = null;
final List<Enumeration> enums = genInterface.getEnumerations();
- assertNotNull("Generated Type Interface cannot contain NULL reference" +
- " to Enumeration types!", enums);
- assertEquals("Generated Type Interface MUST contain 2 Enumeration " +
- "Types", 2, enums.size());
+ assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", enums);
+ assertEquals("Generated Type Interface MUST contain 2 Enumeration Types", 2, enums.size());
for (final Enumeration e : enums) {
if (e.getName().equals("LinkUpDownTrapEnable")) {
linkUpDownTrapEnable = e;
}
}
- assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!",
- linkUpDownTrapEnable);
+ assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);
- assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition " +
- "not NULL reference!", linkUpDownTrapEnable.getValues());
- assertNotNull("Enum OperStatus MUST contain Values definition not " +
- "NULL reference!", operStatus.getValues());
- assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2,
- linkUpDownTrapEnable.getValues().size());
- assertEquals("Enum OperStatus MUST contain 7 values!", 7,
- operStatus.getValues().size());
+ assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition not NULL reference!",
+ linkUpDownTrapEnable.getValues());
+ assertNotNull("Enum OperStatus MUST contain Values definition not NULL reference!", operStatus.getValues());
+ assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2, linkUpDownTrapEnable.getValues().size());
+ assertEquals("Enum OperStatus MUST contain 7 values!", 7, operStatus.getValues().size());
- final List<MethodSignature> methods = genInterface
- .getMethodDefinitions();
+ final List<MethodSignature> methods = genInterface.getMethodDefinitions();
- assertNotNull("Generated Interface cannot contain NULL reference for " +
- "Method Signature Definitions!", methods);
+ assertNotNull("Generated Interface cannot contain NULL reference for Method Signature Definitions!", methods);
- assertEquals("Expected count of method signature definitions is 15",
- 15, methods.size());
+ assertEquals("Expected count of method signature definitions is 15", 15, methods.size());
Enumeration ianaIfType = null;
for (final MethodSignature method : methods) {
if (method.getName().equals("getType")) {
if (method.getReturnType() instanceof Enumeration) {
- ianaIfType = (Enumeration)method.getReturnType();
+ ianaIfType = (Enumeration) method.getReturnType();
}
}
}
- assertNotNull("Method getType MUST return Enumeration Type, " +
- "not NULL reference!", ianaIfType);
- assertEquals("Enumeration getType MUST contain 272 values!", 272,
- ianaIfType.getValues().size());
+ assertNotNull("Method getType MUST return Enumeration Type not NULL reference!", ianaIfType);
+ assertEquals("Enumeration getType MUST contain 272 values!", 272, ianaIfType.getValues().size());
}
@Test
- public void testTypedefEnumResolving() throws URISyntaxException {
- final URI ianaIfTypePath = getClass().getResource(
- "/leafref-test-models/iana-if-type@2012-06-05.yang").toURI();
+ public void testTypedefEnumResolving() throws URISyntaxException, IOException {
+ final URI ianaIfTypePath = getClass().getResource("/leafref-test-models/iana-if-type@2012-06-05.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);
assertTrue(context != null);
assertTrue(type instanceof Enumeration);
final Enumeration enumer = (Enumeration) type;
- assertEquals("Enumeration type MUST contain 272 values!", 272,
- enumer.getValues().size());
+ assertEquals("Enumeration type MUST contain 272 values!", 272, enumer.getValues().size());
}
@Test
- public void testLeafrefEnumResolving() throws URISyntaxException {
- final URI ietfInterfacesPath = getClass().getResource(
- "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();
- final URI ifTypePath = getClass().getResource(
- "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
- final URI yangTypesPath = getClass().getResource(
- "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
- final URI topologyPath = getClass().getResource(
- "/enum-test-models/abstract-topology@2013-02-08.yang")
+ public void testLeafrefEnumResolving() throws URISyntaxException, IOException {
+ final URI ietfInterfacesPath = getClass().getResource("/enum-test-models/ietf-interfaces@2012-11-15.yang")
.toURI();
- final URI inetTypesPath = getClass().getResource(
- "/enum-test-models/ietf-inet-types@2010-09-24.yang")
- .toURI();
- final SchemaContext context = resolveSchemaContextFromFiles(
- ietfInterfacesPath, ifTypePath, yangTypesPath, topologyPath,
- inetTypesPath);
+ final URI ifTypePath = getClass().getResource("/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
+ final URI yangTypesPath = getClass().getResource("/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
+ final URI topologyPath = getClass().getResource("/enum-test-models/abstract-topology@2013-02-08.yang").toURI();
+ final URI inetTypesPath = getClass().getResource("/enum-test-models/ietf-inet-types@2010-09-24.yang").toURI();
+ final SchemaContext context = resolveSchemaContextFromFiles(ietfInterfacesPath, ifTypePath, yangTypesPath,
+ topologyPath, inetTypesPath);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
GeneratedType genInterface = null;
for (final Type type : genTypes) {
if (type instanceof GeneratedType) {
- if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")
+ if (type.getPackageName().equals(
+ "org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")
&& type.getName().equals("Interface")) {
genInterface = (GeneratedType) type;
}
}
}
- assertNotNull("Generated Type Interface is not present in list of " +
- "Generated Types", genInterface);
+ assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
Type linkUpDownTrapEnable = null;
Type operStatus = null;
final List<MethodSignature> methods = genInterface.getMethodDefinitions();
- assertNotNull("Generated Type Interface cannot contain NULL reference" +
- " to Enumeration types!", methods);
- assertEquals("Generated Type Interface MUST contain 5 Methods ",
- 5, methods.size());
+ assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", methods);
+ assertEquals("Generated Type Interface MUST contain 5 Methods ", 5, methods.size());
for (final MethodSignature method : methods) {
if (method.getName().equals("getLinkUpDownTrapEnable")) {
linkUpDownTrapEnable = method.getReturnType();
}
}
- assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!",
- linkUpDownTrapEnable);
+ assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
assertTrue("Expected LinkUpDownTrapEnable of type Enumeration", linkUpDownTrapEnable instanceof Enumeration);
assertEquals(linkUpDownTrapEnable.getPackageName(),
"org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");
- assertNotNull("Expected Referenced Enum OperStatus, but was NULL!",
- operStatus);
+ assertNotNull("Expected Referenced Enum OperStatus, but was NULL!", operStatus);
assertTrue("Expected OperStatus of type Enumeration", operStatus instanceof Enumeration);
assertEquals(operStatus.getPackageName(),
"org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");
}
+
}
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GenTypesSubSetTest {
}
@Test
- public void genTypesFromSubsetOfTwoModulesTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void genTypesFromSubsetOfTwoModulesTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
+ Set<Module> modules = context.getModules();
final Set<Module> toGenModules = new HashSet<>();
for (final Module module : modules) {
}
@Test
- public void genTypesFromSubsetOfThreeModulesTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void genTypesFromSubsetOfThreeModulesTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
+ final Set<Module> modules = context.getModules();
final Set<Module> toGenModules = new HashSet<>();
for (final Module module : modules) {
import static org.junit.Assert.assertTrue;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.List;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
@Test
- public void testGeneretedTypesBitsTest() throws URISyntaxException {
+ public void testGeneretedTypesBitsTest() throws Exception {
final URI yangTypesPath = getClass().getResource("/simple-bits-demo.yang").toURI();
final SchemaContext context = SupportTestUtil.resolveSchemaContextFromFiles(yangTypesPath);
int hashPropertiesNum = 0;
String nameReturnParamType = "";
- String nameMethodeParamType = "";
boolean getByteLeafMethodFound = false;
boolean setByteLeafMethodFound = false;
int setByteLeafMethodParamNum = 0;
List<Parameter> parameters = methodSignature.getParameters();
setByteLeafMethodParamNum = parameters.size();
- for (Parameter parameter : parameters) {
- nameMethodeParamType = parameter.getType().getName();
- }
-
}
}
*/
package org.opendaylight.yangtools.sal.binding.generator.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GeneratedTypesLeafrefTest {
- private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
+ private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+ final YangContextParser parser = new YangParserImpl();
final List<File> inputFiles = new ArrayList<File>();
for (int i = 0; i < yangFiles.length; ++i) {
inputFiles.add(new File(yangFiles[i]));
}
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
+ return parser.parseFiles(inputFiles);
}
@Test
- public void testLeafrefResolving() throws URISyntaxException {
+ public void testLeafrefResolving() throws URISyntaxException, IOException {
final URI topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")
.toURI();
final URI interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")
}
@Test
- public void testLeafrefInvalidPathResolving() throws URISyntaxException {
+ public void testLeafrefInvalidPathResolving() throws URISyntaxException, IOException {
final URI resource = getClass().getResource("/leafref-test-invalid-model/foo.yang").toURI();
assertNotNull(resource);
*/
package org.opendaylight.yangtools.sal.binding.generator.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GeneratedTypesStringTest {
}
@Test
- public void constantGenerationTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void constantGenerationTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
*/
package org.opendaylight.yangtools.sal.binding.generator.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GeneratedTypesTest {
- private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
+ private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+ final YangContextParser parser = new YangParserImpl();
final List<File> inputFiles = new ArrayList<File>();
for (int i = 0; i < yangFiles.length; ++i) {
inputFiles.add(new File(yangFiles[i]));
}
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
+ return parser.parseFiles(inputFiles);
}
@Test
- public void testMultipleModulesResolving() throws URISyntaxException {
+ public void testMultipleModulesResolving() throws URISyntaxException, IOException {
final URI topologyPath = getClass().getResource("/abstract-topology.yang").toURI();
final URI typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);
}
@Test
- public void testContainerResolving() throws URISyntaxException {
+ public void testContainerResolving() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/simple-container-demo.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
assert (context != null);
}
@Test
- public void testLeafListResolving() throws URISyntaxException {
+ public void testLeafListResolving() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/simple-leaf-list-demo.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
assertNotNull(context);
}
@Test
- public void testListResolving() throws URISyntaxException {
+ public void testListResolving() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/simple-list-demo.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
assertNotNull(context);
}
@Test
- public void testListCompositeKeyResolving() throws URISyntaxException {
+ public void testListCompositeKeyResolving() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/list-composite-key.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
}
@Test
- public void testGeneratedTypes() throws URISyntaxException {
+ public void testGeneratedTypes() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/demo-topology.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
assertNotNull(context);
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class IdentityrefTypeTest {
* provideTypeForIdentityref}
*/
@Test
- public void testIdentityrefYangBuiltInType() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void testIdentityrefYangBuiltInType() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class SupportTestUtil {
- public static SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
+ public static SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+ final YangContextParser parser = new YangParserImpl();
final List<File> inputFiles = new ArrayList<File>();
for (int i = 0; i < yangFiles.length; ++i) {
inputFiles.add(new File(yangFiles[i]));
}
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
+ return parser.parseFiles(inputFiles);
}
public static void containsMethods(final GeneratedType genType, final NameTypePattern... searchedSignsWhat) {
import static org.junit.Assert.assertNotNull;
import java.net.URI;
-import java.net.URISyntaxException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Set;
-
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
private Module m;
@BeforeClass
- public static void setup() throws ParseException, URISyntaxException {
+ public static void setup() throws Exception {
final URI path1 = TypeProviderIntegrationTest.class.getResource("/type-provider/test.yang").toURI();
final URI path2 = TypeProviderIntegrationTest.class.getResource(
"/type-provider/ietf-inet-types@2010-09-24.yang").toURI();
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class UnionTypeDefTest {
}
@Test
- public void unionTypeResolvingTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void unionTypeResolvingTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class UsesTest {
}
@Test
- public void usesInGroupingDependenciesTest() {
+ public void usesInGroupingDependenciesTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-dependencies.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInCaseTest() {
+ public void usesInCaseTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-case.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInContainerTest() {
+ public void usesInContainerTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-container.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInGroupingTest() {
+ public void usesInGroupingTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-grouping.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInListTest() {
+ public void usesInListTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-list.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInModulTest() {
+ public void usesInModulTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-modul.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInRpcTest() {
+ public void usesInRpcTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-rpc.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInAugmentTest() {
+ public void usesInAugmentTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-augment.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInNotification() {
+ public void usesInNotification() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-notification.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
namespace "urn:model:abstract:topology";
prefix "tp";
- import ietf-inet-types {
- prefix "inet";
- revision-date 2010-09-24;
- }
-
- organization "OPEN DAYLIGHT";
- contact "http://www.opendaylight.org/";
-
- description
- "This module contains the definitions of elements that creates network
- topology i.e. definition of network nodes and links. This module is not designed
- to be used solely for network representation. This module SHOULD be used as base
- module in defining the network topology.";
-
revision "2013-02-08" {
- reference "http://www.opendaylight.org/";
}
-
+
typedef node-id-ref {
type leafref {
path "/tp:topology/tp:network-nodes/tp:network-node/tp:node-id";
}
- description "This type is used for leafs that reference network node instance.";
}
typedef link-id-ref {
type leafref {
path "/tp:topology/tp:network-links/tp:network-link/tp:link-id";
}
- description "This type is used for leafs that reference network link instance.";
+ }
+
+ typedef uri {
+ type string;
}
container topology {
- description "This is the model of abstract topology which contains
- only Network Nodes and Network Links. Each topology MUST be identified by unique
- topology-id for reason that the store could contain many topologies.";
leaf topology-id {
- type inet:uri;
- description "It is presumed that datastore will contain many topologies.
- To distinguish between topologies it is vital to have
- UNIQUE topology identifier.";
+ type uri;
}
container network-nodes {
key "node-id";
leaf node-id {
- type inet:uri;
- description "The Topology identifier of network-node.";
+ type uri;
}
container attributes {
- description "Aditional attributes that can Network Node contains.";
}
- description "The list of network nodes defined for topology.";
}
}
-
+
container network-links {
list network-link {
key "link-id";
leaf link-id {
- type inet:uri;
+ type uri;
description "";
}
container source-node {
leaf id {
type node-id-ref;
- description "Source node identifier.";
}
}
container destination-node {
leaf id {
type node-id-ref;
- description "Destination node identifier.";
}
}
container attributes {
- description "Aditional attributes that can Network Link contains.";
}
- description "The Network Link which is defined by Local (Source) and Remote (Destination)
- Network Nodes. Every link MUST be defined either by identifier and
- his local and remote Network Nodes (In real applications it is common that
- many links are originated from one node and end up in same remote node).
- To ensure that we would always know to distinguish between links, every link
- SHOULD have identifier.";
}
}
}
-}
\ No newline at end of file
+
+}
namespace "urn:model:augment:abstract:topology";
prefix "atp";
- import ietf-inet-types {
- prefix "inet";
- revision-date 2010-09-24;
- }
-
import ietf-interfaces {
prefix "if";
revision-date 2012-11-15;
revision-date 2013-02-08;
}
- organization "OPEN DAYLIGHT";
- contact "http://www.opendaylight.org/";
-
revision "2013-05-03" {
- reference "http://www.opendaylight.org/";
}
augment "/at:topology" {
}
}
}
-}
\ No newline at end of file
+}
+++ /dev/null
-module iana-if-type {
- namespace "urn:ietf:params:xml:ns:yang:iana-if-type";
- prefix ianaift;
-
- organization "IANA";
- contact
- " Internet Assigned Numbers Authority
-
- Postal: ICANN
- 4676 Admiralty Way, Suite 330
- Marina del Rey, CA 90292
-
- Tel: +1 310 823 9358
- E-Mail: iana&iana.org";
- description
- "This YANG module defines the iana-if-type typedef, which
- contains YANG definitions for IANA-registered interface types.
-
- This YANG module is maintained by IANA, and reflects the
- 'ifType definitions' registry.
-
- The latest revision of this YANG module can be obtained from
- the IANA web site.
-
- Copyright (c) 2011 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC XXXX; see
- the RFC itself for full legal notices.";
- // RFC Ed.: replace XXXX with actual RFC number and remove this
- // note.
-
- // RFC Ed.: update the date below with the date of RFC publication
- // and remove this note.
- revision 2012-06-05 {
- description
- "Initial revision.";
- reference
- "RFC XXXX: TITLE";
- }
-
- typedef iana-if-type {
- type enumeration {
- enum "other" {
- value 1;
- description
- "None of the following";
- }
- enum "regular1822" {
- value 2;
- }
- enum "hdh1822" {
- value 3;
- }
- enum "ddnX25" {
- value 4;
- }
- enum "rfc877x25" {
- value 5;
- reference
- "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer";
- }
- enum "ethernetCsmacd" {
- value 6;
- description
- "For all ethernet-like interfaces, regardless of speed,
- as per RFC3635.";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "iso88023Csmacd" {
- value 7;
- status deprecated;
- description
- "Deprecated via RFC3635.
- Use ethernetCsmacd(6) instead.";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "iso88024TokenBus" {
- value 8;
- }
- enum "iso88025TokenRing" {
- value 9;
- }
- enum "iso88026Man" {
- value 10;
- }
- enum "starLan" {
- value 11;
- status deprecated;
- description
- "Deprecated via RFC3635.
- Use ethernetCsmacd(6) instead.";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "proteon10Mbit" {
- value 12;
- }
- enum "proteon80Mbit" {
- value 13;
- }
- enum "hyperchannel" {
- value 14;
- }
- enum "fddi" {
- value 15;
- reference
- "RFC 1512 - FDDI Management Information Base";
- }
- enum "lapb" {
- value 16;
- reference
- "RFC 1381 - SNMP MIB Extension for X.25 LAPB";
- }
- enum "sdlc" {
- value 17;
- }
- enum "ds1" {
- value 18;
- description
- "DS1-MIB";
- reference
- "RFC 4805 - Definitions of Managed Objects for the
- DS1, J1, E1, DS2, and E2 Interface Types";
- }
- enum "e1" {
- value 19;
- status obsolete;
- description
- "Obsolete see DS1-MIB";
- reference
- "RFC 4805 - Definitions of Managed Objects for the
- DS1, J1, E1, DS2, and E2 Interface Types";
- }
- enum "basicISDN" {
- value 20;
- description
- "see also RFC2127";
- }
- enum "primaryISDN" {
- value 21;
- }
- enum "propPointToPointSerial" {
- value 22;
- description
- "proprietary serial";
- }
- enum "ppp" {
- value 23;
- }
- enum "softwareLoopback" {
- value 24;
- }
- enum "eon" {
- value 25;
- description
- "CLNP over IP";
- }
- enum "ethernet3Mbit" {
- value 26;
- }
- enum "nsip" {
- value 27;
- description
- "XNS over IP";
- }
- enum "slip" {
- value 28;
- description
- "generic SLIP";
- }
- enum "ultra" {
- value 29;
- description
- "ULTRA technologies";
- }
- enum "ds3" {
- value 30;
- description
- "DS3-MIB";
- reference
- "RFC 3896 - Definitions of Managed Objects for the
- DS3/E3 Interface Type";
- }
- enum "sip" {
- value 31;
- description
- "SMDS, coffee";
- reference
- "RFC 1694 - Definitions of Managed Objects for SMDS
- Interfaces using SMIv2";
- }
- enum "frameRelay" {
- value 32;
- description
- "DTE only.";
- reference
- "RFC 2115 - Management Information Base for Frame Relay
- DTEs Using SMIv2";
- }
- enum "rs232" {
- value 33;
- reference
- "RFC 1659 - Definitions of Managed Objects for RS-232-like
- Hardware Devices using SMIv2";
- }
- enum "para" {
- value 34;
- description
- "parallel-port";
- reference
- "RFC 1660 - Definitions of Managed Objects for
- Parallel-printer-like Hardware Devices using
- SMIv2";
- }
- enum "arcnet" {
- value 35;
- description
- "arcnet";
- }
- enum "arcnetPlus" {
- value 36;
- description
- "arcnet plus";
- }
- enum "atm" {
- value 37;
- description
- "ATM cells";
- }
- enum "miox25" {
- value 38;
- reference
- "RFC 1461 - SNMP MIB extension for Multiprotocol
- Interconnect over X.25";
- }
- enum "sonet" {
- value 39;
- description
- "SONET or SDH";
- }
- enum "x25ple" {
- value 40;
- reference
- "RFC 2127 - ISDN Management Information Base using SMIv2";
- }
- enum "iso88022llc" {
- value 41;
- }
- enum "localTalk" {
- value 42;
- }
- enum "smdsDxi" {
- value 43;
- }
- enum "frameRelayService" {
- value 44;
- description
- "FRNETSERV-MIB";
- reference
- "RFC 2954 - Definitions of Managed Objects for Frame
- Relay Service";
- }
- enum "v35" {
- value 45;
- }
- enum "hssi" {
- value 46;
- }
- enum "hippi" {
- value 47;
- }
- enum "modem" {
- value 48;
- description
- "Generic modem";
- }
- enum "aal5" {
- value 49;
- description
- "AAL5 over ATM";
- }
- enum "sonetPath" {
- value 50;
- }
- enum "sonetVT" {
- value 51;
- }
- enum "smdsIcip" {
- value 52;
- description
- "SMDS InterCarrier Interface";
- }
- enum "propVirtual" {
- value 53;
- description
- "proprietary virtual/internal";
- reference
- "RFC 2863 - The Interfaces Group MIB";
- }
- enum "propMultiplexor" {
- value 54;
- description
- "proprietary multiplexing";
- reference
- "RFC 2863 - The Interfaces Group MIB";
- }
- enum "ieee80212" {
- value 55;
- description
- "100BaseVG";
- }
- enum "fibreChannel" {
- value 56;
- description
- "Fibre Channel";
- }
- enum "hippiInterface" {
- value 57;
- description
- "HIPPI interfaces";
- }
- enum "frameRelayInterconnect" {
- value 58;
- status obsolete;
- description
- "Obsolete use either
- frameRelay(32) or frameRelayService(44).";
- }
- enum "aflane8023" {
- value 59;
- description
- "ATM Emulated LAN for 802.3";
- }
- enum "aflane8025" {
- value 60;
- description
- "ATM Emulated LAN for 802.5";
- }
- enum "cctEmul" {
- value 61;
- description
- "ATM Emulated circuit";
- }
- enum "fastEther" {
- value 62;
- status deprecated;
- description
- "Obsoleted via RFC3635.
- ethernetCsmacd(6) should be used instead";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "isdn" {
- value 63;
- description
- "ISDN and X.25";
- reference
- "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN
- in the Packet Mode";
- }
- enum "v11" {
- value 64;
- description
- "CCITT V.11/X.21";
- }
- enum "v36" {
- value 65;
- description
- "CCITT V.36";
- }
- enum "g703at64k" {
- value 66;
- description
- "CCITT G703 at 64Kbps";
- }
- enum "g703at2mb" {
- value 67;
- status obsolete;
- description
- "Obsolete see DS1-MIB";
- }
- enum "qllc" {
- value 68;
- description
- "SNA QLLC";
- }
- enum "fastEtherFX" {
- value 69;
- status deprecated;
- description
- "Obsoleted via RFC3635
- ethernetCsmacd(6) should be used instead";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "channel" {
- value 70;
- description
- "channel";
- }
- enum "ieee80211" {
- value 71;
- description
- "radio spread spectrum";
- }
- enum "ibm370parChan" {
- value 72;
- description
- "IBM System 360/370 OEMI Channel";
- }
- enum "escon" {
- value 73;
- description
- "IBM Enterprise Systems Connection";
- }
- enum "dlsw" {
- value 74;
- description
- "Data Link Switching";
- }
- enum "isdns" {
- value 75;
- description
- "ISDN S/T interface";
- }
- enum "isdnu" {
- value 76;
- description
- "ISDN U interface";
- }
- enum "lapd" {
- value 77;
- description
- "Link Access Protocol D";
- }
- enum "ipSwitch" {
- value 78;
- description
- "IP Switching Objects";
- }
- enum "rsrb" {
- value 79;
- description
- "Remote Source Route Bridging";
- }
- enum "atmLogical" {
- value 80;
- description
- "ATM Logical Port";
- reference
- "RFC 3606 - Definitions of Supplemental Managed Objects
- for ATM Interface";
- }
- enum "ds0" {
- value 81;
- description
- "Digital Signal Level 0";
- reference
- "RFC 2494 - Definitions of Managed Objects for the DS0
- and DS0 Bundle Interface Type";
- }
- enum "ds0Bundle" {
- value 82;
- description
- "group of ds0s on the same ds1";
- reference
- "RFC 2494 - Definitions of Managed Objects for the DS0
- and DS0 Bundle Interface Type";
- }
- enum "bsc" {
- value 83;
- description
- "Bisynchronous Protocol";
- }
- enum "async" {
- value 84;
- description
- "Asynchronous Protocol";
- }
- enum "cnr" {
- value 85;
- description
- "Combat Net Radio";
- }
- enum "iso88025Dtr" {
- value 86;
- description
- "ISO 802.5r DTR";
- }
- enum "eplrs" {
- value 87;
- description
- "Ext Pos Loc Report Sys";
- }
- enum "arap" {
- value 88;
- description
- "Appletalk Remote Access Protocol";
- }
- enum "propCnls" {
- value 89;
- description
- "Proprietary Connectionless Protocol";
- }
- enum "hostPad" {
- value 90;
- description
- "CCITT-ITU X.29 PAD Protocol";
- }
- enum "termPad" {
- value 91;
- description
- "CCITT-ITU X.3 PAD Facility";
- }
- enum "frameRelayMPI" {
- value 92;
- description
- "Multiproto Interconnect over FR";
- }
- enum "x213" {
- value 93;
- description
- "CCITT-ITU X213";
- }
- enum "adsl" {
- value 94;
- description
- "Asymmetric Digital Subscriber Loop";
- }
- enum "radsl" {
- value 95;
- description
- "Rate-Adapt. Digital Subscriber Loop";
- }
- enum "sdsl" {
- value 96;
- description
- "Symmetric Digital Subscriber Loop";
- }
- enum "vdsl" {
- value 97;
- description
- "Very H-Speed Digital Subscrib. Loop";
- }
- enum "iso88025CRFPInt" {
- value 98;
- description
- "ISO 802.5 CRFP";
- }
- enum "myrinet" {
- value 99;
- description
- "Myricom Myrinet";
- }
- enum "voiceEM" {
- value 100;
- description
- "voice recEive and transMit";
- }
- enum "voiceFXO" {
- value 101;
- description
- "voice Foreign Exchange Office";
- }
- enum "voiceFXS" {
- value 102;
- description
- "voice Foreign Exchange Station";
- }
- enum "voiceEncap" {
- value 103;
- description
- "voice encapsulation";
- }
- enum "voiceOverIp" {
- value 104;
- description
- "voice over IP encapsulation";
- }
- enum "atmDxi" {
- value 105;
- description
- "ATM DXI";
- }
- enum "atmFuni" {
- value 106;
- description
- "ATM FUNI";
- }
- enum "atmIma" {
- value 107;
- description
- "ATM IMA";
- }
- enum "pppMultilinkBundle" {
- value 108;
- description
- "PPP Multilink Bundle";
- }
- enum "ipOverCdlc" {
- value 109;
- description
- "IBM ipOverCdlc";
- }
- enum "ipOverClaw" {
- value 110;
- description
- "IBM Common Link Access to Workstn";
- }
- enum "stackToStack" {
- value 111;
- description
- "IBM stackToStack";
- }
- enum "virtualIpAddress" {
- value 112;
- description
- "IBM VIPA";
- }
- enum "mpc" {
- value 113;
- description
- "IBM multi-protocol channel support";
- }
- enum "ipOverAtm" {
- value 114;
- description
- "IBM ipOverAtm";
- reference
- "RFC 2320 - Definitions of Managed Objects for Classical IP
- and ARP Over ATM Using SMIv2 (IPOA-MIB)";
- }
- enum "iso88025Fiber" {
- value 115;
- description
- "ISO 802.5j Fiber Token Ring";
- }
- enum "tdlc" {
- value 116;
- description
- "IBM twinaxial data link control";
- }
- enum "gigabitEthernet" {
- value 117;
- status deprecated;
- description
- "Obsoleted via RFC3635
- ethernetCsmacd(6) should be used instead";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "hdlc" {
- value 118;
- description
- "HDLC";
- }
- enum "lapf" {
- value 119;
- description
- "LAP F";
- }
- enum "v37" {
- value 120;
- description
- "V.37";
- }
- enum "x25mlp" {
- value 121;
- description
- "Multi-Link Protocol";
- }
- enum "x25huntGroup" {
- value 122;
- description
- "X25 Hunt Group";
- }
- enum "transpHdlc" {
- value 123;
- description
- "Transp HDLC";
- }
- enum "interleave" {
- value 124;
- description
- "Interleave channel";
- }
- enum "fast" {
- value 125;
- description
- "Fast channel";
- }
- enum "ip" {
- value 126;
- description
- "IP (for APPN HPR in IP networks)";
- }
- enum "docsCableMaclayer" {
- value 127;
- description
- "CATV Mac Layer";
- }
- enum "docsCableDownstream" {
- value 128;
- description
- "CATV Downstream interface";
- }
- enum "docsCableUpstream" {
- value 129;
- description
- "CATV Upstream interface";
- }
- enum "a12MppSwitch" {
- value 130;
- description
- "Avalon Parallel Processor";
- }
- enum "tunnel" {
- value 131;
- description
- "Encapsulation interface";
- }
- enum "coffee" {
- value 132;
- description
- "coffee pot";
- reference
- "RFC 2325 - Coffee MIB";
- }
- enum "ces" {
- value 133;
- description
- "Circuit Emulation Service";
- }
- enum "atmSubInterface" {
- value 134;
- description
- "ATM Sub Interface";
- }
- enum "l2vlan" {
- value 135;
- description
- "Layer 2 Virtual LAN using 802.1Q";
- }
- enum "l3ipvlan" {
- value 136;
- description
- "Layer 3 Virtual LAN using IP";
- }
- enum "l3ipxvlan" {
- value 137;
- description
- "Layer 3 Virtual LAN using IPX";
- }
- enum "digitalPowerline" {
- value 138;
- description
- "IP over Power Lines";
- }
- enum "mediaMailOverIp" {
- value 139;
- description
- "Multimedia Mail over IP";
- }
- enum "dtm" {
- value 140;
- description
- "Dynamic syncronous Transfer Mode";
- }
- enum "dcn" {
- value 141;
- description
- "Data Communications Network";
- }
- enum "ipForward" {
- value 142;
- description
- "IP Forwarding Interface";
- }
- enum "msdsl" {
- value 143;
- description
- "Multi-rate Symmetric DSL";
- }
- enum "ieee1394" {
- value 144;
- description
- "IEEE1394 High Performance Serial Bus";
- }
- enum "if-gsn" {
- value 145;
- description
- "HIPPI-6400";
- }
- enum "dvbRccMacLayer" {
- value 146;
- description
- "DVB-RCC MAC Layer";
- }
- enum "dvbRccDownstream" {
- value 147;
- description
- "DVB-RCC Downstream Channel";
- }
- enum "dvbRccUpstream" {
- value 148;
- description
- "DVB-RCC Upstream Channel";
- }
- enum "atmVirtual" {
- value 149;
- description
- "ATM Virtual Interface";
- }
- enum "mplsTunnel" {
- value 150;
- description
- "MPLS Tunnel Virtual Interface";
- }
- enum "srp" {
- value 151;
- description
- "Spatial Reuse Protocol ";
- }
- enum "voiceOverAtm" {
- value 152;
- description
- "Voice Over ATM";
- }
- enum "voiceOverFrameRelay" {
- value 153;
- description
- "Voice Over Frame Relay";
- }
- enum "idsl" {
- value 154;
- description
- "Digital Subscriber Loop over ISDN";
- }
- enum "compositeLink" {
- value 155;
- description
- "Avici Composite Link Interface";
- }
- enum "ss7SigLink" {
- value 156;
- description
- "SS7 Signaling Link";
- }
- enum "propWirelessP2P" {
- value 157;
- description
- "Prop. P2P wireless interface";
- }
- enum "frForward" {
- value 158;
- description
- "Frame Forward Interface";
- }
- enum "rfc1483" {
- value 159;
- description
- "Multiprotocol over ATM AAL5";
- reference
- "RFC 1483 - Multiprotocol Encapsulation over ATM
- Adaptation Layer 5";
- }
- enum "usb" {
- value 160;
- description
- "USB Interface";
- }
- enum "ieee8023adLag" {
- value 161;
- description
- "IEEE 802.3ad Link Aggregate";
- }
- enum "bgppolicyaccounting" {
- value 162;
- description
- "BGP Policy Accounting";
- }
- enum "frf16MfrBundle" {
- value 163;
- description
- "FRF .16 Multilink Frame Relay";
- }
- enum "h323Gatekeeper" {
- value 164;
- description
- "H323 Gatekeeper";
- }
- enum "h323Proxy" {
- value 165;
- description
- "H323 Voice and Video Proxy";
- }
- enum "mpls" {
- value 166;
- description
- "MPLS";
- }
- enum "mfSigLink" {
- value 167;
- description
- "Multi-frequency signaling link";
- }
- enum "hdsl2" {
- value 168;
- description
- "High Bit-Rate DSL - 2nd generation";
- }
- enum "shdsl" {
- value 169;
- description
- "Multirate HDSL2";
- }
- enum "ds1FDL" {
- value 170;
- description
- "Facility Data Link 4Kbps on a DS1";
- }
- enum "pos" {
- value 171;
- description
- "Packet over SONET/SDH Interface";
- }
- enum "dvbAsiIn" {
- value 172;
- description
- "DVB-ASI Input";
- }
- enum "dvbAsiOut" {
- value 173;
- description
- "DVB-ASI Output";
- }
- enum "plc" {
- value 174;
- description
- "Power Line Communtications";
- }
- enum "nfas" {
- value 175;
- description
- "Non Facility Associated Signaling";
- }
- enum "tr008" {
- value 176;
- description
- "TR008";
- }
- enum "gr303RDT" {
- value 177;
- description
- "Remote Digital Terminal";
- }
- enum "gr303IDT" {
- value 178;
- description
- "Integrated Digital Terminal";
- }
- enum "isup" {
- value 179;
- description
- "ISUP";
- }
- enum "propDocsWirelessMaclayer" {
- value 180;
- description
- "Cisco proprietary Maclayer";
- }
- enum "propDocsWirelessDownstream" {
- value 181;
- description
- "Cisco proprietary Downstream";
- }
- enum "propDocsWirelessUpstream" {
- value 182;
- description
- "Cisco proprietary Upstream";
- }
- enum "hiperlan2" {
- value 183;
- description
- "HIPERLAN Type 2 Radio Interface";
- }
- enum "propBWAp2Mp" {
- value 184;
- description
- "PropBroadbandWirelessAccesspt2multipt use of this value
- for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f
- is deprecated and ieee80216WMAN(237) should be used
- instead.";
- }
- enum "sonetOverheadChannel" {
- value 185;
- description
- "SONET Overhead Channel";
- }
- enum "digitalWrapperOverheadChannel" {
- value 186;
- description
- "Digital Wrapper";
- }
- enum "aal2" {
- value 187;
- description
- "ATM adaptation layer 2";
- }
- enum "radioMAC" {
- value 188;
- description
- "MAC layer over radio links";
- }
- enum "atmRadio" {
- value 189;
- description
- "ATM over radio links";
- }
- enum "imt" {
- value 190;
- description
- "Inter Machine Trunks";
- }
- enum "mvl" {
- value 191;
- description
- "Multiple Virtual Lines DSL";
- }
- enum "reachDSL" {
- value 192;
- description
- "Long Reach DSL";
- }
- enum "frDlciEndPt" {
- value 193;
- description
- "Frame Relay DLCI End Point";
- }
- enum "atmVciEndPt" {
- value 194;
- description
- "ATM VCI End Point";
- }
- enum "opticalChannel" {
- value 195;
- description
- "Optical Channel";
- }
- enum "opticalTransport" {
- value 196;
- description
- "Optical Transport";
- }
- enum "propAtm" {
- value 197;
- description
- "Proprietary ATM";
- }
- enum "voiceOverCable" {
- value 198;
- description
- "Voice Over Cable Interface";
- }
- enum "infiniband" {
- value 199;
- description
- "Infiniband";
- }
- enum "teLink" {
- value 200;
- description
- "TE Link";
- }
- enum "q2931" {
- value 201;
- description
- "Q.2931";
- }
- enum "virtualTg" {
- value 202;
- description
- "Virtual Trunk Group";
- }
- enum "sipTg" {
- value 203;
- description
- "SIP Trunk Group";
- }
- enum "sipSig" {
- value 204;
- description
- "SIP Signaling";
- }
- enum "docsCableUpstreamChannel" {
- value 205;
- description
- "CATV Upstream Channel";
- }
- enum "econet" {
- value 206;
- description
- "Acorn Econet";
- }
- enum "pon155" {
- value 207;
- description
- "FSAN 155Mb Symetrical PON interface";
- }
- enum "pon622" {
- value 208;
- description
- "FSAN622Mb Symetrical PON interface";
- }
- enum "bridge" {
- value 209;
- description
- "Transparent bridge interface";
- }
- enum "linegroup" {
- value 210;
- description
- "Interface common to multiple lines";
- }
- enum "voiceEMFGD" {
- value 211;
- description
- "voice E&M Feature Group D";
- }
- enum "voiceFGDEANA" {
- value 212;
- description
- "voice FGD Exchange Access North American";
- }
- enum "voiceDID" {
- value 213;
- description
- "voice Direct Inward Dialing";
- }
- enum "mpegTransport" {
- value 214;
- description
- "MPEG transport interface";
- }
- enum "sixToFour" {
- value 215;
- status deprecated;
- description
- "6to4 interface (DEPRECATED)";
- reference
- "RFC 4087 - IP Tunnel MIB";
- }
- enum "gtp" {
- value 216;
- description
- "GTP (GPRS Tunneling Protocol)";
- }
- enum "pdnEtherLoop1" {
- value 217;
- description
- "Paradyne EtherLoop 1";
- }
- enum "pdnEtherLoop2" {
- value 218;
- description
- "Paradyne EtherLoop 2";
- }
- enum "opticalChannelGroup" {
- value 219;
- description
- "Optical Channel Group";
- }
- enum "homepna" {
- value 220;
- description
- "HomePNA ITU-T G.989";
- }
- enum "gfp" {
- value 221;
- description
- "Generic Framing Procedure (GFP)";
- }
- enum "ciscoISLvlan" {
- value 222;
- description
- "Layer 2 Virtual LAN using Cisco ISL";
- }
- enum "actelisMetaLOOP" {
- value 223;
- description
- "Acteleis proprietary MetaLOOP High Speed Link";
- }
- enum "fcipLink" {
- value 224;
- description
- "FCIP Link";
- }
- enum "rpr" {
- value 225;
- description
- "Resilient Packet Ring Interface Type";
- }
- enum "qam" {
- value 226;
- description
- "RF Qam Interface";
- }
- enum "lmp" {
- value 227;
- description
- "Link Management Protocol";
- reference
- "RFC 4327 - Link Management Protocol (LMP) Management
- Information Base (MIB)";
- }
- enum "cblVectaStar" {
- value 228;
- description
- "Cambridge Broadband Networks Limited VectaStar";
- }
- enum "docsCableMCmtsDownstream" {
- value 229;
- description
- "CATV Modular CMTS Downstream Interface";
- }
- enum "adsl2" {
- value 230;
- status deprecated;
- description
- "Asymmetric Digital Subscriber Loop Version 2
- (DEPRECATED/OBSOLETED - please use adsl2plus(238)
- instead)";
- reference
- "RFC 4706 - Definitions of Managed Objects for Asymmetric
- Digital Subscriber Line 2 (ADSL2)";
- }
- enum "macSecControlledIF" {
- value 231;
- description
- "MACSecControlled";
- }
- enum "macSecUncontrolledIF" {
- value 232;
- description
- "MACSecUncontrolled";
- }
- enum "aviciOpticalEther" {
- value 233;
- description
- "Avici Optical Ethernet Aggregate";
- }
- enum "atmbond" {
- value 234;
- description
- "atmbond";
- }
- enum "voiceFGDOS" {
- value 235;
- description
- "voice FGD Operator Services";
- }
- enum "mocaVersion1" {
- value 236;
- description
- "MultiMedia over Coax Alliance (MoCA) Interface
- as documented in information provided privately to IANA";
- }
- enum "ieee80216WMAN" {
- value 237;
- description
- "IEEE 802.16 WMAN interface";
- }
- enum "adsl2plus" {
- value 238;
- description
- "Asymmetric Digital Subscriber Loop Version 2,
- Version 2 Plus and all variants";
- }
- enum "dvbRcsMacLayer" {
- value 239;
- description
- "DVB-RCS MAC Layer";
- reference
- "RFC 5728 - The SatLabs Group DVB-RCS MIB";
- }
- enum "dvbTdm" {
- value 240;
- description
- "DVB Satellite TDM";
- reference
- "RFC 5728 - The SatLabs Group DVB-RCS MIB";
- }
- enum "dvbRcsTdma" {
- value 241;
- description
- "DVB-RCS TDMA";
- reference
- "RFC 5728 - The SatLabs Group DVB-RCS MIB";
- }
- enum "x86Laps" {
- value 242;
- description
- "LAPS based on ITU-T X.86/Y.1323";
- }
- enum "wwanPP" {
- value 243;
- description
- "3GPP WWAN";
- }
- enum "wwanPP2" {
- value 244;
- description
- "3GPP2 WWAN";
- }
- enum "voiceEBS" {
- value 245;
- description
- "voice P-phone EBS physical interface";
- }
- enum "ifPwType" {
- value 246;
- description
- "Pseudowire interface type";
- reference
- "RFC 5601 - Pseudowire (PW) Management Information Base";
- }
- enum "ilan" {
- value 247;
- description
- "Internal LAN on a bridge per IEEE 802.1ap";
- }
- enum "pip" {
- value 248;
- description
- "Provider Instance Port on a bridge per IEEE 802.1ah PBB";
- }
- enum "aluELP" {
- value 249;
- description
- "Alcatel-Lucent Ethernet Link Protection";
- }
- enum "gpon" {
- value 250;
- description
- "Gigabit-capable passive optical networks (G-PON) as per
- ITU-T G.948";
- }
- enum "vdsl2" {
- value 251;
- description
- "Very high speed digital subscriber line Version 2
- (as per ITU-T Recommendation G.993.2)";
- reference
- "RFC 5650 - Definitions of Managed Objects for Very High
- Speed Digital Subscriber Line 2 (VDSL2)";
- }
- enum "capwapDot11Profile" {
- value 252;
- description
- "WLAN Profile Interface";
- reference
- "RFC 5834 - Control and Provisioning of Wireless Access
- Points (CAPWAP) Protocol Binding MIB for
- IEEE 802.11";
- }
- enum "capwapDot11Bss" {
- value 253;
- description
- "WLAN BSS Interface";
- reference
- "RFC 5834 - Control and Provisioning of Wireless Access
- Points (CAPWAP) Protocol Binding MIB for
- IEEE 802.11";
- }
- enum "capwapWtpVirtualRadio" {
- value 254;
- description
- "WTP Virtual Radio Interface";
- reference
- "RFC 5833 - Control and Provisioning of Wireless Access
- Points (CAPWAP) Protocol Base MIB";
- }
- enum "bits" {
- value 255;
- description
- "bitsport";
- }
- enum "docsCableUpstreamRfPort" {
- value 256;
- description
- "DOCSIS CATV Upstream RF Port";
- }
- enum "cableDownstreamRfPort" {
- value 257;
- description
- "CATV downstream RF port";
- }
- enum "vmwareVirtualNic" {
- value 258;
- description
- "VMware Virtual Network Interface";
- }
- enum "ieee802154" {
- value 259;
- description
- "IEEE 802.15.4 WPAN interface";
- reference
- "IEEE 802.15.4-2006";
- }
- enum "otnOdu" {
- value 260;
- description
- "OTN Optical Data Unit";
- }
- enum "otnOtu" {
- value 261;
- description
- "OTN Optical channel Transport Unit";
- }
- enum "ifVfiType" {
- value 262;
- description
- "VPLS Forwarding Instance Interface Type";
- }
- enum "g9981" {
- value 263;
- description
- "G.998.1 bonded interface";
- }
- enum "g9982" {
- value 264;
- description
- "G.998.2 bonded interface";
- }
- enum "g9983" {
- value 265;
- description
- "G.998.3 bonded interface";
- }
- enum "aluEpon" {
- value 266;
- description
- "Ethernet Passive Optical Networks (E-PON)";
- }
- enum "aluEponOnu" {
- value 267;
- description
- "EPON Optical Network Unit";
- }
- enum "aluEponPhysicalUni" {
- value 268;
- description
- "EPON physical User to Network interface";
- }
- enum "aluEponLogicalLink" {
- value 269;
- description
- "The emulation of a point-to-point link over the EPON
- layer";
- }
- enum "aluGponOnu" {
- value 270;
- description
- "GPON Optical Network Unit";
- reference
- "ITU-T G.984.2";
- }
- enum "aluGponPhysicalUni" {
- value 271;
- description
- "GPON physical User to Network interface";
- reference
- "ITU-T G.984.2";
- }
- enum "vmwareNicTeam" {
- value 272;
- description
- "VMware NIC Team";
- }
- }
- description
- "This data type is used as the syntax of the 'type'
- leaf in the 'interface' list in the YANG module
- ietf-interface.
-
- The definition of this typedef with the
- addition of newly assigned values is published
- periodically by the IANA, in either the Assigned
- Numbers RFC, or some derivative of it specific to
- Internet Network Management number assignments. (The
- latest arrangements can be obtained by contacting the
- IANA.)
-
- Requests for new values should be made to IANA via
- email (iana&iana.org).";
- reference
- "ifType definitions registry.
- <http://www.iana.org/assignments/smi-numbers>";
- }
-}
\ No newline at end of file
+++ /dev/null
- module ietf-inet-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
- prefix "inet";
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Partain
- <mailto:david.partain@ericsson.com>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types for Internet addresses and related things.
-
- Copyright (c) 2010 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, is permitted pursuant to, and subject to the license
- terms contained in, the Simplified BSD License set forth in Section
- 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6021; see
- the RFC itself for full legal notices.";
-
- revision 2010-09-24 {
- description
- "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
- }
-
- /*** collection of protocol field related types ***/
-
- typedef ip-version {
- type enumeration {
- enum unknown {
- value "0";
- description
- "An unknown or unspecified version of the Internet protocol.";
- }
- enum ipv4 {
- value "1";
- description
- "The IPv4 protocol as defined in RFC 791.";
- }
- enum ipv6 {
- value "2";
- description
- "The IPv6 protocol as defined in RFC 2460.";
- }
- }
- description
- "This value represents the version of the IP protocol.
-
- In the value set and its semantics, this type is equivalent
- to the InetVersion textual convention of the SMIv2.";
- reference
- "RFC 791: Internet Protocol
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- typedef dscp {
- type uint8 {
- range "0..63";
- }
- description
- "The dscp type represents a Differentiated Services Code-Point
- that may be used for marking packets in a traffic stream.
-
- In the value set and its semantics, this type is equivalent
- to the Dscp textual convention of the SMIv2.";
- reference
- "RFC 3289: Management Information Base for the Differentiated
- Services Architecture
- RFC 2474: Definition of the Differentiated Services Field
- (DS Field) in the IPv4 and IPv6 Headers
- RFC 2780: IANA Allocation Guidelines For Values In
- the Internet Protocol and Related Headers";
- }
-
- typedef ipv6-flow-label {
- type uint32 {
- range "0..1048575";
- }
- description
- "The flow-label type represents flow identifier or Flow Label
- in an IPv6 packet header that may be used to discriminate
- traffic flows.
-
- In the value set and its semantics, this type is equivalent
- to the IPv6FlowLabel textual convention of the SMIv2.";
- reference
- "RFC 3595: Textual Conventions for IPv6 Flow Label
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
- }
-
- typedef port-number {
- type uint16 {
- range "0..65535";
- }
- description
- "The port-number type represents a 16-bit port number of an
- Internet transport layer protocol such as UDP, TCP, DCCP, or
- SCTP. Port numbers are assigned by IANA. A current list of
- all assignments is available from <http://www.iana.org/>.
-
- Note that the port number value zero is reserved by IANA. In
- situations where the value zero does not make sense, it can
- be excluded by subtyping the port-number type.
-
- In the value set and its semantics, this type is equivalent
- to the InetPortNumber textual convention of the SMIv2.";
- reference
- "RFC 768: User Datagram Protocol
- RFC 793: Transmission Control Protocol
- RFC 4960: Stream Control Transmission Protocol
- RFC 4340: Datagram Congestion Control Protocol (DCCP)
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- /*** collection of autonomous system related types ***/
-
- typedef as-number {
- type uint32;
- description
- "The as-number type represents autonomous system numbers
- which identify an Autonomous System (AS). An AS is a set
- of routers under a single technical administration, using
- an interior gateway protocol and common metrics to route
- packets within the AS, and using an exterior gateway
- protocol to route packets to other ASs'. IANA maintains
- the AS number space and has delegated large parts to the
- regional registries.
-
- Autonomous system numbers were originally limited to 16
- bits. BGP extensions have enlarged the autonomous system
- number space to 32 bits. This type therefore uses an uint32
- base type without a range restriction in order to support
- a larger autonomous system number space.
-
- In the value set and its semantics, this type is equivalent
- to the InetAutonomousSystemNumber textual convention of
- the SMIv2.";
- reference
- "RFC 1930: Guidelines for creation, selection, and registration
- of an Autonomous System (AS)
- RFC 4271: A Border Gateway Protocol 4 (BGP-4)
- RFC 4893: BGP Support for Four-octet AS Number Space
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- /*** collection of IP address and hostname related types ***/
-
- typedef ip-address {
- type union {
- type inet:ipv4-address;
- type inet:ipv6-address;
- }
- description
- "The ip-address type represents an IP address and is IP
- version neutral. The format of the textual representations
- implies the IP version.";
- }
-
- typedef ipv4-address {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '(%[\p{N}\p{L}]+)?';
- }
- description
- "The ipv4-address type represents an IPv4 address in
- dotted-quad notation. The IPv4 address may include a zone
- index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
- The canonical format for the zone index is the numerical
- format";
- }
-
- typedef ipv6-address {
- type string {
- pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(%[\p{N}\p{L}]+)?';
- pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(%.+)?';
- }
- description
- "The ipv6-address type represents an IPv6 address in full,
- mixed, shortened, and shortened-mixed notation. The IPv6
- address may include a zone index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
- The canonical format of IPv6 addresses uses the compressed
- format described in RFC 4291, Section 2.2, item 2 with the
- following additional rules: the :: substitution must be
- applied to the longest sequence of all-zero 16-bit chunks
- in an IPv6 address. If there is a tie, the first sequence
- of all-zero 16-bit chunks is replaced by ::. Single
- all-zero 16-bit chunks are not compressed. The canonical
- format uses lowercase characters and leading zeros are
- not allowed. The canonical format for the zone index is
- the numerical format as described in RFC 4007, Section
- 11.2.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture
- RFC 4007: IPv6 Scoped Address Architecture
- RFC 5952: A Recommendation for IPv6 Address Text Representation";
- }
-
- typedef ip-prefix {
- type union {
- type inet:ipv4-prefix;
- type inet:ipv6-prefix;
- }
- description
- "The ip-prefix type represents an IP prefix and is IP
- version neutral. The format of the textual representations
- implies the IP version.";
- }
-
- typedef ipv4-prefix {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
- }
- description
- "The ipv4-prefix type represents an IPv4 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal to 32.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The canonical format of an IPv4 prefix has all bits of
- the IPv4 address set to zero that are not part of the
- IPv4 prefix.";
- }
-
- typedef ipv6-prefix {
- type string {
- pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
- pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(/.+)';
- }
- description
- "The ipv6-prefix type represents an IPv6 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal 128.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The IPv6 address should have all bits that do not belong
- to the prefix set to zero.
-
- The canonical format of an IPv6 prefix has all bits of
- the IPv6 address set to zero that are not part of the
- IPv6 prefix. Furthermore, IPv6 address is represented
- in the compressed format described in RFC 4291, Section
- 2.2, item 2 with the following additional rules: the ::
- substitution must be applied to the longest sequence of
- all-zero 16-bit chunks in an IPv6 address. If there is
- a tie, the first sequence of all-zero 16-bit chunks is
- replaced by ::. Single all-zero 16-bit chunks are not
- compressed. The canonical format uses lowercase
- characters and leading zeros are not allowed.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture";
- }
-
- /*** collection of domain name and URI types ***/
-
- typedef domain-name {
- type string {
- pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
- + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
- + '|\.';
- length "1..253";
- }
- description
- "The domain-name type represents a DNS domain name. The
- name SHOULD be fully qualified whenever possible.
-
- Internet domain names are only loosely specified. Section
- 3.5 of RFC 1034 recommends a syntax (modified in Section
- 2.1 of RFC 1123). The pattern above is intended to allow
- for current practice in domain name use, and some possible
- future expansion. It is designed to hold various types of
- domain names, including names used for A or AAAA records
- (host names) and other records, such as SRV records. Note
- that Internet host names have a stricter syntax (described
- in RFC 952) than the DNS recommendations in RFCs 1034 and
- 1123, and that systems that want to store host names in
- schema nodes using the domain-name type are recommended to
- adhere to this stricter standard to ensure interoperability.
-
- The encoding of DNS names in the DNS protocol is limited
- to 255 characters. Since the encoding consists of labels
- prefixed by a length bytes and there is a trailing NULL
- byte, only 253 characters can appear in the textual dotted
- notation.
-
- The description clause of schema nodes using the domain-name
- type MUST describe when and how these names are resolved to
- IP addresses. Note that the resolution of a domain-name value
- may require to query multiple DNS records (e.g., A for IPv4
- and AAAA for IPv6). The order of the resolution process and
- which DNS record takes precedence can either be defined
- explicitely or it may depend on the configuration of the
- resolver.
-
- Domain-name values use the US-ASCII encoding. Their canonical
- format uses lowercase US-ASCII characters. Internationalized
- domain names MUST be encoded in punycode as described in RFC
- 3492";
- reference
- "RFC 952: DoD Internet Host Table Specification
- RFC 1034: Domain Names - Concepts and Facilities
- RFC 1123: Requirements for Internet Hosts -- Application
- and Support
- RFC 2782: A DNS RR for specifying the location of services
- (DNS SRV)
- RFC 3492: Punycode: A Bootstring encoding of Unicode for
- Internationalized Domain Names in Applications
- (IDNA)
- RFC 5891: Internationalizing Domain Names in Applications
- (IDNA): Protocol";
- }
-
- typedef host {
- type union {
- type inet:ip-address;
- type inet:domain-name;
- }
- description
- "The host type represents either an IP address or a DNS
- domain name.";
- }
-
- typedef uri {
- type string;
- description
- "The uri type represents a Uniform Resource Identifier
- (URI) as defined by STD 66.
-
- Objects using the uri type MUST be in US-ASCII encoding,
- and MUST be normalized as described by RFC 3986 Sections
- 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
- percent-encoding is removed, and all case-insensitive
- characters are set to lowercase except for hexadecimal
- digits, which are normalized to uppercase as described in
- Section 6.2.2.1.
-
- The purpose of this normalization is to help provide
- unique URIs. Note that this normalization is not
- sufficient to provide uniqueness. Two URIs that are
- textually distinct after this normalization may still be
- equivalent.
-
- Objects using the uri type may restrict the schemes that
- they permit. For example, 'data:' and 'urn:' schemes
- might not be appropriate.
-
- A zero-length URI is not a valid URI. This can be used to
- express 'URI absent' where required.
-
- In the value set and its semantics, this type is equivalent
- to the Uri SMIv2 textual convention defined in RFC 5017.";
- reference
- "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
- RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
- Group: Uniform Resource Identifiers (URIs), URLs,
- and Uniform Resource Names (URNs): Clarifications
- and Recommendations
- RFC 5017: MIB Textual Conventions for Uniform Resource
- Identifiers (URIs)";
- }
-
- }
namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
prefix if;
- import ietf-yang-types {
- prefix yang;
- }
- import iana-if-type {
- prefix ianaift;
- }
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- WG Chair: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>
-
- Editor: Martin Bjorklund
- <mailto:mbj@tail-f.com>";
-
- description
- "This module contains a collection of YANG definitions for
- managing network interfaces.
-
- Copyright (c) 2012 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC XXXX; see
- the RFC itself for full legal notices.";
-
- // RFC Ed.: replace XXXX with actual RFC number and remove this
- // note.
-
- // RFC Ed.: update the date below with the date of RFC publication
- // and remove this note.
revision 2012-11-15 {
- description
- "Initial revision.";
- reference
- "RFC XXXX: A YANG Data Model for Interface Management";
}
- /* Typedefs */
-
typedef interface-ref {
type leafref {
path "/if:interfaces/if:interface/if:name";
}
- description
- "This type is used by data models that need to reference
- interfaces.";
- }
-
- /* Features */
-
- feature arbitrary-names {
- description
- "This feature indicates that the server allows interfaces to
- be named arbitrarily.";
}
- feature if-mib {
- description
- "This feature indicates that the server implements IF-MIB.";
- reference
- "RFC 2863: The Interfaces Group MIB";
- }
-
- /* Data nodes */
container interfaces {
- description
- "Interface parameters.";
list interface {
key "name";
unique "type location";
- description
- "The list of interfaces on the device.";
-
leaf name {
type string;
- description
- "The name of the interface.
-
- A device MAY restrict the allowed values for this leaf,
- possibly depending on the type and location.
-
- If the device allows arbitrarily named interfaces, the
- feature 'arbitrary-names' is advertised.
-
- This leaf MAY be mapped to ifName by an implementation.
- Such an implementation MAY restrict the allowed values for
- this leaf so that it matches the restrictions of ifName.
- If a NETCONF server that implements this restriction is
- sent a value that doesn't match the restriction, it MUST
- reply with an rpc-error with the error-tag
- 'invalid-value'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifName";
- }
-
- leaf description {
- type string;
- description
- "A textual description of the interface.
-
- This leaf MAY be mapped to ifAlias by an implementation.
- Such an implementation MAY restrict the allowed values for
- this leaf so that it matches the restrictions of ifAlias.
- If a NETCONF server that implements this restriction is
- sent a value that doesn't match the restriction, it MUST
- reply with an rpc-error with the error-tag
- 'invalid-value'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifAlias";
- }
-
- leaf type {
- type ianaift:iana-if-type;
- mandatory true;
- description
- "The type of the interface.
-
- When an interface entry is created, a server MAY
- initialize the type leaf with a valid value, e.g., if it
- is possible to derive the type from the name of the
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifType";
- }
-
- leaf location {
- type string;
- description
- "The device-specific location of the interface of a
- particular type. The format of the location string
- depends on the interface type and the device.
-
- If the interface's type represents a physical interface,
- this leaf MUST be set.
-
- When an interface entry is created, a server MAY
- initialize the location leaf with a valid value, e.g., if
- it is possible to derive the location from the name of
- the interface.";
- }
-
- leaf enabled {
- type boolean;
- default "true";
- description
- "The desired state of the interface.
-
- This leaf contains the configured, desired state of the
- interface. Systems that implement the IF-MIB use the
- value of this leaf to set IF-MIB.ifAdminStatus to 'up' or
- 'down' after an ifEntry has been initialized, as described
- in RFC 2863.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
- }
-
- leaf oper-status {
- type enumeration {
- enum up {
- value 1;
- description
- "Ready to pass packets.";
- }
- enum down {
- value 2;
- description
- "The interface does not pass any packets.";
- }
- enum testing {
- value 3;
- description
- "In some test mode. No operational packets can
- be passed.";
- }
- enum unknown {
- value 4;
- description
- "Status cannot be determined for some reason.";
- }
- enum dormant {
- value 5;
- description
- "Waiting for some external event.";
- }
- enum not-present {
- value 6;
- description
- "Some component is missing.";
- }
- enum lower-layer-down {
- value 7;
- description
- "Down due to state of lower-layer interface(s).";
- }
- }
- config false;
- description
- "The current operational state of the interface.
-
- If 'enabled' is 'false' then 'oper-status'
- should be 'down'. If 'enabled' is changed to 'true'
- then 'oper-status' should change to 'up' if the interface
- is ready to transmit and receive network traffic; it
- should change to 'dormant' if the interface is waiting for
- external actions (such as a serial line waiting for an
- incoming connection); it should remain in the 'down' state
- if and only if there is a fault that prevents it from
- going to the 'up' state; it should remain in the
- 'not-present' state if the interface has missing
- (typically, hardware) components.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOperStatus";
- }
-
- leaf last-change {
- type yang:date-and-time;
- config false;
- description
- "The time the interface entered its current operational
- state. If the current state was entered prior to the
- last re-initialization of the local network management
- subsystem, then this node is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifLastChange";
- }
-
- leaf if-index {
- if-feature if-mib;
- type int32 {
- range "1..2147483647";
- }
- config false;
- description
- "The ifIndex value for the ifEntry represented by this
- interface.
-
- Media-specific modules must specify how the type is
- mapped to entries in the ifTable.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifIndex";
- }
-
- leaf link-up-down-trap-enable {
- if-feature if-mib;
- type enumeration {
- enum enabled {
- value 1;
- }
- enum disabled {
- value 2;
- }
- }
- description
- "Indicates whether linkUp/linkDown SNMP notifications
- should be generated for this interface.
- If this node is not configured, the value 'enabled' is
- operationally used by the server for interfaces which do
- not operate on top of any other interface (i.e., there are
- no 'lower-layer-if' entries), and 'disabled' otherwise.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifLinkUpDownTrapEnable";
- }
-
- leaf phys-address {
- type yang:phys-address;
- config false;
- description
- "The interface's address at its protocol sub-layer. For
- example, for an 802.x interface, this object normally
- contains a MAC address. The interface's media-specific
- modules must define the bit and byte ordering and the
- format of the value of this object. For interfaces that do
- not have such an address (e.g., a serial line), this node
- is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifPhysAddress";
}
leaf-list higher-layer-if {
type interface-ref;
config false;
- description
- "A list of references to interfaces layered on top of this
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifStackTable";
- }
-
- leaf-list lower-layer-if {
- type interface-ref;
- config false;
- description
- "A list of references to interfaces layered underneath this
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifStackTable";
}
- leaf speed {
- type yang:gauge64;
- units "bits / second";
- config false;
- description
- "An estimate of the interface's current bandwidth in bits
- per second. For interfaces which do not vary in
- bandwidth or for those where no accurate estimation can
- be made, this node should contain the nominal bandwidth.
- For interfaces that has no concept of bandwidth, this
- node is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifSpeed, ifHighSpeed";
- }
-
- container statistics {
- config false;
- description
- "A collection of interface-related statistics objects.";
-
- leaf discontinuity-time {
- type yang:date-and-time;
- description
- "The time on the most recent occasion at which any one or
- more of this interface's counters suffered a
- discontinuity. If no such discontinuities have occurred
- since the last re-initialization of the local management
- subsystem, then this node contains the time the local
- management subsystem re-initialized itself.";
- }
-
- leaf in-octets {
- type yang:counter64;
- description
- "The total number of octets received on the interface,
- including framing characters.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCInOctets";
- }
- leaf in-unicast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, which were not addressed to a
- multicast or broadcast address at this sub-layer.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts";
- }
- leaf in-broadcast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, which were addressed to a broadcast
- address at this sub-layer.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCInBroadcastPkts";
- }
- leaf in-multicast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, which were addressed to a multicast
- address at this sub-layer. For a MAC layer protocol,
- this includes both Group and Functional addresses.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCInMulticastPkts";
- }
- leaf in-discards {
- type yang:counter32;
- description
- "The number of inbound packets which were chosen to be
- discarded even though no errors had been detected to
- prevent their being deliverable to a higher-layer
- protocol. One possible reason for discarding such a
- packet could be to free up buffer space.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInDiscards";
- }
- leaf in-errors {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of inbound
- packets that contained errors preventing them from being
- deliverable to a higher-layer protocol. For character-
- oriented or fixed-length interfaces, the number of
- inbound transmission units that contained errors
- preventing them from being deliverable to a higher-layer
- protocol.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInErrors";
- }
- leaf in-unknown-protos {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of packets
- received via the interface which were discarded because
- of an unknown or unsupported protocol. For
- character-oriented or fixed-length interfaces that
- support protocol multiplexing the number of transmission
- units received via the interface which were discarded
- because of an unknown or unsupported protocol. For any
- interface that does not support protocol multiplexing,
- this counter is not present.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos";
- }
-
- leaf out-octets {
- type yang:counter64;
- description
- "The total number of octets transmitted out of the
- interface, including framing characters.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCOutOctets";
- }
- leaf out-unicast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and which were not addressed
- to a multicast or broadcast address at this sub-layer,
- including those that were discarded or not sent.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts";
- }
- leaf out-broadcast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and which were addressed to a
- broadcast address at this sub-layer, including those
- that were discarded or not sent.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCOutBroadcastPkts";
- }
- leaf out-multicast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and which were addressed to a
- multicast address at this sub-layer, including those
- that were discarded or not sent. For a MAC layer
- protocol, this includes both Group and Functional
- addresses.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCOutMulticastPkts";
- }
- leaf out-discards {
- type yang:counter32;
- description
- "The number of outbound packets which were chosen to be
- discarded even though no errors had been detected to
- prevent their being transmitted. One possible reason
- for discarding such a packet could be to free up buffer
- space.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOutDiscards";
- }
- leaf out-errors {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of outbound
- packets that could not be transmitted because of errors.
- For character-oriented or fixed-length interfaces, the
- number of outbound transmission units that could not be
- transmitted because of errors.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOutErrors";
- }
- }
}
}
-}
\ No newline at end of file
+}
+++ /dev/null
- module ietf-yang-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
- prefix "yang";
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Partain
- <mailto:david.partain@ericsson.com>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types.
-
- Copyright (c) 2010 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, is permitted pursuant to, and subject to the license
- terms contained in, the Simplified BSD License set forth in Section
- 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6021; see
- the RFC itself for full legal notices.";
-
- revision 2010-09-24 {
- description
- "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
- }
-
- /*** collection of counter and gauge types ***/
-
- typedef counter32 {
- type uint32;
- description
- "The counter32 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter32 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter32 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter32.
-
- In the value set and its semantics, this type is equivalent
- to the Counter32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef zero-based-counter32 {
- type yang:counter32;
- default "0";
- description
- "The zero-based-counter32 type represents a counter32
- that has the defined 'initial' value zero.
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter32 textual convention of the SMIv2.";
- reference
- "RFC 4502: Remote Network Monitoring Management Information
- Base Version 2";
- }
-
- typedef counter64 {
- type uint64;
- description
- "The counter64 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter64 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter64 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter64.
-
- In the value set and its semantics, this type is equivalent
- to the Counter64 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef zero-based-counter64 {
- type yang:counter64;
- default "0";
- description
- "The zero-based-counter64 type represents a counter64 that
- has the defined 'initial' value zero.
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter64 textual convention of the SMIv2.";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
- }
-
- typedef gauge32 {
- type uint32;
- description
- "The gauge32 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^32-1 (4294967295 decimal), and
- the minimum value cannot be smaller than 0. The value of
- a gauge32 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge32 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the Gauge32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef gauge64 {
- type uint64;
- description
- "The gauge64 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^64-1 (18446744073709551615), and
- the minimum value cannot be smaller than 0. The value of
- a gauge64 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge64 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the CounterBasedGauge64 SMIv2 textual convention defined
- in RFC 2856";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
- }
-
- /*** collection of identifier related types ***/
-
- typedef object-identifier {
- type string {
- pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
- + '(\.(0|([1-9]\d*)))*';
- }
- description
- "The object-identifier type represents administratively
- assigned names in a registration-hierarchical-name tree.
-
- Values of this type are denoted as a sequence of numerical
- non-negative sub-identifier values. Each sub-identifier
- value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
- are separated by single dots and without any intermediate
- whitespace.
-
- The ASN.1 standard restricts the value space of the first
- sub-identifier to 0, 1, or 2. Furthermore, the value space
- of the second sub-identifier is restricted to the range
- 0 to 39 if the first sub-identifier is 0 or 1. Finally,
- the ASN.1 standard requires that an object identifier
- has always at least two sub-identifier. The pattern
- captures these restrictions.
-
- Although the number of sub-identifiers is not limited,
- module designers should realize that there may be
- implementations that stick with the SMIv2 limit of 128
- sub-identifiers.
-
- This type is a superset of the SMIv2 OBJECT IDENTIFIER type
- since it is not restricted to 128 sub-identifiers. Hence,
- this type SHOULD NOT be used to represent the SMIv2 OBJECT
- IDENTIFIER type, the object-identifier-128 type SHOULD be
- used instead.";
- reference
- "ISO9834-1: Information technology -- Open Systems
- Interconnection -- Procedures for the operation of OSI
- Registration Authorities: General procedures and top
- arcs of the ASN.1 Object Identifier tree";
- }
-
-
-
-
- typedef object-identifier-128 {
- type object-identifier {
- pattern '\d*(\.\d*){1,127}';
- }
- description
- "This type represents object-identifiers restricted to 128
- sub-identifiers.
-
- In the value set and its semantics, this type is equivalent
- to the OBJECT IDENTIFIER type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- /*** collection of date and time related types ***/
-
- typedef date-and-time {
- type string {
- pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
- + '(Z|[\+\-]\d{2}:\d{2})';
- }
- description
- "The date-and-time type is a profile of the ISO 8601
- standard for representation of dates and times using the
- Gregorian calendar. The profile is defined by the
- date-time production in Section 5.6 of RFC 3339.
-
- The date-and-time type is compatible with the dateTime XML
- schema type with the following notable exceptions:
-
- (a) The date-and-time type does not allow negative years.
-
- (b) The date-and-time time-offset -00:00 indicates an unknown
- time zone (see RFC 3339) while -00:00 and +00:00 and Z all
- represent the same time zone in dateTime.
-
- (c) The canonical format (see below) of data-and-time values
- differs from the canonical format used by the dateTime XML
- schema type, which requires all times to be in UTC using the
- time-offset 'Z'.
-
- This type is not equivalent to the DateAndTime textual
- convention of the SMIv2 since RFC 3339 uses a different
- separator between full-date and full-time and provides
- higher resolution of time-secfrac.
-
- The canonical format for date-and-time values with a known time
- zone uses a numeric time zone offset that is calculated using
- the device's configured known offset to UTC time. A change of
- the device's offset to UTC time will cause date-and-time values
- to change accordingly. Such changes might happen periodically
- in case a server follows automatically daylight saving time
- (DST) time zone offset changes. The canonical format for
- date-and-time values with an unknown time zone (usually referring
- to the notion of local time) uses the time-offset -00:00.";
- reference
- "RFC 3339: Date and Time on the Internet: Timestamps
- RFC 2579: Textual Conventions for SMIv2
- XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
- }
-
- typedef timeticks {
- type uint32;
- description
- "The timeticks type represents a non-negative integer that
- represents the time, modulo 2^32 (4294967296 decimal), in
- hundredths of a second between two epochs. When a schema
- node is defined that uses this type, the description of
- the schema node identifies both of the reference epochs.
-
- In the value set and its semantics, this type is equivalent
- to the TimeTicks type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef timestamp {
- type yang:timeticks;
- description
- "The timestamp type represents the value of an associated
- timeticks schema node at which a specific occurrence happened.
- The specific occurrence must be defined in the description
- of any schema node defined using this type. When the specific
- occurrence occurred prior to the last time the associated
- timeticks attribute was zero, then the timestamp value is
- zero. Note that this requires all timestamp values to be
- reset to zero when the value of the associated timeticks
- attribute reaches 497+ days and wraps around to zero.
-
- The associated timeticks schema node must be specified
- in the description of any schema node using this type.
-
- In the value set and its semantics, this type is equivalent
- to the TimeStamp textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
- }
-
- /*** collection of generic address types ***/
-
- typedef phys-address {
- type string {
- pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
- }
- description
- "Represents media- or physical-level addresses represented
- as a sequence octets, each octet represented by two hexadecimal
- numbers. Octets are separated by colons. The canonical
- representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the PhysAddress textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
- }
-
- typedef mac-address {
- type string {
- pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
- }
- description
- "The mac-address type represents an IEEE 802 MAC address.
- The canonical representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the MacAddress textual convention of the SMIv2.";
- reference
- "IEEE 802: IEEE Standard for Local and Metropolitan Area
- Networks: Overview and Architecture
- RFC 2579: Textual Conventions for SMIv2";
- }
-
- /*** collection of XML specific types ***/
-
- typedef xpath1.0 {
- type string;
- description
- "This type represents an XPATH 1.0 expression.
-
- When a schema node is defined that uses this type, the
- description of the schema node MUST specify the XPath
- context in which the XPath expression is evaluated.";
- reference
- "XPATH: XML Path Language (XPath) Version 1.0";
- }
-
- }
\ No newline at end of file
namespace "urn:model:abstract:topology";
prefix "tp";
- import ietf-inet-types {
- prefix "inet";
- revision-date 2010-09-24;
- }
-
- organization "OPEN DAYLIGHT";
- contact "http://www.opendaylight.org/";
-
- description
- "This module contains the definitions of elements that creates network
- topology i.e. definition of network nodes and links. This module is not designed
- to be used solely for network representation. This module SHOULD be used as base
- module in defining the network topology.";
-
revision "2013-02-08" {
reference "http://www.opendaylight.org/";
}
topology-id for reason that the store could contain many topologies.";
leaf topology-id {
- type inet:uri;
+ type string;
description "It is presumed that datastore will contain many topologies.
To distinguish between topologies it is vital to have
UNIQUE topology identifier.";
key "node-id";
leaf node-id {
- type inet:uri;
+ type string;
description "The Topology identifier of network-node.";
}
key "link-id";
leaf link-id {
- type inet:uri;
+ type string;
description "";
}
namespace "urn:model:augment:abstract:topology";
prefix "atp";
- import ietf-inet-types {
- prefix "inet";
- revision-date 2010-09-24;
- }
-
import ietf-interfaces {
prefix "if";
revision-date 2012-11-15;
+++ /dev/null
-module iana-if-type {
- namespace "urn:ietf:params:xml:ns:yang:iana-if-type";
- prefix ianaift;
-
- organization "IANA";
- contact
- " Internet Assigned Numbers Authority
-
- Postal: ICANN
- 4676 Admiralty Way, Suite 330
- Marina del Rey, CA 90292
-
- Tel: +1 310 823 9358
- E-Mail: iana&iana.org";
- description
- "This YANG module defines the iana-if-type typedef, which
- contains YANG definitions for IANA-registered interface types.
-
- This YANG module is maintained by IANA, and reflects the
- 'ifType definitions' registry.
-
- The latest revision of this YANG module can be obtained from
- the IANA web site.
-
- Copyright (c) 2011 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC XXXX; see
- the RFC itself for full legal notices.";
- // RFC Ed.: replace XXXX with actual RFC number and remove this
- // note.
-
- // RFC Ed.: update the date below with the date of RFC publication
- // and remove this note.
- revision 2012-06-05 {
- description
- "Initial revision.";
- reference
- "RFC XXXX: TITLE";
- }
-
- typedef iana-if-type {
- type enumeration {
- enum "other" {
- value 1;
- description
- "None of the following";
- }
- enum "regular1822" {
- value 2;
- }
- enum "hdh1822" {
- value 3;
- }
- enum "ddnX25" {
- value 4;
- }
- enum "rfc877x25" {
- value 5;
- reference
- "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer";
- }
- enum "ethernetCsmacd" {
- value 6;
- description
- "For all ethernet-like interfaces, regardless of speed,
- as per RFC3635.";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "iso88023Csmacd" {
- value 7;
- status deprecated;
- description
- "Deprecated via RFC3635.
- Use ethernetCsmacd(6) instead.";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "iso88024TokenBus" {
- value 8;
- }
- enum "iso88025TokenRing" {
- value 9;
- }
- enum "iso88026Man" {
- value 10;
- }
- enum "starLan" {
- value 11;
- status deprecated;
- description
- "Deprecated via RFC3635.
- Use ethernetCsmacd(6) instead.";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "proteon10Mbit" {
- value 12;
- }
- enum "proteon80Mbit" {
- value 13;
- }
- enum "hyperchannel" {
- value 14;
- }
- enum "fddi" {
- value 15;
- reference
- "RFC 1512 - FDDI Management Information Base";
- }
- enum "lapb" {
- value 16;
- reference
- "RFC 1381 - SNMP MIB Extension for X.25 LAPB";
- }
- enum "sdlc" {
- value 17;
- }
- enum "ds1" {
- value 18;
- description
- "DS1-MIB";
- reference
- "RFC 4805 - Definitions of Managed Objects for the
- DS1, J1, E1, DS2, and E2 Interface Types";
- }
- enum "e1" {
- value 19;
- status obsolete;
- description
- "Obsolete see DS1-MIB";
- reference
- "RFC 4805 - Definitions of Managed Objects for the
- DS1, J1, E1, DS2, and E2 Interface Types";
- }
- enum "basicISDN" {
- value 20;
- description
- "see also RFC2127";
- }
- enum "primaryISDN" {
- value 21;
- }
- enum "propPointToPointSerial" {
- value 22;
- description
- "proprietary serial";
- }
- enum "ppp" {
- value 23;
- }
- enum "softwareLoopback" {
- value 24;
- }
- enum "eon" {
- value 25;
- description
- "CLNP over IP";
- }
- enum "ethernet3Mbit" {
- value 26;
- }
- enum "nsip" {
- value 27;
- description
- "XNS over IP";
- }
- enum "slip" {
- value 28;
- description
- "generic SLIP";
- }
- enum "ultra" {
- value 29;
- description
- "ULTRA technologies";
- }
- enum "ds3" {
- value 30;
- description
- "DS3-MIB";
- reference
- "RFC 3896 - Definitions of Managed Objects for the
- DS3/E3 Interface Type";
- }
- enum "sip" {
- value 31;
- description
- "SMDS, coffee";
- reference
- "RFC 1694 - Definitions of Managed Objects for SMDS
- Interfaces using SMIv2";
- }
- enum "frameRelay" {
- value 32;
- description
- "DTE only.";
- reference
- "RFC 2115 - Management Information Base for Frame Relay
- DTEs Using SMIv2";
- }
- enum "rs232" {
- value 33;
- reference
- "RFC 1659 - Definitions of Managed Objects for RS-232-like
- Hardware Devices using SMIv2";
- }
- enum "para" {
- value 34;
- description
- "parallel-port";
- reference
- "RFC 1660 - Definitions of Managed Objects for
- Parallel-printer-like Hardware Devices using
- SMIv2";
- }
- enum "arcnet" {
- value 35;
- description
- "arcnet";
- }
- enum "arcnetPlus" {
- value 36;
- description
- "arcnet plus";
- }
- enum "atm" {
- value 37;
- description
- "ATM cells";
- }
- enum "miox25" {
- value 38;
- reference
- "RFC 1461 - SNMP MIB extension for Multiprotocol
- Interconnect over X.25";
- }
- enum "sonet" {
- value 39;
- description
- "SONET or SDH";
- }
- enum "x25ple" {
- value 40;
- reference
- "RFC 2127 - ISDN Management Information Base using SMIv2";
- }
- enum "iso88022llc" {
- value 41;
- }
- enum "localTalk" {
- value 42;
- }
- enum "smdsDxi" {
- value 43;
- }
- enum "frameRelayService" {
- value 44;
- description
- "FRNETSERV-MIB";
- reference
- "RFC 2954 - Definitions of Managed Objects for Frame
- Relay Service";
- }
- enum "v35" {
- value 45;
- }
- enum "hssi" {
- value 46;
- }
- enum "hippi" {
- value 47;
- }
- enum "modem" {
- value 48;
- description
- "Generic modem";
- }
- enum "aal5" {
- value 49;
- description
- "AAL5 over ATM";
- }
- enum "sonetPath" {
- value 50;
- }
- enum "sonetVT" {
- value 51;
- }
- enum "smdsIcip" {
- value 52;
- description
- "SMDS InterCarrier Interface";
- }
- enum "propVirtual" {
- value 53;
- description
- "proprietary virtual/internal";
- reference
- "RFC 2863 - The Interfaces Group MIB";
- }
- enum "propMultiplexor" {
- value 54;
- description
- "proprietary multiplexing";
- reference
- "RFC 2863 - The Interfaces Group MIB";
- }
- enum "ieee80212" {
- value 55;
- description
- "100BaseVG";
- }
- enum "fibreChannel" {
- value 56;
- description
- "Fibre Channel";
- }
- enum "hippiInterface" {
- value 57;
- description
- "HIPPI interfaces";
- }
- enum "frameRelayInterconnect" {
- value 58;
- status obsolete;
- description
- "Obsolete use either
- frameRelay(32) or frameRelayService(44).";
- }
- enum "aflane8023" {
- value 59;
- description
- "ATM Emulated LAN for 802.3";
- }
- enum "aflane8025" {
- value 60;
- description
- "ATM Emulated LAN for 802.5";
- }
- enum "cctEmul" {
- value 61;
- description
- "ATM Emulated circuit";
- }
- enum "fastEther" {
- value 62;
- status deprecated;
- description
- "Obsoleted via RFC3635.
- ethernetCsmacd(6) should be used instead";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "isdn" {
- value 63;
- description
- "ISDN and X.25";
- reference
- "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN
- in the Packet Mode";
- }
- enum "v11" {
- value 64;
- description
- "CCITT V.11/X.21";
- }
- enum "v36" {
- value 65;
- description
- "CCITT V.36";
- }
- enum "g703at64k" {
- value 66;
- description
- "CCITT G703 at 64Kbps";
- }
- enum "g703at2mb" {
- value 67;
- status obsolete;
- description
- "Obsolete see DS1-MIB";
- }
- enum "qllc" {
- value 68;
- description
- "SNA QLLC";
- }
- enum "fastEtherFX" {
- value 69;
- status deprecated;
- description
- "Obsoleted via RFC3635
- ethernetCsmacd(6) should be used instead";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "channel" {
- value 70;
- description
- "channel";
- }
- enum "ieee80211" {
- value 71;
- description
- "radio spread spectrum";
- }
- enum "ibm370parChan" {
- value 72;
- description
- "IBM System 360/370 OEMI Channel";
- }
- enum "escon" {
- value 73;
- description
- "IBM Enterprise Systems Connection";
- }
- enum "dlsw" {
- value 74;
- description
- "Data Link Switching";
- }
- enum "isdns" {
- value 75;
- description
- "ISDN S/T interface";
- }
- enum "isdnu" {
- value 76;
- description
- "ISDN U interface";
- }
- enum "lapd" {
- value 77;
- description
- "Link Access Protocol D";
- }
- enum "ipSwitch" {
- value 78;
- description
- "IP Switching Objects";
- }
- enum "rsrb" {
- value 79;
- description
- "Remote Source Route Bridging";
- }
- enum "atmLogical" {
- value 80;
- description
- "ATM Logical Port";
- reference
- "RFC 3606 - Definitions of Supplemental Managed Objects
- for ATM Interface";
- }
- enum "ds0" {
- value 81;
- description
- "Digital Signal Level 0";
- reference
- "RFC 2494 - Definitions of Managed Objects for the DS0
- and DS0 Bundle Interface Type";
- }
- enum "ds0Bundle" {
- value 82;
- description
- "group of ds0s on the same ds1";
- reference
- "RFC 2494 - Definitions of Managed Objects for the DS0
- and DS0 Bundle Interface Type";
- }
- enum "bsc" {
- value 83;
- description
- "Bisynchronous Protocol";
- }
- enum "async" {
- value 84;
- description
- "Asynchronous Protocol";
- }
- enum "cnr" {
- value 85;
- description
- "Combat Net Radio";
- }
- enum "iso88025Dtr" {
- value 86;
- description
- "ISO 802.5r DTR";
- }
- enum "eplrs" {
- value 87;
- description
- "Ext Pos Loc Report Sys";
- }
- enum "arap" {
- value 88;
- description
- "Appletalk Remote Access Protocol";
- }
- enum "propCnls" {
- value 89;
- description
- "Proprietary Connectionless Protocol";
- }
- enum "hostPad" {
- value 90;
- description
- "CCITT-ITU X.29 PAD Protocol";
- }
- enum "termPad" {
- value 91;
- description
- "CCITT-ITU X.3 PAD Facility";
- }
- enum "frameRelayMPI" {
- value 92;
- description
- "Multiproto Interconnect over FR";
- }
- enum "x213" {
- value 93;
- description
- "CCITT-ITU X213";
- }
- enum "adsl" {
- value 94;
- description
- "Asymmetric Digital Subscriber Loop";
- }
- enum "radsl" {
- value 95;
- description
- "Rate-Adapt. Digital Subscriber Loop";
- }
- enum "sdsl" {
- value 96;
- description
- "Symmetric Digital Subscriber Loop";
- }
- enum "vdsl" {
- value 97;
- description
- "Very H-Speed Digital Subscrib. Loop";
- }
- enum "iso88025CRFPInt" {
- value 98;
- description
- "ISO 802.5 CRFP";
- }
- enum "myrinet" {
- value 99;
- description
- "Myricom Myrinet";
- }
- enum "voiceEM" {
- value 100;
- description
- "voice recEive and transMit";
- }
- enum "voiceFXO" {
- value 101;
- description
- "voice Foreign Exchange Office";
- }
- enum "voiceFXS" {
- value 102;
- description
- "voice Foreign Exchange Station";
- }
- enum "voiceEncap" {
- value 103;
- description
- "voice encapsulation";
- }
- enum "voiceOverIp" {
- value 104;
- description
- "voice over IP encapsulation";
- }
- enum "atmDxi" {
- value 105;
- description
- "ATM DXI";
- }
- enum "atmFuni" {
- value 106;
- description
- "ATM FUNI";
- }
- enum "atmIma" {
- value 107;
- description
- "ATM IMA";
- }
- enum "pppMultilinkBundle" {
- value 108;
- description
- "PPP Multilink Bundle";
- }
- enum "ipOverCdlc" {
- value 109;
- description
- "IBM ipOverCdlc";
- }
- enum "ipOverClaw" {
- value 110;
- description
- "IBM Common Link Access to Workstn";
- }
- enum "stackToStack" {
- value 111;
- description
- "IBM stackToStack";
- }
- enum "virtualIpAddress" {
- value 112;
- description
- "IBM VIPA";
- }
- enum "mpc" {
- value 113;
- description
- "IBM multi-protocol channel support";
- }
- enum "ipOverAtm" {
- value 114;
- description
- "IBM ipOverAtm";
- reference
- "RFC 2320 - Definitions of Managed Objects for Classical IP
- and ARP Over ATM Using SMIv2 (IPOA-MIB)";
- }
- enum "iso88025Fiber" {
- value 115;
- description
- "ISO 802.5j Fiber Token Ring";
- }
- enum "tdlc" {
- value 116;
- description
- "IBM twinaxial data link control";
- }
- enum "gigabitEthernet" {
- value 117;
- status deprecated;
- description
- "Obsoleted via RFC3635
- ethernetCsmacd(6) should be used instead";
- reference
- "RFC 3635 - Definitions of Managed Objects for the
- Ethernet-like Interface Types.";
- }
- enum "hdlc" {
- value 118;
- description
- "HDLC";
- }
- enum "lapf" {
- value 119;
- description
- "LAP F";
- }
- enum "v37" {
- value 120;
- description
- "V.37";
- }
- enum "x25mlp" {
- value 121;
- description
- "Multi-Link Protocol";
- }
- enum "x25huntGroup" {
- value 122;
- description
- "X25 Hunt Group";
- }
- enum "transpHdlc" {
- value 123;
- description
- "Transp HDLC";
- }
- enum "interleave" {
- value 124;
- description
- "Interleave channel";
- }
- enum "fast" {
- value 125;
- description
- "Fast channel";
- }
- enum "ip" {
- value 126;
- description
- "IP (for APPN HPR in IP networks)";
- }
- enum "docsCableMaclayer" {
- value 127;
- description
- "CATV Mac Layer";
- }
- enum "docsCableDownstream" {
- value 128;
- description
- "CATV Downstream interface";
- }
- enum "docsCableUpstream" {
- value 129;
- description
- "CATV Upstream interface";
- }
- enum "a12MppSwitch" {
- value 130;
- description
- "Avalon Parallel Processor";
- }
- enum "tunnel" {
- value 131;
- description
- "Encapsulation interface";
- }
- enum "coffee" {
- value 132;
- description
- "coffee pot";
- reference
- "RFC 2325 - Coffee MIB";
- }
- enum "ces" {
- value 133;
- description
- "Circuit Emulation Service";
- }
- enum "atmSubInterface" {
- value 134;
- description
- "ATM Sub Interface";
- }
- enum "l2vlan" {
- value 135;
- description
- "Layer 2 Virtual LAN using 802.1Q";
- }
- enum "l3ipvlan" {
- value 136;
- description
- "Layer 3 Virtual LAN using IP";
- }
- enum "l3ipxvlan" {
- value 137;
- description
- "Layer 3 Virtual LAN using IPX";
- }
- enum "digitalPowerline" {
- value 138;
- description
- "IP over Power Lines";
- }
- enum "mediaMailOverIp" {
- value 139;
- description
- "Multimedia Mail over IP";
- }
- enum "dtm" {
- value 140;
- description
- "Dynamic syncronous Transfer Mode";
- }
- enum "dcn" {
- value 141;
- description
- "Data Communications Network";
- }
- enum "ipForward" {
- value 142;
- description
- "IP Forwarding Interface";
- }
- enum "msdsl" {
- value 143;
- description
- "Multi-rate Symmetric DSL";
- }
- enum "ieee1394" {
- value 144;
- description
- "IEEE1394 High Performance Serial Bus";
- }
- enum "if-gsn" {
- value 145;
- description
- "HIPPI-6400";
- }
- enum "dvbRccMacLayer" {
- value 146;
- description
- "DVB-RCC MAC Layer";
- }
- enum "dvbRccDownstream" {
- value 147;
- description
- "DVB-RCC Downstream Channel";
- }
- enum "dvbRccUpstream" {
- value 148;
- description
- "DVB-RCC Upstream Channel";
- }
- enum "atmVirtual" {
- value 149;
- description
- "ATM Virtual Interface";
- }
- enum "mplsTunnel" {
- value 150;
- description
- "MPLS Tunnel Virtual Interface";
- }
- enum "srp" {
- value 151;
- description
- "Spatial Reuse Protocol ";
- }
- enum "voiceOverAtm" {
- value 152;
- description
- "Voice Over ATM";
- }
- enum "voiceOverFrameRelay" {
- value 153;
- description
- "Voice Over Frame Relay";
- }
- enum "idsl" {
- value 154;
- description
- "Digital Subscriber Loop over ISDN";
- }
- enum "compositeLink" {
- value 155;
- description
- "Avici Composite Link Interface";
- }
- enum "ss7SigLink" {
- value 156;
- description
- "SS7 Signaling Link";
- }
- enum "propWirelessP2P" {
- value 157;
- description
- "Prop. P2P wireless interface";
- }
- enum "frForward" {
- value 158;
- description
- "Frame Forward Interface";
- }
- enum "rfc1483" {
- value 159;
- description
- "Multiprotocol over ATM AAL5";
- reference
- "RFC 1483 - Multiprotocol Encapsulation over ATM
- Adaptation Layer 5";
- }
- enum "usb" {
- value 160;
- description
- "USB Interface";
- }
- enum "ieee8023adLag" {
- value 161;
- description
- "IEEE 802.3ad Link Aggregate";
- }
- enum "bgppolicyaccounting" {
- value 162;
- description
- "BGP Policy Accounting";
- }
- enum "frf16MfrBundle" {
- value 163;
- description
- "FRF .16 Multilink Frame Relay";
- }
- enum "h323Gatekeeper" {
- value 164;
- description
- "H323 Gatekeeper";
- }
- enum "h323Proxy" {
- value 165;
- description
- "H323 Voice and Video Proxy";
- }
- enum "mpls" {
- value 166;
- description
- "MPLS";
- }
- enum "mfSigLink" {
- value 167;
- description
- "Multi-frequency signaling link";
- }
- enum "hdsl2" {
- value 168;
- description
- "High Bit-Rate DSL - 2nd generation";
- }
- enum "shdsl" {
- value 169;
- description
- "Multirate HDSL2";
- }
- enum "ds1FDL" {
- value 170;
- description
- "Facility Data Link 4Kbps on a DS1";
- }
- enum "pos" {
- value 171;
- description
- "Packet over SONET/SDH Interface";
- }
- enum "dvbAsiIn" {
- value 172;
- description
- "DVB-ASI Input";
- }
- enum "dvbAsiOut" {
- value 173;
- description
- "DVB-ASI Output";
- }
- enum "plc" {
- value 174;
- description
- "Power Line Communtications";
- }
- enum "nfas" {
- value 175;
- description
- "Non Facility Associated Signaling";
- }
- enum "tr008" {
- value 176;
- description
- "TR008";
- }
- enum "gr303RDT" {
- value 177;
- description
- "Remote Digital Terminal";
- }
- enum "gr303IDT" {
- value 178;
- description
- "Integrated Digital Terminal";
- }
- enum "isup" {
- value 179;
- description
- "ISUP";
- }
- enum "propDocsWirelessMaclayer" {
- value 180;
- description
- "Cisco proprietary Maclayer";
- }
- enum "propDocsWirelessDownstream" {
- value 181;
- description
- "Cisco proprietary Downstream";
- }
- enum "propDocsWirelessUpstream" {
- value 182;
- description
- "Cisco proprietary Upstream";
- }
- enum "hiperlan2" {
- value 183;
- description
- "HIPERLAN Type 2 Radio Interface";
- }
- enum "propBWAp2Mp" {
- value 184;
- description
- "PropBroadbandWirelessAccesspt2multipt use of this value
- for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f
- is deprecated and ieee80216WMAN(237) should be used
- instead.";
- }
- enum "sonetOverheadChannel" {
- value 185;
- description
- "SONET Overhead Channel";
- }
- enum "digitalWrapperOverheadChannel" {
- value 186;
- description
- "Digital Wrapper";
- }
- enum "aal2" {
- value 187;
- description
- "ATM adaptation layer 2";
- }
- enum "radioMAC" {
- value 188;
- description
- "MAC layer over radio links";
- }
- enum "atmRadio" {
- value 189;
- description
- "ATM over radio links";
- }
- enum "imt" {
- value 190;
- description
- "Inter Machine Trunks";
- }
- enum "mvl" {
- value 191;
- description
- "Multiple Virtual Lines DSL";
- }
- enum "reachDSL" {
- value 192;
- description
- "Long Reach DSL";
- }
- enum "frDlciEndPt" {
- value 193;
- description
- "Frame Relay DLCI End Point";
- }
- enum "atmVciEndPt" {
- value 194;
- description
- "ATM VCI End Point";
- }
- enum "opticalChannel" {
- value 195;
- description
- "Optical Channel";
- }
- enum "opticalTransport" {
- value 196;
- description
- "Optical Transport";
- }
- enum "propAtm" {
- value 197;
- description
- "Proprietary ATM";
- }
- enum "voiceOverCable" {
- value 198;
- description
- "Voice Over Cable Interface";
- }
- enum "infiniband" {
- value 199;
- description
- "Infiniband";
- }
- enum "teLink" {
- value 200;
- description
- "TE Link";
- }
- enum "q2931" {
- value 201;
- description
- "Q.2931";
- }
- enum "virtualTg" {
- value 202;
- description
- "Virtual Trunk Group";
- }
- enum "sipTg" {
- value 203;
- description
- "SIP Trunk Group";
- }
- enum "sipSig" {
- value 204;
- description
- "SIP Signaling";
- }
- enum "docsCableUpstreamChannel" {
- value 205;
- description
- "CATV Upstream Channel";
- }
- enum "econet" {
- value 206;
- description
- "Acorn Econet";
- }
- enum "pon155" {
- value 207;
- description
- "FSAN 155Mb Symetrical PON interface";
- }
- enum "pon622" {
- value 208;
- description
- "FSAN622Mb Symetrical PON interface";
- }
- enum "bridge" {
- value 209;
- description
- "Transparent bridge interface";
- }
- enum "linegroup" {
- value 210;
- description
- "Interface common to multiple lines";
- }
- enum "voiceEMFGD" {
- value 211;
- description
- "voice E&M Feature Group D";
- }
- enum "voiceFGDEANA" {
- value 212;
- description
- "voice FGD Exchange Access North American";
- }
- enum "voiceDID" {
- value 213;
- description
- "voice Direct Inward Dialing";
- }
- enum "mpegTransport" {
- value 214;
- description
- "MPEG transport interface";
- }
- enum "sixToFour" {
- value 215;
- status deprecated;
- description
- "6to4 interface (DEPRECATED)";
- reference
- "RFC 4087 - IP Tunnel MIB";
- }
- enum "gtp" {
- value 216;
- description
- "GTP (GPRS Tunneling Protocol)";
- }
- enum "pdnEtherLoop1" {
- value 217;
- description
- "Paradyne EtherLoop 1";
- }
- enum "pdnEtherLoop2" {
- value 218;
- description
- "Paradyne EtherLoop 2";
- }
- enum "opticalChannelGroup" {
- value 219;
- description
- "Optical Channel Group";
- }
- enum "homepna" {
- value 220;
- description
- "HomePNA ITU-T G.989";
- }
- enum "gfp" {
- value 221;
- description
- "Generic Framing Procedure (GFP)";
- }
- enum "ciscoISLvlan" {
- value 222;
- description
- "Layer 2 Virtual LAN using Cisco ISL";
- }
- enum "actelisMetaLOOP" {
- value 223;
- description
- "Acteleis proprietary MetaLOOP High Speed Link";
- }
- enum "fcipLink" {
- value 224;
- description
- "FCIP Link";
- }
- enum "rpr" {
- value 225;
- description
- "Resilient Packet Ring Interface Type";
- }
- enum "qam" {
- value 226;
- description
- "RF Qam Interface";
- }
- enum "lmp" {
- value 227;
- description
- "Link Management Protocol";
- reference
- "RFC 4327 - Link Management Protocol (LMP) Management
- Information Base (MIB)";
- }
- enum "cblVectaStar" {
- value 228;
- description
- "Cambridge Broadband Networks Limited VectaStar";
- }
- enum "docsCableMCmtsDownstream" {
- value 229;
- description
- "CATV Modular CMTS Downstream Interface";
- }
- enum "adsl2" {
- value 230;
- status deprecated;
- description
- "Asymmetric Digital Subscriber Loop Version 2
- (DEPRECATED/OBSOLETED - please use adsl2plus(238)
- instead)";
- reference
- "RFC 4706 - Definitions of Managed Objects for Asymmetric
- Digital Subscriber Line 2 (ADSL2)";
- }
- enum "macSecControlledIF" {
- value 231;
- description
- "MACSecControlled";
- }
- enum "macSecUncontrolledIF" {
- value 232;
- description
- "MACSecUncontrolled";
- }
- enum "aviciOpticalEther" {
- value 233;
- description
- "Avici Optical Ethernet Aggregate";
- }
- enum "atmbond" {
- value 234;
- description
- "atmbond";
- }
- enum "voiceFGDOS" {
- value 235;
- description
- "voice FGD Operator Services";
- }
- enum "mocaVersion1" {
- value 236;
- description
- "MultiMedia over Coax Alliance (MoCA) Interface
- as documented in information provided privately to IANA";
- }
- enum "ieee80216WMAN" {
- value 237;
- description
- "IEEE 802.16 WMAN interface";
- }
- enum "adsl2plus" {
- value 238;
- description
- "Asymmetric Digital Subscriber Loop Version 2,
- Version 2 Plus and all variants";
- }
- enum "dvbRcsMacLayer" {
- value 239;
- description
- "DVB-RCS MAC Layer";
- reference
- "RFC 5728 - The SatLabs Group DVB-RCS MIB";
- }
- enum "dvbTdm" {
- value 240;
- description
- "DVB Satellite TDM";
- reference
- "RFC 5728 - The SatLabs Group DVB-RCS MIB";
- }
- enum "dvbRcsTdma" {
- value 241;
- description
- "DVB-RCS TDMA";
- reference
- "RFC 5728 - The SatLabs Group DVB-RCS MIB";
- }
- enum "x86Laps" {
- value 242;
- description
- "LAPS based on ITU-T X.86/Y.1323";
- }
- enum "wwanPP" {
- value 243;
- description
- "3GPP WWAN";
- }
- enum "wwanPP2" {
- value 244;
- description
- "3GPP2 WWAN";
- }
- enum "voiceEBS" {
- value 245;
- description
- "voice P-phone EBS physical interface";
- }
- enum "ifPwType" {
- value 246;
- description
- "Pseudowire interface type";
- reference
- "RFC 5601 - Pseudowire (PW) Management Information Base";
- }
- enum "ilan" {
- value 247;
- description
- "Internal LAN on a bridge per IEEE 802.1ap";
- }
- enum "pip" {
- value 248;
- description
- "Provider Instance Port on a bridge per IEEE 802.1ah PBB";
- }
- enum "aluELP" {
- value 249;
- description
- "Alcatel-Lucent Ethernet Link Protection";
- }
- enum "gpon" {
- value 250;
- description
- "Gigabit-capable passive optical networks (G-PON) as per
- ITU-T G.948";
- }
- enum "vdsl2" {
- value 251;
- description
- "Very high speed digital subscriber line Version 2
- (as per ITU-T Recommendation G.993.2)";
- reference
- "RFC 5650 - Definitions of Managed Objects for Very High
- Speed Digital Subscriber Line 2 (VDSL2)";
- }
- enum "capwapDot11Profile" {
- value 252;
- description
- "WLAN Profile Interface";
- reference
- "RFC 5834 - Control and Provisioning of Wireless Access
- Points (CAPWAP) Protocol Binding MIB for
- IEEE 802.11";
- }
- enum "capwapDot11Bss" {
- value 253;
- description
- "WLAN BSS Interface";
- reference
- "RFC 5834 - Control and Provisioning of Wireless Access
- Points (CAPWAP) Protocol Binding MIB for
- IEEE 802.11";
- }
- enum "capwapWtpVirtualRadio" {
- value 254;
- description
- "WTP Virtual Radio Interface";
- reference
- "RFC 5833 - Control and Provisioning of Wireless Access
- Points (CAPWAP) Protocol Base MIB";
- }
- enum "bits" {
- value 255;
- description
- "bitsport";
- }
- enum "docsCableUpstreamRfPort" {
- value 256;
- description
- "DOCSIS CATV Upstream RF Port";
- }
- enum "cableDownstreamRfPort" {
- value 257;
- description
- "CATV downstream RF port";
- }
- enum "vmwareVirtualNic" {
- value 258;
- description
- "VMware Virtual Network Interface";
- }
- enum "ieee802154" {
- value 259;
- description
- "IEEE 802.15.4 WPAN interface";
- reference
- "IEEE 802.15.4-2006";
- }
- enum "otnOdu" {
- value 260;
- description
- "OTN Optical Data Unit";
- }
- enum "otnOtu" {
- value 261;
- description
- "OTN Optical channel Transport Unit";
- }
- enum "ifVfiType" {
- value 262;
- description
- "VPLS Forwarding Instance Interface Type";
- }
- enum "g9981" {
- value 263;
- description
- "G.998.1 bonded interface";
- }
- enum "g9982" {
- value 264;
- description
- "G.998.2 bonded interface";
- }
- enum "g9983" {
- value 265;
- description
- "G.998.3 bonded interface";
- }
- enum "aluEpon" {
- value 266;
- description
- "Ethernet Passive Optical Networks (E-PON)";
- }
- enum "aluEponOnu" {
- value 267;
- description
- "EPON Optical Network Unit";
- }
- enum "aluEponPhysicalUni" {
- value 268;
- description
- "EPON physical User to Network interface";
- }
- enum "aluEponLogicalLink" {
- value 269;
- description
- "The emulation of a point-to-point link over the EPON
- layer";
- }
- enum "aluGponOnu" {
- value 270;
- description
- "GPON Optical Network Unit";
- reference
- "ITU-T G.984.2";
- }
- enum "aluGponPhysicalUni" {
- value 271;
- description
- "GPON physical User to Network interface";
- reference
- "ITU-T G.984.2";
- }
- enum "vmwareNicTeam" {
- value 272;
- description
- "VMware NIC Team";
- }
- }
- description
- "This data type is used as the syntax of the 'type'
- leaf in the 'interface' list in the YANG module
- ietf-interface.
-
- The definition of this typedef with the
- addition of newly assigned values is published
- periodically by the IANA, in either the Assigned
- Numbers RFC, or some derivative of it specific to
- Internet Network Management number assignments. (The
- latest arrangements can be obtained by contacting the
- IANA.)
-
- Requests for new values should be made to IANA via
- email (iana&iana.org).";
- reference
- "ifType definitions registry.
- <http://www.iana.org/assignments/smi-numbers>";
- }
-}
\ No newline at end of file
+++ /dev/null
- module ietf-inet-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
- prefix "inet";
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Partain
- <mailto:david.partain@ericsson.com>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types for Internet addresses and related things.
-
- Copyright (c) 2010 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, is permitted pursuant to, and subject to the license
- terms contained in, the Simplified BSD License set forth in Section
- 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6021; see
- the RFC itself for full legal notices.";
-
- revision 2010-09-24 {
- description
- "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
- }
-
- /*** collection of protocol field related types ***/
-
- typedef ip-version {
- type enumeration {
- enum unknown {
- value "0";
- description
- "An unknown or unspecified version of the Internet protocol.";
- }
- enum ipv4 {
- value "1";
- description
- "The IPv4 protocol as defined in RFC 791.";
- }
- enum ipv6 {
- value "2";
- description
- "The IPv6 protocol as defined in RFC 2460.";
- }
- }
- description
- "This value represents the version of the IP protocol.
-
- In the value set and its semantics, this type is equivalent
- to the InetVersion textual convention of the SMIv2.";
- reference
- "RFC 791: Internet Protocol
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- typedef dscp {
- type uint8 {
- range "0..63";
- }
- description
- "The dscp type represents a Differentiated Services Code-Point
- that may be used for marking packets in a traffic stream.
-
- In the value set and its semantics, this type is equivalent
- to the Dscp textual convention of the SMIv2.";
- reference
- "RFC 3289: Management Information Base for the Differentiated
- Services Architecture
- RFC 2474: Definition of the Differentiated Services Field
- (DS Field) in the IPv4 and IPv6 Headers
- RFC 2780: IANA Allocation Guidelines For Values In
- the Internet Protocol and Related Headers";
- }
-
- typedef ipv6-flow-label {
- type uint32 {
- range "0..1048575";
- }
- description
- "The flow-label type represents flow identifier or Flow Label
- in an IPv6 packet header that may be used to discriminate
- traffic flows.
-
- In the value set and its semantics, this type is equivalent
- to the IPv6FlowLabel textual convention of the SMIv2.";
- reference
- "RFC 3595: Textual Conventions for IPv6 Flow Label
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
- }
-
- typedef port-number {
- type uint16 {
- range "0..65535";
- }
- description
- "The port-number type represents a 16-bit port number of an
- Internet transport layer protocol such as UDP, TCP, DCCP, or
- SCTP. Port numbers are assigned by IANA. A current list of
- all assignments is available from <http://www.iana.org/>.
-
- Note that the port number value zero is reserved by IANA. In
- situations where the value zero does not make sense, it can
- be excluded by subtyping the port-number type.
-
- In the value set and its semantics, this type is equivalent
- to the InetPortNumber textual convention of the SMIv2.";
- reference
- "RFC 768: User Datagram Protocol
- RFC 793: Transmission Control Protocol
- RFC 4960: Stream Control Transmission Protocol
- RFC 4340: Datagram Congestion Control Protocol (DCCP)
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- /*** collection of autonomous system related types ***/
-
- typedef as-number {
- type uint32;
- description
- "The as-number type represents autonomous system numbers
- which identify an Autonomous System (AS). An AS is a set
- of routers under a single technical administration, using
- an interior gateway protocol and common metrics to route
- packets within the AS, and using an exterior gateway
- protocol to route packets to other ASs'. IANA maintains
- the AS number space and has delegated large parts to the
- regional registries.
-
- Autonomous system numbers were originally limited to 16
- bits. BGP extensions have enlarged the autonomous system
- number space to 32 bits. This type therefore uses an uint32
- base type without a range restriction in order to support
- a larger autonomous system number space.
-
- In the value set and its semantics, this type is equivalent
- to the InetAutonomousSystemNumber textual convention of
- the SMIv2.";
- reference
- "RFC 1930: Guidelines for creation, selection, and registration
- of an Autonomous System (AS)
- RFC 4271: A Border Gateway Protocol 4 (BGP-4)
- RFC 4893: BGP Support for Four-octet AS Number Space
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- /*** collection of IP address and hostname related types ***/
-
- typedef ip-address {
- type union {
- type inet:ipv4-address;
- type inet:ipv6-address;
- }
- description
- "The ip-address type represents an IP address and is IP
- version neutral. The format of the textual representations
- implies the IP version.";
- }
-
- typedef ipv4-address {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '(%[\p{N}\p{L}]+)?';
- }
- description
- "The ipv4-address type represents an IPv4 address in
- dotted-quad notation. The IPv4 address may include a zone
- index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
- The canonical format for the zone index is the numerical
- format";
- }
-
- typedef ipv6-address {
- type string {
- pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(%[\p{N}\p{L}]+)?';
- pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(%.+)?';
- }
- description
- "The ipv6-address type represents an IPv6 address in full,
- mixed, shortened, and shortened-mixed notation. The IPv6
- address may include a zone index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
- The canonical format of IPv6 addresses uses the compressed
- format described in RFC 4291, Section 2.2, item 2 with the
- following additional rules: the :: substitution must be
- applied to the longest sequence of all-zero 16-bit chunks
- in an IPv6 address. If there is a tie, the first sequence
- of all-zero 16-bit chunks is replaced by ::. Single
- all-zero 16-bit chunks are not compressed. The canonical
- format uses lowercase characters and leading zeros are
- not allowed. The canonical format for the zone index is
- the numerical format as described in RFC 4007, Section
- 11.2.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture
- RFC 4007: IPv6 Scoped Address Architecture
- RFC 5952: A Recommendation for IPv6 Address Text Representation";
- }
-
- typedef ip-prefix {
- type union {
- type inet:ipv4-prefix;
- type inet:ipv6-prefix;
- }
- description
- "The ip-prefix type represents an IP prefix and is IP
- version neutral. The format of the textual representations
- implies the IP version.";
- }
-
- typedef ipv4-prefix {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
- }
- description
- "The ipv4-prefix type represents an IPv4 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal to 32.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The canonical format of an IPv4 prefix has all bits of
- the IPv4 address set to zero that are not part of the
- IPv4 prefix.";
- }
-
- typedef ipv6-prefix {
- type string {
- pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
- pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(/.+)';
- }
- description
- "The ipv6-prefix type represents an IPv6 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal 128.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The IPv6 address should have all bits that do not belong
- to the prefix set to zero.
-
- The canonical format of an IPv6 prefix has all bits of
- the IPv6 address set to zero that are not part of the
- IPv6 prefix. Furthermore, IPv6 address is represented
- in the compressed format described in RFC 4291, Section
- 2.2, item 2 with the following additional rules: the ::
- substitution must be applied to the longest sequence of
- all-zero 16-bit chunks in an IPv6 address. If there is
- a tie, the first sequence of all-zero 16-bit chunks is
- replaced by ::. Single all-zero 16-bit chunks are not
- compressed. The canonical format uses lowercase
- characters and leading zeros are not allowed.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture";
- }
-
- /*** collection of domain name and URI types ***/
-
- typedef domain-name {
- type string {
- pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
- + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
- + '|\.';
- length "1..253";
- }
- description
- "The domain-name type represents a DNS domain name. The
- name SHOULD be fully qualified whenever possible.
-
- Internet domain names are only loosely specified. Section
- 3.5 of RFC 1034 recommends a syntax (modified in Section
- 2.1 of RFC 1123). The pattern above is intended to allow
- for current practice in domain name use, and some possible
- future expansion. It is designed to hold various types of
- domain names, including names used for A or AAAA records
- (host names) and other records, such as SRV records. Note
- that Internet host names have a stricter syntax (described
- in RFC 952) than the DNS recommendations in RFCs 1034 and
- 1123, and that systems that want to store host names in
- schema nodes using the domain-name type are recommended to
- adhere to this stricter standard to ensure interoperability.
-
- The encoding of DNS names in the DNS protocol is limited
- to 255 characters. Since the encoding consists of labels
- prefixed by a length bytes and there is a trailing NULL
- byte, only 253 characters can appear in the textual dotted
- notation.
-
- The description clause of schema nodes using the domain-name
- type MUST describe when and how these names are resolved to
- IP addresses. Note that the resolution of a domain-name value
- may require to query multiple DNS records (e.g., A for IPv4
- and AAAA for IPv6). The order of the resolution process and
- which DNS record takes precedence can either be defined
- explicitely or it may depend on the configuration of the
- resolver.
-
- Domain-name values use the US-ASCII encoding. Their canonical
- format uses lowercase US-ASCII characters. Internationalized
- domain names MUST be encoded in punycode as described in RFC
- 3492";
- reference
- "RFC 952: DoD Internet Host Table Specification
- RFC 1034: Domain Names - Concepts and Facilities
- RFC 1123: Requirements for Internet Hosts -- Application
- and Support
- RFC 2782: A DNS RR for specifying the location of services
- (DNS SRV)
- RFC 3492: Punycode: A Bootstring encoding of Unicode for
- Internationalized Domain Names in Applications
- (IDNA)
- RFC 5891: Internationalizing Domain Names in Applications
- (IDNA): Protocol";
- }
-
- typedef host {
- type union {
- type inet:ip-address;
- type inet:domain-name;
- }
- description
- "The host type represents either an IP address or a DNS
- domain name.";
- }
-
- typedef uri {
- type string;
- description
- "The uri type represents a Uniform Resource Identifier
- (URI) as defined by STD 66.
-
- Objects using the uri type MUST be in US-ASCII encoding,
- and MUST be normalized as described by RFC 3986 Sections
- 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
- percent-encoding is removed, and all case-insensitive
- characters are set to lowercase except for hexadecimal
- digits, which are normalized to uppercase as described in
- Section 6.2.2.1.
-
- The purpose of this normalization is to help provide
- unique URIs. Note that this normalization is not
- sufficient to provide uniqueness. Two URIs that are
- textually distinct after this normalization may still be
- equivalent.
-
- Objects using the uri type may restrict the schemes that
- they permit. For example, 'data:' and 'urn:' schemes
- might not be appropriate.
-
- A zero-length URI is not a valid URI. This can be used to
- express 'URI absent' where required.
-
- In the value set and its semantics, this type is equivalent
- to the Uri SMIv2 textual convention defined in RFC 5017.";
- reference
- "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
- RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
- Group: Uniform Resource Identifiers (URIs), URLs,
- and Uniform Resource Names (URNs): Clarifications
- and Recommendations
- RFC 5017: MIB Textual Conventions for Uniform Resource
- Identifiers (URIs)";
- }
-
- }
\ No newline at end of file
namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
prefix if;
- import ietf-yang-types {
- prefix yang;
- }
- import iana-if-type {
- prefix ianaift;
- }
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- WG Chair: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>
-
- Editor: Martin Bjorklund
- <mailto:mbj@tail-f.com>";
-
- description
- "This module contains a collection of YANG definitions for
- managing network interfaces.
-
- Copyright (c) 2012 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC XXXX; see
- the RFC itself for full legal notices.";
-
- // RFC Ed.: replace XXXX with actual RFC number and remove this
- // note.
-
- // RFC Ed.: update the date below with the date of RFC publication
- // and remove this note.
revision 2012-11-15 {
- description
- "Initial revision.";
- reference
- "RFC XXXX: A YANG Data Model for Interface Management";
}
- /* Typedefs */
-
typedef interface-ref {
type leafref {
path "/if:interfaces/if:interface/if:name";
}
- description
- "This type is used by data models that need to reference
- interfaces.";
- }
-
- /* Features */
-
- feature arbitrary-names {
- description
- "This feature indicates that the server allows interfaces to
- be named arbitrarily.";
}
- feature if-mib {
- description
- "This feature indicates that the server implements IF-MIB.";
- reference
- "RFC 2863: The Interfaces Group MIB";
- }
-
- /* Data nodes */
container interfaces {
- description
- "Interface parameters.";
list interface {
key "name";
unique "type location";
- description
- "The list of interfaces on the device.";
-
leaf name {
type string;
- description
- "The name of the interface.
-
- A device MAY restrict the allowed values for this leaf,
- possibly depending on the type and location.
-
- If the device allows arbitrarily named interfaces, the
- feature 'arbitrary-names' is advertised.
-
- This leaf MAY be mapped to ifName by an implementation.
- Such an implementation MAY restrict the allowed values for
- this leaf so that it matches the restrictions of ifName.
- If a NETCONF server that implements this restriction is
- sent a value that doesn't match the restriction, it MUST
- reply with an rpc-error with the error-tag
- 'invalid-value'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifName";
- }
-
- leaf description {
- type string;
- description
- "A textual description of the interface.
-
- This leaf MAY be mapped to ifAlias by an implementation.
- Such an implementation MAY restrict the allowed values for
- this leaf so that it matches the restrictions of ifAlias.
- If a NETCONF server that implements this restriction is
- sent a value that doesn't match the restriction, it MUST
- reply with an rpc-error with the error-tag
- 'invalid-value'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifAlias";
- }
-
- leaf type {
- type ianaift:iana-if-type;
- mandatory true;
- description
- "The type of the interface.
-
- When an interface entry is created, a server MAY
- initialize the type leaf with a valid value, e.g., if it
- is possible to derive the type from the name of the
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifType";
- }
-
- leaf location {
- type string;
- description
- "The device-specific location of the interface of a
- particular type. The format of the location string
- depends on the interface type and the device.
-
- If the interface's type represents a physical interface,
- this leaf MUST be set.
-
- When an interface entry is created, a server MAY
- initialize the location leaf with a valid value, e.g., if
- it is possible to derive the location from the name of
- the interface.";
- }
-
- leaf enabled {
- type boolean;
- default "true";
- description
- "The desired state of the interface.
-
- This leaf contains the configured, desired state of the
- interface. Systems that implement the IF-MIB use the
- value of this leaf to set IF-MIB.ifAdminStatus to 'up' or
- 'down' after an ifEntry has been initialized, as described
- in RFC 2863.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
- }
-
- leaf oper-status {
- type enumeration {
- enum up {
- value 1;
- description
- "Ready to pass packets.";
- }
- enum down {
- value 2;
- description
- "The interface does not pass any packets.";
- }
- enum testing {
- value 3;
- description
- "In some test mode. No operational packets can
- be passed.";
- }
- enum unknown {
- value 4;
- description
- "Status cannot be determined for some reason.";
- }
- enum dormant {
- value 5;
- description
- "Waiting for some external event.";
- }
- enum not-present {
- value 6;
- description
- "Some component is missing.";
- }
- enum lower-layer-down {
- value 7;
- description
- "Down due to state of lower-layer interface(s).";
- }
- }
- config false;
- description
- "The current operational state of the interface.
-
- If 'enabled' is 'false' then 'oper-status'
- should be 'down'. If 'enabled' is changed to 'true'
- then 'oper-status' should change to 'up' if the interface
- is ready to transmit and receive network traffic; it
- should change to 'dormant' if the interface is waiting for
- external actions (such as a serial line waiting for an
- incoming connection); it should remain in the 'down' state
- if and only if there is a fault that prevents it from
- going to the 'up' state; it should remain in the
- 'not-present' state if the interface has missing
- (typically, hardware) components.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOperStatus";
- }
-
- leaf last-change {
- type yang:date-and-time;
- config false;
- description
- "The time the interface entered its current operational
- state. If the current state was entered prior to the
- last re-initialization of the local network management
- subsystem, then this node is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifLastChange";
- }
-
- leaf if-index {
- if-feature if-mib;
- type int32 {
- range "1..2147483647";
- }
- config false;
- description
- "The ifIndex value for the ifEntry represented by this
- interface.
-
- Media-specific modules must specify how the type is
- mapped to entries in the ifTable.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifIndex";
- }
-
- leaf link-up-down-trap-enable {
- if-feature if-mib;
- type enumeration {
- enum enabled {
- value 1;
- }
- enum disabled {
- value 2;
- }
- }
- description
- "Indicates whether linkUp/linkDown SNMP notifications
- should be generated for this interface.
- If this node is not configured, the value 'enabled' is
- operationally used by the server for interfaces which do
- not operate on top of any other interface (i.e., there are
- no 'lower-layer-if' entries), and 'disabled' otherwise.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifLinkUpDownTrapEnable";
- }
-
- leaf phys-address {
- type yang:phys-address;
- config false;
- description
- "The interface's address at its protocol sub-layer. For
- example, for an 802.x interface, this object normally
- contains a MAC address. The interface's media-specific
- modules must define the bit and byte ordering and the
- format of the value of this object. For interfaces that do
- not have such an address (e.g., a serial line), this node
- is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifPhysAddress";
}
leaf-list higher-layer-if {
type interface-ref;
config false;
- description
- "A list of references to interfaces layered on top of this
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifStackTable";
- }
-
- leaf-list lower-layer-if {
- type interface-ref;
- config false;
- description
- "A list of references to interfaces layered underneath this
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifStackTable";
}
- leaf speed {
- type yang:gauge64;
- units "bits / second";
- config false;
- description
- "An estimate of the interface's current bandwidth in bits
- per second. For interfaces which do not vary in
- bandwidth or for those where no accurate estimation can
- be made, this node should contain the nominal bandwidth.
- For interfaces that has no concept of bandwidth, this
- node is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifSpeed, ifHighSpeed";
- }
-
- container statistics {
- config false;
- description
- "A collection of interface-related statistics objects.";
-
- leaf discontinuity-time {
- type yang:date-and-time;
- description
- "The time on the most recent occasion at which any one or
- more of this interface's counters suffered a
- discontinuity. If no such discontinuities have occurred
- since the last re-initialization of the local management
- subsystem, then this node contains the time the local
- management subsystem re-initialized itself.";
- }
-
- leaf in-octets {
- type yang:counter64;
- description
- "The total number of octets received on the interface,
- including framing characters.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCInOctets";
- }
- leaf in-unicast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, which were not addressed to a
- multicast or broadcast address at this sub-layer.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts";
- }
- leaf in-broadcast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, which were addressed to a broadcast
- address at this sub-layer.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCInBroadcastPkts";
- }
- leaf in-multicast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, which were addressed to a multicast
- address at this sub-layer. For a MAC layer protocol,
- this includes both Group and Functional addresses.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCInMulticastPkts";
- }
- leaf in-discards {
- type yang:counter32;
- description
- "The number of inbound packets which were chosen to be
- discarded even though no errors had been detected to
- prevent their being deliverable to a higher-layer
- protocol. One possible reason for discarding such a
- packet could be to free up buffer space.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInDiscards";
- }
- leaf in-errors {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of inbound
- packets that contained errors preventing them from being
- deliverable to a higher-layer protocol. For character-
- oriented or fixed-length interfaces, the number of
- inbound transmission units that contained errors
- preventing them from being deliverable to a higher-layer
- protocol.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInErrors";
- }
- leaf in-unknown-protos {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of packets
- received via the interface which were discarded because
- of an unknown or unsupported protocol. For
- character-oriented or fixed-length interfaces that
- support protocol multiplexing the number of transmission
- units received via the interface which were discarded
- because of an unknown or unsupported protocol. For any
- interface that does not support protocol multiplexing,
- this counter is not present.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos";
- }
-
- leaf out-octets {
- type yang:counter64;
- description
- "The total number of octets transmitted out of the
- interface, including framing characters.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCOutOctets";
- }
- leaf out-unicast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and which were not addressed
- to a multicast or broadcast address at this sub-layer,
- including those that were discarded or not sent.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts";
- }
- leaf out-broadcast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and which were addressed to a
- broadcast address at this sub-layer, including those
- that were discarded or not sent.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCOutBroadcastPkts";
- }
- leaf out-multicast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and which were addressed to a
- multicast address at this sub-layer, including those
- that were discarded or not sent. For a MAC layer
- protocol, this includes both Group and Functional
- addresses.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCOutMulticastPkts";
- }
- leaf out-discards {
- type yang:counter32;
- description
- "The number of outbound packets which were chosen to be
- discarded even though no errors had been detected to
- prevent their being transmitted. One possible reason
- for discarding such a packet could be to free up buffer
- space.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOutDiscards";
- }
- leaf out-errors {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of outbound
- packets that could not be transmitted because of errors.
- For character-oriented or fixed-length interfaces, the
- number of outbound transmission units that could not be
- transmitted because of errors.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOutErrors";
- }
- }
}
}
-}
\ No newline at end of file
+}
+++ /dev/null
- module ietf-yang-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
- prefix "yang";
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Partain
- <mailto:david.partain@ericsson.com>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types.
-
- Copyright (c) 2010 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, is permitted pursuant to, and subject to the license
- terms contained in, the Simplified BSD License set forth in Section
- 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6021; see
- the RFC itself for full legal notices.";
-
- revision 2010-09-24 {
- description
- "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
- }
-
- /*** collection of counter and gauge types ***/
-
- typedef counter32 {
- type uint32;
- description
- "The counter32 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter32 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter32 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter32.
-
- In the value set and its semantics, this type is equivalent
- to the Counter32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef zero-based-counter32 {
- type yang:counter32;
- default "0";
- description
- "The zero-based-counter32 type represents a counter32
- that has the defined 'initial' value zero.
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter32 textual convention of the SMIv2.";
- reference
- "RFC 4502: Remote Network Monitoring Management Information
- Base Version 2";
- }
-
- typedef counter64 {
- type uint64;
- description
- "The counter64 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter64 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter64 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter64.
-
- In the value set and its semantics, this type is equivalent
- to the Counter64 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef zero-based-counter64 {
- type yang:counter64;
- default "0";
- description
- "The zero-based-counter64 type represents a counter64 that
- has the defined 'initial' value zero.
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter64 textual convention of the SMIv2.";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
- }
-
- typedef gauge32 {
- type uint32;
- description
- "The gauge32 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^32-1 (4294967295 decimal), and
- the minimum value cannot be smaller than 0. The value of
- a gauge32 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge32 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the Gauge32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef gauge64 {
- type uint64;
- description
- "The gauge64 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^64-1 (18446744073709551615), and
- the minimum value cannot be smaller than 0. The value of
- a gauge64 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge64 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the CounterBasedGauge64 SMIv2 textual convention defined
- in RFC 2856";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
- }
-
- /*** collection of identifier related types ***/
-
- typedef object-identifier {
- type string {
- pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
- + '(\.(0|([1-9]\d*)))*';
- }
- description
- "The object-identifier type represents administratively
- assigned names in a registration-hierarchical-name tree.
-
- Values of this type are denoted as a sequence of numerical
- non-negative sub-identifier values. Each sub-identifier
- value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
- are separated by single dots and without any intermediate
- whitespace.
-
- The ASN.1 standard restricts the value space of the first
- sub-identifier to 0, 1, or 2. Furthermore, the value space
- of the second sub-identifier is restricted to the range
- 0 to 39 if the first sub-identifier is 0 or 1. Finally,
- the ASN.1 standard requires that an object identifier
- has always at least two sub-identifier. The pattern
- captures these restrictions.
-
- Although the number of sub-identifiers is not limited,
- module designers should realize that there may be
- implementations that stick with the SMIv2 limit of 128
- sub-identifiers.
-
- This type is a superset of the SMIv2 OBJECT IDENTIFIER type
- since it is not restricted to 128 sub-identifiers. Hence,
- this type SHOULD NOT be used to represent the SMIv2 OBJECT
- IDENTIFIER type, the object-identifier-128 type SHOULD be
- used instead.";
- reference
- "ISO9834-1: Information technology -- Open Systems
- Interconnection -- Procedures for the operation of OSI
- Registration Authorities: General procedures and top
- arcs of the ASN.1 Object Identifier tree";
- }
-
-
-
-
- typedef object-identifier-128 {
- type object-identifier {
- pattern '\d*(\.\d*){1,127}';
- }
- description
- "This type represents object-identifiers restricted to 128
- sub-identifiers.
-
- In the value set and its semantics, this type is equivalent
- to the OBJECT IDENTIFIER type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- /*** collection of date and time related types ***/
-
- typedef date-and-time {
- type string {
- pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
- + '(Z|[\+\-]\d{2}:\d{2})';
- }
- description
- "The date-and-time type is a profile of the ISO 8601
- standard for representation of dates and times using the
- Gregorian calendar. The profile is defined by the
- date-time production in Section 5.6 of RFC 3339.
-
- The date-and-time type is compatible with the dateTime XML
- schema type with the following notable exceptions:
-
- (a) The date-and-time type does not allow negative years.
-
- (b) The date-and-time time-offset -00:00 indicates an unknown
- time zone (see RFC 3339) while -00:00 and +00:00 and Z all
- represent the same time zone in dateTime.
-
- (c) The canonical format (see below) of data-and-time values
- differs from the canonical format used by the dateTime XML
- schema type, which requires all times to be in UTC using the
- time-offset 'Z'.
-
- This type is not equivalent to the DateAndTime textual
- convention of the SMIv2 since RFC 3339 uses a different
- separator between full-date and full-time and provides
- higher resolution of time-secfrac.
-
- The canonical format for date-and-time values with a known time
- zone uses a numeric time zone offset that is calculated using
- the device's configured known offset to UTC time. A change of
- the device's offset to UTC time will cause date-and-time values
- to change accordingly. Such changes might happen periodically
- in case a server follows automatically daylight saving time
- (DST) time zone offset changes. The canonical format for
- date-and-time values with an unknown time zone (usually referring
- to the notion of local time) uses the time-offset -00:00.";
- reference
- "RFC 3339: Date and Time on the Internet: Timestamps
- RFC 2579: Textual Conventions for SMIv2
- XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
- }
-
- typedef timeticks {
- type uint32;
- description
- "The timeticks type represents a non-negative integer that
- represents the time, modulo 2^32 (4294967296 decimal), in
- hundredths of a second between two epochs. When a schema
- node is defined that uses this type, the description of
- the schema node identifies both of the reference epochs.
-
- In the value set and its semantics, this type is equivalent
- to the TimeTicks type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef timestamp {
- type yang:timeticks;
- description
- "The timestamp type represents the value of an associated
- timeticks schema node at which a specific occurrence happened.
- The specific occurrence must be defined in the description
- of any schema node defined using this type. When the specific
- occurrence occurred prior to the last time the associated
- timeticks attribute was zero, then the timestamp value is
- zero. Note that this requires all timestamp values to be
- reset to zero when the value of the associated timeticks
- attribute reaches 497+ days and wraps around to zero.
-
- The associated timeticks schema node must be specified
- in the description of any schema node using this type.
-
- In the value set and its semantics, this type is equivalent
- to the TimeStamp textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
- }
-
- /*** collection of generic address types ***/
-
- typedef phys-address {
- type string {
- pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
- }
- description
- "Represents media- or physical-level addresses represented
- as a sequence octets, each octet represented by two hexadecimal
- numbers. Octets are separated by colons. The canonical
- representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the PhysAddress textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
- }
-
- typedef mac-address {
- type string {
- pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
- }
- description
- "The mac-address type represents an IEEE 802 MAC address.
- The canonical representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the MacAddress textual convention of the SMIv2.";
- reference
- "IEEE 802: IEEE Standard for Local and Metropolitan Area
- Networks: Overview and Architecture
- RFC 2579: Textual Conventions for SMIv2";
- }
-
- /*** collection of XML specific types ***/
-
- typedef xpath1.0 {
- type string;
- description
- "This type represents an XPATH 1.0 expression.
-
- When a schema node is defined that uses this type, the
- description of the schema node MUST specify the XPath
- context in which the XPath expression is evaluated.";
- reference
- "XPATH: XML Path Language (XPath) Version 1.0";
- }
-
- }
\ No newline at end of file
namespace "urn:ietf:params:xml:ns:yang:choice-monitoring";
prefix "ncm";
- import ietf-yang-types { prefix yang; }
- import ietf-inet-types { prefix inet; }
-
- organization "OPEN DAYLIGHT";
- contact "http://www.opendaylight.org/";
-
- description
- "Test model for testing of resolving choice, case nodes and generation types from them.";
-
revision 2013-07-01 {
-
}
typedef tls-fingerprint-type {
}
leaf locked-time {
- type yang:date-and-time;
+ type string;
mandatory true;
}
container capabilities {
leaf-list capability {
- type inet:uri;
+ type string;
}
}
}
type uint32;
}
leaf-list select {
- type yang:xpath1.0;
+ type string;
min-elements 1;
}
leaf-list locked-node {
+++ /dev/null
- module ietf-inet-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
- prefix "inet";
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Partain
- <mailto:david.partain@ericsson.com>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types for Internet addresses and related things.
-
- Copyright (c) 2010 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, is permitted pursuant to, and subject to the license
- terms contained in, the Simplified BSD License set forth in Section
- 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6021; see
- the RFC itself for full legal notices.";
-
- revision 2010-09-24 {
- description
- "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
- }
-
- /*** collection of protocol field related types ***/
-
- typedef ip-version {
- type enumeration {
- enum unknown {
- value "0";
- description
- "An unknown or unspecified version of the Internet protocol.";
- }
- enum ipv4 {
- value "1";
- description
- "The IPv4 protocol as defined in RFC 791.";
- }
- enum ipv6 {
- value "2";
- description
- "The IPv6 protocol as defined in RFC 2460.";
- }
- }
- description
- "This value represents the version of the IP protocol.
-
- In the value set and its semantics, this type is equivalent
- to the InetVersion textual convention of the SMIv2.";
- reference
- "RFC 791: Internet Protocol
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- typedef dscp {
- type uint8 {
- range "0..63";
- }
- description
- "The dscp type represents a Differentiated Services Code-Point
- that may be used for marking packets in a traffic stream.
-
- In the value set and its semantics, this type is equivalent
- to the Dscp textual convention of the SMIv2.";
- reference
- "RFC 3289: Management Information Base for the Differentiated
- Services Architecture
- RFC 2474: Definition of the Differentiated Services Field
- (DS Field) in the IPv4 and IPv6 Headers
- RFC 2780: IANA Allocation Guidelines For Values In
- the Internet Protocol and Related Headers";
- }
-
- typedef ipv6-flow-label {
- type uint32 {
- range "0..1048575";
- }
- description
- "The flow-label type represents flow identifier or Flow Label
- in an IPv6 packet header that may be used to discriminate
- traffic flows.
-
- In the value set and its semantics, this type is equivalent
- to the IPv6FlowLabel textual convention of the SMIv2.";
- reference
- "RFC 3595: Textual Conventions for IPv6 Flow Label
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
- }
-
- typedef port-number {
- type uint16 {
- range "0..65535";
- }
- description
- "The port-number type represents a 16-bit port number of an
- Internet transport layer protocol such as UDP, TCP, DCCP, or
- SCTP. Port numbers are assigned by IANA. A current list of
- all assignments is available from <http://www.iana.org/>.
-
- Note that the port number value zero is reserved by IANA. In
- situations where the value zero does not make sense, it can
- be excluded by subtyping the port-number type.
-
- In the value set and its semantics, this type is equivalent
- to the InetPortNumber textual convention of the SMIv2.";
- reference
- "RFC 768: User Datagram Protocol
- RFC 793: Transmission Control Protocol
- RFC 4960: Stream Control Transmission Protocol
- RFC 4340: Datagram Congestion Control Protocol (DCCP)
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- /*** collection of autonomous system related types ***/
-
- typedef as-number {
- type uint32;
- description
- "The as-number type represents autonomous system numbers
- which identify an Autonomous System (AS). An AS is a set
- of routers under a single technical administration, using
- an interior gateway protocol and common metrics to route
- packets within the AS, and using an exterior gateway
- protocol to route packets to other ASs'. IANA maintains
- the AS number space and has delegated large parts to the
- regional registries.
-
- Autonomous system numbers were originally limited to 16
- bits. BGP extensions have enlarged the autonomous system
- number space to 32 bits. This type therefore uses an uint32
- base type without a range restriction in order to support
- a larger autonomous system number space.
-
- In the value set and its semantics, this type is equivalent
- to the InetAutonomousSystemNumber textual convention of
- the SMIv2.";
- reference
- "RFC 1930: Guidelines for creation, selection, and registration
- of an Autonomous System (AS)
- RFC 4271: A Border Gateway Protocol 4 (BGP-4)
- RFC 4893: BGP Support for Four-octet AS Number Space
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- /*** collection of IP address and hostname related types ***/
-
- typedef ip-address {
- type union {
- type inet:ipv4-address;
- type inet:ipv6-address;
- }
- description
- "The ip-address type represents an IP address and is IP
- version neutral. The format of the textual representations
- implies the IP version.";
- }
-
- typedef ipv4-address {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '(%[\p{N}\p{L}]+)?';
- }
- description
- "The ipv4-address type represents an IPv4 address in
- dotted-quad notation. The IPv4 address may include a zone
- index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
- The canonical format for the zone index is the numerical
- format";
- }
-
- typedef ipv6-address {
- type string {
- pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(%[\p{N}\p{L}]+)?';
- pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(%.+)?';
- }
- description
- "The ipv6-address type represents an IPv6 address in full,
- mixed, shortened, and shortened-mixed notation. The IPv6
- address may include a zone index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
- The canonical format of IPv6 addresses uses the compressed
- format described in RFC 4291, Section 2.2, item 2 with the
- following additional rules: the :: substitution must be
- applied to the longest sequence of all-zero 16-bit chunks
- in an IPv6 address. If there is a tie, the first sequence
- of all-zero 16-bit chunks is replaced by ::. Single
- all-zero 16-bit chunks are not compressed. The canonical
- format uses lowercase characters and leading zeros are
- not allowed. The canonical format for the zone index is
- the numerical format as described in RFC 4007, Section
- 11.2.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture
- RFC 4007: IPv6 Scoped Address Architecture
- RFC 5952: A Recommendation for IPv6 Address Text Representation";
- }
-
- typedef ip-prefix {
- type union {
- type inet:ipv4-prefix;
- type inet:ipv6-prefix;
- }
- description
- "The ip-prefix type represents an IP prefix and is IP
- version neutral. The format of the textual representations
- implies the IP version.";
- }
-
- typedef ipv4-prefix {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
- }
- description
- "The ipv4-prefix type represents an IPv4 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal to 32.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The canonical format of an IPv4 prefix has all bits of
- the IPv4 address set to zero that are not part of the
- IPv4 prefix.";
- }
-
- typedef ipv6-prefix {
- type string {
- pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
- pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(/.+)';
- }
- description
- "The ipv6-prefix type represents an IPv6 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal 128.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The IPv6 address should have all bits that do not belong
- to the prefix set to zero.
-
- The canonical format of an IPv6 prefix has all bits of
- the IPv6 address set to zero that are not part of the
- IPv6 prefix. Furthermore, IPv6 address is represented
- in the compressed format described in RFC 4291, Section
- 2.2, item 2 with the following additional rules: the ::
- substitution must be applied to the longest sequence of
- all-zero 16-bit chunks in an IPv6 address. If there is
- a tie, the first sequence of all-zero 16-bit chunks is
- replaced by ::. Single all-zero 16-bit chunks are not
- compressed. The canonical format uses lowercase
- characters and leading zeros are not allowed.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture";
- }
-
- /*** collection of domain name and URI types ***/
-
- typedef domain-name {
- type string {
- pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
- + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
- + '|\.';
- length "1..253";
- }
- description
- "The domain-name type represents a DNS domain name. The
- name SHOULD be fully qualified whenever possible.
-
- Internet domain names are only loosely specified. Section
- 3.5 of RFC 1034 recommends a syntax (modified in Section
- 2.1 of RFC 1123). The pattern above is intended to allow
- for current practice in domain name use, and some possible
- future expansion. It is designed to hold various types of
- domain names, including names used for A or AAAA records
- (host names) and other records, such as SRV records. Note
- that Internet host names have a stricter syntax (described
- in RFC 952) than the DNS recommendations in RFCs 1034 and
- 1123, and that systems that want to store host names in
- schema nodes using the domain-name type are recommended to
- adhere to this stricter standard to ensure interoperability.
-
- The encoding of DNS names in the DNS protocol is limited
- to 255 characters. Since the encoding consists of labels
- prefixed by a length bytes and there is a trailing NULL
- byte, only 253 characters can appear in the textual dotted
- notation.
-
- The description clause of schema nodes using the domain-name
- type MUST describe when and how these names are resolved to
- IP addresses. Note that the resolution of a domain-name value
- may require to query multiple DNS records (e.g., A for IPv4
- and AAAA for IPv6). The order of the resolution process and
- which DNS record takes precedence can either be defined
- explicitely or it may depend on the configuration of the
- resolver.
-
- Domain-name values use the US-ASCII encoding. Their canonical
- format uses lowercase US-ASCII characters. Internationalized
- domain names MUST be encoded in punycode as described in RFC
- 3492";
- reference
- "RFC 952: DoD Internet Host Table Specification
- RFC 1034: Domain Names - Concepts and Facilities
- RFC 1123: Requirements for Internet Hosts -- Application
- and Support
- RFC 2782: A DNS RR for specifying the location of services
- (DNS SRV)
- RFC 3492: Punycode: A Bootstring encoding of Unicode for
- Internationalized Domain Names in Applications
- (IDNA)
- RFC 5891: Internationalizing Domain Names in Applications
- (IDNA): Protocol";
- }
-
- typedef host {
- type union {
- type inet:ip-address;
- type inet:domain-name;
- }
- description
- "The host type represents either an IP address or a DNS
- domain name.";
- }
-
- typedef uri {
- type string;
- description
- "The uri type represents a Uniform Resource Identifier
- (URI) as defined by STD 66.
-
- Objects using the uri type MUST be in US-ASCII encoding,
- and MUST be normalized as described by RFC 3986 Sections
- 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
- percent-encoding is removed, and all case-insensitive
- characters are set to lowercase except for hexadecimal
- digits, which are normalized to uppercase as described in
- Section 6.2.2.1.
-
- The purpose of this normalization is to help provide
- unique URIs. Note that this normalization is not
- sufficient to provide uniqueness. Two URIs that are
- textually distinct after this normalization may still be
- equivalent.
-
- Objects using the uri type may restrict the schemes that
- they permit. For example, 'data:' and 'urn:' schemes
- might not be appropriate.
-
- A zero-length URI is not a valid URI. This can be used to
- express 'URI absent' where required.
-
- In the value set and its semantics, this type is equivalent
- to the Uri SMIv2 textual convention defined in RFC 5017.";
- reference
- "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
- RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
- Group: Uniform Resource Identifiers (URIs), URLs,
- and Uniform Resource Names (URNs): Clarifications
- and Recommendations
- RFC 5017: MIB Textual Conventions for Uniform Resource
- Identifiers (URIs)";
- }
-
- }
+++ /dev/null
- module ietf-yang-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
- prefix "yang";
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Partain
- <mailto:david.partain@ericsson.com>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types.
-
- Copyright (c) 2010 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, is permitted pursuant to, and subject to the license
- terms contained in, the Simplified BSD License set forth in Section
- 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6021; see
- the RFC itself for full legal notices.";
-
- revision 2010-09-24 {
- description
- "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
- }
-
- /*** collection of counter and gauge types ***/
-
- typedef counter32 {
- type uint32;
- description
- "The counter32 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter32 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter32 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter32.
-
- In the value set and its semantics, this type is equivalent
- to the Counter32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef zero-based-counter32 {
- type yang:counter32;
- default "0";
- description
- "The zero-based-counter32 type represents a counter32
- that has the defined 'initial' value zero.
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter32 textual convention of the SMIv2.";
- reference
- "RFC 4502: Remote Network Monitoring Management Information
- Base Version 2";
- }
-
- typedef counter64 {
- type uint64;
- description
- "The counter64 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter64 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter64 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter64.
-
- In the value set and its semantics, this type is equivalent
- to the Counter64 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef zero-based-counter64 {
- type yang:counter64;
- default "0";
- description
- "The zero-based-counter64 type represents a counter64 that
- has the defined 'initial' value zero.
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter64 textual convention of the SMIv2.";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
- }
-
- typedef gauge32 {
- type uint32;
- description
- "The gauge32 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^32-1 (4294967295 decimal), and
- the minimum value cannot be smaller than 0. The value of
- a gauge32 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge32 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the Gauge32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef gauge64 {
- type uint64;
- description
- "The gauge64 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^64-1 (18446744073709551615), and
- the minimum value cannot be smaller than 0. The value of
- a gauge64 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge64 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the CounterBasedGauge64 SMIv2 textual convention defined
- in RFC 2856";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
- }
-
- /*** collection of identifier related types ***/
-
- typedef object-identifier {
- type string {
- pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
- + '(\.(0|([1-9]\d*)))*';
- }
- description
- "The object-identifier type represents administratively
- assigned names in a registration-hierarchical-name tree.
-
- Values of this type are denoted as a sequence of numerical
- non-negative sub-identifier values. Each sub-identifier
- value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
- are separated by single dots and without any intermediate
- whitespace.
-
- The ASN.1 standard restricts the value space of the first
- sub-identifier to 0, 1, or 2. Furthermore, the value space
- of the second sub-identifier is restricted to the range
- 0 to 39 if the first sub-identifier is 0 or 1. Finally,
- the ASN.1 standard requires that an object identifier
- has always at least two sub-identifier. The pattern
- captures these restrictions.
-
- Although the number of sub-identifiers is not limited,
- module designers should realize that there may be
- implementations that stick with the SMIv2 limit of 128
- sub-identifiers.
-
- This type is a superset of the SMIv2 OBJECT IDENTIFIER type
- since it is not restricted to 128 sub-identifiers. Hence,
- this type SHOULD NOT be used to represent the SMIv2 OBJECT
- IDENTIFIER type, the object-identifier-128 type SHOULD be
- used instead.";
- reference
- "ISO9834-1: Information technology -- Open Systems
- Interconnection -- Procedures for the operation of OSI
- Registration Authorities: General procedures and top
- arcs of the ASN.1 Object Identifier tree";
- }
-
-
-
-
- typedef object-identifier-128 {
- type object-identifier {
- pattern '\d*(\.\d*){1,127}';
- }
- description
- "This type represents object-identifiers restricted to 128
- sub-identifiers.
-
- In the value set and its semantics, this type is equivalent
- to the OBJECT IDENTIFIER type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- /*** collection of date and time related types ***/
-
- typedef date-and-time {
- type string {
- pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
- + '(Z|[\+\-]\d{2}:\d{2})';
- }
- description
- "The date-and-time type is a profile of the ISO 8601
- standard for representation of dates and times using the
- Gregorian calendar. The profile is defined by the
- date-time production in Section 5.6 of RFC 3339.
-
- The date-and-time type is compatible with the dateTime XML
- schema type with the following notable exceptions:
-
- (a) The date-and-time type does not allow negative years.
-
- (b) The date-and-time time-offset -00:00 indicates an unknown
- time zone (see RFC 3339) while -00:00 and +00:00 and Z all
- represent the same time zone in dateTime.
-
- (c) The canonical format (see below) of data-and-time values
- differs from the canonical format used by the dateTime XML
- schema type, which requires all times to be in UTC using the
- time-offset 'Z'.
-
- This type is not equivalent to the DateAndTime textual
- convention of the SMIv2 since RFC 3339 uses a different
- separator between full-date and full-time and provides
- higher resolution of time-secfrac.
-
- The canonical format for date-and-time values with a known time
- zone uses a numeric time zone offset that is calculated using
- the device's configured known offset to UTC time. A change of
- the device's offset to UTC time will cause date-and-time values
- to change accordingly. Such changes might happen periodically
- in case a server follows automatically daylight saving time
- (DST) time zone offset changes. The canonical format for
- date-and-time values with an unknown time zone (usually referring
- to the notion of local time) uses the time-offset -00:00.";
- reference
- "RFC 3339: Date and Time on the Internet: Timestamps
- RFC 2579: Textual Conventions for SMIv2
- XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
- }
-
- typedef timeticks {
- type uint32;
- description
- "The timeticks type represents a non-negative integer that
- represents the time, modulo 2^32 (4294967296 decimal), in
- hundredths of a second between two epochs. When a schema
- node is defined that uses this type, the description of
- the schema node identifies both of the reference epochs.
-
- In the value set and its semantics, this type is equivalent
- to the TimeTicks type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
- }
-
- typedef timestamp {
- type yang:timeticks;
- description
- "The timestamp type represents the value of an associated
- timeticks schema node at which a specific occurrence happened.
- The specific occurrence must be defined in the description
- of any schema node defined using this type. When the specific
- occurrence occurred prior to the last time the associated
- timeticks attribute was zero, then the timestamp value is
- zero. Note that this requires all timestamp values to be
- reset to zero when the value of the associated timeticks
- attribute reaches 497+ days and wraps around to zero.
-
- The associated timeticks schema node must be specified
- in the description of any schema node using this type.
-
- In the value set and its semantics, this type is equivalent
- to the TimeStamp textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
- }
-
- /*** collection of generic address types ***/
-
- typedef phys-address {
- type string {
- pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
- }
- description
- "Represents media- or physical-level addresses represented
- as a sequence octets, each octet represented by two hexadecimal
- numbers. Octets are separated by colons. The canonical
- representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the PhysAddress textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
- }
-
- typedef mac-address {
- type string {
- pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
- }
- description
- "The mac-address type represents an IEEE 802 MAC address.
- The canonical representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the MacAddress textual convention of the SMIv2.";
- reference
- "IEEE 802: IEEE Standard for Local and Metropolitan Area
- Networks: Overview and Architecture
- RFC 2579: Textual Conventions for SMIv2";
- }
-
- /*** collection of XML specific types ***/
-
- typedef xpath1.0 {
- type string;
- description
- "This type represents an XPATH 1.0 expression.
-
- When a schema node is defined that uses this type, the
- description of the schema node MUST specify the XPath
- context in which the XPath expression is evaluated.";
- reference
- "XPATH: XML Path Language (XPath) Version 1.0";
- }
-
- }
\ No newline at end of file
*/
package org.opendaylight.yangtools.binding.generator.util;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;
import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.ExtendedType;
-import com.google.common.base.Splitter;
-
/**
* Contains the methods for converting strings to valid JAVA language strings
* (package names, class names, attribute names).
final StringBuilder builder = new StringBuilder();
builder.append(basePackageName);
- final List<QName> pathToNode = schemaPath.getPath();
+ final Iterable<QName> iterable = schemaPath.getPathFromRoot();
+ final Iterator<QName> iterator = iterable.iterator();
+ int size = Iterables.size(iterable);
final int traversalSteps;
if (isUsesAugment) {
- traversalSteps = (pathToNode.size());
+ traversalSteps = size;
} else {
- traversalSteps = (pathToNode.size() - 1);
+ traversalSteps = size - 1;
}
for (int i = 0; i < traversalSteps; ++i) {
builder.append('.');
- String nodeLocalName = pathToNode.get(i).getLocalName();
+ String nodeLocalName = iterator.next().getLocalName();
nodeLocalName = nodeLocalName.replace(':', '.');
nodeLocalName = nodeLocalName.replace('-', '.');
* if the length of the returning string has length 0
*/
private static String replaceWithCamelCase(final String text, final char removalChar) {
+ int toBeRemovedPos = text.indexOf(removalChar);
+ if (toBeRemovedPos == -1) {
+ return text;
+ }
+
StringBuilder sb = new StringBuilder(text);
String toBeRemoved = String.valueOf(removalChar);
-
- int toBeRemovedPos = sb.indexOf(toBeRemoved);
- while (toBeRemovedPos != -1) {
+ do {
sb.replace(toBeRemovedPos, toBeRemovedPos + 1, "");
// check if 'toBeRemoved' character is not the only character in
// 'text'
if (sb.length() == 0) {
throw new IllegalArgumentException("The resulting string can not be empty");
}
- String replacement = String.valueOf(sb.charAt(toBeRemovedPos)).toUpperCase();
- sb.setCharAt(toBeRemovedPos, replacement.charAt(0));
+ char replacement = Character.toUpperCase(sb.charAt(toBeRemovedPos));
+ sb.setCharAt(toBeRemovedPos, replacement);
toBeRemovedPos = sb.indexOf(toBeRemoved);
- }
+ } while (toBeRemovedPos != -1);
+
return sb.toString();
}
import static org.junit.Assert.assertNull;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-
import org.junit.Test;
import org.opendaylight.yangtools.yang.binding.BindingMapping;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
* - without revision </ul>
*/
@Test
- public void testBindingGeneratorUtilMethods() {
+ public void testBindingGeneratorUtilMethods() throws IOException {
List<File> testModels = loadTestResources("/module.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
+ final YangContextParser parser = new YangParserImpl();
+ final Set<Module> modules = parser.parseFiles(testModels).getModules();
String packageName = "";
Module module = null;
for (Module m : modules) {
}
}
if (!isValidLength) {
- throw new IllegalArgumentException(String.format("Invalid length: {}, expected: {}.", «paramName», lengthConstraints));
+ throw new IllegalArgumentException(String.format("Invalid length: %s, expected: %s.", «paramName», lengthConstraints));
}
}
'''
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.*;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.BASE_PKG;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.FS;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_BAR;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_BAZ;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_FOO;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_TEST;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsConstructor;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsField;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsMethod;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsRestrictionCheck;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertFilesCount;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertImplementsIfc;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.cleanUp;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.getSourceFiles;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.testCompilation;
+import com.google.common.collect.Range;
import java.io.File;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.sal.java.api.generator.GeneratorJavaFile;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import com.google.common.collect.Range;
-
/**
* Test correct code generation.
*
List<Range<Integer>> lengthConstraints = new ArrayList<>();
lengthConstraints.add(Range.closed(1, 10));
Object arg = new byte[] {};
- String expectedMsg = String.format("Invalid length: {}, expected: {}.", arg, lengthConstraints);
+ String expectedMsg = String.format("Invalid length: %s, expected: %s.", arg, lengthConstraints);
assertContainsRestrictionCheck(builderObj, m, expectedMsg, arg);
m = assertContainsMethod(builderClass, builderClass, "setIdDecimal64", BigDecimal.class);
}
@Test
- public void bug586Test() throws Exception {
+ public void testBug586() throws Exception {
final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "bug586");
assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "bug586");
cleanUp(sourcesOutputDir, compiledOutputDir);
}
+ /**
+ * Test handling nested uses-augmentations.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBug1172() throws Exception {
+ final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "bug1172");
+ assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
+ final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "bug1172");
+ assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
+
+ generateTestSources("/compilation/bug1172", sourcesOutputDir);
+
+ // Test if sources are compilable
+ testCompilation(sourcesOutputDir, compiledOutputDir);
+
+ cleanUp(sourcesOutputDir, compiledOutputDir);
+ }
+
private void generateTestSources(String resourceDirPath, File sourcesOutputDir) throws Exception {
final List<File> sourceFiles = getSourceFiles(resourceDirPath);
final Set<Module> modulesToBuild = parser.parseYangModels(sourceFiles);
List<Range<Integer>> lengthConstraints = new ArrayList<>();
lengthConstraints.add(Range.closed(5, 11));
arg = "abcd";
- expectedMsg = String.format("Invalid length: {}, expected: {}.", arg, lengthConstraints);
+ expectedMsg = String.format("Invalid length: %s, expected: %s.", arg, lengthConstraints);
assertContainsRestrictionCheck(expectedConstructor, expectedMsg, arg);
obj = expectedConstructor.newInstance("hello world");
assertEquals(obj, defInst.invoke(null, "hello world"));
lengthConstraints.clear();
lengthConstraints.add(Range.closed(6, 10));
arg = "abcde";
- String.format("Invalid length: {}, expected: {}.", arg, lengthConstraints);
+ expectedMsg = String.format("Invalid length: %s, expected: %s.", arg, lengthConstraints);
assertContainsRestrictionCheck(expectedConstructor, expectedMsg, arg);
obj = expectedConstructor.newInstance("helloWorld");
assertEquals(obj, defInst.invoke(null, "helloWorld"));
--- /dev/null
+module nested-uses-augment {
+ yang-version 1;
+ namespace "odl:test:nua";
+ prefix "nua";
+
+ revision "2014-07-11" {
+ }
+
+ grouping machine-types {
+ container types {
+ choice machine-type {
+ }
+ }
+ }
+
+ grouping machine-ext {
+ uses machine-types {
+ augment "types/machine-type" {
+ case type-a {
+ leaf id {
+ type string;
+ }
+ }
+ }
+ }
+ }
+
+ grouping machine-ext2 {
+ uses machine-ext {
+ augment "types/machine-type" {
+ case type-b {
+ leaf name {
+ type string;
+ }
+ }
+ }
+ }
+ }
+
+}
*/
package org.opendaylight.yangtools.sal.binding.yang.types;
+import com.google.common.base.Optional;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
import org.opendaylight.yangtools.binding.generator.util.Types;
import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;
@Override
public List<RangeConstraint> getRangeConstraints() {
- return Collections.singletonList(BaseConstraints.rangeConstraint(min, max, null, null));
+ return Collections.singletonList(BaseConstraints.newRangeConstraint(min, max,
+ Optional.<String> absent(), Optional.<String> absent()));
}
@Override
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import com.google.common.io.BaseEncoding;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.apache.commons.lang3.StringEscapeUtils;
import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
import org.opendaylight.yangtools.binding.generator.util.TypeConstants;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.*;
+import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
-import org.opendaylight.yangtools.yang.model.util.*;
+import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
+import org.opendaylight.yangtools.yang.model.util.EnumerationType;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.model.util.Int16;
+import org.opendaylight.yangtools.yang.model.util.Int32;
+import org.opendaylight.yangtools.yang.model.util.Int64;
+import org.opendaylight.yangtools.yang.model.util.Int8;
+import org.opendaylight.yangtools.yang.model.util.StringType;
+import org.opendaylight.yangtools.yang.model.util.Uint16;
+import org.opendaylight.yangtools.yang.model.util.Uint32;
+import org.opendaylight.yangtools.yang.model.util.Uint64;
+import org.opendaylight.yangtools.yang.model.util.Uint8;
+import org.opendaylight.yangtools.yang.model.util.UnionType;
import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import com.google.common.io.BaseEncoding;
-
public final class TypeProviderImpl implements TypeProvider {
/**
* Contains the schema data red from YANG files.
} else if (base instanceof BitsTypeDefinition) {
String parentName;
String className;
- SchemaPath nodePath = node.getPath();
Module parent = getParentModule(node);
- if (nodePath.getPath().size() == 1) {
+ Iterator<QName> path = node.getPath().getPathFromRoot().iterator();
+ path.next();
+ if (!(path.hasNext())) {
parentName = BindingMapping.getClassName((parent).getName()) + "Data";
String basePackageName = BindingGeneratorUtil.moduleNamespaceToPackageName(parent);
className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
}
private Module getParentModule(SchemaNode node) {
- QName qname = node.getPath().getPath().get(0);
+ QName qname = node.getPath().getPathFromRoot().iterator().next();
URI namespace = qname.getNamespace();
Date revision = qname.getRevision();
return schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
String basePackageName = BindingGeneratorUtil.moduleNamespaceToPackageName(module);
className = basePackageName + "." + BindingMapping.getClassName(typeQName);
} else {
- SchemaPath nodePath = node.getPath();
- if (nodePath.getPath().size() == 1) {
- QName first = nodePath.getPath().get(0);
+ Iterator<QName> path = node.getPath().getPathFromRoot().iterator();
+ QName first = path.next();
+ if (!(path.hasNext())) {
URI namespace = first.getNamespace();
Date revision = first.getRevision();
Module parent = schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
String basePackageName = BindingGeneratorUtil.moduleNamespaceToPackageName(parent);
className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
} else {
- QName first = node.getPath().getPath().get(0);
URI namespace = first.getNamespace();
Date revision = first.getRevision();
Module parentModule = schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
+++ /dev/null
-<project>
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
- <relativePath>/../../common/parent/pom.xml</relativePath>
- </parent>
-
- <artifactId>features-file</artifactId>
- <packaging>pom</packaging>
-
- <properties>
- <features.file>features.xml</features.file>
- </properties>
-
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>filter</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>resources</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <phase>package</phase>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/classes/${features.file}</file>
- <type>xml</type>
- <classifier>features</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
-
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yangtools-parent</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>features-yangtools</artifactId>
+ <packaging>pom</packaging>
+ <properties>
+ <features.file>features.xml</features.file>
+ </properties>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.tooling</groupId>
+ <artifactId>karaf-maven-plugin</artifactId>
+ <version>${karaf.version}</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>features-create-kar</id>
+ <goals>
+ <goal>features-create-kar</goal>
+ </goals>
+ <configuration>
+ <featuresFile>${project.build.directory}/classes/${features.file}</featuresFile>
+ </configuration>
+ </execution>
+ </executions>
+ <!-- There is no useful configuration for the kar mojo. The features-generate-descriptor mojo configuration may be useful -->
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
<features>
<feature name='yangtools-all' version='${project.version}'>
<feature version='${project.version}'>yangtools-models</feature>
<feature version='${project.version}'>yangtools-binding</feature>
+ <feature version='${project.version}'>yangtools-common</feature>
<feature version='${project.version}'>yangtools-concepts</feature>
<feature version='${project.version}'>yangtools-binding-generator</feature>
</feature>
<feature name='yangtools-models' version='${project.version}'>
- <bundle>mvn:org.opendaylight.yangtools.model/ietf-inet-types/2010.09.24.4-SNAPSHOT</bundle>
- <bundle>mvn:org.opendaylight.yangtools.model/ietf-yang-types/2010.09.24.4-SNAPSHOT</bundle>
- <bundle>mvn:org.opendaylight.yangtools.model/yang-ext/2013.09.07.4-SNAPSHOT</bundle>
- <bundle>mvn:org.opendaylight.yangtools.model/opendaylight-l2-types/2013.08.27.4-SNAPSHOT</bundle>
- <bundle>mvn:org.opendaylight.yangtools.model/ietf-topology/2013.10.21.2-SNAPSHOT</bundle>
- <bundle>mvn:org.opendaylight.yangtools.model/opendaylight-l2-types/2013.08.27.4-SNAPSHOT</bundle>
- </feature>
+ <bundle>mvn:org.opendaylight.yangtools.model/ietf-inet-types/${ietf.inet.types.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools.model/ietf-yang-types/${ietf.yang.types.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools.model/yang-ext/${yang.ext.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools.model/opendaylight-l2-types/${opendaylight.l2.types.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools.model/ietf-topology/${ietf.topology.version}</bundle>
+ </feature>
<feature name='yangtools-binding' version='${project.version}'>
<feature version='${project.version}'>yangtools-concepts</feature>
- <bundle>mvn:org.opendaylight.yangtools.thirdparty/antlr4-runtime-osgi-nohead/4.0</bundle>
- <bundle>mvn:commons-io/commons-io/2.4</bundle>
+ <bundle>mvn:org.opendaylight.yangtools.thirdparty/antlr4-runtime-osgi-nohead/${antlr4.version}</bundle>
+ <bundle>mvn:commons-io/commons-io/${commons.io.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/yang-binding/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/yang-data-api/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/yang-data-impl/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools/yang-data-json/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools/yang-data-operations/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools/yang-data-util/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/yang-model-api/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/yang-model-util/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/yang-parser-impl/${project.version}</bundle>
<bundle>wrap:mvn:org.eclipse.xtend/org.eclipse.xtend.lib/${xtend.version}</bundle>
<bundle>wrap:mvn:org.eclipse.xtext/org.eclipse.xtext.xbase.lib/${xtend.version}</bundle>
</feature>
-
+ <feature name="yangtools-common" version='${project.version}'>
+ <bundle>mvn:org.opendaylight.yangtools/util/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools/object-cache-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools/object-cache-guava/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools/object-cache-noop/${project.version}</bundle>
+ </feature>
<feature name='yangtools-binding-generator' version='${project.version}'>
<feature version='${project.version}'>yangtools-binding</feature>
<bundle>mvn:org.javassist/javassist/${javassist.version}</bundle>
- <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang.version}</bundle>
+ <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/binding-generator-api/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/binding-generator-impl/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools/binding-generator-spi/${project.version}</bundle>
</prerequisites>
<properties>
- <junit.version>4.10</junit.version>
+ <antlr4.version>4.0</antlr4.version>
+ <commons.io.version>2.4</commons.io.version>
+ <ctrie.version>0.2.0</ctrie.version>
<exam.version>3.0.0</exam.version>
<groovy.version>2.1.6</groovy.version>
- <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
- <ctrie.version>0.2.0</ctrie.version>
<ietf.topology.version>2013.10.21.2-SNAPSHOT</ietf.topology.version>
<ietf.inet.types.version>2010.09.24.4-SNAPSHOT</ietf.inet.types.version>
<ietf.yang.types.version>2010.09.24.4-SNAPSHOT</ietf.yang.types.version>
- <ietf.restconf.version>2013.09.04.1-SNAPSHOT</ietf.restconf.version>
+ <ietf.restconf.version>2013.10.19.1-SNAPSHOT</ietf.restconf.version>
+ <junit.version>4.10</junit.version>
+ <karaf.version>3.0.1</karaf.version>
+ <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
+ <opendaylight.l2.types.version>2013.08.27.4-SNAPSHOT</opendaylight.l2.types.version>
+ <yang.ext.version>2013.09.07.4-SNAPSHOT</yang.ext.version>
<maven.javadoc.version>2.9.1</maven.javadoc.version>
</properties>
<version>0.6.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>bug1196-test-model</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<modules>
<module>checkstyle-logging</module>
<module>concepts</module>
- <module>feature</module>
+ <module>features</module>
<module>mockito-configuration</module>
<module>object-cache-api</module>
<module>object-cache-guava</module>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!-- Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. This
+ program and the accompanying materials are made available under the terms of the
+ Eclipse Public License v1.0 which accompanies this distribution, and is available
+ at http://www.eclipse.org/legal/epl-v10.html -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yangtools-parent</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ <relativePath>/../../common/parent/pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>bug1196-test-model</artifactId>
+ <name>${project.artifactId}</name>
+ <description>${project.artifactId}</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-binding</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>yang-ext</artifactId>
+ <version>2013.09.07.4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-inet-types</artifactId>
+ <version>2010.09.24.4-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>org.opendaylight.yangtools.model.${project.artifactId}</Bundle-Name>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-binding</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>yang-ext</artifactId>
+ <version>2013.09.07.4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-inet-types</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+module network-topology-pcep {
+ // vi: set et smarttab sw=4 tabstop=4:
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:topology:pcep";
+ prefix "pn";
+
+ import network-topology { prefix nt; revision-date 2013-10-21; }
+
+ revision "2013-10-24" {
+ }
+
+
+ grouping pcep-client-attributes {
+ container path-computation-client {
+ config false;
+ list reported-lsp {
+ leaf name {
+ type string;
+ }
+ key name;
+ }
+ }
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:node" {
+ when "../../nt:topology-types/topology-pcep";
+
+ uses pcep-client-attributes;
+ }
+
+}
+
--- /dev/null
+module network-topology-unix {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:network:topology-unix";
+ prefix "unix";
+
+ import network-topology { prefix nt; revision-date 2013-10-21; }
+ import network-topology-pcep { prefix topo; revision-date 2013-10-24; }
+ import odl-pcep-ietf-stateful07 { prefix stateful; revision-date 2013-12-22; }
+
+ revision "2013-12-22" {
+ }
+
+
+ augment "/nt:network-topology/nt:topology/nt:node/topo:path-computation-client/topo:reported-lsp/stateful:lsp/stateful:tlvs/stateful:vs-tlv/stateful:vendor-payload" {
+ case unix {
+ container unix-sub-tlvs {
+ leaf unix-value {
+ type uint8;
+ }
+ }
+ }
+ }
+
+}
+
--- /dev/null
+module network-topology {
+ yang-version 1;
+ namespace "urn:TBD:params:xml:ns:yang:network-topology";
+ prefix "nt";
+
+
+ revision 2013-10-21 {
+ }
+
+
+
+ container network-topology {
+ list topology {
+ key "topology-id";
+ leaf topology-id {
+ type string;
+ }
+ list node {
+ }
+ }
+ }
+}
+
--- /dev/null
+module odl-pcep-ietf-stateful07 {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:pcep:ietf:stateful";
+ prefix "stateful";
+
+ import network-topology { prefix nt; revision-date 2013-10-21; }
+ import network-topology-pcep { prefix topo; revision-date 2013-10-24; }
+ import pcep-types { prefix pcep; revision-date 2013-10-05; }
+ import yang-ext { prefix ext; revision-date 2013-07-09; }
+
+ revision "2013-12-22" {
+ }
+
+
+ grouping lsp-object {
+ container lsp {
+ container "tlvs" {
+ uses pcep:vs-tlv;
+ }
+ }
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:node/topo:path-computation-client/topo:reported-lsp" {
+ uses lsp-object;
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:node/topo:path-computation-client/topo:reported-lsp/stateful:lsp/stateful:tlvs/stateful:vs-tlv/stateful:vendor-payload" {
+ case linux {
+ container linux-sub-tlvs {
+ leaf linux-value {
+ type uint8;
+ }
+ }
+ }
+ }
+
+}
+
--- /dev/null
+module pcep-types {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:pcep:types";
+ prefix "pcep-t";
+
+ revision "2013-10-05" {
+ }
+
+
+ grouping vs-tlv {
+ description "Vendor-specific TLV.";
+ container vs-tlv {
+ choice vendor-payload {
+ }
+ }
+ }
+
+}
+
<modules>
<module>bug527-test-model</module>
+ <module>bug1196-test-model</module>
<module>bundle-test</module>
<module>test-models</module>
<module>regression-test-model</module>
<ietf.topology.version>2013.10.21.2-SNAPSHOT</ietf.topology.version>
<ietf.inet.types.version>2010.09.24.4-SNAPSHOT</ietf.inet.types.version>
<ietf.yang.types.version>2010.09.24.4-SNAPSHOT</ietf.yang.types.version>
- <ietf.restconf.version>2013.09.04.1-SNAPSHOT</ietf.restconf.version>
+ <ietf.restconf.version>2013.10.19.1-SNAPSHOT</ietf.restconf.version>
</properties>
<modules>
<version>0.6.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>bug1196-test-model</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.utils;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Map.Entry;
+
+import javassist.ClassPool;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.unix.rev131222.network.topology.topology.node.path.computation.client.reported.lsp.lsp.tlvs.vs.tlv.vendor.payload.unix.UnixSubTlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.ReportedLsp1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.network.topology.topology.node.path.computation.client.reported.lsp.lsp.tlvs.vs.tlv.vendor.payload.linux.LinuxSubTlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vs.tlv.VsTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.Node1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.PathComputationClient;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.ReportedLsp;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+
+public class Bug1196Test {
+
+ private static final InstanceIdentifier<PathComputationClient> PATH_TO_CLIENT = InstanceIdentifier.builder(NetworkTopology.class)
+ .child(Topology.class)
+ .child(Node.class)
+ .augmentation(Node1.class)
+ .child(PathComputationClient.class)
+ .build();
+ private RuntimeGeneratedMappingServiceImpl mappingService;
+
+ @Before
+ public void setup() {
+ this.mappingService = new RuntimeGeneratedMappingServiceImpl(new ClassPool());
+
+ final ModuleInfoBackedContext moduleInfo = ModuleInfoBackedContext.create();
+ moduleInfo.addModuleInfos(BindingReflections.loadModuleInfos());
+ this.mappingService.onGlobalContextUpdated(moduleInfo.tryToCreateSchemaContext().get());
+ }
+
+ @Test
+ public void testXmlDataToDataObjectLinuxCase() {
+ final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+ final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-linux.xml");
+ final DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
+ this.mappingService.getSchemaContext()).getValue();
+ Topology topology = (Topology) RestconfUtils.dataObjectFromInputStream(instanceIdentifier, is,
+ this.mappingService.getSchemaContext(), this.mappingService, dataSchema);
+ assertNotNull(topology);
+ assertNotNull(topology.getNode());
+ assertEquals(1, topology.getNode().size());
+ Node node = topology.getNode().get(0);
+ Node1 node1 = node.getAugmentation(Node1.class);
+ assertNotNull(node1);
+ final PathComputationClient pcc = node1.getPathComputationClient();
+ final Lsp lsp = pcc.getReportedLsp().get(0).getAugmentation(ReportedLsp1.class).getLsp();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
+ assertNotNull(tlvs);
+ VsTlv vsTlv = tlvs.getVsTlv();
+ assertNotNull(vsTlv.getVendorPayload());
+
+ Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> domPcc = mappingService.toDataDom(new SimpleEntry<InstanceIdentifier<?>,DataObject>(PATH_TO_CLIENT,pcc));
+ CompositeNode domPccValue = domPcc.getValue();
+ assertNotNull(domPccValue);
+ CompositeNode domPccTlvs = getFirstReportedLspVsTlvs(domPccValue);
+ assertNotNull(domPccTlvs);
+ assertNotNull(domPccTlvs.getFirstCompositeByName(LinuxSubTlvs.QNAME));
+
+ }
+
+ private CompositeNode getFirstReportedLspVsTlvs(final CompositeNode domPccValue) {
+ return domPccValue.getFirstCompositeByName(ReportedLsp.QNAME).getFirstCompositeByName(Lsp.QNAME).getFirstCompositeByName(Tlvs.QNAME).getFirstCompositeByName(QName.create(Tlvs.QNAME,VsTlv.QNAME.getLocalName()));
+ }
+
+ @Test
+ public void testXmlDataToDataObjectUnixCase() {
+ final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+ final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-unix.xml");
+ final DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
+ this.mappingService.getSchemaContext()).getValue();
+ Topology topology = (Topology) RestconfUtils.dataObjectFromInputStream(instanceIdentifier, is,
+ this.mappingService.getSchemaContext(), this.mappingService, dataSchema);
+ assertNotNull(topology);
+ assertNotNull(topology.getNode());
+ assertEquals(1, topology.getNode().size());
+ Node node = topology.getNode().get(0);
+ Node1 node1 = node.getAugmentation(Node1.class);
+ assertNotNull(node1);
+ final PathComputationClient pcc = node1.getPathComputationClient();
+ final Lsp lsp = pcc.getReportedLsp().get(0).getAugmentation(ReportedLsp1.class).getLsp();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
+ assertNotNull(tlvs);
+ VsTlv vsTlv = tlvs.getVsTlv();
+ assertNotNull(vsTlv.getVendorPayload());
+
+ Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> domPcc = mappingService.toDataDom(new SimpleEntry<InstanceIdentifier<?>,DataObject>(PATH_TO_CLIENT,pcc));
+ CompositeNode domPccValue = domPcc.getValue();
+ assertNotNull(domPccValue);
+ CompositeNode domPccTlvs = getFirstReportedLspVsTlvs(domPccValue);
+ assertNotNull(domPccTlvs);
+ assertNotNull(domPccTlvs.getFirstCompositeByName(UnixSubTlvs.QNAME));
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. This
+ program and the accompanying materials are made available under the terms of the
+ Eclipse Public License v1.0 which accompanies this distribution, and is available
+ at http://www.eclipse.org/legal/epl-v10.html -->
+<topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
+ <server-provided>true</server-provided>
+ <topology-id>example-pcep-topology</topology-id>
+ <topology-types/>
+ <node>
+ <path-computation-client xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep">
+ <state-sync>synchronized</state-sync>
+ <stateful-tlv>
+ <stateful>
+ <lsp-update-capability>true</lsp-update-capability>
+ <include-db-version>false</include-db-version>
+ <initiation>true</initiation>
+ </stateful>
+ </stateful-tlv>
+ <reported-lsp>
+ <name>update-tunel</name>
+ <path>
+ <bandwidth>
+ <bandwidth>AAAAAA==</bandwidth>
+ <ignore>false</ignore>
+ <processing-rule>false</processing-rule>
+ </bandwidth>
+ <ero>
+ <ignore>false</ignore>
+ <processing-rule>false</processing-rule>
+ <subobject>
+ <loose>false</loose>
+ <ip-prefix>
+ <ip-prefix>195.20.160.40/32</ip-prefix>
+ </ip-prefix>
+ </subobject>
+ <subobject>
+ <loose>false</loose>
+ <ip-prefix>
+ <ip-prefix>201.20.160.43/32</ip-prefix>
+ </ip-prefix>
+ </subobject>
+ </ero>
+ <lspa>
+ <exclude-any>0</exclude-any>
+ <hold-priority>7</hold-priority>
+ <ignore>false</ignore>
+ <include-all>0</include-all>
+ <include-any>0</include-any>
+ <local-protection-desired>false</local-protection-desired>
+ <processing-rule>false</processing-rule>
+ <setup-priority>7</setup-priority>
+ </lspa>
+ </path>
+ <lsp xmlns="urn:opendaylight:params:xml:ns:yang:pcep:ietf:stateful">
+ <tlvs>
+ <symbolic-path-name>
+ <path-name>dXBkYXRlLXR1bmVs</path-name>
+ </symbolic-path-name>
+ <vs-tlv>
+ <enterprise-number>9</enterprise-number>
+ <linux-sub-tlvs>
+ <linux-value>5</linux-value>
+ </linux-sub-tlvs>
+ </vs-tlv>
+ </tlvs>
+ <delegate>true</delegate>
+ <processing-rule>false</processing-rule>
+ <ignore>false</ignore>
+ <operational>true</operational>
+ <sync>false</sync>
+ <plsp-id>40</plsp-id>
+ <remove>false</remove>
+ </lsp>
+ </reported-lsp>
+ <ip-address>39.39.39.39</ip-address>
+ </path-computation-client>
+ <node-id>pcc://39.39.39.39</node-id>
+ </node>
+</topology>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. This
+ program and the accompanying materials are made available under the terms of the
+ Eclipse Public License v1.0 which accompanies this distribution, and is available
+ at http://www.eclipse.org/legal/epl-v10.html -->
+<topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
+ <server-provided>true</server-provided>
+ <topology-id>example-pcep-topology</topology-id>
+ <topology-types/>
+ <node>
+ <path-computation-client xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep">
+ <state-sync>synchronized</state-sync>
+ <stateful-tlv>
+ <stateful>
+ <lsp-update-capability>true</lsp-update-capability>
+ <include-db-version>false</include-db-version>
+ <initiation>true</initiation>
+ </stateful>
+ </stateful-tlv>
+ <reported-lsp>
+ <name>update-tunel</name>
+ <path>
+ <bandwidth>
+ <bandwidth>AAAAAA==</bandwidth>
+ <ignore>false</ignore>
+ <processing-rule>false</processing-rule>
+ </bandwidth>
+ <ero>
+ <ignore>false</ignore>
+ <processing-rule>false</processing-rule>
+ <subobject>
+ <loose>false</loose>
+ <ip-prefix>
+ <ip-prefix>195.20.160.40/32</ip-prefix>
+ </ip-prefix>
+ </subobject>
+ <subobject>
+ <loose>false</loose>
+ <ip-prefix>
+ <ip-prefix>201.20.160.43/32</ip-prefix>
+ </ip-prefix>
+ </subobject>
+ </ero>
+ <lspa>
+ <exclude-any>0</exclude-any>
+ <hold-priority>7</hold-priority>
+ <ignore>false</ignore>
+ <include-all>0</include-all>
+ <include-any>0</include-any>
+ <local-protection-desired>false</local-protection-desired>
+ <processing-rule>false</processing-rule>
+ <setup-priority>7</setup-priority>
+ </lspa>
+ </path>
+ <lsp xmlns="urn:opendaylight:params:xml:ns:yang:pcep:ietf:stateful">
+ <tlvs>
+ <symbolic-path-name>
+ <path-name>dXBkYXRlLXR1bmVs</path-name>
+ </symbolic-path-name>
+ <vs-tlv>
+ <enterprise-number>9</enterprise-number>
+ <unix-sub-tlvs xmlns="urn:opendaylight:params:xml:ns:yang:network:topology-unix">
+ <unix-value>5</unix-value>
+ </unix-sub-tlvs>
+ </vs-tlv>
+ </tlvs>
+ <delegate>true</delegate>
+ <processing-rule>false</processing-rule>
+ <ignore>false</ignore>
+ <operational>true</operational>
+ <sync>false</sync>
+ <plsp-id>40</plsp-id>
+ <remove>false</remove>
+ </lsp>
+ </reported-lsp>
+ <ip-address>39.39.39.39</ip-address>
+ </path-computation-client>
+ <node-id>pcc://39.39.39.39</node-id>
+ </node>
+</topology>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
<name>${project.artifactId}</name>
<description>Java binding for YANG</description>
*/
package org.opendaylight.yangtools.yang.binding;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.Path;
-
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.concepts.Path;
/**
*
* Interface which implementations are used as path components of the
* path in overall data tree.
*/
- public interface PathArgument {
+ public interface PathArgument extends Comparable<PathArgument> {
Class<? extends DataObject> getType();
}
final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
return type.equals(other.type);
}
+
+ @Override
+ public int compareTo(PathArgument arg) {
+ return type.getCanonicalName().compareTo(arg.getType().getCanonicalName());
+ }
}
/**
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-
import org.opendaylight.yangtools.yang.binding.Augmentable;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-
public class DataObjectReadingUtil {
private DataObjectReadingUtil() {
checkArgument(childPath != null, "Child path must not be null");
checkArgument(parentPath.containsWildcarded(childPath), "Parent object must be parent of child.");
- final int commonOffset = parentPath.getPath().size();
- final int lastIndex = childPath.getPath().size();
- List<PathArgument> pathArgs = childPath.getPath().subList(commonOffset, lastIndex);
-
+ List<PathArgument> pathArgs = subList(parentPath.getPathArguments(), childPath.getPathArguments());
@SuppressWarnings("rawtypes")
Map<InstanceIdentifier, DataContainer> lastFound = Collections
.<InstanceIdentifier, DataContainer> singletonMap(parentPath, parent);
return (DataContainer) potential;
}
}
+
+ /**
+ * Create sublist view of child from element on [size-of-parent] position to
+ * last element.
+ *
+ * @param parent
+ * @param child
+ * @return sublist view of child argument
+ * @throws IllegalArgumentException
+ * if parent argument is bigger than child
+ */
+ private static <P, C> List<C> subList(Iterable<P> parent, Iterable<C> child) {
+ Iterator<P> iParent = parent.iterator();
+ List<C> result = new ArrayList<>();
+ for (C arg : child) {
+ if (iParent.hasNext()) {
+ iParent.next();
+ } else {
+ result.add(arg);
+ }
+ }
+ if (iParent.hasNext()) {
+ throw new IllegalArgumentException("Parent argument is bigger than child.");
+ }
+ return result;
+ }
+
}
throw new IllegalArgumentException("Invalid input:" + input);
}
+ /**
+ * Get the module component of the QName.
+ *
+ * @return Module component
+ */
+ public QNameModule getModule() {
+ return module;
+ }
+
/**
* Returns XMLNamespace assigned to the YANG module.
*
return new QName(base, localName);
}
+ public static QName create(final QNameModule module, final String prefix, final String localName) {
+ if (module == null) {
+ throw new NullPointerException("module may not be null");
+ }
+ return new QName(module, prefix, localName);
+ }
+
/**
*
* Creates new QName.
* @return Instance of QName
*/
public static QName create(final URI namespace, final Date revision, final String localName) {
- return new QName(QNameModule.create(namespace, revision), null,localName);
+ return new QName(QNameModule.create(namespace, revision), null, localName);
}
/**
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class QNameModule implements Immutable, Serializable {
+public final class QNameModule implements Immutable, Serializable {
private static final Logger LOG = LoggerFactory.getLogger(QNameModule.class);
private static final long serialVersionUID = 1L;
import org.opendaylight.yangtools.yang.common.QName;
+/**
+ *
+ * Container of attributes, which may be attached to {@link Node}
+ *
+ */
public interface AttributesContainer {
+ /**
+ * Returns immutable map of QName and value of the attribute.
+ *
+ * @return immutable map of attribute names and values.
+ */
Map<QName, String> getAttributes();
- Object getAttributeValue(QName value);
+ /**
+ * Returns attribute value by supplied QName
+ *
+ *
+ * @param name Attribute name
+ * @return Value of attribute if present, null otherwise.
+ */
+ Object getAttributeValue(QName name);
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.yangtools.yang.data.api;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
-
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.concepts.Path;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
+/**
+ * Unique identifier of a partical node instance in the data tree.
+ *
+ *
+ * <p>
+ * Java representation of YANG Built-in type <code>instance-identifier</code>,
+ * which conceptually is XPath expression minimised to uniquely identify element
+ * in data tree which conforms to constraints maintained by YANG Model,
+ * effectively this makes Instance Identifier a path to element in data tree.
+ * <p>
+ * Constraints put in YANG specification on instance-identifier allowed it to be
+ * effectively represented in Java and it's evaluation does not require
+ * full-blown XPath processor.
+ * <p>
+ * <h3>Path Arguments</h3>
+ * Path to the node represented in instance identifier consists of
+ * {@link PathArgument} which carries necessary information to uniquely identify
+ * node on particular level in the subtree.
+ * <p>
+ * <ul>
+ * <li>{@link NodeIdentifier} - Identifier of node, which has cardinality
+ * <code>0..1</code> in particular subtree in data tree.</li>
+ * <li>{@link NodeIdentifierWithPredicates} - Identifier of node (list item),
+ * which has cardinality <code>0..n</code>.</li>
+ * <li>{@link NodeWithValue} - Identifier of instance <code>leaf</code> node or
+ * <code>leaf-list</code> node.</li>
+ * <li>{@link AugmentationIdentifier} - Identifier of instance of
+ * <code>augmentation</code> node.</li>
+ * </ul>
+ *
+ *
+ * @see http://tools.ietf.org/html/rfc6020#section-9.13
+ *
+ *
+ */
public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable, Serializable {
private static final long serialVersionUID = 8467409862384206193L;
private transient String toStringCache = null;
private transient Integer hashCodeCache = null;
+ /**
+ *
+ * Returns a list of path arguments.
+ *
+ * @deprecated Use {@link #getPathArguments()} instead.
+ * @return Immutable list of path arguments.
+ */
+ @Deprecated
public List<PathArgument> getPath() {
return path;
}
+ /**
+ *
+ * Returns a ordered iteration of path arguments.
+ *
+ * @return Immutable iteration of path arguments.
+ */
+ public Iterable<PathArgument> getPathArguments() {
+ return path;
+ }
+
+ /**
+ *
+ *
+ * @deprecated Use {@link #create(Iterable)} instead.
+ * @param path
+ */
+ @Deprecated
public InstanceIdentifier(final List<? extends PathArgument> path) {
this.path = ImmutableList.copyOf(path);
}
+ private InstanceIdentifier(final Iterable<? extends PathArgument> path) {
+ Preconditions.checkNotNull(path, "path must not be null.");
+ this.path = ImmutableList.copyOf(path);
+ }
+
private InstanceIdentifier(final NodeIdentifier nodeIdentifier) {
this.path = ImmutableList.<PathArgument> of(nodeIdentifier);
}
+ public static final InstanceIdentifier create(final Iterable<? extends PathArgument> path) {
+ return new InstanceIdentifier(path);
+ }
+
@Override
public int hashCode() {
/*
* The hashCodeCache is safe, since the object contract requires
* immutability of the object and all objects referenced from this
* object.
- *
* Used lists, maps are immutable. Path Arguments (elements) are also
* immutable, since the PathArgument contract requires immutability.
- *
* The cache is thread-safe - if multiple computations occurs at the
* same time, cache will be overwritten with same result.
*/
if (hashCodeCache == null) {
final int prime = 31;
int result = 1;
- result = prime * result + ((path == null) ? 0 : path.hashCode());
+ result = prime * result + path.hashCode();
hashCodeCache = result;
}
return hashCodeCache;
return true;
}
+ /**
+ *
+ * Constructs a new Instance Identifier with new {@link NodeIdentifier} added to the end of path arguments
+ *
+ * @param name QName of {@link NodeIdentifier}
+ * @return Instance Identifier with additional path argument added to the end.
+ */
public InstanceIdentifier node(final QName name) {
return node(new NodeIdentifier(name));
}
+ /**
+ *
+ * Constructs a new Instance Identifier with new {@link PathArgument} added to the end of path arguments
+ *
+ * @param arg Path argument which should be added to the end
+ * @return Instance Identifier with additional path argument added to the end.
+ */
public InstanceIdentifier node(final PathArgument arg) {
- return new InstanceIdentifier(ImmutableList.<PathArgument>builder().addAll(path).add(arg).build());
+ return create(ImmutableList.<PathArgument> builder().addAll(path).add(arg).build());
}
/**
- * Get the relative path from an ancestor. This method attempts to perform the reverse
+ * Get the relative path from an ancestor. This method attempts to perform
+ * the reverse
* of concatenating a base (ancestor) and a path.
*
- * @param ancestor Ancestor against which the relative path should be calculated
- * @return This object's relative path from parent, or Optional.absent() if the
+ * @param ancestor
+ * Ancestor against which the relative path should be calculated
+ * @return This object's relative path from parent, or Optional.absent() if
+ * the
* specified parent is not in fact an ancestor of this object.
*/
public Optional<InstanceIdentifier> relativeTo(final InstanceIdentifier ancestor) {
}
}
- static int hashCode( Object value ) {
- if( value == null ) {
+ static int hashCode(final Object value) {
+ if (value == null) {
return 0;
}
- if( value.getClass().equals( byte[].class ) ) {
- return Arrays.hashCode( (byte[])value );
+ if (value.getClass().equals(byte[].class)) {
+ return Arrays.hashCode((byte[]) value);
}
- if( value.getClass().isArray() ) {
+ if (value.getClass().isArray()) {
int hash = 0;
- int length = Array.getLength( value );
- for( int i = 0; i < length; i++ ) {
- hash += Objects.hashCode( Array.get( value, i ) );
+ int length = Array.getLength(value);
+ for (int i = 0; i < length; i++) {
+ hash += Objects.hashCode(Array.get(value, i));
}
return hash;
}
- return Objects.hashCode( value );
+ return Objects.hashCode(value);
}
// Static factories & helpers
+ /**
+ *
+ * Returns a new InstanceIdentifier with only one path argument of type {@link NodeIdentifier} with supplied QName
+ *
+ * @param name QName of first node identifier
+ * @return Instance Identifier with only one path argument of type {@link NodeIdentifier}
+ */
public static InstanceIdentifier of(final QName name) {
return new InstanceIdentifier(new NodeIdentifier(name));
}
+ /**
+ *
+ * Returns new builder for InstanceIdentifier with empty path arguments.
+ *
+ * @return new builder for InstanceIdentifier with empty path arguments.
+ */
static public InstanceIdentifierBuilder builder() {
return new BuilderImpl();
}
+ /**
+ *
+ * Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.
+ *
+ * @param origin Instace Identifier from which path arguments are copied.
+ * @return new builder for InstanceIdentifier with path arguments copied from original instance identifier.
+ */
static public InstanceIdentifierBuilder builder(final InstanceIdentifier origin) {
return new BuilderImpl(origin.getPath());
}
-
+ /**
+ *
+ * Returns new builder for InstanceIdentifier with first path argument set to {@link NodeIdentifier}.
+ *
+ * @param node QName of first {@link NodeIdentifier} path argument.
+ * @return new builder for InstanceIdentifier with first path argument set to {@link NodeIdentifier}.
+ */
public static InstanceIdentifierBuilder builder(final QName node) {
return builder().node(node);
}
- public interface PathArgument extends Immutable, Serializable {
+ /**
+ *
+ * Path argument / component of InstanceIdentifier
+ *
+ * Path argument uniquelly identifies node in data tree on particular
+ * level.
+ * <p>
+ * This interface itself is used as common parent for actual
+ * path arguments types and should not be implemented by user code.
+ * <p>
+ * Path arguments SHOULD contain only minimum of information
+ * required to uniquely identify node on particular subtree level.
+ *
+ * For actual path arguments types see:
+ * <ul>
+ * <li>{@link NodeIdentifier} - Identifier of container or leaf
+ * <li>{@link NodeIdentifierWithPredicates} - Identifier of list entries, which have key defined
+ * <li>{@link AugmentationIdentifier} - Identifier of augmentation
+ * <li>{@link NodeWithValue} - Identifier of leaf-list entry
+ * </ul>
+ *
+ *
+ *
+ */
+ public interface PathArgument extends Comparable<PathArgument>, Immutable, Serializable {
/**
- * If applicable returns uniqee QName of data node as defined in YANG
+ * If applicable returns unique QName of data node as defined in YANG
* Schema.
*
* This method may return null, if the corresponding schema node, does
}
+ private static abstract class AbstractPathArgument implements PathArgument {
+ private static final long serialVersionUID = -4546547994250849340L;
+ protected final QName nodeType;
+
+ protected AbstractPathArgument(final QName nodeType) {
+ this.nodeType = Preconditions.checkNotNull(nodeType);
+ }
+
+ @Override
+ public QName getNodeType() {
+ return nodeType;
+ }
+
+ @Override
+ public int compareTo(final PathArgument o) {
+ return nodeType.compareTo(o.getNodeType());
+ }
+
+ }
+
+ /**
+ *
+ * Fluent Builder of Instance Identifier instances
+ *
+ * @
+ *
+ */
public interface InstanceIdentifierBuilder extends Builder<InstanceIdentifier> {
+
+ /**
+ *
+ * Adds {@link NodeIdentifier} with supplied QName to path arguments of resulting instance identifier.
+ *
+ * @param nodeType QName of {@link NodeIdentifier} which will be added
+ * @return this builder
+ */
InstanceIdentifierBuilder node(QName nodeType);
+ /**
+ *
+ * Adds {@link NodeIdentifierWithPredicates} with supplied QName and key values to path arguments of resulting instance identifier.
+ *
+ * @param nodeType QName of {@link NodeIdentifierWithPredicates} which will be added
+ * @param keyValues Map of key components and their respective values for {@link NodeIdentifierWithPredicates}
+ * @return this builder
+ */
InstanceIdentifierBuilder nodeWithKey(QName nodeType, Map<QName, Object> keyValues);
+ /**
+ *
+ * Adds {@link NodeIdentifierWithPredicates} with supplied QName and key, value.
+ *
+ * @param nodeType QName of {@link NodeIdentifierWithPredicates} which will be added
+ * @param key QName of key which will be added
+ * @param value value of key which will be added
+ * @return this builder
+ */
InstanceIdentifierBuilder nodeWithKey(QName nodeType, QName key, Object value);
+ /**
+ *
+ * @return
+ * @deprecated use {@link #build()}
+ *
+ */
@Deprecated
InstanceIdentifier getIdentifier();
+ /**
+ *
+ * Builds an {@link InstanceIdentifier} with path arguments from this builder
+ *
+ * @return {@link InstanceIdentifier}
+ */
InstanceIdentifier build();
}
/**
- * Simple path argument identifying a {@link ContainerNode} or {@link LeafNode} leaf
- * overall data tree.
+ * Simple path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.ContainerNode} or
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} leaf in particular subtree.
*/
- public static final class NodeIdentifier implements PathArgument, Comparable<NodeIdentifier> {
+ public static final class NodeIdentifier extends AbstractPathArgument {
private static final long serialVersionUID = -2255888212390871347L;
- private final QName nodeType;
public NodeIdentifier(final QName node) {
- this.nodeType = Preconditions.checkNotNull(node);
- }
-
- @Override
- public QName getNodeType() {
- return nodeType;
+ super(node);
}
@Override
return nodeType.toString();
}
- @Override
- public int compareTo(final NodeIdentifier o) {
- return nodeType.compareTo(o.nodeType);
- }
}
/**
- * Composite path argument identifying a {@link MapEntryNode} leaf
+ * Composite path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode} leaf
* overall data tree.
*/
- public static final class NodeIdentifierWithPredicates implements PathArgument {
+ public static final class NodeIdentifierWithPredicates extends AbstractPathArgument {
private static final long serialVersionUID = -4787195606494761540L;
- private final QName nodeType;
private final Map<QName, Object> keyValues;
public NodeIdentifierWithPredicates(final QName node, final Map<QName, Object> keyValues) {
- this.nodeType = Preconditions.checkNotNull(node);
+ super(node);
this.keyValues = ImmutableMap.copyOf(keyValues);
}
public NodeIdentifierWithPredicates(final QName node, final QName key, final Object value) {
- this( node, ImmutableMap.of(key, value) );
+ this(node, ImmutableMap.of(key, value));
}
@Override
private int hashKeyValues() {
int hash = 0;
- for( Entry<QName,Object> entry: keyValues.entrySet() ) {
- hash += Objects.hashCode( entry.getKey() ) + InstanceIdentifier.hashCode( entry.getValue() );
+ for (Entry<QName, Object> entry : keyValues.entrySet()) {
+ hash += Objects.hashCode(entry.getKey()) + InstanceIdentifier.hashCode(entry.getValue());
}
return hash;
return true;
}
- private boolean keyValuesEquals( Map<QName, Object> otherKeyValues ) {
- if( otherKeyValues == null || keyValues.size() != otherKeyValues.size() ) {
+ private boolean keyValuesEquals(final Map<QName, Object> otherKeyValues) {
+ if (otherKeyValues == null || keyValues.size() != otherKeyValues.size()) {
return false;
}
boolean result = true;
- for( Entry<QName,Object> entry: keyValues.entrySet() ) {
- if( !otherKeyValues.containsKey( entry.getKey() ) ||
- !Objects.deepEquals( entry.getValue(), otherKeyValues.get( entry.getKey() ) ) ) {
+ for (Entry<QName, Object> entry : keyValues.entrySet()) {
+ if (!otherKeyValues.containsKey(entry.getKey())
+ || !Objects.deepEquals(entry.getValue(), otherKeyValues.get(entry.getKey()))) {
result = false;
break;
* Simple path argument identifying a {@link LeafSetEntryNode} leaf
* overall data tree.
*/
- public static final class NodeWithValue implements PathArgument {
+ public static final class NodeWithValue extends AbstractPathArgument {
private static final long serialVersionUID = -3637456085341738431L;
- private final QName nodeType;
private final Object value;
public NodeWithValue(final QName node, final Object value) {
- this.nodeType = Preconditions.checkNotNull(node);
+ super(node);
this.value = value;
}
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((value == null) ? 0 : InstanceIdentifier.hashCode( value ) );
+ result = prime * result + ((value == null) ? 0 : InstanceIdentifier.hashCode(value));
result = prime * result + ((nodeType == null) ? 0 : nodeType.hashCode());
return result;
}
}
/**
- * Composite path argument identifying a {@link AugmentationNode} leaf
- * overall data tree.
+ * Composite path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode} node in
+ * particular subtree.
+ *
+ * Augmentation is uniquely identified by set of all possible child nodes.
+ * This is possible
+ * to identify instance of augmentation,
+ * since RFC6020 states that <code>augment</code> that augment
+ * statement must not add multiple nodes from same namespace
+ * / module to the target node.
+ *
+ *
+ * @see http://tools.ietf.org/html/rfc6020#section-7.15
*/
public static final class AugmentationIdentifier implements PathArgument {
private static final long serialVersionUID = -8122335594681936939L;
throw new UnsupportedOperationException("Augmentation node has no QName");
}
+ /**
+ *
+ * Construct new augmentation identifier using supplied set of possible
+ * child nodes
+ *
+ * @param childNames
+ * Set of possible child nodes.
+ */
public AugmentationIdentifier(final Set<QName> childNames) {
this.childNames = ImmutableSet.copyOf(childNames);
}
/**
* Augmentation node has no QName
+ *
+ * @deprecated Use
+ * {@link AugmentationIdentifier#AugmentationIdentifier(Set)}
+ * instead.
*/
@Deprecated
public AugmentationIdentifier(final QName nodeType, final Set<QName> childNames) {
this(childNames);
}
+ /**
+ *
+ * Returns set of all possible child nodes
+ *
+ * @return set of all possible child nodes.
+ */
public Set<QName> getPossibleChildNames() {
return childNames;
}
public int hashCode() {
return childNames.hashCode();
}
+
+ @Override
+ public int compareTo(PathArgument o) {
+ if (!(o instanceof AugmentationIdentifier)) {
+ return -1;
+ }
+ AugmentationIdentifier other = (AugmentationIdentifier) o;
+ Set<QName> otherChildNames = other.getPossibleChildNames();
+ int thisSize = childNames.size();
+ int otherSize = otherChildNames.size();
+ if (thisSize == otherSize) {
+ Iterator<QName> otherIterator = otherChildNames.iterator();
+ for (QName name : childNames) {
+ int c = name.compareTo(otherIterator.next());
+ if (c != 0) {
+ return c;
+ }
+ }
+ return 0;
+ } else if (thisSize < otherSize) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
}
private static class BuilderImpl implements InstanceIdentifierBuilder {
* The toStringCache is safe, since the object contract requires
* immutability of the object and all objects referenced from this
* object.
- *
* Used lists, maps are immutable. Path Arguments (elements) are also
* immutable, since the PathArgument contract requires immutability.
- *
* The cache is thread-safe - if multiple computations occurs at the
* same time, cache will be overwritten with same result.
*/
* Returns parent node
*
* @return parent node
+ * @deprecated Unused, Deprecated because reference to parent disallows of sharing one instance
+ * in multiple trees / subtress.
*/
@Deprecated
CompositeNode getParent();
import org.opendaylight.yangtools.concepts.Codec;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
+/**
+ *
+ * Codec which serializes / deserializes InstanceIdentifier
+ *
+ * @param <T> Target type
+ */
public interface InstanceIdentifierCodec<T> extends Codec<T,InstanceIdentifier> {
@Override
T serialize(InstanceIdentifier data);
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.api.schema;
+
+import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.Node;
+
+/**
+ * Anyxml normalizedNode.
+ *
+ * <p>
+ * This node contains values for anyxml as either SimpleNode or CompositeNode.
+ * The concrete value depends on the current value of anyxml node.
+ * </p>
+ *
+ * <p>
+ * For yang node: anyxml foo;
+ *
+ * <ul>
+ * <li>
+ * with xml value:
+ * <pre>
+ * {@code <foo>justSomeString</foo>}
+ * </pre>
+ * </li>
+ *
+ * this AnyXmlNode returns SimpleNode with QName{namespace=someNamespace, revision=someRevision, localName=foo} and value="justSomeString"
+ *
+ * <li>
+ * but with xml value:
+ * <pre>
+ * {@code <foo><bar>stringInXml</bar></foo>}
+ * </pre>
+ * </li>
+ *
+ * this AnyXmlNode returns CompositeNode with QName{}namespace=someNamespace, revision=someRevision, localName=foo}
+ * and values [SimpleNode with QName{}namespace=someNamespace, revision=someRevision, localName=bar} and value="stringInXml"]
+ * </ul>
+ * </p>
+ */
+public interface AnyXmlNode extends AttributesContainer, DataContainerChild<NodeIdentifier, Node<?>> {
+
+ @Override
+ NodeIdentifier getIdentifier();
+
+ /**
+ * @return anyxml node value represented as SimpleNode or CompositeNode.
+ * Returned node contains top level element that duplicates the anyxml node.
+ */
+ @Override
+ Node<?> getValue();
+}
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import com.google.common.base.Optional;
/**
*
- * Node representing Augmentation.
+ * Data instance of <code>augment</code> assiociated with parent node.
+ *
+ * Augmentation is addition of subtree defined by other external YANG Model and
+ * is schema for subtree is described by instance of {@link AugmentationSchema}
+ * associated with parent node of this node.
*
* Augmentation node MUST NOT be direct child of other augmentation node.
*
DataContainerNode<AugmentationIdentifier>,
DataContainerChild<InstanceIdentifier.AugmentationIdentifier, Iterable<DataContainerChild<? extends PathArgument, ?>>> {
+ /**
+ * Gets identifier of augmentation node
+ *
+ * Returned identifier of augmentation node contains all possible
+ * direct child QNames.
+ *
+ * This is sufficient to identify instance of augmentation,
+ * since RFC6020 states that <code>augment</code> that augment
+ * statement must not add multiple nodes from same namespace
+ * / module
+ * to the target node.
+ *
+ * @return Identifier which uniquelly identifies augmentation in particular subtree.
+ *
+ */
@Override
- Iterable<DataContainerChild<? extends PathArgument, ?>> getValue();
-
- @Override
- Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child);
-
- @Override
- AugmentationIdentifier getIdentifier();
+ public AugmentationIdentifier getIdentifier();
}
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import com.google.common.base.Optional;
-
/**
*
- * Node representing choice.
+ * Node representing data instance of <code>choice</code>.
*
- * @author Tony Tkacik
+ * Choice node is instance of one of possible alternatives, from which
+ * only one is allowed to exist at one time in particular context of parent node.
+ YANG Model and
+ * schema for choice is described by instance of {@link org.opendaylight.yangtools.yang.model.api.ChoiceNode}.
+ * Valid alternatives of subtree are described by instances of {@link org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode}
+ * which are retrieved via {@link org.opendaylight.yangtools.yang.model.api.ChoiceNode#getCases()}.
*
*/
public interface ChoiceNode extends //
DataContainerNode<NodeIdentifier>,
DataContainerChild<NodeIdentifier, Iterable<DataContainerChild<? extends PathArgument, ?>>> {
- @Override
- NodeIdentifier getIdentifier();
-
- @Override
- Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child);
}
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import com.google.common.base.Optional;
-
+/**
+ * Data subtree with cardinality 0..1 in the context of parent node
+ *
+ * Node which does not have value but contains valid {@link DataContainerChild} nodes.
+ *
+ * Schema of this node is described by instance of {@link org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode}.
+ *
+ */
public interface ContainerNode extends //
AttributesContainer,
DataContainerNode<NodeIdentifier>,
DataContainerChild<NodeIdentifier, Iterable<DataContainerChild<? extends PathArgument, ?>>> {
- @Override
- NodeIdentifier getIdentifier();
-
- @Override
- Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child);
}
/**
*
* Marker interface for direct children of {@link DataContainerNode}.
- *
- * Implementation notes:
+ *
+ * <h3>Implementation notes</h3>
* This interface should not be implemented directly, but rather using one
* of its subinterfaces:
*
+ * <ul>
+ * <li>{@link LeafNode}
+ * <li>{@link ContainerNode}
+ * <li>{@link ChoiceNode}
+ * <li>{@link MapNode}
+ * <li>{@link AugmentationNode}
+ *</ul>
*
- * {@link LeafNode}
- * {@link ContainerNode}
- * {@link ChoiceNode}
- * {@link MapNode}
- * {@link AugmentationNode}
- *
- * @param <K>
- * @param <V>
+ * @param <K> Path Argument Type which is used to identify node
+ * @param <V> Value type
*/
public interface DataContainerChild<K extends PathArgument,V> extends NormalizedNode<K, V> {
+
@Override
K getIdentifier();
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import com.google.common.base.Optional;
-
+/**
+ *
+ * Abstract node which does not have value but contains valid {@link DataContainerChild} nodes.
+ *
+ * Schema of this node is described by instance of {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer}.
+ *
+ * <h2>Implementation notes</h2>
+ * This interface should not be implemented directly, but rather implementing one of it's subclasses
+ * <ul>
+ * <li>{@link ContainerNode}
+ * <li>{@link MapEntryNode}
+ * <li>{@link UnkeyedListEntryNode}
+ * <li>{@link ChoiceNode}
+ * <li>{@link AugmentationNode}
+ * </ul>
+ *
+ * @param <K> {@link PathArgument} which identifies instance of {@link DataContainerNode}
+ */
public interface DataContainerNode<K extends PathArgument> extends //
NormalizedNodeContainer<K, PathArgument, DataContainerChild<? extends PathArgument, ?>> {
- @Override
- K getIdentifier();
+ /**
+ * Returns iteration of all child nodes
+ *
+ * Order of returned child nodes may be defined by subinterfaces.
+ *
+ * <b>Implementation Notes:</b>
+ * <p>
+ * All nodes returned in this iterable, MUST also be accessible via
+ * {@link #getChild(PathArgument)} using their associated identifier.
+ *
+ * @return Iteration of all child nodes
+ */
@Override
Iterable<DataContainerChild<? extends PathArgument, ?>> getValue();
-
- @Override
- Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child);
}
import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
+/**
+ *
+ * Leaf node with multiplicity 0..1
+ *
+ * Leaf node has a value, but no child nodes in the data tree, schema
+ * for leaf node and its value is described by {@link org.opendaylight.yangtools.yang.model.api.LeafSchemaNode}.
+ *
+ * @param <T> Value type
+ */
public interface LeafNode<T> extends //
AttributesContainer,
DataContainerChild<NodeIdentifier, T> {
+
+
+ /**
+ *
+ * Returns value of this leaf node
+ *
+ * @return Returned value of this leaf node. Value SHOULD meet criteria defined by schema.
+ *
+ */
@Override
- NodeIdentifier getIdentifier();
+ T getValue();
+
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue;
-public interface LeafSetEntryNode<T> extends
- AttributesContainer,
- NormalizedNode<NodeWithValue, T> {
+/**
+ *
+ * Leaf node with multiplicity 0...n
+ *
+ * Leaf node has a value, but no child nodes in the data tree, schema
+ * for leaf node and its value is described by
+ * {@link org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode}.
+ *
+ * @param <T>
+ * Value type
+ */
+public interface LeafSetEntryNode<T> extends AttributesContainer, NormalizedNode<NodeWithValue, T> {
+
+ /**
+ * Returns {@link NodeWithValue} which identifies this leaf set entry.
+ *
+ * Returned {@link NodeWithValue} contains same value as this node.
+ *
+ * <h3>Implementation notes</h3> Invocation of
+ * {@link NodeWithValue#getValue()} on returned instance of
+ * {@link NodeWithValue} must returns
+ * same value as invocation of {@link #getValue()}, such as
+ * following condition is allways met:
+ * <code>true == this.getIdentifier().getValue().equals(this.getValue())</code>
+ *
+ *
+ * @return {@link NodeWithValue} which identifies this leaf set entry.
+ */
@Override
NodeWithValue getIdentifier();
+
+ /**
+ *
+ * Returns value of this leaf node
+ *
+ * <h3>Implementation notes</h3> Invocation of {@link #getValue()} must
+ * provides same value as value in {@link #getIdentifier()}.
+ * <code>true == this.getIdentifier().getValue().equals(this.getValue())</code>
+ *
+ * @return Returned value of this leaf node. Value SHOULD meet criteria
+ * defined by schema.
+ *
+ */
+ @Override
+ public T getValue();
}
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue;
-import com.google.common.base.Optional;
-
+/**
+ *
+ * Node representing set of simple leaf nodes.
+ *
+ * Node containing instances of {@link LeafSetEntryNode}
+ *
+ * Schema and semantics of this node are described by instance of {@link org.opendaylight.yangtools.yang.model.api.LeafListSchema}.
+ *
+ *
+ * @param <T> Type of leaf node values.
+ */
public interface LeafSetNode<T> extends
MixinNode, //
DataContainerChild<NodeIdentifier, Iterable<LeafSetEntryNode<T>>>, //
NormalizedNodeContainer<NodeIdentifier, NodeWithValue,LeafSetEntryNode<T>> {
- @Override
- NodeIdentifier getIdentifier();
-
- @Override
- Iterable<LeafSetEntryNode<T>> getValue();
-
- @Override
- Optional<LeafSetEntryNode<T>> getChild(NodeWithValue child);
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
-public interface MapEntryNode extends
- AttributesContainer,
- DataContainerNode<NodeIdentifierWithPredicates> {
+/**
+ *
+ * Instance of Map entry, this node does not contains value, but child nodes.
+ *
+ */
+public interface MapEntryNode extends AttributesContainer, DataContainerNode<NodeIdentifierWithPredicates> {
+ /**
+ *
+ * Returns identifier of this node in parent map node
+ *
+ * Contents of identifier is defined by <code>key</code> (
+ * {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.ListSchemaNode#getKeyDefinition()}
+ * ) statement in YANG schema for associated list item and child {@link LeafNode}s
+ * values with {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier}
+ * as defined in the schema.
+ *
+ * @return identifier of this node in the context of parent node
+ */
@Override
NodeIdentifierWithPredicates getIdentifier();
+
}
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
/**
- * Containment node, which contains {@link MapEntryNode} of the same type.
+ * Containment node, which contains {@link MapEntryNode} of the same type, which may
+ * be quickly retrieved using key.
*
- * This node maps to the list node in YANG schema.
+ * This node maps to the list node in YANG schema, schema and semantics of this node,
+ * its children and key construction is defined by YANG <code>list</code>
+ * statement and its <code>key</code> and <code>ordered-by</code> substatements.
*
*/
public interface MapNode extends //
DataContainerChild<NodeIdentifier, Iterable<MapEntryNode>>,
NormalizedNodeContainer<NodeIdentifier, NodeIdentifierWithPredicates, MapEntryNode> {
- @Override
- NodeIdentifier getIdentifier();
}
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.yangtools.yang.data.api.schema;
import org.opendaylight.yangtools.concepts.Identifiable;
* Node which is normalized according to the YANG schema
* is identifiable by {@link InstanceIdentifier}.
*
- *
- * @author Tony Tkacik
+ * See subinterfaces of this interface for concretization
+ * of node.
*
* @param <K> Local identifier of node
* @param <V> Value of node
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import com.google.common.base.Optional;
/**
- *
- * @param <I> Node Identifier type
- * @param <K> Child Node Identifier type
- * @param <V> Child Node type
+ * Node which is not leaf, but has child {@link NormalizedNode}s as its valzue.
+ *
+ *
+ * NormalizedNodeContainer does not have a value, but it has a child
+ * nodes. Definition of possible and valid child nodes is introduced
+ * in subclasses of this interface.
+ *
+ * This interface should not be used directly, but rather use of of derived subinterfaces
+ * such as {@link DataContainerNode}, {@link MapNode}, {@link LeafSetNode}.
+ *
+ * @param <I>
+ * Node Identifier type
+ * @param <K>
+ * Child Node Identifier type
+ * @param <V>
+ * Child Node type
*/
public interface NormalizedNodeContainer<I extends PathArgument, K extends PathArgument, V extends NormalizedNode<? extends K, ?>>
extends NormalizedNode<I, Iterable<V>> {
@Override
I getIdentifier();
+ /**
+ * Returns immutable iteration of child nodes of this node.
+ *
+ */
@Override
Iterable<V> getValue();
/**
- *
- *
+ * Returns child node identified by provided key.
+ *
* @param child
- * @return
+ * Path argument identifying child node
+ * @return Optional with child node if child exists.
+ * {@link Optional#absent()} if child does not exists.
*/
Optional<V> getChild(K child);
}
*/
package org.opendaylight.yangtools.yang.data.api.schema;
+
+/**
+ *
+ * Leaf set node which preserves user-supplied ordering.
+ *
+ * This node represents a data instance of <code>leaf-list</code> with
+ * <code>ordered-by user;</code> substatement.
+ *
+ * Except preserving user-ordering all other semantics and behaviour is same
+ * as in {@link LeafSetNode}.
+ *
+ * @param <T> Value type of Leaf entries
+ */
public interface OrderedLeafSetNode<T> extends LeafSetNode<T>, OrderedNodeContainer<LeafSetEntryNode<T>> {
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.yangtools.yang.data.api.schema;
+/**
+ *
+ * Map node which preserves user-supplied ordering.
+ *
+ * <p>
+ * This node represents a data instance of <code>list</code> with
+ * <code>ordered-by user;</code> substatement and <code>key</code> definition.
+ *
+ * <p>
+ * Except preserving user-ordering all other semantics and behaviour is same as
+ * in {@link MapNode}.
+ *
+ */
public interface OrderedMapNode extends MapNode, OrderedNodeContainer<MapEntryNode> {
}
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
+/**
+ *
+ * Normalized Node container which preserves user supplied ordering
+ * and allows addressing of child elements by positiion.
+ *
+ * @param <V>
+ */
public interface OrderedNodeContainer<V extends NormalizedNode<?, ?>> extends MixinNode, NormalizedNode<NodeIdentifier, Iterable<V>> {
+
+ /**
+ * Returns child node by position
+ *
+ * @param position Position of child node
+ * @return Child Node
+ * @throws IndexOutOfBoundsException
+ */
V getChild(int position);
+
+ /**
+ * Returns count of child nodes
+ *
+ * @return count of child nodes.
+ */
int getSize();
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
+/**
+ * List entry node, which does not have value, but child nodes.
+ *
+ * Represents an instance of data, which schema is instance of
+ * {@link org.opendaylight.yangtools.yang.model.api.ListSchemaNode} with key undefined.
+ *
+ * This nodes itself does not contain any ordering information, user supplied
+ * ordering is preserved by parent node, which is instance of {@link UnkeyedListNode}.
+ *
+ *
+ */
public interface UnkeyedListEntryNode extends DataContainerNode<NodeIdentifier> {
}
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
+
+/**
+ *
+ * Containment node, which contains {@link UnkeyedListEntryNode} of the same type, which may
+ * be quickly retrieved using key.
+ *
+ * <p>
+ * This node maps to the <code>list</code> statement in YANG schema,
+ * which did not define <code>key</code> substatement.
+ *
+ * <p>
+ * Ordering of the elements is user-defined during construction of instance of this
+ * interface. Ordered view of elements (iteration)
+ * is provided by {@link #getValue()} call.
+ *
+ */
public interface UnkeyedListNode extends
DataContainerChild<NodeIdentifier, Iterable<UnkeyedListEntryNode>>,
OrderedNodeContainer<UnkeyedListEntryNode> {
--- /dev/null
+/**
+ *
+ * Definition of normalized YANG DOM Model
+ *
+ * Normalized DOM Model brings more direct mapping between YANG Model, DOM
+ * representation of data
+ *
+ * <h2>Normalized DOM Model</h2>
+ *
+ * <h3>Node Types</h3>
+ * <ul>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode} -
+ * Base type representing a node in a tree structure; all nodes are derived from
+ * it, it contains a leaf identifier and a value.
+ * <ul>
+ * <li>
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode} -
+ * Node which contains multiple leafs; it does not have a direct representation
+ * in the YANG syntax.
+ * <ul>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.ContainerNode} -
+ * Node, which represents a leaf which can occur only once per parent node; it
+ * contains multiple child leaves and maps to the <i>container</i> statement in
+ * YANG.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode} -
+ * Node which represents a leaf, which can occur multiple times; a leave is
+ * uniquely identified by the value of its key. A MapEntryNode may contain
+ * multiple child leaves. MapEntryNode maps to the instance of <i>list</i> in
+ * YANG.</li>
+ * <li>
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode}
+ * - Node which represents a leaf, which can occur multiple times; a leave is
+ * uniquely identified by the value of its key. A MapEntryNode may contain
+ * multiple child leaves. MapEntryNode maps to the instance of <i>list</i> in
+ * YANG.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode} - Node
+ * which represents a leaf, which occurs mostly once per parent node, but
+ * possible values could have different types. Maps to <i>choice</i> statement.
+ * Types maps to the <i>case</i> statements for that <i>choice</i>.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode}
+ * - Node which represents a leaf, which occurs mostly once per parent node.</li>
+ * </ul>
+ * </li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} - Node
+ * which represents a leaf, which occurs mostly once per parent node. Contains
+ * simple value.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode}
+ * - Node which represents a leaf, which type could occurs multiple times per
+ * parent node. Maps to to the instances of <i>leaf-list</i> in YANG.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode} -
+ * Special node, which can occur only once per parent node; its leaves are
+ * LeafSetEntryNode nodes of specified type. Maps into the <i>leaf-list</i> in
+ * YANG.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.MapNode} - Special
+ * node, which can occur only once per parent node; its leaves are MapEntryNode
+ * nodes.
+ * <ul>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode} -
+ * Special node, which can occur only once per parent node; its leaves are
+ * MapEntryNode nodes.</li>
+ * </ul>
+ * </li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode} -
+ * Special node, which can occur only once per parent node; its leaves are
+ * MapEntryNode nodes.</li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * <h3>Tree / subtree structure</h3> <h4>Grammar representation</h4>
+ *
+ * <pre>
+ * {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument}*
+ * {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier}| {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates}| {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue} | {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier}
+ *
+ * TreeRoot = {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode} = ( {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} | {@link org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode} | {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode} | {@link org.opendaylight.yangtools.yang.data.api.schema.MapNode} | {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode})*
+ * ContainerDataNode = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ *
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} SimpleValue
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.MapNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode}
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates} {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ *
+ * // Special nodes
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode}*
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue} SimpleValue
+ * </pre>
+ *
+ * The resulting tree organization is following:
+ *
+ * <ul>
+ * <li>(DataContainerNode)
+ * <ul>
+ * <li>(0..n) LeafNode</li>
+ * <li>(0..n) LeafSetNode
+ * <ul>
+ * <li>(0..n) LeafSetEntryNode</li>
+ * </ul>
+ * </li>
+ * <li>(0..n) ContainerNode
+ * <ul>
+ * <li>(Same as DataContainerNode)</li>
+ * </ul>
+ * </li>
+ * <li>(0..n) ContainerNode
+ * <ul>
+ * <li>(Same as DataContainerNode)</li>
+ * </ul>
+ * </li>
+ * <li>(0..n) MapNode
+ * <ul>
+ * <li>(0..n) MapEntryNode
+ * <ul>
+ * <li>(Same as DataContainerNode)</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </li>
+ * <li>(0..n) AugmentationNode
+ * <ul>
+ * <li>(Same as DataContainerNode)</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * <h3>Ordering of child nodes</h3>
+ *
+ * Ordering of child nodes is not enforced by this API definition, unless
+ * explicitly stated by subclasses of
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.OrderedNodeContainer}
+ * which marks nodes with semantic constrain to preserve user-supplied ordering.
+ * <p>
+ * Clients should not expect any specific ordering of child nodes for interfaces
+ * from this package which does not extend
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.OrderedNodeContainer},
+ * since implementations are not required to have well-defined order, which
+ * allows for more efficient implementations. If such ordering is required by
+ * clients for serialization / debugability it SHOULD be done externally in
+ * code using these interfaces.
+ *
+ */
+package org.opendaylight.yangtools.yang.data.api.schema;
\ No newline at end of file
package org.opendaylight.yangtools.yang.data.impl.schema;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAnyXmlNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAnyXmlNodeSchemaAwareBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeSchemaAwareBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
return ImmutableLeafSetEntryNodeSchemaAwareBuilder.create(schema);
}
+ public static <T> NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> anyXmlBuilder() {
+ return ImmutableAnyXmlNodeBuilder.create();
+ }
+
+ public static <T> NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> anyXmlBuilder(
+ final AnyXmlSchemaNode schema) {
+ return ImmutableAnyXmlNodeSchemaAwareBuilder.create(schema);
+ }
+
public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder() {
return ImmutableLeafSetNodeBuilder.create();
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
+
+import java.util.Map;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedValueAttrNode;
+
+public class ImmutableAnyXmlNodeBuilder extends AbstractImmutableNormalizedNodeBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> {
+
+ public static NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> create() {
+ return new ImmutableAnyXmlNodeBuilder();
+ }
+
+ @Override
+ public AnyXmlNode build() {
+ return new ImmutableXmlNode(getNodeIdentifier(), getValue(), getAttributes());
+ }
+
+ private static final class ImmutableXmlNode extends AbstractImmutableNormalizedValueAttrNode<InstanceIdentifier.NodeIdentifier, Node<?>> implements AnyXmlNode {
+
+ ImmutableXmlNode(final InstanceIdentifier.NodeIdentifier nodeIdentifier, final Node<?> value, final Map<QName, String> attributes) {
+ super(nodeIdentifier, value, attributes);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
+
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
+
+public final class ImmutableAnyXmlNodeSchemaAwareBuilder extends ImmutableAnyXmlNodeBuilder {
+
+ private ImmutableAnyXmlNodeSchemaAwareBuilder(AnyXmlSchemaNode schema) {
+ super.withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(schema.getQName()));
+ }
+
+ public static NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> create(AnyXmlSchemaNode schema) {
+ return new ImmutableAnyXmlNodeSchemaAwareBuilder(schema);
+ }
+
+ @Override
+ public NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> withValue(Node<?> value) {
+ return super.withValue(value);
+ }
+
+ @Override
+ public NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> withNodeIdentifier(InstanceIdentifier.NodeIdentifier nodeIdentifier) {
+ throw new UnsupportedOperationException("Node identifier created from schema");
+ }
+}
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Maps;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
class YangToSourcesProcessor {
static final String LOG_PREFIX = "yang-to-sources:";
static final String META_INF_YANG_STRING = "META-INF" + File.separator + "yang";
}
if (noChange) {
- log.info(Util.message("None of %s input files changed", LOG_PREFIX, allFiles.size()));
+ log.info(Util.message("None of %s input files changed", LOG_PREFIX, allFiles.size()));
return null;
}
List<InputStream> all = new ArrayList<>(yangsInProject);
closeables.addAll(yangsInProject);
Map<InputStream, Module> allYangModules;
+
+ /**
+ * Set contains all modules generated from input sources. Number of
+ * modules may differ from number of sources due to submodules
+ * (parsed submodule's data are added to its parent module). Set
+ * cannot contains null values.
+ */
Set<Module> projectYangModules;
try {
if (inspectDependencies) {
projectYangModules = new HashSet<>();
for (InputStream inProject : yangsInProject) {
- Module module = checkNotNull(allYangModules.get(inProject), "Cannot find module by %s", inProject);
- projectYangModules.add(module);
+ Module module = allYangModules.get(inProject);
+ if (module != null) {
+ projectYangModules.add(module);
+ }
}
} finally {
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
public interface AugmentationSchema extends DataNodeContainer {
/**
- * @return when statement
+ *
+ * Returns when statement
+ *
+ * If when condition is present node defined by the parent data definition
+ * statement is only valid when the returned XPath
+ * expression conceptually evaluates to "true"
+ * for a particular instance, then the node defined by the parent data
+ * definition statement is valid; otherwise, it is not.
+ *
+ * @return XPath condition
*/
RevisionAwareXPath getWhenCondition();
* @return collection of all unknown nodes defined in this augmentation
*/
List<UnknownSchemaNode> getUnknownSchemaNodes();
+
/**
* Returns Augmentation Definition from which this augmentation is derived
* if augmentation was added transitively via augmented uses.
*
* @return ugmentation Definition from which this augmentation is derived
- * if augmentation was added transitively via augmented uses.
+ * if augmentation was added transitively via augmented uses.
*/
Optional<AugmentationSchema> getOriginalDefinition();
*/
package org.opendaylight.yangtools.yang.model.util;
+import com.google.common.base.Preconditions;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
/**
* The Schema Context Util contains support methods for searching through Schema
* Context modules for specified schema nodes via Schema Path or Revision Aware
return result;
}
- private static DataSchemaNode findCorrectTargetFromGrouping(final DataSchemaNode node, final SchemaContext ctx) {
- if (node.getPath().getPath().size() == 1) {
- // uses is under module statement
- Module m = findParentModule(ctx, node);
- DataSchemaNode result = null;
- for (UsesNode u : m.getUses()) {
- SchemaNode targetGrouping = findNodeInSchemaContext(ctx, u.getGroupingPath().getPath());
- if (!(targetGrouping instanceof GroupingDefinition)) {
- throw new IllegalArgumentException(String.format("Failed to generate code for augment in %s", u));
- }
- GroupingDefinition gr = (GroupingDefinition) targetGrouping;
- result = gr.getDataChildByName(node.getQName().getLocalName());
- }
- if (result == null) {
- throw new IllegalArgumentException("Failed to generate code for augment");
+ private static DataSchemaNode findCorrectImmediateTargetFromGrouping(final DataSchemaNode node, final SchemaContext ctx) {
+ // uses is under module statement
+ final Module m = findParentModule(ctx, node);
+ Preconditions.checkArgument(m != null, "Failed to find module for node {} in context {}", node, ctx);
+
+ for (final UsesNode u : m.getUses()) {
+ final SchemaNode targetGrouping = findNodeInSchemaContext(ctx, u.getGroupingPath().getPath());
+ Preconditions.checkArgument(targetGrouping instanceof GroupingDefinition,
+ "Failed to generate code for augment in %s", u);
+
+ LOG.trace("Checking grouping {} for node {}", targetGrouping, node);
+ final GroupingDefinition gr = (GroupingDefinition) targetGrouping;
+ final DataSchemaNode result = gr.getDataChildByName(node.getQName().getLocalName());
+ if (result != null) {
+ return result;
}
- return result;
- } else {
- DataSchemaNode result = null;
+
+ LOG.debug("Skipped grouping {}, no matching node found", gr);
+ }
+
+ throw new IllegalArgumentException(
+ String.format("Failed to find uses node matching {} in context {}", node, ctx));
+ }
+
+ private static DataSchemaNode findCorrectTargetFromGrouping(final DataSchemaNode node, final SchemaContext ctx) {
+ if (node.getPath().getPath().size() != 1) {
QName currentName = node.getQName();
+ // tmpPath is used to track level of nesting
List<QName> tmpPath = new ArrayList<>();
Object parent = null;
+ // create schema path of parent node
SchemaPath sp = node.getPath();
- List<QName> names = sp.getPath();
- List<QName> newNames = new ArrayList<>(names);
+ List<QName> newNames = new ArrayList<>(sp.getPath());
+ // parentPath = nodePath - lastQName
newNames.remove(newNames.size() - 1);
SchemaPath newSp = SchemaPath.create(newNames, sp.isAbsolute());
+ // find parent node by its schema path
parent = findDataSchemaNode(ctx, newSp);
do {
tmpPath.add(currentName);
+
+ DataSchemaNode result = null;
+ // search parent node's used groupings for presence of wanted
+ // node
if (parent instanceof DataNodeContainer) {
DataNodeContainer dataNodeParent = (DataNodeContainer) parent;
for (UsesNode u : dataNodeParent.getUses()) {
- if (result == null) {
- result = getResultFromUses(u, currentName.getLocalName(), ctx);
+ result = getResultFromUses(u, currentName.getLocalName(), ctx);
+ if (result != null) {
+ break;
}
}
}
+
+ // if node is not found in any of current parent's used
+ // groupings => parent is added by grouping too, so repeat same
+ // process for parent
if (result == null) {
+ // set current name to name of parent node
currentName = ((SchemaNode) parent).getQName();
- if (parent instanceof SchemaNode) {
- SchemaPath nodeSp = ((SchemaNode) parent).getPath();
- List<QName> nodeNames = nodeSp.getPath();
- List<QName> nodeNewNames = new ArrayList<>(nodeNames);
- nodeNewNames.remove(nodeNewNames.size() - 1);
- if (nodeNewNames.isEmpty()) {
- parent = getParentModule((SchemaNode) parent, ctx);
- } else {
- SchemaPath nodeNewSp = SchemaPath.create(nodeNewNames, nodeSp.isAbsolute());
- parent = findDataSchemaNode(ctx, nodeNewSp);
- }
+ Preconditions.checkArgument(parent instanceof SchemaNode,
+ "Failed to generate code for augmend node {} at parent {}", node, parent);
+ // create schema path for parent of current parent
+ SchemaPath nodeSp = ((SchemaNode) parent).getPath();
+ List<QName> nodeNewNames = new ArrayList<>(nodeSp.getPath());
+ nodeNewNames.remove(nodeNewNames.size() - 1);
+ // set new parent based on path
+ if (nodeNewNames.isEmpty()) {
+ parent = getParentModule((SchemaNode) parent, ctx);
} else {
- throw new IllegalArgumentException("Failed to generate code for augment");
+ SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.isAbsolute());
+ parent = findDataSchemaNode(ctx, nodeNewSp);
}
+ } else {
+ // if wanted node was found in grouping, traverse this node
+ // based on level of nesting
+ return getTargetNode(tmpPath, result, ctx);
}
- } while (result == null && !(parent instanceof Module));
+ } while (!(parent instanceof Module));
- if (result != null) {
- result = getTargetNode(tmpPath, result, ctx);
- }
- return result;
+ return null;
+ } else {
+ return findCorrectImmediateTargetFromGrouping(node, ctx);
}
}
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
+import com.google.common.base.Preconditions;
+
/**
- * Basic implementation of Builder.
+ * Base helper implementation of Builders for Yang Model elements.
+ *
*/
public abstract class AbstractBuilder implements Builder {
- protected String moduleName;
- protected final int line;
- protected Builder parentBuilder;
+ private String moduleName;
+ private final int line;
+ private Builder parentBuilder;
protected final List<UnknownSchemaNode> unknownNodes = new ArrayList<>();
protected final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
protected AbstractBuilder(final String moduleName, final int line) {
- this.moduleName = moduleName;
+ this.moduleName = Preconditions.checkNotNull(moduleName,"moduleName must not be null");
this.line = line;
}
}
@Override
+ @Deprecated
public void setModuleName(final String moduleName) {
this.moduleName = moduleName;
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import java.util.Collections;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
import java.util.TreeSet;
import org.opendaylight.yangtools.yang.common.QName;
public abstract class AbstractDataNodeContainerBuilder extends AbstractBuilder implements DataNodeContainerBuilder {
protected final QName qname;
- protected final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ protected final Map<QName, DataSchemaNode> childNodes = new TreeMap<>();
protected final Set<DataSchemaNodeBuilder> addedChildNodes = new HashSet<>();
protected final Set<GroupingDefinition> groupings = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
return qname;
}
- public Set<DataSchemaNode> getChildNodes() {
+ public Map<QName, DataSchemaNode> getChildNodes() {
return childNodes;
}
}
@Override
- public void addChildNode(DataSchemaNodeBuilder child) {
+ public void addChildNode(final DataSchemaNodeBuilder child) {
QName childName = child.getQName();
for (DataSchemaNodeBuilder addedChildNode : addedChildNodes) {
if (addedChildNode.getQName().equals(childName)) {
- throw new YangParseException(child.getModuleName(), child.getLine(), "Can not add '" + child + "' to '"
- + this + "' in module '" + moduleName + "': node with same name already declared at line "
- + addedChildNode.getLine());
+ throw new YangParseException(child.getModuleName(), child.getLine(), String.format(
+ "Can not add '%s' to '%s' in module '%s': node with same name already declared at line %d",
+ child, this, getModuleName(), addedChildNode.getLine()));
}
}
addedChildNodes.add(child);
}
@Override
- public void addChildNodeToContext(DataSchemaNodeBuilder child) {
+ public void addChildNodeToContext(final DataSchemaNodeBuilder child) {
addedChildNodes.add(child);
}
@Override
- public void addChildNode(DataSchemaNode child) {
+ public void addChildNode(final DataSchemaNode child) {
QName childName = child.getQName();
- for (DataSchemaNode childNode : childNodes) {
- if (childNode.getQName().equals(childName)) {
- throw new YangParseException(moduleName, line, "Can not add '" + child + "' to '" + this
- + "' in module '" + moduleName + "': node with same name already declared");
- }
+ if (childNodes.containsKey(childName)) {
+ throw new YangParseException(getModuleName(), getLine(),
+ String.format("Can not add '%s' to '%s' in module '%s': node with same name already declared",
+ child, this, getModuleName()));
}
- childNodes.add(child);
+ childNodes.put(childName, child);
}
@Override
}
@Override
- public void addGrouping(GroupingBuilder grouping) {
+ public void addGrouping(final GroupingBuilder grouping) {
QName groupingName = grouping.getQName();
for (GroupingBuilder addedGrouping : addedGroupings) {
if (addedGrouping.getQName().equals(groupingName)) {
- throw new YangParseException(grouping.getModuleName(), grouping.getLine(), "Can not add '" + grouping
- + "': grouping with same name already declared in module '" + moduleName + "' at line "
- + addedGrouping.getLine());
+ throw new YangParseException(grouping.getModuleName(), grouping.getLine(), String.format(
+ "Can not add '%s': grouping with same name already declared in module '%s' at line %d",
+ grouping, getModuleName(), addedGrouping.getLine()));
}
}
addedGroupings.add(grouping);
}
@Override
- public void addUsesNode(UsesNodeBuilder usesNode) {
+ public void addUsesNode(final UsesNodeBuilder usesNode) {
addedUsesNodes.add(usesNode);
}
- protected static DataSchemaNode getChildNode(Set<DataSchemaNode> childNodes, QName name) {
+ protected static DataSchemaNode getChildNode(final Set<DataSchemaNode> childNodes, final QName name) {
for (DataSchemaNode node : childNodes) {
if (node.getQName().equals(name)) {
return node;
return null;
}
- protected static DataSchemaNode getChildNode(Set<DataSchemaNode> childNodes, String name) {
+ protected static DataSchemaNode getChildNode(final Set<DataSchemaNode> childNodes, final String name) {
for (DataSchemaNode node : childNodes) {
if (node.getQName().getLocalName().equals(name)) {
return node;
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
- result = prime * result + ((parentBuilder == null) ? 0 : parentBuilder.hashCode());
+ result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
return result;
}
return false;
}
AbstractSchemaNodeBuilder other = (AbstractSchemaNodeBuilder) obj;
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
if (schemaPath == null) {
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.Status;
/**
- * Interface for builders of 'augment' statement.
+ * Builder for {@link AugmentationSchema}, which represents 'augment' statement.
*/
-public interface AugmentationSchemaBuilder extends DataNodeContainerBuilder {
+public interface AugmentationSchemaBuilder extends DataNodeContainerBuilder,DocumentedNodeBuilder {
+ /**
+ * Returns when condition
+ *
+ * If when condition is present node defined by the parent data definition
+ * statement is only valid when the returned XPath
+ * expression conceptually evaluates to "true"
+ * for a particular instance, then the node defined by the parent data
+ * definition statement is valid; otherwise, it is not.
+ *
+ *
+ * @return
+ */
String getWhenCondition();
+ /**
+ * Adds string representation of when condition.
+ *
+ * If when condition is present node defined by the parent data definition
+ * statement is only valid when the returned XPath
+ * expression conceptually evaluates to "true"
+ * for a particular instance, then the node defined by the parent data
+ * definition statement is valid; otherwise, it is not.
+ *
+ * @param whenCondition
+ */
void addWhenCondition(String whenCondition);
- String getDescription();
-
- void setDescription(String description);
-
- String getReference();
-
- void setReference(String reference);
-
- Status getStatus();
-
- void setStatus(Status status);
-
/**
- * Get path to target node as single string.
+ * Returns target path representation as was present in schema source.
*
* @return path to target node as String
*/
*/
void setTargetNodeSchemaPath(SchemaPath path);
+ @Override
AugmentationSchema build();
/**
*/
void setResolved(boolean resolved);
+ /**
+ *
+ * Returns position of defining <code>augment</code> statement
+ * as was present in schema source.
+ *
+ * @return Position of definiing augment statement in source code.
+ */
int getOrder();
}
import java.util.List;
+import org.opendaylight.yangtools.concepts.Mutable;
import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
/**
* Parent interface for all builder interfaces.
*/
-public interface Builder {
+public interface Builder extends Mutable {
/**
- * Get name of module in which this node is declared.
+ * Returns name of module in which node created by this builder
+ * was declared.
*
* @return module name
*/
* Set name of module in which this node is declared.
*
* @param moduleName
+ * @deprecated Module name should be set during creation of builder.
*/
+ @Deprecated
void setModuleName(String moduleName);
/**
- * Get current line in yang file.
+ * Get current line in yang file, on which statement
+ * associated with this builder was declared.
*
* @return current line in yang file
*/
int getLine();
/**
- * Get parent node of this node.
+ * Returns parent node builder of this node.
*
* @return parent node builder or null if this is top level node
*/
void setParent(Builder parent);
/**
- * Add unknown node to this builder.
+ * Adds an unknown node builder to this builder.
+ *
+ * When product (child) is builded by the {@link #build()}
+ * method, this builder is also built and unknown node is added
+ * as child to the product of this builder.
*
* @param unknownNode
*/
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
/**
- * Interface for all yang data-node containers [augment, case, container,
- * grouping, list, module, notification].
+ * Common builder for for all YANG {@link DataNodeContainer}
+ * <code>augment, case, container,
+ * grouping, list, module, notification</code>.
*/
public interface DataNodeContainerBuilder extends Builder {
/**
- * Get qname of this node.
+ * Returns QName of this node.
*
* @return QName of this node
*/
QName getQName();
/**
- * Get schema path of this node.
+ * Returns Schema path of this node.
*
* @return SchemaPath of this node
*/
SchemaPath getPath();
/**
- * Get builders of child nodes.
+ * Returns set of of child node builders.
+ *
+ * This child node builder are build, during invoking {@link #build()} and
+ * added as children to resulting {@link DataNodeContainer}.
*
* @return collection child nodes builders
*/
Set<DataSchemaNodeBuilder> getChildNodeBuilders();
/**
- * Get child node by name.
+ * Retrieves child node builder by local name.
*
* @param name
* name of child to seek
*/
void addUsesNode(UsesNodeBuilder usesBuilder);
+ /**
+ * Returns set of already built type definitions.
+ *
+ * @return set of already built type definitions.
+ */
Set<TypeDefinition<?>> getTypeDefinitions();
/**
- * Get builders of typedef statement defined in this node.
+ * Returns builders of typedef statement defined in this node.
*
- * @return typedefBuilder
+ * @return builders of typedef statement defined in this node.
*/
Set<TypeDefinitionBuilder> getTypeDefinitionBuilders();
/**
* Add typedef builder to this node.
*
- * @param typedefBuilder
+ * @param typedefBuilder Builder to add to this node.
*/
void addTypedef(TypeDefinitionBuilder typedefBuilder);
+ /**
+ * Returns an instance of product - DataNodeContainer
+ *
+ * Returns an instance of data node container with
+ * children and properties constructed as per this builder state,
+ * all nested builders are also built and their product is
+ * set to DataNodeContainer.
+ *
+ * @return Instance of DataNodeContainer
+ */
+ @Override
+ DataNodeContainer build();
+
}
package org.opendaylight.yangtools.yang.parser.builder.api;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.parser.builder.impl.ConstraintsBuilder;
/**
*/
public interface DataSchemaNodeBuilder extends SchemaNodeBuilder, GroupingMember {
- /**
- * Build DataSchemaNode object from this builder.
- */
- DataSchemaNode build();
- void setPath(SchemaPath path);
/**
+ *
+ * Returns true if product of this builder is added by augmentation.
*
* @return true, if this node is added by augmentation, false otherwise
*/
boolean isAugmenting();
/**
- * Set if this node is added by augmentation.
+ * Set if the product of the builder node is introduced by augmentation.
*
* @param augmenting
*/
boolean isConfiguration();
/**
- * Set config statement.
+ * Set config statement to the product.
+ *
*
- * @param config
+ * @param config true if config true was set, false if config false was set.
*/
void setConfiguration(boolean config);
*/
ConstraintsBuilder getConstraints();
+ /**
+ * Build DataSchemaNode object from this builder.
+ *
+ * @return instance of {@link DataSchemaNode} based on the state present in this builder.
+ */
+ @Override
+ DataSchemaNode build();
+
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.builder.api;
+
+import org.opendaylight.yangtools.yang.model.api.Status;
+
+/**
+ * Mixin-style builder interfac for nodes, which may have documentation attached.
+ *
+ **/
+public interface DocumentedNodeBuilder {
+
+ /**
+ * Returns description of resulting schema node
+ * as was defined by description statement.
+ *
+ * @return description statement
+ */
+ String getDescription();
+
+ /**
+ * Set description to this node.
+ *
+ * @param description
+ */
+ void setDescription(String description);
+
+ /**
+ * Get reference of this node.
+ *
+ * @return reference statement
+ */
+ String getReference();
+
+ /**
+ * Set reference to this node.
+ *
+ * @param reference
+ */
+ void setReference(String reference);
+
+ /**
+ * Get status of this node.
+ *
+ * @return status statement
+ */
+ Status getStatus();
+
+ /**
+ * Set status to this node.
+ *
+ * @param status
+ */
+ void setStatus(Status status);
+}
/**
* Build GroupingDefinition object from this builder.
+ *
+ * @return Instance of {@link GroupingDefinition} described by this builder.
*/
+ @Override
GroupingDefinition build();
+ /**
+ *
+ * Returns instantiation of grouping child nodes under supplied builder.
+ *
+ * Supplied newParent is not modified.
+ *
+ * For each {@link #getChildNodeBuilders()} new builder is created,
+ * which has supplied new parent set as their {@link Builder#getParent()}
+ * and QNames have updated namespace and revision per supplied parent
+ * node.
+ *
+ * @param newParent Parent node, under which this grouping should be instantiated.
+ * @return Set of new builders representing instantiation of this grouping.
+ */
Set<DataSchemaNodeBuilder> instantiateChildNodes(Builder newParent);
+
+ /**
+ *
+ * Returns instantiation of grouping type definitions under supplied builder.
+ *
+ * Supplied newParent is not modified.
+ *
+ * For each {@link #getTypeDefinitionBuilders()} new builder is created,
+ * which has supplied new parent set as their {@link Builder#getParent()}
+ * and QNames have updated namespace and revision per supplied parent
+ * node.
+ *
+ * @param newParent Parent node, under which this grouping should be instantiated.
+ * @return Set of new builders representing instantiation of this grouping.
+ */
Set<TypeDefinitionBuilder> instantiateTypedefs(Builder newParent);
+ /**
+ *
+ * Returns instantiation of grouping definitions under supplied builder.
+ *
+ * Supplied newParent is not modified.
+ *
+ * For each {@link #getGroupingBuilders()} new builder is created,
+ * which has supplied new parent set as their {@link Builder#getParent()}
+ * and QNames have updated namespace and revision per supplied parent
+ * node.
+ *
+ * @param newParent Parent node, under which this grouping should be instantiated.
+ * @return Set of new builders representing instantiation of this grouping.
+ */
Set<GroupingBuilder> instantiateGroupings(Builder newParent);
+ /**
+ *
+ * Returns instantiation of unknown nodes under supplied builder.
+ *
+ * Supplied newParent is not modified.
+ *
+ * For each {@link #getUnknownNodes()} new builder is created,
+ * which has supplied new parent set as their {@link Builder#getParent()}
+ * and QNames have updated namespace and revision per supplied parent
+ * node.
+ *
+ * @param newParent Parent node, under which this grouping should be instantiated.
+ * @return Set of new builders representing instantiation of this grouping.
+ */
Set<UnknownSchemaNodeBuilder> instantiateUnknownNodes(Builder newParent);
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.Status;
/**
- * Interface for all builders of SchemaNode nodes.
+ * Builder for {@link SchemaNode}.
*/
-public interface SchemaNodeBuilder extends Builder {
+public interface SchemaNodeBuilder extends DocumentedNodeBuilder, Builder {
/**
- * Get qname of this node.
+ * Returns qname of resulting {@link SchemaNode}.
*
* @return QName of this node
*/
QName getQName();
/**
- * Get schema path of this node.
+ * Returns schema path of resulting {@link SchemaNode}.
*
* @return SchemaPath of this node
*/
SchemaPath getPath();
/**
- * Set path to this node.
+ * Updates schema path to resulting {@link SchemaNode}.
*
* @param path
*/
void setPath(SchemaPath path);
- /**
- * Get description of this node.
- *
- * @return description statement
- */
- String getDescription();
-
- /**
- * Set description to this node.
- *
- * @param description
- */
- void setDescription(String description);
-
- /**
- * Get reference of this node.
- *
- * @return reference statement
- */
- String getReference();
-
- /**
- * Set reference to this node.
- *
- * @param reference
- */
- void setReference(String reference);
-
- /**
- * Get status of this node.
- *
- * @return status statement
- */
- Status getStatus();
-
- /**
- * Set status to this node.
- *
- * @param status
- */
- void setStatus(Status status);
-
/**
* Build SchemaNode object from this builder.
*/
+ @Override
SchemaNode build();
}
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
/**
- * Builders of all nodes, which can have 'type' statement must implement this
+ * Builder for nodes, which can have 'type' statement must implement this
* interface. [typedef, type, leaf, leaf-list, deviate]
*/
public interface TypeAwareBuilder extends Builder {
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
public interface TypeDefinitionBuilder extends TypeAwareBuilder, SchemaNodeBuilder, GroupingMember {
+ /**
+ * Sets QName for resulting type definition.
+ *
+ * @param qname QName of resulting type
+ */
void setQName(QName qname);
+ @Override
TypeDefinition<?> build();
+ /**
+ *
+ * Returns range restrictions of resulting type definition.
+ *
+ * @return range restrictions of resulting type definition.
+ */
List<RangeConstraint> getRanges();
+ /**
+ * Set Range restrictions for resulting type definition.
+ *
+ * @param ranges
+ * Range restrictions of resulting type definition.
+ */
void setRanges(List<RangeConstraint> ranges);
+ /**
+ *
+ * Returns length restrictions of resulting type definition.
+ *
+ * @return length restrictions of resulting type definition.
+ */
List<LengthConstraint> getLengths();
+ /**
+ * Set length restrictions for resulting type definition.
+ *
+ * @param lengths
+ * Length restrictions of resulting type definition.
+ */
void setLengths(List<LengthConstraint> lengths);
+ /**
+ *
+ * Returns pattern restrictions of resulting type definition.
+ *
+ * @return range restrictions of resulting type definition.
+ */
List<PatternConstraint> getPatterns();
+ /**
+ * Set length restrictions for resulting type definition.
+ *
+ * @param lengths
+ * Length restrictions of resulting type definition.
+ */
void setPatterns(List<PatternConstraint> patterns);
+ /**
+ *
+ * Returns fractions digits of resulting type if it is derived
+ * from <code>decimal</code> built-in type.
+ *
+ * @return fractions digits of resulting type
+ */
Integer getFractionDigits();
+ /**
+ *
+ * Sets fractions digits of resulting type if it is derived
+ * from <code>decimal</code> built-in type.
+ *
+ * @return fractions digits of resulting type
+ */
void setFractionDigits(Integer fractionDigits);
+ /**
+ *
+ * Returns default value of resulting type
+ *
+ * @return default value of resulting type
+ */
Object getDefaultValue();
+ /**
+ *
+ * Sets default value of resulting type
+ *
+ * @param defaultValue Default value of resulting type
+ */
void setDefaultValue(Object defaultValue);
+ /**
+ * Gets unit definition for resulting type
+ *
+ * @return unit definition for resulting type
+ */
String getUnits();
+ /**
+ * Sets units definition for resulting type
+ *
+ * @param units units definition for resulting type
+ */
void setUnits(String units);
}
import org.opendaylight.yangtools.yang.parser.util.RefineHolder;
/**
- * Interface for builders of 'uses' statement.
+ * Builder for 'uses' statement.
*/
public interface UsesNodeBuilder extends GroupingMember {
* module, container, list, case, grouping, input, output, notification or
* augment, return type is DataNodeContainerBuilder.
*/
+ @Override
DataNodeContainerBuilder getParent();
/**
/**
* Build new UsesNode object.
+ *
+ *
+ * @return UsesNode Instance of {@link UsesNode} described by this builder.
*/
+ @Override
UsesNode build();
+ /**
+ *
+ * Returns true if uses node was resolved and {@link #getGroupingBuilder()}
+ * was instantiated for parent done of this node.
+ *
+ * @return true if uses node was resolved and associated nodes were instantiated in parent node.
+ */
boolean isResolved();
+ /**
+ *
+ * Sets state of instantiation of {@link #getGroupingBuilder()}
+ * into parent node of this node.
+ *
+ * @deprecated Do not use this, this should be internal to the implementation
+ * and public API contract.
+ */
+ @Deprecated
void setResolved(boolean resolved);
}
} else if (!schemaPath.equals(other.schemaPath)) {
return false;
}
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
return true;
*/
package org.opendaylight.yangtools.yang.parser.builder.impl;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.parser.util.ParserUtils;
import org.opendaylight.yangtools.yang.parser.util.YangParseException;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
public final class AugmentationSchemaBuilderImpl extends AbstractDataNodeContainerBuilder implements
AugmentationSchemaBuilder {
private final int order;
private boolean resolved;
private AugmentationSchemaBuilder copyOf;
- public AugmentationSchemaBuilderImpl(final String moduleName, final int line, final String augmentTargetStr, int order) {
+ public AugmentationSchemaBuilderImpl(final String moduleName, final int line, final String augmentTargetStr, final int order) {
super(moduleName, line, null);
this.order = order;
this.augmentTargetStr = augmentTargetStr;
@Override
public void addGrouping(final GroupingBuilder grouping) {
- throw new YangParseException(moduleName, line, "augment can not contains grouping statement");
+ throw new YangParseException(getModuleName(), grouping.getLine(), "augment can not contains grouping statement");
}
@Override
}
if (parent instanceof UsesNodeBuilder) {
- ModuleBuilder mb = ParserUtils.getParentModule(this);
+ final ModuleBuilder mb = ParserUtils.getParentModule(this);
+ final QNameModule qm = QNameModule.create(mb.getNamespace(), mb.getRevision());
+
List<QName> newPath = new ArrayList<>();
- List<QName> parsedPath = targetPath.getPath();
- for (QName name : parsedPath) {
- newPath.add(new QName(mb.getNamespace(), mb.getRevision(), name.getPrefix(), name.getLocalName()));
+ for (QName name : targetPath.getPathFromRoot()) {
+ newPath.add(QName.create(qm, name.getPrefix(), name.getLocalName()));
}
instance.targetPath = SchemaPath.create(newPath, false);
} else {
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- childNodes.add(node.build());
+ childNodes.put(node.getQName(), node.build());
}
- instance.childNodes = ImmutableSet.copyOf(childNodes);
+ instance.childNodes = ImmutableSet.copyOf(childNodes.values());
// USES
for (UsesNodeBuilder builder : addedUsesNodes) {
@Override
public void addTypedef(final TypeDefinitionBuilder type) {
- throw new YangParseException(moduleName, line, "Augmentation can not contains typedef statement.");
+ throw new YangParseException(getModuleName(), type.getLine(), "Augmentation can not contains typedef statement.");
}
@Override
}
@Override
- public int compareTo(AugmentationSchemaImpl o) {
- Iterator<QName> thisIt = this.targetPath.getPath().iterator();
- Iterator<QName> otherIt = o.getTargetPath().getPath().iterator();
+ public int compareTo(final AugmentationSchemaImpl o) {
+ Iterator<QName> thisIt = this.targetPath.getPathFromRoot().iterator();
+ Iterator<QName> otherIt = o.getTargetPath().getPathFromRoot().iterator();
while (thisIt.hasNext()) {
if (otherIt.hasNext()) {
int comp = thisIt.next().compareTo(otherIt.next());
QName caseQName = caseNode.getQName();
String caseName = caseQName.getLocalName();
- for (ChoiceCaseBuilder addedCase : caseBuilders) {
- if (addedCase.getQName().getLocalName().equals(caseName)) {
+ for (ChoiceCaseBuilder existingCase : caseBuilders) {
+ if (existingCase.getQName().getLocalName().equals(caseName)) {
throw new YangParseException(caseNode.getModuleName(), caseNode.getLine(), "Can not add '" + caseNode
- + "' to node '" + qname.getLocalName() + "' in module '" + moduleName
- + "': case with same name already declared at line " + addedCase.getLine());
+ + "' to node '" + qname.getLocalName() + "' in module '" + getModuleName()
+ + "': case with same name already declared at line " + existingCase.getLine());
}
}
caseBuilder.setAugmenting(true);
caseNode.setAugmenting(false);
}
- SchemaPath newPath = ParserUtils.createSchemaPath(caseNode.getPath(), caseQName);
+ SchemaPath newPath = caseNode.getPath().createChild(caseQName);
caseNode.setPath(newPath);
caseBuilder.addChildNode(caseNode);
caseBuilders.add(caseBuilder);
} else if (!schemaPath.equals(other.schemaPath)) {
return false;
}
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
return true;
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- childNodes.add(node.build());
+ childNodes.put(node.getQName(), node.build());
}
- instance.childNodes = ImmutableSet.copyOf(childNodes);
+ instance.childNodes = ImmutableSet.copyOf(childNodes.values());
// USES
for (UsesNodeBuilder builder : addedUsesNodes) {
}
@Override
- public void setStatus(Status status) {
+ public void setStatus(final Status status) {
this.status = Preconditions.checkNotNull(status, "status cannot be null");
}
@Override
public void addTypedef(final TypeDefinitionBuilder typedefBuilder) {
- throw new YangParseException(moduleName, line, "Can not add type definition to choice case.");
+ throw new YangParseException(getModuleName(), typedefBuilder.getLine(), "Can not add type definition to choice case.");
}
@Override
@Override
public void setConfiguration(final boolean configuration) {
- throw new YangParseException(moduleName, line, "Can not add config statement to choice case.");
+ throw new YangParseException(getModuleName(), getLine(), "Can not add config statement to choice case.");
}
@Override
} else if (!schemaPath.equals(other.schemaPath)) {
return false;
}
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
return true;
import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
import org.opendaylight.yangtools.yang.parser.builder.api.AbstractDataNodeContainerBuilder;
import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationTargetBuilder;
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- childNodes.add(node.build());
+ childNodes.put(node.getQName(), node.build());
}
- instance.childNodes = ImmutableSet.copyOf(childNodes);
+ instance.childNodes = ImmutableSet.copyOf(childNodes.values());
// GROUPINGS
for (GroupingBuilder builder : addedGroupings) {
String typeName = type.getQName().getLocalName();
for (TypeDefinitionBuilder addedTypedef : addedTypedefs) {
if (addedTypedef.getQName().getLocalName().equals(typeName)) {
- throw new YangParseException(moduleName, type.getLine(), "Can not add typedef '" + typeName
+ throw new YangParseException(getModuleName(), type.getLine(), "Can not add typedef '" + typeName
+ "': typedef with same name already declared at line " + addedTypedef.getLine());
}
}
}
@Override
- public void addAugmentation(AugmentationSchemaBuilder augment) {
+ public void addAugmentation(final AugmentationSchemaBuilder augment) {
augmentationBuilders.add(augment);
}
}
@Override
- public void setPath(SchemaPath path) {
+ public void setPath(final SchemaPath path) {
this.path = path;
}
}
@Override
- public void setStatus(Status status) {
+ public void setStatus(final Status status) {
this.status = Preconditions.checkNotNull(status, "status cannot be null");
}
}
@Override
- public void setAugmenting(boolean augmenting) {
+ public void setAugmenting(final boolean augmenting) {
this.augmenting = augmenting;
}
}
@Override
- public void setConfiguration(boolean configuration) {
+ public void setConfiguration(final boolean configuration) {
this.configuration = configuration;
}
return presence;
}
- public void setPresence(boolean presence) {
+ public void setPresence(final boolean presence) {
this.presence = presence;
}
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
} else if (!path.equals(other.path)) {
return false;
}
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ // FIXME: Do we really need this? This actually triggers equals
+ // up to the root builder.
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
return true;
private boolean presence;
- private ContainerSchemaNodeImpl(QName qname, SchemaPath path) {
+ private ContainerSchemaNodeImpl(final QName qname, final SchemaPath path) {
this.qname = qname;
this.path = path;
}
}
@Override
- public DataSchemaNode getDataChildByName(QName name) {
+ public DataSchemaNode getDataChildByName(final QName name) {
return getChildNode(childNodes, name);
}
@Override
- public DataSchemaNode getDataChildByName(String name) {
+ public DataSchemaNode getDataChildByName(final String name) {
return getChildNode(childNodes, name);
}
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
*/
package org.opendaylight.yangtools.yang.parser.builder.impl;
-import java.util.*;
+import java.util.List;
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.Deviation;
import org.opendaylight.yangtools.yang.model.api.Deviation.Deviate;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.parser.builder.api.AbstractBuilder;
-import org.opendaylight.yangtools.yang.parser.util.*;
+import org.opendaylight.yangtools.yang.parser.util.ParserUtils;
+import org.opendaylight.yangtools.yang.parser.util.YangParseException;
import com.google.common.collect.ImmutableList;
@Override
public Deviation build() {
if (targetPath == null) {
- throw new YangParseException(moduleName, line, "Unresolved deviation target");
+ throw new YangParseException(getModuleName(), getLine(), "Unresolved deviation target");
}
if (instance != null) {
} else if ("delete".equals(deviate)) {
this.deviate = Deviate.DELETE;
} else {
- throw new YangParseException(moduleName, line, "Unsupported type of 'deviate' statement: " + deviate);
+ throw new YangParseException(getModuleName(), getLine(), "Unsupported type of 'deviate' statement: " + deviate);
}
}
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- childNodes.add(node.build());
+ childNodes.put(node.getQName(), node.build());
}
- instance.childNodes = ImmutableSet.copyOf(childNodes);
+ instance.childNodes = ImmutableSet.copyOf(childNodes.values());
// GROUPINGS
for (GroupingBuilder builder : addedGroupings) {
}
@Override
- public Set<DataSchemaNodeBuilder> instantiateChildNodes(Builder newParent) {
+ public Set<DataSchemaNodeBuilder> instantiateChildNodes(final Builder newParent) {
final Set<DataSchemaNodeBuilder> nodes = new HashSet<>();
for (DataSchemaNodeBuilder node : addedChildNodes) {
DataSchemaNodeBuilder copy = CopyUtils.copy(node, newParent, true);
}
@Override
- public Set<TypeDefinitionBuilder> instantiateTypedefs(Builder newParent) {
+ public Set<TypeDefinitionBuilder> instantiateTypedefs(final Builder newParent) {
final Set<TypeDefinitionBuilder> nodes = new HashSet<>();
for (TypeDefinitionBuilder node : addedTypedefs) {
TypeDefinitionBuilder copy = CopyUtils.copy(node, newParent, true);
}
@Override
- public Set<GroupingBuilder> instantiateGroupings(Builder newParent) {
+ public Set<GroupingBuilder> instantiateGroupings(final Builder newParent) {
final Set<GroupingBuilder> nodes = new HashSet<>();
for (GroupingBuilder node : addedGroupings) {
GroupingBuilder copy = CopyUtils.copy(node, newParent, true);
}
@Override
- public Set<UnknownSchemaNodeBuilder> instantiateUnknownNodes(Builder newParent) {
+ public Set<UnknownSchemaNodeBuilder> instantiateUnknownNodes(final Builder newParent) {
final Set<UnknownSchemaNodeBuilder> nodes = new HashSet<>();
for (UnknownSchemaNodeBuilder node : addedUnknownNodes) {
UnknownSchemaNodeBuilder copy = CopyUtils.copy(node, newParent, true);
public void addTypedef(final TypeDefinitionBuilder type) {
String typeName = type.getQName().getLocalName();
for (TypeDefinitionBuilder addedTypedef : addedTypedefs) {
- throw new YangParseException(moduleName, type.getLine(), "Can not add typedef '" + typeName
+ throw new YangParseException(getModuleName(), type.getLine(), "Can not add typedef '" + typeName
+ "': typedef with same name already declared at line " + addedTypedef.getLine());
}
addedTypedefs.add(type);
}
@Override
- public void setStatus(Status status) {
+ public void setStatus(final Status status) {
this.status = Preconditions.checkNotNull(status, "status cannot be null");
}
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((parentBuilder == null) ? 0 : parentBuilder.hashCode());
+ result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
return result;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
return false;
}
final GroupingBuilderImpl other = (GroupingBuilderImpl) obj;
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
if (schemaPath == null) {
}
@Override
- public DataSchemaNode getDataChildByName(QName name) {
+ public DataSchemaNode getDataChildByName(final QName name) {
return getChildNode(childNodes, name);
}
@Override
- public DataSchemaNode getDataChildByName(String name) {
+ public DataSchemaNode getDataChildByName(final String name) {
return getChildNode(childNodes, name);
}
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
import java.util.List;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
-import org.opendaylight.yangtools.yang.model.api.type.*;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
import org.opendaylight.yangtools.yang.parser.builder.api.AbstractTypeAwareBuilder;
}
@Override
- public void setQName(QName qname) {
+ public void setQName(final QName qname) {
this.qname = qname;
}
@Override
public IdentityrefType build() {
- return new IdentityrefType(baseIdentity.build(), schemaPath);
+ return IdentityrefType.create(schemaPath, baseIdentity.build());
}
public String getBaseString() {
return baseString;
}
- public void setBaseIdentity(IdentitySchemaNodeBuilder baseIdentity) {
+ public void setBaseIdentity(final IdentitySchemaNodeBuilder baseIdentity) {
this.baseIdentity = baseIdentity;
}
@Override
public void setType(final TypeDefinition<?> type) {
- throw new YangParseException(moduleName, line, "Can not set type to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set type to " + NAME);
}
@Override
public void setTypedef(final TypeDefinitionBuilder tdb) {
- throw new YangParseException(moduleName, line, "Can not set type to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set type to " + NAME);
}
@Override
public void setDescription(final String description) {
- throw new YangParseException(moduleName, line, "Can not set description to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set description to " + NAME);
}
@Override
public void setReference(final String reference) {
- throw new YangParseException(moduleName, line, "Can not set reference to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set reference to " + NAME);
}
@Override
public void setStatus(final Status status) {
- throw new YangParseException(moduleName, line, "Can not set status to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set status to " + NAME);
}
@Override
@Override
public void setAddedByUses(final boolean addedByUses) {
- throw new YangParseException(moduleName, line, "Identityref type can not be added by uses.");
+ throw new YangParseException(getModuleName(), getLine(), "Identityref type can not be added by uses.");
}
@Override
public void addUnknownNodeBuilder(final UnknownSchemaNodeBuilder unknownNode) {
- throw new YangParseException(moduleName, line, "Can not add unknown node to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not add unknown node to " + NAME);
}
@Override
}
@Override
- public void setPath(SchemaPath path) {
+ public void setPath(final SchemaPath path) {
this.schemaPath = path;
}
}
@Override
- public void setRanges(List<RangeConstraint> ranges) {
- throw new YangParseException(moduleName, line, "Can not set ranges to " + NAME);
+ public void setRanges(final List<RangeConstraint> ranges) {
+ throw new YangParseException(getModuleName(), getLine(), "Can not set ranges to " + NAME);
}
@Override
}
@Override
- public void setLengths(List<LengthConstraint> lengths) {
- throw new YangParseException(moduleName, line, "Can not set lengths to " + NAME);
+ public void setLengths(final List<LengthConstraint> lengths) {
+ throw new YangParseException(getModuleName(), getLine(), "Can not set lengths to " + NAME);
}
@Override
}
@Override
- public void setPatterns(List<PatternConstraint> patterns) {
- throw new YangParseException(moduleName, line, "Can not set patterns to " + NAME);
+ public void setPatterns(final List<PatternConstraint> patterns) {
+ throw new YangParseException(getModuleName(), getLine(), "Can not set patterns to " + NAME);
}
@Override
}
@Override
- public void setFractionDigits(Integer fractionDigits) {
- throw new YangParseException(moduleName, line, "Can not set fraction digits to " + NAME);
+ public void setFractionDigits(final Integer fractionDigits) {
+ throw new YangParseException(getModuleName(), getLine(), "Can not set fraction digits to " + NAME);
}
@Override
}
@Override
- public void setDefaultValue(Object defaultValue) {
- throw new YangParseException(moduleName, line, "Can not set default value to " + NAME);
+ public void setDefaultValue(final Object defaultValue) {
+ throw new YangParseException(getModuleName(), getLine(), "Can not set default value to " + NAME);
}
@Override
public String getUnits() {
return null;
}
-
@Override
- public void setUnits(String units) {
- throw new YangParseException(moduleName, line, "Can not set units to " + NAME);
+ public void setUnits(final String units) {
+ throw new YangParseException(getModuleName(), getLine(), "Can not set units to " + NAME);
}
@Override
} else if (!schemaPath.equals(other.schemaPath)) {
return false;
}
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
return true;
instance.unitsStr = unitsStr;
if (type == null && typedef == null) {
- throw new YangParseException(moduleName, line, "Failed to resolve leaf type.");
+ throw new YangParseException(getModuleName(), getLine(), "Failed to resolve leaf type.");
}
// TYPE
} else if (!schemaPath.equals(other.schemaPath)) {
return false;
}
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
return true;
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- childNodes.add(node.build());
+ childNodes.put(node.getQName(), node.build());
}
- instance.childNodes = ImmutableSet.copyOf(childNodes);
+ instance.childNodes = ImmutableSet.copyOf(childNodes.values());
// KEY
if (keys == null) {
String typeName = type.getQName().getLocalName();
for (TypeDefinitionBuilder addedTypedef : addedTypedefs) {
if (addedTypedef.getQName().getLocalName().equals(typeName)) {
- throw new YangParseException(moduleName, type.getLine(), "Can not add typedef '" + typeName
+ throw new YangParseException(getModuleName(), type.getLine(), "Can not add typedef '" + typeName
+ "': typedef with same name already declared at line " + addedTypedef.getLine());
}
}
}
@Override
- public void setPath(SchemaPath path) {
+ public void setPath(final SchemaPath path) {
this.schemaPath = path;
}
}
@Override
- public void setStatus(Status status) {
+ public void setStatus(final Status status) {
this.status = Preconditions.checkNotNull(status, "status cannot be null");
}
}
@Override
- public void setAugmenting(boolean augmenting) {
+ public void setAugmenting(final boolean augmenting) {
this.augmenting = augmenting;
}
}
@Override
- public void setConfiguration(boolean configuration) {
+ public void setConfiguration(final boolean configuration) {
this.configuration = configuration;
}
} else if (!schemaPath.equals(other.schemaPath)) {
return false;
}
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
return true;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Deque;
revision = base.getRevision();
for (DataSchemaNode childNode : base.getChildNodes()) {
- childNodes.add(childNode);
+ childNodes.put(childNode.getQName(), childNode);
}
typedefs.addAll(base.getTypeDefinitions());
// CHILD NODES
for (DataSchemaNodeBuilder child : addedChildNodes) {
- childNodes.add(child.build());
+ childNodes.put(child.getQName(), child.build());
}
- instance.addChildNodes(childNodes);
+ instance.addChildNodes(childNodes.values());
// GROUPINGS
for (GroupingBuilder gb : addedGroupings) {
return Collections.unmodifiableSet(childNodes);
}
- private void addChildNodes(final Set<DataSchemaNode> childNodes) {
+ private void addChildNodes(final Collection<DataSchemaNode> childNodes) {
if (childNodes != null) {
this.childNodes.addAll(childNodes);
}
String msg = String.format("%s%s with same name '%s' already declared at line %d.", msgPrefix, type, name,
duplicateLine);
- throw new YangParseException(moduleName, currentLine, msg);
+ throw new YangParseException(getModuleName(), currentLine, msg);
}
@Override
@Override
public NotificationDefinition build() {
- if (!(parentBuilder instanceof ModuleBuilder)) {
- throw new YangParseException(moduleName, line, "Notification can be defined only under module (was " + parentBuilder + ")");
+ if (!(getParent() instanceof ModuleBuilder)) {
+ throw new YangParseException(getModuleName(), getLine(), "Notification can be defined only under module (was " + getParent() + ")");
}
if (instance != null) {
return instance;
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- childNodes.add(node.build());
+ childNodes.put(node.getQName(), node.build());
}
- instance.childNodes = ImmutableSet.copyOf(childNodes);
+ instance.childNodes = ImmutableSet.copyOf(childNodes.values());
// GROUPINGS
for (GroupingBuilder builder : addedGroupings) {
}
@Override
- public void setPath(SchemaPath path) {
+ public void setPath(final SchemaPath path) {
this.schemaPath = path;
}
}
@Override
- public void setStatus(Status status) {
+ public void setStatus(final Status status) {
this.status = Preconditions.checkNotNull(status, "status cannot be null");
}
for (TypeDefinitionBuilder tdb : typedefs) {
types.add(tdb.build());
}
- instance = new UnionType(types);
+ instance = UnionType.create(types);
isBuilt = true;
}
return instance;
@Override
public void setDescription(final String description) {
- throw new YangParseException(moduleName, line, "Can not set description to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set description to " + NAME);
}
@Override
public void setReference(final String reference) {
- throw new YangParseException(moduleName, line, "Can not set reference to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set reference to " + NAME);
}
@Override
public void setStatus(final Status status) {
- throw new YangParseException(moduleName, line, "Can not set status to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set status to " + NAME);
}
@Override
@Override
public void setAddedByUses(final boolean addedByUses) {
- throw new YangParseException(moduleName, line, "Union type can not be added by uses.");
+ throw new YangParseException(getModuleName(), getLine(), "Union type can not be added by uses.");
}
@Override
@Override
public SchemaPath getPath() {
- return BaseTypes.schemaPath(QNAME);
+ return SchemaPath.create(true, QNAME);
}
@Override
public void setPath(final SchemaPath path) {
- throw new YangParseException(moduleName, line, "Can not set path to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set path to " + NAME);
}
@Override
@Override
public void setRanges(final List<RangeConstraint> ranges) {
- throw new YangParseException(moduleName, line, "Can not set ranges to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set ranges to " + NAME);
}
@Override
@Override
public void setLengths(final List<LengthConstraint> lengths) {
- throw new YangParseException(moduleName, line, "Can not set lengths to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set lengths to " + NAME);
}
@Override
@Override
public void setPatterns(final List<PatternConstraint> patterns) {
- throw new YangParseException(moduleName, line, "Can not set patterns to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set patterns to " + NAME);
}
@Override
@Override
public void setFractionDigits(final Integer fractionDigits) {
- throw new YangParseException(moduleName, line, "Can not set fraction digits to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set fraction digits to " + NAME);
}
@Override
@Override
public void setDefaultValue(final Object defaultValue) {
- throw new YangParseException(moduleName, line, "Can not set default value to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set default value to " + NAME);
}
@Override
@Override
public void setUnits(final String units) {
- throw new YangParseException(moduleName, line, "Can not set units to " + NAME);
+ throw new YangParseException(getModuleName(), getLine(), "Can not set units to " + NAME);
}
@Override
@Override
public void setParent(final Builder parent) {
if (!(parent instanceof DataNodeContainerBuilder)) {
- throw new YangParseException(moduleName, line,
+ throw new YangParseException(getModuleName(), getLine(),
"Parent of 'uses' has to be instance of DataNodeContainerBuilder, but was: '" + parent + "'.");
}
this.parentBuilder = (DataNodeContainerBuilder) parent;
import org.opendaylight.yangtools.antlrv4.code.gen.YangParser;
import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.YangContext;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
module.getAugmentBuilders().addAll(submodule.getAugmentBuilders());
module.getAllAugments().addAll(submodule.getAllAugments());
module.getChildNodeBuilders().addAll(submodule.getChildNodeBuilders());
- module.getChildNodes().addAll(submodule.getChildNodes());
+ module.getChildNodes().putAll(submodule.getChildNodes());
module.getGroupings().addAll(submodule.getGroupings());
module.getGroupingBuilders().addAll(submodule.getGroupingBuilders());
module.getTypeDefinitions().addAll(submodule.getTypeDefinitions());
prefix = baseQName.getPrefix();
}
+ final QNameModule qm = QNameModule.create(ns, revision);
for (QName qn : oldSchemaPath.getPath()) {
- newPath.add(new QName(ns, revision, prefix, qn.getLocalName()));
+ newPath.add(QName.create(qm, prefix, qn.getLocalName()));
}
} else {
for (QName qn : oldPath) {
*/
private void checkAugmentMandatoryNodes(final Collection<AugmentationSchemaBuilder> augments) {
for (AugmentationSchemaBuilder augment : augments) {
- String augmentPrefix = augment.getTargetPath().getPath().get(0).getPrefix();
+ String augmentPrefix = augment.getTargetPath().getPathFromRoot().iterator().next().getPrefix();
ModuleBuilder module = ParserUtils.getParentModule(augment);
String modulePrefix = module.getPrefix();
return true;
}
- List<QName> targetPath = augment.getTargetPath().getPath();
- ModuleBuilder targetModule = findTargetModule(targetPath.get(0), module, modules, context, augment.getLine());
+ QName targetPath = augment.getTargetPath().getPathFromRoot().iterator().next();
+ ModuleBuilder targetModule = findTargetModule(targetPath, module, modules, context, augment.getLine());
if (targetModule == null) {
throw new YangParseException(module.getModuleName(), augment.getLine(), "Failed to resolve augment "
+ augment);
for (DeviationBuilder dev : module.getDeviationBuilders()) {
int line = dev.getLine();
SchemaPath targetPath = dev.getTargetPath();
- List<QName> path = targetPath.getPath();
- QName q0 = path.get(0);
+ Iterable<QName> path = targetPath.getPathFromRoot();
+ QName q0 = path.iterator().next();
String prefix = q0.getPrefix();
if (prefix == null) {
prefix = module.getPrefix();
for (DeviationBuilder dev : module.getDeviationBuilders()) {
int line = dev.getLine();
SchemaPath targetPath = dev.getTargetPath();
- List<QName> path = targetPath.getPath();
- QName q0 = path.get(0);
+ Iterable<QName> path = targetPath.getPathFromRoot();
+ QName q0 = path.iterator().next();
String prefix = q0.getPrefix();
if (prefix == null) {
prefix = module.getPrefix();
* current module
*/
private void processDeviation(final DeviationBuilder dev, final ModuleBuilder dependentModuleBuilder,
- final List<QName> path, final ModuleBuilder module) {
+ final Iterable<QName> path, final ModuleBuilder module) {
final int line = dev.getLine();
Builder currentParent = dependentModuleBuilder;
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/eplv10.html
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
+/**
+ * Helper transfer object which holds basic and dependency information for YANG
+ * model.
+ *
+ *
+ *
+ * There are two concrete implementations of this interface:
+ * <ul>
+ * <li>{@link ModuleDependencyInfo} - Dependency information for module</li>
+ * <li>{@link SubmoduleDependencyInfo} - Dependency information for submodule</li>
+ * </ul>
+ *
+ * @see ModuleDependencyInfo
+ * @see SubmoduleDependencyInfo
+ *
+ */
public abstract class YangModelDependencyInfo {
private final String name;
private final ImmutableSet<ModuleImport> moduleImports;
private final ImmutableSet<ModuleImport> dependencies;
- public YangModelDependencyInfo(final String name, final String formattedRevision, final ImmutableSet<ModuleImport> imports,
- final ImmutableSet<ModuleImport> includes) {
+ protected YangModelDependencyInfo(final String name, final String formattedRevision,
+ final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
this.name = name;
this.formattedRevision = formattedRevision;
this.revision = QName.parseRevision(formattedRevision);
.build();
}
+ /**
+ * Returns immutable collection of all module imports.
+ *
+ * This collection contains both <code>import</code> statements
+ * and <code>include</code> statements for submodules.
+ *
+ * @return Immutable collection of imports.
+ */
public ImmutableSet<ModuleImport> getDependencies() {
return dependencies;
}
+ /**
+ * Returns model name
+ *
+ * @return model name
+ */
public String getName() {
return name;
}
+ /**
+ * Returns formatted revision string
+ *
+ * @return formatted revision string
+ */
public String getFormattedRevision() {
return formattedRevision;
}
+ /**
+ * Returns revision
+ *
+ * @return revision
+ */
public Date getRevision() {
return revision;
}
return true;
}
+ /**
+ * Extracts {@link YangModelDependencyInfo} from input stream
+ * containing YANG model.
+ *
+ * This parsing does not validate full YANG module, only
+ * parses header up to the revisions and imports.
+ *
+ * @param yangStream
+ * Opened Input stream containing text source of YANG model
+ * @return {@link YangModelDependencyInfo}
+ * @throws IllegalArgumentException
+ * If input stream is not valid YANG stream
+ */
public static YangModelDependencyInfo fromInputStream(final InputStream yangStream) {
YangContext yangContext = YangParserImpl.parseStreamWithoutErrorListeners(yangStream);
Optional<Module_stmtContext> moduleCtx = getFirstContext(yangContext, Module_stmtContext.class);
if (moduleCtx.isPresent()) {
- return fromModuleContext(moduleCtx.get());
+ return parseModuleContext(moduleCtx.get());
}
Optional<Submodule_stmtContext> submoduleCtx = getFirstContext(yangContext, Submodule_stmtContext.class);
if (submoduleCtx.isPresent()) {
- return fromSubmoduleContext(submoduleCtx.get());
+ return parseSubmoduleContext(submoduleCtx.get());
}
throw new IllegalArgumentException("Supplied stream is not valid yang file.");
}
- private static YangModelDependencyInfo fromModuleContext(final Module_stmtContext module) {
+ private static YangModelDependencyInfo parseModuleContext(final Module_stmtContext module) {
String name = getArgumentString(module);
// String prefix =
// getArgumentString(module.module_header_stmts().prefix_stmt(0));
String namespace = getArgumentString(module.module_header_stmts().namespace_stmt(0));
String latestRevision = getLatestRevision(module.revision_stmts());
- ImmutableSet<ModuleImport> imports = getImports(module.linkage_stmts().import_stmt());
- ImmutableSet<ModuleImport> includes = getIncludes(module.linkage_stmts().include_stmt());
+ ImmutableSet<ModuleImport> imports = parseImports(module.linkage_stmts().import_stmt());
+ ImmutableSet<ModuleImport> includes = parseIncludes(module.linkage_stmts().include_stmt());
return new ModuleDependencyInfo(name, latestRevision, namespace, imports, includes);
}
- private static ImmutableSet<ModuleImport> getImports(final List<Import_stmtContext> importStatements) {
+ private static ImmutableSet<ModuleImport> parseImports(final List<Import_stmtContext> importStatements) {
ImmutableSet.Builder<ModuleImport> builder = ImmutableSet.builder();
for (Import_stmtContext importStmt : importStatements) {
String moduleName = getArgumentString(importStmt);
return latestRevision;
}
- private static YangModelDependencyInfo fromSubmoduleContext(final Submodule_stmtContext submodule) {
+ private static YangModelDependencyInfo parseSubmoduleContext(final Submodule_stmtContext submodule) {
String name = getArgumentString(submodule);
Belongs_to_stmtContext belongsToStmt = submodule.submodule_header_stmts().belongs_to_stmt(0);
String belongsTo = getArgumentString(belongsToStmt);
String latestRevision = getLatestRevision(submodule.revision_stmts());
- ImmutableSet<ModuleImport> imports = getImports(submodule.linkage_stmts().import_stmt());
- ImmutableSet<ModuleImport> includes = getIncludes(submodule.linkage_stmts().include_stmt());
+ ImmutableSet<ModuleImport> imports = parseImports(submodule.linkage_stmts().import_stmt());
+ ImmutableSet<ModuleImport> includes = parseIncludes(submodule.linkage_stmts().include_stmt());
return new SubmoduleDependencyInfo(name, latestRevision, belongsTo, imports, includes);
}
- private static ImmutableSet<ModuleImport> getIncludes(final List<Include_stmtContext> importStatements) {
+ private static ImmutableSet<ModuleImport> parseIncludes(final List<Include_stmtContext> importStatements) {
ImmutableSet.Builder<ModuleImport> builder = ImmutableSet.builder();
for (Include_stmtContext importStmt : importStatements) {
String moduleName = getArgumentString(importStmt);
return QName.parseRevision(formatedDate);
}
+ /**
+ *
+ * Dependency information for YANG module.
+ *
+ */
public static final class ModuleDependencyInfo extends YangModelDependencyInfo {
private ModuleDependencyInfo(final String name, final String latestRevision, final String namespace,
@Override
public String toString() {
- return "Module [name=" + getName() + ", revision=" + getRevision()
- + ", dependencies=" + getDependencies() + "]";
+ return "Module [name=" + getName() + ", revision=" + getRevision() + ", dependencies=" + getDependencies()
+ + "]";
}
}
+ /**
+ *
+ * Dependency information for submodule, also provides name
+ * for parent module.
+ *
+ */
public static final class SubmoduleDependencyInfo extends YangModelDependencyInfo {
private final String belongsTo;
+ /**
+ * Returns name of parent module.
+ *
+ */
public String getParentModule() {
return belongsTo;
}
@Override
public String toString() {
- return "Submodule [name=" + getName() + ", revision=" + getRevision()
- + ", dependencies=" + getDependencies() + "]";
+ return "Submodule [name=" + getName() + ", revision=" + getRevision() + ", dependencies="
+ + getDependencies() + "]";
}
}
+ /**
+ * Utility implementation of {@link ModuleImport} to be used by
+ * {@link YangModelDependencyInfo}.
+ *
+ */
private static final class ModuleImportImpl implements ModuleImport {
private final Date revision;
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/eplv10.html
import java.util.Map;
import java.util.Set;
+import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
-public class YangSourceContext implements AdvancedSchemaSourceProvider<InputStream>, AutoCloseable {
+/**
+ *
+ * Context of YANG model sources
+ *
+ * YANG sources context represent information learned about set of model sources
+ * which could be derived from dependency information only.
+ *
+ * Contains following information:
+ * <ul>
+ * <li>{@link #getValidSources()} - set of {@link SourceIdentifier} which have
+ * their dependencies present and are safe to be used by full blown parser.
+ * <li>{@link #getMissingSources()} - set of {@link SourceIdentifier} which have
+ * been referenced by other YANG sources, but source code for them is missing.
+ * <li>{@link #getMissingDependencies()} - map of {@link SourceIdentifier} and
+ * their imports for which source codes was not available.
+ *
+ * {@link YangSourceContext} may be associated with {@link SchemaSourceProvider}
+ * (see {@link #getDelegate()}, which was used for retrieval of sources during
+ * context computation.
+ *
+ * {@link YangSourceContext} may be used as schema source provider to retrieve
+ * this sources.
+ *
+ *
+ */
+public class YangSourceContext implements AdvancedSchemaSourceProvider<InputStream>, AutoCloseable,
+ Delegator<AdvancedSchemaSourceProvider<InputStream>> {
private final ImmutableSet<SourceIdentifier> validSources;
private final ImmutableMultimap<SourceIdentifier, ModuleImport> missingDependencies;
private AdvancedSchemaSourceProvider<InputStream> sourceProvider;
+ /**
+ * Construct YANG Source Context
+ *
+ * @param validSourcesSet Set of identifiers of valid sources
+ * @param missingSourcesSet Set of identifiers of missing sources
+ * @param missingDependenciesMap Map of identifiers of resolved sources and their missing imports.
+ * @param sourceProvider Source provider which was used for context resolution or
+ * null if provider was not used.
+ */
YangSourceContext(final ImmutableSet<SourceIdentifier> validSourcesSet,
final ImmutableSet<SourceIdentifier> missingSourcesSet,
final ImmutableMultimap<SourceIdentifier, ModuleImport> missingDependenciesMap,
- final AdvancedSchemaSourceProvider<InputStream> sourceProvicer) {
- validSources = validSourcesSet;
- missingSources = missingSourcesSet;
- missingDependencies = missingDependenciesMap;
- sourceProvider = sourceProvicer;
+ final AdvancedSchemaSourceProvider<InputStream> sourceProvider) {
+ validSources = Preconditions.checkNotNull(validSourcesSet, "Valid source set must not be null");
+ missingSources = Preconditions.checkNotNull(missingSourcesSet, "Missing sources set must not be null");
+ missingDependencies = Preconditions.checkNotNull(missingDependenciesMap, "Missing dependencies map must not be null");
+ this.sourceProvider = sourceProvider;
}
+ /**
+ * Returns set of valid source identifiers.
+ *
+ * Source identifier is considered valid if it's source
+ * was present during resolution and sources
+ * for all known dependencies was present at the time of creation
+ * of {@link YangSourceContext}.
+ *
+ * @return Set of valid source identifiers.
+ */
public ImmutableSet<SourceIdentifier> getValidSources() {
return validSources;
}
+ /**
+ * Returns set of source identifiers, whom sources was not resolved.
+ *
+ * Source is considered missing if the source was not present
+ * during resolution of {@link YangSourceContext}.
+ *
+ * @return Set of missing sources.
+ */
public ImmutableSet<SourceIdentifier> getMissingSources() {
return missingSources;
}
+ /**
+ * Returns a multimap of Source Identifier and imports which had missing
+ * sources.
+ *
+ * Maps a source identifier to its imports, which was not resolved
+ * during resolution of this context, so it is unable to fully
+ * processed source identifier.
+ *
+ *
+ * @return Multi-map of source identifier to it's unresolved dependencies.
+ */
public ImmutableMultimap<SourceIdentifier, ModuleImport> getMissingDependencies() {
return missingDependencies;
}
return sourceProvider;
}
+ @Override
+ public AdvancedSchemaSourceProvider<InputStream> getDelegate() {
+ return sourceProvider;
+ }
+
@Override
public void close() {
if (sourceProvider != null) {
}
}
+ /**
+ * Creates YANG Source context from supplied capabilities and schema source
+ * provider.
+ *
+ * @param capabilities
+ * Set of QName representing module capabilities,
+ * {@link QName#getLocalName()} represents
+ * source name and {@link QName#getRevision()} represents
+ * revision of source.
+ *
+ * @param schemaSourceProvider
+ * - {@link SchemaSourceProvider} which should be used to resolve
+ * sources.
+ * @return YANG source context which describes resolution of capabilities
+ * and their dependencies
+ * against supplied schema source provider.
+ */
public static final YangSourceContext createFrom(final Iterable<QName> capabilities,
final SchemaSourceProvider<InputStream> schemaSourceProvider) {
YangSourceContextResolver resolver = new YangSourceFromCapabilitiesResolver(capabilities, schemaSourceProvider);
return resolver.resolveContext();
}
- public static final YangSourceContext createFrom(final Map<SourceIdentifier, YangModelDependencyInfo> moduleDependencies) {
+ public static final YangSourceContext createFrom(
+ final Map<SourceIdentifier, YangModelDependencyInfo> moduleDependencies) {
YangSourceContextResolver resolver = new YangSourceFromDependencyInfoResolver(moduleDependencies);
return resolver.resolveContext();
}
+ /**
+ * Tries to create schema context using {@link YangParserImpl} and valid
+ * sources
+ * retrieved from YANG Source context and schema source provider which
+ * was used to create YANG Source Context
+ *
+ * @param context
+ * @return Schema Context created from valid sources in YANG Source Context
+ * @deprecated Use {@link #toSchemaContext(AdvancedSchemaSourceProvider)}
+ * with {@link #getDelegate()}
+ */
+ @Deprecated
public static final SchemaContext toSchemaContext(final YangSourceContext context) {
- List<InputStream> inputStreams = getValidInputStreams(context);
+ return context.toSchemaContext(context.getDelegate());
+ }
+
+ /**
+ * Tries to create schema context using {@link YangParserImpl} and valid
+ * sources
+ * retrieved from YANG Source context and schema source provider which
+ * was used to create YANG Source Context
+ *
+ * @param provider
+ * Schema Source Provider to be used to retrieve sources
+ * @return Schema Context created from valid sources in YANG Source Context
+ */
+ public final SchemaContext toSchemaContext(AdvancedSchemaSourceProvider<InputStream> provider) {
+ List<InputStream> inputStreams = this.getValidInputStreams(provider);
YangParserImpl parser = new YangParserImpl();
+ @SuppressWarnings("deprecation")
Set<Module> models = parser.parseYangModelsFromStreams(inputStreams);
return parser.resolveSchemaContext(models);
}
+ /**
+ * Returns a list of valid input streams from YANG Source Context
+ * using schema source provider which was used to create YANG Source Context
+ *
+ * @param context
+ * YANG Source context
+ * @return List of input streams for valid sources.
+ * @deprecated Use
+ * {@link #getValidInputStreams(AdvancedSchemaSourceProvider)}
+ * combined with {@link #getDelegate()} instead.
+ */
+ @Deprecated
public static List<InputStream> getValidInputStreams(final YangSourceContext context) {
- return getValidInputStreams(context, context.sourceProvider);
+ return context.getValidInputStreams(context.getDelegate());
}
+ /**
+ * Returns a list of valid input streams from YANG Source Context
+ * using supplied schema source provider.
+ *
+ * @param context
+ * YANG Source context from which list of valid sources is used
+ * @param provider
+ * Schema Source Provider which is used to retrieve sources
+ * @return List of input streams.
+ * @deprecated Use
+ * {@link #getValidInputStreams(AdvancedSchemaSourceProvider)}
+ * instead.
+ */
+ @Deprecated
public static List<InputStream> getValidInputStreams(final YangSourceContext context,
final AdvancedSchemaSourceProvider<InputStream> provider) {
+ return context.getValidInputStreams(provider);
+ }
+
+ /**
+ * Returns a list of valid input streams from YANG Source Context
+ * using supplied schema source provider.
+ *
+ * @param context
+ * YANG Source context from which list of valid sources is used
+ * @param provider
+ * Schema Source Provider which is used to retrieve sources
+ * @return List of input streams.
+ */
+ public List<InputStream> getValidInputStreams(final AdvancedSchemaSourceProvider<InputStream> provider) {
+ Preconditions.checkNotNull(provider, "provider must not be null.");
final HashSet<SourceIdentifier> sourcesToLoad = new HashSet<>();
- sourcesToLoad.addAll(context.getValidSources());
- for (SourceIdentifier source : context.getValidSources()) {
+ sourcesToLoad.addAll(this.getValidSources());
+ for (SourceIdentifier source : this.getValidSources()) {
if (source.getRevision() != null) {
SourceIdentifier sourceWithoutRevision = SourceIdentifier.create(source.getName(),
Optional.<String> absent());
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/eplv10.html
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider;
+import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
+/**
+ *
+ * Resolution task for YANG Source Context
+ *
+ * {@link YangSourceContextResolver} and its subclasses are responsible for
+ * resolving {@link YangSourceContext} based on provided
+ * {@link SchemaSourceProvider} and set of modules to process.
+ *
+ *
+ * <h3>Implementation notes</h3>
+ *
+ * In order to customize resolution of {@link YangSourceContext} implementators
+ * of this class are required to implement following methods:
+ * <ul>
+ * <li>{@link #getDependencyInfo(SourceIdentifier)} - Retrieval of dependency
+ * information</li>
+ * <li>{@link #resolveContext()} - Main resolution algorithm
+ * <li>
+ * </ul>
+ *
+ * This abstract class provides utility methods for implementators which may be
+ * used in {@link #resolveContext()} to create {@link YangSourceContext}:
+ * <ul>
+ * <li>{@link #resolveSource(SourceIdentifier)} and
+ * {@link #resolveSource(String, Optional)} - Tries to resolve state for
+ * supplied model identifier and updates internal state. If state was not
+ * already resolved for identifier it invokes
+ * {@link #getDependencyInfo(SourceIdentifier)} for particular identifier. This
+ * method is recursivelly invoked for all dependencies.</li>
+ * <li>{@link #createSourceContext()} - Creates {@link YangSourceContext} based
+ * on previous invocations of {@link #resolveSource(SourceIdentifier)} methods.</li>
+ * </ul>
+ *
+ */
public abstract class YangSourceContextResolver {
- enum ResolutionState {
- MISSING_SOURCE,
- MISSING_DEPENDENCY,
- OTHER_ERROR,
+ /**
+ *
+ * State of source code resolution
+ *
+ */
+ public enum ResolutionState {
+ /**
+ *
+ * Source was missing during source resolution
+ *
+ */
+ MISSING_SOURCE,
+ /**
+ *
+ * One or multiple of dependencies of source are missing
+ *
+ */
+ MISSING_DEPENDENCY,
+ /**
+ * Other error ocurred during resolution
+ *
+ */
+ OTHER_ERROR,
+ /**
+ * Source, its dependencies and its transient dependencies
+ * are resolved.
+ *
+ */
EVERYTHING_OK,
}
private static final Logger LOG = LoggerFactory.getLogger(YangSourceContextResolver.class);
private final HashMap<SourceIdentifier, YangSourceContextResolver.ResolutionState> alreadyProcessed = new HashMap<>();
private final ImmutableSet.Builder<SourceIdentifier> missingSources = ImmutableSet.builder();
- private final ImmutableMultimap.Builder<SourceIdentifier, ModuleImport> missingDependencies =
- ImmutableMultimap.builder();
+ private final ImmutableMultimap.Builder<SourceIdentifier, ModuleImport> missingDependencies = ImmutableMultimap
+ .builder();
private final ImmutableSet.Builder<SourceIdentifier> validSources = ImmutableSet.builder();
private final AdvancedSchemaSourceProvider<InputStream> sourceProvider;
}
public YangSourceContextResolver(final AdvancedSchemaSourceProvider<InputStream> sourceProvicer) {
- super();
this.sourceProvider = sourceProvicer;
}
+ /**
+ * Resolves {@link YangSourceContext}
+ *
+ * Implementators of this method should invoke
+ * {@link #resolveSource(SourceIdentifier)} for sources which should be
+ * present in {@link YangSourceContext} and {@link #createSourceContext()}
+ * to create resulting {@link YangSourceContext} which will contain state
+ * derived by callbacks to {@link #getDependencyInfo(SourceIdentifier)}.
+ *
+ * @return Resolved {@link YangSourceContext}.
+ */
public abstract YangSourceContext resolveContext();
- public abstract Optional<YangModelDependencyInfo> getDependencyInfo(SourceIdentifier identifier);
+ /**
+ * Returns dependency information for provided identifier
+ *
+ * Implementations are required to:
+ * <ul>
+ * <li>return {@link Optional#absent()} If source code for source is not
+ * present</li>
+ * <li>return same dependency information for multiple invocations of this
+ * method for same source identifier.</li>
+ * <li>return latest available revision if {@link SourceIdentifier} does not
+ * specify revision. If no revision is available {@link Optional#absent()}
+ * MUST be returned.</li>
+ * </ul>
+ *
+ *
+ * Internal state of this object (and resulting {@link YangSourceContext}
+ * will be updated as following:
+ * <ul>
+ * <li>If {@link Optional#absent()} is returned:
+ * <ul>
+ * <li>source will be marked as {@link ResolutionState#MISSING_SOURCE} and
+ * source identifier will be contained in -
+ * {@link YangSourceContext#getMissingSources()}</li>
+ * <li>All sources which imported or included this source will be present in
+ * {@link YangSourceContext#getMissingDependencies()}</li>
+ * </ul>
+ *
+ *
+ *
+ * @param identifier
+ * Source identifier
+ * @return Dependency Information for {@link SourceIdentifier},
+ * {@link Optional#absent()} if no source is present.
+ */
+ abstract Optional<YangModelDependencyInfo> getDependencyInfo(SourceIdentifier identifier);
+
+ /**
+ * Return Source provider against which YANG source context was computed
+ *
+ * @return Source provider against which YANG source context was computed or null, if source provider
+ * is not associated with computation.
+ */
public AdvancedSchemaSourceProvider<InputStream> getSourceProvider() {
return sourceProvider;
}
- public YangSourceContextResolver.ResolutionState resolveSource(final String name, final Optional<String> formattedRevision) {
+ /**
+ *
+ * Resolves resolution state for provided name and formated revision
+ *
+ * This method is shorthand for {@link #resolveSource(SourceIdentifier)}
+ * with argument <code>new SourceIdentifier(name, formattedRevision)</code>
+ *
+ * @see #resolveSource(SourceIdentifier)
+ * @param name
+ * Name of YANG model
+ * @param formattedRevision
+ * revision of YANG model
+ * @return Resolution context of YANG Source
+ */
+ public final YangSourceContextResolver.ResolutionState resolveSource(final String name,
+ final Optional<String> formattedRevision) {
return resolveSource(new SourceIdentifier(name, formattedRevision));
}
- public YangSourceContextResolver.ResolutionState resolveSource(final SourceIdentifier identifier) {
+ /**
+ * Resolves state of source and updates internal state accordingly.
+ *
+ * <p>
+ * Resolves state of source and updates internal state based on resolution.
+ * This method tries to get module dependency info via user implementation
+ * of {@link #getDependencyInfo(SourceIdentifier)} and then is recursively
+ * called for each announced dependency in
+ * {@link YangModelDependencyInfo#getDependencies()}.
+ *
+ * <p>
+ * Resolution state of resolveSource is internally cached and is used in
+ * subsequent resolution of dependent modules and in creation of
+ * YANGSourceContext via {@link #createSourceContext()}.
+ *
+ * <p>
+ * Possible resolution state for sources are:
+ * <ul>
+ * <li>{@link ResolutionState#EVERYTHING_OK} - If sources for module and its
+ * dependencies are available</li>
+ * <li>{@link ResolutionState#MISSING_DEPENDENCY} - If dependency of source
+ * is missing (call to {@link #getDependencyInfo(SourceIdentifier)} for
+ * imported / included model returned returned {@link Optional#absent()}.</li>
+ * <li>{@link ResolutionState#MISSING_SOURCE} - If source is missing. (call
+ * of {@link #getDependencyInfo(SourceIdentifier)} returned
+ * {@link Optional#absent()}.</li>
+ * <li>{@link ResolutionState#OTHER_ERROR} - If other runtime error
+ * prevented resolution of informations.</li>
+ * </ul>
+ *
+ * Note: Multiple invocations of this method returns cached result, since
+ * {@link #getDependencyInfo(SourceIdentifier)} contract requires
+ * implementors to return same information during life of this object.
+ *
+ *
+ * @param identifier
+ * Source Identifier
+ * @return Returns resolution state for source.
+ */
+ public final YangSourceContextResolver.ResolutionState resolveSource(final SourceIdentifier identifier) {
if (alreadyProcessed.containsKey(identifier)) {
return alreadyProcessed.get(identifier);
private boolean checkValidSource(final SourceIdentifier identifier, final YangModelDependencyInfo info) {
if (!identifier.getName().equals(info.getName())) {
- LOG.warn("Incorrect model returned. Identifier name was: {}, source contained: {}",
- identifier.getName(), info.getName());
+ LOG.warn("Incorrect model returned. Identifier name was: {}, source contained: {}", identifier.getName(),
+ info.getName());
throw new IllegalStateException("Incorrect source was returned");
}
return true;
}
- private void updateResolutionState(final SourceIdentifier identifier, final YangSourceContextResolver.ResolutionState potentialState) {
+ private void updateResolutionState(final SourceIdentifier identifier,
+ final YangSourceContextResolver.ResolutionState potentialState) {
alreadyProcessed.put(identifier, potentialState);
switch (potentialState) {
case MISSING_SOURCE:
private YangSourceContextResolver.ResolutionState resolveDependency(final ModuleImport dependency) {
String name = dependency.getModuleName();
- Optional<String> formattedRevision = Optional
- .fromNullable(QName.formattedRevision(dependency.getRevision()));
+ Optional<String> formattedRevision = Optional.fromNullable(QName.formattedRevision(dependency.getRevision()));
return resolveSource(new SourceIdentifier(name, formattedRevision));
}
import com.google.common.base.Optional;
+/**
+ *
+ * Source code resolver which resolves Yang Source Context against
+ * {@link SchemaSourceProvider} and set of QName which represent capabilities.
+ *
+ * This source code resolver is useful for components which deals with
+ * capability exchange similar to YANG/Netconf specification
+ * and there is {@link SchemaSourceProvider} able to retrieve YANG models.
+ *
+ */
public final class YangSourceFromCapabilitiesResolver extends YangSourceContextResolver {
private final Iterable<QName> capabilities;
+ /**
+ * Construct new {@link YangSourceFromCapabilitiesResolver}.
+ *
+ * @param capabilities Set of QName representing module capabilities, {@link QName#getLocalName()} represents
+ * source name and {@link QName#getRevision()} represents revision of source.
+ *
+ * @param schemaSourceProvider - {@link SchemaSourceProvider} which should be used to resolve sources.
+ */
public YangSourceFromCapabilitiesResolver(final Iterable<QName> capabilities,
final SchemaSourceProvider<InputStream> schemaSourceProvider) {
super(SchemaSourceProviders.toAdvancedSchemaSourceProvider(schemaSourceProvider));
@Override
public Optional<YangModelDependencyInfo> getDependencyInfo(final SourceIdentifier identifier) {
- Optional<InputStream> source = getSchemaSource(identifier);
+ Optional<InputStream> source = getSourceProvider().getSchemaSource(identifier);
if (source.isPresent()) {
return Optional.of(YangModelDependencyInfo.fromInputStream(source.get()));
}
return Optional.absent();
}
- private Optional<InputStream> getSchemaSource(final SourceIdentifier identifier) {
- return getSourceProvider().getSchemaSource(identifier.getName(),
- Optional.fromNullable(identifier.getRevision()));
- }
-
}
import java.util.Map;
import java.util.Map.Entry;
+import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
+/**
+ * Resolver for YANG Schema Source which is based on DependencyInfo
+ *
+ * This resolver does not use {@link SchemaSourceProvider} but supplied map
+ * of source identifiers and {@link YangModelDependencyInfo} to construct
+ * {@link YangSourceContext}.
+ *
+ */
public final class YangSourceFromDependencyInfoResolver extends YangSourceContextResolver {
private final Map<SourceIdentifier, YangModelDependencyInfo> dependencyInfo;
import java.util.Collections;
import java.util.List;
+import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
-final class BitImpl implements BitsTypeDefinition.Bit {
+final class BitImpl implements BitsTypeDefinition.Bit, Immutable {
private final Long position;
private final QName qname;
private final SchemaPath schemaPath;
result = prime * result + ((minElements == null) ? 0 : minElements.hashCode());
result = prime * result + ((must == null) ? 0 : must.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((parentBuilder == null) ? 0 : parentBuilder.hashCode());
+ result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
result = prime * result + ((presence == null) ? 0 : presence.hashCode());
result = prime * result + ((reference == null) ? 0 : reference.hashCode());
return result;
} else if (!name.equals(other.name)) {
return false;
}
- if (parentBuilder == null) {
- if (other.parentBuilder != null) {
+ if (getParent() == null) {
+ if (other.getParent() != null) {
return false;
}
- } else if (!parentBuilder.equals(other.parentBuilder)) {
+ } else if (!getParent().equals(other.getParent())) {
return false;
}
if (presence == null) {
super("Error in module '" + moduleName + "' at line " + line + ": " + errorMsg, exception);
}
+
}