Added support for leaf-list in state data definition.
Updated config subsystem as well as netconf mapping.
Change-Id: I4bdfbed352e29d6d3dc569f38c07022383d565c8
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
*/
package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
import org.opendaylight.controller.config.api.runtime.RuntimeBean;
import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.*;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute.Dependency;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.TypedAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.*;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation.Parameter;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDeclaration;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.FullyQualifiedNameHelper;
import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import javax.management.openmbean.SimpleType;
+import java.util.*;
+import java.util.Map.Entry;
public class TemplateFactory {
List<String> extendedInterfaces = Arrays.asList(RuntimeBean.class
.getCanonicalName());
List<MethodDeclaration> methods = new ArrayList<>();
+
// convert attributes to getters
for (AttributeIfc attributeIfc : entry.getAttributes()) {
String returnType = null;
- if (attributeIfc instanceof TypedAttribute) {
- returnType = ((TypedAttribute) attributeIfc).getType()
- .getFullyQualifiedName();
- } else if (attributeIfc instanceof TOAttribute) {
- String fullyQualifiedName = FullyQualifiedNameHelper
- .getFullyQualifiedName(entry.getPackageName(),
- attributeIfc.getUpperCaseCammelCase());
-
- returnType = fullyQualifiedName;
- } else if (attributeIfc instanceof ListAttribute) {
- AttributeIfc innerAttr = ((ListAttribute) attributeIfc)
- .getInnerAttribute();
-
- String innerTpe = innerAttr instanceof TypedAttribute ? ((TypedAttribute) innerAttr)
- .getType().getFullyQualifiedName()
- : FullyQualifiedNameHelper.getFullyQualifiedName(
- entry.getPackageName(),
- attributeIfc.getUpperCaseCammelCase());
-
- returnType = "java.util.List<" + innerTpe + ">";
- } else {
- throw new UnsupportedOperationException(
- "Attribute not supported: "
- + attributeIfc.getClass());
- }
+ returnType = getReturnType(entry, attributeIfc);
String getterName = "get"
+ attributeIfc.getUpperCaseCammelCase();
MethodDeclaration getter = new MethodDeclaration(returnType,
getterName, Collections.<Field> emptyList());
methods.add(getter);
}
+
// add rpc methods
for (Rpc rpc : entry.getRpcs()) {
// convert JavaAttribute parameters into fields
fields.add(field);
}
MethodDeclaration operation = new MethodDeclaration(
- rpc.getReturnType(), rpc.getName(), fields);
+ getReturnType(entry, rpc.getReturnType()), rpc.getName(), fields);
methods.add(operation);
}
return result;
}
+ private static String getReturnType(RuntimeBeanEntry entry, AttributeIfc attributeIfc) {
+ String returnType;
+ if (attributeIfc instanceof TypedAttribute) {
+ returnType = ((TypedAttribute) attributeIfc).getType()
+ .getFullyQualifiedName();
+ } else if (attributeIfc instanceof TOAttribute) {
+ String fullyQualifiedName = FullyQualifiedNameHelper
+ .getFullyQualifiedName(entry.getPackageName(),
+ attributeIfc.getUpperCaseCammelCase());
+
+ returnType = fullyQualifiedName;
+ } else if (attributeIfc instanceof ListAttribute) {
+ AttributeIfc innerAttr = ((ListAttribute) attributeIfc)
+ .getInnerAttribute();
+
+ String innerTpe = innerAttr instanceof TypedAttribute ? ((TypedAttribute) innerAttr)
+ .getType().getFullyQualifiedName()
+ : FullyQualifiedNameHelper.getFullyQualifiedName(
+ entry.getPackageName(),
+ attributeIfc.getUpperCaseCammelCase());
+
+ returnType = "java.util.List<" + innerTpe + ">";
+ } else if (attributeIfc == VoidAttribute.getInstance()) {
+ return "void";
+ } else {
+ throw new UnsupportedOperationException(
+ "Attribute not supported: "
+ + attributeIfc.getClass());
+ }
+ return returnType;
+ }
+
public static GeneralInterfaceTemplate serviceInterfaceFromSie(
ServiceInterfaceEntry sie) {
RuntimeBeanEntry rbe) {
Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
TOAttributesProcessor processor = new TOAttributesProcessor();
- processor.processAttributes(rbe.getYangPropertiesToTypesMap(),
- rbe.getPackageName());
+ Map<String, AttributeIfc> yangPropertiesToTypesMap = Maps.newHashMap(rbe.getYangPropertiesToTypesMap());
+
+ // Add TOs from output parameters
+ for (Rpc rpc : rbe.getRpcs()) {
+ AttributeIfc returnType = rpc.getReturnType();
+
+ if (returnType == VoidAttribute.getInstance())
+ continue;
+ if (returnType instanceof JavaAttribute)
+ continue;
+ if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType)
+ continue;
+
+ Preconditions.checkState(yangPropertiesToTypesMap.containsKey(returnType.getAttributeYangName()) == false,
+ "Duplicate TO %s for %s", returnType.getAttributeYangName(), rbe);
+ yangPropertiesToTypesMap.put(returnType.getAttributeYangName(), returnType);
+ }
+
+ processor.processAttributes(yangPropertiesToTypesMap, rbe.getPackageName());
for (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor
.getTOs()) {
List<Constructor> constructors = Lists.newArrayList();
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.*;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.FullyQualifiedNameHelper;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException;
import org.opendaylight.yangtools.yang.common.QName;
attributes.add(listAttribute);
}
+ } else if (child instanceof LeafListSchemaNode) {
+ ListAttribute listAttribute = ListAttribute.create(
+ (LeafListSchemaNode) child, typeProviderWrapper);
+ attributes.add(listAttribute);
} else {
- throw new IllegalStateException("Unknown running-data node "
- + child + " , " + "" + "expected leaf or container");
+ throw new IllegalStateException("Unexpected running-data node "
+ + child);
}
}
Set<Rpc> rpcs = new HashSet<>();
for (RpcDefinition rpcDefinition : rpcDefinitions) {
String name = ModuleMXBeanEntry
.findJavaParameter(rpcDefinition);
- String returnType;
+ AttributeIfc returnType;
if (rpcDefinition.getOutput() == null
|| rpcDefinition.getOutput().getChildNodes().size() == 0) {
- returnType = "void";
+ returnType = VoidAttribute.getInstance();
} else if (rpcDefinition.getOutput().getChildNodes().size() == 1) {
DataSchemaNode returnDSN = rpcDefinition.getOutput()
.getChildNodes().iterator().next();
- checkArgument(
- returnDSN instanceof LeafSchemaNode,
- "Unexpected type of rpc return type. "
- + "Currently only leafs and empty output nodes are supported, got "
- + returnDSN);
- LeafSchemaNode returnLeaf = (LeafSchemaNode) returnDSN;
- // We currently expect leaf defined in output element in yang to be named result
- // FIXME: value of result is fully qualified name - should be extended to accept TOs
- String localName = returnLeaf.getQName().getLocalName();
- checkArgument(
- localName.equals("result"),
- "Unexpected name of leaf in output element, expected leaf named result, was %s at %s",
- localName, currentModule.getName());
-
- returnType = typeProviderWrapper.getType(returnLeaf)
- .getFullyQualifiedName();
+ returnType = getReturnTypeAttribute(returnDSN, typeProviderWrapper);
+
} else {
throw new IllegalArgumentException(
"More than one child node in rpc output is not supported. "
attributes, rpcs);
}
+ private static AttributeIfc getReturnTypeAttribute(DataSchemaNode child, TypeProviderWrapper typeProviderWrapper) {
+ if (child instanceof LeafSchemaNode) {
+ LeafSchemaNode leaf = (LeafSchemaNode) child;
+ return new JavaAttribute(leaf, typeProviderWrapper);
+ } else if (child instanceof ContainerSchemaNode) {
+ ContainerSchemaNode container = (ContainerSchemaNode) child;
+ TOAttribute toAttribute = TOAttribute.create(container, typeProviderWrapper);
+ return toAttribute;
+ } else if (child instanceof ListSchemaNode) {
+ return ListAttribute.create((ListSchemaNode) child, typeProviderWrapper);
+ } else if (child instanceof LeafListSchemaNode) {
+ return ListAttribute.create((LeafListSchemaNode) child, typeProviderWrapper);
+ } else {
+ throw new IllegalStateException("Unknown output data node " + child + " for rpc");
+ }
+ }
+
private static Collection<DataSchemaNode> sortAttributes(Set<DataSchemaNode> childNodes) {
final TreeSet<DataSchemaNode> dataSchemaNodes = new TreeSet<>(new Comparator<DataSchemaNode>() {
@Override
public static class Rpc {
private final String name;
private final List<JavaAttribute> parameters;
- private final String returnType;
+ private final AttributeIfc returnType;
private final String yangName;
- Rpc(String returnType, String name, String yangName,
+ Rpc(AttributeIfc returnType, String name, String yangName,
List<JavaAttribute> parameters) {
this.returnType = returnType;
this.name = name;
return parameters;
}
- public String getReturnType() {
+ public AttributeIfc getReturnType() {
return returnType;
}
}
*/
package org.opendaylight.controller.config.yangjmxgenerator.attribute;
-import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
+
private final Type type;
private final String nullableDescription, nullableDefault;
--- /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.controller.config.yangjmxgenerator.attribute;
+
+import javax.management.openmbean.OpenType;
+
+public class VoidAttribute implements AttributeIfc {
+
+ private static VoidAttribute instance = new VoidAttribute();
+
+ public static VoidAttribute getInstance() {
+ return instance;
+ }
+
+ private VoidAttribute() {
+ }
+
+ @Override
+ public String getAttributeYangName() {
+ return null;
+ }
+
+ @Override
+ public String getNullableDescription() {
+ return null;
+ }
+
+ @Override
+ public String getNullableDefault() {
+ return null;
+ }
+
+ @Override
+ public String getUpperCaseCammelCase() {
+ return null;
+ }
+
+ @Override
+ public String getLowerCaseCammelCase() {
+ return null;
+ }
+
+ @Override
+ public OpenType<?> getOpenType() {
+ return null;
+ }
+}
*/
package org.opendaylight.controller.config.yangjmxgenerator;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.doReturn;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.openmbean.SimpleType;
-
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import javax.management.openmbean.SimpleType;
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.doReturn;
+
public class RuntimeBeanEntryTest extends AbstractYangTest {
public static final String PACKAGE_NAME = "packages.sis";
RuntimeBeanEntry.Rpc rpc = getRpcByName(rpcs, SLEEP_RPC_NAME);
assertNotNull(rpc);
assertThat(rpc.getYangName(), is(SLEEP_RPC_NAME));
- assertThat(rpc.getReturnType().endsWith(SLEEP_RPC_OUTPUT), is(true));
+
+ assertThat(((JavaAttribute)rpc.getReturnType()).getType().getFullyQualifiedName().endsWith(SLEEP_RPC_OUTPUT), is(true));
// get sleep rpc input attribute and test it
List<JavaAttribute> attributes = rpc.getParameters();
config:inner-state-bean;
rpcx:rpc-context-instance "inner-inner-test-rpc";
+ rpcx:rpc-context-instance "complex-output-rpc";
key "simple-int3";
leaf simple-int3 {
- type uint16;
+ type uint16;
+ }
+
+ leaf-list list-of-strings {
+ type string;
}
list not-state-bean {
identity inner-test-rpc;
identity inner-inner-test-rpc;
+ identity complex-output-rpc;
+
rpc no-arg {
input {
uses rpcx:rpc-context-ref {
}
}
+ rpc container-output {
+ input {
+ uses rpcx:rpc-context-ref {
+ refine context-instance {
+ rpcx:rpc-context-instance complex-output-rpc;
+ }
+ }
+ }
+
+ output {
+ container retValContainer {
+ leaf v1 {
+ type string;
+ }
+
+ leaf v2 {
+ type uint32;
+ }
+ }
+ }
+ }
+
+ rpc leaf-list-output {
+ input {
+ uses rpcx:rpc-context-ref {
+ refine context-instance {
+ rpcx:rpc-context-instance complex-output-rpc;
+ }
+ }
+ }
+
+ output {
+ leaf-list result {
+ type string;
+ }
+ }
+ }
+
+ rpc list-output {
+ input {
+ uses rpcx:rpc-context-ref {
+ refine context-instance {
+ rpcx:rpc-context-instance complex-output-rpc;
+ }
+ }
+ }
+
+ output {
+ list ret-val-list {
+ leaf v2 {
+ type uint32;
+ }
+
+ leaf v1 {
+ type boolean;
+ }
+ }
+ }
+ }
+
rpc noArgInner {
input {
uses rpcx:rpc-context-ref {
package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping;
-import java.util.Map;
-import java.util.Map.Entry;
+import com.google.common.collect.Maps;
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.*;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.AttributeIfcSwitchStatement;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.Services;
import javax.management.openmbean.ArrayType;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
-
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.*;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.AttributeIfcSwitchStatement;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.Services;
-
-import com.google.common.collect.Maps;
+import java.util.Map;
+import java.util.Map.Entry;
public class ObjectMapper extends AttributeIfcSwitchStatement<AttributeMappingStrategy<?, ? extends OpenType<?>>> {
return strategies;
}
- private AttributeMappingStrategy<?, ? extends OpenType<?>> prepareStrategy(AttributeIfc attributeIfc) {
+ public AttributeMappingStrategy<?, ? extends OpenType<?>> prepareStrategy(AttributeIfc attributeIfc) {
return switchAttribute(attributeIfc);
}
return preparedWriting;
}
- private AttributeWritingStrategy prepareWritingStrategy(String key, AttributeIfc expectedAttr, Document document) {
+ public AttributeWritingStrategy prepareWritingStrategy(String key, AttributeIfc expectedAttr, Document document) {
Preconditions.checkNotNull(expectedAttr, "Mbean attributes mismatch, unable to find expected attribute for %s",
key);
this.document = document;
return rpc.getName();
}
- public String getReturnType() {
+ public AttributeIfc getReturnType() {
return rpc.getReturnType();
}
import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.SimpleTypeResolver;
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.VoidAttribute;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.SimpleAttributeMappingStrategy;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.AttributeMappingStrategy;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectMapper;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.toxml.ObjectXmlWriter;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.InstanceRuntimeRpc;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.ModuleRpcs;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc.Rpcs;
import org.opendaylight.controller.netconf.confignetconfconnector.operations.Commit;
import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.management.ObjectName;
-import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.OpenType;
import java.util.Map;
public class RuntimeRpc extends AbstractConfigNetconfOperation {
this.yangStoreSnapshot = yangStoreSnapshot;
}
- private String getStringRepresentation(final Object result) {
- final SimpleType<?> simpleType = SimpleTypeResolver.getSimpleType(result.getClass().getName());
- final Optional<String> mappedAttributeOpt = new SimpleAttributeMappingStrategy(simpleType).mapAttribute(result);
- return mappedAttributeOpt.isPresent() ? mappedAttributeOpt.get() : "";
+ private Element toXml(Document doc, Object result, AttributeIfc returnType, String namespace, String elementName) {
+ AttributeMappingStrategy<?, ? extends OpenType<?>> mappingStrategy = new ObjectMapper(null).prepareStrategy(returnType);
+ Optional<?> mappedAttributeOpt = mappingStrategy.mapAttribute(result);
+ Preconditions.checkState(mappedAttributeOpt.isPresent(), "Unable to map return value %s as %s", result, returnType.getOpenType());
+
+ // FIXME: multiple return values defined as leaf-list and list in yang should not be wrapped in output xml element,
+ // they need to be appended directly under rpc-reply element
+ //
+ // Either allow List of Elements to be returned from NetconfOperation or
+ // pass reference to parent output xml element for netconf operations to
+ // append result(s) on their own
+ Element tempParent = doc.createElementNS(XmlNetconfConstants.RFC4741_TARGET_NAMESPACE, "output");
+ new ObjectXmlWriter().prepareWritingStrategy(elementName, returnType, doc).writeElement(tempParent, namespace, mappedAttributeOpt.get());
+
+ XmlElement xmlElement = XmlElement.fromDomElement(tempParent);
+ return xmlElement.getChildElements().size() > 1 ? tempParent : xmlElement.getOnlyChildElement().getDomElement();
}
private Object executeOperation(final ConfigRegistryClient configRegistryClient, final ObjectName on,
logger.info("Operation {} called successfully on {} with arguments {} with result {}", execution.operationName,
execution.on, execution.attributes, result);
- if (execution.returnType.equals("void")) {
+ if (execution.isVoid()) {
return document.createElement("ok");
} else {
- final Element output = XmlUtil.createTextElement(document, "result", getStringRepresentation(result));
- XmlUtil.addNamespaceAttr(output, execution.namespace);
- return output;
+ return toXml(document, result, execution.returnType, execution.namespace,
+ execution.returnType.getAttributeYangName());
}
}
private final ObjectName on;
private final String operationName;
private final Map<String, AttributeConfigElement> attributes;
- private final String returnType;
+ private final AttributeIfc returnType;
private final String namespace;
public NetconfOperationExecution(final ObjectName on, final String name,
- final Map<String, AttributeConfigElement> attributes, final String returnType, final String namespace) {
+ final Map<String, AttributeConfigElement> attributes, final AttributeIfc returnType, final String namespace) {
this.on = on;
this.operationName = name;
this.attributes = attributes;
this.namespace = namespace;
}
+ boolean isVoid() {
+ return returnType == VoidAttribute.getInstance();
+ }
+
}
private static Map<String, AttributeConfigElement> sortAttributes(
Element response = get();
+ System.err.println(XmlUtil.toString(response));
+
assertEquals(2, getElementsSize(response, "instance"));
assertEquals(2, getElementsSize(response, "asdf"));
assertEquals(5, getElementsSize(response, "inner-running-data"));
assertEquals(5, getElementsSize(response, "deep2"));
assertEquals(11, getElementsSize(response, "inner-inner-running-data"));
assertEquals(11, getElementsSize(response, "deep3"));
+ assertEquals(11 * 2, getElementsSize(response, "list-of-strings"));
assertEquals(4, getElementsSize(response, "inner-running-data-additional"));
assertEquals(4, getElementsSize(response, "deep4"));
// TODO assert keys
response = executeOp(netconf, "netconfMessages/rpcInnerInner.xml");
assertThat(XmlUtil.toString(response), JUnitMatchers.containsString("true"));
+
+ response = executeOp(netconf, "netconfMessages/rpcInnerInner_complex_output.xml");
+ assertThat(XmlUtil.toString(response), JUnitMatchers.containsString("1"));
+ assertThat(XmlUtil.toString(response), JUnitMatchers.containsString("2"));
}
private Element get() throws NetconfDocumentedException, ParserConfigurationException, SAXException, IOException {
return new Deep3();
}
+ @Override
+ public List<String> getListOfStrings() {
+ return Lists.newArrayList("l1", "l2");
+ }
+
+ @Override
+ public List<RetValList> listOutput() {
+ return Lists.newArrayList(new RetValList());
+ }
+
@Override
public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
return aBoolean;
}
+ @Override
+ public RetValContainer containerOutput() {
+ return new RetValContainer();
+ }
+
+ @Override
+ public List<String> leafListOutput() {
+ return Lists.newArrayList("1", "2");
+ }
+
}
reg.register(new InnerInnerRunningDataRuntimeMXBeanTest(counter++));
--- /dev/null
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <leaf-list-output
+ xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+ <context-instance>
+ /data/modules/module[name='impl-netconf']/instance[name='instance2']/inner-running-data[key='1015']/inner-inner-running-data[key='1017']
+ </context-instance>
+ </leaf-list-output>
+</rpc>