Skip to content

Commit

Permalink
Merge pull request #200 from n-r-anderson/master
Browse files Browse the repository at this point in the history
Fix update() for Port (AllowedAddressPair) and Router (HostRoutes) to se...
  • Loading branch information
gondor committed Jan 12, 2015
2 parents 02d4ead + 1ac8507 commit e523f63
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public Port create(Port port) {
public Port update(Port port) {
checkNotNull(port);
checkNotNull(port.getId());
return put(NeutronPort.class, uri("/ports/%s", getAndClearIdentifier(port))).entity(port).execute();
Port p = port.toBuilder().networkId(null).state(null).tenantId(null).macAddress(null).build();
return put(NeutronPort.class, uri("/ports/%s", getAndClearIdentifier(p))).entity(p).execute();
}

private String getAndClearIdentifier(Port port) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.openstack4j.model.network.AttachInterfaceType;
import org.openstack4j.model.network.Router;
import org.openstack4j.model.network.RouterInterface;
import org.openstack4j.model.network.builder.RouterBuilder;
import org.openstack4j.openstack.networking.domain.AddRouterInterfaceAction;
import org.openstack4j.openstack.networking.domain.NeutronHostRoute;
import org.openstack4j.openstack.networking.domain.NeutronRouter;
import org.openstack4j.openstack.networking.domain.NeutronRouter.Routers;
import org.openstack4j.openstack.networking.domain.NeutronRouterInterface;
Expand Down Expand Up @@ -73,8 +75,18 @@ public Router create(Router router) {
public Router update(Router router) {
checkNotNull(router);
checkNotNull(router.getId());

RouterBuilder rb = NeutronRouter.builder().name(router.getName()).adminStateUp(router.isAdminStateUp()).externalGateway(router.getExternalGatewayInfo());
List<NeutronHostRoute> routes = (List<NeutronHostRoute>) router.getRoutes();

if (routes != null) {
for (NeutronHostRoute route : routes) {
rb.route(route.getDestination(), route.getNexthop());
}
}

return put(NeutronRouter.class, uri("/routers/%s", router.getId()))
.entity(NeutronRouter.builder().name(router.getName()).adminStateUp(router.isAdminStateUp()).externalGateway(router.getExternalGatewayInfo()).build())
.entity(rb.build())
.execute();
}

Expand Down

0 comments on commit e523f63

Please sign in to comment.