*.swp
**/*.swp
**/*.checkstyle
+**/*.swo
--- /dev/null
+package org.opendaylight.alto.commons.helper;
+
+public abstract class Converter<I, O> {
+ private I _in = null;
+ private O _out = null;
+
+ public Converter() {
+ }
+
+ public Converter(I in) {
+ this._in = in;
+ this._out = convert();
+ }
+
+ public O convert() {
+ return (O)_convert();
+ }
+
+ protected abstract Object _convert();
+
+ public O convert(I in) {
+ return reset(in).out();
+ }
+
+ public Converter<I, O> reset(I in) {
+ this._in = in;
+ this._out = convert();
+ return this;
+ }
+
+ public I in() {
+ return _in;
+ }
+
+ public O out() {
+ return _out;
+ }
+}
--- /dev/null
+package org.opendaylight.alto.commons.helper;
+
+public class TypeWrapper<T extends TypeWrapper, E> {
+
+ private E data = null;
+
+ public static <T extends TypeWrapper, E> T wrap(T wrapper, E data) {
+ wrapper.set(data);
+ return wrapper;
+ }
+
+ public TypeWrapper() {
+ data = null;
+ }
+
+ public TypeWrapper(E data) {
+ this.data = data;
+ }
+
+ public TypeWrapper(TypeWrapper<T, E> wrapper) {
+ this.set(wrapper.get());
+ }
+
+ public E get() {
+ return this.data;
+ }
+
+ public void set(E newData) {
+ this.data = newData;
+ }
+}
--- /dev/null
+package org.opendaylight.alto.commons.types.converter;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import org.opendaylight.alto.commons.helper.Converter;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
+import org.opendaylight.alto.commons.types.model150404.ModelEndpointAddressGroup;
+
+public class RFC2ModelEndpointAddressGroupConverter
+ extends Converter<RFC7285Endpoint.AddressGroup, List<ModelEndpointAddressGroup>> {
+
+ public RFC2ModelEndpointAddressGroupConverter() {
+ }
+
+ public RFC2ModelEndpointAddressGroupConverter(RFC7285Endpoint.AddressGroup _in) {
+ super(_in);
+ }
+
+ @Override
+ protected Object _convert() {
+ List<ModelEndpointAddressGroup> out = new LinkedList<ModelEndpointAddressGroup>();
+ if ((in().ipv4 != null) && (!in().ipv4.isEmpty())) {
+ ModelEndpointAddressGroup v4 = new ModelEndpointAddressGroup();
+ v4.setJSONAddressType(ModelEndpointAddressGroup.IPV4);
+ v4.setJSONEndpointPrefix(in().ipv4);
+ out.add(v4);
+ }
+ if ((in().ipv6 != null) && (!in().ipv6.isEmpty())) {
+ ModelEndpointAddressGroup v6 = new ModelEndpointAddressGroup();
+ v6.setJSONAddressType(ModelEndpointAddressGroup.IPV6);
+ v6.setJSONEndpointPrefix(in().ipv6);
+ out.add(v6);
+ }
+ return out;
+ }
+}
--- /dev/null
+package org.opendaylight.alto.commons.types.converter;
+
+import org.opendaylight.alto.commons.helper.Converter;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
+
+public class RFC2ModelNetworkMapConverter
+ extends Converter<RFC7285NetworkMap, ModelNetworkMap> {
+
+ protected RFC2ModelNetworkMapDataConverter conv = new RFC2ModelNetworkMapDataConverter();
+
+ public RFC2ModelNetworkMapConverter() {
+ }
+
+ public RFC2ModelNetworkMapConverter(RFC7285NetworkMap _in) {
+ super(_in);
+ }
+
+ @Override
+ public Object _convert() {
+ ModelNetworkMap out = new ModelNetworkMap();
+ out.setJSONResourceId(in().meta.vtag.rid);
+ out.setJSONTag(in().meta.vtag.tag);
+ out.setJSONMap(conv.reset(in().map).out());
+
+ return out;
+ }
+}
--- /dev/null
+package org.opendaylight.alto.commons.types.converter;
+
+import java.util.Map;
+import java.util.List;
+import java.util.LinkedList;
+
+import org.opendaylight.alto.commons.helper.Converter;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
+import org.opendaylight.alto.commons.types.model150404.ModelEndpoint;
+
+public class RFC2ModelNetworkMapDataConverter
+ extends Converter<Map<String, RFC7285Endpoint.AddressGroup>, List<ModelEndpoint>> {
+
+ protected RFC2ModelEndpointAddressGroupConverter conv = new RFC2ModelEndpointAddressGroupConverter();
+
+ public RFC2ModelNetworkMapDataConverter() {
+ }
+
+ public RFC2ModelNetworkMapDataConverter(Map<String, RFC7285Endpoint.AddressGroup> _in) {
+ super(_in);
+ }
+
+ @Override
+ public Object _convert() {
+ List<ModelEndpoint> out = new LinkedList<ModelEndpoint>();
+
+ for (Map.Entry<String, RFC7285Endpoint.AddressGroup> rep: in().entrySet()) {
+ ModelEndpoint mep = new ModelEndpoint();
+ mep.setJSONPid(rep.getKey());
+ mep.setJSONEndpointAddressGroup(conv.reset(rep.getValue()).out());
+ out.add(mep);
+ }
+ return out;
+ }
+}
+++ /dev/null
-package org.opendaylight.alto.commons.types.convertor;
-
-public class Model2RFCConvertor {
-}
+++ /dev/null
-package org.opendaylight.alto.commons.types.convertor;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Arrays;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupBuilder;
-
-import org.opendaylight.alto.commons.types.rfc7285.RFC7285Type;
-import org.opendaylight.alto.commons.types.model150404.ModelType;
-
-public class RFC2ModelConvertor {
-
- public static final String IPV4 = "ipv4";
- public static final String IPV6 = "ipv6";
-
- public ModelType.NetworkMap convert(RFC7285Type.NetworkMap nmap) {
- ResourceId rid = new ResourceId(nmap.meta.vtag.rid);
- TagString tag = new TagString(nmap.meta.vtag.tag);
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map> mapData
- = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map>(convert(nmap.map));
- ModelType.NetworkMap result = (ModelType.NetworkMap)(new NetworkMapBuilder()
- .setResourceId(rid)
- .setTag(tag)
- .setMap(mapData).build());
- return result;
- }
-
- public List<ModelType.NetworkMapData> convert(Map<String, RFC7285Type.Endpoint.AddressGroup> mapData) {
- List<ModelType.NetworkMapData> result = new ArrayList<ModelType.NetworkMapData>();
- for (Map.Entry<String, RFC7285Type.Endpoint.AddressGroup> entry: mapData.entrySet()) {
- String pid = entry.getKey();
- RFC7285Type.Endpoint.AddressGroup addresses = entry.getValue();
-
- result.add(convert(pid, addresses));
- }
- return result;
- }
-
- public ModelType.NetworkMapData convert(String pid, RFC7285Type.Endpoint.AddressGroup data) {
- PidName _pid = new PidName(pid);
- return (ModelType.NetworkMapData)new MapBuilder()
- .setPid(_pid)
- .setKey(new MapKey(_pid))
- .setEndpointAddressGroup(convert(data))
- .build();
- }
-
- public List<EndpointAddressGroup> convert(RFC7285Type.Endpoint.AddressGroup addressGroup) {
- EndpointAddressGroup result[] = {
- buildAddressGroup(EndpointAddressType.Enumeration.Ipv4, str2IpPrefix(addressGroup.ipv4)),
- buildAddressGroup(EndpointAddressType.Enumeration.Ipv6, str2IpPrefix(addressGroup.ipv6)),
- };
-
- return Arrays.asList(result);
- }
-
- private EndpointAddressGroup buildAddressGroup(EndpointAddressType.Enumeration type, List<IpPrefix> prefixes) {
- EndpointAddressType _type = new EndpointAddressType(type);
- return new EndpointAddressGroupBuilder()
- .setAddressType(_type)
- .setEndpointPrefix(prefixes).build();
- }
-
- private List<IpPrefix> str2IpPrefix(List<String> ipList) {
- List<IpPrefix> prefixList = new ArrayList<IpPrefix>();
- for (String ip : ipList) {
- prefixList.add(IpPrefixBuilder.getDefaultInstance(ip));
- }
- return prefixList;
- }
-
-}
+++ /dev/null
-package org.opendaylight.alto.commons.types.model150404;
-public class JSONMapper {
-}
--- /dev/null
+package org.opendaylight.alto.commons.types.model150404;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class ModelEndpoint implements Map {
+
+ @JsonIgnore
+ protected PidName pid = null;
+
+ @JsonIgnore
+ protected List<EndpointAddressGroup> data = new LinkedList<EndpointAddressGroup>();
+
+ public ModelEndpoint() {
+ }
+
+ public ModelEndpoint(Map model) {
+ this.pid = model.getPid();
+ this.setEndpointAddressGroup(model.getEndpointAddressGroup());
+ }
+
+ @JsonIgnore
+ @Override
+ public Class<Map> getImplementedInterface() {
+ return Map.class;
+ }
+
+ @JsonIgnore
+ @Override
+ public <E extends Augmentation<Map>> E getAugmentation(Class<E> augmentationType) {
+ return null;
+ }
+
+ @JsonIgnore
+ @Override
+ public MapKey getKey() {
+ return new MapKey(pid);
+ }
+
+ @JsonIgnore
+ @Override
+ public PidName getPid() {
+ return pid;
+ }
+
+ @JsonProperty("alto-service:pid")
+ public String getJSONPid() {
+ return pid.getValue();
+ }
+
+ @JsonProperty("alto-service:pid")
+ public void setJSONPid(String pid) {
+ this.pid = new PidName(pid);
+ }
+
+ @JsonIgnore
+ @Override
+ public List<EndpointAddressGroup> getEndpointAddressGroup() {
+ return data;
+ }
+
+ @JsonIgnore
+ public void setEndpointAddressGroup(List<EndpointAddressGroup> rhs) {
+ data = new LinkedList<EndpointAddressGroup>(rhs);
+ }
+
+ @JsonProperty("alto-service:endpoint-address-group")
+ public List<EndpointAddressGroup> getJSONEndpointAddressGroup() {
+ return data;
+ }
+
+ @JsonProperty("alto-service:endpoint-address-group")
+ public void setJSONEndpointAddressGroup(List<ModelEndpointAddressGroup> rhs) {
+ data = new LinkedList<EndpointAddressGroup>(rhs);
+ }
+}
--- /dev/null
+package org.opendaylight.alto.commons.types.model150404;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class ModelEndpointAddressGroup implements EndpointAddressGroup {
+
+ public static final String IPV4 = "ipv4";
+ public static final String IPV6 = "ipv6";
+
+
+ @JsonIgnore
+ protected EndpointAddressType type;
+
+ @JsonIgnore
+ protected List<IpPrefix> data = new LinkedList<IpPrefix>();
+
+ @JsonIgnore
+ protected List<String> prefixes = new LinkedList<String>();
+
+ public ModelEndpointAddressGroup() {
+ }
+
+ public ModelEndpointAddressGroup(EndpointAddressGroup model) {
+ }
+
+ @JsonIgnore
+ @Override
+ public Class<EndpointAddressGroup> getImplementedInterface() {
+ return EndpointAddressGroup.class;
+ }
+
+ @JsonIgnore
+ @Override
+ public EndpointAddressType getAddressType() {
+ return type;
+ }
+
+ @JsonProperty("alto-service:address-type")
+ public String getJSONAddressType() {
+ if (type == null)
+ return null;
+ if (EndpointAddressType.Enumeration.Ipv4.equals(type.getEnumeration()))
+ return IPV4;
+ if (EndpointAddressType.Enumeration.Ipv6.equals(type.getEnumeration()))
+ return IPV6;
+ return "unsupported";
+ }
+
+ @JsonProperty
+ public void setJSONAddressType(String type) {
+ if (IPV4.equals(type))
+ this.type = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4);
+ if (IPV6.equals(type))
+ this.type = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv6);
+ this.type = null;
+ }
+
+ @JsonIgnore
+ @Override
+ public List<IpPrefix> getEndpointPrefix() {
+ return data;
+ }
+
+ @JsonIgnore
+ public void setEndpointPrefix(List<IpPrefix> rhs) {
+ data = new LinkedList<IpPrefix>(rhs);
+ prefixes = new LinkedList<String>();
+ for (IpPrefix p: rhs) {
+ prefixes.add(p.getValue().toString());
+ }
+ }
+
+ @JsonProperty("alto-service:endpoint-prefix")
+ public List<String> getJSONEndpointAddressGroup() {
+ return prefixes;
+ }
+
+ @JsonProperty("alto-service:endpoint-prefix")
+ public void setJSONEndpointPrefix(List<String> rhs) {
+ prefixes = rhs;
+ data = new LinkedList<IpPrefix>();
+ for (String p: rhs) {
+ data.add(IpPrefixBuilder.getDefaultInstance(p));
+ }
+ }
+
+ @JsonIgnore
+ @Override
+ public EndpointAddressGroupKey getKey() {
+ return new EndpointAddressGroupKey(type);
+ }
+
+ @JsonIgnore
+ @Override
+ public <E extends Augmentation<EndpointAddressGroup>> E getAugmentation(Class<E> augmentationType) {
+ return null;
+ }
+}
--- /dev/null
+package org.opendaylight.alto.commons.types.model150404;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ModelJSONMapper {
+
+ private ObjectMapper mapper = new ObjectMapper()
+ .setSerializationInclusion(Include.NON_DEFAULT)
+ .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
+
+ public ModelNetworkMap asNetworkMap(String json) throws Exception {
+ return mapper.readValue(json, ModelNetworkMap.class);
+ }
+
+ public String asJSON(Object obj) throws Exception {
+ return mapper.writeValueAsString(obj);
+ }
+}
--- /dev/null
+package org.opendaylight.alto.commons.types.model150404;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.NetworkMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class ModelNetworkMap implements NetworkMap {
+
+ @JsonIgnore
+ protected ResourceId rid = null;
+
+ @JsonIgnore
+ protected TagString tag = null;
+
+ @JsonIgnore
+ protected List<Map> data = new LinkedList<Map>();
+
+ public ModelNetworkMap() {
+ }
+
+ public ModelNetworkMap(NetworkMap map) {
+ this.rid = map.getResourceId();
+ this.tag = map.getTag();
+ this.setMap(map.getMap());
+ }
+
+ @JsonIgnore
+ @Override
+ public Class<NetworkMap> getImplementedInterface() {
+ return NetworkMap.class;
+ }
+
+ @JsonIgnore
+ @Override
+ public ResourceId getResourceId() {
+ return rid;
+ }
+
+ @JsonProperty("alto-service:resource-id")
+ public String getJSONResourceId() {
+ return rid.getValue();
+ }
+
+ @JsonProperty("alto-service:resource-id")
+ public void setJSONResourceId(String rid) {
+ this.rid = new ResourceId(rid);
+ }
+
+ @JsonIgnore
+ @Override
+ public TagString getTag() {
+ return tag;
+ }
+
+ @JsonProperty("alto-service:tag")
+ public String getJSONTag() {
+ return tag.getValue();
+ }
+
+ @JsonProperty("alto-service:tag")
+ public void setJSONTag(String tag) {
+ this.tag = new TagString(tag);
+ }
+
+ @JsonIgnore
+ @Override
+ public List<Map> getMap() {
+ return data;
+ }
+
+ @JsonIgnore
+ public void setMap(List<Map> data) {
+ this.data = new LinkedList<Map>(data);
+ }
+
+ @JsonProperty("alto-service:map")
+ public List<Map> getJSONMap() {
+ return data;
+ }
+
+ @JsonProperty("alto-service:map")
+ public void setJSONMap(List<ModelEndpoint> data) {
+ this.data = new LinkedList<Map>(data);
+ }
+}
+++ /dev/null
-package org.opendaylight.alto.commons.types.model150404;
-
-public class ModelType {
-
- public static interface NetworkMap
- extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap {}
-
- public static interface NetworkMapData
- extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map {
- }
-
- public static class JSONMapper
- extends org.opendaylight.alto.commons.types.model150404.JSONMapper {}
-}
+++ /dev/null
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class JSONMapper {
-
- private ObjectMapper mapper = new ObjectMapper()
- .setSerializationInclusion(Include.NON_DEFAULT)
- .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
-
- public Endpoint.AddressGroup asAddressGroup(String json) throws Exception {
- return mapper.readValue(json, Endpoint.AddressGroup.class);
- }
-
- public Endpoint.PropertyRequest asPropertyRequest(String json) throws Exception {
- return mapper.readValue(json, Endpoint.PropertyRequest.class);
- }
-
- public Endpoint.PropertyResponse asPropertyResponse(String json) throws Exception {
- return mapper.readValue(json, Endpoint.PropertyResponse.class);
- }
-
- public Endpoint.CostRequest asCostRequest(String json) throws Exception {
- return mapper.readValue(json, Endpoint.CostRequest.class);
- }
-
- public Endpoint.CostResponse asCostResponse(String json) throws Exception {
- return mapper.readValue(json, Endpoint.CostResponse.class);
- }
-
- public CostMap asCostMap(String json) throws Exception {
- return mapper.readValue(json, CostMap.class);
- }
-
- public CostType asCostType(String json) throws Exception {
- return mapper.readValue(json, CostType.class);
- }
-
- public Endpoint asEndpoint(String json) throws Exception {
- return mapper.readValue(json, Endpoint.class);
- }
-
- public Extensible asExtensible(String json) throws Exception {
- return mapper.readValue(json, Extensible.class);
- }
-
- public IRD asIRD(String json) throws Exception {
- return mapper.readValue(json, IRD.class);
- }
-
- public NetworkMap asNetworkMap(String json) throws Exception {
- return mapper.readValue(json, NetworkMap.class);
- }
-
- public NetworkMap.Filter asNetworkMapFilter(String json) throws Exception {
- return mapper.readValue(json, NetworkMap.Filter.class);
- }
-
- public CostMap.Filter asCostMapFilter(String json) throws Exception {
- return mapper.readValue(json, CostMap.Filter.class);
- }
-
- public VersionTag asVersionTag(String json) throws Exception {
- return mapper.readValue(json, VersionTag.class);
- }
-
- public String asJSON(Object obj) throws Exception {
- return mapper.writeValueAsString(obj);
- }
-}
+++ /dev/null
-package org.opendaylight.alto.commons.types.rfc7285;
-
-public class Mark {
- public static int marker = 2;
-}
/**
* Cost Map: defined in RFC7285 secion 11.2.3
* */
-public class CostMap {
+public class RFC7285CostMap {
public static class Meta extends Extensible {
@JsonProperty("dependent-vtags")
- public List<VersionTag> netmap_tags;
+ public List<RFC7285VersionTag> netmap_tags;
@JsonProperty("cost-type")
- public CostType costType;
+ public RFC7285CostType costType;
}
/**
public static class Filter {
@JsonProperty("cost-type")
- public CostType costType;
+ public RFC7285CostType costType;
@JsonProperty("pids")
- public QueryPairs pids;
+ public RFC7285QueryPairs pids;
}
@JsonProperty("meta")
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Arrays;
-public class CostType {
+public class RFC7285CostType {
@JsonProperty("cost-mode")
- public String mode;
+ public String mode = "";
@JsonProperty("cost-metric")
- public String metric;
+ public String metric = "";
@JsonProperty("description")
- public String description;
+ public String description = "";
- public CostType() {
+ public RFC7285CostType() {
}
- public CostType(String mode, String metric) {
+ public RFC7285CostType(String mode, String metric) {
this.mode = mode;
this.metric = metric;
}
- public CostType(String mode, String metric, String description) {
+ public RFC7285CostType(String mode, String metric, String description) {
this.mode = mode;
this.metric = metric;
this.description = description;
public boolean equals(Object obj) {
if (this == obj)
return true;
- if (!(obj != null ? (obj instanceof CostType) : false))
+ if (!(obj != null ? (obj instanceof RFC7285CostType) : false))
return false;
- CostType other = (CostType)obj;
+ RFC7285CostType other = (RFC7285CostType)obj;
String[] lhs = { metric, mode };
String[] rhs = { other.metric, other.mode };
return Arrays.equals(lhs, rhs);
import java.util.Map;
import java.util.LinkedHashMap;
-public class Endpoint {
+
+public class RFC7285Endpoint {
public static class AddressGroup extends Extensible {
public static class PropertyRequest {
@JsonProperty("properties")
- public List<String> properties;
+ public List<String> properties = new ArrayList<String>();
@JsonProperty("endpoints")
- public List<String> endpoints;
+ public List<String> endpoints = new ArrayList<String>();
}
public static class PropertyResponse {
public static class Meta extends Extensible {
@JsonProperty("dependent-vtags")
- public List<VersionTag> netmap_tags;
+ public List<RFC7285VersionTag> netmap_tags = new ArrayList<RFC7285VersionTag>();
}
@JsonProperty("meta")
- public Meta meta;
+ public Meta meta = new Meta();
@JsonProperty("endpoint-properties")
public Map<String, Map<String, Object>> answer
public static class CostRequest {
@JsonProperty("cost-type")
- public CostType costType;
+ public RFC7285CostType costType = new RFC7285CostType();
@JsonProperty("endpoints")
- public QueryPairs endpoints;
+ public RFC7285QueryPairs endpoints = new RFC7285QueryPairs();
}
public static class CostResponse {
public static class Meta extends Extensible {
@JsonProperty("cost-type")
- public CostType costType;
+ public RFC7285CostType costType = new RFC7285CostType();
}
@JsonProperty("meta")
- public Meta meta;
+ public Meta meta = new Meta();
@JsonProperty("endpoint-cost-map")
public Map<String, Map<String, Object>> answer
import com.fasterxml.jackson.annotation.JsonProperty;
-public class IRD {
+public class RFC7285IRD {
public class Meta extends Extensible {
public String defaultAltoNetworkMap;
@JsonProperty("cost-types")
- public Map<String, CostType> costTypes;
+ public Map<String, RFC7285CostType> costTypes;
public Meta() {
defaultAltoNetworkMap = null;
- costTypes = new LinkedHashMap<String, CostType>();
+ costTypes = new LinkedHashMap<String, RFC7285CostType>();
}
}
--- /dev/null
+package org.opendaylight.alto.commons.types.rfc7285;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RFC7285JSONMapper {
+
+ private ObjectMapper mapper = new ObjectMapper()
+ .setSerializationInclusion(Include.NON_DEFAULT)
+ .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
+
+ public RFC7285Endpoint.AddressGroup asAddressGroup(String json) throws Exception {
+ return mapper.readValue(json, RFC7285Endpoint.AddressGroup.class);
+ }
+
+ public RFC7285Endpoint.PropertyRequest asPropertyRequest(String json) throws Exception {
+ return mapper.readValue(json, RFC7285Endpoint.PropertyRequest.class);
+ }
+
+ public RFC7285Endpoint.PropertyResponse asPropertyResponse(String json) throws Exception {
+ return mapper.readValue(json, RFC7285Endpoint.PropertyResponse.class);
+ }
+
+ public RFC7285Endpoint.CostRequest asCostRequest(String json) throws Exception {
+ return mapper.readValue(json, RFC7285Endpoint.CostRequest.class);
+ }
+
+ public RFC7285Endpoint.CostResponse asCostResponse(String json) throws Exception {
+ return mapper.readValue(json, RFC7285Endpoint.CostResponse.class);
+ }
+
+ public RFC7285CostMap asCostMap(String json) throws Exception {
+ return mapper.readValue(json, RFC7285CostMap.class);
+ }
+
+ public RFC7285CostType asCostType(String json) throws Exception {
+ return mapper.readValue(json, RFC7285CostType.class);
+ }
+
+ public RFC7285Endpoint asEndpoint(String json) throws Exception {
+ return mapper.readValue(json, RFC7285Endpoint.class);
+ }
+
+ public Extensible asExtensible(String json) throws Exception {
+ return mapper.readValue(json, Extensible.class);
+ }
+
+ public RFC7285IRD asIRD(String json) throws Exception {
+ return mapper.readValue(json, RFC7285IRD.class);
+ }
+
+ public RFC7285NetworkMap asNetworkMap(String json) throws Exception {
+ return mapper.readValue(json, RFC7285NetworkMap.class);
+ }
+
+ public RFC7285NetworkMap.Filter asNetworkMapFilter(String json) throws Exception {
+ return mapper.readValue(json, RFC7285NetworkMap.Filter.class);
+ }
+
+ public RFC7285CostMap.Filter asCostMapFilter(String json) throws Exception {
+ return mapper.readValue(json, RFC7285CostMap.Filter.class);
+ }
+
+ public RFC7285VersionTag asVersionTag(String json) throws Exception {
+ return mapper.readValue(json, RFC7285VersionTag.class);
+ }
+
+ public String asJSON(Object obj) throws Exception {
+ return mapper.writeValueAsString(obj);
+ }
+}
package org.opendaylight.alto.commons.types.rfc7285;
import java.util.LinkedHashMap;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Network Map: defined in RFC 7285 section 11.2.1
* */
-public class NetworkMap {
+public class RFC7285NetworkMap {
public static class Meta extends Extensible {
@JsonProperty("vtag")
- public VersionTag vtag;
+ public RFC7285VersionTag vtag = new RFC7285VersionTag();
}
public static class Filter {
@JsonProperty("pids")
- public List<String> pids;
+ public List<String> pids = new ArrayList<String>();
}
@JsonProperty("meta")
- public Meta meta;
+ public Meta meta = new Meta();
@JsonProperty("network-map")
- public Map<String, Endpoint.AddressGroup> map
- = new LinkedHashMap<String, Endpoint.AddressGroup>();
+ public Map<String, RFC7285Endpoint.AddressGroup> map
+ = new LinkedHashMap<String, RFC7285Endpoint.AddressGroup>();
}
import com.fasterxml.jackson.annotation.JsonProperty;
-public class QueryPairs {
+public class RFC7285QueryPairs {
@JsonProperty("srcs")
List<String> src = new LinkedList<String>();
+++ /dev/null
-package org.opendaylight.alto.commons.types.rfc7285;
-
-public class RFC7285Type {
-
- public static class NetworkMap
- extends org.opendaylight.alto.commons.types.rfc7285.NetworkMap {}
-
- public static class CostMap
- extends org.opendaylight.alto.commons.types.rfc7285.CostMap {}
-
- public static class CostType
- extends org.opendaylight.alto.commons.types.rfc7285.CostType {}
-
- public static class Endpoint
- extends org.opendaylight.alto.commons.types.rfc7285.Endpoint {}
-
- public static class IRD
- extends org.opendaylight.alto.commons.types.rfc7285.IRD {}
-
- public static class MediaType
- extends org.opendaylight.alto.commons.types.rfc7285.MediaType {}
-
- public static class JSONMapper
- extends org.opendaylight.alto.commons.types.rfc7285.JSONMapper {}
-
- public static class VersionTag
- extends org.opendaylight.alto.commons.types.rfc7285.VersionTag {}
-}
import com.fasterxml.jackson.annotation.JsonProperty;
-public class VersionTag {
+public class RFC7285VersionTag {
@JsonProperty("resource-id")
public String rid;
@JsonProperty("tag")
public String tag;
- public VersionTag() {
+ public RFC7285VersionTag() {
rid = "";
tag = "";
}
- public VersionTag(String rid, String tag) {
+ public RFC7285VersionTag(String rid, String tag) {
this.rid = (rid != null ? rid : "");
this.tag = (tag != null ? tag : "");
}
if (obj == null)
return false;
- VersionTag other = (VersionTag)obj;
+ RFC7285VersionTag other = (RFC7285VersionTag)obj;
boolean _rid = (rid == null ? (other.rid == null) : rid.equals(other.rid));
boolean _tag = (tag == null ? (other.tag == null) : tag.equals(other.tag));
return (_rid && _tag);
--- /dev/null
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.alto</groupId>
+ <artifactId>alto-extensions</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../../</relativePath>
+ </parent>
+
+ <artifactId>file-converter</artifactId>
+ <packaging>bundle</packaging>
+ <name>${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>alto-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <version>2.2.11</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>alto-commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${bundle.plugin.version}</version>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.apache.felix.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.karaf.shell.console,
+ org.opendaylight.alto.commons.types.*,
+ *
+ </Import-Package>
+ <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package org.opendaylight.alto.ext.cli.fileconverter;
+
+public class ConvertType {
+
+ //TODO add more types
+
+ public static final String NETWORK_MAP = "networkmap";
+
+}
--- /dev/null
+package org.opendaylight.alto.ext.cli.fileconverter;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+
+import com.google.common.io.Files;
+
+class FileConverterHelper {
+
+ public String load(String path) throws Exception {
+ File file = new File(path);
+ return Files.toString(file, StandardCharsets.US_ASCII);
+ }
+
+ public void save(String path, String content) throws Exception {
+ File file = new File(path);
+ Files.write(content, file, StandardCharsets.US_ASCII);
+ }
+}
--- /dev/null
+package org.opendaylight.alto.ext.cli.fileconverter;
+
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import org.opendaylight.alto.commons.types.converter.RFC2ModelNetworkMapConverter;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
+import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Command(scope = "alto", name = "file-rfc2yang", description = "Convert file from RFC 7285 format to Yang Data format")
+public class RFC2Yang extends OsgiCommandSupport {
+
+ private static final Logger logger = LoggerFactory.getLogger(RFC2Yang.class);
+
+ @Argument(index = 0, name = "type", description = "The type of the source file", required = true, multiValued = false)
+ String type = null;
+
+ @Argument(index = 1, name = "source", description = "The source file", required = true, multiValued = false)
+ String source = null;
+
+ @Argument(index = 2, name = "target", description = "The target file", required = false, multiValued = false)
+ String target = null;
+
+ protected RFC7285JSONMapper rfcMapper = new RFC7285JSONMapper();
+ protected ModelJSONMapper modelMapper = new ModelJSONMapper();
+ protected FileConverterHelper helper = new FileConverterHelper();
+
+ @Override
+ protected Object doExecute() throws Exception {
+ logger.info("command: alto:rfc2yang {} {} {}",
+ type, source, target);
+ if (ConvertType.NETWORK_MAP.equals(type)) {
+ String input = helper.load(source);
+ RFC7285NetworkMap rfcMap = rfcMapper.asNetworkMap(input);
+
+ RFC2ModelNetworkMapConverter conv = new RFC2ModelNetworkMapConverter();
+
+ ModelNetworkMap modelMap = conv.convert(rfcMap);
+ String output = modelMapper.asJSON(modelMap);
+ helper.save(target, output);
+ }
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+}
+
--- /dev/null
+package org.opendaylight.alto.ext.cli.fileconverter;
+
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Command(scope = "alto", name = "file-yang2rfc", description = "The converter between RFC 7285 and Yang Model files")
+public class Yang2RFC extends OsgiCommandSupport {
+
+ private static final Logger logger = LoggerFactory.getLogger(Yang2RFC.class);
+
+ @Argument(index = 0, name = "type", description = "The type of the source file", required = true, multiValued = false)
+ String type = null;
+
+ @Argument(index = 1, name = "source", description = "The source file", required = true, multiValued = false)
+ String source = null;
+
+ @Argument(index = 2, name = "target", description = "The target file", required = false, multiValued = false)
+ String target = null;
+
+ @Override
+ protected Object doExecute() throws Exception {
+ logger.info("command: alto:rfc2yang {} {} {}",
+ type, source, target);
+
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+}
+
--- /dev/null
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+ <command name="alto/file-yang2rfc">
+ <action class="org.opendaylight.alto.ext.cli.fileconvertor.Yang2RFC"/>
+ </command>
+
+ <command name="alto/file-rfc2yang">
+ <action class="org.opendaylight.alto.ext.cli.fileconvertor.RFC2Yang"/>
+ </command>
+ </command-bundle>
+</blueprint>
</parent>
<groupId>org.opendaylight.alto</groupId>
- <artifactId>services.ext</artifactId>
+ <artifactId>alto-cli-extension</artifactId>
<packaging>pom</packaging>
<modules>
- <module>fs-map</module>
- <module>fake</module>
+ <module>file-converter</module>
</modules>
</project>
<parent>
<groupId>org.opendaylight.alto</groupId>
- <artifactId>services.ext</artifactId>
+ <artifactId>alto-extensions</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
- <artifactId>services.ext.fake</artifactId>
+ <artifactId>alto-fake-extension</artifactId>
<packaging>bundle</packaging>
<build>
org.slf4j,
</Import-Package>
<Export-Package>
- org.opendaylight.alto.services.ext.fake;
+ org.opendaylight.alto.ext.fake;
</Export-Package>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
</instructions>
-package org.opendaylight.alto.services.ext.fake;
+package org.opendaylight.alto.ext.fake;
import org.opendaylight.alto.services.api.rfc7285.AltoService;
-import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.CostType;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.IRD;
-import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
public class FakeAltoService implements AltoService {
- private JSONMapper mapper = new JSONMapper();
+ private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
private static final String NETWORKMAP_JSON =
"{"
private static final String DEFAULT_NETWORKMAP_ID = "default-networkmap";
private static final String DEFAULT_NETWORKMAP_TAG = "3ee2cb7e8d63d9fab71b9b34cbf764436315542e";
- private NetworkMap networkMap = null;
+ private RFC7285NetworkMap networkMap = null;
private static final String COSTMAP_JSON =
"{"
private static final String DEFAULT_COSTMAP_ID = "default-costmap";
- private CostMap costMap = null;
+ private RFC7285CostMap costMap = null;
public FakeAltoService() {
try {
}
}
- public CostMap getCostMap(String id) {
+ public RFC7285CostMap getCostMap(String id) {
if (!DEFAULT_COSTMAP_ID.equals(id))
return null;
return costMap;
}
- public CostMap getCostMap(VersionTag vtag) {
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag) {
return getCostMap(vtag.rid);
}
- public CostMap getCostMap(String id, CostType type) {
+ public RFC7285CostMap getCostMap(String id, RFC7285CostType type) {
if (!DEFAULT_COSTMAP_ID.equals(id))
return null;
if (!(costMap.meta.costType.equals(type)))
return costMap;
}
- public CostMap getCostMap(VersionTag vtag, CostType type) {
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type) {
return getCostMap(vtag.rid, type);
}
- public CostMap getCostMap(String id, CostMap.Filter filter) {
+ public RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter) {
return null;
}
- public CostMap getCostMap(VersionTag vtag, CostMap.Filter filter) {
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
return null;
}
- public Boolean supportCostType(String id, CostType type) {
+ public Boolean supportCostType(String id, RFC7285CostType type) {
return null;
}
- public Boolean supportCostType(VersionTag vtag, CostType type) {
+ public Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type) {
if (!DEFAULT_COSTMAP_ID.equals(vtag.rid))
return new Boolean(false);
if (!costMap.meta.costType.equals(type))
return new Boolean(true);
}
- public Boolean validateCostMapFilter(String id, CostMap.Filter filter) {
+ public Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter) {
return false;
}
- public Boolean validateCostMapFilter(VersionTag vtag, CostMap.Filter filter) {
+ public Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter) {
return false;
}
- public NetworkMap getDefaultNetworkMap() {
+ public RFC7285NetworkMap getDefaultNetworkMap() {
return networkMap;
}
- public NetworkMap getNetworkMap(String id) {
+ public RFC7285NetworkMap getNetworkMap(String id) {
if (!DEFAULT_NETWORKMAP_ID.equals(id))
return null;
return networkMap;
}
- public NetworkMap getNetworkMap(VersionTag vtag) {
+ public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag) {
if (!DEFAULT_NETWORKMAP_ID.equals(vtag.rid))
return null;
if (!DEFAULT_NETWORKMAP_TAG.equals(vtag.tag))
return networkMap;
}
- public NetworkMap getNetworkMap(String id, NetworkMap.Filter filter) {
+ public RFC7285NetworkMap getNetworkMap(String id, RFC7285NetworkMap.Filter filter) {
return null;
}
- public NetworkMap getNetworkMap(VersionTag vtag, NetworkMap.Filter filter) {
+ public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter) {
return null;
}
- public Boolean validateNetworkMapFilter(String id, NetworkMap.Filter filter) {
+ public Boolean validateNetworkMapFilter(String id, RFC7285NetworkMap.Filter filter) {
return new Boolean(false);
}
- public Boolean validateNetworkMapFilter(VersionTag vtag, NetworkMap.Filter filter) {
+ public Boolean validateNetworkMapFilter(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter) {
return new Boolean(false);
}
- public IRD getDefaultIRD() {
+ public RFC7285IRD getDefaultIRD() {
return null;
}
- public IRD getIRD(String id) {
+ public RFC7285IRD getIRD(String id) {
return null;
}
- public Endpoint.CostResponse getEndpointCost(String id, Endpoint.CostRequest request) {
+ public RFC7285Endpoint.CostResponse getEndpointCost(String id, RFC7285Endpoint.CostRequest request) {
return null;
}
- public Endpoint.CostResponse getEndpointCost(VersionTag vtag, Endpoint.CostRequest request) {
+ public RFC7285Endpoint.CostResponse getEndpointCost(RFC7285VersionTag vtag, RFC7285Endpoint.CostRequest request) {
return null;
}
- public Endpoint.PropertyResponse getEndpointProperty(String id, Endpoint.PropertyRequest request) {
+ public RFC7285Endpoint.PropertyResponse getEndpointProperty(String id, RFC7285Endpoint.PropertyRequest request) {
return null;
}
- public Endpoint.PropertyResponse getEndpointProperty(VersionTag vtag, Endpoint.PropertyRequest request) {
+ public RFC7285Endpoint.PropertyResponse getEndpointProperty(RFC7285VersionTag vtag, RFC7285Endpoint.PropertyRequest request) {
return null;
}
<parent>
<groupId>org.opendaylight.alto</groupId>
- <artifactId>services.ext</artifactId>
+ <artifactId>alto-extensions</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
- <artifactId>services.ext.fs-map</artifactId>
+ <artifactId>fs-map-generator</artifactId>
<packaging>bundle</packaging>
<build>
org.slf4j,
</Import-Package>
<Export-Package>
- org.opendaylight.alto.services.ext.fsmap;
+ org.opendaylight.alto.ext.fsmap;
</Export-Package>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
</instructions>
-package org.opendaylight.alto.services.ext.fsmap;
+package org.opendaylight.alto.ext.fsmap;
import java.net.URI;
import java.nio.file.FileSystem;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.HashMap;
-import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
-import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private HashMap<WatchKey, Path> paths = new HashMap<WatchKey, Path>();
private MapFileLoader loader = null;
private AtomicBoolean cancelled = new AtomicBoolean(false);
- private HashMap<Path, VersionTag> path_to_id = new HashMap<Path, VersionTag>();
- private HashMap<VersionTag, NetworkMap> id_to_map = new HashMap<VersionTag, NetworkMap>();
- private JSONMapper mapper = new JSONMapper();
+ private HashMap<Path, RFC7285VersionTag> path_to_id = new HashMap<Path, RFC7285VersionTag>();
+ private HashMap<RFC7285VersionTag, RFC7285NetworkMap> id_to_map = new HashMap<RFC7285VersionTag, RFC7285NetworkMap>();
+ private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
public FileSystemNetworkMapGenerator(URI uri) throws Exception {
source = Paths.get(uri);
} catch (Exception e) {
}
- for (VersionTag vtag: path_to_id.values()) {
+ for (RFC7285VersionTag vtag: path_to_id.values()) {
// TODO remove network map
if (vtag.incomplete())
continue;
//TODO
try {
String content = new String(Files.readAllBytes(file), StandardCharsets.US_ASCII);
- NetworkMap map = mapper.asNetworkMap(content);
+ RFC7285NetworkMap map = mapper.asNetworkMap(content);
- VersionTag vtag = map.meta.vtag;
+ RFC7285VersionTag vtag = map.meta.vtag;
logger.info("vtag: <" + vtag.rid + ", " + vtag.tag + ">");
if (id_to_map.get(map.meta.vtag) != null) {
logger.warn("Version tag already registered: ("
public void onDelete(Path file) {
//TODO
try {
- VersionTag vtag = path_to_id.get(file);
+ RFC7285VersionTag vtag = path_to_id.get(file);
if (vtag == null)
return;
//TODO
try {
String content = new String(Files.readAllBytes(file), StandardCharsets.US_ASCII);
- NetworkMap map = mapper.asNetworkMap(content);
- VersionTag vtag = map.meta.vtag;
- VersionTag old = path_to_id.get(file);
+ RFC7285NetworkMap map = mapper.asNetworkMap(content);
+ RFC7285VersionTag vtag = map.meta.vtag;
+ RFC7285VersionTag old = path_to_id.get(file);
if (old != null) {
if (vtag.rid != old.rid) {
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.alto</groupId>
+ <artifactId>alto-parent</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <groupId>org.opendaylight.alto</groupId>
+ <artifactId>alto-extensions</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>fs-map</module>
+ <module>fake</module>
+ <module>cli</module>
+ </modules>
+
+</project>
+
<instructions>
<Import-Package>
org.opendaylight.yang.gen.v1.urn.opendaylight.alto.*,
- org.opendaylight.alto.services.ext.fake,
+ org.opendaylight.alto.ext.fake,
org.opendaylight.alto.services.api.rfc7285,
org.opendaylight.alto.commons.*,
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>services.ext.fake</artifactId>
+ <artifactId>alto-fake-extension</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
-import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285JSONMapper;
import org.opendaylight.alto.commons.types.rfc7285.FormatValidator;
import org.opendaylight.alto.commons.types.rfc7285.MediaType;
-import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.CostType;
-import org.opendaylight.alto.commons.types.rfc7285.IRD;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint;
import org.opendaylight.alto.services.api.rfc7285.AltoService;
-import org.opendaylight.alto.services.ext.fake.FakeAltoService;
+import org.opendaylight.alto.ext.fake.FakeAltoService;
import org.opendaylight.alto.northbound.exception.AltoBasicException;
import org.opendaylight.alto.northbound.exception.AltoBadFormatException;
private static final Logger logger = LoggerFactory.getLogger(AltoNorthbound.class);
private AltoService altoService = new FakeAltoService();
- private JSONMapper mapper = new JSONMapper();
+ private RFC7285JSONMapper mapper = new RFC7285JSONMapper();
private void checkAltoService() throws Exception {
if (altoService == null)
public Response retrieveIRD() throws Exception {
checkAltoService();
- IRD ird = altoService.getDefaultIRD();
+ RFC7285IRD ird = altoService.getDefaultIRD();
if (ird == null)
return fail(Status.NOT_FOUND, null);
return success(ird, MediaType.ALTO_DIRECTORY);
checkAltoService();
checkResourceId(id);
- IRD ird = altoService.getIRD(id);
+ RFC7285IRD ird = altoService.getIRD(id);
if (ird == null)
return fail(Status.NOT_FOUND, id);
return success(ird, MediaType.ALTO_DIRECTORY);
public Response retrieveDefaultNetworkMap() throws Exception {
checkAltoService();
- NetworkMap map = altoService.getDefaultNetworkMap();
+ RFC7285NetworkMap map = altoService.getDefaultNetworkMap();
if (map == null)
return fail(Status.NOT_FOUND, null);
return success(map, MediaType.ALTO_NETWORKMAP);
checkAltoService();
checkResourceId(id);
- NetworkMap map = altoService.getNetworkMap(id);
+ RFC7285NetworkMap map = altoService.getNetworkMap(id);
if (map == null)
return fail(Status.NOT_FOUND, id);
return success(map, MediaType.ALTO_NETWORKMAP);
checkResourceId(id);
checkTag(tag);
- VersionTag vtag = new VersionTag(id, tag);
- NetworkMap map = altoService.getNetworkMap(vtag);
+ RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+ RFC7285NetworkMap map = altoService.getNetworkMap(vtag);
if (map == null)
return fail(Status.NOT_FOUND, vtag);
return success(map, MediaType.ALTO_NETWORKMAP);
checkAltoService();
checkResourceId(id);
- CostMap map = altoService.getCostMap(id);
+ RFC7285CostMap map = altoService.getCostMap(id);
if (map == null)
return fail(Status.NOT_FOUND, id);
return success(map, MediaType.ALTO_COSTMAP);
checkResourceId(id);
checkTag(tag);
- VersionTag vtag = new VersionTag(id, tag);
- CostMap map = altoService.getCostMap(vtag);
+ RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+ RFC7285CostMap map = altoService.getCostMap(vtag);
if (map == null)
return fail(Status.NOT_FOUND, vtag);
return success(map, MediaType.ALTO_COSTMAP);
checkAltoService();
checkResourceId(id);
- CostType costType = new CostType(mode, metric);
+ RFC7285CostType costType = new RFC7285CostType(mode, metric);
if (!altoService.supportCostType(id, costType))
return fail(Status.NOT_FOUND, costType);
- CostMap map = altoService.getCostMap(id, costType);
+ RFC7285CostMap map = altoService.getCostMap(id, costType);
if (map == null)
return fail(Status.NOT_FOUND, id);
return success(map, MediaType.ALTO_COSTMAP);
checkResourceId(id);
checkTag(tag);
- VersionTag vtag = new VersionTag(id, tag);
- CostType costType = new CostType(mode, metric);
+ RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+ RFC7285CostType costType = new RFC7285CostType(mode, metric);
if (!altoService.supportCostType(vtag, costType))
return fail(Status.NOT_FOUND, costType);
- CostMap map = altoService.getCostMap(vtag, costType);
+ RFC7285CostMap map = altoService.getCostMap(vtag, costType);
if (map == null)
return fail(Status.NOT_FOUND, vtag);
return success(map, MediaType.ALTO_COSTMAP);
checkAltoService();
checkResourceId(id);
- NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
+ RFC7285NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
if (!altoService.validateNetworkMapFilter(id, filter))
return fail(Status.BAD_REQUEST, filter);
- NetworkMap map = altoService.getNetworkMap(id, filter);
+ RFC7285NetworkMap map = altoService.getNetworkMap(id, filter);
if (map == null)
return fail(Status.NOT_FOUND, id);
return success(map, MediaType.ALTO_NETWORKMAP);
checkResourceId(id);
checkTag(tag);
- VersionTag vtag = new VersionTag(id, tag);
- NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
+ RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+ RFC7285NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
if (!altoService.validateNetworkMapFilter(vtag, filter))
return fail(Status.BAD_REQUEST, filter);
- NetworkMap map = altoService.getNetworkMap(vtag, filter);
+ RFC7285NetworkMap map = altoService.getNetworkMap(vtag, filter);
if (map == null)
return fail(Status.NOT_FOUND, vtag);
return success(map, MediaType.ALTO_NETWORKMAP);
checkAltoService();
checkResourceId(id);
- CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
+ RFC7285CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
if (!altoService.validateCostMapFilter(id, filter))
return fail(Status.BAD_REQUEST, filter);
- CostMap map = altoService.getCostMap(id, filter);
+ RFC7285CostMap map = altoService.getCostMap(id, filter);
if (map == null)
return fail(Status.NOT_FOUND, id);
return success(map, MediaType.ALTO_COSTMAP);
checkResourceId(id);
checkTag(tag);
- VersionTag vtag = new VersionTag(id, tag);
- CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
+ RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+ RFC7285CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
if (!altoService.validateCostMapFilter(vtag, filter))
return fail(Status.BAD_REQUEST, filter);
- CostMap map = altoService.getCostMap(vtag, filter);
+ RFC7285CostMap map = altoService.getCostMap(vtag, filter);
if (map == null)
return fail(Status.NOT_FOUND, vtag);
return success(map, MediaType.ALTO_COSTMAP);
checkAltoService();
checkResourceId(id);
- Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
- Endpoint.PropertyResponse response = altoService.getEndpointProperty(id, request);
+ RFC7285Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
+ RFC7285Endpoint.PropertyResponse response = altoService.getEndpointProperty(id, request);
if (response == null)
return fail(Status.NOT_FOUND, request);
return success(response, MediaType.ALTO_ENDPOINT_PROP);
checkResourceId(id);
checkTag(tag);
- VersionTag vtag = new VersionTag(id, tag);
- Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
- Endpoint.PropertyResponse response = altoService.getEndpointProperty(vtag, request);
+ RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+ RFC7285Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
+ RFC7285Endpoint.PropertyResponse response = altoService.getEndpointProperty(vtag, request);
if (response == null)
return fail(Status.NOT_FOUND, request);
return success(response, MediaType.ALTO_ENDPOINT_PROP);
checkAltoService();
checkResourceId(id);
- Endpoint.CostRequest request = mapper.asCostRequest(params);
- Endpoint.CostResponse response = altoService.getEndpointCost(id, request);
+ RFC7285Endpoint.CostRequest request = mapper.asCostRequest(params);
+ RFC7285Endpoint.CostResponse response = altoService.getEndpointCost(id, request);
if (response == null)
return fail(Status.NOT_FOUND, request);
return success(response, MediaType.ALTO_ENDPOINT_COST);
checkResourceId(id);
checkTag(tag);
- VersionTag vtag = new VersionTag(id, tag);
- Endpoint.CostRequest request = mapper.asCostRequest(params);
- Endpoint.CostResponse response = altoService.getEndpointCost(vtag, request);
+ RFC7285VersionTag vtag = new RFC7285VersionTag(id, tag);
+ RFC7285Endpoint.CostRequest request = mapper.asCostRequest(params);
+ RFC7285Endpoint.CostResponse response = altoService.getEndpointCost(vtag, request);
if (response == null)
return fail(Status.NOT_FOUND, request);
return success(response, MediaType.ALTO_ENDPOINT_COST);
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(AltoNorthbound.class);
+ classes.add(Echo.class);
return classes;
}
}
--- /dev/null
+package org.opendaylight.alto.northbound;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+import org.opendaylight.alto.commons.types.model150404.ModelNetworkMap;
+import org.opendaylight.alto.commons.types.model150404.ModelJSONMapper;
+
+@Path("/echo")
+class Echo {
+
+ protected ModelJSONMapper modelMapper = new ModelJSONMapper();
+
+ @Path("/model/networkmap")
+ @POST
+ Response echoModelNetworkMap(String content) throws Exception {
+ ModelNetworkMap nmap = modelMapper.asNetworkMap(content);
+ String output = modelMapper.asJSON(nmap);
+ return Response.ok(output).build();
+ }
+
+ @Path("/model/networkmap")
+ @GET
+ Response echoModelNetworkMap() throws Exception {
+ return Response.ok("not implemented").build();
+ }
+}
import java.util.Collections;
import java.util.Map;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
import java.util.HashMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker;
this._dataBroker = base.getDataBroker();
this._rpcRegistry = base.getRpcRegistry();
if (base instanceof AltoProviderImplImpl) {
- AltoProviderImplImpl _impl = (AltoProviderImplImpl) base;
- this.augmentation = new HashMap<>(_impl.augmentation);
+ AltoProviderImplImpl impl = (AltoProviderImplImpl) base;
+ this.augmentation = new HashMap<>(impl.augmentation);
+ } else if (base instanceof AugmentationHolder) {
+ @SuppressWarnings("unchecked")
+ AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>) base;
+ this.augmentation = new HashMap<>(casted.augmentations());
}
}
private AltoProviderImplImpl(AltoProviderImplBuilder base) {
this._dataBroker = base.getDataBroker();
this._rpcRegistry = base.getRpcRegistry();
- switch (base.augmentation.size()) {
- case 0:
- this.augmentation = Collections.emptyMap();
- break;
- case 1:
- final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>> e = base.augmentation.entrySet().iterator().next();
- this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>singletonMap(e.getKey(), e.getValue());
- break;
- default :
- this.augmentation = new HashMap<>(base.augmentation);
- }
+ switch (base.augmentation.size()) {
+ case 0:
+ this.augmentation = Collections.emptyMap();
+ break;
+ case 1:
+ final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>> e = base.augmentation.entrySet().iterator().next();
+ this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.AltoProviderImpl>>singletonMap(e.getKey(), e.getValue());
+ break;
+ default :
+ this.augmentation = new HashMap<>(base.augmentation);
+ }
}
@Override
import java.util.Collections;
import java.util.Map;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
import java.util.HashMap;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.Augmentation;
this._name = base.getName();
this._type = base.getType();
if (base instanceof DataBrokerImpl) {
- DataBrokerImpl _impl = (DataBrokerImpl) base;
- this.augmentation = new HashMap<>(_impl.augmentation);
+ DataBrokerImpl impl = (DataBrokerImpl) base;
+ this.augmentation = new HashMap<>(impl.augmentation);
+ } else if (base instanceof AugmentationHolder) {
+ @SuppressWarnings("unchecked")
+ AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>) base;
+ this.augmentation = new HashMap<>(casted.augmentations());
}
}
private DataBrokerImpl(DataBrokerBuilder base) {
this._name = base.getName();
this._type = base.getType();
- switch (base.augmentation.size()) {
- case 0:
- this.augmentation = Collections.emptyMap();
- break;
- case 1:
- final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>> e = base.augmentation.entrySet().iterator().next();
- this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>singletonMap(e.getKey(), e.getValue());
- break;
- default :
- this.augmentation = new HashMap<>(base.augmentation);
- }
+ switch (base.augmentation.size()) {
+ case 0:
+ this.augmentation = Collections.emptyMap();
+ break;
+ case 1:
+ final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>> e = base.augmentation.entrySet().iterator().next();
+ this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.DataBroker>>singletonMap(e.getKey(), e.getValue());
+ break;
+ default :
+ this.augmentation = new HashMap<>(base.augmentation);
+ }
}
@Override
import java.util.Collections;
import java.util.Map;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
import java.util.HashMap;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.Augmentation;
this._name = base.getName();
this._type = base.getType();
if (base instanceof RpcRegistryImpl) {
- RpcRegistryImpl _impl = (RpcRegistryImpl) base;
- this.augmentation = new HashMap<>(_impl.augmentation);
+ RpcRegistryImpl impl = (RpcRegistryImpl) base;
+ this.augmentation = new HashMap<>(impl.augmentation);
+ } else if (base instanceof AugmentationHolder) {
+ @SuppressWarnings("unchecked")
+ AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>) base;
+ this.augmentation = new HashMap<>(casted.augmentations());
}
}
private RpcRegistryImpl(RpcRegistryBuilder base) {
this._name = base.getName();
this._type = base.getType();
- switch (base.augmentation.size()) {
- case 0:
- this.augmentation = Collections.emptyMap();
- break;
- case 1:
- final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> e = base.augmentation.entrySet().iterator().next();
- this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>singletonMap(e.getKey(), e.getValue());
- break;
- default :
- this.augmentation = new HashMap<>(base.augmentation);
- }
+ switch (base.augmentation.size()) {
+ case 0:
+ this.augmentation = Collections.emptyMap();
+ break;
+ case 1:
+ final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> e = base.augmentation.entrySet().iterator().next();
+ this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>singletonMap(e.getKey(), e.getValue());
+ break;
+ default :
+ this.augmentation = new HashMap<>(base.augmentation);
+ }
}
@Override
import java.util.Collections;
import java.util.Map;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
import java.util.HashMap;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.Augmentation;
public AltoProviderImplBuilder(AltoProviderImpl base) {
if (base instanceof AltoProviderImplImpl) {
- AltoProviderImplImpl _impl = (AltoProviderImplImpl) base;
- this.augmentation = new HashMap<>(_impl.augmentation);
+ AltoProviderImplImpl impl = (AltoProviderImplImpl) base;
+ this.augmentation = new HashMap<>(impl.augmentation);
+ } else if (base instanceof AugmentationHolder) {
+ @SuppressWarnings("unchecked")
+ AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>) base;
+ this.augmentation = new HashMap<>(casted.augmentations());
}
}
private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> augmentation = new HashMap<>();
private AltoProviderImplImpl(AltoProviderImplBuilder base) {
- switch (base.augmentation.size()) {
- case 0:
- this.augmentation = Collections.emptyMap();
- break;
- case 1:
- final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> e = base.augmentation.entrySet().iterator().next();
- this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>singletonMap(e.getKey(), e.getValue());
- break;
- default :
- this.augmentation = new HashMap<>(base.augmentation);
- }
+ switch (base.augmentation.size()) {
+ case 0:
+ this.augmentation = Collections.emptyMap();
+ break;
+ case 1:
+ final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> e = base.augmentation.entrySet().iterator().next();
+ this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>singletonMap(e.getKey(), e.getValue());
+ break;
+ default :
+ this.augmentation = new HashMap<>(base.augmentation);
+ }
}
package org.opendaylight.alto.services.api.rfc7285;
-import org.opendaylight.alto.commons.types.rfc7285.CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
-import org.opendaylight.alto.commons.types.rfc7285.CostType;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285CostType;
public interface CostMapService {
- public CostMap getCostMap(String id);
+ public RFC7285CostMap getCostMap(String id);
- public CostMap getCostMap(VersionTag vtag);
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag);
- public CostMap getCostMap(String id, CostType type);
+ public RFC7285CostMap getCostMap(String id, RFC7285CostType type);
- public CostMap getCostMap(VersionTag vtag, CostType type);
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostType type);
- public CostMap getCostMap(String id, CostMap.Filter filter);
+ public RFC7285CostMap getCostMap(String id, RFC7285CostMap.Filter filter);
- public CostMap getCostMap(VersionTag vtag, CostMap.Filter filter);
+ public RFC7285CostMap getCostMap(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter);
- public Boolean supportCostType(String id, CostType type);
+ public Boolean supportCostType(String id, RFC7285CostType type);
- public Boolean supportCostType(VersionTag vtag, CostType type);
+ public Boolean supportCostType(RFC7285VersionTag vtag, RFC7285CostType type);
- public Boolean validateCostMapFilter(String id, CostMap.Filter filter);
+ public Boolean validateCostMapFilter(String id, RFC7285CostMap.Filter filter);
- public Boolean validateCostMapFilter(VersionTag vtag, CostMap.Filter filter);
+ public Boolean validateCostMapFilter(RFC7285VersionTag vtag, RFC7285CostMap.Filter filter);
}
package org.opendaylight.alto.services.api.rfc7285;
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostRequest;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.CostResponse;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
public interface EndpointCostService {
- public Endpoint.CostResponse getEndpointCost(String id, Endpoint.CostRequest request);
+ public CostResponse getEndpointCost(String id, CostRequest request);
- public Endpoint.CostResponse getEndpointCost(VersionTag vtag, Endpoint.CostRequest request);
+ public CostResponse getEndpointCost(RFC7285VersionTag vtag, CostRequest request);
}
package org.opendaylight.alto.services.api.rfc7285;
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyRequest;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Endpoint.PropertyResponse;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
public interface EndpointPropertyService {
- public Endpoint.PropertyResponse getEndpointProperty(String id, Endpoint.PropertyRequest request);
+ public PropertyResponse getEndpointProperty(String id, PropertyRequest request);
- public Endpoint.PropertyResponse getEndpointProperty(VersionTag vtag, Endpoint.PropertyRequest request);
+ public PropertyResponse getEndpointProperty(RFC7285VersionTag vtag, PropertyRequest request);
}
package org.opendaylight.alto.services.api.rfc7285;
-import org.opendaylight.alto.commons.types.rfc7285.IRD;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285IRD;
public interface IRDService {
- public IRD getDefaultIRD();
+ public RFC7285IRD getDefaultIRD();
- public IRD getIRD(String id);
+ public RFC7285IRD getIRD(String id);
}
package org.opendaylight.alto.services.api.rfc7285;
-import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285VersionTag;
public interface NetworkMapService {
- public NetworkMap getDefaultNetworkMap();
+ public RFC7285NetworkMap getDefaultNetworkMap();
- public NetworkMap getNetworkMap(String id);
+ public RFC7285NetworkMap getNetworkMap(String id);
- public NetworkMap getNetworkMap(VersionTag vtag);
+ public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag);
- public NetworkMap getNetworkMap(String id, NetworkMap.Filter filter);
+ public RFC7285NetworkMap getNetworkMap(String id, RFC7285NetworkMap.Filter filter);
- public NetworkMap getNetworkMap(VersionTag vtag, NetworkMap.Filter filter);
+ public RFC7285NetworkMap getNetworkMap(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter);
- public Boolean validateNetworkMapFilter(String id, NetworkMap.Filter filter);
+ public Boolean validateNetworkMapFilter(String id, RFC7285NetworkMap.Filter filter);
- public Boolean validateNetworkMapFilter(VersionTag vtag, NetworkMap.Filter filter);
+ public Boolean validateNetworkMapFilter(RFC7285VersionTag vtag, RFC7285NetworkMap.Filter filter);
}
<module>alto-commons</module>
<module>alto-manager</module>
<module>alto-services/api</module>
- <module>alto-services/ext</module>
+ <module>alto-extensions</module>
<!-- <module>alto-karaf</module> -->
<module>alto-northbound</module>
</modules>