diff options
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web')
17 files changed, 0 insertions, 1088 deletions
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java deleted file mode 100644 index 4b6b662f..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.AllocationPool; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Subnet AllocationPool codec. - */ -public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> { - - @Override - public ObjectNode encode(AllocationPool alocPool, CodecContext context) { - checkNotNull(alocPool, "AllocationPools cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("start", alocPool.startIp().toString()) - .put("end", alocPool.endIp().toString()); - return result; - } - -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java deleted file mode 100644 index 8ffc4e91..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.AllowedAddressPair; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * VirtualPort AllowedAddressPair codec. - */ -public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> { - - @Override - public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) { - checkNotNull(alocAddPair, "AllowedAddressPair cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("ip_address", alocAddPair.ip().toString()) - .put("mac_address", alocAddPair.mac().toString()); - return result; - } - -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java deleted file mode 100644 index 559de685..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.FixedIp; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * VirtualPort FixedIp codec. - */ -public final class FixedIpCodec extends JsonCodec<FixedIp> { - - @Override - public ObjectNode encode(FixedIp fixIp, CodecContext context) { - checkNotNull(fixIp, "FixedIp cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("subnet_id", fixIp.subnetId().toString()) - .put("ip_address", fixIp.ip().toString()); - return result; - } - -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java deleted file mode 100644 index ff5aebb4..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Iterator; -import java.util.List; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.FloatingIp; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * FloatingIp JSON codec. - */ -public final class FloatingIpCodec extends JsonCodec<FloatingIp> { - @Override - public ObjectNode encode(FloatingIp floatingIp, CodecContext context) { - checkNotNull(floatingIp, "floatingIp cannot be null"); - ObjectNode result = context - .mapper() - .createObjectNode() - .put("id", floatingIp.id().floatingIpId().toString()) - .put("floating_network_id", floatingIp.networkId().toString()) - .put("router_id", - floatingIp.routerId() == null ? null : floatingIp - .routerId().routerId()) - .put("tenant_id", floatingIp.tenantId().toString()) - .put("port_id", - floatingIp.portId() == null ? null : floatingIp.portId() - .toString()) - .put("fixed_ip_address", - floatingIp.fixedIp() == null ? null : floatingIp.fixedIp() - .toString()) - .put("floating_ip_address", floatingIp.floatingIp().toString()) - .put("status", floatingIp.status().toString()); - return result; - } - - public ObjectNode extracFields(FloatingIp floatingIp, CodecContext context, - List<String> fields) { - checkNotNull(floatingIp, "floatingIp cannot be null"); - ObjectNode result = context.mapper().createObjectNode(); - Iterator<String> i = fields.iterator(); - while (i.hasNext()) { - String s = i.next(); - if (s.equals("floating_network_id")) { - result.put("floating_network_id", floatingIp.networkId() - .toString()); - } - if (s.equals("router_id")) { - result.put("router_id", - floatingIp.routerId() == null ? null : floatingIp - .routerId().routerId()); - } - if (s.equals("tenant_id")) { - result.put("tenant_id", floatingIp.tenantId().toString()); - } - if (s.equals("port_id")) { - result.put("port_id", - floatingIp.portId() == null ? null : floatingIp - .portId().toString()); - } - if (s.equals("id")) { - result.put("id", floatingIp.id().floatingIpId().toString()); - } - if (s.equals("fixed_ip_address")) { - result.put("fixed_ip_address", - floatingIp.fixedIp() == null ? null : floatingIp - .fixedIp().toString()); - } - if (s.equals("floating_ip_address")) { - result.put("floating_ip_address", floatingIp.floatingIp() - .toString()); - } - if (s.equals("status")) { - result.put("status", floatingIp.status().toString()); - } - } - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java deleted file mode 100644 index a18ca362..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.onlab.util.Tools.nullIsIllegal; - -import org.onlab.packet.IpPrefix; -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.DefaultFlowClassifier; -import org.onosproject.vtnrsc.FlowClassifier; -import org.onosproject.vtnrsc.FlowClassifierId; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.VirtualPortId; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Flow Classifier JSON codec. - */ -public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> { - - private static final String FLOW_CLASSIFIER_ID = "id"; - private static final String TENANT_ID = "tenant_id"; - private static final String NAME = "name"; - private static final String DESCRIPTION = "description"; - private static final String ETHER_TYPE = "ethertype"; - private static final String PROTOCOL = "protocol"; - private static final String MIN_SRC_PORT_RANGE = "source_port_range_min"; - private static final String MAX_SRC_PORT_RANGE = "source_port_range_max"; - private static final String MIN_DST_PORT_RANGE = "destination_port_range_min"; - private static final String MAX_DST_PORT_RANGE = "destination_port_range_max"; - private static final String SRC_IP_PREFIX = "source_ip_prefix"; - private static final String DST_IP_PREFIX = "destination_ip_prefix"; - private static final String SRC_PORT = "logical_source_port"; - private static final String DST_PORT = "logical_destination_port"; - private static final String MISSING_MEMBER_MESSAGE = " member is required in Flow Classifier."; - - @Override - public FlowClassifier decode(ObjectNode json, CodecContext context) { - if (json == null || !json.isObject()) { - return null; - } - - FlowClassifier.Builder resultBuilder = new DefaultFlowClassifier.Builder(); - - String flowClassifierId = nullIsIllegal(json.get(FLOW_CLASSIFIER_ID), - FLOW_CLASSIFIER_ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setFlowClassifierId(FlowClassifierId.of(flowClassifierId)); - - String tenantId = nullIsIllegal(json.get(TENANT_ID), TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setTenantId(TenantId.tenantId(tenantId)); - - String flowClassiferName = nullIsIllegal(json.get(NAME), NAME + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setName(flowClassiferName); - - String flowClassiferDescription = (json.get(DESCRIPTION)).asText(); - resultBuilder.setDescription(flowClassiferDescription); - - String etherType = nullIsIllegal(json.get(ETHER_TYPE), ETHER_TYPE + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setEtherType(etherType); - - String protocol = (json.get(PROTOCOL)).asText(); - resultBuilder.setProtocol(protocol); - - int minSrcPortRange = (json.get(MIN_SRC_PORT_RANGE)).asInt(); - resultBuilder.setMinSrcPortRange(minSrcPortRange); - - int maxSrcPortRange = (json.get(MAX_SRC_PORT_RANGE)).asInt(); - resultBuilder.setMaxSrcPortRange(maxSrcPortRange); - - int minDstPortRange = (json.get(MIN_DST_PORT_RANGE)).asInt(); - resultBuilder.setMinDstPortRange(minDstPortRange); - - int maxDstPortRange = (json.get(MAX_DST_PORT_RANGE)).asInt(); - resultBuilder.setMaxDstPortRange(maxDstPortRange); - - String srcIpPrefix = (json.get(SRC_IP_PREFIX)).asText(); - if (!srcIpPrefix.isEmpty()) { - resultBuilder.setSrcIpPrefix(IpPrefix.valueOf(srcIpPrefix)); - } - - String dstIpPrefix = (json.get(DST_IP_PREFIX)).asText(); - if (!dstIpPrefix.isEmpty()) { - resultBuilder.setDstIpPrefix(IpPrefix.valueOf(dstIpPrefix)); - } - - String srcPort = json.get(SRC_PORT) != null ? (json.get(SRC_PORT)).asText() : ""; - if (!srcPort.isEmpty()) { - resultBuilder.setSrcPort(VirtualPortId.portId(srcPort)); - } - - String dstPort = json.get(DST_PORT) != null ? (json.get(DST_PORT)).asText() : ""; - if (!dstPort.isEmpty()) { - resultBuilder.setDstPort(VirtualPortId.portId(dstPort)); - } - return resultBuilder.build(); - } - - @Override - public ObjectNode encode(FlowClassifier flowClassifier, CodecContext context) { - checkNotNull(flowClassifier, "flowClassifier cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put(FLOW_CLASSIFIER_ID, flowClassifier.flowClassifierId().toString()) - .put(TENANT_ID, flowClassifier.tenantId().toString()) - .put(NAME, flowClassifier.name()) - .put(DESCRIPTION, flowClassifier.description()) - .put(ETHER_TYPE, flowClassifier.etherType()) - .put(PROTOCOL, flowClassifier.protocol()) - .put(MIN_SRC_PORT_RANGE, flowClassifier.minSrcPortRange()) - .put(MAX_SRC_PORT_RANGE, flowClassifier.maxSrcPortRange()) - .put(MIN_DST_PORT_RANGE, flowClassifier.minDstPortRange()) - .put(MAX_DST_PORT_RANGE, flowClassifier.maxDstPortRange()) - .put(SRC_IP_PREFIX, flowClassifier.srcIpPrefix().toString()) - .put(DST_IP_PREFIX, flowClassifier.dstIpPrefix().toString()) - .put(SRC_PORT, flowClassifier.srcPort().toString()) - .put(DST_PORT, flowClassifier.dstPort().toString()); - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java deleted file mode 100644 index 815a0d02..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.HostRoute; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Subnet HostRoute codec. - */ -public final class HostRoutesCodec extends JsonCodec<HostRoute> { - - @Override - public ObjectNode encode(HostRoute hostRoute, CodecContext context) { - checkNotNull(hostRoute, "HostRoute cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("nexthop", hostRoute.nexthop().toString()) - .put("destination", hostRoute.destination().toString()); - return result; - } - -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java deleted file mode 100644 index 1e9cf009..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.onlab.util.Tools.nullIsIllegal; - -import java.util.List; -import java.util.UUID; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.DefaultPortChain; -import org.onosproject.vtnrsc.FlowClassifierId; -import org.onosproject.vtnrsc.PortChain; -import org.onosproject.vtnrsc.PortChainId; -import org.onosproject.vtnrsc.PortPairGroupId; - -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.Lists; - -/** - * Port chain JSON codec. - */ -public final class PortChainCodec extends JsonCodec<PortChain> { - - private static final String ID = "id"; - private static final String TENANT_ID = "tenant_id"; - private static final String NAME = "name"; - private static final String DESCRIPTION = "description"; - private static final String PORT_PAIR_GROUPS = "port_pair_groups"; - private static final String FLOW_CLASSIFIERS = "flow_classifiers"; - private static final String MISSING_MEMBER_MESSAGE = - " member is required in PortChain"; - - @Override - public PortChain decode(ObjectNode json, CodecContext context) { - if (json == null || !json.isObject()) { - return null; - } - - PortChain.Builder resultBuilder = new DefaultPortChain.Builder(); - - String id = nullIsIllegal(json.get(ID), - ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setId(PortChainId.of(id)); - - String tenantId = nullIsIllegal(json.get(TENANT_ID), - TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setTenantId(TenantId.tenantId(tenantId)); - - String name = nullIsIllegal(json.get(NAME), - NAME + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setName(name); - - String description = nullIsIllegal(json.get(DESCRIPTION), - DESCRIPTION + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setDescription(description); - - ArrayNode arrayNode = (ArrayNode) json.path(PORT_PAIR_GROUPS); - if (arrayNode != null) { - List<PortPairGroupId> list = Lists.newArrayList(); - arrayNode.forEach(i -> list.add(PortPairGroupId.of(i.asText()))); - resultBuilder.setPortPairGroups(list); - } - - arrayNode = (ArrayNode) json.path(FLOW_CLASSIFIERS); - if (arrayNode != null) { - List<FlowClassifierId> list = Lists.newArrayList(); - arrayNode.forEach(i -> list.add(FlowClassifierId.of(UUID.fromString(i.asText())))); - resultBuilder.setFlowClassifiers(list); - } - - return resultBuilder.build(); - } - - @Override - public ObjectNode encode(PortChain portChain, CodecContext context) { - checkNotNull(portChain, "port pair cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put(ID, portChain.portChainId().toString()) - .put(TENANT_ID, portChain.tenantId().toString()) - .put(NAME, portChain.name()) - .put(DESCRIPTION, portChain.description()) - .put(PORT_PAIR_GROUPS, portChain.portPairGroups().toString()) - .put(FLOW_CLASSIFIERS, portChain.flowClassifiers().toString()); - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java deleted file mode 100644 index 691536f4..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.onlab.util.Tools.nullIsIllegal; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.core.CoreService; -import org.onosproject.vtnrsc.DefaultPortPair; -import org.onosproject.vtnrsc.PortPair; -import org.onosproject.vtnrsc.PortPairId; -import org.onosproject.vtnrsc.TenantId; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Port Pair JSON codec. - */ -public final class PortPairCodec extends JsonCodec<PortPair> { - - private static final String ID = "id"; - private static final String TENANT_ID = "tenant_id"; - private static final String NAME = "name"; - private static final String DESCRIPTION = "description"; - private static final String INGRESS = "ingress"; - private static final String EGRESS = "egress"; - private static final String MISSING_MEMBER_MESSAGE = - " member is required in PortPair"; - - @Override - public PortPair decode(ObjectNode json, CodecContext context) { - if (json == null || !json.isObject()) { - return null; - } - - PortPair.Builder resultBuilder = new DefaultPortPair.Builder(); - - CoreService coreService = context.getService(CoreService.class); - - String id = nullIsIllegal(json.get(ID), - ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setId(PortPairId.of(id)); - - String tenantId = nullIsIllegal(json.get(TENANT_ID), - TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setTenantId(TenantId.tenantId(tenantId)); - - String name = nullIsIllegal(json.get(NAME), - NAME + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setName(name); - - String description = nullIsIllegal(json.get(DESCRIPTION), - DESCRIPTION + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setDescription(description); - - String ingressPort = nullIsIllegal(json.get(INGRESS), - INGRESS + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setIngress(ingressPort); - - String egressPort = nullIsIllegal(json.get(EGRESS), - EGRESS + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setEgress(egressPort); - - return resultBuilder.build(); - } - - @Override - public ObjectNode encode(PortPair portPair, CodecContext context) { - checkNotNull(portPair, "port pair cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put(ID, portPair.portPairId().toString()) - .put(TENANT_ID, portPair.tenantId().toString()) - .put(NAME, portPair.name()) - .put(DESCRIPTION, portPair.description()) - .put(INGRESS, portPair.ingress()) - .put(EGRESS, portPair.egress()); - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java deleted file mode 100644 index b5ae266b..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.onlab.util.Tools.nullIsIllegal; - -import java.util.List; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.core.CoreService; -import org.onosproject.vtnrsc.DefaultPortPairGroup; -import org.onosproject.vtnrsc.PortPairGroup; -import org.onosproject.vtnrsc.PortPairGroupId; -import org.onosproject.vtnrsc.PortPairId; -import org.onosproject.vtnrsc.TenantId; - -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.Lists; - -/** - * Port Pair Group JSON codec. - */ -public final class PortPairGroupCodec extends JsonCodec<PortPairGroup> { - - private static final String ID = "id"; - private static final String TENANT_ID = "tenant_id"; - private static final String NAME = "name"; - private static final String DESCRIPTION = "description"; - private static final String PORT_PAIRS = "port_pairs"; - private static final String MISSING_MEMBER_MESSAGE = - " member is required in PortPairGroup"; - - @Override - public PortPairGroup decode(ObjectNode json, CodecContext context) { - if (json == null || !json.isObject()) { - return null; - } - - PortPairGroup.Builder resultBuilder = new DefaultPortPairGroup.Builder(); - - CoreService coreService = context.getService(CoreService.class); - - String id = nullIsIllegal(json.get(ID), - ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setId(PortPairGroupId.of(id)); - - String tenantId = nullIsIllegal(json.get(TENANT_ID), - TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setTenantId(TenantId.tenantId(tenantId)); - - String name = nullIsIllegal(json.get(NAME), - NAME + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setName(name); - - String description = nullIsIllegal(json.get(DESCRIPTION), - DESCRIPTION + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setDescription(description); - - List<PortPairId> list = Lists.newArrayList(); - ArrayNode arrayNode = (ArrayNode) json.path(PORT_PAIRS); - arrayNode.forEach(i -> list.add(PortPairId.of(i.asText()))); - resultBuilder.setPortPairs(list); - - return resultBuilder.build(); - } - - @Override - public ObjectNode encode(PortPairGroup portPairGroup, CodecContext context) { - checkNotNull(portPairGroup, "port pair group cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put(ID, portPairGroup.portPairGroupId().toString()) - .put(TENANT_ID, portPairGroup.tenantId().toString()) - .put(NAME, portPairGroup.name()) - .put(DESCRIPTION, portPairGroup.description()) - .put(PORT_PAIRS, portPairGroup.portPairs().toString()); - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java deleted file mode 100644 index 61f7e955..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Iterator; -import java.util.List; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.Router; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Router JSON codec. - */ -public class RouterCodec extends JsonCodec<Router> { - @Override - public ObjectNode encode(Router router, CodecContext context) { - checkNotNull(router, "router cannot be null"); - ObjectNode result = context - .mapper() - .createObjectNode() - .put("id", router.id().routerId()) - .put("status", router.status().toString()) - .put("name", router.name().toString()) - .put("admin_state_up", router.adminStateUp()) - .put("tenant_id", router.tenantId().toString()) - .put("routes", - router.routes() == null ? null : router.routes() - .toString()); - result.set("external_gateway_info", - router.externalGatewayInfo() == null ? null - : new RouterGatewayInfoCodec() - .encode(router.externalGatewayInfo(), context)); - - return result; - } - - public ObjectNode extracFields(Router router, CodecContext context, - List<String> fields) { - checkNotNull(router, "router cannot be null"); - ObjectNode result = context.mapper().createObjectNode(); - Iterator<String> i = fields.iterator(); - while (i.hasNext()) { - String s = i.next(); - if (s.equals("id")) { - result.put("id", router.id().routerId()); - } - if (s.equals("status")) { - result.put("status", router.status().toString()); - } - if (s.equals("name")) { - result.put("name", router.name().toString()); - } - if (s.equals("admin_state_up")) { - result.put("admin_state_up", router.adminStateUp()); - } - if (s.equals("tenant_id")) { - result.put("tenant_id", router.tenantId().toString()); - } - if (s.equals("routes")) { - result.put("routes", router.routes() == null ? null : router - .routes().toString()); - } - if (s.equals("external_gateway_info")) { - result.set("external_gateway_info", - router.externalGatewayInfo() == null ? null - : new RouterGatewayInfoCodec() - .encode(router.externalGatewayInfo(), - context)); - } - } - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterGatewayInfoCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterGatewayInfoCodec.java deleted file mode 100644 index cb9fb67d..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterGatewayInfoCodec.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.RouterGateway; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Subnet Router Gateway Info codec. - */ -public class RouterGatewayInfoCodec extends JsonCodec<RouterGateway> { - @Override - public ObjectNode encode(RouterGateway routerGateway, CodecContext context) { - checkNotNull(routerGateway, "routerGateway cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("network_id", routerGateway.networkId().toString()); - result.set("external_fixed_ips", new FixedIpCodec() - .encode(routerGateway.externalFixedIps(), context)); - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java deleted file mode 100644 index 18ed61ba..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.SecurityGroup; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Virtualport SecurityGroup codec. - */ -public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> { - - @Override - public ObjectNode encode(SecurityGroup securGroup, CodecContext context) { - checkNotNull(securGroup, "SecurityGroup cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("security_group", securGroup.securityGroup()); - return result; - } - -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java deleted file mode 100644 index e3d92fea..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.Subnet; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Subnet JSON codec. - */ -public final class SubnetCodec extends JsonCodec<Subnet> { - @Override - public ObjectNode encode(Subnet subnet, CodecContext context) { - checkNotNull(subnet, "Subnet cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("id", subnet.id().toString()) - .put("gateway_ip", subnet.gatewayIp().toString()) - .put("network_id", subnet.networkId().toString()) - .put("name", subnet.subnetName()) - .put("ip_version", subnet.ipVersion().toString()) - .put("cidr", subnet.cidr().toString()) - .put("shared", subnet.shared()) - .put("enabled_dchp", subnet.dhcpEnabled()) - .put("tenant_id", subnet.tenantId().toString()) - .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null - : subnet.ipV6AddressMode().toString()) - .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null - : subnet.ipV6RaMode().toString()); - result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet - .allocationPools(), context)); - result.set("host_routes", - new HostRoutesCodec().encode(subnet.hostRoutes(), context)); - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java deleted file mode 100644 index 8adba034..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.TenantNetwork; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * TenantNetwork JSON codec. - */ -public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> { - - @Override - public ObjectNode encode(TenantNetwork network, CodecContext context) { - checkNotNull(network, "Network cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("id", network.id().toString()) - .put("name", network.name()) - .put("admin_state_up", network.adminStateUp()) - .put("status", "" + network.state()) - .put("shared", network.shared()) - .put("tenant_id", network.tenantId().toString()) - .put("router:external", network.routerExternal()) - .put("provider:network_type", "" + network.type()) - .put("provider:physical_network", network.physicalNetwork().toString()) - .put("provider:segmentation_id", network.segmentationId().toString()); - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java deleted file mode 100644 index 5cea5327..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.VirtualPort; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * VirtualPort JSON codec. - */ -public final class VirtualPortCodec extends JsonCodec<VirtualPort> { - @Override - public ObjectNode encode(VirtualPort vPort, CodecContext context) { - checkNotNull(vPort, "VPort cannot be null"); - ObjectNode result = context - .mapper() - .createObjectNode() - .put("id", vPort.portId().toString()) - .put("network_id", vPort.networkId().toString()) - .put("admin_state_up", vPort.adminStateUp()) - .put("name", vPort.name()) - .put("status", vPort.state().toString()) - .put("mac_address", vPort.macAddress().toString()) - .put("tenant_id", vPort.tenantId().toString()) - .put("device_id", vPort.deviceId().toString()) - .put("device_owner", vPort.deviceOwner()) - .put("binding:vnic_type", vPort.bindingVnicType()) - .put("binding:Vif_type", vPort.bindingVifType()) - .put("binding:host_id", vPort.bindingHostId().toString()) - .put("binding:vif_details", vPort.bindingVifDetails()); - result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode( - vPort.allowedAddressPairs(), context)); - result.set("fixed_ips", new FixedIpCodec().encode( - vPort.fixedIps(), context)); - result.set("security_groups", new SecurityGroupCodec().encode( - vPort.securityGroups(), context)); - return result; - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java deleted file mode 100644 index e2defe59..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnweb.web; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.onosproject.codec.CodecService; -import org.onosproject.vtnrsc.FlowClassifier; -import org.onosproject.vtnrsc.PortChain; -import org.onosproject.vtnrsc.PortPair; -import org.onosproject.vtnrsc.PortPairGroup; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Implementation of the JSON codec brokering service for VTN app. - */ -@Component(immediate = true) -public class VtnCodecRegistrator { - - private static Logger log = LoggerFactory.getLogger(VtnCodecRegistrator.class); - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected CodecService codecService; - - @Activate - public void activate() { - codecService.registerCodec(PortPair.class, new PortPairCodec()); - codecService.registerCodec(PortPairGroup.class, new PortPairGroupCodec()); - codecService.registerCodec(FlowClassifier.class, new FlowClassifierCodec()); - codecService.registerCodec(PortChain.class, new PortChainCodec()); - - log.info("Started"); - } - - @Deactivate - public void deactivate() { - log.info("Stopped"); - } -} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java deleted file mode 100644 index 3a609435..00000000 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Codecs for virtual tenant objects. - */ -package org.onosproject.vtnweb.web; |