ONOS-2622
Fix error of north app and update onos-app-vtnrsc package

Change-Id: I375002ff26d2ab3ada879a92a1d47bcdb8980054
diff --git a/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
new file mode 100644
index 0000000..4a6c321
--- /dev/null
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
@@ -0,0 +1,40 @@
+/*

+ * 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.vtnrsc.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/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
new file mode 100644
index 0000000..6c5cc2e
--- /dev/null
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
@@ -0,0 +1,40 @@
+/*

+ * 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.vtnrsc.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/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
new file mode 100644
index 0000000..a69b821
--- /dev/null
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
@@ -0,0 +1,40 @@
+/*

+ * 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.vtnrsc.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/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
new file mode 100644
index 0000000..ba977a0
--- /dev/null
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
@@ -0,0 +1,40 @@
+/*

+ * 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.vtnrsc.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/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
new file mode 100644
index 0000000..83bab6b
--- /dev/null
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
@@ -0,0 +1,39 @@
+/*

+ * 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.vtnrsc.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/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
new file mode 100644
index 0000000..8f0fd2e
--- /dev/null
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
@@ -0,0 +1,49 @@
+/*

+ * 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.vtnrsc.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("gate_ip", subnet.gatewayIp().toString())

+                .put("network_id", subnet.networkId().toString())

+                .put("name", subnet.subnetName().toString())

+                .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());

+        result.set("alloction_pools", new AllocationPoolsCodec().encode(subnet

+                .allocationPools(), context));

+        result.set("host_routes",

+                   new HostRoutesCodec().encode(subnet.hostRoutes(), context));

+        return result;

+    }

+}

diff --git a/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
new file mode 100644
index 0000000..07ae9f8
--- /dev/null
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
@@ -0,0 +1,47 @@
+/*

+ * 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.vtnrsc.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().toString())

+                .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/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
new file mode 100644
index 0000000..aa3c0c7
--- /dev/null
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
@@ -0,0 +1,57 @@
+/*

+ * 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.vtnrsc.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().toString())

+                .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().toString())

+                .put("binding:vnic_type", vPort.bindingVnicType().toString())

+                .put("binding:Vif_type", vPort.bindingVifType().toString())

+                .put("binding:host_id", vPort.bindingHostId().toString())

+                .put("binding:vif_details", vPort.bindingVifDetails().toString());

+        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;

+    }

+}