description "the port uuid holding the router's gateway address.";
type yang:uuid;
}
- leaf-list routes {
+ list routes {
description "list of routes for this router.";
- type string;
+ leaf destination {
+ description "Specifies a destination in CIDR format";
+ type inet:ip-prefix;
+ }
+ leaf nexthop {
+ type inet:ip-address;
+ }
}
leaf router-status {
description "Contains the Router status.";
--- /dev/null
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.spi;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class NeutronRoute implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Network API v2.0 Reference for description of
+ // annotated attributes
+
+ @XmlElement(name = "destination")
+ String destination;
+
+ @XmlElement(name = "nexthop")
+ String nextHop;
+
+ /**
+ * HostRoute constructor
+ */
+ public NeutronRoute() { }
+
+ public String getDestination() {
+ return destination;
+ }
+
+ public void setDestination(String destination) {
+ this.destination = destination;
+ }
+
+ public String getNextHop() {
+ return nextHop;
+ }
+
+ public void setNextHop(String nextHop) {
+ this.nextHop = nextHop;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronRoute [" +
+ "destination=" + destination +
+ ", nextHop=" + nextHop + "]";
+ }
+
+}
String gatewayPortId;
@XmlElement (name = "routes")
- List<String> routes;
+ List<NeutronRoute> routes;
/* Holds a map of OpenStackRouterInterfaces by subnet UUID
* used for internal mapping to DOVE
this.gatewayPortId = gatewayPortId;
}
- public List<String> getRoutes() {
+ public List<NeutronRoute> getRoutes() {
return routes;
}
- public void setRoutes(List<String> routes) {
+ public void setRoutes(List<NeutronRoute> routes) {
this.routes = routes;
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
+@Deprecated
public class NeutronSubnet_HostRoute implements Serializable {
private static final long serialVersionUID = 1L;
"\"external_gateway_info\": {\"network_id\": \"e9330b1f-a2ef-4160-a991-169e56ab17f6\" }, " +
"\"distributed\": false , " +
"\"gw_port_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17127\", " +
- "\"routes\": [ \"3b80198d-4f7b-4f77-9ef5-774d54e17126\" ] }";
+ "\"routes\": [ { \"destination\":\"10.0.0.0/24\",\"nexthop\":\"1.1.1.1\" } ] }";
@Test
public void test_NeutronRouter_JAXB() {
NeutronRouter_sourceJson);
NeutronRouter_NetworkReference external_gateway_info = testObject.getExternalGatewayInfo();
- List<String> routes = testObject.getRoutes();
+ List<NeutronRoute> routes = testObject.getRoutes();
Assert.assertEquals("NeutronRouter JAXB Test 1: Testing router_uuid failed",
"e9330b1f-a2ef-4160-a991-169e56ab17f5", testObject.getID());
Assert.assertEquals("NeutronRouter JAXB Test 9.1: Testing routes failed", 1, routes.size());
Assert.assertEquals("NeutronRouter JAXB Test 9.2: Testing routes failed",
- "3b80198d-4f7b-4f77-9ef5-774d54e17126", routes.get(0));
+ "10.0.0.0/24", routes.get(0).getDestination());
} catch (Exception e) {
Assert.fail("Tests failed");
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.neutron.spi.INeutronRouterCRUD;
+import org.opendaylight.neutron.spi.NeutronRoute;
import org.opendaylight.neutron.spi.Neutron_IPs;
import org.opendaylight.neutron.spi.NeutronRouter;
import org.opendaylight.neutron.spi.NeutronRouter_Interface;
import org.opendaylight.neutron.spi.NeutronRouter_NetworkReference;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.RoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.RouterBuilder;
routerBuilder.setAdminStateUp(router.getAdminStateUp());
routerBuilder.setDistributed(router.getDistributed());
if (router.getRoutes() != null) {
- List<String> routes = new ArrayList<String>();
- for (String route : router.getRoutes()) {
- routes.add(route);
+ List<Routes> routes = new ArrayList<Routes>();
+ for (NeutronRoute route : router.getRoutes()) {
+ RoutesBuilder routeBuilder = new RoutesBuilder();
+ routeBuilder.setDestination(new IpPrefix(route.getDestination().toCharArray()));
+ routeBuilder.setNexthop(new IpAddress(route.getNextHop().toCharArray()));
+ routes.add(routeBuilder.build());
}
routerBuilder.setRoutes(routes);
}
result.setGatewayPortId(String.valueOf(router.getGatewayPortId().getValue()));
}
if (router.getRoutes() != null) {
- List<String> routes = new ArrayList<String>();
- for (String route : router.getRoutes()) {
- routes.add(route);
+ List<NeutronRoute> routes = new ArrayList<NeutronRoute>();
+ for (Routes route : router.getRoutes()) {
+ NeutronRoute routerRoute = new NeutronRoute();
+ routerRoute.setDestination(String.valueOf(route.getDestination().getValue()));
+ routerRoute.setNextHop(String.valueOf(route.getNexthop().getValue()));
+ routes.add(routerRoute);
}
result.setRoutes(routes);
}