bringing src to commit tag 65d551b50e782b0c1ea76c1a9ed1c5a801a5a7e4 91/1891/1
authorAshlee Young <ashlee@onosfw.com>
Tue, 22 Sep 2015 19:49:09 +0000 (12:49 -0700)
committerAshlee Young <ashlee@onosfw.com>
Tue, 22 Sep 2015 19:49:09 +0000 (12:49 -0700)
Change-Id: Ib2da78962eaef856f418636c31b0f5c84286244f

559 files changed:
framework/src/onos/apps/aaa/pom.xml
framework/src/onos/apps/acl/pom.xml
framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java
framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java [new file with mode: 0644]
framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java [new file with mode: 0644]
framework/src/onos/apps/bgprouter/app.xml
framework/src/onos/apps/bgprouter/features.xml
framework/src/onos/apps/bgprouter/pom.xml
framework/src/onos/apps/cip/pom.xml
framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java [new file with mode: 0644]
framework/src/onos/apps/cordfabric/pom.xml
framework/src/onos/apps/cordvtn/pom.xml [new file with mode: 0644]
framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java [new file with mode: 0644]
framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java [new file with mode: 0644]
framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java [new file with mode: 0644]
framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java [new file with mode: 0644]
framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java [new file with mode: 0644]
framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java [new file with mode: 0644]
framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java [new file with mode: 0644]
framework/src/onos/apps/demo/cord-gui/pom.xml
framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java
framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh
framework/src/onos/apps/demo/cord-gui/src/scripts/run.me
framework/src/onos/apps/dhcp/pom.xml
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java [new file with mode: 0644]
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java [new file with mode: 0644]
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java [new file with mode: 0644]
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java
framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java [new file with mode: 0644]
framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html
framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java
framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java
framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json
framework/src/onos/apps/flowanalyzer/pom.xml
framework/src/onos/apps/fwd/pom.xml
framework/src/onos/apps/metrics/pom.xml
framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java
framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java
framework/src/onos/apps/mobility/pom.xml
framework/src/onos/apps/olt/pom.xml
framework/src/onos/apps/optical/pom.xml
framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java
framework/src/onos/apps/pcep-api/pom.xml
framework/src/onos/apps/pom.xml
framework/src/onos/apps/proxyarp/pom.xml
framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
framework/src/onos/apps/reactive-routing/pom.xml
framework/src/onos/apps/routing-api/pom.xml
framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java
framework/src/onos/apps/routing/pom.xml
framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
framework/src/onos/apps/sdnip/pom.xml
framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
framework/src/onos/apps/segmentrouting/pom.xml
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java
framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java
framework/src/onos/apps/test/demo/pom.xml
framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java
framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
framework/src/onos/apps/test/distributed-primitives/pom.xml
framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java
framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java
framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java
framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java
framework/src/onos/apps/test/election/pom.xml
framework/src/onos/apps/test/intent-perf/pom.xml
framework/src/onos/apps/test/messaging-perf/pom.xml
framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java
framework/src/onos/apps/test/pom.xml
framework/src/onos/apps/virtualbng/pom.xml
framework/src/onos/apps/vtn/pom.xml
framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java
framework/src/onos/apps/vtnrsc/pom.xml
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java [new file with mode: 0644]
framework/src/onos/apps/vtnweb/pom.xml
framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
framework/src/onos/apps/xos-integration/pom.xml
framework/src/onos/cli/pom.xml
framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java
framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java
framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java
framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java
framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java [new file with mode: 0644]
framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java [new file with mode: 0644]
framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
framework/src/onos/core/api/pom.xml
framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java
framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java
framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java
framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java
framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java
framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java
framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java
framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java
framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java
framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java
framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java
framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java
framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java
framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java
framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java
framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java
framework/src/onos/core/common/pom.xml
framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java
framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java
framework/src/onos/core/net/pom.xml
framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java
framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java
framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java
framework/src/onos/core/pom.xml
framework/src/onos/core/security/pom.xml
framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java
framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java
framework/src/onos/core/security/src/main/java/org/onosproject/security/store/package-info.java [new file with mode: 0644]
framework/src/onos/core/store/dist/pom.xml
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/proxyarp/impl/package-info.java [new file with mode: 0644]
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java
framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java
framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java
framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java
framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java
framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java
framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java
framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java
framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java
framework/src/onos/core/store/pom.xml
framework/src/onos/core/store/serializers/pom.xml
framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java
framework/src/onos/docs/external.xml
framework/src/onos/docs/internal-apis
framework/src/onos/docs/internal-core
framework/src/onos/docs/internal-incubator
framework/src/onos/docs/internal.xml
framework/src/onos/drivers/pom.xml
framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java
framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CorsaPipeline.java
framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA1Pipeline.java
framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java
framework/src/onos/features/pom.xml
framework/src/onos/incubator/api/pom.xml
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ConfigException.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ExtraSubjectFactories.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/TunnelPrimitive.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/DefaultLabelResource.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResource.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceAdminService.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceDelegate.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceEvent.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceListener.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourcePool.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProvider.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderRegistry.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderService.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceRequest.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceService.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceStore.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelStatistics.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java
framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStatistics.java
framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/config/basics/OpticalPortConfigTest.java
framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/DefaultLabelResourceTest.java
framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourcePoolTest.java
framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourceRequestTest.java
framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java
framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java
framework/src/onos/incubator/net/pom.xml
framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/package-info.java [new file with mode: 0644]
framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/package-info.java [new file with mode: 0644]
framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/package-info.java [new file with mode: 0644]
framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java
framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/intf/impl/InterfaceManagerTest.java [new file with mode: 0644]
framework/src/onos/incubator/pom.xml
framework/src/onos/incubator/store/pom.xml
framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/package-info.java [new file with mode: 0644]
framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java
framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/LabelResourceMessageSubjects.java
framework/src/onos/openflow/api/pom.xml
framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java
framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java
framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java
framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java
framework/src/onos/openflow/ctl/pom.xml
framework/src/onos/openflow/pom.xml
framework/src/onos/ovsdb/api/pom.xml
framework/src/onos/ovsdb/ctl/pom.xml
framework/src/onos/ovsdb/pom.xml
framework/src/onos/ovsdb/rfc/pom.xml
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Port.java
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/package-info.java [new file with mode: 0644]
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java
framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/package-info.java [new file with mode: 0644]
framework/src/onos/pcep/api/pom.xml
framework/src/onos/pcep/ctl/pom.xml
framework/src/onos/pcep/pcepio/pom.xml
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java
framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java
framework/src/onos/pcep/pom.xml
framework/src/onos/pom.xml
framework/src/onos/providers/host/pom.xml
framework/src/onos/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java
framework/src/onos/providers/lldp/pom.xml
framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/DiscoveryContext.java [new file with mode: 0644]
framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java
framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java
framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java
framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/SuppressionRulesTest.java
framework/src/onos/providers/netconf/app/features.xml
framework/src/onos/providers/netconf/app/pom.xml
framework/src/onos/providers/netconf/device/pom.xml
framework/src/onos/providers/netconf/flow/pom.xml
framework/src/onos/providers/netconf/pom.xml
framework/src/onos/providers/null/pom.xml
framework/src/onos/providers/openflow/app/features.xml
framework/src/onos/providers/openflow/app/pom.xml
framework/src/onos/providers/openflow/device/pom.xml
framework/src/onos/providers/openflow/flow/pom.xml
framework/src/onos/providers/openflow/group/pom.xml
framework/src/onos/providers/openflow/group/src/test/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProviderTest.java
framework/src/onos/providers/openflow/meter/pom.xml
framework/src/onos/providers/openflow/packet/pom.xml
framework/src/onos/providers/openflow/pom.xml
framework/src/onos/providers/ovsdb/app/pom.xml
framework/src/onos/providers/ovsdb/device/pom.xml
framework/src/onos/providers/ovsdb/host/pom.xml
framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java
framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java
framework/src/onos/providers/ovsdb/pom.xml
framework/src/onos/providers/ovsdb/tunnel/pom.xml
framework/src/onos/providers/pcep/app/features.xml
framework/src/onos/providers/pcep/app/pom.xml
framework/src/onos/providers/pcep/pom.xml
framework/src/onos/providers/pcep/topology/pom.xml
framework/src/onos/providers/pcep/tunnel/pom.xml
framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java
framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java
framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java
framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelServiceAdapter.java
framework/src/onos/providers/pom.xml
framework/src/onos/tools/build/envDefaults
framework/src/onos/tools/build/onos-package
framework/src/onos/tools/build/onosUploadBits.py
framework/src/onos/tools/package/archetypes/api/pom.xml
framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml
framework/src/onos/tools/package/archetypes/bundle/pom.xml
framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
framework/src/onos/tools/package/archetypes/cli/pom.xml
framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/pom.xml
framework/src/onos/tools/package/archetypes/pom.xml
framework/src/onos/tools/package/archetypes/ui/pom.xml
framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml
framework/src/onos/tools/package/branding/pom.xml
framework/src/onos/tools/package/deb/control [new file with mode: 0644]
framework/src/onos/tools/package/deb/copyright [new file with mode: 0644]
framework/src/onos/tools/package/deb/postinst [new file with mode: 0755]
framework/src/onos/tools/package/deb/postrm [new file with mode: 0755]
framework/src/onos/tools/package/deb/prerm [new file with mode: 0755]
framework/src/onos/tools/package/init/onos.conf [new file with mode: 0644]
framework/src/onos/tools/package/rpm/onos.spec [new file with mode: 0644]
framework/src/onos/tools/test/bin/onos-archetypes-test
framework/src/onos/tools/test/bin/onos-check-intent
framework/src/onos/tools/test/bin/onos-check-logs
framework/src/onos/tools/test/bin/onos-install
framework/src/onos/tools/test/bin/onos-start-network
framework/src/onos/tools/test/bin/onos-topo-cfg
framework/src/onos/tools/test/bin/onos-uninstall
framework/src/onos/tools/test/bin/stc
framework/src/onos/tools/test/cells/office
framework/src/onos/tools/test/configs/office-dhcp.json [new file with mode: 0644]
framework/src/onos/tools/test/scenarios/bin/curl-with-retry [new file with mode: 0755]
framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py [new file with mode: 0755]
framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py [new file with mode: 0755]
framework/src/onos/tools/test/scenarios/bin/query-cluster.py [new file with mode: 0755]
framework/src/onos/tools/test/scenarios/bin/query-topo.py [new file with mode: 0755]
framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py [new file with mode: 0755]
framework/src/onos/tools/test/scenarios/net-link-down-up.xml
framework/src/onos/tools/test/scenarios/net-pingall.xml
framework/src/onos/tools/test/scenarios/net-rest.xml
framework/src/onos/tools/test/scenarios/net-setup.xml
framework/src/onos/tools/test/scenarios/net-smoke.xml
framework/src/onos/tools/test/scenarios/net-topo.xml [new file with mode: 0644]
framework/src/onos/tools/test/scenarios/prerequisites.xml
framework/src/onos/tools/test/topos/onos.py
framework/src/onos/tools/test/topos/opticalUtils.py
framework/src/onos/utils/jdvue/bin/jdvue
framework/src/onos/utils/jdvue/pom.xml
framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Catalog.java
framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Dependency.java
framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java
framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyViewer.java
framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaEntity.java
framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaPackage.java
framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaSource.java
framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/CatalogTest.java
framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyCycleTest.java
framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyTest.java
framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyViewerTest.java
framework/src/onos/utils/jnc/pom.xml
framework/src/onos/utils/junit/pom.xml
framework/src/onos/utils/misc/pom.xml
framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAOrganism.java
framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAPopulation.java
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IPv4.java
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MPLS.java
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java [new file with mode: 0755]
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java [new file with mode: 0644]
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java [new file with mode: 0644]
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java [new file with mode: 0644]
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHello.java [new file with mode: 0644]
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHelloOption.java [new file with mode: 0644]
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMJoinPrune.java [new file with mode: 0644]
framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/package-info.java [new file with mode: 0755]
framework/src/onos/utils/misc/src/test/java/org/onlab/packet/PIMTest.java [new file with mode: 0644]
framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java
framework/src/onos/utils/netty/pom.xml
framework/src/onos/utils/nio/pom.xml
framework/src/onos/utils/osgi/pom.xml
framework/src/onos/utils/pom.xml
framework/src/onos/utils/rest/pom.xml
framework/src/onos/utils/stc/bin/stc
framework/src/onos/utils/stc/pom.xml
framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java
framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java
framework/src/onos/utils/stc/src/main/java/org/onlab/stc/ScenarioStore.java
framework/src/onos/utils/thirdparty/pom.xml
framework/src/onos/web/api/pom.xml
framework/src/onos/web/gui/pom.xml
framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TunnelViewMessageHandler.java
framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java [new file with mode: 0644]
framework/src/onos/web/pom.xml

index 6f85075..78fd4a6 100644 (file)
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 20f784f..54dee43 100644 (file)
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
     <artifactId>onos-app-acl</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <description>ONOS ACL application</description>
     <url>http://onosproject.org</url>
 
     <properties>
-        <onos.version>1.3.0-SNAPSHOT</onos.version>
+        <onos.version>1.4.0-SNAPSHOT</onos.version>
         <onos.app.name>org.onosproject.acl</onos.app.name>
         <onos.app.origin>DLUT</onos.app.origin>
         <web.context>/onos/acl</web.context>
index 6d909a9..5c8a93c 100644 (file)
@@ -234,7 +234,7 @@ public class DistributedAclStore extends AbstractStore implements AclStore {
         ruleToDevice.computeIf(ruleId,
                                deviceIdSet -> (deviceIdSet == null || !deviceIdSet.contains(deviceId)),
                                (id, deviceIdSet) -> {
-                                   Set<DeviceId> newSet = new HashSet<DeviceId>();
+                                   Set<DeviceId> newSet = new HashSet<>();
                                    if (deviceIdSet != null) {
                                        newSet.addAll(deviceIdSet);
                                    }
@@ -248,4 +248,4 @@ public class DistributedAclStore extends AbstractStore implements AclStore {
         ruleToDevice.remove(ruleId);
     }
 
-}
\ No newline at end of file
+}
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java
new file mode 100644 (file)
index 0000000..e9aa144
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * ACL application implementation.
+ */
+package org.onos.acl.impl;
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java
new file mode 100644 (file)
index 0000000..fa4131e
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * ACL application.
+ */
+package org.onos.acl;
index c85e469..2fc47be 100644 (file)
@@ -22,5 +22,4 @@
     <artifact>mvn:${project.groupId}/onos-app-routing-api/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-app-routing/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-app-proxyarp/${project.version}</artifact>
-    <artifact>mvn:${project.groupId}/onos-app-config/${project.version}</artifact>
 </app>
index 3457321..c91a7f1 100644 (file)
@@ -20,7 +20,6 @@
              description="${project.description}">
         <feature>onos-api</feature>
         <bundle>mvn:${project.groupId}/onos-app-routing-api/${project.version}</bundle>
-        <bundle>mvn:${project.groupId}/onos-app-config/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-app-proxyarp/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-app-bgprouter/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-app-routing/${project.version}</bundle>
index d3f6f52..decdf5c 100644 (file)
@@ -20,7 +20,7 @@
     <parent>
         <artifactId>onos-apps</artifactId>
         <groupId>org.onosproject</groupId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
             <artifactId>guava</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-app-config</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-app-proxyarp</artifactId>
index a364593..77cfe15 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java b/framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java
new file mode 100644 (file)
index 0000000..1d358eb
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Cluster IP Manager, which is responsible for managing the cluster IP
+ * address alias.
+ */
+package org.onosproject.cip;
index f538855..a10db44 100644 (file)
@@ -20,7 +20,7 @@
     <parent>
         <artifactId>onos-apps</artifactId>
         <groupId>org.onosproject</groupId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
diff --git a/framework/src/onos/apps/cordvtn/pom.xml b/framework/src/onos/apps/cordvtn/pom.xml
new file mode 100644 (file)
index 0000000..a019bec
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2014 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.
+  -->
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-apps</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-app-cordvtn</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>Virtual tenant network service for CORD</description>
+
+    <properties>
+        <onos.app.name>org.onosproject.cordvtn</onos.app.name>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-core-serializers</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java
new file mode 100644 (file)
index 0000000..af73823
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.cordvtn;
+
+/**
+ * Entity capable of handling a subject connected and disconnected situation.
+ */
+public interface ConnectionHandler<T> {
+
+    /**
+     * Processes the connected subject.
+     *
+     * @param subject subject
+     */
+    void connected(T subject);
+
+    /**
+     * Processes the disconnected subject.
+     *
+     * @param subject subject.
+     */
+    void disconnected(T subject);
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java
new file mode 100644 (file)
index 0000000..072254d
--- /dev/null
@@ -0,0 +1,311 @@
+/*
+ * 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.cordvtn;
+
+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.apache.felix.scr.annotations.Service;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.cluster.ClusterService;
+import org.onosproject.cluster.LeadershipEvent;
+import org.onosproject.cluster.LeadershipEventListener;
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Host;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.NetworkConfigService;
+import org.onosproject.net.config.basics.SubjectFactories;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.host.HostEvent;
+import org.onosproject.net.host.HostListener;
+import org.onosproject.net.host.HostService;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.EventuallyConsistentMap;
+import org.onosproject.store.service.LogicalClockService;
+import org.onosproject.store.service.StorageService;
+import org.slf4j.Logger;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.cordvtn.OvsdbNode.State.INIT;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * CORD VTN Application that provisions overlay virtual tenant networks.
+ */
+@Component(immediate = true)
+@Service
+public class CordVtn implements CordVtnService {
+
+    protected final Logger log = getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected StorageService storageService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected LogicalClockService clockService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected ClusterService clusterService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected LeadershipService leadershipService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected NetworkConfigService configService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected NetworkConfigRegistry configRegistry;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected DeviceService deviceService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected HostService hostService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected MastershipService mastershipService;
+
+    private static final int DEFAULT_NUM_THREADS = 1;
+    private static final KryoNamespace.Builder NODE_SERIALIZER = KryoNamespace.newBuilder()
+            .register(KryoNamespaces.API)
+            .register(OvsdbNode.class);
+
+    private final ExecutorService eventExecutor = Executors.newFixedThreadPool(
+            DEFAULT_NUM_THREADS, groupedThreads("onos/cordvtn", "event-handler"));
+
+    private final LeadershipEventListener leadershipListener = new InternalLeadershipListener();
+    private final DeviceListener deviceListener = new InternalDeviceListener();
+    private final HostListener hostListener = new InternalHostListener();
+    private final NodeHandler nodeHandler = new NodeHandler();
+    private final BridgeHandler bridgeHandler = new BridgeHandler();
+    private final VirtualMachineHandler vmHandler = new VirtualMachineHandler();
+
+    private final ConfigFactory configFactory =
+            new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, CordVtnConfig.class, "cordvtn") {
+                @Override
+                public CordVtnConfig createConfig() {
+                    return new CordVtnConfig();
+                }
+            };
+
+    private ApplicationId appId;
+    private NodeId local;
+    private EventuallyConsistentMap<DeviceId, OvsdbNode> nodeStore;
+    private NodeConnectionManager nodeConnectionManager;
+
+    @Activate
+    protected void activate() {
+        appId = coreService.registerApplication("org.onosproject.cordvtn");
+
+        local = clusterService.getLocalNode().id();
+        nodeStore = storageService.<DeviceId, OvsdbNode>eventuallyConsistentMapBuilder()
+                .withName("cordvtn-nodestore")
+                .withSerializer(NODE_SERIALIZER)
+                .withTimestampProvider((k, v) -> clockService.getTimestamp())
+                .build();
+        configRegistry.registerConfigFactory(configFactory);
+
+        deviceService.addListener(deviceListener);
+        hostService.addListener(hostListener);
+        leadershipService.addListener(leadershipListener);
+        leadershipService.runForLeadership(appId.name());
+        nodeConnectionManager = new NodeConnectionManager(appId, local, nodeStore,
+                                            mastershipService, leadershipService);
+        nodeConnectionManager.start();
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        nodeConnectionManager.stop();
+        leadershipService.removeListener(leadershipListener);
+        leadershipService.withdraw(appId.name());
+        deviceService.removeListener(deviceListener);
+        hostService.removeListener(hostListener);
+        eventExecutor.shutdown();
+        nodeStore.destroy();
+        configRegistry.unregisterConfigFactory(configFactory);
+        log.info("Stopped");
+    }
+
+    @Override
+    public void addNode(String hostname, IpAddress ip, TpPort port) {
+        DefaultOvsdbNode node = new DefaultOvsdbNode(hostname, ip, port, DeviceId.NONE, INIT);
+
+        if (nodeStore.containsKey(node.deviceId())) {
+            log.warn("Node {} with ovsdb-server {}:{} already exists", hostname, ip, port);
+            return;
+        }
+        nodeStore.put(node.deviceId(), node);
+        log.info("New node {} with ovsdb-server {}:{} has been added", hostname, ip, port);
+    }
+
+    @Override
+    public void deleteNode(IpAddress ip, TpPort port) {
+        DeviceId deviceId = DeviceId.deviceId("ovsdb:" + ip + ":" + port);
+        OvsdbNode node = nodeStore.get(deviceId);
+
+        if (node == null) {
+            log.warn("Node with ovsdb-server on {}:{} does not exist", ip, port);
+            return;
+        }
+        nodeConnectionManager.disconnectNode(node);
+        nodeStore.remove(node.deviceId());
+    }
+
+    @Override
+    public int getNodeCount() {
+        return nodeStore.size();
+    }
+
+    @Override
+    public List<OvsdbNode> getNodes() {
+        return nodeStore.values()
+                .stream()
+                .collect(Collectors.toList());
+    }
+
+    private void initialSetup() {
+        // Read ovsdb nodes from network config
+        CordVtnConfig config = configService.getConfig(appId, CordVtnConfig.class);
+        if (config == null) {
+            log.warn("No configuration found");
+            return;
+        }
+        config.ovsdbNodes().forEach(
+                node -> addNode(node.hostname(), node.ip(), node.port()));
+    }
+
+    private synchronized void processLeadershipChange(NodeId leader) {
+        // Only the leader performs the initial setup
+        if (leader == null || !leader.equals(local)) {
+            return;
+        }
+        initialSetup();
+    }
+
+    private class InternalLeadershipListener implements LeadershipEventListener {
+
+        @Override
+        public void event(LeadershipEvent event) {
+            if (event.subject().topic().equals(appId.name())) {
+                processLeadershipChange(event.subject().leader());
+            }
+        }
+    }
+
+    private class InternalDeviceListener implements DeviceListener {
+
+        @Override
+        public void event(DeviceEvent event) {
+            Device device = event.subject();
+            ConnectionHandler handler =
+                    (device.type() == Device.Type.CONTROLLER ? nodeHandler : bridgeHandler);
+
+            switch (event.type()) {
+                    case DEVICE_ADDED:
+                        eventExecutor.submit(() -> handler.connected(device));
+                        break;
+                    case DEVICE_AVAILABILITY_CHANGED:
+                        eventExecutor.submit(() -> handler.disconnected(device));
+                        break;
+                    default:
+                        break;
+            }
+        }
+    }
+
+    private class InternalHostListener implements HostListener {
+
+        @Override
+        public void event(HostEvent event) {
+            Host vm = event.subject();
+
+            switch (event.type()) {
+                case HOST_ADDED:
+                    eventExecutor.submit(() -> vmHandler.connected(vm));
+                    break;
+                case HOST_REMOVED:
+                    eventExecutor.submit(() -> vmHandler.disconnected(vm));
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+
+    private class NodeHandler implements ConnectionHandler<Device> {
+
+        @Override
+        public void connected(Device device) {
+            // create bridge and set bridgeId
+            // set node state connected
+        }
+
+        @Override
+        public void disconnected(Device device) {
+            // set node state disconnected if the node exists
+            // which means that the node is not deleted explicitly
+        }
+    }
+
+    private class BridgeHandler implements ConnectionHandler<Device> {
+
+        @Override
+        public void connected(Device device) {
+            // create vxlan port
+        }
+
+        @Override
+        public void disconnected(Device device) {
+
+        }
+    }
+
+    private class VirtualMachineHandler implements ConnectionHandler<Host> {
+
+        @Override
+        public void connected(Host host) {
+            // install flow rules for this vm
+        }
+
+        @Override
+        public void disconnected(Host host) {
+            // uninstall flow rules associated with this vm
+        }
+    }
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java
new file mode 100644 (file)
index 0000000..c2c37ab
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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.cordvtn;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.config.Config;
+
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Configuration object for CORD VTN service.
+ */
+public class CordVtnConfig extends Config<ApplicationId> {
+
+    public static final String OVSDB_NODES = "ovsdbNodes";
+    public static final String HOSTNAME = "hostname";
+    public static final String IP = "ip";
+    public static final String PORT = "port";
+
+    /**
+     * Returns the set of ovsdb nodes read from network config.
+     *
+     * @return set of OvsdbNodeConfig or null
+     */
+    public Set<OvsdbNodeConfig> ovsdbNodes() {
+        Set<OvsdbNodeConfig> ovsdbNodes = Sets.newHashSet();
+
+        JsonNode nodes = object.get(OVSDB_NODES);
+        if (nodes == null) {
+            return null;
+        }
+        nodes.forEach(jsonNode -> ovsdbNodes.add(new OvsdbNodeConfig(
+            jsonNode.path(HOSTNAME).asText(),
+            IpAddress.valueOf(jsonNode.path(IP).asText()),
+            TpPort.tpPort(jsonNode.path(PORT).asInt()))));
+
+        return ovsdbNodes;
+    }
+
+    /**
+     * Configuration for an OVSDB node.
+     */
+    public static class OvsdbNodeConfig {
+
+        private final String hostname;
+        private final IpAddress ip;
+        private final TpPort port;
+
+        public OvsdbNodeConfig(String hostname, IpAddress ip, TpPort port) {
+            this.hostname = checkNotNull(hostname);
+            this.ip = checkNotNull(ip);
+            this.port = checkNotNull(port);
+        }
+
+        /**
+         * Returns hostname of the node.
+         *
+         * @return hostname
+         */
+        public String hostname() {
+            return this.hostname;
+        }
+
+        /**
+         * Returns ip address to access ovsdb-server of the node.
+         *
+         * @return ip address
+         */
+        public IpAddress ip() {
+            return this.ip;
+        }
+
+        /**
+         * Returns port number to access ovsdb-server of the node.
+         *
+         * @return port number
+         */
+        public TpPort port() {
+            return this.port;
+        }
+    }
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java
new file mode 100644 (file)
index 0000000..d26a10a
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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.cordvtn;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+
+import java.util.List;
+
+/**
+ * Service for provisioning overlay virtual networks on compute nodes.
+ */
+public interface CordVtnService {
+    /**
+     * Adds a new node to the service.
+     *
+     * @param hostname hostname of the node
+     * @param ip ip address to access the ovsdb server running on the node
+     * @param port port number to access the ovsdb server running on the node
+     */
+    void addNode(String hostname, IpAddress ip, TpPort port);
+
+    /**
+     * Deletes the node from the service.
+     *
+     * @param ip ip address to access the ovsdb server running on the node
+     * @param port port number to access the ovsdb server running on the node
+     */
+    void deleteNode(IpAddress ip, TpPort port);
+
+    /**
+     * Returns the number of the nodes known to the service.
+     *
+     * @return number of nodes
+     */
+    int getNodeCount();
+
+    /**
+     * Returns all nodes known to the service.
+     *
+     * @return list of nodes
+     */
+    List<OvsdbNode> getNodes();
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java
new file mode 100644 (file)
index 0000000..b8cdbe9
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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.cordvtn;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.net.DeviceId;
+
+import java.util.Objects;
+
+/**
+ * OvsdbNode implementation.
+ */
+public class DefaultOvsdbNode implements OvsdbNode {
+
+    private final String hostname;
+    private final IpAddress ip;
+    private final TpPort port;
+    private final DeviceId deviceId;
+    private final DeviceId bridgeId;
+    private final State state;
+
+    public DefaultOvsdbNode(String hostname, IpAddress ip, TpPort port,
+                            DeviceId bridgeId, State state) {
+        this.hostname = hostname;
+        this.ip = ip;
+        this.port = port;
+        this.deviceId = DeviceId.deviceId(
+                "ovsdb:" + ip.toString() + ":" + port.toString());
+        this.bridgeId = bridgeId;
+        this.state = state;
+    }
+
+    @Override
+    public IpAddress ip() {
+        return this.ip;
+    }
+
+    @Override
+    public TpPort port() {
+        return this.port;
+    }
+
+    @Override
+    public String hostname() {
+        return this.hostname;
+    }
+
+    @Override
+    public State state() {
+        return this.state;
+    }
+
+    @Override
+    public DeviceId deviceId() {
+        return this.deviceId;
+    }
+
+    @Override
+    public DeviceId bridgeId() {
+        return this.bridgeId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (o instanceof DefaultOvsdbNode) {
+            DefaultOvsdbNode that = (DefaultOvsdbNode) o;
+            // We compare the ip and port only.
+            if (this.ip.equals(that.ip) && this.port.equals(that.port)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(ip, port);
+    }
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java
new file mode 100644 (file)
index 0000000..0b7029e
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * 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.cordvtn;
+
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.store.service.EventuallyConsistentMap;
+import org.slf4j.Logger;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import static org.onlab.util.Tools.groupedThreads;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Node connection manager.
+ */
+public class NodeConnectionManager {
+    protected final Logger log = getLogger(getClass());
+
+    private final ApplicationId appId;
+    private final NodeId localId;
+    private final EventuallyConsistentMap<DeviceId, OvsdbNode> nodeStore;
+    private final MastershipService mastershipService;
+    private final LeadershipService leadershipService;
+
+    private static final int DELAY_SEC = 5;
+    private ScheduledExecutorService connectionExecutor;
+
+    /**
+     * Creates a new NodeConnectionManager.
+     *
+     * @param localId local id
+     * @param nodeStore node store
+     * @param mastershipService mastership service
+     */
+    public NodeConnectionManager(ApplicationId appId, NodeId localId,
+                                 EventuallyConsistentMap<DeviceId, OvsdbNode> nodeStore,
+                                 MastershipService mastershipService,
+                                 LeadershipService leadershipService) {
+        this.appId = appId;
+        this.localId = localId;
+        this.nodeStore = nodeStore;
+        this.mastershipService = mastershipService;
+        this.leadershipService = leadershipService;
+    }
+
+    /**
+     * Starts the node connection manager.
+     */
+    public void start() {
+        connectionExecutor = Executors.newSingleThreadScheduledExecutor(
+                        groupedThreads("onos/cordvtn", "connection-executor"));
+        connectionExecutor.scheduleWithFixedDelay(() -> nodeStore.values()
+                .stream()
+                .filter(node -> localId.equals(getMaster(node)))
+                .forEach(node -> connectNode(node)), 0, DELAY_SEC, TimeUnit.SECONDS);
+    }
+
+    /**
+     * Stops the node connection manager.
+     */
+    public void stop() {
+        connectionExecutor.shutdown();
+    }
+
+    /**
+     * Adds a new node to the system.
+     *
+     * @param ovsdbNode ovsdb node
+     */
+    public void connectNode(OvsdbNode ovsdbNode) {
+        switch (ovsdbNode.state()) {
+            case INIT:
+            case DISCONNECTED:
+                // TODO: set the node to passive mode
+            case READY:
+                // TODO: initiate connection
+                break;
+            case CONNECTED:
+                break;
+            default:
+        }
+    }
+
+    /**
+     * Deletes the ovsdb node.
+     *
+     * @param ovsdbNode ovsdb node
+     */
+    public void disconnectNode(OvsdbNode ovsdbNode) {
+        switch (ovsdbNode.state()) {
+            case CONNECTED:
+                // TODO: disconnect
+                break;
+            case INIT:
+            case READY:
+            case DISCONNECTED:
+                break;
+            default:
+        }
+    }
+
+    private NodeId getMaster(OvsdbNode ovsdbNode) {
+        // Return the master of the bridge(switch) if it exist or
+        // return the current leader
+        if (ovsdbNode.bridgeId() == DeviceId.NONE) {
+            return leadershipService.getLeader(this.appId.name());
+        } else {
+            return mastershipService.getMasterFor(ovsdbNode.bridgeId());
+        }
+    }
+
+    private void setPassiveMode(OvsdbNode ovsdbNode) {
+        // TODO: need ovsdb client implementation first
+        // TODO: set the remove ovsdb server passive mode
+        // TODO: set the node state READY if it succeed
+    }
+
+    private void connect(OvsdbNode ovsdbNode) {
+        // TODO: need ovsdb client implementation first
+    }
+
+    private void disconnect(OvsdbNode ovsdbNode) {
+        // TODO: need ovsdb client implementation first
+    }
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java
new file mode 100644 (file)
index 0000000..bb2a0b7
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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.cordvtn;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Representation of a node with ovsdb server.
+ */
+public interface OvsdbNode {
+    /**
+     * State of the ovsdb node.
+     */
+    enum State {
+        INIT, READY, CONNECTED, DISCONNECTED
+    }
+
+    /**
+     * Returns the IP address of ovsdb server.
+     *
+     * @return ip address
+     */
+    IpAddress ip();
+
+    /**
+     * Returns the port number of ovsdb server.
+     *
+     * @return port number
+     */
+    TpPort port();
+
+    /**
+     * Returns the hostname of the node.
+     *
+     * @return hostname
+     */
+    String hostname();
+
+    /**
+     * Returns the state of the node.
+     *
+     * @return state of the node
+     */
+    State state();
+
+    /**
+     * Returns the device ID of the node.
+     *
+     * @return device id
+     */
+    DeviceId deviceId();
+
+    /**
+     * Returns the device ID of the bridge associated with this node.
+     *
+     * @return device id
+     */
+    DeviceId bridgeId();
+}
index eeda585..16ed5d9 100644 (file)
@@ -27,7 +27,7 @@
     </parent>
 
     <artifactId>cord-gui</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
     <packaging>war</packaging>
 
     <description>Demo CORD Subscriber Web GUI</description>
index a91dbfb..dffabce 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.cord.gui.model;
 
 import com.fasterxml.jackson.databind.node.ArrayNode;
index e7ad332..d5a7528 100644 (file)
@@ -1 +1 @@
-cp $ONOS_ROOT/apps/demo/cord-gui/target/cord-gui-1.3.0-SNAPSHOT.war .
+cp $ONOS_ROOT/apps/demo/cord-gui/target/cord-gui-1.4.0-SNAPSHOT.war .
index db76fb6..496b18e 100644 (file)
@@ -4,7 +4,7 @@
 
 export LISTENPORT=8080
 export JETTY="-jar jetty-runner.jar"
-export CORD=./cord-gui-1.3.0-SNAPSHOT.war
+export CORD=./cord-gui-1.4.0-SNAPSHOT.war
 export LOGDBG=-Dorg.onosproject.cord.gui.LEVEL=DEBUG
 export DEBUG="-Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n"
 export LOG=cord.log
index 1329816..0daa4f7 100644 (file)
@@ -21,7 +21,7 @@
     <parent>
         <artifactId>onos-apps</artifactId>
         <groupId>org.onosproject</groupId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 20e1c61..7c2127f 100644 (file)
@@ -17,6 +17,7 @@ package org.onosproject.dhcp;
 
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.MacAddress;
+import org.onosproject.net.HostId;
 
 import java.util.Map;
 
@@ -30,7 +31,7 @@ public interface DhcpService {
      *
      * @return collection of mappings.
      */
-    Map<MacAddress, IpAssignment> listMapping();
+    Map<HostId, IpAssignment> listMapping();
 
     /**
      * Returns the default lease time granted by the DHCP Server.
index 4e2d67d..c9fade9 100644 (file)
@@ -17,6 +17,7 @@ package org.onosproject.dhcp;
 
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.MacAddress;
+import org.onosproject.net.HostId;
 
 import java.util.Map;
 
@@ -36,21 +37,21 @@ public interface DhcpStore {
     /**
      * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message.
      *
-     * @param macID Mac ID of the client requesting an IP
+     * @param hostId Host ID of the client requesting an IP
      * @param requestedIP requested IP address
      * @return IP address assigned to the Mac ID
      */
-    Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP);
+    Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP);
 
     /**
      * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
      *
-     * @param macID Mac Id of the client requesting an IP
+     * @param hostId Host Id of the client requesting an IP
      * @param ipAddr IP Address being requested
      * @param leaseTime Lease time offered by the server for this mapping
      * @return returns true if the assignment was successful, false otherwise
      */
-    boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime);
+    boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime);
 
     /**
      * Sets the default time for which suggested IP mappings are valid.
@@ -60,25 +61,25 @@ public interface DhcpStore {
     void setDefaultTimeoutForPurge(int timeInSeconds);
 
     /**
-     * Sets the delay after which the dhcp server will purge expired entries.
+     * Releases the IP assigned to a Mac ID into the free pool.
      *
-     * @param timeInSeconds default time
+     * @param hostId the host ID for which the mapping needs to be changed
      */
-    void setTimerDelay(int timeInSeconds);
+    void releaseIP(HostId hostId);
 
     /**
-     * Releases the IP assigned to a Mac ID into the free pool.
+     * Returns a collection of all the MacAddress to IPAddress mapping assigned to the hosts.
      *
-     * @param macID the macID for which the mapping needs to be changed
+     * @return the collection of the mappings
      */
-    void releaseIP(MacAddress macID);
+    Map<HostId, IpAssignment> listAssignedMapping();
 
     /**
      * Returns a collection of all the MacAddress to IPAddress mapping.
      *
      * @return the collection of the mappings
      */
-    Map<MacAddress, IpAssignment> listMapping();
+    Map<HostId, IpAssignment> listAllMapping();
 
     /**
      * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
index c8bd190..9b3aa68 100644 (file)
@@ -49,7 +49,7 @@ public final class IpAssignment {
         /**
          * IP mapping is no longer active.
          */
-        Option_Expired;
+        Option_Expired
     }
 
     /**
@@ -100,10 +100,19 @@ public final class IpAssignment {
     /**
      * Returns the lease period of the IP assignment.
      *
-     * @return the lease period
+     * @return the lease period in seconds
      */
     public int leasePeriod() {
-        return (int) this.leasePeriod / 1000;
+        return (int) this.leasePeriod;
+    }
+
+    /**
+     * Returns the lease period of the IP assignment.
+     *
+     * @return the lease period in milliseconds
+     */
+    public int leasePeriodMs() {
+        return (int) this.leasePeriod * 1000;
     }
 
     @Override
@@ -155,7 +164,7 @@ public final class IpAssignment {
         private Builder(IpAssignment ipAssignment) {
             ipAddress = ipAssignment.ipAddress();
             timeStamp = ipAssignment.timestamp();
-            leasePeriod = ipAssignment.leasePeriod() * 1000;
+            leasePeriod = ipAssignment.leasePeriod();
             assignmentStatus = ipAssignment.assignmentStatus();
         }
 
@@ -178,7 +187,7 @@ public final class IpAssignment {
         }
 
         public Builder leasePeriod(int leasePeriodinSeconds) {
-            leasePeriod = leasePeriodinSeconds * 1000;
+            leasePeriod = leasePeriodinSeconds;
             return this;
         }
 
index fc470ce..209ba68 100644 (file)
 package org.onosproject.dhcp.cli;
 
 import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.MacAddress;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.dhcp.DhcpService;
 import org.onosproject.dhcp.IpAssignment;
+import org.onosproject.net.HostId;
 
 import java.util.Map;
 
@@ -35,9 +35,9 @@ public class DhcpListAllMappings extends AbstractShellCommand {
     protected void execute() {
 
         DhcpService dhcpService = AbstractShellCommand.get(DhcpService.class);
-        Map<MacAddress, IpAssignment> allocationMap = dhcpService.listMapping();
+        Map<HostId, IpAssignment> allocationMap = dhcpService.listMapping();
 
-        for (Map.Entry<MacAddress, IpAssignment> entry : allocationMap.entrySet()) {
+        for (Map.Entry<HostId, IpAssignment> entry : allocationMap.entrySet()) {
             print(DHCP_MAPPING_FORMAT, entry.getKey().toString(), entry.getValue().ipAddress().toString());
         }
     }
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java
new file mode 100644 (file)
index 0000000..f878019
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * CLI implementation for sample application that assigns and manages DHCP leases.
+ */
+package org.onosproject.dhcp.cli;
\ No newline at end of file
index f8d5e63..4353d62 100644 (file)
@@ -15,6 +15,8 @@
  */
 package org.onosproject.dhcp.impl;
 
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.MacAddress;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.config.Config;
 import org.onosproject.net.config.basics.BasicElementConfig;
@@ -34,14 +36,21 @@ public class DhcpConfig extends Config<ApplicationId> {
     public static final String LEASE_TIME = "lease";
     public static final String RENEW_TIME = "renew";
     public static final String REBIND_TIME = "rebind";
+    public static final String TIMER_DELAY = "delay";
+    public static final String DEFAULT_TIMEOUT = "timeout";
+    public static final String START_IP = "startip";
+    public static final String END_IP = "endip";
+
+    public static final int DEFAULT = -1;
 
     /**
      * Returns the dhcp server ip.
      *
      * @return ip address or null if not set
      */
-    public String ip() {
-        return get(MY_IP, null);
+    public Ip4Address ip() {
+        String ip = get(MY_IP, null);
+        return ip != null ? Ip4Address.valueOf(ip) : null;
     }
 
     /**
@@ -59,8 +68,9 @@ public class DhcpConfig extends Config<ApplicationId> {
      *
      * @return server mac or null if not set
      */
-    public String mac() {
-        return get(MY_MAC, null);
+    public MacAddress mac() {
+        String mac = get(MY_MAC, null);
+        return mac != null ? MacAddress.valueOf(mac) : null;
     }
 
     /**
@@ -78,8 +88,9 @@ public class DhcpConfig extends Config<ApplicationId> {
      *
      * @return subnet mask or null if not set
      */
-    public String subnetMask() {
-        return get(SUBNET_MASK, null);
+    public Ip4Address subnetMask() {
+        String ip = get(SUBNET_MASK, null);
+        return ip != null ? Ip4Address.valueOf(ip) : null;
     }
 
     /**
@@ -97,8 +108,9 @@ public class DhcpConfig extends Config<ApplicationId> {
      *
      * @return broadcast address or null if not set
      */
-    public String broadcastAddress() {
-        return get(BROADCAST_ADDRESS, null);
+    public Ip4Address broadcastAddress() {
+        String ip = get(BROADCAST_ADDRESS, null);
+        return ip != null ? Ip4Address.valueOf(ip) : null;
     }
 
     /**
@@ -114,10 +126,10 @@ public class DhcpConfig extends Config<ApplicationId> {
     /**
      * Returns the Time To Live for the reply packets.
      *
-     * @return ttl or null if not set
+     * @return ttl or -1 if not set
      */
-    public String ttl() {
-        return get(TTL, null);
+    public int ttl() {
+        return get(TTL, DEFAULT);
     }
 
     /**
@@ -126,17 +138,17 @@ public class DhcpConfig extends Config<ApplicationId> {
      * @param ttl new ttl; null to clear
      * @return self
      */
-    public BasicElementConfig ttl(String ttl) {
+    public BasicElementConfig ttl(int ttl) {
         return (BasicElementConfig) setOrClear(TTL, ttl);
     }
 
     /**
      * Returns the Lease Time offered by the DHCP Server.
      *
-     * @return lease time or null if not set
+     * @return lease time or -1 if not set
      */
-    public String leaseTime() {
-        return get(LEASE_TIME, null);
+    public int leaseTime() {
+        return get(LEASE_TIME, DEFAULT);
     }
 
     /**
@@ -145,17 +157,17 @@ public class DhcpConfig extends Config<ApplicationId> {
      * @param lease new lease time; null to clear
      * @return self
      */
-    public BasicElementConfig leaseTime(String lease) {
+    public BasicElementConfig leaseTime(int lease) {
         return (BasicElementConfig) setOrClear(LEASE_TIME, lease);
     }
 
     /**
      * Returns the Renew Time offered by the DHCP Server.
      *
-     * @return renew time or null if not set
+     * @return renew time or -1 if not set
      */
-    public String renewTime() {
-        return get(RENEW_TIME, null);
+    public int renewTime() {
+        return get(RENEW_TIME, DEFAULT);
     }
 
     /**
@@ -164,17 +176,17 @@ public class DhcpConfig extends Config<ApplicationId> {
      * @param renew new renew time; null to clear
      * @return self
      */
-    public BasicElementConfig renewTime(String renew) {
+    public BasicElementConfig renewTime(int renew) {
         return (BasicElementConfig) setOrClear(RENEW_TIME, renew);
     }
 
     /**
      * Returns the Rebind Time offered by the DHCP Server.
      *
-     * @return rebind time or null if not set
+     * @return rebind time or -1 if not set
      */
-    public String rebindTime() {
-        return get(REBIND_TIME, null);
+    public int rebindTime() {
+        return get(REBIND_TIME, DEFAULT);
     }
 
     /**
@@ -183,7 +195,7 @@ public class DhcpConfig extends Config<ApplicationId> {
      * @param rebind new rebind time; null to clear
      * @return self
      */
-    public BasicElementConfig rebindTime(String rebind) {
+    public BasicElementConfig rebindTime(int rebind) {
         return (BasicElementConfig) setOrClear(REBIND_TIME, rebind);
     }
 
@@ -192,8 +204,9 @@ public class DhcpConfig extends Config<ApplicationId> {
      *
      * @return router address or null if not set
      */
-    public String routerAddress() {
-        return get(ROUTER_ADDRESS, null);
+    public Ip4Address routerAddress() {
+        String ip = get(ROUTER_ADDRESS, null);
+        return ip != null ? Ip4Address.valueOf(ip) : null;
     }
 
     /**
@@ -211,8 +224,9 @@ public class DhcpConfig extends Config<ApplicationId> {
      *
      * @return domain server address or null if not set
      */
-    public String domainServer() {
-        return get(DOMAIN_SERVER, null);
+    public Ip4Address domainServer() {
+        String ip = get(DOMAIN_SERVER, null);
+        return ip != null ? Ip4Address.valueOf(ip) : null;
     }
 
     /**
@@ -224,4 +238,82 @@ public class DhcpConfig extends Config<ApplicationId> {
     public BasicElementConfig domainServer(String domain) {
         return (BasicElementConfig) setOrClear(DOMAIN_SERVER, domain);
     }
+
+    /**
+     * Returns the delay in minutes after which the dhcp server will purge expired entries.
+     *
+     * @return time delay or -1 if not set
+     */
+    public int timerDelay() {
+        return get(TIMER_DELAY, DEFAULT);
+    }
+
+    /**
+     * Sets the delay after which the dhcp server will purge expired entries.
+     *
+     * @param delay new time delay; null to clear
+     * @return self
+     */
+    public BasicElementConfig timerDelay(int delay) {
+        return (BasicElementConfig) setOrClear(TIMER_DELAY, delay);
+    }
+
+    /**
+     * Returns the default timeout for pending assignments.
+     *
+     * @return default timeout or -1 if not set
+     */
+    public int defaultTimeout() {
+        return get(DEFAULT_TIMEOUT, DEFAULT);
+    }
+
+    /**
+     * Sets the default timeout for pending assignments.
+     *
+     * @param defaultTimeout new default timeout; null to clear
+     * @return self
+     */
+    public BasicElementConfig defaultTimeout(int defaultTimeout) {
+        return (BasicElementConfig) setOrClear(DEFAULT_TIMEOUT, defaultTimeout);
+    }
+
+    /**
+     * Returns the start IP for the available IP Range.
+     *
+     * @return start IP or null if not set
+     */
+    public Ip4Address startIp() {
+        String ip = get(START_IP, null);
+        return ip != null ? Ip4Address.valueOf(ip) : null;
+    }
+
+    /**
+     * Sets the start IP for the available IP Range.
+     *
+     * @param startIp new start IP; null to clear
+     * @return self
+     */
+    public BasicElementConfig startIp(String startIp) {
+        return (BasicElementConfig) setOrClear(START_IP, startIp);
+    }
+
+    /**
+     * Returns the end IP for the available IP Range.
+     *
+     * @return end IP or null if not set
+     */
+    public Ip4Address endIp() {
+        String ip = get(END_IP, null);
+        return ip != null ? Ip4Address.valueOf(ip) : null;
+    }
+
+    /**
+     * Sets the end IP for the available IP Range.
+     *
+     * @param endIp new end IP; null to clear
+     * @return self
+     */
+    public BasicElementConfig endIp(String endIp) {
+        return (BasicElementConfig) setOrClear(END_IP, endIp);
+    }
 }
index 24cb087..345d5ad 100644 (file)
@@ -22,6 +22,8 @@ import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.Service;
+import org.jboss.netty.util.Timeout;
+import org.jboss.netty.util.TimerTask;
 import org.onlab.packet.ARP;
 import org.onlab.packet.DHCP;
 import org.onlab.packet.DHCPOption;
@@ -34,20 +36,20 @@ import org.onlab.packet.MacAddress;
 import org.onlab.packet.TpPort;
 import org.onlab.packet.UDP;
 import org.onlab.packet.VlanId;
+import org.onlab.util.Timer;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
 import org.onosproject.dhcp.DhcpService;
 import org.onosproject.dhcp.DhcpStore;
 import org.onosproject.dhcp.IpAssignment;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.Host;
 import org.onosproject.net.HostId;
 import org.onosproject.net.HostLocation;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
 import org.onosproject.net.flow.DefaultTrafficSelector;
 import org.onosproject.net.flow.DefaultTrafficTreatment;
 import org.onosproject.net.flow.TrafficSelector;
@@ -68,10 +70,13 @@ import org.slf4j.LoggerFactory;
 
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 import static org.onlab.packet.MacAddress.valueOf;
 import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
@@ -86,7 +91,7 @@ public class DhcpManager implements DhcpService {
     private static final ProviderId PID = new ProviderId("of", "org.onosproject.dhcp", true);
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private final NetworkConfigListener cfgListener = new InternalConfigListener();
+    private final InternalConfigListener cfgListener = new InternalConfigListener();
 
     private final Set<ConfigFactory> factories = ImmutableSet.of(
             new ConfigFactory<ApplicationId, DhcpConfig>(APP_SUBJECT_FACTORY,
@@ -96,14 +101,6 @@ public class DhcpManager implements DhcpService {
                 public DhcpConfig createConfig() {
                     return new DhcpConfig();
                 }
-            },
-            new ConfigFactory<ApplicationId, DhcpStoreConfig>(APP_SUBJECT_FACTORY,
-                    DhcpStoreConfig.class,
-                    "dhcpstore") {
-                @Override
-                public DhcpStoreConfig createConfig() {
-                    return new DhcpStoreConfig();
-                }
             }
     );
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -125,11 +122,13 @@ public class DhcpManager implements DhcpService {
 
     protected HostProviderService hostProviderService;
 
+    private final HostProvider hostProvider = new InternalHostProvider();
+
     private ApplicationId appId;
 
     // Hardcoded values are default values.
 
-    private static String myIP = "10.0.0.2";
+    private static Ip4Address myIP = Ip4Address.valueOf("10.0.0.2");
 
     private static MacAddress myMAC = valueOf("4f:4f:4f:4f:4f:4f");
 
@@ -147,14 +146,17 @@ public class DhcpManager implements DhcpService {
 
     private static byte packetTTL = (byte) 127;
 
-    private static String subnetMask = "255.0.0.0";
+    private static Ip4Address subnetMask = Ip4Address.valueOf("255.0.0.0");
 
-    private static String broadcastAddress = "10.255.255.255";
+    private static Ip4Address broadcastAddress = Ip4Address.valueOf("10.255.255.255");
 
-    private static String routerAddress = "10.0.0.2";
+    private static Ip4Address routerAddress = Ip4Address.valueOf("10.0.0.2");
 
-    private static String domainServer = "10.0.0.2";
-    private final HostProvider hostProvider = new InternalHostProvider();
+    private static Ip4Address domainServer = Ip4Address.valueOf("10.0.0.2");
+
+    protected Timeout timeout;
+
+    protected static int timerDelay = 2;
 
     @Activate
     protected void activate() {
@@ -163,9 +165,12 @@ public class DhcpManager implements DhcpService {
 
         cfgService.addListener(cfgListener);
         factories.forEach(cfgService::registerConfigFactory);
+        cfgListener.reconfigureNetwork(cfgService.getConfig(appId, DhcpConfig.class));
+
         hostProviderService = hostProviderRegistry.register(hostProvider);
-        packetService.addProcessor(processor, PacketProcessor.observer(1));
+        packetService.addProcessor(processor, PacketProcessor.director(0));
         requestPackets();
+        timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);
         log.info("Started");
     }
 
@@ -177,6 +182,7 @@ public class DhcpManager implements DhcpService {
         hostProviderRegistry.unregister(hostProvider);
         hostProviderService = null;
         cancelPackets();
+        timeout.cancel();
         log.info("Stopped");
     }
 
@@ -214,8 +220,8 @@ public class DhcpManager implements DhcpService {
     }
 
     @Override
-    public Map<MacAddress, IpAssignment> listMapping() {
-        return dhcpStore.listMapping();
+    public Map<HostId, IpAssignment> listMapping() {
+        return dhcpStore.listAssignedMapping();
     }
 
     @Override
@@ -258,9 +264,7 @@ public class DhcpManager implements DhcpService {
          * @param outgoingMessageType the message type of the outgoing packet
          * @return the Ethernet reply frame
          */
-        private Ethernet buildReply(Ethernet packet, String ipOffered, byte outgoingMessageType) {
-            Ip4Address myIPAddress = Ip4Address.valueOf(myIP);
-            Ip4Address ipAddress;
+        private Ethernet buildReply(Ethernet packet, Ip4Address ipOffered, byte outgoingMessageType) {
 
             // Ethernet Frame.
             Ethernet ethReply = new Ethernet();
@@ -272,9 +276,8 @@ public class DhcpManager implements DhcpService {
             // IP Packet
             IPv4 ipv4Packet = (IPv4) packet.getPayload();
             IPv4 ipv4Reply = new IPv4();
-            ipv4Reply.setSourceAddress(myIPAddress.toInt());
-            ipAddress = Ip4Address.valueOf(ipOffered);
-            ipv4Reply.setDestinationAddress(ipAddress.toInt());
+            ipv4Reply.setSourceAddress(myIP.toInt());
+            ipv4Reply.setDestinationAddress(ipOffered.toInt());
             ipv4Reply.setTtl(packetTTL);
 
             // UDP Datagram.
@@ -288,9 +291,8 @@ public class DhcpManager implements DhcpService {
             DHCP dhcpReply = new DHCP();
             dhcpReply.setOpCode(DHCP.OPCODE_REPLY);
 
-            ipAddress = Ip4Address.valueOf(ipOffered);
-            dhcpReply.setYourIPAddress(ipAddress.toInt());
-            dhcpReply.setServerIPAddress(myIPAddress.toInt());
+            dhcpReply.setYourIPAddress(ipOffered.toInt());
+            dhcpReply.setServerIPAddress(myIP.toInt());
 
             dhcpReply.setTransactionId(dhcpPacket.getTransactionId());
             dhcpReply.setClientHardwareAddress(dhcpPacket.getClientHardwareAddress());
@@ -312,7 +314,7 @@ public class DhcpManager implements DhcpService {
             option = new DHCPOption();
             option.setCode(DHCP.DHCPOptionCode.OptionCode_DHCPServerIp.getValue());
             option.setLength((byte) 4);
-            option.setData(myIPAddress.toOctets());
+            option.setData(myIP.toOctets());
             optionList.add(option);
 
             // IP Address Lease Time.
@@ -340,32 +342,28 @@ public class DhcpManager implements DhcpService {
             option = new DHCPOption();
             option.setCode(DHCP.DHCPOptionCode.OptionCode_SubnetMask.getValue());
             option.setLength((byte) 4);
-            ipAddress = Ip4Address.valueOf(subnetMask);
-            option.setData(ipAddress.toOctets());
+            option.setData(subnetMask.toOctets());
             optionList.add(option);
 
             // Broadcast Address.
             option = new DHCPOption();
             option.setCode(DHCP.DHCPOptionCode.OptionCode_BroadcastAddress.getValue());
             option.setLength((byte) 4);
-            ipAddress = Ip4Address.valueOf(broadcastAddress);
-            option.setData(ipAddress.toOctets());
+            option.setData(broadcastAddress.toOctets());
             optionList.add(option);
 
             // Router Address.
             option = new DHCPOption();
             option.setCode(DHCP.DHCPOptionCode.OptionCode_RouterAddress.getValue());
             option.setLength((byte) 4);
-            ipAddress = Ip4Address.valueOf(routerAddress);
-            option.setData(ipAddress.toOctets());
+            option.setData(routerAddress.toOctets());
             optionList.add(option);
 
             // DNS Server Address.
             option = new DHCPOption();
             option.setCode(DHCP.DHCPOptionCode.OptionCode_DomainServer.getValue());
             option.setLength((byte) 4);
-            ipAddress = Ip4Address.valueOf(domainServer);
-            option.setData(ipAddress.toOctets());
+            option.setData(domainServer.toOctets());
             optionList.add(option);
 
             // End Option.
@@ -394,7 +392,7 @@ public class DhcpManager implements DhcpService {
                 TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
                 ConnectPoint sourcePoint = context.inPacket().receivedFrom();
                 builder.setOutput(sourcePoint.port());
-
+                context.block();
                 packetService.emit(new DefaultOutboundPacket(sourcePoint.deviceId(),
                         builder.build(), ByteBuffer.wrap(reply.serialize())));
             }
@@ -407,7 +405,6 @@ public class DhcpManager implements DhcpService {
          * @param dhcpPayload the extracted DHCP payload
          */
         private void processDHCPPacket(PacketContext context, DHCP dhcpPayload) {
-
             Ethernet packet = context.inPacket().parsed();
             boolean flagIfRequestedIP = false;
             boolean flagIfServerIP = false;
@@ -416,12 +413,11 @@ public class DhcpManager implements DhcpService {
 
             if (dhcpPayload != null) {
 
-                // TODO Convert this to enum value.
-                byte incomingPacketType = 0;
+                DHCPPacketType incomingPacketType = DHCPPacketType.getType(0);
                 for (DHCPOption option : dhcpPayload.getOptions()) {
                     if (option.getCode() == DHCP.DHCPOptionCode.OptionCode_MessageType.getValue()) {
                         byte[] data = option.getData();
-                        incomingPacketType = data[0];
+                        incomingPacketType = DHCPPacketType.getType(data[0]);
                     }
                     if (option.getCode() == DHCP.DHCPOptionCode.OptionCode_RequestedIP.getValue()) {
                         byte[] data = option.getData();
@@ -434,37 +430,39 @@ public class DhcpManager implements DhcpService {
                         flagIfServerIP = true;
                     }
                 }
-
-                String ipOffered = "";
                 DHCPPacketType outgoingPacketType;
                 MacAddress clientMAC = new MacAddress(dhcpPayload.getClientHardwareAddress());
+                VlanId vlanId = VlanId.vlanId(packet.getVlanID());
+                HostId hostId = HostId.hostId(clientMAC, vlanId);
 
-                if (incomingPacketType == DHCPPacketType.DHCPDISCOVER.getValue()) {
+                if (incomingPacketType.getValue() == DHCPPacketType.DHCPDISCOVER.getValue()) {
 
                     outgoingPacketType = DHCPPacketType.DHCPOFFER;
-                    ipOffered = dhcpStore.suggestIP(clientMAC, requestedIP).toString();
-
-                    Ethernet ethReply = buildReply(packet, ipOffered, (byte) outgoingPacketType.getValue());
-                    sendReply(context, ethReply);
+                    Ip4Address ipOffered = dhcpStore.suggestIP(hostId, requestedIP);
+                    if (ipOffered != null) {
+                        Ethernet ethReply = buildReply(packet, ipOffered,
+                                (byte) outgoingPacketType.getValue());
+                        sendReply(context, ethReply);
+                    }
 
-                } else if (incomingPacketType == DHCPPacketType.DHCPREQUEST.getValue()) {
+                } else if (incomingPacketType.getValue() == DHCPPacketType.DHCPREQUEST.getValue()) {
 
                     outgoingPacketType = DHCPPacketType.DHCPACK;
 
                     if (flagIfServerIP && flagIfRequestedIP) {
                         // SELECTING state
-                        if (myIP.equals(serverIP.toString()) &&
-                                dhcpStore.assignIP(clientMAC, requestedIP, leaseTime)) {
+                        if (myIP.equals(serverIP) &&
+                                dhcpStore.assignIP(hostId, requestedIP, leaseTime)) {
 
-                            Ethernet ethReply = buildReply(packet, requestedIP.toString(),
+                            Ethernet ethReply = buildReply(packet, requestedIP,
                                     (byte) outgoingPacketType.getValue());
                             sendReply(context, ethReply);
                             discoverHost(context, requestedIP);
                         }
                     } else if (flagIfRequestedIP) {
                         // INIT-REBOOT state
-                        if (dhcpStore.assignIP(clientMAC, requestedIP, leaseTime)) {
-                            Ethernet ethReply = buildReply(packet, requestedIP.toString(),
+                        if (dhcpStore.assignIP(hostId, requestedIP, leaseTime)) {
+                            Ethernet ethReply = buildReply(packet, requestedIP,
                                     (byte) outgoingPacketType.getValue());
                             sendReply(context, ethReply);
                             discoverHost(context, requestedIP);
@@ -474,17 +472,16 @@ public class DhcpManager implements DhcpService {
                         int ciaadr = dhcpPayload.getClientIPAddress();
                         if (ciaadr != 0) {
                             Ip4Address clientIaddr = Ip4Address.valueOf(ciaadr);
-                            if (dhcpStore.assignIP(clientMAC, clientIaddr, leaseTime)) {
-                                Ethernet ethReply = buildReply(packet, clientIaddr.toString(),
+                            if (dhcpStore.assignIP(hostId, clientIaddr, leaseTime)) {
+                                Ethernet ethReply = buildReply(packet, clientIaddr,
                                         (byte) outgoingPacketType.getValue());
                                 sendReply(context, ethReply);
                                 discoverHost(context, clientIaddr);
                             }
                         }
                     }
-                } else if (incomingPacketType == DHCPPacketType.DHCPRELEASE.getValue()) {
-
-                    dhcpStore.releaseIP(clientMAC);
+                } else if (incomingPacketType.getValue() == DHCPPacketType.DHCPRELEASE.getValue()) {
+                    dhcpStore.releaseIP(hostId);
                 }
             }
         }
@@ -540,7 +537,6 @@ public class DhcpManager implements DhcpService {
 
         @Override
         public void process(PacketContext context) {
-
             Ethernet packet = context.inPacket().parsed();
             if (packet == null) {
                 return;
@@ -564,7 +560,7 @@ public class DhcpManager implements DhcpService {
                 ARP arpPacket = (ARP) packet.getPayload();
 
                 if ((arpPacket.getOpCode() == ARP.OP_REQUEST) &&
-                        (Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()).toString().equals(myIP))) {
+                        Objects.equals(myIP, Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()))) {
 
                     processARPPacket(context, packet);
 
@@ -581,12 +577,14 @@ public class DhcpManager implements DhcpService {
          * @param cfg configuration object
          */
         private void reconfigureNetwork(DhcpConfig cfg) {
-
+            if (cfg == null) {
+                return;
+            }
             if (cfg.ip() != null) {
                 myIP = cfg.ip();
             }
             if (cfg.mac() != null) {
-                myMAC = MacAddress.valueOf(cfg.mac());
+                myMAC = cfg.mac();
             }
             if (cfg.subnetMask() != null) {
                 subnetMask = cfg.subnetMask();
@@ -600,54 +598,40 @@ public class DhcpManager implements DhcpService {
             if (cfg.domainServer() != null) {
                 domainServer = cfg.domainServer();
             }
-            if (cfg.ttl() != null) {
-                packetTTL = Byte.valueOf(cfg.ttl());
+            if (cfg.ttl() != -1) {
+                packetTTL = (byte) cfg.ttl();
             }
-            if (cfg.leaseTime() != null) {
-                leaseTime = Integer.valueOf(cfg.leaseTime());
+            if (cfg.leaseTime() != -1) {
+                leaseTime = cfg.leaseTime();
             }
-            if (cfg.renewTime() != null) {
-                renewalTime = Integer.valueOf(cfg.renewTime());
+            if (cfg.renewTime() != -1) {
+                renewalTime = cfg.renewTime();
             }
-            if (cfg.rebindTime() != null) {
-                rebindingTime = Integer.valueOf(cfg.rebindTime());
+            if (cfg.rebindTime() != -1) {
+                rebindingTime = cfg.rebindTime();
             }
-        }
-
-        /**
-         * Reconfigures the DHCP Store according to the configuration parameters passed.
-         *
-         * @param cfg configuration object
-         */
-        private void reconfigureStore(DhcpStoreConfig cfg) {
-
-            if (cfg.defaultTimeout() != null) {
-                dhcpStore.setDefaultTimeoutForPurge(Integer.valueOf(cfg.defaultTimeout()));
+            if (cfg.defaultTimeout() != -1) {
+                dhcpStore.setDefaultTimeoutForPurge(cfg.defaultTimeout());
             }
-            if (cfg.timerDelay() != null) {
-                dhcpStore.setTimerDelay(Integer.valueOf(cfg.defaultTimeout()));
+            if (cfg.timerDelay() != -1) {
+                timerDelay = cfg.timerDelay();
             }
-            if ((cfg.startIP() != null) && (cfg.endIP() != null)) {
-                dhcpStore.populateIPPoolfromRange(Ip4Address.valueOf(cfg.startIP()),
-                        Ip4Address.valueOf(cfg.endIP()));
+            if ((cfg.startIp() != null) && (cfg.endIp() != null)) {
+                dhcpStore.populateIPPoolfromRange(cfg.startIp(), cfg.endIp());
             }
         }
 
+
         @Override
         public void event(NetworkConfigEvent event) {
 
             if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
-                    event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)) {
-                if (event.configClass().equals(DhcpConfig.class)) {
-                    DhcpConfig cfg = cfgService.getConfig(appId, DhcpConfig.class);
-                    reconfigureNetwork(cfg);
-                    log.info("Reconfigured Manager");
-                }
-                if (event.configClass().equals(DhcpStoreConfig.class)) {
-                    DhcpStoreConfig cfg = cfgService.getConfig(appId, DhcpStoreConfig.class);
-                    reconfigureStore(cfg);
-                    log.info("Reconfigured Store");
-                }
+                    event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) &&
+                    event.configClass().equals(DhcpConfig.class)) {
+
+                DhcpConfig cfg = cfgService.getConfig(appId, DhcpConfig.class);
+                reconfigureNetwork(cfg);
+                log.info("Reconfigured");
             }
         }
     }
@@ -666,4 +650,28 @@ public class DhcpManager implements DhcpService {
             // nothing to do
         }
     }
+
+    private class PurgeListTask implements TimerTask {
+
+        @Override
+        public void run(Timeout to) {
+            IpAssignment ipAssignment;
+            Date dateNow = new Date();
+
+            Map<HostId, IpAssignment> ipAssignmentMap = dhcpStore.listAllMapping();
+            for (Map.Entry<HostId, IpAssignment> entry: ipAssignmentMap.entrySet()) {
+                ipAssignment = entry.getValue();
+
+                long timeLapsed = dateNow.getTime() - ipAssignment.timestamp().getTime();
+                if ((ipAssignment.assignmentStatus() != IpAssignment.AssignmentStatus.Option_Expired) &&
+                        (ipAssignment.leasePeriod() > 0) && (timeLapsed > (ipAssignment.leasePeriodMs()))) {
+
+                    dhcpStore.releaseIP(entry.getKey());
+                    // TODO remove only the IP from the host entry when the API is in place.
+                    hostProviderService.hostVanished(entry.getKey());
+                }
+            }
+            timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);
+        }
+    }
 }
\ No newline at end of file
index 89ed572..9ce65d5 100644 (file)
@@ -17,10 +17,10 @@ package org.onosproject.dhcp.impl;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.ImmutableSet;
-import org.onlab.packet.MacAddress;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.dhcp.DhcpService;
 import org.onosproject.dhcp.IpAssignment;
+import org.onosproject.net.HostId;
 import org.onosproject.ui.RequestHandler;
 import org.onosproject.ui.UiMessageHandler;
 import org.onosproject.ui.table.TableModel;
@@ -39,12 +39,12 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
     private static final String DHCP_DATA_RESP = "dhcpDataResponse";
     private static final String DHCP = "dhcps";
 
-    private static final String MAC = "mac";
+    private static final String HOST = "host";
     private static final String IP = "ip";
     private static final String LEASE = "lease";
 
     private static final String[] COL_IDS = {
-            MAC, IP, LEASE
+            HOST, IP, LEASE
     };
 
     @Override
@@ -54,6 +54,7 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
         );
     }
 
+    // handler for dhcp table requests
     private final class DataRequestHandler extends TableRequestHandler {
 
         private DataRequestHandler() {
@@ -62,7 +63,7 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
 
         @Override
         protected String defaultColumnId() {
-            return MAC;
+            return HOST;
         }
 
         @Override
@@ -73,21 +74,21 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
         @Override
         protected void populateTable(TableModel tm, ObjectNode payload) {
             DhcpService dhcpService = AbstractShellCommand.get(DhcpService.class);
-            Map<MacAddress, IpAssignment> allocationMap = dhcpService.listMapping();
+            Map<HostId, IpAssignment> allocationMap = dhcpService.listMapping();
 
-            for (Map.Entry<MacAddress, IpAssignment> entry : allocationMap.entrySet()) {
+            for (Map.Entry<HostId, IpAssignment> entry : allocationMap.entrySet()) {
                 populateRow(tm.addRow(), entry);
             }
         }
 
-        private void populateRow(TableModel.Row row, Map.Entry<MacAddress, IpAssignment> entry) {
+        private void populateRow(TableModel.Row row, Map.Entry<HostId, IpAssignment> entry) {
             if (entry.getValue().leasePeriod() > 0) {
                 Date now = new Date(entry.getValue().timestamp().getTime() + entry.getValue().leasePeriod());
-                row.cell(MAC, entry.getKey())
+                row.cell(HOST, entry.getKey())
                         .cell(IP, entry.getValue().ipAddress())
                         .cell(LEASE, now.toString());
             } else {
-                row.cell(MAC, entry.getKey())
+                row.cell(HOST, entry.getKey())
                         .cell(IP, entry.getValue().ipAddress())
                         .cell(LEASE, "Infinite Static Lease");
             }
index 6e29216..dbdadb3 100644 (file)
@@ -22,14 +22,12 @@ import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.Service;
-import org.jboss.netty.util.Timeout;
-import org.jboss.netty.util.TimerTask;
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.MacAddress;
 import org.onlab.util.KryoNamespace;
-import org.onlab.util.Timer;
 import org.onosproject.dhcp.DhcpStore;
 import org.onosproject.dhcp.IpAssignment;
+import org.onosproject.net.HostId;
 import org.onosproject.store.serializers.KryoNamespaces;
 import org.onosproject.store.service.ConsistentMap;
 import org.onosproject.store.service.DistributedSet;
@@ -42,7 +40,7 @@ import org.slf4j.LoggerFactory;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
+import java.util.Objects;
 
 /**
  * Manages the pool of available IP Addresses in the network and
@@ -58,25 +56,21 @@ public class DistributedDhcpStore implements DhcpStore {
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected StorageService storageService;
 
-    private ConsistentMap<MacAddress, IpAssignment> allocationMap;
+    private ConsistentMap<HostId, IpAssignment> allocationMap;
 
     private DistributedSet<Ip4Address> freeIPPool;
 
-    private Timeout timeout;
-
     private static Ip4Address startIPRange;
 
     private static Ip4Address endIPRange;
 
     // Hardcoded values are default values.
 
-    private static int timerDelay = 2;
-
     private static int timeoutForPendingAssignments = 60;
 
     @Activate
     protected void activate() {
-        allocationMap = storageService.<MacAddress, IpAssignment>consistentMapBuilder()
+        allocationMap = storageService.<HostId, IpAssignment>consistentMapBuilder()
                 .withName("onos-dhcp-assignedIP")
                 .withSerializer(Serializer.using(
                         new KryoNamespace.Builder()
@@ -94,30 +88,27 @@ public class DistributedDhcpStore implements DhcpStore {
                 .withSerializer(Serializer.using(KryoNamespaces.API))
                 .build();
 
-        timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);
-
         log.info("Started");
     }
 
     @Deactivate
     protected void deactivate() {
-        timeout.cancel();
         log.info("Stopped");
     }
 
     @Override
-    public Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP) {
+    public Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP) {
 
         IpAssignment assignmentInfo;
-        if (allocationMap.containsKey(macID)) {
-            assignmentInfo = allocationMap.get(macID).value();
+        if (allocationMap.containsKey(hostId)) {
+            assignmentInfo = allocationMap.get(hostId).value();
             IpAssignment.AssignmentStatus status = assignmentInfo.assignmentStatus();
             Ip4Address ipAddr = assignmentInfo.ipAddress();
 
             if (status == IpAssignment.AssignmentStatus.Option_Assigned ||
                     status == IpAssignment.AssignmentStatus.Option_Requested) {
                 // Client has a currently Active Binding.
-                if ((ipAddr.toInt() > startIPRange.toInt()) && (ipAddr.toInt() < endIPRange.toInt())) {
+                if (ipWithinRange(ipAddr)) {
                     return ipAddr;
                 }
 
@@ -131,13 +122,11 @@ public class DistributedDhcpStore implements DhcpStore {
                             .assignmentStatus(IpAssignment.AssignmentStatus.Option_Requested)
                             .build();
                     if (freeIPPool.remove(ipAddr)) {
-                        allocationMap.put(macID, assignmentInfo);
+                        allocationMap.put(hostId, assignmentInfo);
                         return ipAddr;
                     }
                 }
             }
-            return assignmentInfo.ipAddress();
-
         } else if (requestedIP.toInt() != 0) {
             // Client has requested an IP.
             if (freeIPPool.contains(requestedIP)) {
@@ -148,7 +137,7 @@ public class DistributedDhcpStore implements DhcpStore {
                         .assignmentStatus(IpAssignment.AssignmentStatus.Option_Requested)
                         .build();
                 if (freeIPPool.remove(requestedIP)) {
-                    allocationMap.put(macID, assignmentInfo);
+                    allocationMap.put(hostId, assignmentInfo);
                     return requestedIP;
                 }
             }
@@ -156,35 +145,56 @@ public class DistributedDhcpStore implements DhcpStore {
 
         // Allocate a new IP from the server's pool of available IP.
         Ip4Address nextIPAddr = fetchNextIP();
-        assignmentInfo = IpAssignment.builder()
-                                    .ipAddress(nextIPAddr)
-                                    .timestamp(new Date())
-                                    .leasePeriod(timeoutForPendingAssignments)
-                                    .assignmentStatus(IpAssignment.AssignmentStatus.Option_Requested)
-                                    .build();
+        if (nextIPAddr != null) {
+            assignmentInfo = IpAssignment.builder()
+                    .ipAddress(nextIPAddr)
+                    .timestamp(new Date())
+                    .leasePeriod(timeoutForPendingAssignments)
+                    .assignmentStatus(IpAssignment.AssignmentStatus.Option_Requested)
+                    .build();
 
-        allocationMap.put(macID, assignmentInfo);
+            allocationMap.put(hostId, assignmentInfo);
+        }
         return nextIPAddr;
 
     }
 
     @Override
-    public boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime) {
+    public boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime) {
 
         IpAssignment assignmentInfo;
-        if (allocationMap.containsKey(macID)) {
-            assignmentInfo = allocationMap.get(macID).value();
-            if ((assignmentInfo.ipAddress().toInt() == ipAddr.toInt()) &&
-                    (ipAddr.toInt() > startIPRange.toInt()) && (ipAddr.toInt() < endIPRange.toInt())) {
+        if (allocationMap.containsKey(hostId)) {
+            assignmentInfo = allocationMap.get(hostId).value();
+            IpAssignment.AssignmentStatus status = assignmentInfo.assignmentStatus();
 
-                assignmentInfo = IpAssignment.builder()
-                        .ipAddress(ipAddr)
-                        .timestamp(new Date())
-                        .leasePeriod(leaseTime)
-                        .assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
-                        .build();
-                allocationMap.put(macID, assignmentInfo);
-                return true;
+            if (Objects.equals(assignmentInfo.ipAddress(), ipAddr) && ipWithinRange(ipAddr)) {
+
+                if (status == IpAssignment.AssignmentStatus.Option_Assigned ||
+                        status == IpAssignment.AssignmentStatus.Option_Requested) {
+                    // Client has a currently active binding with the server.
+                    assignmentInfo = IpAssignment.builder()
+                            .ipAddress(ipAddr)
+                            .timestamp(new Date())
+                            .leasePeriod(leaseTime)
+                            .assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
+                            .build();
+                    allocationMap.put(hostId, assignmentInfo);
+                    return true;
+                } else if (status == IpAssignment.AssignmentStatus.Option_Expired) {
+                    // Client has an expired binding with the server.
+                    if (freeIPPool.contains(ipAddr)) {
+                        assignmentInfo = IpAssignment.builder()
+                                .ipAddress(ipAddr)
+                                .timestamp(new Date())
+                                .leasePeriod(leaseTime)
+                                .assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
+                                .build();
+                        if (freeIPPool.remove(ipAddr)) {
+                            allocationMap.put(hostId, assignmentInfo);
+                            return true;
+                        }
+                    }
+                }
             }
         } else if (freeIPPool.contains(ipAddr)) {
             assignmentInfo = IpAssignment.builder()
@@ -194,7 +204,7 @@ public class DistributedDhcpStore implements DhcpStore {
                                     .assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
                                     .build();
             if (freeIPPool.remove(ipAddr)) {
-                allocationMap.put(macID, assignmentInfo);
+                allocationMap.put(hostId, assignmentInfo);
                 return true;
             }
         }
@@ -202,14 +212,16 @@ public class DistributedDhcpStore implements DhcpStore {
     }
 
     @Override
-    public void releaseIP(MacAddress macID) {
-        if (allocationMap.containsKey(macID)) {
-            IpAssignment newAssignment = IpAssignment.builder(allocationMap.get(macID).value())
+    public void releaseIP(HostId hostId) {
+        if (allocationMap.containsKey(hostId)) {
+            IpAssignment newAssignment = IpAssignment.builder(allocationMap.get(hostId).value())
                                                     .assignmentStatus(IpAssignment.AssignmentStatus.Option_Expired)
                                                     .build();
             Ip4Address freeIP = newAssignment.ipAddress();
-            allocationMap.put(macID, newAssignment);
-            freeIPPool.add(freeIP);
+            allocationMap.put(hostId, newAssignment);
+            if (ipWithinRange(freeIP)) {
+                freeIPPool.add(freeIP);
+            }
         }
     }
 
@@ -219,37 +231,45 @@ public class DistributedDhcpStore implements DhcpStore {
     }
 
     @Override
-    public void setTimerDelay(int timeInSeconds) {
-        timerDelay = timeInSeconds;
-    }
+    public Map<HostId, IpAssignment> listAssignedMapping() {
 
-    @Override
-    public Map<MacAddress, IpAssignment> listMapping() {
-
-        Map<MacAddress, IpAssignment> allMapping = new HashMap<>();
-        for (Map.Entry<MacAddress, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
-            IpAssignment assignment = entry.getValue().value();
+        Map<HostId, IpAssignment> validMapping = new HashMap<>();
+        IpAssignment assignment;
+        for (Map.Entry<HostId, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
+            assignment = entry.getValue().value();
             if (assignment.assignmentStatus() == IpAssignment.AssignmentStatus.Option_Assigned) {
-                allMapping.put(entry.getKey(), assignment);
+                validMapping.put(entry.getKey(), assignment);
             }
         }
-        return allMapping;
+        return validMapping;
+    }
 
+    @Override
+    public Map<HostId, IpAssignment> listAllMapping() {
+        Map<HostId, IpAssignment> validMapping = new HashMap<>();
+        for (Map.Entry<HostId, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
+            validMapping.put(entry.getKey(), entry.getValue().value());
+        }
+        return validMapping;
     }
 
     @Override
     public boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr) {
-        return assignIP(macID, ipAddr, -1);
+        HostId host = HostId.hostId(macID);
+        return assignIP(host, ipAddr, -1);
     }
 
     @Override
     public boolean removeStaticIP(MacAddress macID) {
-        if (allocationMap.containsKey(macID)) {
-            IpAssignment assignment = allocationMap.get(macID).value();
+        HostId host = HostId.hostId(macID);
+        if (allocationMap.containsKey(host)) {
+            IpAssignment assignment = allocationMap.get(host).value();
             Ip4Address freeIP = assignment.ipAddress();
             if (assignment.leasePeriod() < 0) {
-                allocationMap.remove(macID);
-                freeIPPool.add(freeIP);
+                allocationMap.remove(host);
+                if (ipWithinRange(freeIP)) {
+                    freeIPPool.add(freeIP);
+                }
                 return true;
             }
         }
@@ -258,15 +278,16 @@ public class DistributedDhcpStore implements DhcpStore {
 
     @Override
     public Iterable<Ip4Address> getAvailableIPs() {
-        return ImmutableSet.<Ip4Address>copyOf(freeIPPool);
+        return ImmutableSet.copyOf(freeIPPool);
     }
 
     @Override
     public void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP) {
         // Clear all entries from previous range.
+        allocationMap.clear();
+        freeIPPool.clear();
         startIPRange = startIP;
         endIPRange = endIP;
-        freeIPPool.clear();
 
         int lastIP = endIP.toInt();
         Ip4Address nextIP;
@@ -291,34 +312,15 @@ public class DistributedDhcpStore implements DhcpStore {
     }
 
     /**
-     * Purges the IP allocation map to remove expired entries and returns the freed IPs to the free pool.
+     * Returns true if the given ip is within the range of available IPs.
+     *
+     * @param ip given ip address
+     * @return true if within range, false otherwise
      */
-    private class PurgeListTask implements TimerTask {
-
-        @Override
-        public void run(Timeout to) {
-            IpAssignment ipAssignment, newAssignment;
-            Date dateNow = new Date();
-            for (Map.Entry<MacAddress, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
-                ipAssignment = entry.getValue().value();
-                long timeLapsed = dateNow.getTime() - ipAssignment.timestamp().getTime();
-                if ((ipAssignment.assignmentStatus() != IpAssignment.AssignmentStatus.Option_Expired) &&
-                        (ipAssignment.leasePeriod() > 0) && (timeLapsed > (ipAssignment.leasePeriod()))) {
-                    Ip4Address freeIP = ipAssignment.ipAddress();
-
-                    newAssignment = IpAssignment.builder(ipAssignment)
-                            .assignmentStatus(IpAssignment.AssignmentStatus.Option_Expired)
-                            .build();
-                    allocationMap.put(entry.getKey(), newAssignment);
-
-                    if ((freeIP.toInt() > startIPRange.toInt()) && (freeIP.toInt() < endIPRange.toInt())) {
-                        freeIPPool.add(freeIP);
-                    }
-                }
-            }
-            timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);
+    private boolean ipWithinRange(Ip4Address ip) {
+        if ((ip.toInt() >= startIPRange.toInt()) && (ip.toInt() <= endIPRange.toInt())) {
+            return true;
         }
-
+        return false;
     }
-
 }
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java
new file mode 100644 (file)
index 0000000..12e14e4
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation classes for sample application that assigns and manages DHCP leases.
+ */
+package org.onosproject.dhcp.impl;
\ No newline at end of file
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java
new file mode 100644 (file)
index 0000000..56778a3
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Sample application that assigns and manages DHCP leases.
+ */
+package org.onosproject.dhcp;
\ No newline at end of file
index bfa2767..646ab7e 100644 (file)
@@ -22,6 +22,7 @@ import org.onlab.packet.Ip4Address;
 import org.onlab.packet.MacAddress;
 import org.onosproject.dhcp.DhcpService;
 import org.onosproject.dhcp.IpAssignment;
+import org.onosproject.net.HostId;
 import org.onosproject.rest.AbstractWebResource;
 
 import javax.ws.rs.Consumes;
@@ -72,10 +73,10 @@ public class DHCPWebResource extends AbstractWebResource {
     public Response listMappings() {
         ObjectNode root = mapper().createObjectNode();
 
-        final Map<MacAddress, IpAssignment> intents = service.listMapping();
+        final Map<HostId, IpAssignment> intents = service.listMapping();
         ArrayNode arrayNode = root.putArray("mappings");
         intents.entrySet().forEach(i -> arrayNode.add(mapper().createObjectNode()
-                .put("mac", i.getKey().toString())
+                .put("host", i.getKey().toString())
                 .put("ip", i.getValue().ipAddress().toString())));
 
         return ok(root.toString()).build();
@@ -125,10 +126,10 @@ public class DHCPWebResource extends AbstractWebResource {
                 }
             }
 
-            final Map<MacAddress, IpAssignment> intents = service.listMapping();
+            final Map<HostId, IpAssignment> intents = service.listMapping();
             ArrayNode arrayNode = root.putArray("mappings");
             intents.entrySet().forEach(i -> arrayNode.add(mapper().createObjectNode()
-                    .put("mac", i.getKey().toString())
+                    .put("host", i.getKey().toString())
                     .put("ip", i.getValue().ipAddress().toString())));
         } catch (IOException e) {
             throw new IllegalArgumentException(e.getMessage());
@@ -152,10 +153,10 @@ public class DHCPWebResource extends AbstractWebResource {
         if (!service.removeStaticMapping(MacAddress.valueOf(macID))) {
             throw new IllegalArgumentException("Static Mapping Removal Failed.");
         }
-        final Map<MacAddress, IpAssignment> intents = service.listMapping();
+        final Map<HostId, IpAssignment> intents = service.listMapping();
         ArrayNode arrayNode = root.putArray("mappings");
         intents.entrySet().forEach(i -> arrayNode.add(mapper().createObjectNode()
-                .put("mac", i.getKey().toString())
+                .put("host", i.getKey().toString())
                 .put("ip", i.getValue().ipAddress().toString())));
 
         return ok(root.toString()).build();
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java
new file mode 100644 (file)
index 0000000..73173c5
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * REST APIs for sample application that assigns and manages DHCP leases.
+ */
+package org.onosproject.dhcp.rest;
\ No newline at end of file
index 3e14570..5782bad 100644 (file)
@@ -17,7 +17,7 @@
     <div class="table-header" onos-sortable-header>
       <table>
         <tr>
-          <td colId="mac" sortable>MAC Address</td>
+          <td colId="host" sortable>Host ID</td>
           <td colId="ip" sortable>IP Address</td>
           <td colId="lease" sortable>Lease Expiry</td>
         </tr>
@@ -25,7 +25,7 @@
     </div>
 
     <div class="table-body">
-      <table onos-flash-changes id-prop="mac">
+      <table onos-flash-changes id-prop="host">
         <tr ng-if="!tableData.length" class="no-data">
           <td colspan="2">
             No mappings found
@@ -34,8 +34,8 @@
 
         <tr ng-repeat="dhcp in tableData track by $index"
             ng-click="selectCallback($event, dhcp)"
-            ng-repeat-complete row-id="{{dhcp.mac}}">
-          <td>{{dhcp.mac}}</td>
+            ng-repeat-complete row-id="{{dhcp.host}}">
+          <td>{{dhcp.host}}</td>
           <td>{{dhcp.ip}}</td>
           <td>{{dhcp.lease}}</td>
         </tr>
index dad5ef5..3ecc5cf 100644 (file)
@@ -16,7 +16,6 @@
 package org.onosproject.dhcp;
 
 import com.google.common.testing.EqualsTester;
-import junit.framework.TestCase;
 import org.junit.Assert;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
@@ -31,7 +30,7 @@ import static org.junit.Assert.fail;
 /**
  * Unit Tests for IPAssignment class.
  */
-public class IpAssignmentTest extends TestCase {
+public class IpAssignmentTest {
 
     private final Date dateNow = new Date();
 
@@ -98,4 +97,4 @@ public class IpAssignmentTest extends TestCase {
             Assert.assertThat(e.getMessage(), containsString("must be specified"));
         }
     }
-}
\ No newline at end of file
+}
index 42ac73d..3ea3b1b 100644 (file)
@@ -72,7 +72,7 @@ public class DhcpManagerTest {
 
     protected HostProviderService hostProviderService;
 
-    private static final MacAddress CLIENT1_MAC = MacAddress.valueOf("1a:1a:1a:1a:1a:1a");
+    private static final HostId CLIENT1_HOST = HostId.hostId(MacAddress.valueOf("1a:1a:1a:1a:1a:1a"));
 
     private static final String EXPECTED_IP = "10.2.0.2";
 
@@ -141,7 +141,7 @@ public class DhcpManagerTest {
 
         // Ethernet Frame.
         Ethernet ethReply = new Ethernet();
-        ethReply.setSourceMACAddress(CLIENT1_MAC);
+        ethReply.setSourceMACAddress(CLIENT1_HOST.mac());
         ethReply.setDestinationMACAddress(MacAddress.BROADCAST);
         ethReply.setEtherType(Ethernet.TYPE_IPV4);
         ethReply.setVlanID((short) 2);
@@ -165,7 +165,7 @@ public class DhcpManagerTest {
         dhcpReply.setServerIPAddress(0);
 
         dhcpReply.setTransactionId(TRANSACTION_ID);
-        dhcpReply.setClientHardwareAddress(CLIENT1_MAC.toBytes());
+        dhcpReply.setClientHardwareAddress(CLIENT1_HOST.mac().toBytes());
         dhcpReply.setHardwareType(DHCP.HWTYPE_ETHERNET);
         dhcpReply.setHardwareAddressLength((byte) 6);
 
@@ -209,7 +209,7 @@ public class DhcpManagerTest {
      */
     private void validatePacket(Ethernet packet) {
         DHCP dhcpPacket = (DHCP) packet.getPayload().getPayload().getPayload();
-        assertEquals(MacAddress.valueOf(dhcpPacket.getClientHardwareAddress()), CLIENT1_MAC);
+        assertEquals(MacAddress.valueOf(dhcpPacket.getClientHardwareAddress()), CLIENT1_HOST.mac());
         assertEquals(Ip4Address.valueOf(dhcpPacket.getYourIPAddress()), Ip4Address.valueOf(EXPECTED_IP));
         assertEquals(dhcpPacket.getTransactionId(), TRANSACTION_ID);
     }
@@ -223,32 +223,33 @@ public class DhcpManagerTest {
         public void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP) {
         }
 
-        public Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP) {
+        public Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP) {
             return Ip4Address.valueOf(EXPECTED_IP);
         }
 
-        public boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime) {
+        public boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime) {
             return true;
         }
 
         public void setDefaultTimeoutForPurge(int timeInSeconds) {
         }
 
-        public void setTimerDelay(int timeInSeconds) {
+        public void releaseIP(HostId hostId) {
         }
 
-        public void releaseIP(MacAddress macID) {
+        public Map<HostId, IpAssignment> listAssignedMapping() {
+            return listAllMapping();
         }
 
-        public Map<MacAddress, IpAssignment> listMapping() {
-            Map<MacAddress, IpAssignment> map = new HashMap<>();
+        public Map<HostId, IpAssignment> listAllMapping() {
+            Map<HostId, IpAssignment> map = new HashMap<>();
             IpAssignment assignment = IpAssignment.builder()
                                         .ipAddress(Ip4Address.valueOf(EXPECTED_IP))
                                         .assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
                                         .leasePeriod(300)
                                         .timestamp(new Date())
                                         .build();
-            map.put(CLIENT1_MAC, assignment);
+            map.put(CLIENT1_HOST, assignment);
             return map;
         }
 
@@ -329,7 +330,7 @@ public class DhcpManagerTest {
         }
 
         @Override
-        public void hostDetected(HostId hostId, HostDescription hostDescription) {
+        public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) {
         }
 
         @Override
index 8ce5486..abc48a8 100644 (file)
@@ -11,9 +11,7 @@
         "ttl": "63",
         "lease": "300",
         "renew": "150",
-        "rebind": "200"
-      },
-      "dhcpstore" : {
+        "rebind": "200",
         "delay": "3",
         "timeout": "150",
         "startip": "10.0.0.110",
index e068be6..f5dfcf2 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 324f46c..977a75a 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 89757c9..8a39990 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 78a540c..9a42e9e 100644 (file)
@@ -107,7 +107,7 @@ public class IntentMetrics implements IntentMetricsService,
     @Override
     public List<IntentEvent> getEvents() {
         synchronized (lastEvents) {
-            return ImmutableList.<IntentEvent>copyOf(lastEvents);
+            return ImmutableList.copyOf(lastEvents);
         }
     }
 
index 5785f5f..fb984c9 100644 (file)
@@ -138,7 +138,7 @@ public class TopologyMetrics implements TopologyMetricsService {
     @Override
     public List<Event> getEvents() {
         synchronized (lastEvents) {
-            return ImmutableList.<Event>copyOf(lastEvents);
+            return ImmutableList.copyOf(lastEvents);
         }
     }
 
index bc50813..59fd666 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index a2a7b96..180e026 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index ac298e0..9ae6f85 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index f3f8d17..2ef5cd5 100644 (file)
@@ -34,8 +34,8 @@ public class OpticalNetworkConfig {
     private List<OpticalLinkDescription> opticalLinks;
 
     public OpticalNetworkConfig() {
-        opticalSwitches = new ArrayList<OpticalSwitchDescription>();
-        opticalLinks = new ArrayList<OpticalLinkDescription>();
+        opticalSwitches = new ArrayList<>();
+        opticalLinks = new ArrayList<>();
     }
 
     public List<OpticalSwitchDescription> getOpticalSwitches() {
index 80b4a43..5e87167 100644 (file)
@@ -1,12 +1,29 @@
-<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/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.onosproject</groupId>
-    <artifactId>onos-apps</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
-  </parent>
-  <artifactId>onos-app-pcep-api</artifactId>
-  <packaging>bundle</packaging>
+<!--
+  ~ 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.
+  -->
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-apps</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>onos-app-pcep-api</artifactId>
+    <packaging>bundle</packaging>
 
-  <description>PCEP protocol API</description>
+    <description>PCEP protocol API</description>
 </project>
\ No newline at end of file
index e5ceddd..334c690 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
@@ -37,7 +37,6 @@
         <module>fwd</module>
         <module>mobility</module>
         <module>proxyarp</module>
-        <module>config</module>
         <module>sdnip</module>
         <module>optical</module>
         <module>metrics</module>
@@ -58,7 +57,8 @@
         <module>vtn</module>
         <module>vtnweb</module>
         <module>dhcp</module>
-    </modules>
+        <module>cordvtn</module>
+  </modules>
 
     <properties>
         <web.context>default</web.context>
index e6e7658..69f64dd 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 742d7af..2eb96df 100644 (file)
@@ -82,7 +82,7 @@ public class ProxyArp {
 
         packetService.addProcessor(processor, PacketProcessor.director(1));
         readComponentConfiguration(context);
-        requestPackests();
+        requestPackets();
 
         log.info("Started with Application ID {}", appId.id());
     }
@@ -99,13 +99,13 @@ public class ProxyArp {
     @Modified
     public void modified(ComponentContext context) {
         readComponentConfiguration(context);
-        requestPackests();
+        requestPackets();
     }
 
     /**
      * Request packet in via PacketService.
      */
-    private void requestPackests() {
+    private void requestPackets() {
         TrafficSelector.Builder selectorBuilder =
                 DefaultTrafficSelector.builder();
         selectorBuilder.matchEthType(TYPE_ARP);
index 1d93cbf..58fb91e 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 1b9fc2f..48fc292 100644 (file)
@@ -20,7 +20,7 @@
     <parent>
         <artifactId>onos-apps</artifactId>
         <groupId>org.onosproject</groupId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
index d6f6e57..8d563b8 100644 (file)
@@ -21,7 +21,6 @@ import org.onlab.packet.MacAddress;
 import org.onlab.packet.VlanId;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
 
 import java.util.Objects;
 import java.util.Set;
@@ -54,18 +53,6 @@ public class Interface {
         this.vlan = vlan;
     }
 
-    /**
-     * Creates an Interface based on a PortAddresses object.
-     *
-     * @param portAddresses the PortAddresses object to turn into an Interface
-     */
-    public Interface(PortAddresses portAddresses) {
-        connectPoint = portAddresses.connectPoint();
-        ipAddresses = Sets.newHashSet(portAddresses.ipAddresses());
-        macAddress = portAddresses.mac();
-        vlan = portAddresses.vlan();
-    }
-
     /**
      * Retrieves the connection point that this interface maps to.
      *
index 1d9f19b..c461ef3 100644 (file)
@@ -20,7 +20,7 @@
     <parent>
         <artifactId>onos-apps</artifactId>
         <groupId>org.onosproject</groupId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
index 57481c2..ab8a049 100644 (file)
@@ -300,21 +300,18 @@ public class BgpSessionManager implements BgpInfoService, BgpService {
         ChannelFactory channelFactory = new NioServerSocketChannelFactory(
                 newCachedThreadPool(groupedThreads("onos/bgp", "sm-boss-%d")),
                 newCachedThreadPool(groupedThreads("onos/bgp", "sm-worker-%d")));
-        ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {
-            @Override
-            public ChannelPipeline getPipeline() throws Exception {
-                // Allocate a new session per connection
-                BgpSession bgpSessionHandler =
-                        new BgpSession(BgpSessionManager.this);
-                BgpFrameDecoder bgpFrameDecoder =
-                        new BgpFrameDecoder(bgpSessionHandler);
-
-                // Setup the processing pipeline
-                ChannelPipeline pipeline = Channels.pipeline();
-                pipeline.addLast("BgpFrameDecoder", bgpFrameDecoder);
-                pipeline.addLast("BgpSession", bgpSessionHandler);
-                return pipeline;
-            }
+        ChannelPipelineFactory pipelineFactory = () -> {
+            // Allocate a new session per connection
+            BgpSession bgpSessionHandler =
+                    new BgpSession(BgpSessionManager.this);
+            BgpFrameDecoder bgpFrameDecoder =
+                    new BgpFrameDecoder(bgpSessionHandler);
+
+            // Setup the processing pipeline
+            ChannelPipeline pipeline = Channels.pipeline();
+            pipeline.addLast("BgpFrameDecoder", bgpFrameDecoder);
+            pipeline.addLast("BgpSession", bgpSessionHandler);
+            return pipeline;
         };
         InetSocketAddress listenAddress =
                 new InetSocketAddress(bgpPort);
index 1078319..0a6f9d4 100644 (file)
@@ -38,7 +38,6 @@ import org.onosproject.net.config.ConfigFactory;
 import org.onosproject.net.config.NetworkConfigRegistry;
 import org.onosproject.net.config.NetworkConfigService;
 import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.net.host.HostService;
 import org.onosproject.routing.config.BgpConfig;
 import org.onosproject.routing.config.BgpPeer;
 import org.onosproject.routing.config.BgpSpeaker;
@@ -75,9 +74,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
     private static final String DEFAULT_CONFIG_FILE = "sdnip.json";
     private String configFileName = DEFAULT_CONFIG_FILE;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected HostService hostService;
-
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected NetworkConfigRegistry registry;
 
@@ -103,7 +99,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
                     new DefaultByteArrayNodeFactory());
 
     private MacAddress virtualGatewayMacAddress;
-    private HostToInterfaceAdaptor hostAdaptor;
 
     private ConfigFactory configFactory =
             new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, BgpConfig.class, "bgp") {
@@ -117,7 +112,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
     public void activate() {
         registry.registerConfigFactory(configFactory);
         readConfiguration();
-        hostAdaptor = new HostToInterfaceAdaptor(hostService);
         log.info("Routing configuration service started");
     }
 
@@ -189,7 +183,7 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
 
     @Override
     public Set<Interface> getInterfaces() {
-        return hostAdaptor.getInterfaces();
+        return Collections.emptySet();
     }
 
     @Override
@@ -212,17 +206,17 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
 
     @Override
     public Interface getInterface(ConnectPoint connectPoint) {
-        return hostAdaptor.getInterface(connectPoint);
+        return null;
     }
 
     @Override
     public Interface getInterface(IpAddress ip) {
-        return hostAdaptor.getInterface(ip);
+        return null;
     }
 
     @Override
     public Interface getMatchingInterface(IpAddress ipAddress) {
-        return hostAdaptor.getMatchingInterface(ipAddress);
+        return null;
     }
 
     @Override
index c4f291b..6700d53 100644 (file)
@@ -159,12 +159,7 @@ public class Router implements RoutingService {
 
         bgpService.start(new InternalRouteListener());
 
-        bgpUpdatesExecutor.execute(new Runnable() {
-            @Override
-            public void run() {
-                doUpdatesThread();
-            }
-        });
+        bgpUpdatesExecutor.execute(this::doUpdatesThread);
     }
 
     @Override
index 634e87b..3f5a6b8 100644 (file)
@@ -151,19 +151,15 @@ public class BgpSessionManagerTest {
                 new NioClientSocketChannelFactory(
                         Executors.newCachedThreadPool(),
                         Executors.newCachedThreadPool());
-            ChannelPipelineFactory pipelineFactory =
-                new ChannelPipelineFactory() {
-                    @Override
-                    public ChannelPipeline getPipeline() throws Exception {
-                        // Setup the transmitting pipeline
-                        ChannelPipeline pipeline = Channels.pipeline();
-                        pipeline.addLast("TestBgpPeerFrameDecoder",
-                                         peerFrameDecoder);
-                        pipeline.addLast("TestBgpPeerChannelHandler",
-                                         peerChannelHandler);
-                        return pipeline;
-                    }
-                };
+            ChannelPipelineFactory pipelineFactory = () -> {
+                // Setup the transmitting pipeline
+                ChannelPipeline pipeline = Channels.pipeline();
+                pipeline.addLast("TestBgpPeerFrameDecoder",
+                        peerFrameDecoder);
+                pipeline.addLast("TestBgpPeerChannelHandler",
+                        peerChannelHandler);
+                return pipeline;
+            };
 
             peerBootstrap = new ClientBootstrap(channelFactory);
             peerBootstrap.setOption("child.keepAlive", true);
index 68b500d..99314aa 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
             <version>${project.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-app-config</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
         <dependency>
             <groupId>org.apache.karaf.shell</groupId>
             <artifactId>org.apache.karaf.shell.console</artifactId>
index 35ff705..d8d8f45 100644 (file)
@@ -887,7 +887,7 @@ public class IntentSynchronizer implements FibListener, IntentRequestListener {
         checkNotNull(dstMacAddress);
         checkNotNull(srcConnectPoint);
 
-        Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
+        Set<ConnectPoint> ingressPoints = new HashSet<>();
         ingressPoints.add(srcConnectPoint);
         IpPrefix dstIpPrefix = dstIpAddress.toIpPrefix();
 
index 3ed4c4f..83ae76d 100644 (file)
@@ -21,7 +21,7 @@
     <parent>
         <artifactId>onos-apps</artifactId>
         <groupId>org.onosproject</groupId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index d82eb5e..ef9d444 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting;
 
 import com.google.common.collect.Lists;
@@ -33,7 +48,7 @@ public class DeviceConfiguration implements DeviceProperties {
 
     private static final Logger log = LoggerFactory
             .getLogger(DeviceConfiguration.class);
-    private final List<Integer> allSegmentIds = new ArrayList<Integer>();
+    private final List<Integer> allSegmentIds = new ArrayList<>();
     private final HashMap<DeviceId, SegmentRouterInfo> deviceConfigMap = new HashMap<>();
     private final NetworkConfigManager configService;
 
@@ -73,7 +88,7 @@ public class DeviceConfiguration implements DeviceProperties {
             info.ip = prefix.address();
             info.isEdge = ((SegmentRouterConfig) cfg).isEdgeRouter();
             info.subnets = new HashMap<>();
-            info.gatewayIps = new HashMap<PortNumber, Ip4Address>();
+            info.gatewayIps = new HashMap<>();
             for (Subnet s: ((SegmentRouterConfig) cfg).getSubnets()) {
                 info.subnets.put(PortNumber.portNumber(s.getPortNo()),
                                  Ip4Prefix.valueOf(s.getSubnetIp()));
@@ -264,8 +279,7 @@ public class DeviceConfiguration implements DeviceProperties {
             log.debug("getSubnetGatewayIps for device{} is {}",
                     deviceId,
                     deviceConfigMap.get(deviceId).gatewayIps.values());
-            return new ArrayList<Ip4Address>(deviceConfigMap.
-                    get(deviceId).gatewayIps.values());
+            return new ArrayList<>(deviceConfigMap.get(deviceId).gatewayIps.values());
         } else {
             return null;
         }
@@ -282,8 +296,7 @@ public class DeviceConfiguration implements DeviceProperties {
             log.debug("getSubnets for device{} is {}",
                     deviceId,
                     deviceConfigMap.get(deviceId).subnets.values());
-            return new ArrayList<Ip4Prefix>(deviceConfigMap.
-                    get(deviceId).subnets.values());
+            return new ArrayList<>(deviceConfigMap.get(deviceId).subnets.values());
         } else {
             return null;
         }
index cd28fcf..2e2041c 100644 (file)
@@ -97,7 +97,7 @@ public class ECMPShortestPathGraph {
                 }
 
                 Integer distance = deviceSearched.get(reachedDevice);
-                if ((distance != null) && (distance.intValue() < (currDistance + 1))) {
+                if ((distance != null) && (distance < (currDistance + 1))) {
                     continue;
                 }
                 if (distance == null) {
@@ -109,7 +109,7 @@ public class ECMPShortestPathGraph {
                     ArrayList<DeviceId> distanceSwArray = distanceDeviceMap
                             .get(currDistance + 1);
                     if (distanceSwArray == null) {
-                        distanceSwArray = new ArrayList<DeviceId>();
+                        distanceSwArray = new ArrayList<>();
                         distanceSwArray.add(reachedDevice);
                         distanceDeviceMap.put(currDistance + 1, distanceSwArray);
                     } else {
@@ -120,7 +120,7 @@ public class ECMPShortestPathGraph {
                 ArrayList<Link> upstreamLinkArray =
                         upstreamLinks.get(reachedDevice);
                 if (upstreamLinkArray == null) {
-                    upstreamLinkArray = new ArrayList<Link>();
+                    upstreamLinkArray = new ArrayList<>();
                     upstreamLinkArray.add(copyDefaultLink(link));
                     //upstreamLinkArray.add(link);
                     upstreamLinks.put(reachedDevice, upstreamLinkArray);
@@ -171,7 +171,7 @@ public class ECMPShortestPathGraph {
                 }
 
                 Integer distance = deviceSearched.get(reachedDevice);
-                if ((distance != null) && (distance.intValue() < (currDistance + 1))) {
+                if ((distance != null) && (distance < (currDistance + 1))) {
                     continue;
                 }
                 if (distance == null) {
@@ -183,7 +183,7 @@ public class ECMPShortestPathGraph {
                     ArrayList<DeviceId> distanceSwArray = distanceDeviceMap
                             .get(currDistance + 1);
                     if (distanceSwArray == null) {
-                        distanceSwArray = new ArrayList<DeviceId>();
+                        distanceSwArray = new ArrayList<>();
                         distanceSwArray.add(reachedDevice);
                         distanceDeviceMap.put(currDistance + 1, distanceSwArray);
                     } else {
@@ -194,7 +194,7 @@ public class ECMPShortestPathGraph {
                 ArrayList<Link> upstreamLinkArray =
                         upstreamLinks.get(reachedDevice);
                 if (upstreamLinkArray == null) {
-                    upstreamLinkArray = new ArrayList<Link>();
+                    upstreamLinkArray = new ArrayList<>();
                     upstreamLinkArray.add(copyDefaultLink(link));
                     upstreamLinks.put(reachedDevice, upstreamLinkArray);
                 } else {
@@ -234,7 +234,7 @@ public class ECMPShortestPathGraph {
         for (Link upstreamLink : upstreamLinks.get(dstDeviceDeviceId)) {
             /* Deep clone the path object */
             Path sofarPath;
-            ArrayList<Link> sofarLinks = new ArrayList<Link>();
+            ArrayList<Link> sofarLinks = new ArrayList<>();
             if (path != null && !path.links().isEmpty()) {
                 sofarLinks.addAll(path.links());
             }
@@ -288,12 +288,10 @@ public class ECMPShortestPathGraph {
     public HashMap<Integer, HashMap<DeviceId,
             ArrayList<Path>>> getCompleteLearnedDeviceesAndPaths() {
 
-        HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>> pathGraph = new
-                HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>>();
+        HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>> pathGraph = new HashMap<>();
 
         for (Integer itrIndx : distanceDeviceMap.keySet()) {
-            HashMap<DeviceId, ArrayList<Path>> swMap = new
-                    HashMap<DeviceId, ArrayList<Path>>();
+            HashMap<DeviceId, ArrayList<Path>> swMap = new HashMap<>();
             for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
                 swMap.put(sw, getECMPPaths(sw));
             }
@@ -314,12 +312,10 @@ public class ECMPShortestPathGraph {
     public HashMap<Integer, HashMap<DeviceId,
             ArrayList<ArrayList<DeviceId>>>> getAllLearnedSwitchesAndVia() {
 
-        HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> deviceViaMap =
-                new HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>>();
+        HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> deviceViaMap = new HashMap<>();
 
         for (Integer itrIndx : distanceDeviceMap.keySet()) {
-            HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swMap =
-                    new HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>();
+            HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swMap = new HashMap<>();
 
             for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
                 ArrayList<ArrayList<DeviceId>> swViaArray = new ArrayList<>();
index 81d00f5..e37fe52 100644 (file)
@@ -50,7 +50,7 @@ public class IpHandler {
     public IpHandler(SegmentRoutingManager srManager) {
         this.srManager = srManager;
         this.config = checkNotNull(srManager.deviceConfiguration);
-        ipPacketQueue = new ConcurrentHashMap<Ip4Address, ConcurrentLinkedQueue<IPv4>>();
+        ipPacketQueue = new ConcurrentHashMap<>();
     }
 
     /**
@@ -104,7 +104,7 @@ public class IpHandler {
         Ip4Address destIpAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress());
 
         if (ipPacketQueue.get(destIpAddress) == null) {
-            ConcurrentLinkedQueue<IPv4> queue = new ConcurrentLinkedQueue<IPv4>();
+            ConcurrentLinkedQueue<IPv4> queue = new ConcurrentLinkedQueue<>();
             queue.add(ipPacket);
             ipPacketQueue.put(destIpAddress, queue);
         } else {
index 59fc4ca..d802be9 100644 (file)
@@ -221,7 +221,7 @@ public class RoutingRulePopulator {
                                     Set<DeviceId> nextHops) {
 
         TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
-        List<ForwardingObjective.Builder> fwdObjBuilders = new ArrayList<ForwardingObjective.Builder>();
+        List<ForwardingObjective.Builder> fwdObjBuilders = new ArrayList<>();
 
         // TODO Handle the case of Bos == false
         sbuilder.matchMplsLabel(MplsLabel.mplsLabel(config.getSegmentId(destSwId)));
index 6ae0779..0c7749e 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
 
 import java.util.ArrayList;
@@ -30,8 +45,8 @@ public class NetworkConfig {
      * Default constructor.
      */
     public NetworkConfig() {
-        switches = new ArrayList<SwitchConfig>();
-        links = new ArrayList<LinkConfig>();
+        switches = new ArrayList<>();
+        links = new ArrayList<>();
     }
 
     @JsonProperty("comment")
index 9194221..0c0dac8 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
 
 import org.onosproject.net.DeviceId;
index 44e4f1c..f034f37 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
 
 import java.io.File;
@@ -135,7 +150,7 @@ public class NetworkConfigManager implements NetworkConfigService {
 
     @Override
     public List<SwitchConfig> getConfiguredAllowedSwitches() {
-        List<SwitchConfig> allowed = new ArrayList<SwitchConfig>();
+        List<SwitchConfig> allowed = new ArrayList<>();
         for (SwitchConfig swc : configuredSwitches.values()) {
             if (swc.isAllowed()) {
                 allowed.add(swc);
@@ -146,7 +161,7 @@ public class NetworkConfigManager implements NetworkConfigService {
 
     @Override
     public List<LinkConfig> getConfiguredAllowedLinks() {
-        List<LinkConfig> allowed = new ArrayList<LinkConfig>();
+        List<LinkConfig> allowed = new ArrayList<>();
         for (LinkConfig lkc : configuredLinks.values()) {
             if (lkc.isAllowed()) {
                 allowed.add(lkc);
@@ -244,8 +259,8 @@ public class NetworkConfigManager implements NetworkConfigService {
     }
 
     private void validateSwitchConfig(List<SwitchConfig> swConfList) {
-        Set<DeviceId> swDpids = new HashSet<DeviceId>();
-        Set<String> swNames = new HashSet<String>();
+        Set<DeviceId> swDpids = new HashSet<>();
+        Set<String> swNames = new HashSet<>();
         for (SwitchConfig swc : swConfList) {
             if (swc.getNodeDpid() == null || swc.getDpid() == null) {
                 throw new NetworkConfigException.DpidNotSpecified(swc.getName());
@@ -315,9 +330,9 @@ public class NetworkConfigManager implements NetworkConfigService {
      */
     public void init() {
         loadNetworkConfig();
-        configuredSwitches = new ConcurrentHashMap<DeviceId, SwitchConfig>();
-        configuredLinks = new ConcurrentHashMap<Link, LinkConfig>();
-        nameToDpid = new HashMap<String, DeviceId>();
+        configuredSwitches = new ConcurrentHashMap<>();
+        configuredLinks = new ConcurrentHashMap<>();
+        nameToDpid = new HashMap<>();
         parseNetworkConfig();
     }
 }
index 5685527..afbb0fc 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
 
 import java.util.List;
index c66ac3c..3c51fa9 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
 
 import java.util.List;
@@ -33,7 +48,7 @@ public class PktLinkConfig extends LinkConfig {
         type = lkc.getType();
         allowed = lkc.isAllowed();
         params = lkc.getParams();
-        publishAttributes = new ConcurrentHashMap<String, String>();
+        publishAttributes = new ConcurrentHashMap<>();
         parseParams();
         validateParams();
         setPublishAttributes();
index 4775c77..c8d4a54 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
 
 import java.io.IOException;
@@ -52,9 +67,9 @@ public class SegmentRouterConfig extends SwitchConfig {
         this.setLongitude(swc.getLongitude());
         this.setParams(swc.getParams());
         this.setAllowed(swc.isAllowed());
-        publishAttributes = new ConcurrentHashMap<String, String>();
-        adjacencySids = new ArrayList<AdjacencySid>();
-        subnets = new ArrayList<Subnet>();
+        publishAttributes = new ConcurrentHashMap<>();
+        adjacencySids = new ArrayList<>();
+        subnets = new ArrayList<>();
         parseParams();
         validateParams();
         setPublishAttributes();
@@ -267,7 +282,7 @@ public class SegmentRouterConfig extends SwitchConfig {
                 } else if (fe.getKey().equals("ports")) {
                     if (fe.getValue().isArray()) {
                         Iterator<JsonNode> i = fe.getValue().elements();
-                        ports = new ArrayList<Integer>();
+                        ports = new ArrayList<>();
                         while (i.hasNext()) {
                             ports.add(i.next().asInt());
                         }
index 41cf8ac..3dc312d 100644 (file)
@@ -69,7 +69,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
         Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(neighbors);
         log.trace("createGroupsAtEdgeRouter: The size of neighbor powerset "
                 + "for sw {} is {}", deviceId, powerSet.size());
-        Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
+        Set<NeighborSet> nsSet = new HashSet<>();
         for (Set<DeviceId> combo : powerSet) {
             if (combo.isEmpty()) {
                 continue;
@@ -148,7 +148,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
                                             Set<DeviceId> updatedNeighbors) {
         Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(updatedNeighbors);
 
-        Set<DeviceId> tmp = new HashSet<DeviceId>();
+        Set<DeviceId> tmp = new HashSet<>();
         tmp.addAll(updatedNeighbors);
         tmp.remove(impactedNeighbor);
         Set<Set<DeviceId>> tmpPowerSet = getPowerSetOfNeighbors(tmp);
@@ -156,7 +156,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
         // Compute the impacted neighbor sets
         powerSet.removeAll(tmpPowerSet);
 
-        Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
+        Set<NeighborSet> nsSet = new HashSet<>();
         for (Set<DeviceId> combo : powerSet) {
             if (combo.isEmpty()) {
                 continue;
index a43a0f0..9bbde2f 100644 (file)
@@ -313,13 +313,13 @@ public class DefaultGroupHandler {
                 return -1;
             } else {
                 log.debug("getNextObjectiveId in device{}: Next objective id {} "
-                    + "created for {}", deviceId, nextId.intValue(), ns);
+                    + "created for {}", deviceId, nextId, ns);
             }
         } else {
             log.trace("getNextObjectiveId in device{}: Next objective id {} "
-                    + "found for {}", deviceId, nextId.intValue(), ns);
+                    + "found for {}", deviceId, nextId, ns);
         }
-        return nextId.intValue();
+        return nextId;
     }
 
     /**
@@ -371,7 +371,7 @@ public class DefaultGroupHandler {
         if (devicePortMap.get(neighborId) != null) {
             devicePortMap.get(neighborId).add(portToNeighbor);
         } else {
-            Set<PortNumber> ports = new HashSet<PortNumber>();
+            Set<PortNumber> ports = new HashSet<>();
             ports.add(portToNeighbor);
             devicePortMap.put(neighborId, ports);
         }
@@ -383,8 +383,8 @@ public class DefaultGroupHandler {
     }
 
     protected Set<Set<DeviceId>> getPowerSetOfNeighbors(Set<DeviceId> neighbors) {
-        List<DeviceId> list = new ArrayList<DeviceId>(neighbors);
-        Set<Set<DeviceId>> sets = new HashSet<Set<DeviceId>>();
+        List<DeviceId> list = new ArrayList<>(neighbors);
+        Set<Set<DeviceId>> sets = new HashSet<>();
         // get the number of elements in the neighbors
         int elements = list.size();
         // the number of members of a power set is 2^n
@@ -394,7 +394,7 @@ public class DefaultGroupHandler {
         // run a binary counter for the number of power elements
         // NOTE: Exclude empty set
         for (long i = 1; i < powerElements; i++) {
-            Set<DeviceId> neighborSubSet = new HashSet<DeviceId>();
+            Set<DeviceId> neighborSubSet = new HashSet<>();
             for (int j = 0; j < elements; j++) {
                 if ((i >> j) % 2 == 1) {
                     neighborSubSet.add(list.get(j));
@@ -411,7 +411,7 @@ public class DefaultGroupHandler {
 
     protected List<Integer> getSegmentIdsTobePairedWithNeighborSet(Set<DeviceId> neighbors) {
 
-        List<Integer> nsSegmentIds = new ArrayList<Integer>();
+        List<Integer> nsSegmentIds = new ArrayList<>();
 
         // Always pair up with no edge label
         // If (neighbors.size() == 1) {
index e12426c..3cb73ab 100644 (file)
@@ -63,7 +63,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
         sets = filterEdgeRouterOnlyPairings(sets);
         log.debug("createGroupsAtTransitRouter: The size of neighbor powerset "
                 + "for sw {} is {}", deviceId, sets.size());
-        Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
+        Set<NeighborSet> nsSet = new HashSet<>();
         for (Set<DeviceId> combo : sets) {
             if (combo.isEmpty()) {
                 continue;
@@ -137,7 +137,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
                                             Set<DeviceId> updatedNeighbors) {
         Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(updatedNeighbors);
 
-        Set<DeviceId> tmp = new HashSet<DeviceId>();
+        Set<DeviceId> tmp = new HashSet<>();
         tmp.addAll(updatedNeighbors);
         tmp.remove(impactedNeighbor);
         Set<Set<DeviceId>> tmpPowerSet = getPowerSetOfNeighbors(tmp);
@@ -146,7 +146,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
         powerSet.removeAll(tmpPowerSet);
 
         powerSet = filterEdgeRouterOnlyPairings(powerSet);
-        Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
+        Set<NeighborSet> nsSet = new HashSet<>();
         for (Set<DeviceId> combo : powerSet) {
             if (combo.isEmpty()) {
                 continue;
@@ -163,7 +163,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
     }
 
     private Set<Set<DeviceId>> filterEdgeRouterOnlyPairings(Set<Set<DeviceId>> sets) {
-        Set<Set<DeviceId>> fiteredSets = new HashSet<Set<DeviceId>>();
+        Set<Set<DeviceId>> fiteredSets = new HashSet<>();
         for (Set<DeviceId> deviceSubSet : sets) {
             if (deviceSubSet.size() > 1) {
                 boolean avoidEdgeRouterPairing = true;
index 7ada322..44715d2 100644 (file)
@@ -44,7 +44,7 @@ public class NeighborSet {
     public NeighborSet(Set<DeviceId> neighbors) {
         checkNotNull(neighbors);
         this.edgeLabel = NO_EDGE_LABEL;
-        this.neighbors = new HashSet<DeviceId>();
+        this.neighbors = new HashSet<>();
         this.neighbors.addAll(neighbors);
     }
 
@@ -57,7 +57,7 @@ public class NeighborSet {
     public NeighborSet(Set<DeviceId> neighbors, int edgeLabel) {
         checkNotNull(neighbors);
         this.edgeLabel = edgeLabel;
-        this.neighbors = new HashSet<DeviceId>();
+        this.neighbors = new HashSet<>();
         this.neighbors.addAll(neighbors);
     }
 
@@ -66,7 +66,7 @@ public class NeighborSet {
      */
     public NeighborSet() {
         this.edgeLabel = NO_EDGE_LABEL;
-        this.neighbors = new HashSet<DeviceId>();
+        this.neighbors = new HashSet<>();
     }
 
     /**
index 27dd667..4b08430 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps-test</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 4197bb6..0095676 100644 (file)
@@ -24,7 +24,7 @@ import java.util.Optional;
  */
 public interface DemoAPI {
 
-    enum InstallType { MESH, RANDOM };
+    enum InstallType { MESH, RANDOM }
 
     /**
      * Tests flow subsystem based on the parameters supplied.
index 27d1ca9..a408e69 100644 (file)
@@ -393,13 +393,8 @@ public class DemoInstaller implements DemoAPI {
         }
 
         private Predicate<? super Host> hasLocalMaster() {
-            return new Predicate<Host>() {
-                @Override
-                public boolean apply(Host host) {
-                    return mastershipService.getLocalRole(
-                            host.location().deviceId()).equals(MastershipRole.MASTER);
-                }
-            };
+            return host -> mastershipService.getLocalRole(
+                    host.location().deviceId()).equals(MastershipRole.MASTER);
         }
 
 
index e0376ee..f77fd57 100644 (file)
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps-test</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
@@ -54,7 +54,7 @@
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-core-dist</artifactId>
-            <version>1.3.0-SNAPSHOT</version>
+            <version>1.4.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
index d8e8e0b..12c8140 100644 (file)
@@ -91,9 +91,7 @@ public class CounterTestIncrementCommand extends AbstractShellCommand {
             print("%s was updated to %d", counter, result.get(3, TimeUnit.SECONDS));
         } catch (InterruptedException e) {
             return;
-        } catch (ExecutionException e) {
-            e.printStackTrace();
-        } catch (TimeoutException e) {
+        } catch (ExecutionException | TimeoutException e) {
             e.printStackTrace();
         }
     }
index 792eab9..fb36a06 100644 (file)
@@ -49,8 +49,8 @@ public class SetTestGetCommand extends AbstractShellCommand {
     String[] values = null;
 
     Set<String> set;
-    Set<String> toCheck = new HashSet<String>();
-    String output = new String();
+    Set<String> toCheck = new HashSet<>();
+    String output = "";
 
     Serializer serializer = Serializer.using(
             new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build());
index 7e3a3e8..d1f81e4 100644 (file)
@@ -54,7 +54,7 @@ public class SetTestRemoveCommand extends AbstractShellCommand {
     String[] values = null;
 
     Set<String> set;
-    Set<String> givenValues = new HashSet<String>();
+    Set<String> givenValues = new HashSet<>();
     Serializer serializer = Serializer.using(
             new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build());
 
index 4c18bae..3ceadb4 100644 (file)
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps-test</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 7d32539..b837d11 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps-test</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 66a7c30..28de5b7 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps-test</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 2469793..8b41bd5 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.messagingperf;
 
 import static com.google.common.base.Strings.isNullOrEmpty;
index 41e1f20..ead2252 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 835272a..01caa66 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 56aa99d..fb8fcb1 100644 (file)
@@ -1,12 +1,28 @@
 <?xml version="1.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.
+  -->
 <project
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
-    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/xsd/maven-4.0.0.xsd"
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
             <artifactId>jsr311-api</artifactId>
             <version>1.1.1</version>
         </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-api</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-incubator-api</artifactId>
index 01c9882..ba4745b 100644 (file)
@@ -289,12 +289,10 @@ public class VTNManager implements VTNService {
                         ports.stream()
                                 .filter(p -> p.name()
                                         .equalsIgnoreCase(tunnelName))
-                                .forEach(p -> {
-                            programTunnelOut(sw.deviceId(),
-                                             network.segmentationId(), p,
-                                             host.mac(), appId,
-                                             Objective.Operation.ADD);
-                        });
+                                .forEach(p -> programTunnelOut(sw.deviceId(),
+                                                 network.segmentationId(), p,
+                                                 host.mac(), appId,
+                                                 Objective.Operation.ADD));
                     }
                 });
         programLocalIn(deviceId, network.segmentationId(), inPort, host.mac(),
@@ -355,12 +353,10 @@ public class VTNManager implements VTNService {
                         ports.stream()
                                 .filter(p -> p.name()
                                         .equalsIgnoreCase(tunnelName))
-                                .forEach(p -> {
-                            programTunnelOut(sw.deviceId(),
-                                             segId, p,
-                                             host.mac(), appId,
-                                             Objective.Operation.REMOVE);
-                        });
+                                .forEach(p -> programTunnelOut(sw.deviceId(),
+                                                 segId, p,
+                                                 host.mac(), appId,
+                                                 Objective.Operation.REMOVE));
                     }
                 });
         programLocalIn(deviceId, segId, inPort, host.mac(),
@@ -379,26 +375,18 @@ public class VTNManager implements VTNService {
             Device device = event.subject();
             if (Device.Type.CONTROLLER == device.type()
                     && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
-                backgroundService.execute(() -> {
-                    onServerDetected(device);
-                });
+                backgroundService.execute(() -> onServerDetected(device));
             } else if (Device.Type.CONTROLLER == device.type()
                     && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
                             .type()) {
-                backgroundService.execute(() -> {
-                    onServerVanished(device);
-                });
+                backgroundService.execute(() -> onServerVanished(device));
             } else if (Device.Type.SWITCH == device.type()
                     && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
-                backgroundService.execute(() -> {
-                    onOvsDetected(device);
-                });
+                backgroundService.execute(() -> onOvsDetected(device));
             } else if (Device.Type.SWITCH == device.type()
                     && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
                             .type()) {
-                backgroundService.execute(() -> {
-                    onOvsVanished(device);
-                });
+                backgroundService.execute(() -> onOvsVanished(device));
             } else {
                 log.info("Do nothing for this device type");
             }
@@ -412,13 +400,9 @@ public class VTNManager implements VTNService {
         public void event(HostEvent event) {
             Host host = event.subject();
             if (HostEvent.Type.HOST_ADDED == event.type()) {
-                backgroundService.execute(() -> {
-                    onHostDetected(host);
-                });
+                backgroundService.execute(() -> onHostDetected(host));
             } else if (HostEvent.Type.HOST_REMOVED == event.type()) {
-                backgroundService.execute(() -> {
-                    onHostVanished(host);
-                });
+                backgroundService.execute(() -> onHostVanished(host));
             } else if (HostEvent.Type.HOST_UPDATED == event.type()) {
                 backgroundService.execute(() -> {
                     onHostVanished(host);
@@ -626,7 +610,7 @@ public class VTNManager implements VTNService {
         VirtualPort port = virtualPortService.getPort(portId);
         TenantNetwork network = tenantNetworkService
                 .getNetwork(port.networkId());
-        Collection<String> ifaceIds = new HashSet<String>();
+        Collection<String> ifaceIds = new HashSet<>();
         Collection<VirtualPort> ports = virtualPortService
                 .getPorts(network.id());
         Sets.newHashSet(ports).stream()
index ce4e2c8..0874f6d 100644 (file)
@@ -1,4 +1,19 @@
 <?xml version="1.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.
+  -->
 <project
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
        xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -6,7 +21,7 @@
        <parent>
                <groupId>org.onosproject</groupId>
                <artifactId>onos-apps</artifactId>
-               <version>1.3.0-SNAPSHOT</version>
+               <version>1.4.0-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 85d1fa9..3d6ba8e 100644 (file)
@@ -1,38 +1,38 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import org.onlab.packet.IpAddress;\r
-\r
-/**\r
- * The continuous IP address range between the start address and the end address for the allocation pools.\r
- */\r
-public interface AllocationPool {\r
-\r
-    /**\r
-     * The start address for the allocation pool.\r
-     *\r
-     * @return startIp\r
-     */\r
-    IpAddress startIp();\r
-\r
-    /**\r
-     * The end address for the allocation pool.\r
-     *\r
-     * @return endIp\r
-     */\r
-    IpAddress endIp();\r
-}\r
+/*
+ * 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;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * The continuous IP address range between the start address and the end address for the allocation pools.
+ */
+public interface AllocationPool {
+
+    /**
+     * The start address for the allocation pool.
+     *
+     * @return startIp
+     */
+    IpAddress startIp();
+
+    /**
+     * The end address for the allocation pool.
+     *
+     * @return endIp
+     */
+    IpAddress endIp();
+}
index b60cb67..4e1028d 100644 (file)
@@ -1,94 +1,94 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.MoreObjects.toStringHelper;\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import java.util.Objects;\r
-\r
-import org.onlab.packet.IpAddress;\r
-import org.onlab.packet.MacAddress;\r
-\r
-/**\r
- * Immutable representation of a allowed address pair.\r
- */\r
-public final class AllowedAddressPair {\r
-    private final IpAddress ip;\r
-    private final MacAddress mac;\r
-    // Public construction is prohibited\r
-    private AllowedAddressPair(IpAddress ip, MacAddress mac) {\r
-        checkNotNull(ip, "IpAddress cannot be null");\r
-        checkNotNull(mac, "MacAddress cannot be null");\r
-        this.ip = ip;\r
-        this.mac = mac;\r
-    }\r
-    /**\r
-     * Returns the AllowedAddressPair ip address.\r
-     *\r
-     * @return ip address\r
-     */\r
-    public IpAddress ip() {\r
-        return ip;\r
-    }\r
-\r
-    /**\r
-     * Returns the AllowedAddressPair MAC address.\r
-     *\r
-     * @return MAC address\r
-     */\r
-    public MacAddress mac() {\r
-        return mac;\r
-    }\r
-\r
-\r
-    /**\r
-     * Creates a allowedAddressPair using the supplied ipAddress &amp;\r
-     * macAddress.\r
-     *\r
-     * @param ip IP address\r
-     * @param mac MAC address\r
-     * @return AllowedAddressPair\r
-     */\r
-    public static AllowedAddressPair allowedAddressPair(IpAddress ip,\r
-                                                        MacAddress mac) {\r
-        return new AllowedAddressPair(ip, mac);\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(ip, mac);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof AllowedAddressPair) {\r
-            final AllowedAddressPair that = (AllowedAddressPair) obj;\r
-            return Objects.equals(this.ip, that.ip)\r
-                    && Objects.equals(this.mac, that.mac);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return toStringHelper(this).add("ip", ip).add("mac", mac).toString();\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+
+/**
+ * Immutable representation of a allowed address pair.
+ */
+public final class AllowedAddressPair {
+    private final IpAddress ip;
+    private final MacAddress mac;
+    // Public construction is prohibited
+    private AllowedAddressPair(IpAddress ip, MacAddress mac) {
+        checkNotNull(ip, "IpAddress cannot be null");
+        checkNotNull(mac, "MacAddress cannot be null");
+        this.ip = ip;
+        this.mac = mac;
+    }
+    /**
+     * Returns the AllowedAddressPair ip address.
+     *
+     * @return ip address
+     */
+    public IpAddress ip() {
+        return ip;
+    }
+
+    /**
+     * Returns the AllowedAddressPair MAC address.
+     *
+     * @return MAC address
+     */
+    public MacAddress mac() {
+        return mac;
+    }
+
+
+    /**
+     * Creates a allowedAddressPair using the supplied ipAddress &amp;
+     * macAddress.
+     *
+     * @param ip IP address
+     * @param mac MAC address
+     * @return AllowedAddressPair
+     */
+    public static AllowedAddressPair allowedAddressPair(IpAddress ip,
+                                                        MacAddress mac) {
+        return new AllowedAddressPair(ip, mac);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(ip, mac);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof AllowedAddressPair) {
+            final AllowedAddressPair that = (AllowedAddressPair) obj;
+            return Objects.equals(this.ip, that.ip)
+                    && Objects.equals(this.mac, that.mac);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("ip", ip).add("mac", mac).toString();
+    }
+
+}
index da40387..c715d08 100644 (file)
@@ -1,57 +1,72 @@
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import java.util.Objects;\r
-\r
-public final class BindingHostId {\r
-    private final String bindingHostId;\r
-\r
-    // Public construction is prohibited\r
-    private BindingHostId(String bindingHostId) {\r
-        checkNotNull(bindingHostId, "BindingHosttId cannot be null");\r
-        this.bindingHostId = bindingHostId;\r
-    }\r
-\r
-    /**\r
-     * Creates a BindingHostId identifier.\r
-     *\r
-     * @param bindingHostId the bindingHostId identifier\r
-     * @return the bindingHostId identifier\r
-     */\r
-    public static BindingHostId bindingHostId(String bindingHostId) {\r
-        return new BindingHostId(bindingHostId);\r
-    }\r
-\r
-    /**\r
-     * Returns the bindingHostId identifier.\r
-     *\r
-     * @return the bindingHostId identifier\r
-     */\r
-    public String bindingHostId() {\r
-        return bindingHostId;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(bindingHostId);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof BindingHostId) {\r
-            final BindingHostId that = (BindingHostId) obj;\r
-            return this.getClass() == that.getClass()\r
-                    && Objects.equals(this.bindingHostId, that.bindingHostId);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return bindingHostId;\r
-    }\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+public final class BindingHostId {
+    private final String bindingHostId;
+
+    // Public construction is prohibited
+    private BindingHostId(String bindingHostId) {
+        checkNotNull(bindingHostId, "BindingHosttId cannot be null");
+        this.bindingHostId = bindingHostId;
+    }
+
+    /**
+     * Creates a BindingHostId identifier.
+     *
+     * @param bindingHostId the bindingHostId identifier
+     * @return the bindingHostId identifier
+     */
+    public static BindingHostId bindingHostId(String bindingHostId) {
+        return new BindingHostId(bindingHostId);
+    }
+
+    /**
+     * Returns the bindingHostId identifier.
+     *
+     * @return the bindingHostId identifier
+     */
+    public String bindingHostId() {
+        return bindingHostId;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(bindingHostId);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof BindingHostId) {
+            final BindingHostId that = (BindingHostId) obj;
+            return this.getClass() == that.getClass()
+                    && Objects.equals(this.bindingHostId, that.bindingHostId);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return bindingHostId;
+    }
+}
index 6a6a475..8a48019 100644 (file)
@@ -1,81 +1,81 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.MoreObjects.toStringHelper;\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-import java.util.Objects;\r
-\r
-import org.onlab.packet.IpAddress;\r
-\r
-/**\r
- * The continuous IP address range between the start address and the end address\r
- * for the allocation pools.\r
- */\r
-public final class DefaultAllocationPool implements AllocationPool {\r
-\r
-    private final IpAddress startIp;\r
-    private final IpAddress endIp;\r
-\r
-    /**\r
-     * Creates an AllocationPool by using the start IP address and the end IP\r
-     * address.\r
-     *\r
-     * @param startIp the start IP address of the allocation pool\r
-     * @param endIp the end IP address of the allocation pool\r
-     */\r
-    public DefaultAllocationPool(IpAddress startIp, IpAddress endIp) {\r
-        checkNotNull(startIp, "StartIp cannot be null");\r
-        checkNotNull(endIp, "EndIp cannot be null");\r
-        this.startIp = startIp;\r
-        this.endIp = endIp;\r
-    }\r
-\r
-    @Override\r
-    public IpAddress startIp() {\r
-        return startIp;\r
-    }\r
-\r
-    @Override\r
-    public IpAddress endIp() {\r
-        return endIp;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(startIp, endIp);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof DefaultAllocationPool) {\r
-            final DefaultAllocationPool other = (DefaultAllocationPool) obj;\r
-            return Objects.equals(this.startIp, other.startIp)\r
-                    && Objects.equals(this.endIp, other.endIp);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return toStringHelper(this).add("startIp", startIp).add("endIp", endIp)\r
-                .toString();\r
-    }\r
-}\r
-\r
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * The continuous IP address range between the start address and the end address
+ * for the allocation pools.
+ */
+public final class DefaultAllocationPool implements AllocationPool {
+
+    private final IpAddress startIp;
+    private final IpAddress endIp;
+
+    /**
+     * Creates an AllocationPool by using the start IP address and the end IP
+     * address.
+     *
+     * @param startIp the start IP address of the allocation pool
+     * @param endIp the end IP address of the allocation pool
+     */
+    public DefaultAllocationPool(IpAddress startIp, IpAddress endIp) {
+        checkNotNull(startIp, "StartIp cannot be null");
+        checkNotNull(endIp, "EndIp cannot be null");
+        this.startIp = startIp;
+        this.endIp = endIp;
+    }
+
+    @Override
+    public IpAddress startIp() {
+        return startIp;
+    }
+
+    @Override
+    public IpAddress endIp() {
+        return endIp;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(startIp, endIp);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof DefaultAllocationPool) {
+            final DefaultAllocationPool other = (DefaultAllocationPool) obj;
+            return Objects.equals(this.startIp, other.startIp)
+                    && Objects.equals(this.endIp, other.endIp);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("startIp", startIp).add("endIp", endIp)
+                .toString();
+    }
+}
+
index c84ae18..8679100 100644 (file)
@@ -1,79 +1,79 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.MoreObjects.toStringHelper;\r
-\r
-import java.util.Objects;\r
-\r
-import org.onlab.packet.IpAddress;\r
-import org.onlab.packet.IpPrefix;\r
-\r
-/**\r
- * Host route dictionaries for the subnet.\r
- */\r
-public final class DefaultHostRoute implements HostRoute {\r
-\r
-    private final IpAddress nexthop;\r
-    private final IpPrefix destination;\r
-\r
-    /**\r
-     *\r
-     * Creates a DefaultHostRoute by using the next hop and the destination.\r
-     *\r
-     * @param nexthop of the DefaultHostRoute\r
-     * @param destination of the DefaultHostRoute\r
-     */\r
-    public DefaultHostRoute(IpAddress nexthop, IpPrefix destination) {\r
-        this.nexthop = nexthop;\r
-        this.destination = destination;\r
-    }\r
-\r
-    @Override\r
-    public IpAddress nexthop() {\r
-        return nexthop;\r
-    }\r
-\r
-    @Override\r
-    public IpPrefix destination() {\r
-        return destination;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return toStringHelper(this).add("nexthop", nexthop)\r
-                .add("destination", destination).toString();\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(nexthop, destination);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof DefaultHostRoute) {\r
-            final DefaultHostRoute other = (DefaultHostRoute) obj;\r
-            return Objects.equals(this.nexthop, other.nexthop)\r
-                    && Objects.equals(this.destination, other.destination);\r
-        }\r
-        return false;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Host route dictionaries for the subnet.
+ */
+public final class DefaultHostRoute implements HostRoute {
+
+    private final IpAddress nexthop;
+    private final IpPrefix destination;
+
+    /**
+     *
+     * Creates a DefaultHostRoute by using the next hop and the destination.
+     *
+     * @param nexthop of the DefaultHostRoute
+     * @param destination of the DefaultHostRoute
+     */
+    public DefaultHostRoute(IpAddress nexthop, IpPrefix destination) {
+        this.nexthop = nexthop;
+        this.destination = destination;
+    }
+
+    @Override
+    public IpAddress nexthop() {
+        return nexthop;
+    }
+
+    @Override
+    public IpPrefix destination() {
+        return destination;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("nexthop", nexthop)
+                .add("destination", destination).toString();
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(nexthop, destination);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof DefaultHostRoute) {
+            final DefaultHostRoute other = (DefaultHostRoute) obj;
+            return Objects.equals(this.nexthop, other.nexthop)
+                    && Objects.equals(this.destination, other.destination);
+        }
+        return false;
+    }
+
+}
index 88fabff..6049b55 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.MoreObjects.toStringHelper;\r
-\r
-import java.util.Objects;\r
-import java.util.Set;\r
-\r
-import org.onlab.packet.IpAddress;\r
-import org.onlab.packet.IpAddress.Version;\r
-import org.onlab.packet.IpPrefix;\r
-\r
-/**\r
- * Default implementation of Subnet interface .\r
- */\r
-public final class DefaultSubnet implements Subnet {\r
-    private final SubnetId id;\r
-    private final String subnetName;\r
-    private final TenantNetworkId networkId;\r
-    private final TenantId tenantId;\r
-    private final Version ipVersion;\r
-    private final IpPrefix cidr;\r
-    private final IpAddress gatewayIp;\r
-    private final boolean dhcpEnabled;\r
-    private final boolean shared;\r
-    private final Mode ipV6AddressMode;\r
-    private final Mode ipV6RaMode;\r
-    private final Set<HostRoute> hostRoutes;\r
-    private final Set<AllocationPool> allocationPools;\r
-\r
-    /**\r
-     * Creates a subnet object.\r
-     *\r
-     * @param id subnet identifier\r
-     * @param subnetName the name of subnet\r
-     * @param networkId network identifier\r
-     * @param tenantId tenant identifier\r
-     * @param ipVersion Version of ipv4 or ipv6\r
-     * @param cidr the cidr\r
-     * @param gatewayIp gateway ip\r
-     * @param dhcpEnabled dhcp enabled or not\r
-     * @param shared indicates whether this network is shared across all\r
-     *            tenants, By default, only administrative user can change this\r
-     *            value\r
-     * @param hostRoutes a collection of host routes\r
-     * @param ipV6AddressMode ipV6AddressMode\r
-     * @param ipV6RaMode ipV6RaMode\r
-     * @param allocationPoolsIt a collection of allocationPools\r
-     */\r
-    public DefaultSubnet(SubnetId id, String subnetName,\r
-                         TenantNetworkId networkId, TenantId tenantId,\r
-                         Version ipVersion, IpPrefix cidr, IpAddress gatewayIp,\r
-                         boolean dhcpEnabled, boolean shared,\r
-                         Set<HostRoute> hostRoutes, Mode ipV6AddressMode,\r
-                         Mode ipV6RaMode,\r
-                         Set<AllocationPool> allocationPoolsIt) {\r
-        this.id = id;\r
-        this.subnetName = subnetName;\r
-        this.networkId = networkId;\r
-        this.tenantId = tenantId;\r
-        this.ipVersion = ipVersion;\r
-        this.cidr = cidr;\r
-        this.gatewayIp = gatewayIp;\r
-        this.dhcpEnabled = dhcpEnabled;\r
-        this.shared = shared;\r
-        this.ipV6AddressMode = ipV6AddressMode;\r
-        this.ipV6RaMode = ipV6RaMode;\r
-        this.hostRoutes = hostRoutes;\r
-        this.allocationPools = allocationPoolsIt;\r
-    }\r
-\r
-    @Override\r
-    public SubnetId id() {\r
-        return id;\r
-    }\r
-\r
-    @Override\r
-    public String subnetName() {\r
-        return subnetName;\r
-    }\r
-\r
-    @Override\r
-    public TenantNetworkId networkId() {\r
-        return networkId;\r
-    }\r
-\r
-    @Override\r
-    public TenantId tenantId() {\r
-        return tenantId;\r
-    }\r
-\r
-    @Override\r
-    public Version ipVersion() {\r
-        return ipVersion;\r
-    }\r
-\r
-    @Override\r
-    public IpPrefix cidr() {\r
-        return cidr;\r
-    }\r
-\r
-    @Override\r
-    public IpAddress gatewayIp() {\r
-        return gatewayIp;\r
-    }\r
-\r
-    @Override\r
-    public boolean dhcpEnabled() {\r
-        return dhcpEnabled;\r
-    }\r
-\r
-    @Override\r
-    public boolean shared() {\r
-        return shared;\r
-    }\r
-\r
-    @Override\r
-    public Iterable<HostRoute> hostRoutes() {\r
-        return hostRoutes;\r
-    }\r
-\r
-    @Override\r
-    public Mode ipV6AddressMode() {\r
-        return ipV6AddressMode;\r
-    }\r
-\r
-    @Override\r
-    public Mode ipV6RaMode() {\r
-        return ipV6RaMode;\r
-    }\r
-\r
-    @Override\r
-    public Iterable<AllocationPool> allocationPools() {\r
-        return allocationPools;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(id, subnetName, ipVersion, cidr, gatewayIp,\r
-                            dhcpEnabled, shared, tenantId);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof DefaultSubnet) {\r
-            final DefaultSubnet that = (DefaultSubnet) obj;\r
-            return Objects.equals(this.id, that.id)\r
-                    && Objects.equals(this.subnetName, that.subnetName)\r
-                    && Objects.equals(this.ipVersion, that.ipVersion)\r
-                    && Objects.equals(this.cidr, that.cidr)\r
-                    && Objects.equals(this.shared, that.shared)\r
-                    && Objects.equals(this.gatewayIp, that.gatewayIp)\r
-                    && Objects.equals(this.dhcpEnabled, that.dhcpEnabled);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return toStringHelper(this).add("id", id).add("subnetName", subnetName)\r
-                .add("ipVersion", ipVersion).add("cidr", cidr)\r
-                .add("shared", shared).add("gatewayIp", gatewayIp)\r
-                .add("dhcpEnabled", dhcpEnabled).toString();\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+import java.util.Set;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpAddress.Version;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Default implementation of Subnet interface .
+ */
+public final class DefaultSubnet implements Subnet {
+    private final SubnetId id;
+    private final String subnetName;
+    private final TenantNetworkId networkId;
+    private final TenantId tenantId;
+    private final Version ipVersion;
+    private final IpPrefix cidr;
+    private final IpAddress gatewayIp;
+    private final boolean dhcpEnabled;
+    private final boolean shared;
+    private final Mode ipV6AddressMode;
+    private final Mode ipV6RaMode;
+    private final Set<HostRoute> hostRoutes;
+    private final Set<AllocationPool> allocationPools;
+
+    /**
+     * Creates a subnet object.
+     *
+     * @param id subnet identifier
+     * @param subnetName the name of subnet
+     * @param networkId network identifier
+     * @param tenantId tenant identifier
+     * @param ipVersion Version of ipv4 or ipv6
+     * @param cidr the cidr
+     * @param gatewayIp gateway ip
+     * @param dhcpEnabled dhcp enabled or not
+     * @param shared indicates whether this network is shared across all
+     *            tenants, By default, only administrative user can change this
+     *            value
+     * @param hostRoutes a collection of host routes
+     * @param ipV6AddressMode ipV6AddressMode
+     * @param ipV6RaMode ipV6RaMode
+     * @param allocationPoolsIt a collection of allocationPools
+     */
+    public DefaultSubnet(SubnetId id, String subnetName,
+                         TenantNetworkId networkId, TenantId tenantId,
+                         Version ipVersion, IpPrefix cidr, IpAddress gatewayIp,
+                         boolean dhcpEnabled, boolean shared,
+                         Set<HostRoute> hostRoutes, Mode ipV6AddressMode,
+                         Mode ipV6RaMode,
+                         Set<AllocationPool> allocationPoolsIt) {
+        this.id = id;
+        this.subnetName = subnetName;
+        this.networkId = networkId;
+        this.tenantId = tenantId;
+        this.ipVersion = ipVersion;
+        this.cidr = cidr;
+        this.gatewayIp = gatewayIp;
+        this.dhcpEnabled = dhcpEnabled;
+        this.shared = shared;
+        this.ipV6AddressMode = ipV6AddressMode;
+        this.ipV6RaMode = ipV6RaMode;
+        this.hostRoutes = hostRoutes;
+        this.allocationPools = allocationPoolsIt;
+    }
+
+    @Override
+    public SubnetId id() {
+        return id;
+    }
+
+    @Override
+    public String subnetName() {
+        return subnetName;
+    }
+
+    @Override
+    public TenantNetworkId networkId() {
+        return networkId;
+    }
+
+    @Override
+    public TenantId tenantId() {
+        return tenantId;
+    }
+
+    @Override
+    public Version ipVersion() {
+        return ipVersion;
+    }
+
+    @Override
+    public IpPrefix cidr() {
+        return cidr;
+    }
+
+    @Override
+    public IpAddress gatewayIp() {
+        return gatewayIp;
+    }
+
+    @Override
+    public boolean dhcpEnabled() {
+        return dhcpEnabled;
+    }
+
+    @Override
+    public boolean shared() {
+        return shared;
+    }
+
+    @Override
+    public Iterable<HostRoute> hostRoutes() {
+        return hostRoutes;
+    }
+
+    @Override
+    public Mode ipV6AddressMode() {
+        return ipV6AddressMode;
+    }
+
+    @Override
+    public Mode ipV6RaMode() {
+        return ipV6RaMode;
+    }
+
+    @Override
+    public Iterable<AllocationPool> allocationPools() {
+        return allocationPools;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, subnetName, ipVersion, cidr, gatewayIp,
+                            dhcpEnabled, shared, tenantId);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof DefaultSubnet) {
+            final DefaultSubnet that = (DefaultSubnet) obj;
+            return Objects.equals(this.id, that.id)
+                    && Objects.equals(this.subnetName, that.subnetName)
+                    && Objects.equals(this.ipVersion, that.ipVersion)
+                    && Objects.equals(this.cidr, that.cidr)
+                    && Objects.equals(this.shared, that.shared)
+                    && Objects.equals(this.gatewayIp, that.gatewayIp)
+                    && Objects.equals(this.dhcpEnabled, that.dhcpEnabled);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("id", id).add("subnetName", subnetName)
+                .add("ipVersion", ipVersion).add("cidr", cidr)
+                .add("shared", shared).add("gatewayIp", gatewayIp)
+                .add("dhcpEnabled", dhcpEnabled).toString();
+    }
+
+}
index 2165078..8c941ea 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.MoreObjects.toStringHelper;\r
-\r
-import java.util.Objects;\r
-\r
-/**\r
- * Default implementation of  TenantNetwork interface.\r
- */\r
-public final class DefaultTenantNetwork implements TenantNetwork {\r
-    private final TenantNetworkId id;\r
-    private final String name;\r
-    private final boolean adminStateUp;\r
-    private final State state;\r
-    private final boolean shared;\r
-    private final Type type;\r
-    private final TenantId tenantId;\r
-    private final boolean routerExternal;\r
-    private final PhysicalNetwork physicalNetwork;\r
-    private final SegmentationId segmentationId;\r
-\r
-    /**\r
-     * Creates a neutronNetwork element attributed to the specified provider.\r
-     *\r
-     * @param id  network identifier\r
-     * @param name the network name\r
-     * @param adminStateUp administrative state of the network\r
-     * @param state the network state\r
-     * @param shared indicates whether this network is shared across all\r
-     *            tenants, By default, only administrative user can change this\r
-     *            value\r
-     * @param tenantId tenant identifier\r
-     * @param routerExternal network routerExternal\r
-     * @param type the network type\r
-     * @param physicalNetwork physicalNetwork identifier\r
-     * @param segmentationId segmentation identifier\r
-     */\r
-    public DefaultTenantNetwork(TenantNetworkId id, String name,\r
-                                boolean adminStateUp, State state,\r
-                                boolean shared, TenantId tenantId,\r
-                                boolean routerExternal, Type type,\r
-                                PhysicalNetwork physicalNetwork,\r
-                                SegmentationId segmentationId) {\r
-        this.id = id;\r
-        this.name = name;\r
-        this.adminStateUp = adminStateUp;\r
-        this.state = state;\r
-        this.shared = shared;\r
-        this.type = type;\r
-        this.tenantId = tenantId;\r
-        this.routerExternal = routerExternal;\r
-        this.physicalNetwork = physicalNetwork;\r
-        this.segmentationId = segmentationId;\r
-    }\r
-\r
-    @Override\r
-    public TenantNetworkId id() {\r
-        return id;\r
-    }\r
-\r
-    @Override\r
-    public String name() {\r
-        return name;\r
-    }\r
-\r
-    @Override\r
-    public boolean adminStateUp() {\r
-        return adminStateUp;\r
-    }\r
-\r
-    @Override\r
-    public State state() {\r
-        return state;\r
-    }\r
-\r
-    @Override\r
-    public boolean shared() {\r
-        return shared;\r
-    }\r
-\r
-    @Override\r
-    public TenantId tenantId() {\r
-        return tenantId;\r
-    }\r
-\r
-    @Override\r
-    public boolean routerExternal() {\r
-        return routerExternal;\r
-    }\r
-\r
-    @Override\r
-    public Type type() {\r
-        return type;\r
-    }\r
-\r
-    @Override\r
-    public PhysicalNetwork physicalNetwork() {\r
-        return physicalNetwork;\r
-    }\r
-\r
-    @Override\r
-    public SegmentationId segmentationId() {\r
-        return segmentationId;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(id, name, adminStateUp, state, shared, tenantId,\r
-                            routerExternal, type, physicalNetwork,\r
-                            segmentationId);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof DefaultTenantNetwork) {\r
-            final DefaultTenantNetwork that = (DefaultTenantNetwork) obj;\r
-            return Objects.equals(this.id, that.id)\r
-                    && Objects.equals(this.name, that.name)\r
-                    && Objects.equals(this.adminStateUp, that.adminStateUp)\r
-                    && Objects.equals(this.state, that.state)\r
-                    && Objects.equals(this.shared, that.shared)\r
-                    && Objects.equals(this.tenantId, that.tenantId)\r
-                    && Objects.equals(this.routerExternal, that.routerExternal)\r
-                    && Objects.equals(this.type, that.type)\r
-                    && Objects.equals(this.physicalNetwork,\r
-                                      that.physicalNetwork)\r
-                    && Objects.equals(this.segmentationId, that.segmentationId);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return toStringHelper(this).add("id", id).add("name", name)\r
-                .add("adminStateUp", adminStateUp).add("state", state)\r
-                .add("shared", shared).add("tenantId", tenantId)\r
-                .add("routeExternal", routerExternal).add("type", type)\r
-                .add("physicalNetwork", physicalNetwork)\r
-                .add("segmentationId", segmentationId).toString();\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * Default implementation of  TenantNetwork interface.
+ */
+public final class DefaultTenantNetwork implements TenantNetwork {
+    private final TenantNetworkId id;
+    private final String name;
+    private final boolean adminStateUp;
+    private final State state;
+    private final boolean shared;
+    private final Type type;
+    private final TenantId tenantId;
+    private final boolean routerExternal;
+    private final PhysicalNetwork physicalNetwork;
+    private final SegmentationId segmentationId;
+
+    /**
+     * Creates a neutronNetwork element attributed to the specified provider.
+     *
+     * @param id  network identifier
+     * @param name the network name
+     * @param adminStateUp administrative state of the network
+     * @param state the network state
+     * @param shared indicates whether this network is shared across all
+     *            tenants, By default, only administrative user can change this
+     *            value
+     * @param tenantId tenant identifier
+     * @param routerExternal network routerExternal
+     * @param type the network type
+     * @param physicalNetwork physicalNetwork identifier
+     * @param segmentationId segmentation identifier
+     */
+    public DefaultTenantNetwork(TenantNetworkId id, String name,
+                                boolean adminStateUp, State state,
+                                boolean shared, TenantId tenantId,
+                                boolean routerExternal, Type type,
+                                PhysicalNetwork physicalNetwork,
+                                SegmentationId segmentationId) {
+        this.id = id;
+        this.name = name;
+        this.adminStateUp = adminStateUp;
+        this.state = state;
+        this.shared = shared;
+        this.type = type;
+        this.tenantId = tenantId;
+        this.routerExternal = routerExternal;
+        this.physicalNetwork = physicalNetwork;
+        this.segmentationId = segmentationId;
+    }
+
+    @Override
+    public TenantNetworkId id() {
+        return id;
+    }
+
+    @Override
+    public String name() {
+        return name;
+    }
+
+    @Override
+    public boolean adminStateUp() {
+        return adminStateUp;
+    }
+
+    @Override
+    public State state() {
+        return state;
+    }
+
+    @Override
+    public boolean shared() {
+        return shared;
+    }
+
+    @Override
+    public TenantId tenantId() {
+        return tenantId;
+    }
+
+    @Override
+    public boolean routerExternal() {
+        return routerExternal;
+    }
+
+    @Override
+    public Type type() {
+        return type;
+    }
+
+    @Override
+    public PhysicalNetwork physicalNetwork() {
+        return physicalNetwork;
+    }
+
+    @Override
+    public SegmentationId segmentationId() {
+        return segmentationId;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, name, adminStateUp, state, shared, tenantId,
+                            routerExternal, type, physicalNetwork,
+                            segmentationId);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof DefaultTenantNetwork) {
+            final DefaultTenantNetwork that = (DefaultTenantNetwork) obj;
+            return Objects.equals(this.id, that.id)
+                    && Objects.equals(this.name, that.name)
+                    && Objects.equals(this.adminStateUp, that.adminStateUp)
+                    && Objects.equals(this.state, that.state)
+                    && Objects.equals(this.shared, that.shared)
+                    && Objects.equals(this.tenantId, that.tenantId)
+                    && Objects.equals(this.routerExternal, that.routerExternal)
+                    && Objects.equals(this.type, that.type)
+                    && Objects.equals(this.physicalNetwork,
+                                      that.physicalNetwork)
+                    && Objects.equals(this.segmentationId, that.segmentationId);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("id", id).add("name", name)
+                .add("adminStateUp", adminStateUp).add("state", state)
+                .add("shared", shared).add("tenantId", tenantId)
+                .add("routeExternal", routerExternal).add("type", type)
+                .add("physicalNetwork", physicalNetwork)
+                .add("segmentationId", segmentationId).toString();
+    }
+
+}
index adf3a3a..9ee85da 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.MoreObjects.toStringHelper;\r
-\r
-import java.util.Collection;\r
-import java.util.Map;\r
-import java.util.Objects;\r
-import java.util.Set;\r
-\r
-import org.onlab.packet.MacAddress;\r
-import org.onosproject.net.DeviceId;\r
-\r
-/**\r
- * Default implementation of VirtualPort interface .\r
- */\r
-public final class DefaultVirtualPort implements VirtualPort {\r
-    private final VirtualPortId id;\r
-    private final TenantNetworkId networkId;\r
-    private final Boolean adminStateUp;\r
-    private final String name;\r
-    private final State state;\r
-    private final MacAddress macAddress;\r
-    private final TenantId tenantId;\r
-    private final String deviceOwner;\r
-    private final DeviceId deviceId;\r
-    private final Set<FixedIp> fixedIps;\r
-    private final BindingHostId bindingHostId;\r
-    private final String bindingVnicType;\r
-    private final String bindingVifType;\r
-    private final String bindingVifDetails;\r
-    private final Set<AllowedAddressPair> allowedAddressPairs;\r
-    private final Set<SecurityGroup> securityGroups;\r
-\r
-    /**\r
-     * Creates a VirtualPort object.\r
-     *\r
-     * @param id the virtual port identifier\r
-     * @param networkId the network identifier\r
-     * @param adminStateUp adminStateup true or false\r
-     * @param strMap the map of properties of virtual port\r
-     * @param state virtual port state\r
-     * @param macAddress the MAC address\r
-     * @param tenantId the tenant identifier\r
-     * @param deviceId the device identifier\r
-     * @param fixedIps set of fixed IP\r
-     * @param bindingHostId the binding host identifier\r
-     * @param allowedAddressPairs the collection of allowdeAddressPairs\r
-     * @param securityGroups the collection of securityGroups\r
-     */\r
-    public DefaultVirtualPort(VirtualPortId id,\r
-                              TenantNetworkId networkId,\r
-                              Boolean adminStateUp,\r
-                              Map<String, String> strMap,\r
-                              State state,\r
-                              MacAddress macAddress,\r
-                              TenantId tenantId,\r
-                              DeviceId deviceId,\r
-                              Set<FixedIp> fixedIps,\r
-                              BindingHostId bindingHostId,\r
-                              Set<AllowedAddressPair> allowedAddressPairs,\r
-                              Set<SecurityGroup> securityGroups) {\r
-        this.id = id;\r
-        this.networkId = networkId;\r
-        this.adminStateUp = adminStateUp;\r
-        this.name = strMap.get("name");\r
-        this.state = state;\r
-        this.macAddress = macAddress;\r
-        this.tenantId = tenantId;\r
-        this.deviceOwner = strMap.get("deviceOwner");\r
-        this.deviceId = deviceId;\r
-        this.fixedIps = fixedIps;\r
-        this.bindingHostId = bindingHostId;\r
-        this.bindingVnicType = strMap.get("bindingVnicType");\r
-        this.bindingVifType = strMap.get("bindingVifType");\r
-        this.bindingVifDetails = strMap.get("bindingVifDetails");\r
-        this.allowedAddressPairs = allowedAddressPairs;\r
-        this.securityGroups = securityGroups;\r
-    }\r
-\r
-    @Override\r
-    public VirtualPortId portId() {\r
-        return id;\r
-    }\r
-\r
-    @Override\r
-    public TenantNetworkId networkId() {\r
-        return networkId;\r
-    }\r
-\r
-    @Override\r
-    public String name() {\r
-        return name;\r
-    }\r
-\r
-    @Override\r
-    public boolean adminStateUp() {\r
-        return adminStateUp;\r
-    }\r
-\r
-    @Override\r
-    public State state() {\r
-        return state;\r
-    }\r
-\r
-    @Override\r
-    public MacAddress macAddress() {\r
-        return macAddress;\r
-    }\r
-\r
-    @Override\r
-    public TenantId tenantId() {\r
-        return tenantId;\r
-    }\r
-\r
-    @Override\r
-    public DeviceId deviceId() {\r
-        return deviceId;\r
-    }\r
-\r
-    @Override\r
-    public String deviceOwner() {\r
-        return deviceOwner;\r
-    }\r
-\r
-    @Override\r
-    public Collection<AllowedAddressPair> allowedAddressPairs() {\r
-        return allowedAddressPairs;\r
-    }\r
-\r
-    @Override\r
-    public Set<FixedIp> fixedIps() {\r
-        return fixedIps;\r
-    }\r
-\r
-    @Override\r
-    public BindingHostId bindingHostId() {\r
-        return bindingHostId;\r
-    }\r
-\r
-    @Override\r
-    public String bindingVnicType() {\r
-        return bindingVifType;\r
-    }\r
-\r
-    @Override\r
-    public String bindingVifType() {\r
-        return bindingVifType;\r
-    }\r
-\r
-    @Override\r
-    public String bindingVifDetails() {\r
-        return bindingVifDetails;\r
-    }\r
-\r
-    @Override\r
-    public Collection<SecurityGroup> securityGroups() {\r
-        return securityGroups;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(id, networkId, adminStateUp, name, state,\r
-                            macAddress, tenantId, deviceId, deviceOwner,\r
-                            allowedAddressPairs, fixedIps, bindingHostId,\r
-                            bindingVnicType, bindingVifType, bindingVifDetails,\r
-                            securityGroups);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof DefaultVirtualPort) {\r
-            final DefaultVirtualPort that = (DefaultVirtualPort) obj;\r
-            return Objects.equals(this.id, that.id)\r
-                    && Objects.equals(this.networkId, that.networkId)\r
-                    && Objects.equals(this.adminStateUp, that.adminStateUp)\r
-                    && Objects.equals(this.state, that.state)\r
-                    && Objects.equals(this.name, that.name)\r
-                    && Objects.equals(this.tenantId, that.tenantId)\r
-                    && Objects.equals(this.macAddress, that.macAddress)\r
-                    && Objects.equals(this.deviceId, that.deviceId)\r
-                    && Objects.equals(this.deviceOwner, that.deviceOwner)\r
-                    && Objects.equals(this.allowedAddressPairs,\r
-                                      that.allowedAddressPairs)\r
-                    && Objects.equals(this.fixedIps, that.fixedIps)\r
-                    && Objects.equals(this.bindingHostId, that.bindingHostId)\r
-                    && Objects.equals(this.bindingVifDetails,\r
-                                      that.bindingVifDetails)\r
-                    && Objects.equals(this.bindingVifType, that.bindingVifType)\r
-                    && Objects.equals(this.bindingVnicType,\r
-                                      that.bindingVnicType)\r
-                    && Objects.equals(this.securityGroups, that.securityGroups);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return toStringHelper(this).add("id", id).add("network_id", networkId)\r
-                .add("adminStateUp", adminStateUp).add("state", state)\r
-                .add("name", name).add("state", state)\r
-                .add("macAddress", macAddress).add("tenantId", tenantId)\r
-                .add("deviced", deviceId).add("deviceOwner", deviceOwner)\r
-                .add("allowedAddressPairs", allowedAddressPairs)\r
-                .add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)\r
-                .add("bindingVnicType", bindingVnicType)\r
-                .add("bindingVifDetails", bindingVifDetails)\r
-                .add("bindingVifType", bindingVifType)\r
-                .add("securityGroups", securityGroups).toString();\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Default implementation of VirtualPort interface .
+ */
+public final class DefaultVirtualPort implements VirtualPort {
+    private final VirtualPortId id;
+    private final TenantNetworkId networkId;
+    private final Boolean adminStateUp;
+    private final String name;
+    private final State state;
+    private final MacAddress macAddress;
+    private final TenantId tenantId;
+    private final String deviceOwner;
+    private final DeviceId deviceId;
+    private final Set<FixedIp> fixedIps;
+    private final BindingHostId bindingHostId;
+    private final String bindingVnicType;
+    private final String bindingVifType;
+    private final String bindingVifDetails;
+    private final Set<AllowedAddressPair> allowedAddressPairs;
+    private final Set<SecurityGroup> securityGroups;
+
+    /**
+     * Creates a VirtualPort object.
+     *
+     * @param id the virtual port identifier
+     * @param networkId the network identifier
+     * @param adminStateUp adminStateup true or false
+     * @param strMap the map of properties of virtual port
+     * @param state virtual port state
+     * @param macAddress the MAC address
+     * @param tenantId the tenant identifier
+     * @param deviceId the device identifier
+     * @param fixedIps set of fixed IP
+     * @param bindingHostId the binding host identifier
+     * @param allowedAddressPairs the collection of allowdeAddressPairs
+     * @param securityGroups the collection of securityGroups
+     */
+    public DefaultVirtualPort(VirtualPortId id,
+                              TenantNetworkId networkId,
+                              Boolean adminStateUp,
+                              Map<String, String> strMap,
+                              State state,
+                              MacAddress macAddress,
+                              TenantId tenantId,
+                              DeviceId deviceId,
+                              Set<FixedIp> fixedIps,
+                              BindingHostId bindingHostId,
+                              Set<AllowedAddressPair> allowedAddressPairs,
+                              Set<SecurityGroup> securityGroups) {
+        this.id = id;
+        this.networkId = networkId;
+        this.adminStateUp = adminStateUp;
+        this.name = strMap.get("name");
+        this.state = state;
+        this.macAddress = macAddress;
+        this.tenantId = tenantId;
+        this.deviceOwner = strMap.get("deviceOwner");
+        this.deviceId = deviceId;
+        this.fixedIps = fixedIps;
+        this.bindingHostId = bindingHostId;
+        this.bindingVnicType = strMap.get("bindingVnicType");
+        this.bindingVifType = strMap.get("bindingVifType");
+        this.bindingVifDetails = strMap.get("bindingVifDetails");
+        this.allowedAddressPairs = allowedAddressPairs;
+        this.securityGroups = securityGroups;
+    }
+
+    @Override
+    public VirtualPortId portId() {
+        return id;
+    }
+
+    @Override
+    public TenantNetworkId networkId() {
+        return networkId;
+    }
+
+    @Override
+    public String name() {
+        return name;
+    }
+
+    @Override
+    public boolean adminStateUp() {
+        return adminStateUp;
+    }
+
+    @Override
+    public State state() {
+        return state;
+    }
+
+    @Override
+    public MacAddress macAddress() {
+        return macAddress;
+    }
+
+    @Override
+    public TenantId tenantId() {
+        return tenantId;
+    }
+
+    @Override
+    public DeviceId deviceId() {
+        return deviceId;
+    }
+
+    @Override
+    public String deviceOwner() {
+        return deviceOwner;
+    }
+
+    @Override
+    public Collection<AllowedAddressPair> allowedAddressPairs() {
+        return allowedAddressPairs;
+    }
+
+    @Override
+    public Set<FixedIp> fixedIps() {
+        return fixedIps;
+    }
+
+    @Override
+    public BindingHostId bindingHostId() {
+        return bindingHostId;
+    }
+
+    @Override
+    public String bindingVnicType() {
+        return bindingVifType;
+    }
+
+    @Override
+    public String bindingVifType() {
+        return bindingVifType;
+    }
+
+    @Override
+    public String bindingVifDetails() {
+        return bindingVifDetails;
+    }
+
+    @Override
+    public Collection<SecurityGroup> securityGroups() {
+        return securityGroups;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, networkId, adminStateUp, name, state,
+                            macAddress, tenantId, deviceId, deviceOwner,
+                            allowedAddressPairs, fixedIps, bindingHostId,
+                            bindingVnicType, bindingVifType, bindingVifDetails,
+                            securityGroups);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof DefaultVirtualPort) {
+            final DefaultVirtualPort that = (DefaultVirtualPort) obj;
+            return Objects.equals(this.id, that.id)
+                    && Objects.equals(this.networkId, that.networkId)
+                    && Objects.equals(this.adminStateUp, that.adminStateUp)
+                    && Objects.equals(this.state, that.state)
+                    && Objects.equals(this.name, that.name)
+                    && Objects.equals(this.tenantId, that.tenantId)
+                    && Objects.equals(this.macAddress, that.macAddress)
+                    && Objects.equals(this.deviceId, that.deviceId)
+                    && Objects.equals(this.deviceOwner, that.deviceOwner)
+                    && Objects.equals(this.allowedAddressPairs,
+                                      that.allowedAddressPairs)
+                    && Objects.equals(this.fixedIps, that.fixedIps)
+                    && Objects.equals(this.bindingHostId, that.bindingHostId)
+                    && Objects.equals(this.bindingVifDetails,
+                                      that.bindingVifDetails)
+                    && Objects.equals(this.bindingVifType, that.bindingVifType)
+                    && Objects.equals(this.bindingVnicType,
+                                      that.bindingVnicType)
+                    && Objects.equals(this.securityGroups, that.securityGroups);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("id", id).add("network_id", networkId)
+                .add("adminStateUp", adminStateUp).add("state", state)
+                .add("name", name).add("state", state)
+                .add("macAddress", macAddress).add("tenantId", tenantId)
+                .add("deviced", deviceId).add("deviceOwner", deviceOwner)
+                .add("allowedAddressPairs", allowedAddressPairs)
+                .add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)
+                .add("bindingVnicType", bindingVnicType)
+                .add("bindingVifDetails", bindingVifDetails)
+                .add("bindingVifType", bindingVifType)
+                .add("securityGroups", securityGroups).toString();
+    }
+
+}
index dcfb72a..c6569a7 100644 (file)
@@ -1,93 +1,93 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.MoreObjects.toStringHelper;\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import java.util.Objects;\r
-\r
-import org.onlab.packet.IpAddress;\r
-\r
-/**\r
- * Immutable representation of a IP address for the port, Include the IP address\r
- * and subnet identity.\r
- */\r
-public final class FixedIp {\r
-    private final SubnetId subnetId;\r
-    private final IpAddress ip;\r
-    // Public construction is prohibited\r
-    private FixedIp(SubnetId subnetId, IpAddress ip) {\r
-        checkNotNull(subnetId, "SubnetId cannot be null");\r
-        checkNotNull(ip, "IpAddress cannot be null");\r
-        this.subnetId = subnetId;\r
-        this.ip = ip;\r
-    }\r
-\r
-    /**\r
-     * Returns the FixedIp subnet identifier.\r
-     *\r
-     * @return subnet identifier\r
-     */\r
-    public SubnetId subnetId() {\r
-        return subnetId;\r
-    }\r
-\r
-    /**\r
-     * Returns the FixedIp IP address.\r
-     *\r
-     * @return IP address\r
-     */\r
-    public IpAddress ip() {\r
-        return ip;\r
-    }\r
-\r
-    /**\r
-     * Creates a fixed ip using the supplied fixedIp.\r
-     *\r
-     * @param subnetId subnet identity\r
-     * @param ip IP address\r
-     * @return FixedIp\r
-     */\r
-    public static FixedIp fixedIp(SubnetId subnetId, IpAddress ip) {\r
-        return new FixedIp(subnetId, ip);\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(subnetId, ip);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof FixedIp) {\r
-            final FixedIp that = (FixedIp) obj;\r
-            return Objects.equals(this.subnetId, that.subnetId)\r
-                    && Objects.equals(this.ip, that.ip);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return toStringHelper(this).add("subnetId", subnetId).add("ip", ip)\r
-                .toString();\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * Immutable representation of a IP address for the port, Include the IP address
+ * and subnet identity.
+ */
+public final class FixedIp {
+    private final SubnetId subnetId;
+    private final IpAddress ip;
+    // Public construction is prohibited
+    private FixedIp(SubnetId subnetId, IpAddress ip) {
+        checkNotNull(subnetId, "SubnetId cannot be null");
+        checkNotNull(ip, "IpAddress cannot be null");
+        this.subnetId = subnetId;
+        this.ip = ip;
+    }
+
+    /**
+     * Returns the FixedIp subnet identifier.
+     *
+     * @return subnet identifier
+     */
+    public SubnetId subnetId() {
+        return subnetId;
+    }
+
+    /**
+     * Returns the FixedIp IP address.
+     *
+     * @return IP address
+     */
+    public IpAddress ip() {
+        return ip;
+    }
+
+    /**
+     * Creates a fixed ip using the supplied fixedIp.
+     *
+     * @param subnetId subnet identity
+     * @param ip IP address
+     * @return FixedIp
+     */
+    public static FixedIp fixedIp(SubnetId subnetId, IpAddress ip) {
+        return new FixedIp(subnetId, ip);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(subnetId, ip);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof FixedIp) {
+            final FixedIp that = (FixedIp) obj;
+            return Objects.equals(this.subnetId, that.subnetId)
+                    && Objects.equals(this.ip, that.ip);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("subnetId", subnetId).add("ip", ip)
+                .toString();
+    }
+
+}
index 74c2816..b18cb95 100644 (file)
@@ -1,39 +1,39 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import org.onlab.packet.IpAddress;\r
-import org.onlab.packet.IpPrefix;\r
-\r
-/**\r
- * Host route dictionaries for the subnet.\r
- */\r
-public interface HostRoute {\r
-\r
-    /**\r
-     * Returns the next hop address.\r
-     *\r
-     * @return next hop address\r
-     */\r
-    IpAddress nexthop();\r
-\r
-    /**\r
-     * Returns the destination address.\r
-     *\r
-     * @return destination address\r
-     */\r
-    IpPrefix destination();\r
-}\r
+/*
+ * 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;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Host route dictionaries for the subnet.
+ */
+public interface HostRoute {
+
+    /**
+     * Returns the next hop address.
+     *
+     * @return next hop address
+     */
+    IpAddress nexthop();
+
+    /**
+     * Returns the destination address.
+     *
+     * @return destination address
+     */
+    IpPrefix destination();
+}
index 6a0c5cb..e96e666 100644 (file)
@@ -1,78 +1,78 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import java.util.Objects;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-/**\r
- * Immutable representation of a physical network identity.\r
- */\r
-public final class PhysicalNetwork {\r
-\r
-    private final String physicalNetwork;\r
-\r
-    // Public construction is prohibited\r
-    private PhysicalNetwork(String physicalNetwork) {\r
-        checkNotNull(physicalNetwork, "PhysicalNetwork cannot be null");\r
-        this.physicalNetwork = physicalNetwork;\r
-    }\r
-\r
-    /**\r
-     * Creates a PhysicalNetwork object.\r
-     *\r
-     * @param physicalNetwork physical network\r
-     * @return physical network\r
-     */\r
-    public static PhysicalNetwork physicalNetwork(String physicalNetwork) {\r
-        return new PhysicalNetwork(physicalNetwork);\r
-    }\r
-\r
-    /**\r
-     * Returns a physicalNetwork.\r
-     *\r
-     * @return physical network\r
-     */\r
-    public String physicalNetwork() {\r
-        return physicalNetwork;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(physicalNetwork);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof PhysicalNetwork) {\r
-            final PhysicalNetwork that = (PhysicalNetwork) obj;\r
-            return this.getClass() == that.getClass()\r
-                    && Objects.equals(this.physicalNetwork,\r
-                                      that.physicalNetwork);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return physicalNetwork;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a physical network identity.
+ */
+public final class PhysicalNetwork {
+
+    private final String physicalNetwork;
+
+    // Public construction is prohibited
+    private PhysicalNetwork(String physicalNetwork) {
+        checkNotNull(physicalNetwork, "PhysicalNetwork cannot be null");
+        this.physicalNetwork = physicalNetwork;
+    }
+
+    /**
+     * Creates a PhysicalNetwork object.
+     *
+     * @param physicalNetwork physical network
+     * @return physical network
+     */
+    public static PhysicalNetwork physicalNetwork(String physicalNetwork) {
+        return new PhysicalNetwork(physicalNetwork);
+    }
+
+    /**
+     * Returns a physicalNetwork.
+     *
+     * @return physical network
+     */
+    public String physicalNetwork() {
+        return physicalNetwork;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(physicalNetwork);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof PhysicalNetwork) {
+            final PhysicalNetwork that = (PhysicalNetwork) obj;
+            return this.getClass() == that.getClass()
+                    && Objects.equals(this.physicalNetwork,
+                                      that.physicalNetwork);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return physicalNetwork;
+    }
+
+}
index 7f09806..9ec1dc6 100644 (file)
@@ -1,77 +1,77 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import java.util.Objects;\r
-\r
-import static com.google.common.base.MoreObjects.toStringHelper;\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-/**\r
- * Immutable representation of a security group.\r
- */\r
-public final class SecurityGroup {\r
-    private final String securityGroup;\r
-\r
-    /**\r
-     * Returns the securityGroup.\r
-     *\r
-     * @return securityGroup\r
-     */\r
-    public String securityGroup() {\r
-        return securityGroup;\r
-    }\r
-    // Public construction is prohibited\r
-    private SecurityGroup(String securityGroup) {\r
-        checkNotNull(securityGroup, "SecurityGroup cannot be null");\r
-        this.securityGroup = securityGroup;\r
-    }\r
-\r
-    /**\r
-     * Creates a securityGroup using the supplied securityGroup.\r
-     *\r
-     * @param securityGroup security group\r
-     * @return securityGroup\r
-     */\r
-    public static SecurityGroup securityGroup(String securityGroup) {\r
-        return new SecurityGroup(securityGroup);\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(securityGroup);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof SecurityGroup) {\r
-            final SecurityGroup that = (SecurityGroup) obj;\r
-            return this.getClass() == that.getClass()\r
-                    && Objects.equals(this.securityGroup, that.securityGroup);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return toStringHelper(this).add("securityGroup", securityGroup)\r
-                .toString();\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a security group.
+ */
+public final class SecurityGroup {
+    private final String securityGroup;
+
+    /**
+     * Returns the securityGroup.
+     *
+     * @return securityGroup
+     */
+    public String securityGroup() {
+        return securityGroup;
+    }
+    // Public construction is prohibited
+    private SecurityGroup(String securityGroup) {
+        checkNotNull(securityGroup, "SecurityGroup cannot be null");
+        this.securityGroup = securityGroup;
+    }
+
+    /**
+     * Creates a securityGroup using the supplied securityGroup.
+     *
+     * @param securityGroup security group
+     * @return securityGroup
+     */
+    public static SecurityGroup securityGroup(String securityGroup) {
+        return new SecurityGroup(securityGroup);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(securityGroup);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof SecurityGroup) {
+            final SecurityGroup that = (SecurityGroup) obj;
+            return this.getClass() == that.getClass()
+                    && Objects.equals(this.securityGroup, that.securityGroup);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("securityGroup", securityGroup)
+                .toString();
+    }
+
+}
index 69f9dce..a076265 100644 (file)
@@ -1,77 +1,77 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import java.util.Objects;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-/**\r
- * Immutable representation of a Segmentation identifier.\r
- */\r
-public final class SegmentationId {\r
-\r
-    private final String segmentationId;\r
-\r
-    // Public construction is prohibited\r
-    private SegmentationId(String segmentationId) {\r
-        checkNotNull(segmentationId, "SegmentationId cannot be null");\r
-        this.segmentationId = segmentationId;\r
-    }\r
-\r
-    /**\r
-     * Creates a  SegmentationId object.\r
-     *\r
-     * @param segmentationId segmentation identifier\r
-     * @return SegmentationId\r
-     */\r
-    public static SegmentationId segmentationId(String segmentationId) {\r
-        return new SegmentationId(segmentationId);\r
-    }\r
-\r
-    /**\r
-     * Returns the segmentation identifier.\r
-     *\r
-     * @return segmentationId\r
-     */\r
-    public String segmentationId() {\r
-        return segmentationId;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(segmentationId);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof SegmentationId) {\r
-            final SegmentationId that = (SegmentationId) obj;\r
-            return this.getClass() == that.getClass()\r
-                    && Objects.equals(this.segmentationId, that.segmentationId);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return segmentationId;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a Segmentation identifier.
+ */
+public final class SegmentationId {
+
+    private final String segmentationId;
+
+    // Public construction is prohibited
+    private SegmentationId(String segmentationId) {
+        checkNotNull(segmentationId, "SegmentationId cannot be null");
+        this.segmentationId = segmentationId;
+    }
+
+    /**
+     * Creates a  SegmentationId object.
+     *
+     * @param segmentationId segmentation identifier
+     * @return SegmentationId
+     */
+    public static SegmentationId segmentationId(String segmentationId) {
+        return new SegmentationId(segmentationId);
+    }
+
+    /**
+     * Returns the segmentation identifier.
+     *
+     * @return segmentationId
+     */
+    public String segmentationId() {
+        return segmentationId;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(segmentationId);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof SegmentationId) {
+            final SegmentationId that = (SegmentationId) obj;
+            return this.getClass() == that.getClass()
+                    && Objects.equals(this.segmentationId, that.segmentationId);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return segmentationId;
+    }
+
+}
index 1104d7e..f563a78 100644 (file)
-/*\r
- *Copyright 2015 Open Networking Laboratory\r
- *\r
- *Licensed under the Apache License, Version 2.0 (the "License");\r
- *you may not use this file except in compliance with the License.\r
- *You may obtain a copy of the License at\r
- *\r
- *    http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *Unless required by applicable law or agreed to in writing, software\r
- *distributed under the License is distributed on an "AS IS" BASIS,\r
- *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *See the License for the specific language governing permissions and\r
- *limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import org.onlab.packet.IpAddress;\r
-import org.onlab.packet.IpAddress.Version;\r
-import org.onlab.packet.IpPrefix;\r
-\r
-/**\r
- * Representation of a subnet.\r
- */\r
-public interface Subnet {\r
-\r
-    /**\r
-     * Coarse classification of the type of the ipV6Mode.\r
-     */\r
-    public enum Mode {\r
-        DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC\r
-    }\r
-\r
-    /**\r
-     * Returns the subnet identifier.\r
-     *\r
-     * @return identifier\r
-     */\r
-    SubnetId id();\r
-\r
-    /**\r
-     * Returns the name of the subnet.\r
-     *\r
-     * @return subnetName\r
-     */\r
-    String subnetName();\r
-\r
-    /**\r
-     * Returns the network identifier.\r
-     *\r
-     * @return the network identifier\r
-     */\r
-    TenantNetworkId networkId();\r
-\r
-    /**\r
-     * Returns tenant identifier.\r
-     *\r
-     * @return the tenant identifier\r
-     */\r
-    TenantId tenantId();\r
-\r
-    /**\r
-     * Returns the IP version, which is 4 or 6.\r
-     *\r
-     * @return ipVersion\r
-     */\r
-    Version ipVersion();\r
-\r
-    /**\r
-     * Returns the cidr.\r
-     *\r
-     * @return cidr\r
-     */\r
-    IpPrefix cidr();\r
-\r
-    /**\r
-     * Returns the gateway IP address.\r
-     *\r
-     * @return gatewayIp\r
-     */\r
-    IpAddress gatewayIp();\r
-\r
-    /**\r
-     * Returns true if DHCP is enabled and return false if DHCP is disabled.\r
-     *\r
-     * @return true or false\r
-     */\r
-    boolean dhcpEnabled();\r
-\r
-    /**\r
-     * Indicates whether this tenantNetwork is shared across all tenants. By\r
-     * default, only administrative user can change this value.\r
-     *\r
-     * @return true or false\r
-     */\r
-    boolean shared();\r
-\r
-    /**\r
-     * Returns a collection of hostRoutes.\r
-     *\r
-     * @return a collection of hostRoutes\r
-     */\r
-    Iterable<HostRoute> hostRoutes();\r
-\r
-    /**\r
-     * Returns the ipV6AddressMode. A valid value is dhcpv6-stateful,\r
-     * dhcpv6-stateless, or slaac.\r
-     *\r
-     * @return ipV6AddressMode whose value is dhcpv6-stateful, dhcpv6-stateless\r
-     *         or slaac\r
-     */\r
-    Mode ipV6AddressMode();\r
-\r
-    /**\r
-     * Returns the ipV6RaMode.A valid value is dhcpv6-stateful,\r
-     * dhcpv6-stateless, or slaac.\r
-     *\r
-     * @return ipV6RaMode whose value is dhcpv6-stateful, dhcpv6-stateless or\r
-     *         slaac\r
-     */\r
-    Mode ipV6RaMode();\r
-\r
-    /**\r
-     * Returns a collection of allocation_pools.\r
-     *\r
-     * @return a collection of allocationPools\r
-     */\r
-    Iterable<AllocationPool> allocationPools();\r
-}\r
+/*
+ * 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;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpAddress.Version;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Representation of a subnet.
+ */
+public interface Subnet {
+
+    /**
+     * Coarse classification of the type of the ipV6Mode.
+     */
+    enum Mode {
+        DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC
+    }
+
+    /**
+     * Returns the subnet identifier.
+     *
+     * @return identifier
+     */
+    SubnetId id();
+
+    /**
+     * Returns the name of the subnet.
+     *
+     * @return subnetName
+     */
+    String subnetName();
+
+    /**
+     * Returns the network identifier.
+     *
+     * @return the network identifier
+     */
+    TenantNetworkId networkId();
+
+    /**
+     * Returns tenant identifier.
+     *
+     * @return the tenant identifier
+     */
+    TenantId tenantId();
+
+    /**
+     * Returns the IP version, which is 4 or 6.
+     *
+     * @return ipVersion
+     */
+    Version ipVersion();
+
+    /**
+     * Returns the cidr.
+     *
+     * @return cidr
+     */
+    IpPrefix cidr();
+
+    /**
+     * Returns the gateway IP address.
+     *
+     * @return gatewayIp
+     */
+    IpAddress gatewayIp();
+
+    /**
+     * Returns true if DHCP is enabled and return false if DHCP is disabled.
+     *
+     * @return true or false
+     */
+    boolean dhcpEnabled();
+
+    /**
+     * Indicates whether this tenantNetwork is shared across all tenants. By
+     * default, only administrative user can change this value.
+     *
+     * @return true or false
+     */
+    boolean shared();
+
+    /**
+     * Returns a collection of hostRoutes.
+     *
+     * @return a collection of hostRoutes
+     */
+    Iterable<HostRoute> hostRoutes();
+
+    /**
+     * Returns the ipV6AddressMode. A valid value is dhcpv6-stateful,
+     * dhcpv6-stateless, or slaac.
+     *
+     * @return ipV6AddressMode whose value is dhcpv6-stateful, dhcpv6-stateless
+     *         or slaac
+     */
+    Mode ipV6AddressMode();
+
+    /**
+     * Returns the ipV6RaMode.A valid value is dhcpv6-stateful,
+     * dhcpv6-stateless, or slaac.
+     *
+     * @return ipV6RaMode whose value is dhcpv6-stateful, dhcpv6-stateless or
+     *         slaac
+     */
+    Mode ipV6RaMode();
+
+    /**
+     * Returns a collection of allocation_pools.
+     *
+     * @return a collection of allocationPools
+     */
+    Iterable<AllocationPool> allocationPools();
+}
index e0c1aee..4bcc332 100644 (file)
@@ -1,76 +1,76 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import java.util.Objects;\r
-\r
-/**\r
- * Immutable representation of a subnet identifier.\r
- */\r
-public final class SubnetId {\r
-\r
-    private final String subnetId;\r
-\r
-    // Public construction is prohibited\r
-    private SubnetId(String subnetId) {\r
-        checkNotNull(subnetId, "SubnetId cannot be null");\r
-        this.subnetId = subnetId;\r
-    }\r
-\r
-    /**\r
-     * Creates a Subnet identifier.\r
-     *\r
-     * @param subnetId the subnet identifier\r
-     * @return the subnet identifier\r
-     */\r
-    public static SubnetId subnetId(String subnetId) {\r
-        return new SubnetId(subnetId);\r
-    }\r
-\r
-    /**\r
-     * Returns the subnet identifier.\r
-     *\r
-     * @return the subnet identifier\r
-     */\r
-    public String subnetId() {\r
-        return subnetId;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(subnetId);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof SubnetId) {\r
-            final SubnetId that = (SubnetId) obj;\r
-            return this.getClass() == that.getClass()\r
-                    && Objects.equals(this.subnetId, that.subnetId);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return subnetId;\r
-    }\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * Immutable representation of a subnet identifier.
+ */
+public final class SubnetId {
+
+    private final String subnetId;
+
+    // Public construction is prohibited
+    private SubnetId(String subnetId) {
+        checkNotNull(subnetId, "SubnetId cannot be null");
+        this.subnetId = subnetId;
+    }
+
+    /**
+     * Creates a Subnet identifier.
+     *
+     * @param subnetId the subnet identifier
+     * @return the subnet identifier
+     */
+    public static SubnetId subnetId(String subnetId) {
+        return new SubnetId(subnetId);
+    }
+
+    /**
+     * Returns the subnet identifier.
+     *
+     * @return the subnet identifier
+     */
+    public String subnetId() {
+        return subnetId;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(subnetId);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof SubnetId) {
+            final SubnetId that = (SubnetId) obj;
+            return this.getClass() == that.getClass()
+                    && Objects.equals(this.subnetId, that.subnetId);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return subnetId;
+    }
+}
index 9d44c46..c4d99e4 100644 (file)
@@ -1,77 +1,77 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import java.util.Objects;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-/**\r
- * Immutable representation of a tenant identifier.\r
- */\r
-public final class TenantId {\r
-\r
-    private final String tenantId;\r
-\r
-    // Public construction is prohibited\r
-    private TenantId(String tenantId) {\r
-        this.tenantId = tenantId;\r
-    }\r
-\r
-    /**\r
-     * Creates a network id using the tenantid.\r
-     *\r
-     * @param tenantid network String\r
-     * @return TenantId\r
-     */\r
-    public static TenantId tenantId(String tenantid) {\r
-        checkNotNull(tenantid, "Tenantid can not be null");\r
-        return new TenantId(tenantid);\r
-    }\r
-\r
-    /**\r
-     * Returns the tenant identifier.\r
-     *\r
-     * @return the tenant identifier\r
-     */\r
-    public String tenantId() {\r
-        return tenantId;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(tenantId);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof TenantId) {\r
-            final TenantId that = (TenantId) obj;\r
-            return this.getClass() == that.getClass()\r
-                    && Objects.equals(this.tenantId, that.tenantId);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return tenantId;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a tenant identifier.
+ */
+public final class TenantId {
+
+    private final String tenantId;
+
+    // Public construction is prohibited
+    private TenantId(String tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    /**
+     * Creates a network id using the tenantid.
+     *
+     * @param tenantid network String
+     * @return TenantId
+     */
+    public static TenantId tenantId(String tenantid) {
+        checkNotNull(tenantid, "Tenantid can not be null");
+        return new TenantId(tenantid);
+    }
+
+    /**
+     * Returns the tenant identifier.
+     *
+     * @return the tenant identifier
+     */
+    public String tenantId() {
+        return tenantId;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(tenantId);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof TenantId) {
+            final TenantId that = (TenantId) obj;
+            return this.getClass() == that.getClass()
+                    && Objects.equals(this.tenantId, that.tenantId);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return tenantId;
+    }
+
+}
index d9238f9..256352f 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-/**\r
- * Representation of the tenantNetwork.\r
- */\r
-public interface TenantNetwork {\r
-\r
-    /**\r
-     * Coarse classification of the state of the tenantNetwork.\r
-     */\r
-    public enum State {\r
-        /**\r
-         * Signifies that a tenantNetwork is currently active.This state means\r
-         * that this network is available.\r
-         */\r
-        ACTIVE,\r
-        /**\r
-         * Signifies that a tenantNetwork is currently built.\r
-         */\r
-        BUILD,\r
-        /**\r
-         * Signifies that a tenantNetwork is currently unavailable.\r
-         */\r
-        DOWN,\r
-        /**\r
-         * Signifies that a tenantNetwork is currently error.\r
-         */\r
-        ERROR\r
-    }\r
-\r
-    /**\r
-     * Coarse classification of the type of the tenantNetwork.\r
-     */\r
-    public enum Type {\r
-        /**\r
-         * Signifies that a tenantNetwork is local.\r
-         */\r
-        LOCAL\r
-    }\r
-\r
-    /**\r
-     * Returns the tenantNetwork identifier.\r
-     *\r
-     * @return tenantNetwork identifier\r
-     */\r
-    TenantNetworkId id();\r
-\r
-    /**\r
-     * Returns the tenantNetwork name.\r
-     *\r
-     * @return tenantNetwork name\r
-     */\r
-    String name();\r
-\r
-    /**\r
-     * Returns the administrative state of the tenantNetwork,which is up(true)\r
-     * or down(false).\r
-     *\r
-     * @return true or false\r
-     */\r
-    boolean adminStateUp();\r
-\r
-    /**\r
-     * Returns the tenantNetwork state.\r
-     *\r
-     * @return tenant network state\r
-     */\r
-    State state();\r
-\r
-    /**\r
-     * Indicates whether this tenantNetwork is shared across all tenants. By\r
-     * default,only administrative user can change this value.\r
-     *\r
-     * @return true or false\r
-     */\r
-    boolean shared();\r
-\r
-    /**\r
-     * Returns the UUID of the tenant that will own the tenantNetwork. This\r
-     * tenant can be different from the tenant that makes the create\r
-     * tenantNetwork request.\r
-     *\r
-     * @return the tenant identifier\r
-     */\r
-    TenantId tenantId();\r
-\r
-    /**\r
-     * Returns the routerExternal.Indicates whether this network is externally\r
-     * accessible.\r
-     *\r
-     * @return true or false\r
-     */\r
-    boolean routerExternal();\r
-\r
-    /**\r
-     * Returns the tenantNetwork Type.\r
-     *\r
-     * @return tenantNetwork Type\r
-     */\r
-    Type type();\r
-\r
-    /**\r
-     * Returns the tenantNetwork physical network.\r
-     *\r
-     * @return tenantNetwork physical network\r
-     */\r
-    PhysicalNetwork physicalNetwork();\r
-\r
-    /**\r
-     * Returns the tenantNetwork segmentation id.\r
-     *\r
-     * @return tenantNetwork segmentation id\r
-     */\r
-    SegmentationId segmentationId();\r
-}\r
+/*
+ * 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;
+
+/**
+ * Representation of the tenantNetwork.
+ */
+public interface TenantNetwork {
+
+    /**
+     * Coarse classification of the state of the tenantNetwork.
+     */
+    enum State {
+        /**
+         * Signifies that a tenantNetwork is currently active.This state means
+         * that this network is available.
+         */
+        ACTIVE,
+        /**
+         * Signifies that a tenantNetwork is currently built.
+         */
+        BUILD,
+        /**
+         * Signifies that a tenantNetwork is currently unavailable.
+         */
+        DOWN,
+        /**
+         * Signifies that a tenantNetwork is currently error.
+         */
+        ERROR
+    }
+
+    /**
+     * Coarse classification of the type of the tenantNetwork.
+     */
+    enum Type {
+        /**
+         * Signifies that a tenantNetwork is local.
+         */
+        LOCAL
+    }
+
+    /**
+     * Returns the tenantNetwork identifier.
+     *
+     * @return tenantNetwork identifier
+     */
+    TenantNetworkId id();
+
+    /**
+     * Returns the tenantNetwork name.
+     *
+     * @return tenantNetwork name
+     */
+    String name();
+
+    /**
+     * Returns the administrative state of the tenantNetwork,which is up(true)
+     * or down(false).
+     *
+     * @return true or false
+     */
+    boolean adminStateUp();
+
+    /**
+     * Returns the tenantNetwork state.
+     *
+     * @return tenant network state
+     */
+    State state();
+
+    /**
+     * Indicates whether this tenantNetwork is shared across all tenants. By
+     * default,only administrative user can change this value.
+     *
+     * @return true or false
+     */
+    boolean shared();
+
+    /**
+     * Returns the UUID of the tenant that will own the tenantNetwork. This
+     * tenant can be different from the tenant that makes the create
+     * tenantNetwork request.
+     *
+     * @return the tenant identifier
+     */
+    TenantId tenantId();
+
+    /**
+     * Returns the routerExternal.Indicates whether this network is externally
+     * accessible.
+     *
+     * @return true or false
+     */
+    boolean routerExternal();
+
+    /**
+     * Returns the tenantNetwork Type.
+     *
+     * @return tenantNetwork Type
+     */
+    Type type();
+
+    /**
+     * Returns the tenantNetwork physical network.
+     *
+     * @return tenantNetwork physical network
+     */
+    PhysicalNetwork physicalNetwork();
+
+    /**
+     * Returns the tenantNetwork segmentation id.
+     *
+     * @return tenantNetwork segmentation id
+     */
+    SegmentationId segmentationId();
+}
index 81c9962..fbb9e48 100644 (file)
@@ -1,76 +1,76 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import java.util.Objects;\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-/**\r
- * Immutable representation of a tenantNetwork identity.\r
- */\r
-public final class TenantNetworkId {\r
-\r
-    private final String networkId;\r
-\r
-    // Public construction is prohibited\r
-    private TenantNetworkId(String networkId) {\r
-        this.networkId = networkId;\r
-    }\r
-\r
-    /**\r
-     * Creates a TenantNetwork identifier.\r
-     *\r
-     * @param networkId tenantNetwork identify string\r
-     * @return the attached tenantNetwork identifier\r
-     */\r
-    public static TenantNetworkId networkId(String networkId) {\r
-        checkNotNull(networkId, "Networkid cannot be null");\r
-        return new TenantNetworkId(networkId);\r
-    }\r
-\r
-    /**\r
-     * Returns tenantNetwork identifier.\r
-     *\r
-     * @return the tenantNetwork identifier\r
-     */\r
-    public String networkId() {\r
-        return networkId;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(networkId);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof TenantNetworkId) {\r
-            final TenantNetworkId that = (TenantNetworkId) obj;\r
-            return this.getClass() == that.getClass()\r
-                    && Objects.equals(this.networkId, that.networkId);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return networkId;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import java.util.Objects;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a tenantNetwork identity.
+ */
+public final class TenantNetworkId {
+
+    private final String networkId;
+
+    // Public construction is prohibited
+    private TenantNetworkId(String networkId) {
+        this.networkId = networkId;
+    }
+
+    /**
+     * Creates a TenantNetwork identifier.
+     *
+     * @param networkId tenantNetwork identify string
+     * @return the attached tenantNetwork identifier
+     */
+    public static TenantNetworkId networkId(String networkId) {
+        checkNotNull(networkId, "Networkid cannot be null");
+        return new TenantNetworkId(networkId);
+    }
+
+    /**
+     * Returns tenantNetwork identifier.
+     *
+     * @return the tenantNetwork identifier
+     */
+    public String networkId() {
+        return networkId;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(networkId);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof TenantNetworkId) {
+            final TenantNetworkId that = (TenantNetworkId) obj;
+            return this.getClass() == that.getClass()
+                    && Objects.equals(this.networkId, that.networkId);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return networkId;
+    }
+
+}
index a607109..d2d7c14 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import java.util.Collection;\r
-import java.util.Set;\r
-\r
-import org.onlab.packet.MacAddress;\r
-import org.onosproject.net.DeviceId;\r
-\r
-/**\r
- * Representation of the VirtualPort.\r
- */\r
-public interface VirtualPort {\r
-    /**\r
-     * Coarse classification of the type of the virtual port.\r
-     */\r
-    public enum State {\r
-        /**\r
-         * Signifies that a virtualPort is currently active,This state mean that\r
-         * this virtualPort is available.\r
-         */\r
-        ACTIVE,\r
-        /**\r
-         * Signifies that a virtualPort is currently unavailable.\r
-         */\r
-        DOWN;\r
-    }\r
-\r
-    /**\r
-     * Returns the virtualPort identifier.\r
-     *\r
-     * @return virtualPort identifier\r
-     */\r
-    VirtualPortId portId();\r
-\r
-    /**\r
-     * Returns the network identifier.\r
-     *\r
-     * @return tenantNetwork identifier\r
-     */\r
-    TenantNetworkId networkId();\r
-\r
-    /**\r
-     * Returns the symbolic name for the virtualPort.\r
-     *\r
-     * @return virtualPort name\r
-     */\r
-    String name();\r
-\r
-    /**\r
-     * Returns the administrative status of the port,which is up(true) or\r
-     * down(false).\r
-     *\r
-     * @return true if the administrative status of the port is up\r
-     */\r
-    boolean adminStateUp();\r
-\r
-    /**\r
-     * Returns the state.\r
-     *\r
-     * @return state\r
-     */\r
-    State state();\r
-\r
-    /**\r
-     * Returns the MAC address.\r
-     *\r
-     * @return MAC Address\r
-     */\r
-    MacAddress macAddress();\r
-\r
-    /**\r
-     * Returns the port tenantId.\r
-     *\r
-     * @return port tenantId\r
-     */\r
-    TenantId tenantId();\r
-\r
-    /**\r
-     * Returns the device identifier.\r
-     *\r
-     * @return deviceId\r
-     */\r
-    DeviceId deviceId();\r
-\r
-    /**\r
-     * Returns the identifier of the entity that uses this port.\r
-     *\r
-     * @return deviceOwner\r
-     */\r
-    String deviceOwner();\r
-\r
-    /**\r
-     * Returns the virtualPort allowedAddressPairs.\r
-     *\r
-     * @return virtualPort allowedAddressPairs\r
-     */\r
-    Collection<AllowedAddressPair> allowedAddressPairs();\r
-\r
-    /**\r
-     * Returns set of IP addresses for the port, include the IP addresses and subnet\r
-     * identity.\r
-     *\r
-     * @return FixedIps Set of fixedIp\r
-     */\r
-    Set<FixedIp> fixedIps();\r
-\r
-    /**\r
-     * Returns the virtualPort bindinghostId.\r
-     *\r
-     * @return virtualPort bindinghostId\r
-     */\r
-    BindingHostId bindingHostId();\r
-\r
-    /**\r
-     * Returns the virtualPort bindingVnicType.\r
-     *\r
-     * @return virtualPort bindingVnicType\r
-     */\r
-    String bindingVnicType();\r
-\r
-    /**\r
-     * Returns the virtualPort bindingVifType.\r
-     *\r
-     * @return virtualPort bindingVifType\r
-     */\r
-    String bindingVifType();\r
-\r
-    /**\r
-     * Returns the virtualPort bindingvifDetail.\r
-     *\r
-     * @return virtualPort bindingvifDetail\r
-     */\r
-    String bindingVifDetails();\r
-\r
-    /**\r
-     * Returns the security groups.\r
-     *\r
-     * @return port security groups\r
-     */\r
-    Iterable<SecurityGroup> securityGroups();\r
-}\r
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Representation of the VirtualPort.
+ */
+public interface VirtualPort {
+    /**
+     * Coarse classification of the type of the virtual port.
+     */
+    enum State {
+        /**
+         * Signifies that a virtualPort is currently active,This state mean that
+         * this virtualPort is available.
+         */
+        ACTIVE,
+        /**
+         * Signifies that a virtualPort is currently unavailable.
+         */
+        DOWN;
+    }
+
+    /**
+     * Returns the virtualPort identifier.
+     *
+     * @return virtualPort identifier
+     */
+    VirtualPortId portId();
+
+    /**
+     * Returns the network identifier.
+     *
+     * @return tenantNetwork identifier
+     */
+    TenantNetworkId networkId();
+
+    /**
+     * Returns the symbolic name for the virtualPort.
+     *
+     * @return virtualPort name
+     */
+    String name();
+
+    /**
+     * Returns the administrative status of the port,which is up(true) or
+     * down(false).
+     *
+     * @return true if the administrative status of the port is up
+     */
+    boolean adminStateUp();
+
+    /**
+     * Returns the state.
+     *
+     * @return state
+     */
+    State state();
+
+    /**
+     * Returns the MAC address.
+     *
+     * @return MAC Address
+     */
+    MacAddress macAddress();
+
+    /**
+     * Returns the port tenantId.
+     *
+     * @return port tenantId
+     */
+    TenantId tenantId();
+
+    /**
+     * Returns the device identifier.
+     *
+     * @return deviceId
+     */
+    DeviceId deviceId();
+
+    /**
+     * Returns the identifier of the entity that uses this port.
+     *
+     * @return deviceOwner
+     */
+    String deviceOwner();
+
+    /**
+     * Returns the virtualPort allowedAddressPairs.
+     *
+     * @return virtualPort allowedAddressPairs
+     */
+    Collection<AllowedAddressPair> allowedAddressPairs();
+
+    /**
+     * Returns set of IP addresses for the port, include the IP addresses and subnet
+     * identity.
+     *
+     * @return FixedIps Set of fixedIp
+     */
+    Set<FixedIp> fixedIps();
+
+    /**
+     * Returns the virtualPort bindinghostId.
+     *
+     * @return virtualPort bindinghostId
+     */
+    BindingHostId bindingHostId();
+
+    /**
+     * Returns the virtualPort bindingVnicType.
+     *
+     * @return virtualPort bindingVnicType
+     */
+    String bindingVnicType();
+
+    /**
+     * Returns the virtualPort bindingVifType.
+     *
+     * @return virtualPort bindingVifType
+     */
+    String bindingVifType();
+
+    /**
+     * Returns the virtualPort bindingvifDetail.
+     *
+     * @return virtualPort bindingvifDetail
+     */
+    String bindingVifDetails();
+
+    /**
+     * Returns the security groups.
+     *
+     * @return port security groups
+     */
+    Iterable<SecurityGroup> securityGroups();
+}
index 0969ce1..3038bdf 100644 (file)
@@ -1,70 +1,70 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import java.util.Objects;\r
-\r
-/**\r
- * Immutable representation of a virtual port identifier.\r
- */\r
-public final class VirtualPortId {\r
-    private final String portId;\r
-    // Public construction is prohibited\r
-    private VirtualPortId(String virtualPortId) {\r
-        checkNotNull(virtualPortId, "VirtualPortId cannot be null");\r
-        this.portId = virtualPortId;\r
-    }\r
-\r
-    public String portId() {\r
-        return portId;\r
-    }\r
-\r
-    /**\r
-     * Creates a virtualPort id using the supplied portId.\r
-     *\r
-     * @param portId virtualport identifier\r
-     * @return VirtualPortId\r
-     */\r
-    public static VirtualPortId portId(String portId) {\r
-        return new VirtualPortId(portId);\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return Objects.hash(portId);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj instanceof VirtualPortId) {\r
-            final VirtualPortId that = (VirtualPortId) obj;\r
-            return this.getClass() == that.getClass()\r
-                    && Objects.equals(this.portId, that.portId);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return portId;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * Immutable representation of a virtual port identifier.
+ */
+public final class VirtualPortId {
+    private final String portId;
+    // Public construction is prohibited
+    private VirtualPortId(String virtualPortId) {
+        checkNotNull(virtualPortId, "VirtualPortId cannot be null");
+        this.portId = virtualPortId;
+    }
+
+    public String portId() {
+        return portId;
+    }
+
+    /**
+     * Creates a virtualPort id using the supplied portId.
+     *
+     * @param portId virtualport identifier
+     * @return VirtualPortId
+     */
+    public static VirtualPortId portId(String portId) {
+        return new VirtualPortId(portId);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(portId);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof VirtualPortId) {
+            final VirtualPortId that = (VirtualPortId) obj;
+            return this.getClass() == that.getClass()
+                    && Objects.equals(this.portId, that.portId);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return portId;
+    }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java
new file mode 100644 (file)
index 0000000..1622c80
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Command line interface for tenant networks.
+ */
+package org.onosproject.vtnrsc.cli.network;
index f8ee6b9..b0578a1 100644 (file)
@@ -92,7 +92,7 @@ public class SubnetUpdateCommand extends AbstractShellCommand {
 
     @Option(name = "-a", aliases = "--allocationPools",
             description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
-    Set<AllocationPool> allocationPools = Sets.newHashSet();;
+    Set<AllocationPool> allocationPools = Sets.newHashSet();
 
     @Override
     protected void execute() {
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java
new file mode 100644 (file)
index 0000000..b3a2ff5
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Command line interface for subnets.
+ */
+package org.onosproject.vtnrsc.cli.subnet;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java
new file mode 100644 (file)
index 0000000..fac214a
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Command line interface for virtual ports.
+ */
+package org.onosproject.vtnrsc.cli.virtualport;
index 71ea9ba..82eb961 100644 (file)
@@ -1,72 +1,72 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.subnet;\r
-\r
-import org.onosproject.vtnrsc.Subnet;\r
-import org.onosproject.vtnrsc.SubnetId;\r
-\r
-\r
-/**\r
- * Service for interacting with the inventory of subnets.\r
- */\r
-public interface SubnetService {\r
-    /**\r
-     * Returns the subnet with the specified identifier.\r
-     *\r
-     * @param subnetId subnet identifier\r
-     * @return true or false\r
-     */\r
-    boolean exists(SubnetId subnetId);\r
-    /**\r
-     * Returns a collection of the currently known subnets.\r
-     *\r
-     * @return iterable collection of subnets\r
-     */\r
-    Iterable<Subnet> getSubnets();\r
-\r
-    /**\r
-     * Returns the subnet with the specified identifier.\r
-     *\r
-     * @param subnetId subnet identifier\r
-     * @return subnet or null if one with the given identifier is not known\r
-     */\r
-    Subnet getSubnet(SubnetId subnetId);\r
-    /**\r
-     * Creates new subnets.\r
-     *\r
-     * @param subnets the iterable collection of subnets\r
-     * @return true  if the identifier subnet has been created right\r
-     */\r
-    boolean createSubnets(Iterable<Subnet> subnets);\r
-\r
-    /**\r
-     * Updates existing subnets.\r
-     *\r
-     * @param subnets the iterable collection of subnets\r
-     * @return true if all subnets were updated successfully\r
-     */\r
-    boolean updateSubnets(Iterable<Subnet> subnets);\r
-\r
-    /**\r
-     * Administratively removes the specified subnets from the store.\r
-     *\r
-     * @param subnetIds the iterable collection of  subnets identifier\r
-     * @return true if remove identifier subnets successfully\r
-     */\r
-    boolean removeSubnets(Iterable<SubnetId> subnetIds);\r
-\r
-\r
-}\r
+/*
+ * 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.subnet;
+
+import org.onosproject.vtnrsc.Subnet;
+import org.onosproject.vtnrsc.SubnetId;
+
+
+/**
+ * Service for interacting with the inventory of subnets.
+ */
+public interface SubnetService {
+    /**
+     * Returns the subnet with the specified identifier.
+     *
+     * @param subnetId subnet identifier
+     * @return true or false
+     */
+    boolean exists(SubnetId subnetId);
+    /**
+     * Returns a collection of the currently known subnets.
+     *
+     * @return iterable collection of subnets
+     */
+    Iterable<Subnet> getSubnets();
+
+    /**
+     * Returns the subnet with the specified identifier.
+     *
+     * @param subnetId subnet identifier
+     * @return subnet or null if one with the given identifier is not known
+     */
+    Subnet getSubnet(SubnetId subnetId);
+    /**
+     * Creates new subnets.
+     *
+     * @param subnets the iterable collection of subnets
+     * @return true  if the identifier subnet has been created right
+     */
+    boolean createSubnets(Iterable<Subnet> subnets);
+
+    /**
+     * Updates existing subnets.
+     *
+     * @param subnets the iterable collection of subnets
+     * @return true if all subnets were updated successfully
+     */
+    boolean updateSubnets(Iterable<Subnet> subnets);
+
+    /**
+     * Administratively removes the specified subnets from the store.
+     *
+     * @param subnetIds the iterable collection of  subnets identifier
+     * @return true if remove identifier subnets successfully
+     */
+    boolean removeSubnets(Iterable<SubnetId> subnetIds);
+
+
+}
index ab810a8..890beb2 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.subnet.impl;\r
-\r
-import org.apache.felix.scr.annotations.Activate;\r
-import org.apache.felix.scr.annotations.Component;\r
-import org.apache.felix.scr.annotations.Deactivate;\r
-import org.apache.felix.scr.annotations.Reference;\r
-import org.apache.felix.scr.annotations.ReferenceCardinality;\r
-import org.apache.felix.scr.annotations.Service;\r
-import org.onlab.packet.IpAddress;\r
-import org.onosproject.core.ApplicationId;\r
-import org.onosproject.core.CoreService;\r
-import org.onosproject.store.serializers.KryoNamespaces;\r
-import org.onosproject.store.service.Serializer;\r
-import org.onosproject.store.service.StorageService;\r
-import org.onosproject.vtnrsc.AllocationPool;\r
-import org.onosproject.vtnrsc.DefaultSubnet;\r
-import org.onosproject.vtnrsc.HostRoute;\r
-import org.onosproject.vtnrsc.Subnet;\r
-import org.onosproject.vtnrsc.SubnetId;\r
-import org.onosproject.vtnrsc.TenantId;\r
-import org.onosproject.vtnrsc.TenantNetworkId;\r
-import org.onosproject.vtnrsc.subnet.SubnetService;\r
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;\r
-import org.slf4j.Logger;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-import static org.slf4j.LoggerFactory.getLogger;\r
-\r
-/**\r
- * Provides implementation of the Subnet service.\r
- */\r
-@Component(immediate = true)\r
-@Service\r
-public class SubnetManager implements SubnetService {\r
-\r
-    private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";\r
-    private static final String SUBNET_NOT_NULL = "Subnet cannot be null";\r
-    private static final String SUBNET = "vtn-subnet-store";\r
-    private static final String VTNRSC_APP = "org.onosproject.vtnrsc";\r
-\r
-\r
-    private final Logger log = getLogger(getClass());\r
-\r
-    protected Map<SubnetId, Subnet> subnetStore;\r
-    protected ApplicationId appId;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected StorageService storageService;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected CoreService coreService;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected TenantNetworkService tenantNetworkService;\r
-\r
-    @Activate\r
-    public void activate() {\r
-\r
-        appId = coreService.registerApplication(VTNRSC_APP);\r
-\r
-        subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()\r
-                .withName(SUBNET)\r
-                .withApplicationId(appId)\r
-                .withPurgeOnUninstall()\r
-                .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),\r
-                                                 Subnet.class,\r
-                                                 SubnetId.class,\r
-                                                 TenantNetworkId.class,\r
-                                                 TenantId.class,\r
-                                                 HostRoute.class,\r
-                                                 Subnet.Mode.class,\r
-                                                 AllocationPool.class,\r
-                                                 DefaultSubnet.class,\r
-                                                 IpAddress.Version.class))\r
-                .build().asJavaMap();\r
-\r
-        log.info("Started");\r
-    }\r
-\r
-    @Deactivate\r
-    public void deactivate() {\r
-        log.info("Stopped");\r
-    }\r
-\r
-    @Override\r
-    public Iterable<Subnet> getSubnets() {\r
-        return Collections.unmodifiableCollection(subnetStore.values());\r
-    }\r
-\r
-    @Override\r
-    public Subnet getSubnet(SubnetId subnetId) {\r
-        checkNotNull(subnetId, SUBNET_ID_NULL);\r
-        return subnetStore.get(subnetId);\r
-    }\r
-\r
-    @Override\r
-    public boolean exists(SubnetId subnetId) {\r
-        checkNotNull(subnetId, SUBNET_ID_NULL);\r
-        return subnetStore.containsKey(subnetId);\r
-    }\r
-\r
-    @Override\r
-    public boolean createSubnets(Iterable<Subnet> subnets) {\r
-        checkNotNull(subnets, SUBNET_NOT_NULL);\r
-        for (Subnet subnet : subnets) {\r
-            if (!tenantNetworkService.exists(subnet.networkId())) {\r
-                log.debug("The network identifier that the subnet {} belong to is not exist",\r
-                          subnet.networkId().toString(), subnet.id().toString());\r
-                return false;\r
-            }\r
-            subnetStore.put(subnet.id(), subnet);\r
-            if (!subnetStore.containsKey(subnet.id())) {\r
-                log.debug("The identified subnet whose identifier is {}  create failed",\r
-                          subnet.id().toString());\r
-                return false;\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean updateSubnets(Iterable<Subnet> subnets) {\r
-        checkNotNull(subnets, SUBNET_NOT_NULL);\r
-        if (subnets != null) {\r
-            for (Subnet subnet : subnets) {\r
-                if (!subnetStore.containsKey(subnet.id())) {\r
-                    log.debug("The subnet is not exist whose identifier is {}",\r
-                              subnet.id().toString());\r
-                    return false;\r
-                }\r
-\r
-                subnetStore.put(subnet.id(), subnet);\r
-\r
-                if (!subnet.equals(subnetStore.get(subnet.id()))) {\r
-                    log.debug("The subnet is updated failed whose identifier is {}",\r
-                              subnet.id().toString());\r
-                    return false;\r
-                }\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean removeSubnets(Iterable<SubnetId> subnetIds) {\r
-        checkNotNull(subnetIds, SUBNET_ID_NULL);\r
-        if (subnetIds != null) {\r
-            for (SubnetId subnetId : subnetIds) {\r
-                subnetStore.remove(subnetId);\r
-                if (subnetStore.containsKey(subnetId)) {\r
-                    log.debug("The subnet created is failed whose identifier is {}",\r
-                              subnetId.toString());\r
-                    return false;\r
-                }\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-}\r
+/*
+ * 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.subnet.impl;
+
+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.apache.felix.scr.annotations.Service;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.vtnrsc.AllocationPool;
+import org.onosproject.vtnrsc.DefaultAllocationPool;
+import org.onosproject.vtnrsc.DefaultHostRoute;
+import org.onosproject.vtnrsc.DefaultSubnet;
+import org.onosproject.vtnrsc.HostRoute;
+import org.onosproject.vtnrsc.Subnet;
+import org.onosproject.vtnrsc.SubnetId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.subnet.SubnetService;
+import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
+import org.slf4j.Logger;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Provides implementation of the Subnet service.
+ */
+@Component(immediate = true)
+@Service
+public class SubnetManager implements SubnetService {
+
+    private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";
+    private static final String SUBNET_NOT_NULL = "Subnet cannot be null";
+    private static final String SUBNET = "vtn-subnet-store";
+    private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
+
+
+    private final Logger log = getLogger(getClass());
+
+    protected Map<SubnetId, Subnet> subnetStore;
+    protected ApplicationId appId;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected StorageService storageService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected TenantNetworkService tenantNetworkService;
+
+    @Activate
+    public void activate() {
+
+        appId = coreService.registerApplication(VTNRSC_APP);
+
+        subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()
+                .withName(SUBNET)
+                .withApplicationId(appId)
+                .withPurgeOnUninstall()
+                .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
+                                                 Subnet.class,
+                                                 SubnetId.class,
+                                                 TenantNetworkId.class,
+                                                 TenantId.class,
+                                                 HostRoute.class,
+                                                 DefaultHostRoute.class,
+                                                 Subnet.Mode.class,
+                                                 AllocationPool.class,
+                                                 DefaultAllocationPool.class,
+                                                 DefaultSubnet.class,
+                                                 IpAddress.Version.class))
+                .build().asJavaMap();
+
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        log.info("Stopped");
+    }
+
+    @Override
+    public Iterable<Subnet> getSubnets() {
+        return Collections.unmodifiableCollection(subnetStore.values());
+    }
+
+    @Override
+    public Subnet getSubnet(SubnetId subnetId) {
+        checkNotNull(subnetId, SUBNET_ID_NULL);
+        return subnetStore.get(subnetId);
+    }
+
+    @Override
+    public boolean exists(SubnetId subnetId) {
+        checkNotNull(subnetId, SUBNET_ID_NULL);
+        return subnetStore.containsKey(subnetId);
+    }
+
+    @Override
+    public boolean createSubnets(Iterable<Subnet> subnets) {
+        checkNotNull(subnets, SUBNET_NOT_NULL);
+        for (Subnet subnet : subnets) {
+            if (!tenantNetworkService.exists(subnet.networkId())) {
+                log.debug("The network identifier that the subnet {} belong to is not exist",
+                          subnet.networkId().toString(), subnet.id().toString());
+                return false;
+            }
+            subnetStore.put(subnet.id(), subnet);
+            if (!subnetStore.containsKey(subnet.id())) {
+                log.debug("The identified subnet whose identifier is {}  create failed",
+                          subnet.id().toString());
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean updateSubnets(Iterable<Subnet> subnets) {
+        checkNotNull(subnets, SUBNET_NOT_NULL);
+        if (subnets != null) {
+            for (Subnet subnet : subnets) {
+                if (!subnetStore.containsKey(subnet.id())) {
+                    log.debug("The subnet is not exist whose identifier is {}",
+                              subnet.id().toString());
+                    return false;
+                }
+
+                subnetStore.put(subnet.id(), subnet);
+
+                if (!subnet.equals(subnetStore.get(subnet.id()))) {
+                    log.debug("The subnet is updated failed whose identifier is {}",
+                              subnet.id().toString());
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean removeSubnets(Iterable<SubnetId> subnetIds) {
+        checkNotNull(subnetIds, SUBNET_ID_NULL);
+        if (subnetIds != null) {
+            for (SubnetId subnetId : subnetIds) {
+                subnetStore.remove(subnetId);
+                if (subnetStore.containsKey(subnetId)) {
+                    log.debug("The subnet created is failed whose identifier is {}",
+                              subnetId.toString());
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java
new file mode 100644 (file)
index 0000000..79040d8
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides implementation of the Subnet service.
+ */
+package org.onosproject.vtnrsc.subnet.impl;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java
new file mode 100644 (file)
index 0000000..7b2bdb9
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Service for interacting with the inventory of subnets.
+ */
+package org.onosproject.vtnrsc.subnet;
index 56e8bce..e246cc4 100644 (file)
@@ -1,80 +1,80 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.tenantnetwork;\r
-\r
-import org.onosproject.vtnrsc.TenantNetwork;\r
-import org.onosproject.vtnrsc.TenantNetworkId;\r
-\r
-/**\r
- * Service for interacting with the inventory of tenantNetwork.\r
- */\r
-public interface TenantNetworkService {\r
-\r
-    /**\r
-     * Returns if the tenantNetwork is existed.\r
-     *\r
-     * @param networkId tenantNetwork identifier\r
-     * @return true or false if one with the given identifier exists.\r
-     */\r
-    boolean exists(TenantNetworkId networkId);\r
-\r
-    /**\r
-     * Returns the number of tenantNetwork known to the system.\r
-     *\r
-     * @return number of tenantNetwork.\r
-     */\r
-    int getNetworkCount();\r
-\r
-    /**\r
-     * Returns an iterable collection of the currently known tenantNetwork.\r
-     *\r
-     * @return collection of tenantNetwork.\r
-     */\r
-    Iterable<TenantNetwork> getNetworks();\r
-\r
-    /**\r
-     * Returns the tenantNetwork with the identifier.\r
-     *\r
-     * @param networkId TenantNetwork identifier\r
-     * @return TenantNetwork or null if one with the given identifier is not\r
-     *         known.\r
-     */\r
-    TenantNetwork getNetwork(TenantNetworkId networkId);\r
-\r
-    /**\r
-     * Creates tenantNetworks by networks.\r
-     *\r
-     * @param networks the collection of tenantNetworks\r
-     * @return true if all given identifiers created successfully.\r
-     */\r
-    boolean createNetworks(Iterable<TenantNetwork> networks);\r
-\r
-    /**\r
-     * Updates tenantNetworks by tenantNetworks.\r
-     *\r
-     * @param networks the collection of tenantNetworks\r
-     * @return true if all given identifiers updated successfully.\r
-     */\r
-    boolean updateNetworks(Iterable<TenantNetwork> networks);\r
-\r
-    /**\r
-     * Deletes tenantNetwork by tenantNetworkIds.\r
-     *\r
-     * @param networksIds the collection of tenantNetworkIds\r
-     * @return true if the specified tenantNetworks deleted successfully.\r
-     */\r
-    boolean removeNetworks(Iterable<TenantNetworkId> networksIds);\r
-}\r
+/*
+ * 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.tenantnetwork;
+
+import org.onosproject.vtnrsc.TenantNetwork;
+import org.onosproject.vtnrsc.TenantNetworkId;
+
+/**
+ * Service for interacting with the inventory of tenantNetwork.
+ */
+public interface TenantNetworkService {
+
+    /**
+     * Returns if the tenantNetwork is existed.
+     *
+     * @param networkId tenantNetwork identifier
+     * @return true or false if one with the given identifier exists.
+     */
+    boolean exists(TenantNetworkId networkId);
+
+    /**
+     * Returns the number of tenantNetwork known to the system.
+     *
+     * @return number of tenantNetwork.
+     */
+    int getNetworkCount();
+
+    /**
+     * Returns an iterable collection of the currently known tenantNetwork.
+     *
+     * @return collection of tenantNetwork.
+     */
+    Iterable<TenantNetwork> getNetworks();
+
+    /**
+     * Returns the tenantNetwork with the identifier.
+     *
+     * @param networkId TenantNetwork identifier
+     * @return TenantNetwork or null if one with the given identifier is not
+     *         known.
+     */
+    TenantNetwork getNetwork(TenantNetworkId networkId);
+
+    /**
+     * Creates tenantNetworks by networks.
+     *
+     * @param networks the collection of tenantNetworks
+     * @return true if all given identifiers created successfully.
+     */
+    boolean createNetworks(Iterable<TenantNetwork> networks);
+
+    /**
+     * Updates tenantNetworks by tenantNetworks.
+     *
+     * @param networks the collection of tenantNetworks
+     * @return true if all given identifiers updated successfully.
+     */
+    boolean updateNetworks(Iterable<TenantNetwork> networks);
+
+    /**
+     * Deletes tenantNetwork by tenantNetworkIds.
+     *
+     * @param networksIds the collection of tenantNetworkIds
+     * @return true if the specified tenantNetworks deleted successfully.
+     */
+    boolean removeNetworks(Iterable<TenantNetworkId> networksIds);
+}
index c5290ad..0dfc99e 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.tenantnetwork.impl;\r
-\r
-import org.apache.felix.scr.annotations.Activate;\r
-import org.apache.felix.scr.annotations.Component;\r
-import org.apache.felix.scr.annotations.Deactivate;\r
-import org.apache.felix.scr.annotations.Reference;\r
-import org.apache.felix.scr.annotations.ReferenceCardinality;\r
-import org.apache.felix.scr.annotations.Service;\r
-import org.onosproject.core.ApplicationId;\r
-import org.onosproject.core.CoreService;\r
-import org.onosproject.store.serializers.KryoNamespaces;\r
-import org.onosproject.store.service.Serializer;\r
-import org.onosproject.store.service.StorageService;\r
-import org.onosproject.vtnrsc.DefaultTenantNetwork;\r
-import org.onosproject.vtnrsc.PhysicalNetwork;\r
-import org.onosproject.vtnrsc.SegmentationId;\r
-import org.onosproject.vtnrsc.TenantId;\r
-import org.onosproject.vtnrsc.TenantNetwork;\r
-import org.onosproject.vtnrsc.TenantNetworkId;\r
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;\r
-import org.slf4j.Logger;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-import static org.slf4j.LoggerFactory.getLogger;\r
-\r
-/**\r
- * Provides implementation of the tenantNetworkService.\r
- */\r
-@Component(immediate = true)\r
-@Service\r
-public class TenantNetworkManager implements TenantNetworkService {\r
-\r
-    private static final String NETWORK_ID_NULL = "Network ID cannot be null";\r
-    private static final String NETWORK_NOT_NULL = "Network ID cannot be null";\r
-    private static final String TENANTNETWORK = "vtn-tenant-network-store";\r
-    private static final String VTNRSC_APP = "org.onosproject.vtnrsc";\r
-\r
-    protected Map<TenantNetworkId, TenantNetwork> networkIdAsKeyStore;\r
-    protected ApplicationId appId;\r
-\r
-    private final Logger log = getLogger(getClass());\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected StorageService storageService;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected CoreService coreService;\r
-\r
-\r
-    @Activate\r
-    public void activate() {\r
-\r
-        appId = coreService.registerApplication(VTNRSC_APP);\r
-\r
-        networkIdAsKeyStore = storageService.<TenantNetworkId, TenantNetwork>consistentMapBuilder()\r
-                .withName(TENANTNETWORK)\r
-                .withApplicationId(appId)\r
-                .withPurgeOnUninstall()\r
-                .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),\r
-                                                 TenantNetworkId.class,\r
-                                                 DefaultTenantNetwork.class,\r
-                                                 TenantNetwork.State.class,\r
-                                                 TenantId.class,\r
-                                                 TenantNetwork.Type.class,\r
-                                                 PhysicalNetwork.class,\r
-                                                 SegmentationId.class))\r
-                .build().asJavaMap();\r
-\r
-        log.info("Started");\r
-    }\r
-\r
-    @Deactivate\r
-    public void deactivate() {\r
-        log.info("Stopped");\r
-    }\r
-\r
-    @Override\r
-    public boolean exists(TenantNetworkId networkId) {\r
-        checkNotNull(networkId, NETWORK_ID_NULL);\r
-        return networkIdAsKeyStore.containsKey(networkId);\r
-    }\r
-\r
-    @Override\r
-    public int getNetworkCount() {\r
-        return networkIdAsKeyStore.size();\r
-    }\r
-\r
-    @Override\r
-    public Iterable<TenantNetwork> getNetworks() {\r
-        return Collections.unmodifiableCollection(networkIdAsKeyStore.values());\r
-    }\r
-\r
-    @Override\r
-    public TenantNetwork getNetwork(TenantNetworkId networkId) {\r
-        checkNotNull(networkId, NETWORK_ID_NULL);\r
-        return networkIdAsKeyStore.get(networkId);\r
-    }\r
-\r
-    @Override\r
-    public boolean createNetworks(Iterable<TenantNetwork> networks) {\r
-        checkNotNull(networks, NETWORK_NOT_NULL);\r
-        for (TenantNetwork network : networks) {\r
-            networkIdAsKeyStore.put(network.id(), network);\r
-            if (!networkIdAsKeyStore.containsKey(network.id())) {\r
-                log.debug("The tenantNetwork is created failed which identifier was {}", network.id()\r
-                        .toString());\r
-                return false;\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean updateNetworks(Iterable<TenantNetwork> networks) {\r
-        checkNotNull(networks, NETWORK_NOT_NULL);\r
-        for (TenantNetwork network : networks) {\r
-            if (!networkIdAsKeyStore.containsKey(network.id())) {\r
-                log.debug("The tenantNetwork is not exist whose identifier was {} ",\r
-                          network.id().toString());\r
-                return false;\r
-            }\r
-\r
-            networkIdAsKeyStore.put(network.id(), network);\r
-\r
-            if (!network.equals(networkIdAsKeyStore.get(network.id()))) {\r
-                log.debug("The tenantNetwork is updated failed whose identifier was {} ",\r
-                          network.id().toString());\r
-                return false;\r
-            }\r
-\r
-        }\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean removeNetworks(Iterable<TenantNetworkId> networkIds) {\r
-        checkNotNull(networkIds, NETWORK_NOT_NULL);\r
-        for (TenantNetworkId networkId : networkIds) {\r
-            networkIdAsKeyStore.remove(networkId);\r
-            if (networkIdAsKeyStore.containsKey(networkId)) {\r
-                log.debug("The tenantNetwork is removed failed whose identifier was {}",\r
-                          networkId.toString());\r
-                return false;\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-}\r
+/*
+ * 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.tenantnetwork.impl;
+
+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.apache.felix.scr.annotations.Service;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.vtnrsc.DefaultTenantNetwork;
+import org.onosproject.vtnrsc.PhysicalNetwork;
+import org.onosproject.vtnrsc.SegmentationId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetwork;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
+import org.slf4j.Logger;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Provides implementation of the tenantNetworkService.
+ */
+@Component(immediate = true)
+@Service
+public class TenantNetworkManager implements TenantNetworkService {
+
+    private static final String NETWORK_ID_NULL = "Network ID cannot be null";
+    private static final String NETWORK_NOT_NULL = "Network ID cannot be null";
+    private static final String TENANTNETWORK = "vtn-tenant-network-store";
+    private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
+
+    protected Map<TenantNetworkId, TenantNetwork> networkIdAsKeyStore;
+    protected ApplicationId appId;
+
+    private final Logger log = getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected StorageService storageService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+
+
+    @Activate
+    public void activate() {
+
+        appId = coreService.registerApplication(VTNRSC_APP);
+
+        networkIdAsKeyStore = storageService.<TenantNetworkId, TenantNetwork>consistentMapBuilder()
+                .withName(TENANTNETWORK)
+                .withApplicationId(appId)
+                .withPurgeOnUninstall()
+                .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
+                                                 TenantNetworkId.class,
+                                                 DefaultTenantNetwork.class,
+                                                 TenantNetwork.State.class,
+                                                 TenantId.class,
+                                                 TenantNetwork.Type.class,
+                                                 PhysicalNetwork.class,
+                                                 SegmentationId.class))
+                .build().asJavaMap();
+
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        log.info("Stopped");
+    }
+
+    @Override
+    public boolean exists(TenantNetworkId networkId) {
+        checkNotNull(networkId, NETWORK_ID_NULL);
+        return networkIdAsKeyStore.containsKey(networkId);
+    }
+
+    @Override
+    public int getNetworkCount() {
+        return networkIdAsKeyStore.size();
+    }
+
+    @Override
+    public Iterable<TenantNetwork> getNetworks() {
+        return Collections.unmodifiableCollection(networkIdAsKeyStore.values());
+    }
+
+    @Override
+    public TenantNetwork getNetwork(TenantNetworkId networkId) {
+        checkNotNull(networkId, NETWORK_ID_NULL);
+        return networkIdAsKeyStore.get(networkId);
+    }
+
+    @Override
+    public boolean createNetworks(Iterable<TenantNetwork> networks) {
+        checkNotNull(networks, NETWORK_NOT_NULL);
+        for (TenantNetwork network : networks) {
+            networkIdAsKeyStore.put(network.id(), network);
+            if (!networkIdAsKeyStore.containsKey(network.id())) {
+                log.debug("The tenantNetwork is created failed which identifier was {}", network.id()
+                        .toString());
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean updateNetworks(Iterable<TenantNetwork> networks) {
+        checkNotNull(networks, NETWORK_NOT_NULL);
+        for (TenantNetwork network : networks) {
+            if (!networkIdAsKeyStore.containsKey(network.id())) {
+                log.debug("The tenantNetwork is not exist whose identifier was {} ",
+                          network.id().toString());
+                return false;
+            }
+
+            networkIdAsKeyStore.put(network.id(), network);
+
+            if (!network.equals(networkIdAsKeyStore.get(network.id()))) {
+                log.debug("The tenantNetwork is updated failed whose identifier was {} ",
+                          network.id().toString());
+                return false;
+            }
+
+        }
+        return true;
+    }
+
+    @Override
+    public boolean removeNetworks(Iterable<TenantNetworkId> networkIds) {
+        checkNotNull(networkIds, NETWORK_NOT_NULL);
+        for (TenantNetworkId networkId : networkIds) {
+            networkIdAsKeyStore.remove(networkId);
+            if (networkIdAsKeyStore.containsKey(networkId)) {
+                log.debug("The tenantNetwork is removed failed whose identifier was {}",
+                          networkId.toString());
+                return false;
+            }
+        }
+        return true;
+    }
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java
new file mode 100644 (file)
index 0000000..f381fda
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation of service for interacting with the inventory of tenant networks.
+ */
+package org.onosproject.vtnrsc.tenantnetwork.impl;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java
new file mode 100644 (file)
index 0000000..1489c97
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Service for interacting with the inventory of tenant networks.
+ */
+package org.onosproject.vtnrsc.tenantnetwork;
index f09caf2..6f3cf65 100644 (file)
@@ -1,72 +1,72 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.tunnel;\r
-\r
-import org.onosproject.vtnrsc.Subnet;\r
-import org.onosproject.vtnrsc.SubnetId;\r
-\r
-\r
-/**\r
- * Service for interacting with the inventory of subnets.\r
- */\r
-public interface TunnelConfigService {\r
-    /**\r
-     * Returns the subnet with the specified identifier.\r
-     *\r
-     * @param subnetId subnet identifier\r
-     * @return true or false\r
-     */\r
-    boolean exists(SubnetId subnetId);\r
-    /**\r
-     * Returns a collection of the currently known subnets.\r
-     *\r
-     * @return iterable collection of subnets\r
-     */\r
-    Iterable<Subnet> getSubnets();\r
-\r
-    /**\r
-     * Returns the subnet with the specified identifier.\r
-     *\r
-     * @param subnetId subnet identifier\r
-     * @return subnet or null if one with the given identifier is not known\r
-     */\r
-    Subnet getSubnet(SubnetId subnetId);\r
-    /**\r
-     * Creates new subnets.\r
-     *\r
-     * @param subnets the iterable collection of subnets\r
-     * @return true  if the identifier subnet has been created right\r
-     */\r
-    boolean createSubnets(Iterable<Subnet> subnets);\r
-\r
-    /**\r
-     * Updates existing subnets.\r
-     *\r
-     * @param subnets the iterable collection of subnets\r
-     * @return true if all subnets were updated successfully\r
-     */\r
-    boolean updateSubnets(Iterable<Subnet> subnets);\r
-\r
-    /**\r
-     * Administratively removes the specified subnets from the store.\r
-     *\r
-     * @param subnetIds the iterable collection of  subnets identifier\r
-     * @return true if remove identifier subnets successfully\r
-     */\r
-    boolean removeSubnets(Iterable<SubnetId> subnetIds);\r
-\r
-\r
-}\r
+/*
+ * 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.tunnel;
+
+import org.onosproject.vtnrsc.Subnet;
+import org.onosproject.vtnrsc.SubnetId;
+
+
+/**
+ * Service for interacting with the inventory of subnets.
+ */
+public interface TunnelConfigService {
+    /**
+     * Returns the subnet with the specified identifier.
+     *
+     * @param subnetId subnet identifier
+     * @return true or false
+     */
+    boolean exists(SubnetId subnetId);
+    /**
+     * Returns a collection of the currently known subnets.
+     *
+     * @return iterable collection of subnets
+     */
+    Iterable<Subnet> getSubnets();
+
+    /**
+     * Returns the subnet with the specified identifier.
+     *
+     * @param subnetId subnet identifier
+     * @return subnet or null if one with the given identifier is not known
+     */
+    Subnet getSubnet(SubnetId subnetId);
+    /**
+     * Creates new subnets.
+     *
+     * @param subnets the iterable collection of subnets
+     * @return true  if the identifier subnet has been created right
+     */
+    boolean createSubnets(Iterable<Subnet> subnets);
+
+    /**
+     * Updates existing subnets.
+     *
+     * @param subnets the iterable collection of subnets
+     * @return true if all subnets were updated successfully
+     */
+    boolean updateSubnets(Iterable<Subnet> subnets);
+
+    /**
+     * Administratively removes the specified subnets from the store.
+     *
+     * @param subnetIds the iterable collection of  subnets identifier
+     * @return true if remove identifier subnets successfully
+     */
+    boolean removeSubnets(Iterable<SubnetId> subnetIds);
+
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java
new file mode 100644 (file)
index 0000000..3a84e6e
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Service for interacting with the inventory of subnets.
+ */
+package org.onosproject.vtnrsc.tunnel;
index 24ddb9f..05ebccf 100644 (file)
-/*\r
- * Copyright 2015 Open Porting Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.virtualport;\r
-\r
-import java.util.Collection;\r
-\r
-import org.onosproject.net.DeviceId;\r
-import org.onosproject.vtnrsc.TenantId;\r
-import org.onosproject.vtnrsc.TenantNetworkId;\r
-import org.onosproject.vtnrsc.VirtualPort;\r
-import org.onosproject.vtnrsc.VirtualPortId;\r
-\r
-/**\r
- * Service for interacting with the inventory of virtualPort.\r
- */\r
-public interface VirtualPortService {\r
-    /**\r
-     * Returns if the virtualPort is existed.\r
-     *\r
-     * @param virtualPortId virtualPort identifier\r
-     * @return true or false if one with the given identifier is not existed.\r
-     */\r
-    boolean exists(VirtualPortId virtualPortId);\r
-\r
-    /**\r
-     * Returns the virtualPort with the identifier.\r
-     *\r
-     * @param virtualPortId virtualPort ID\r
-     * @return VirtualPort or null if one with the given ID is not know.\r
-     */\r
-    VirtualPort getPort(VirtualPortId virtualPortId);\r
-\r
-    /**\r
-     * Returns the collection of the currently known virtualPort.\r
-     * @return collection of VirtualPort.\r
-     */\r
-    Collection<VirtualPort> getPorts();\r
-\r
-    /**\r
-     * Returns the collection of the virtualPorts associated with the networkId.\r
-     *\r
-     * @param networkId  the network identifer\r
-     * @return collection of virtualPort.\r
-     */\r
-    Collection<VirtualPort> getPorts(TenantNetworkId networkId);\r
-\r
-    /**\r
-     * Returns the collection of the virtualPorts associated with the tenantId.\r
-     *\r
-     * @param tenantId   the tenant identifier\r
-     * @return collection of virtualPorts.\r
-     */\r
-    Collection<VirtualPort> getPorts(TenantId tenantId);\r
-\r
-    /**\r
-     * Returns the collection of the virtualPorts associated with the deviceId.\r
-     *\r
-     * @param deviceId   the device identifier\r
-     * @return collection of virtualPort.\r
-     */\r
-    Collection<VirtualPort> getPorts(DeviceId deviceId);\r
-\r
-    /**\r
-     * Creates virtualPorts by virtualPorts.\r
-     *\r
-     * @param virtualPorts the iterable collection of virtualPorts\r
-     * @return true if all given identifiers created successfully.\r
-     */\r
-    boolean createPorts(Iterable<VirtualPort> virtualPorts);\r
-\r
-    /**\r
-     * Updates virtualPorts by virtualPorts.\r
-     *\r
-     * @param virtualPorts the iterable  collection of virtualPorts\r
-     * @return true if all given identifiers updated successfully.\r
-     */\r
-    boolean updatePorts(Iterable<VirtualPort> virtualPorts);\r
-\r
-    /**\r
-     * Deletes virtualPortIds by virtualPortIds.\r
-     *\r
-     * @param virtualPortIds the iterable collection of virtualPort identifiers\r
-     * @return true or false if one with the given identifier to delete is\r
-     *         successfully.\r
-     */\r
-    boolean removePorts(Iterable<VirtualPortId> virtualPortIds);\r
-}\r
+/*
+ * 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.virtualport;
+
+import java.util.Collection;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.VirtualPort;
+import org.onosproject.vtnrsc.VirtualPortId;
+
+/**
+ * Service for interacting with the inventory of virtualPort.
+ */
+public interface VirtualPortService {
+    /**
+     * Returns if the virtualPort is existed.
+     *
+     * @param virtualPortId virtualPort identifier
+     * @return true or false if one with the given identifier is not existed.
+     */
+    boolean exists(VirtualPortId virtualPortId);
+
+    /**
+     * Returns the virtualPort with the identifier.
+     *
+     * @param virtualPortId virtualPort ID
+     * @return VirtualPort or null if one with the given ID is not know.
+     */
+    VirtualPort getPort(VirtualPortId virtualPortId);
+
+    /**
+     * Returns the collection of the currently known virtualPort.
+     * @return collection of VirtualPort.
+     */
+    Collection<VirtualPort> getPorts();
+
+    /**
+     * Returns the collection of the virtualPorts associated with the networkId.
+     *
+     * @param networkId  the network identifer
+     * @return collection of virtualPort.
+     */
+    Collection<VirtualPort> getPorts(TenantNetworkId networkId);
+
+    /**
+     * Returns the collection of the virtualPorts associated with the tenantId.
+     *
+     * @param tenantId   the tenant identifier
+     * @return collection of virtualPorts.
+     */
+    Collection<VirtualPort> getPorts(TenantId tenantId);
+
+    /**
+     * Returns the collection of the virtualPorts associated with the deviceId.
+     *
+     * @param deviceId   the device identifier
+     * @return collection of virtualPort.
+     */
+    Collection<VirtualPort> getPorts(DeviceId deviceId);
+
+    /**
+     * Creates virtualPorts by virtualPorts.
+     *
+     * @param virtualPorts the iterable collection of virtualPorts
+     * @return true if all given identifiers created successfully.
+     */
+    boolean createPorts(Iterable<VirtualPort> virtualPorts);
+
+    /**
+     * Updates virtualPorts by virtualPorts.
+     *
+     * @param virtualPorts the iterable  collection of virtualPorts
+     * @return true if all given identifiers updated successfully.
+     */
+    boolean updatePorts(Iterable<VirtualPort> virtualPorts);
+
+    /**
+     * Deletes virtualPortIds by virtualPortIds.
+     *
+     * @param virtualPortIds the iterable collection of virtualPort identifiers
+     * @return true or false if one with the given identifier to delete is
+     *         successfully.
+     */
+    boolean removePorts(Iterable<VirtualPortId> virtualPortIds);
+}
index e0c49f5..bea0fd5 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.virtualport.impl;\r
-\r
-import org.apache.felix.scr.annotations.Activate;\r
-import org.apache.felix.scr.annotations.Component;\r
-import org.apache.felix.scr.annotations.Deactivate;\r
-import org.apache.felix.scr.annotations.Reference;\r
-import org.apache.felix.scr.annotations.ReferenceCardinality;\r
-import org.apache.felix.scr.annotations.Service;\r
-import org.onlab.packet.IpAddress;\r
-import org.onosproject.core.ApplicationId;\r
-import org.onosproject.core.CoreService;\r
-import org.onosproject.net.DeviceId;\r
-import org.onosproject.store.serializers.KryoNamespaces;\r
-import org.onosproject.store.service.Serializer;\r
-import org.onosproject.store.service.StorageService;\r
-import org.onosproject.vtnrsc.AllowedAddressPair;\r
-import org.onosproject.vtnrsc.BindingHostId;\r
-import org.onosproject.vtnrsc.DefaultVirtualPort;\r
-import org.onosproject.vtnrsc.FixedIp;\r
-import org.onosproject.vtnrsc.SecurityGroup;\r
-import org.onosproject.vtnrsc.SubnetId;\r
-import org.onosproject.vtnrsc.TenantId;\r
-import org.onosproject.vtnrsc.TenantNetworkId;\r
-import org.onosproject.vtnrsc.VirtualPort;\r
-import org.onosproject.vtnrsc.VirtualPortId;\r
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;\r
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-/**\r
- * Provides implementation of the VirtualPort APIs.\r
- */\r
-@Component(immediate = true)\r
-@Service\r
-public class VirtualPortManager implements VirtualPortService {\r
-\r
-    private final Logger log = LoggerFactory.getLogger(getClass());\r
-\r
-    private static final String VIRTUALPORT = "vtn-virtual-port";\r
-    private static final String VTNRSC_APP = "org.onosproject.vtnrsc";\r
-\r
-    private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null";\r
-    private static final String VIRTUALPORT_NOT_NULL = "VirtualPort  cannot be null";\r
-    private static final String TENANTID_NOT_NULL = "TenantId  cannot be null";\r
-    private static final String NETWORKID_NOT_NULL = "NetworkId  cannot be null";\r
-    private static final String DEVICEID_NOT_NULL = "DeviceId  cannot be null";\r
-\r
-    protected Map<VirtualPortId, VirtualPort> vPortStore;\r
-    protected ApplicationId appId;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected StorageService storageService;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected TenantNetworkService networkService;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected CoreService coreService;\r
-\r
-    @Activate\r
-    public void activate() {\r
-\r
-        appId = coreService.registerApplication(VTNRSC_APP);\r
-\r
-        vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder()\r
-                .withName(VIRTUALPORT)\r
-                .withApplicationId(appId)\r
-                .withPurgeOnUninstall()\r
-                .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),\r
-                                                 VirtualPortId.class,\r
-                                                 TenantNetworkId.class,\r
-                                                 VirtualPort.State.class,\r
-                                                 TenantId.class,\r
-                                                 AllowedAddressPair.class,\r
-                                                 FixedIp.class,\r
-                                                 BindingHostId.class,\r
-                                                 SecurityGroup.class,\r
-                                                 SubnetId.class,\r
-                                                 IpAddress.class,\r
-                                                 DefaultVirtualPort.class))\r
-                .build().asJavaMap();\r
-        log.info("Started");\r
-    }\r
-\r
-    @Deactivate\r
-    public void deactivate() {\r
-        vPortStore.clear();\r
-        log.info("Stoppped");\r
-    }\r
-\r
-    @Override\r
-    public boolean exists(VirtualPortId vPortId) {\r
-        checkNotNull(vPortId, VIRTUALPORT_ID_NULL);\r
-        return vPortStore.containsKey(vPortId);\r
-    }\r
-\r
-    @Override\r
-    public VirtualPort getPort(VirtualPortId vPortId) {\r
-        checkNotNull(vPortId, VIRTUALPORT_ID_NULL);\r
-        return vPortStore.get(vPortId);\r
-    }\r
-\r
-    @Override\r
-    public Collection<VirtualPort> getPorts() {\r
-        return Collections.unmodifiableCollection(vPortStore.values());\r
-    }\r
-\r
-    @Override\r
-    public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {\r
-        checkNotNull(networkId, NETWORKID_NOT_NULL);\r
-        Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values();\r
-        for (VirtualPort vPort : vPortWithNetworkIds) {\r
-            if (!vPort.networkId().equals(networkId)) {\r
-                vPortWithNetworkIds.remove(vPort);\r
-            }\r
-        }\r
-        return vPortWithNetworkIds;\r
-    }\r
-\r
-    @Override\r
-    public Collection<VirtualPort> getPorts(TenantId tenantId) {\r
-        checkNotNull(tenantId, TENANTID_NOT_NULL);\r
-        Collection<VirtualPort> vPortWithTenantIds = vPortStore.values();\r
-        for (VirtualPort vPort : vPortWithTenantIds) {\r
-            if (!vPort.tenantId().equals(tenantId)) {\r
-                vPortWithTenantIds.remove(vPort);\r
-            }\r
-        }\r
-        return vPortWithTenantIds;\r
-    }\r
-\r
-    @Override\r
-    public Collection<VirtualPort> getPorts(DeviceId deviceId) {\r
-        checkNotNull(deviceId, DEVICEID_NOT_NULL);\r
-        Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values();\r
-        for (VirtualPort vPort : vPortWithDeviceIds) {\r
-            if (!vPort.deviceId().equals(deviceId)) {\r
-                vPortWithDeviceIds.remove(vPort);\r
-            }\r
-        }\r
-        return vPortWithDeviceIds;\r
-    }\r
-\r
-    @Override\r
-    public boolean createPorts(Iterable<VirtualPort> vPorts) {\r
-        checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);\r
-        for (VirtualPort vPort : vPorts) {\r
-            log.debug("vPortId is  {} ", vPort.portId().toString());\r
-            vPortStore.put(vPort.portId(), vPort);\r
-            if (!vPortStore.containsKey(vPort.portId())) {\r
-                log.debug("The virtualPort is created failed whose identifier is {} ",\r
-                          vPort.portId().toString());\r
-                return false;\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean updatePorts(Iterable<VirtualPort> vPorts) {\r
-        checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);\r
-        if (vPorts != null) {\r
-            for (VirtualPort vPort : vPorts) {\r
-                vPortStore.put(vPort.portId(), vPort);\r
-                if (!vPortStore.containsKey(vPort.portId())) {\r
-                    log.debug("The virtualPort is not exist whose identifier is {}",\r
-                              vPort.portId().toString());\r
-                    return false;\r
-                }\r
-\r
-                vPortStore.put(vPort.portId(), vPort);\r
-\r
-                if (!vPort.equals(vPortStore.get(vPort.portId()))) {\r
-                    log.debug("The virtualPort is updated failed whose  identifier is {}",\r
-                              vPort.portId().toString());\r
-                    return false;\r
-                }\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean removePorts(Iterable<VirtualPortId> vPortIds) {\r
-        checkNotNull(vPortIds, VIRTUALPORT_ID_NULL);\r
-        if (vPortIds != null) {\r
-            for (VirtualPortId vPortId : vPortIds) {\r
-                vPortStore.remove(vPortId);\r
-                if (vPortStore.containsKey(vPortId)) {\r
-                    log.debug("The virtualPort is removed failed whose identifier is {}",\r
-                              vPortId.toString());\r
-                    return false;\r
-                }\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-\r
-}\r
+/*
+ * 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.virtualport.impl;
+
+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.apache.felix.scr.annotations.Service;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.vtnrsc.AllowedAddressPair;
+import org.onosproject.vtnrsc.BindingHostId;
+import org.onosproject.vtnrsc.DefaultVirtualPort;
+import org.onosproject.vtnrsc.FixedIp;
+import org.onosproject.vtnrsc.SecurityGroup;
+import org.onosproject.vtnrsc.SubnetId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.VirtualPort;
+import org.onosproject.vtnrsc.VirtualPortId;
+import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
+import org.onosproject.vtnrsc.virtualport.VirtualPortService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Provides implementation of the VirtualPort APIs.
+ */
+@Component(immediate = true)
+@Service
+public class VirtualPortManager implements VirtualPortService {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private static final String VIRTUALPORT = "vtn-virtual-port";
+    private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
+
+    private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null";
+    private static final String VIRTUALPORT_NOT_NULL = "VirtualPort  cannot be null";
+    private static final String TENANTID_NOT_NULL = "TenantId  cannot be null";
+    private static final String NETWORKID_NOT_NULL = "NetworkId  cannot be null";
+    private static final String DEVICEID_NOT_NULL = "DeviceId  cannot be null";
+
+    protected Map<VirtualPortId, VirtualPort> vPortStore;
+    protected ApplicationId appId;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected StorageService storageService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected TenantNetworkService networkService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+
+    @Activate
+    public void activate() {
+
+        appId = coreService.registerApplication(VTNRSC_APP);
+
+        vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder()
+                .withName(VIRTUALPORT)
+                .withApplicationId(appId)
+                .withPurgeOnUninstall()
+                .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
+                                                 VirtualPortId.class,
+                                                 TenantNetworkId.class,
+                                                 VirtualPort.State.class,
+                                                 TenantId.class,
+                                                 AllowedAddressPair.class,
+                                                 FixedIp.class,
+                                                 BindingHostId.class,
+                                                 SecurityGroup.class,
+                                                 SubnetId.class,
+                                                 IpAddress.class,
+                                                 DefaultVirtualPort.class))
+                .build().asJavaMap();
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        vPortStore.clear();
+        log.info("Stoppped");
+    }
+
+    @Override
+    public boolean exists(VirtualPortId vPortId) {
+        checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
+        return vPortStore.containsKey(vPortId);
+    }
+
+    @Override
+    public VirtualPort getPort(VirtualPortId vPortId) {
+        checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
+        return vPortStore.get(vPortId);
+    }
+
+    @Override
+    public Collection<VirtualPort> getPorts() {
+        return Collections.unmodifiableCollection(vPortStore.values());
+    }
+
+    @Override
+    public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {
+        checkNotNull(networkId, NETWORKID_NOT_NULL);
+        Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values();
+        for (VirtualPort vPort : vPortWithNetworkIds) {
+            if (!vPort.networkId().equals(networkId)) {
+                vPortWithNetworkIds.remove(vPort);
+            }
+        }
+        return vPortWithNetworkIds;
+    }
+
+    @Override
+    public Collection<VirtualPort> getPorts(TenantId tenantId) {
+        checkNotNull(tenantId, TENANTID_NOT_NULL);
+        Collection<VirtualPort> vPortWithTenantIds = vPortStore.values();
+        for (VirtualPort vPort : vPortWithTenantIds) {
+            if (!vPort.tenantId().equals(tenantId)) {
+                vPortWithTenantIds.remove(vPort);
+            }
+        }
+        return vPortWithTenantIds;
+    }
+
+    @Override
+    public Collection<VirtualPort> getPorts(DeviceId deviceId) {
+        checkNotNull(deviceId, DEVICEID_NOT_NULL);
+        Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values();
+        for (VirtualPort vPort : vPortWithDeviceIds) {
+            if (!vPort.deviceId().equals(deviceId)) {
+                vPortWithDeviceIds.remove(vPort);
+            }
+        }
+        return vPortWithDeviceIds;
+    }
+
+    @Override
+    public boolean createPorts(Iterable<VirtualPort> vPorts) {
+        checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
+        for (VirtualPort vPort : vPorts) {
+            log.debug("vPortId is  {} ", vPort.portId().toString());
+            vPortStore.put(vPort.portId(), vPort);
+            if (!vPortStore.containsKey(vPort.portId())) {
+                log.debug("The virtualPort is created failed whose identifier is {} ",
+                          vPort.portId().toString());
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean updatePorts(Iterable<VirtualPort> vPorts) {
+        checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
+        if (vPorts != null) {
+            for (VirtualPort vPort : vPorts) {
+                vPortStore.put(vPort.portId(), vPort);
+                if (!vPortStore.containsKey(vPort.portId())) {
+                    log.debug("The virtualPort is not exist whose identifier is {}",
+                              vPort.portId().toString());
+                    return false;
+                }
+
+                vPortStore.put(vPort.portId(), vPort);
+
+                if (!vPort.equals(vPortStore.get(vPort.portId()))) {
+                    log.debug("The virtualPort is updated failed whose  identifier is {}",
+                              vPort.portId().toString());
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean removePorts(Iterable<VirtualPortId> vPortIds) {
+        checkNotNull(vPortIds, VIRTUALPORT_ID_NULL);
+        if (vPortIds != null) {
+            for (VirtualPortId vPortId : vPortIds) {
+                vPortStore.remove(vPortId);
+                if (vPortStore.containsKey(vPortId)) {
+                    log.debug("The virtualPort is removed failed whose identifier is {}",
+                              vPortId.toString());
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java
new file mode 100644 (file)
index 0000000..24eb0d3
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation of service for interacting with the inventory of virtual ports.
+ */
+package org.onosproject.vtnrsc.virtualport.impl;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java
new file mode 100644 (file)
index 0000000..06a01a0
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Service for interacting with the inventory of virtual ports.
+ */
+package org.onosproject.vtnrsc.virtualport;
index 4a6c321..57c97c1 100644 (file)
@@ -1,40 +1,40 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.web;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import org.onosproject.codec.CodecContext;\r
-import org.onosproject.codec.JsonCodec;\r
-import org.onosproject.vtnrsc.AllocationPool;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * Subnet AllocationPool codec.\r
- */\r
-public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> {\r
-\r
-    @Override\r
-    public ObjectNode encode(AllocationPool alocPool, CodecContext context) {\r
-        checkNotNull(alocPool, "AllocationPools cannot be null");\r
-        ObjectNode result = context.mapper().createObjectNode()\r
-                .put("start", alocPool.startIp().toString())\r
-                .put("end", alocPool.endIp().toString());\r
-        return result;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+    }
+
+}
index 6c5cc2e..7960808 100644 (file)
@@ -1,40 +1,40 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.web;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import org.onosproject.codec.CodecContext;\r
-import org.onosproject.codec.JsonCodec;\r
-import org.onosproject.vtnrsc.AllowedAddressPair;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * VirtualPort AllowedAddressPair codec.\r
- */\r
-public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> {\r
-\r
-    @Override\r
-    public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) {\r
-        checkNotNull(alocAddPair, "AllowedAddressPair cannot be null");\r
-        ObjectNode result = context.mapper().createObjectNode()\r
-                .put("ip_address", alocAddPair.ip().toString())\r
-                .put("mac_address", alocAddPair.mac().toString());\r
-        return result;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+    }
+
+}
index a69b821..96c9bb4 100644 (file)
@@ -1,40 +1,40 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.web;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import org.onosproject.codec.CodecContext;\r
-import org.onosproject.codec.JsonCodec;\r
-import org.onosproject.vtnrsc.FixedIp;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * VirtualPort FixedIp codec.\r
- */\r
-public final class FixedIpCodec extends JsonCodec<FixedIp> {\r
-\r
-    @Override\r
-    public ObjectNode encode(FixedIp fixIp, CodecContext context) {\r
-        checkNotNull(fixIp, "FixedIp cannot be null");\r
-        ObjectNode result = context.mapper().createObjectNode()\r
-                .put("subnet_id", fixIp.subnetId().toString())\r
-                .put("ip_address", fixIp.ip().toString());\r
-        return result;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+    }
+
+}
index ba977a0..69ca6b3 100644 (file)
@@ -1,40 +1,40 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.web;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import org.onosproject.codec.CodecContext;\r
-import org.onosproject.codec.JsonCodec;\r
-import org.onosproject.vtnrsc.HostRoute;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * Subnet HostRoute codec.\r
- */\r
-public final class HostRoutesCodec extends JsonCodec<HostRoute> {\r
-\r
-    @Override\r
-    public ObjectNode encode(HostRoute hostRoute, CodecContext context) {\r
-        checkNotNull(hostRoute, "HostRoute cannot be null");\r
-        ObjectNode result = context.mapper().createObjectNode()\r
-                .put("nexthop", hostRoute.nexthop().toString())\r
-                .put("destination", hostRoute.destination().toString());\r
-        return result;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+    }
+
+}
index 83bab6b..c2ded19 100644 (file)
@@ -1,39 +1,39 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.web;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import org.onosproject.codec.CodecContext;\r
-import org.onosproject.codec.JsonCodec;\r
-import org.onosproject.vtnrsc.SecurityGroup;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * Virtualport SecurityGroup codec.\r
- */\r
-public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> {\r
-\r
-    @Override\r
-    public ObjectNode encode(SecurityGroup securGroup, CodecContext context) {\r
-        checkNotNull(securGroup, "SecurityGroup cannot be null");\r
-        ObjectNode result = context.mapper().createObjectNode()\r
-                .put("security_group", securGroup.securityGroup());\r
-        return result;\r
-    }\r
-\r
-}\r
+/*
+ * 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;
+    }
+
+}
index afd561f..122b75a 100644 (file)
@@ -1,53 +1,53 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.web;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import org.onosproject.codec.CodecContext;\r
-import org.onosproject.codec.JsonCodec;\r
-import org.onosproject.vtnrsc.Subnet;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * Subnet JSON codec.\r
- */\r
-public final class SubnetCodec extends JsonCodec<Subnet> {\r
-    @Override\r
-    public ObjectNode encode(Subnet subnet, CodecContext context) {\r
-        checkNotNull(subnet, "Subnet cannot be null");\r
-        ObjectNode result = context.mapper().createObjectNode()\r
-                .put("id", subnet.id().toString())\r
-                .put("gateway_ip", subnet.gatewayIp().toString())\r
-                .put("network_id", subnet.networkId().toString())\r
-                .put("name", subnet.subnetName().toString())\r
-                .put("ip_version", subnet.ipVersion().toString())\r
-                .put("cidr", subnet.cidr().toString())\r
-                .put("shared", subnet.shared())\r
-                .put("enabled_dchp", subnet.dhcpEnabled())\r
-                .put("tenant_id", subnet.tenantId().toString())\r
-                .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null\r
-                          : subnet.ipV6AddressMode().toString())\r
-                .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null\r
-                          : subnet.ipV6RaMode().toString());\r
-        result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet\r
-                .allocationPools(), context));\r
-        result.set("host_routes",\r
-                   new HostRoutesCodec().encode(subnet.hostRoutes(), context));\r
-        return result;\r
-    }\r
-}\r
+/*
+ * 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("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;
+    }
+}
index 07ae9f8..48ba3b9 100644 (file)
@@ -1,47 +1,47 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.web;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import org.onosproject.codec.CodecContext;\r
-import org.onosproject.codec.JsonCodec;\r
-import org.onosproject.vtnrsc.TenantNetwork;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * TenantNetwork JSON codec.\r
- */\r
-public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> {\r
-\r
-    @Override\r
-    public ObjectNode encode(TenantNetwork network, CodecContext context) {\r
-        checkNotNull(network, "Network cannot be null");\r
-        ObjectNode result = context.mapper().createObjectNode()\r
-                .put("id", network.id().toString())\r
-                .put("name", network.name().toString())\r
-                .put("admin_state_up", network.adminStateUp())\r
-                .put("status", "" + network.state())\r
-                .put("shared", network.shared())\r
-                .put("tenant_id", network.tenantId().toString())\r
-                .put("router:external", network.routerExternal())\r
-                .put("provider:network_type", "" + network.type())\r
-                .put("provider:physical_network", network.physicalNetwork().toString())\r
-                .put("provider:segmentation_id", network.segmentationId().toString());\r
-        return result;\r
-    }\r
-}\r
+/*
+ * 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())
+                .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;
+    }
+}
index aa3c0c7..e57d56b 100644 (file)
@@ -1,57 +1,57 @@
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnrsc.web;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-\r
-import org.onosproject.codec.CodecContext;\r
-import org.onosproject.codec.JsonCodec;\r
-import org.onosproject.vtnrsc.VirtualPort;\r
-\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
-/**\r
- * VirtualPort JSON codec.\r
- */\r
-public final class VirtualPortCodec extends JsonCodec<VirtualPort> {\r
-    @Override\r
-    public ObjectNode encode(VirtualPort vPort, CodecContext context) {\r
-        checkNotNull(vPort, "VPort cannot be null");\r
-        ObjectNode result = context\r
-                .mapper()\r
-                .createObjectNode()\r
-                .put("id", vPort.portId().toString())\r
-                .put("network_id", vPort.networkId().toString())\r
-                .put("admin_state_up", vPort.adminStateUp())\r
-                .put("name", vPort.name().toString())\r
-                .put("status", vPort.state().toString())\r
-                .put("mac_address", vPort.macAddress().toString())\r
-                .put("tenant_id", vPort.tenantId().toString())\r
-                .put("device_id", vPort.deviceId().toString())\r
-                .put("device_owner", vPort.deviceOwner().toString())\r
-                .put("binding:vnic_type", vPort.bindingVnicType().toString())\r
-                .put("binding:Vif_type", vPort.bindingVifType().toString())\r
-                .put("binding:host_id", vPort.bindingHostId().toString())\r
-                .put("binding:vif_details", vPort.bindingVifDetails().toString());\r
-        result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode(\r
-                                                                               vPort.allowedAddressPairs(), context));\r
-        result.set("fixed_ips", new FixedIpCodec().encode(\r
-                                                        vPort.fixedIps(), context));\r
-        result.set("security_groups", new SecurityGroupCodec().encode(\r
-                                                        vPort.securityGroups(), context));\r
-        return result;\r
-    }\r
-}\r
+/*
+ * 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())
+                .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/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java
new file mode 100644 (file)
index 0000000..34636a9
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.vtnrsc.web;
index 974d3bf..543bcfb 100644 (file)
@@ -1,76 +1,88 @@
 <?xml version="1.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.
+  -->
 <project
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
-       xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.onosproject</groupId>
-               <artifactId>onos-apps</artifactId>
-               <version>1.3.0-SNAPSHOT</version>
-               <relativePath>../pom.xml</relativePath>
-       </parent>
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-apps</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
 
 
-       <artifactId>onos-app-vtnweb</artifactId>
-       <packaging>bundle</packaging>
-       <properties>
-               <onos.app.name>org.onosproject.vtnweb</onos.app.name>
-               <web.context>/onos/vtn</web.context>
-       </properties>
+    <artifactId>onos-app-vtnweb</artifactId>
+    <packaging>bundle</packaging>
+    <properties>
+        <onos.app.name>org.onosproject.vtnweb</onos.app.name>
+        <web.context>/onos/vtn</web.context>
+    </properties>
 
-       <dependencies>
-               <dependency>
-                       <groupId>javax.ws.rs</groupId>
-                       <artifactId>jsr311-api</artifactId>
-                       <version>1.1.1</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.onosproject</groupId>
-                       <artifactId>onos-api</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.onosproject</groupId>
-                       <artifactId>onos-app-vtnrsc</artifactId>
-                       <version>${project.version}</version>
-               </dependency>
-       </dependencies>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.felix</groupId>
-                               <artifactId>maven-bundle-plugin</artifactId>
-                               <extensions>true</extensions>
-                               <configuration>
-                                       <instructions>
-                                               <_wab>src/main/webapp/</_wab>
-                                               <Bundle-SymbolicName>
-                                                       ${project.groupId}.${project.artifactId}
-                                               </Bundle-SymbolicName>
-                                               <Import-Package>
-                                                       org.slf4j,
-                                                       org.osgi.framework,
-                                                       javax.ws.rs,
-                                                       javax.ws.rs.core,
-                                                       com.sun.jersey.api.core,
-                                                       com.sun.jersey.spi.container.servlet,
-                                                       com.sun.jersey.server.impl.container.servlet,
-                                                       com.fasterxml.jackson.databind,
-                                                       com.fasterxml.jackson.databind.node,
-                                                       com.fasterxml.jackson.core,
-                                                       org.apache.karaf.shell.commands,
-                                                       org.apache.commons.lang.math.*,
-                                                       com.google.common.*,
-                                                       org.onlab.packet.*,
-                                                       org.onlab.rest.*,
-                                                       org.onosproject.*,
-                                                       org.onlab.util.*,
-                                                       org.jboss.netty.util.*
-                                               </Import-Package>
-                                               <Web-ContextPath>${web.context}</Web-ContextPath>
-                                       </instructions>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
+    <dependencies>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>jsr311-api</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-app-vtnrsc</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <_wab>src/main/webapp/</_wab>
+                        <Bundle-SymbolicName>
+                            ${project.groupId}.${project.artifactId}
+                        </Bundle-SymbolicName>
+                        <Import-Package>
+                            org.slf4j,
+                            org.osgi.framework,
+                            javax.ws.rs,
+                            javax.ws.rs.core,
+                            com.sun.jersey.api.core,
+                            com.sun.jersey.spi.container.servlet,
+                            com.sun.jersey.server.impl.container.servlet,
+                            com.fasterxml.jackson.databind,
+                            com.fasterxml.jackson.databind.node,
+                            com.fasterxml.jackson.core,
+                            org.apache.karaf.shell.commands,
+                            org.apache.commons.lang.math.*,
+                            com.google.common.*,
+                            org.onlab.packet.*,
+                            org.onlab.rest.*,
+                            org.onosproject.*,
+                            org.onlab.util.*,
+                            org.jboss.netty.util.*
+                        </Import-Package>
+                        <Web-ContextPath>${web.context}</Web-ContextPath>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>
\ No newline at end of file
index c46af6e..3979e1e 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnweb.resources;\r
-\r
-import static com.google.common.base.Preconditions.checkArgument;\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.util.Collections;\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.concurrent.ConcurrentMap;\r
-\r
-import javax.ws.rs.Consumes;\r
-import javax.ws.rs.DELETE;\r
-import javax.ws.rs.GET;\r
-import javax.ws.rs.POST;\r
-import javax.ws.rs.PUT;\r
-import javax.ws.rs.Path;\r
-import javax.ws.rs.PathParam;\r
-import javax.ws.rs.Produces;\r
-import javax.ws.rs.core.MediaType;\r
-import javax.ws.rs.core.Response;\r
-\r
-import org.onlab.packet.IpAddress;\r
-import org.onlab.packet.IpAddress.Version;\r
-import org.onlab.packet.IpPrefix;\r
-import org.onlab.util.ItemNotFoundException;\r
-import org.onosproject.rest.AbstractWebResource;\r
-import org.onosproject.vtnrsc.AllocationPool;\r
-import org.onosproject.vtnrsc.DefaultAllocationPool;\r
-import org.onosproject.vtnrsc.DefaultHostRoute;\r
-import org.onosproject.vtnrsc.DefaultSubnet;\r
-import org.onosproject.vtnrsc.HostRoute;\r
-import org.onosproject.vtnrsc.Subnet;\r
-import org.onosproject.vtnrsc.SubnetId;\r
-import org.onosproject.vtnrsc.TenantId;\r
-import org.onosproject.vtnrsc.TenantNetworkId;\r
-import org.onosproject.vtnrsc.Subnet.Mode;\r
-import org.onosproject.vtnrsc.subnet.SubnetService;\r
-import org.onosproject.vtnrsc.web.SubnetCodec;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-import com.google.common.collect.Maps;\r
-import com.google.common.collect.Sets;\r
-\r
-@Path("subnets")\r
-public class SubnetWebResource extends AbstractWebResource {\r
-    private final Logger log = LoggerFactory.getLogger(SubnetWebResource.class);\r
-    public static final String SUBNET_NOT_CREATE = "Subnets is failed to create!";\r
-    public static final String SUBNET_NOT_FOUND = "Subnets is failed to update!";\r
-    public static final String JSON_NOT_NULL = "JsonNode can not be null";\r
-\r
-    @GET\r
-    @Produces(MediaType.APPLICATION_JSON)\r
-    public Response listSubnets() {\r
-        Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();\r
-        ObjectNode result = new ObjectMapper().createObjectNode();\r
-        result.set("subnets", new SubnetCodec().encode(subnets, this));\r
-        return ok(result.toString()).build();\r
-    }\r
-\r
-    @GET\r
-    @Path("{subnetUUID}")\r
-    @Produces(MediaType.APPLICATION_JSON)\r
-    public Response getSubnet(@PathParam("subnetUUID") String id) {\r
-\r
-        if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {\r
-            return ok("The subnet does not exists").build();\r
-        }\r
-        Subnet sub = nullIsNotFound(get(SubnetService.class)\r
-                                            .getSubnet(SubnetId.subnetId(id)),\r
-                                    SUBNET_NOT_FOUND);\r
-\r
-        ObjectNode result = new ObjectMapper().createObjectNode();\r
-        result.set("subnet", new SubnetCodec().encode(sub, this));\r
-        return ok(result.toString()).build();\r
-    }\r
-\r
-    @POST\r
-    @Produces(MediaType.APPLICATION_JSON)\r
-    @Consumes(MediaType.APPLICATION_JSON)\r
-    public Response createSubnet(final InputStream input) {\r
-\r
-        try {\r
-            ObjectMapper mapper = new ObjectMapper();\r
-            JsonNode subnode = mapper.readTree(input);\r
-            Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);\r
-            Boolean result = nullIsNotFound((get(SubnetService.class)\r
-                                                    .createSubnets(subnets)),\r
-                                            SUBNET_NOT_CREATE);\r
-\r
-            if (!result) {\r
-                return Response.status(204).entity(SUBNET_NOT_CREATE).build();\r
-            }\r
-            return Response.status(202).entity(result.toString()).build();\r
-        } catch (Exception e) {\r
-            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())\r
-                    .build();\r
-        }\r
-    }\r
-\r
-    @PUT\r
-    @Path("{subnetUUID}")\r
-    @Produces(MediaType.APPLICATION_JSON)\r
-    @Consumes(MediaType.APPLICATION_JSON)\r
-    public Response updateSubnet(@PathParam("id") String id,\r
-                                 final InputStream input) {\r
-        try {\r
-            ObjectMapper mapper = new ObjectMapper();\r
-            JsonNode subnode = mapper.readTree(input);\r
-            Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);\r
-            Boolean result = nullIsNotFound(get(SubnetService.class)\r
-                    .updateSubnets(subnets), SUBNET_NOT_FOUND);\r
-            if (!result) {\r
-                return Response.status(204).entity(SUBNET_NOT_FOUND).build();\r
-            }\r
-            return Response.status(203).entity(result.toString()).build();\r
-        } catch (Exception e) {\r
-            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())\r
-                    .build();\r
-        }\r
-    }\r
-\r
-    @Path("{subnetUUID}")\r
-    @DELETE\r
-    public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)\r
-            throws IOException {\r
-        try {\r
-            SubnetId subId = SubnetId.subnetId(id);\r
-            Set<SubnetId> subIds = new HashSet<SubnetId>();\r
-            subIds.add(subId);\r
-            get(SubnetService.class).removeSubnets(subIds);\r
-            return Response.status(201).entity("SUCCESS").build();\r
-        } catch (Exception e) {\r
-            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())\r
-                    .build();\r
-        }\r
-    }\r
-\r
-    private Iterable<Subnet> createOrUpdateByInputStream(JsonNode subnode) {\r
-        checkNotNull(subnode, JSON_NOT_NULL);\r
-        Iterable<Subnet> subnets = null;\r
-        JsonNode subnetNodes = subnode.get("subnets");\r
-        if (subnetNodes == null) {\r
-            subnetNodes = subnode.get("subnet");\r
-        }\r
-        log.debug("subnetNodes is {}", subnetNodes.toString());\r
-        if (subnetNodes.isArray()) {\r
-            subnets = changeJsonToSubs(subnetNodes);\r
-        } else {\r
-            subnets = changeJsonToSub(subnetNodes);\r
-        }\r
-        return subnets;\r
-    }\r
-\r
-    /**\r
-     * Returns a collection of subnets from subnetNodes.\r
-     *\r
-     * @param subnetNodes the subnet json node\r
-     * @return subnets a collection of subnets\r
-     */\r
-    public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {\r
-        checkNotNull(subnetNodes, JSON_NOT_NULL);\r
-        Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();\r
-        for (JsonNode subnetNode : subnetNodes) {\r
-            if (!subnetNode.hasNonNull("id")) {\r
-                return null;\r
-            }\r
-            SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());\r
-            String subnetName = subnetNode.get("name").asText();\r
-            TenantId tenantId = TenantId\r
-                    .tenantId(subnetNode.get("tenant_id").asText());\r
-            TenantNetworkId networkId = TenantNetworkId\r
-                    .networkId(subnetNode.get("network_id").asText());\r
-            Version ipVersion = Version\r
-                    .valueOf(subnetNode.get("ip_version").asText());\r
-            IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());\r
-            IpAddress gatewayIp = IpAddress\r
-                    .valueOf(subnetNode.get("gateway_ip").asText());\r
-            Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();\r
-            Boolean shared = subnetNode.get("shared").asBoolean();\r
-            JsonNode hostRoutes = subnetNode.get("host_routes");\r
-            Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);\r
-            JsonNode allocationPools = subnetNode.get("allocation_pools");\r
-            Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);\r
-            Mode ipV6AddressMode = Mode\r
-                    .valueOf(subnetNode.get("ipv6_address_mode").asText());\r
-            Mode ipV6RaMode = Mode\r
-                    .valueOf(subnetNode.get("ipv6_ra_mode").asText());\r
-            Subnet subnet = new DefaultSubnet(id, subnetName, networkId,\r
-                                              tenantId, ipVersion, cidr,\r
-                                              gatewayIp, dhcpEnabled, shared,\r
-                                              Sets.newHashSet(hostRoutesIt), ipV6AddressMode,\r
-                                              ipV6RaMode, Sets.newHashSet(allocationPoolsIt));\r
-            subMap.put(id, subnet);\r
-        }\r
-        return Collections.unmodifiableCollection(subMap.values());\r
-    }\r
-\r
-    /**\r
-     * Returns a collection of subnets from subnetNodes.\r
-     *\r
-     * @param subnetNodes the subnet json node\r
-     * @return subnets a collection of subnets\r
-     */\r
-    public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {\r
-        checkNotNull(subnetNodes, JSON_NOT_NULL);\r
-        checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");\r
-        checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");\r
-        Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();\r
-        if (!subnetNodes.hasNonNull("id")) {\r
-            return null;\r
-        }\r
-        SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());\r
-        String subnetName = subnetNodes.get("name").asText();\r
-        TenantId tenantId = TenantId\r
-                .tenantId(subnetNodes.get("tenant_id").asText());\r
-        TenantNetworkId networkId = TenantNetworkId\r
-                .networkId(subnetNodes.get("network_id").asText());\r
-        String version = subnetNodes.get("ip_version").asText();\r
-        Version ipVersion;\r
-        switch (version) {\r
-        case "4":\r
-            ipVersion = Version.INET;\r
-            break;\r
-        case "6":\r
-            ipVersion = Version.INET;\r
-            break;\r
-        default:\r
-            throw new IllegalArgumentException("ipVersion should be 4 or 6.");\r
-        }\r
-\r
-        IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());\r
-        IpAddress gatewayIp = IpAddress\r
-                .valueOf(subnetNodes.get("gateway_ip").asText());\r
-        Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();\r
-        Boolean shared = subnetNodes.get("shared").asBoolean();\r
-        JsonNode hostRoutes = subnetNodes.get("host_routes");\r
-        Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);\r
-        JsonNode allocationPools = subnetNodes.get("allocation_pools");\r
-        Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);\r
-\r
-        Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")\r
-                .asText());\r
-        Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());\r
-\r
-        Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,\r
-                                          ipVersion, cidr, gatewayIp,\r
-                                          dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt),\r
-                                          ipV6AddressMode, ipV6RaMode,\r
-                                          Sets.newHashSet(allocationPoolsIt));\r
-        subMap.put(id, subnet);\r
-        return Collections.unmodifiableCollection(subMap.values());\r
-    }\r
-\r
-    /**\r
-     * Gets ipv6_address_mode or ipv6_ra_mode type.\r
-     *\r
-     * @param mode the String value in JsonNode\r
-     * @return ipV6Mode Mode of the ipV6Mode\r
-     */\r
-    private Mode getMode(String mode) {\r
-        Mode ipV6Mode;\r
-        if (mode == null) {\r
-            return null;\r
-        }\r
-        switch (mode) {\r
-        case "dhcpv6-stateful":\r
-            ipV6Mode = Mode.DHCPV6_STATEFUL;\r
-            break;\r
-        case "dhcpv6-stateless":\r
-            ipV6Mode = Mode.DHCPV6_STATELESS;\r
-            break;\r
-        case "slaac":\r
-            ipV6Mode = Mode.SLAAC;\r
-            break;\r
-        default:\r
-            ipV6Mode = null;\r
-        }\r
-        return ipV6Mode;\r
-    }\r
-\r
-    /**\r
-     * Changes JsonNode alocPools to a collection of the alocPools.\r
-     *\r
-     * @param allocationPools the allocationPools JsonNode\r
-     * @return a collection of allocationPools\r
-     */\r
-    public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {\r
-        checkNotNull(allocationPools, JSON_NOT_NULL);\r
-        ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps\r
-                .newConcurrentMap();\r
-        Integer i = 0;\r
-        for (JsonNode node : allocationPools) {\r
-            IpAddress startIp = IpAddress.valueOf(node.get("start").asText());\r
-            IpAddress endIp = IpAddress.valueOf(node.get("end").asText());\r
-            AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);\r
-            alocplMaps.putIfAbsent(i, alocPls);\r
-            i++;\r
-        }\r
-        return Collections.unmodifiableCollection(alocplMaps.values());\r
-    }\r
-\r
-    /**\r
-     * Changes hostRoutes JsonNode to a collection of the hostRoutes.\r
-     *\r
-     * @param hostRoutes the hostRoutes json node\r
-     * @return a collection of hostRoutes\r
-     */\r
-    public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {\r
-        checkNotNull(hostRoutes, JSON_NOT_NULL);\r
-        ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps\r
-                .newConcurrentMap();\r
-        Integer i = 0;\r
-        for (JsonNode node : hostRoutes) {\r
-            IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());\r
-            IpPrefix destination = IpPrefix.valueOf(node.get("destination")\r
-                    .asText());\r
-            HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);\r
-            hostRouteMaps.putIfAbsent(i, hostRoute);\r
-            i++;\r
-        }\r
-        return Collections.unmodifiableCollection(hostRouteMaps.values());\r
-    }\r
-\r
-    /**\r
-     * Returns the specified item if that items is null; otherwise throws not\r
-     * found exception.\r
-     *\r
-     * @param item item to check\r
-     * @param <T> item type\r
-     * @param message not found message\r
-     * @return item if not null\r
-     * @throws org.onlab.util.ItemNotFoundException if item is null\r
-     */\r
-    protected <T> T nullIsNotFound(T item, String message) {\r
-        if (item == null) {\r
-            throw new ItemNotFoundException(message);\r
-        }\r
-        return item;\r
-    }\r
-\r
-}\r
+/*
+ * 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.resources;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpAddress.Version;
+import org.onlab.packet.IpPrefix;
+import org.onlab.util.ItemNotFoundException;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.vtnrsc.AllocationPool;
+import org.onosproject.vtnrsc.DefaultAllocationPool;
+import org.onosproject.vtnrsc.DefaultHostRoute;
+import org.onosproject.vtnrsc.DefaultSubnet;
+import org.onosproject.vtnrsc.HostRoute;
+import org.onosproject.vtnrsc.Subnet;
+import org.onosproject.vtnrsc.SubnetId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.Subnet.Mode;
+import org.onosproject.vtnrsc.subnet.SubnetService;
+import org.onosproject.vtnrsc.web.SubnetCodec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+@Path("subnets")
+public class SubnetWebResource extends AbstractWebResource {
+    private final Logger log = LoggerFactory.getLogger(SubnetWebResource.class);
+    public static final String SUBNET_NOT_CREATE = "Subnets is failed to create!";
+    public static final String SUBNET_NOT_FOUND = "Subnets is failed to update!";
+    public static final String JSON_NOT_NULL = "JsonNode can not be null";
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response listSubnets() {
+        Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();
+        ObjectNode result = new ObjectMapper().createObjectNode();
+        result.set("subnets", new SubnetCodec().encode(subnets, this));
+        return ok(result.toString()).build();
+    }
+
+    @GET
+    @Path("{subnetUUID}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getSubnet(@PathParam("subnetUUID") String id) {
+
+        if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
+            return ok("The subnet does not exists").build();
+        }
+        Subnet sub = nullIsNotFound(get(SubnetService.class)
+                                            .getSubnet(SubnetId.subnetId(id)),
+                                    SUBNET_NOT_FOUND);
+
+        ObjectNode result = new ObjectMapper().createObjectNode();
+        result.set("subnet", new SubnetCodec().encode(sub, this));
+        return ok(result.toString()).build();
+    }
+
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response createSubnet(final InputStream input) {
+
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode subnode = mapper.readTree(input);
+            Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
+            Boolean result = nullIsNotFound((get(SubnetService.class)
+                                                    .createSubnets(subnets)),
+                                            SUBNET_NOT_CREATE);
+
+            if (!result) {
+                return Response.status(204).entity(SUBNET_NOT_CREATE).build();
+            }
+            return Response.status(202).entity(result.toString()).build();
+        } catch (Exception e) {
+            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+                    .build();
+        }
+    }
+
+    @PUT
+    @Path("{subnetUUID}")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response updateSubnet(@PathParam("id") String id,
+                                 final InputStream input) {
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode subnode = mapper.readTree(input);
+            Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
+            Boolean result = nullIsNotFound(get(SubnetService.class)
+                    .updateSubnets(subnets), SUBNET_NOT_FOUND);
+            if (!result) {
+                return Response.status(204).entity(SUBNET_NOT_FOUND).build();
+            }
+            return Response.status(203).entity(result.toString()).build();
+        } catch (Exception e) {
+            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+                    .build();
+        }
+    }
+
+    @Path("{subnetUUID}")
+    @DELETE
+    public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)
+            throws IOException {
+        try {
+            SubnetId subId = SubnetId.subnetId(id);
+            Set<SubnetId> subIds = new HashSet<>();
+            subIds.add(subId);
+            get(SubnetService.class).removeSubnets(subIds);
+            return Response.status(201).entity("SUCCESS").build();
+        } catch (Exception e) {
+            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+                    .build();
+        }
+    }
+
+    private Iterable<Subnet> createOrUpdateByInputStream(JsonNode subnode) {
+        checkNotNull(subnode, JSON_NOT_NULL);
+        Iterable<Subnet> subnets = null;
+        JsonNode subnetNodes = subnode.get("subnets");
+        if (subnetNodes == null) {
+            subnetNodes = subnode.get("subnet");
+        }
+        log.debug("subnetNodes is {}", subnetNodes.toString());
+        if (subnetNodes.isArray()) {
+            subnets = changeJsonToSubs(subnetNodes);
+        } else {
+            subnets = changeJsonToSub(subnetNodes);
+        }
+        return subnets;
+    }
+
+    /**
+     * Returns a collection of subnets from subnetNodes.
+     *
+     * @param subnetNodes the subnet json node
+     * @return subnets a collection of subnets
+     */
+    public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {
+        checkNotNull(subnetNodes, JSON_NOT_NULL);
+        Map<SubnetId, Subnet> subMap = new HashMap<>();
+        for (JsonNode subnetNode : subnetNodes) {
+            if (!subnetNode.hasNonNull("id")) {
+                return null;
+            }
+            SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());
+            String subnetName = subnetNode.get("name").asText();
+            TenantId tenantId = TenantId
+                    .tenantId(subnetNode.get("tenant_id").asText());
+            TenantNetworkId networkId = TenantNetworkId
+                    .networkId(subnetNode.get("network_id").asText());
+            Version ipVersion = Version
+                    .valueOf(subnetNode.get("ip_version").asText());
+            IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());
+            IpAddress gatewayIp = IpAddress
+                    .valueOf(subnetNode.get("gateway_ip").asText());
+            Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();
+            Boolean shared = subnetNode.get("shared").asBoolean();
+            JsonNode hostRoutes = subnetNode.get("host_routes");
+            Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
+            JsonNode allocationPools = subnetNode.get("allocation_pools");
+            Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
+            Mode ipV6AddressMode = Mode
+                    .valueOf(subnetNode.get("ipv6_address_mode").asText());
+            Mode ipV6RaMode = Mode
+                    .valueOf(subnetNode.get("ipv6_ra_mode").asText());
+            Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
+                                              tenantId, ipVersion, cidr,
+                                              gatewayIp, dhcpEnabled, shared,
+                                              Sets.newHashSet(hostRoutesIt), ipV6AddressMode,
+                                              ipV6RaMode, Sets.newHashSet(allocationPoolsIt));
+            subMap.put(id, subnet);
+        }
+        return Collections.unmodifiableCollection(subMap.values());
+    }
+
+    /**
+     * Returns a collection of subnets from subnetNodes.
+     *
+     * @param subnetNodes the subnet json node
+     * @return subnets a collection of subnets
+     */
+    public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
+        checkNotNull(subnetNodes, JSON_NOT_NULL);
+        checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
+        checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");
+        Map<SubnetId, Subnet> subMap = new HashMap<>();
+        if (!subnetNodes.hasNonNull("id")) {
+            return null;
+        }
+        SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());
+        String subnetName = subnetNodes.get("name").asText();
+        TenantId tenantId = TenantId
+                .tenantId(subnetNodes.get("tenant_id").asText());
+        TenantNetworkId networkId = TenantNetworkId
+                .networkId(subnetNodes.get("network_id").asText());
+        String version = subnetNodes.get("ip_version").asText();
+        Version ipVersion;
+        switch (version) {
+        case "4":
+            ipVersion = Version.INET;
+            break;
+        case "6":
+            ipVersion = Version.INET;
+            break;
+        default:
+            throw new IllegalArgumentException("ipVersion should be 4 or 6.");
+        }
+
+        IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());
+        IpAddress gatewayIp = IpAddress
+                .valueOf(subnetNodes.get("gateway_ip").asText());
+        Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();
+        Boolean shared = subnetNodes.get("shared").asBoolean();
+        JsonNode hostRoutes = subnetNodes.get("host_routes");
+        Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
+        JsonNode allocationPools = subnetNodes.get("allocation_pools");
+        Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
+
+        Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")
+                .asText());
+        Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());
+
+        Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
+                                          ipVersion, cidr, gatewayIp,
+                                          dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt),
+                                          ipV6AddressMode, ipV6RaMode,
+                                          Sets.newHashSet(allocationPoolsIt));
+        subMap.put(id, subnet);
+        return Collections.unmodifiableCollection(subMap.values());
+    }
+
+    /**
+     * Gets ipv6_address_mode or ipv6_ra_mode type.
+     *
+     * @param mode the String value in JsonNode
+     * @return ipV6Mode Mode of the ipV6Mode
+     */
+    private Mode getMode(String mode) {
+        Mode ipV6Mode;
+        if (mode == null) {
+            return null;
+        }
+        switch (mode) {
+        case "dhcpv6-stateful":
+            ipV6Mode = Mode.DHCPV6_STATEFUL;
+            break;
+        case "dhcpv6-stateless":
+            ipV6Mode = Mode.DHCPV6_STATELESS;
+            break;
+        case "slaac":
+            ipV6Mode = Mode.SLAAC;
+            break;
+        default:
+            ipV6Mode = null;
+        }
+        return ipV6Mode;
+    }
+
+    /**
+     * Changes JsonNode alocPools to a collection of the alocPools.
+     *
+     * @param allocationPools the allocationPools JsonNode
+     * @return a collection of allocationPools
+     */
+    public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {
+        checkNotNull(allocationPools, JSON_NOT_NULL);
+        ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps
+                .newConcurrentMap();
+        Integer i = 0;
+        for (JsonNode node : allocationPools) {
+            IpAddress startIp = IpAddress.valueOf(node.get("start").asText());
+            IpAddress endIp = IpAddress.valueOf(node.get("end").asText());
+            AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);
+            alocplMaps.putIfAbsent(i, alocPls);
+            i++;
+        }
+        return Collections.unmodifiableCollection(alocplMaps.values());
+    }
+
+    /**
+     * Changes hostRoutes JsonNode to a collection of the hostRoutes.
+     *
+     * @param hostRoutes the hostRoutes json node
+     * @return a collection of hostRoutes
+     */
+    public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {
+        checkNotNull(hostRoutes, JSON_NOT_NULL);
+        ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps
+                .newConcurrentMap();
+        Integer i = 0;
+        for (JsonNode node : hostRoutes) {
+            IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());
+            IpPrefix destination = IpPrefix.valueOf(node.get("destination")
+                    .asText());
+            HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);
+            hostRouteMaps.putIfAbsent(i, hostRoute);
+            i++;
+        }
+        return Collections.unmodifiableCollection(hostRouteMaps.values());
+    }
+
+    /**
+     * Returns the specified item if that items is null; otherwise throws not
+     * found exception.
+     *
+     * @param item item to check
+     * @param <T> item type
+     * @param message not found message
+     * @return item if not null
+     * @throws org.onlab.util.ItemNotFoundException if item is null
+     */
+    protected <T> T nullIsNotFound(T item, String message) {
+        if (item == null) {
+            throw new ItemNotFoundException(message);
+        }
+        return item;
+    }
+
+}
index 7a0d43d..b3888db 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnweb.resources;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-import static com.google.common.base.Preconditions.checkArgument;\r
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;\r
-import static javax.ws.rs.core.Response.Status.OK;\r
-\r
-import java.io.InputStream;\r
-import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.Iterator;\r
-import java.util.Set;\r
-import java.util.concurrent.ConcurrentMap;\r
-\r
-import javax.ws.rs.Consumes;\r
-import javax.ws.rs.DELETE;\r
-import javax.ws.rs.GET;\r
-import javax.ws.rs.POST;\r
-import javax.ws.rs.PUT;\r
-import javax.ws.rs.Path;\r
-import javax.ws.rs.PathParam;\r
-import javax.ws.rs.Produces;\r
-import javax.ws.rs.QueryParam;\r
-import javax.ws.rs.core.MediaType;\r
-import javax.ws.rs.core.Response;\r
-\r
-import org.onlab.util.ItemNotFoundException;\r
-import org.onosproject.rest.AbstractWebResource;\r
-import org.onosproject.vtnrsc.DefaultTenantNetwork;\r
-import org.onosproject.vtnrsc.PhysicalNetwork;\r
-import org.onosproject.vtnrsc.SegmentationId;\r
-import org.onosproject.vtnrsc.TenantId;\r
-import org.onosproject.vtnrsc.TenantNetwork;\r
-import org.onosproject.vtnrsc.TenantNetworkId;\r
-import org.onosproject.vtnrsc.TenantNetwork.State;\r
-import org.onosproject.vtnrsc.TenantNetwork.Type;\r
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;\r
-import org.onosproject.vtnrsc.web.TenantNetworkCodec;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-import com.google.common.collect.Maps;\r
-\r
-/**\r
- * REST resource for interacting with the inventory of networks.\r
- */\r
-@Path("networks")\r
-public class TenantNetworkWebResource extends AbstractWebResource {\r
-    public static final String NETWORK_NOT_FOUND = "Network is not found";\r
-    public static final String NETWORK_ID_EXIST = "Network id is existed";\r
-    public static final String NETWORK_ID_NOT_EXIST = "Network id is not existed";\r
-    public static final String CREATE_NETWORK = "create network";\r
-    public static final String UPDATE_NETWORK = "update network";\r
-    public static final String DELETE_NETWORK = "delete network";\r
-    public static final String JSON_NOT_NULL = "JsonNode can not be null";\r
-\r
-    protected static final Logger log = LoggerFactory\r
-            .getLogger(TenantNetworkWebResource.class);\r
-    private final ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps\r
-            .newConcurrentMap();\r
-\r
-    @GET\r
-    @Produces({ MediaType.APPLICATION_JSON })\r
-    public Response getNetworks(@QueryParam("id") String queryId,\r
-                                @QueryParam("name") String queryName,\r
-                                @QueryParam("admin_state_up") String queryadminStateUp,\r
-                                @QueryParam("status") String querystate,\r
-                                @QueryParam("shared") String queryshared,\r
-                                @QueryParam("tenant_id") String querytenantId,\r
-                                @QueryParam("router:external") String routerExternal,\r
-                                @QueryParam("provider:network_type") String type,\r
-                                @QueryParam("provider:physical_network") String physicalNetwork,\r
-                                @QueryParam("provider:segmentation_id") String segmentationId) {\r
-        Iterable<TenantNetwork> networks = get(TenantNetworkService.class)\r
-                .getNetworks();\r
-        Iterator<TenantNetwork> networkors = networks.iterator();\r
-        while (networkors.hasNext()) {\r
-            TenantNetwork network = networkors.next();\r
-            if ((queryId == null || queryId.equals(network.id().toString()))\r
-                    && (queryName == null || queryName.equals(network.name()\r
-                            .toString()))\r
-                    && (queryadminStateUp == null || queryadminStateUp\r
-                            .equals(network.adminStateUp()))\r
-                    && (querystate == null || querystate.equals(network.state()\r
-                            .toString()))\r
-                    && (queryshared == null || queryshared.equals(network\r
-                            .shared()))\r
-                    && (querytenantId == null || querytenantId.equals(network\r
-                            .tenantId().toString()))\r
-                    && (routerExternal == null || routerExternal.equals(network\r
-                            .routerExternal()))\r
-                    && (type == null || type.equals(network.type()))\r
-                    && (physicalNetwork == null || physicalNetwork\r
-                            .equals(network.physicalNetwork()))\r
-                    && (segmentationId == null || segmentationId.equals(network\r
-                            .segmentationId()))) {\r
-                networksMap.putIfAbsent(network.id(), network);\r
-            }\r
-        }\r
-        networks = Collections.unmodifiableCollection(networksMap.values());\r
-        ObjectNode result = new ObjectMapper().createObjectNode();\r
-        result.set("networks", new TenantNetworkCodec().encode(networks, this));\r
-\r
-        return ok(result.toString()).build();\r
-    }\r
-\r
-    private State isState(String state) {\r
-        if (state.equals("ACTIVE")) {\r
-            return TenantNetwork.State.ACTIVE;\r
-        } else if (state.equals("BUILD")) {\r
-            return TenantNetwork.State.BUILD;\r
-        } else if (state.equals("DOWN")) {\r
-            return TenantNetwork.State.DOWN;\r
-        } else if (state.equals("ERROR")) {\r
-            return TenantNetwork.State.ERROR;\r
-        } else {\r
-            return null;\r
-        }\r
-    }\r
-\r
-    private Type isType(String type) {\r
-        if (type.equals("LOCAL")) {\r
-            return TenantNetwork.Type.LOCAL;\r
-        } else {\r
-            return null;\r
-        }\r
-    }\r
-\r
-    @GET\r
-    @Path("{id}")\r
-    @Produces({ MediaType.APPLICATION_JSON })\r
-    public Response getNetwork(@PathParam("id") String id) {\r
-\r
-        if (!get(TenantNetworkService.class).exists(TenantNetworkId\r
-                                                            .networkId(id))) {\r
-            return ok("The tenantNetwork does not exists").build();\r
-        }\r
-        TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class)\r
-                .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND);\r
-        ObjectNode result = new ObjectMapper().createObjectNode();\r
-        result.set("network", new TenantNetworkCodec().encode(network, this));\r
-\r
-        return ok(result.toString()).build();\r
-\r
-    }\r
-\r
-    @POST\r
-    @Produces(MediaType.APPLICATION_JSON)\r
-    @Consumes(MediaType.APPLICATION_JSON)\r
-    public Response createNetworks(InputStream input) {\r
-        try {\r
-            ObjectMapper mapper = new ObjectMapper();\r
-            JsonNode cfg = mapper.readTree(input);\r
-            JsonNode nodes = null;\r
-            Iterable<TenantNetwork> networks = null;\r
-            if (cfg.get("network") != null) {\r
-                nodes = cfg.get("network");\r
-                if (nodes.isArray()) {\r
-                    networks = changeJson2objs(nodes);\r
-                } else {\r
-                    networks = changeJson2obj(CREATE_NETWORK, null, nodes);\r
-                }\r
-            } else if (cfg.get("networks") != null) {\r
-                nodes = cfg.get("networks");\r
-                networks = changeJson2objs(nodes);\r
-            }\r
-            Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)\r
-                                                       .createNetworks(networks)),\r
-                                               NETWORK_NOT_FOUND);\r
-\r
-            if (!issuccess) {\r
-                return Response.status(INTERNAL_SERVER_ERROR)\r
-                        .entity(NETWORK_ID_EXIST).build();\r
-            }\r
-            return Response.status(OK).entity(issuccess.toString()).build();\r
-        } catch (Exception e) {\r
-            log.error("Creates tenantNetwork exception {}.", e.toString());\r
-            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())\r
-                    .build();\r
-        }\r
-    }\r
-\r
-    @PUT\r
-    @Path("{id}")\r
-    @Produces(MediaType.APPLICATION_JSON)\r
-    @Consumes(MediaType.APPLICATION_JSON)\r
-    public Response updateNetworks(@PathParam("id") String id, InputStream input) {\r
-        try {\r
-            ObjectMapper mapper = new ObjectMapper();\r
-            JsonNode cfg = mapper.readTree(input);\r
-            JsonNode nodes = null;\r
-            Iterable<TenantNetwork> networks = null;\r
-            if (cfg.get("network") != null) {\r
-                nodes = cfg.get("network");\r
-                if (nodes.isArray()) {\r
-                    networks = changeJson2objs(nodes);\r
-                } else {\r
-                    networks = changeJson2obj(UPDATE_NETWORK,\r
-                                              TenantNetworkId.networkId(id),\r
-                                              nodes);\r
-                }\r
-            } else if (cfg.get("networks") != null) {\r
-                nodes = cfg.get("networks");\r
-                networks = changeJson2objs(nodes);\r
-            }\r
-            Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)\r
-                                                       .updateNetworks(networks)),\r
-                                               NETWORK_NOT_FOUND);\r
-            if (!issuccess) {\r
-                return Response.status(INTERNAL_SERVER_ERROR)\r
-                        .entity(NETWORK_ID_NOT_EXIST).build();\r
-            }\r
-            return Response.status(OK).entity(issuccess.toString()).build();\r
-        } catch (Exception e) {\r
-            log.error("Updates tenantNetwork failed because of exception {}.",\r
-                      e.toString());\r
-            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())\r
-                    .build();\r
-        }\r
-    }\r
-\r
-    @DELETE\r
-    @Path("{id}")\r
-    public Response deleteNetworks(@PathParam("id") String id) {\r
-        log.debug("Deletes network by identifier {}.", id);\r
-        Set<TenantNetworkId> networkSet = new HashSet<TenantNetworkId>();\r
-        networkSet.add(TenantNetworkId.networkId(id));\r
-        Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class)\r
-                .removeNetworks(networkSet), NETWORK_NOT_FOUND);\r
-        if (!issuccess) {\r
-            log.debug("Network identifier {} is not existed", id);\r
-            return Response.status(INTERNAL_SERVER_ERROR)\r
-                    .entity(NETWORK_ID_NOT_EXIST).build();\r
-        }\r
-        return Response.status(OK).entity(issuccess.toString()).build();\r
-    }\r
-\r
-    /**\r
-     * Returns a collection of tenantNetworks.\r
-     *\r
-     * @param flag the flag\r
-     * @param networkId network identifier\r
-     * @param node the network json node\r
-     * @return a collection of tenantNetworks\r
-     */\r
-    public Iterable<TenantNetwork> changeJson2obj(String flag,\r
-                                                  TenantNetworkId networkId,\r
-                                                  JsonNode node) {\r
-        checkNotNull(node, JSON_NOT_NULL);\r
-        TenantNetwork network = null;\r
-        ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps\r
-                .newConcurrentMap();\r
-        if (node != null) {\r
-            checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");\r
-            checkArgument(node.get("shared").isBoolean(), "shared should be boolean");\r
-            checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean");\r
-            String name = node.get("name").asText();\r
-            boolean adminStateUp = node.get("admin_state_up").asBoolean();\r
-            String state = node.get("status").asText();\r
-            boolean shared = node.get("shared").asBoolean();\r
-            String tenantId = node.get("tenant_id").asText();\r
-            boolean routerExternal = node.get("router:external").asBoolean();\r
-            String type = node.get("provider:network_type").asText();\r
-            String physicalNetwork = node.get("provider:physical_network")\r
-                    .asText();\r
-            String segmentationId = node.get("provider:segmentation_id")\r
-                    .asText();\r
-            TenantNetworkId id = null;\r
-            if (flag == CREATE_NETWORK) {\r
-                id = TenantNetworkId.networkId(node.get("id").asText());\r
-            } else if (flag == UPDATE_NETWORK) {\r
-                id = networkId;\r
-            }\r
-            network = new DefaultTenantNetwork(\r
-                                               id,\r
-                                               name,\r
-                                               adminStateUp,\r
-                                               isState(state),\r
-                                               shared,\r
-                                               TenantId.tenantId(tenantId),\r
-                                               routerExternal,\r
-                                               isType(type),\r
-                                               PhysicalNetwork\r
-                                                       .physicalNetwork(physicalNetwork),\r
-                                               SegmentationId\r
-                                                       .segmentationId(segmentationId));\r
-            networksMap.putIfAbsent(id, network);\r
-        }\r
-        return Collections.unmodifiableCollection(networksMap.values());\r
-    }\r
-\r
-    /**\r
-     * Returns a collection of tenantNetworks.\r
-     *\r
-     * @param nodes the network jsonnodes\r
-     * @return a collection of tenantNetworks\r
-     */\r
-    public Iterable<TenantNetwork> changeJson2objs(JsonNode nodes) {\r
-        checkNotNull(nodes, JSON_NOT_NULL);\r
-        TenantNetwork network = null;\r
-        ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps\r
-                .newConcurrentMap();\r
-        if (nodes != null) {\r
-            for (JsonNode node : nodes) {\r
-                String id = node.get("id").asText();\r
-                String name = node.get("name").asText();\r
-                boolean adminStateUp = node.get("admin_state_up").asBoolean();\r
-                String state = node.get("status").asText();\r
-                boolean shared = node.get("shared").asBoolean();\r
-                String tenantId = node.get("tenant_id").asText();\r
-                boolean routerExternal = node.get("router:external")\r
-                        .asBoolean();\r
-                String type = node.get("provider:network_type").asText();\r
-                String physicalNetwork = node.get("provider:physical_network")\r
-                        .asText();\r
-                String segmentationId = node.get("provider:segmentation_id")\r
-                        .asText();\r
-                network = new DefaultTenantNetwork(\r
-                                                   TenantNetworkId\r
-                                                           .networkId(id),\r
-                                                   name,\r
-                                                   adminStateUp,\r
-                                                   isState(state),\r
-                                                   shared,\r
-                                                   TenantId.tenantId(tenantId),\r
-                                                   routerExternal,\r
-                                                   isType(type),\r
-                                                   PhysicalNetwork\r
-                                                           .physicalNetwork(physicalNetwork),\r
-                                                   SegmentationId\r
-                                                           .segmentationId(segmentationId));\r
-                networksMap.putIfAbsent(TenantNetworkId.networkId(id), network);\r
-            }\r
-        }\r
-        return Collections.unmodifiableCollection(networksMap.values());\r
-    }\r
-\r
-    /**\r
-     * Returns the specified item if that items is null; otherwise throws not\r
-     * found exception.\r
-     *\r
-     * @param item item to check\r
-     * @param <T> item type\r
-     * @param message not found message\r
-     * @return item if not null\r
-     * @throws org.onlab.util.ItemNotFoundException if item is null\r
-     */\r
-    protected <T> T nullIsNotFound(T item, String message) {\r
-        if (item == null) {\r
-            throw new ItemNotFoundException(message);\r
-        }\r
-        return item;\r
-    }\r
-}\r
+/*
+ * 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.resources;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkArgument;
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+import static javax.ws.rs.core.Response.Status.OK;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onlab.util.ItemNotFoundException;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.vtnrsc.DefaultTenantNetwork;
+import org.onosproject.vtnrsc.PhysicalNetwork;
+import org.onosproject.vtnrsc.SegmentationId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetwork;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.TenantNetwork.State;
+import org.onosproject.vtnrsc.TenantNetwork.Type;
+import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
+import org.onosproject.vtnrsc.web.TenantNetworkCodec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Maps;
+
+/**
+ * REST resource for interacting with the inventory of networks.
+ */
+@Path("networks")
+public class TenantNetworkWebResource extends AbstractWebResource {
+    public static final String NETWORK_NOT_FOUND = "Network is not found";
+    public static final String NETWORK_ID_EXIST = "Network id is existed";
+    public static final String NETWORK_ID_NOT_EXIST = "Network id is not existed";
+    public static final String CREATE_NETWORK = "create network";
+    public static final String UPDATE_NETWORK = "update network";
+    public static final String DELETE_NETWORK = "delete network";
+    public static final String JSON_NOT_NULL = "JsonNode can not be null";
+
+    protected static final Logger log = LoggerFactory
+            .getLogger(TenantNetworkWebResource.class);
+    private final ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
+            .newConcurrentMap();
+
+    @GET
+    @Produces({ MediaType.APPLICATION_JSON })
+    public Response getNetworks(@QueryParam("id") String queryId,
+                                @QueryParam("name") String queryName,
+                                @QueryParam("admin_state_up") String queryadminStateUp,
+                                @QueryParam("status") String querystate,
+                                @QueryParam("shared") String queryshared,
+                                @QueryParam("tenant_id") String querytenantId,
+                                @QueryParam("router:external") String routerExternal,
+                                @QueryParam("provider:network_type") String type,
+                                @QueryParam("provider:physical_network") String physicalNetwork,
+                                @QueryParam("provider:segmentation_id") String segmentationId) {
+        Iterable<TenantNetwork> networks = get(TenantNetworkService.class)
+                .getNetworks();
+        Iterator<TenantNetwork> networkors = networks.iterator();
+        while (networkors.hasNext()) {
+            TenantNetwork network = networkors.next();
+            if ((queryId == null || queryId.equals(network.id().toString()))
+                    && (queryName == null || queryName.equals(network.name()))
+                    && (queryadminStateUp == null || queryadminStateUp
+                            .equals(network.adminStateUp()))
+                    && (querystate == null || querystate.equals(network.state()
+                            .toString()))
+                    && (queryshared == null || queryshared.equals(network
+                            .shared()))
+                    && (querytenantId == null || querytenantId.equals(network
+                            .tenantId().toString()))
+                    && (routerExternal == null || routerExternal.equals(network
+                            .routerExternal()))
+                    && (type == null || type.equals(network.type()))
+                    && (physicalNetwork == null || physicalNetwork
+                            .equals(network.physicalNetwork()))
+                    && (segmentationId == null || segmentationId.equals(network
+                            .segmentationId()))) {
+                networksMap.putIfAbsent(network.id(), network);
+            }
+        }
+        networks = Collections.unmodifiableCollection(networksMap.values());
+        ObjectNode result = new ObjectMapper().createObjectNode();
+        result.set("networks", new TenantNetworkCodec().encode(networks, this));
+
+        return ok(result.toString()).build();
+    }
+
+    private State isState(String state) {
+        if (state.equals("ACTIVE")) {
+            return TenantNetwork.State.ACTIVE;
+        } else if (state.equals("BUILD")) {
+            return TenantNetwork.State.BUILD;
+        } else if (state.equals("DOWN")) {
+            return TenantNetwork.State.DOWN;
+        } else if (state.equals("ERROR")) {
+            return TenantNetwork.State.ERROR;
+        } else {
+            return null;
+        }
+    }
+
+    private Type isType(String type) {
+        if (type.equals("LOCAL")) {
+            return TenantNetwork.Type.LOCAL;
+        } else {
+            return null;
+        }
+    }
+
+    @GET
+    @Path("{id}")
+    @Produces({ MediaType.APPLICATION_JSON })
+    public Response getNetwork(@PathParam("id") String id) {
+
+        if (!get(TenantNetworkService.class).exists(TenantNetworkId
+                                                            .networkId(id))) {
+            return ok("The tenantNetwork does not exists").build();
+        }
+        TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class)
+                .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND);
+        ObjectNode result = new ObjectMapper().createObjectNode();
+        result.set("network", new TenantNetworkCodec().encode(network, this));
+
+        return ok(result.toString()).build();
+
+    }
+
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response createNetworks(InputStream input) {
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode cfg = mapper.readTree(input);
+            JsonNode nodes = null;
+            Iterable<TenantNetwork> networks = null;
+            if (cfg.get("network") != null) {
+                nodes = cfg.get("network");
+                if (nodes.isArray()) {
+                    networks = changeJson2objs(nodes);
+                } else {
+                    networks = changeJson2obj(CREATE_NETWORK, null, nodes);
+                }
+            } else if (cfg.get("networks") != null) {
+                nodes = cfg.get("networks");
+                networks = changeJson2objs(nodes);
+            }
+            Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
+                                                       .createNetworks(networks)),
+                                               NETWORK_NOT_FOUND);
+
+            if (!issuccess) {
+                return Response.status(INTERNAL_SERVER_ERROR)
+                        .entity(NETWORK_ID_EXIST).build();
+            }
+            return Response.status(OK).entity(issuccess.toString()).build();
+        } catch (Exception e) {
+            log.error("Creates tenantNetwork exception {}.", e.toString());
+            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+                    .build();
+        }
+    }
+
+    @PUT
+    @Path("{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response updateNetworks(@PathParam("id") String id, InputStream input) {
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode cfg = mapper.readTree(input);
+            JsonNode nodes = null;
+            Iterable<TenantNetwork> networks = null;
+            if (cfg.get("network") != null) {
+                nodes = cfg.get("network");
+                if (nodes.isArray()) {
+                    networks = changeJson2objs(nodes);
+                } else {
+                    networks = changeJson2obj(UPDATE_NETWORK,
+                                              TenantNetworkId.networkId(id),
+                                              nodes);
+                }
+            } else if (cfg.get("networks") != null) {
+                nodes = cfg.get("networks");
+                networks = changeJson2objs(nodes);
+            }
+            Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
+                                                       .updateNetworks(networks)),
+                                               NETWORK_NOT_FOUND);
+            if (!issuccess) {
+                return Response.status(INTERNAL_SERVER_ERROR)
+                        .entity(NETWORK_ID_NOT_EXIST).build();
+            }
+            return Response.status(OK).entity(issuccess.toString()).build();
+        } catch (Exception e) {
+            log.error("Updates tenantNetwork failed because of exception {}.",
+                      e.toString());
+            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+                    .build();
+        }
+    }
+
+    @DELETE
+    @Path("{id}")
+    public Response deleteNetworks(@PathParam("id") String id) {
+        log.debug("Deletes network by identifier {}.", id);
+        Set<TenantNetworkId> networkSet = new HashSet<>();
+        networkSet.add(TenantNetworkId.networkId(id));
+        Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class)
+                .removeNetworks(networkSet), NETWORK_NOT_FOUND);
+        if (!issuccess) {
+            log.debug("Network identifier {} is not existed", id);
+            return Response.status(INTERNAL_SERVER_ERROR)
+                    .entity(NETWORK_ID_NOT_EXIST).build();
+        }
+        return Response.status(OK).entity(issuccess.toString()).build();
+    }
+
+    /**
+     * Returns a collection of tenantNetworks.
+     *
+     * @param flag the flag
+     * @param networkId network identifier
+     * @param node the network json node
+     * @return a collection of tenantNetworks
+     */
+    public Iterable<TenantNetwork> changeJson2obj(String flag,
+                                                  TenantNetworkId networkId,
+                                                  JsonNode node) {
+        checkNotNull(node, JSON_NOT_NULL);
+        TenantNetwork network = null;
+        ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
+                .newConcurrentMap();
+        if (node != null) {
+            checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
+            checkArgument(node.get("shared").isBoolean(), "shared should be boolean");
+            checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean");
+            String name = node.get("name").asText();
+            boolean adminStateUp = node.get("admin_state_up").asBoolean();
+            String state = node.get("status").asText();
+            boolean shared = node.get("shared").asBoolean();
+            String tenantId = node.get("tenant_id").asText();
+            boolean routerExternal = node.get("router:external").asBoolean();
+            String type = node.get("provider:network_type").asText();
+            String physicalNetwork = node.get("provider:physical_network")
+                    .asText();
+            String segmentationId = node.get("provider:segmentation_id")
+                    .asText();
+            TenantNetworkId id = null;
+            if (flag == CREATE_NETWORK) {
+                id = TenantNetworkId.networkId(node.get("id").asText());
+            } else if (flag == UPDATE_NETWORK) {
+                id = networkId;
+            }
+            network = new DefaultTenantNetwork(
+                                               id,
+                                               name,
+                                               adminStateUp,
+                                               isState(state),
+                                               shared,
+                                               TenantId.tenantId(tenantId),
+                                               routerExternal,
+                                               isType(type),
+                                               PhysicalNetwork
+                                                       .physicalNetwork(physicalNetwork),
+                                               SegmentationId
+                                                       .segmentationId(segmentationId));
+            networksMap.putIfAbsent(id, network);
+        }
+        return Collections.unmodifiableCollection(networksMap.values());
+    }
+
+    /**
+     * Returns a collection of tenantNetworks.
+     *
+     * @param nodes the network jsonnodes
+     * @return a collection of tenantNetworks
+     */
+    public Iterable<TenantNetwork> changeJson2objs(JsonNode nodes) {
+        checkNotNull(nodes, JSON_NOT_NULL);
+        TenantNetwork network = null;
+        ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
+                .newConcurrentMap();
+        if (nodes != null) {
+            for (JsonNode node : nodes) {
+                String id = node.get("id").asText();
+                String name = node.get("name").asText();
+                boolean adminStateUp = node.get("admin_state_up").asBoolean();
+                String state = node.get("status").asText();
+                boolean shared = node.get("shared").asBoolean();
+                String tenantId = node.get("tenant_id").asText();
+                boolean routerExternal = node.get("router:external")
+                        .asBoolean();
+                String type = node.get("provider:network_type").asText();
+                String physicalNetwork = node.get("provider:physical_network")
+                        .asText();
+                String segmentationId = node.get("provider:segmentation_id")
+                        .asText();
+                network = new DefaultTenantNetwork(
+                                                   TenantNetworkId
+                                                           .networkId(id),
+                                                   name,
+                                                   adminStateUp,
+                                                   isState(state),
+                                                   shared,
+                                                   TenantId.tenantId(tenantId),
+                                                   routerExternal,
+                                                   isType(type),
+                                                   PhysicalNetwork
+                                                           .physicalNetwork(physicalNetwork),
+                                                   SegmentationId
+                                                           .segmentationId(segmentationId));
+                networksMap.putIfAbsent(TenantNetworkId.networkId(id), network);
+            }
+        }
+        return Collections.unmodifiableCollection(networksMap.values());
+    }
+
+    /**
+     * Returns the specified item if that items is null; otherwise throws not
+     * found exception.
+     *
+     * @param item item to check
+     * @param <T> item type
+     * @param message not found message
+     * @return item if not null
+     * @throws org.onlab.util.ItemNotFoundException if item is null
+     */
+    protected <T> T nullIsNotFound(T item, String message) {
+        if (item == null) {
+            throw new ItemNotFoundException(message);
+        }
+        return item;
+    }
+}
index 0a427bb..d0b7ed2 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.vtnweb.resources;\r
-\r
-import static com.google.common.base.Preconditions.checkArgument;\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;\r
-import static javax.ws.rs.core.Response.Status.OK;\r
-\r
-import java.io.InputStream;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.concurrent.ConcurrentMap;\r
-\r
-import javax.ws.rs.Consumes;\r
-import javax.ws.rs.DELETE;\r
-import javax.ws.rs.GET;\r
-import javax.ws.rs.POST;\r
-import javax.ws.rs.PUT;\r
-import javax.ws.rs.Path;\r
-import javax.ws.rs.PathParam;\r
-import javax.ws.rs.Produces;\r
-import javax.ws.rs.core.MediaType;\r
-import javax.ws.rs.core.Response;\r
-\r
-import org.onlab.packet.IpAddress;\r
-import org.onlab.packet.MacAddress;\r
-import org.onlab.util.ItemNotFoundException;\r
-import org.onosproject.net.DeviceId;\r
-import org.onosproject.rest.AbstractWebResource;\r
-import org.onosproject.vtnrsc.AllowedAddressPair;\r
-import org.onosproject.vtnrsc.BindingHostId;\r
-import org.onosproject.vtnrsc.DefaultVirtualPort;\r
-import org.onosproject.vtnrsc.FixedIp;\r
-import org.onosproject.vtnrsc.SecurityGroup;\r
-import org.onosproject.vtnrsc.SubnetId;\r
-import org.onosproject.vtnrsc.TenantId;\r
-import org.onosproject.vtnrsc.TenantNetworkId;\r
-import org.onosproject.vtnrsc.VirtualPort;\r
-import org.onosproject.vtnrsc.VirtualPort.State;\r
-import org.onosproject.vtnrsc.VirtualPortId;\r
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;\r
-import org.onosproject.vtnrsc.web.VirtualPortCodec;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-import com.google.common.collect.Maps;\r
-import com.google.common.collect.Sets;\r
-\r
-/**\r
- * REST resource for interacting with the inventory of infrastructure\r
- * virtualPort.\r
- */\r
-@Path("ports")\r
-public class VirtualPortWebResource extends AbstractWebResource {\r
-    public static final String VPORT_NOT_FOUND = "VirtualPort is not found";\r
-    public static final String VPORT_ID_EXIST = "VirtualPort id is exist";\r
-    public static final String VPORT_ID_NOT_EXIST = "VirtualPort id is not exist";\r
-    public static final String JSON_NOT_NULL = "JsonNode can not be null";\r
-    protected static final Logger log = LoggerFactory\r
-            .getLogger(VirtualPortService.class);\r
-\r
-    @GET\r
-    @Produces({ MediaType.APPLICATION_JSON })\r
-    public Response getPorts() {\r
-        Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class)\r
-                .getPorts();\r
-        ObjectNode result = new ObjectMapper().createObjectNode();\r
-        result.set("ports", new VirtualPortCodec().encode(virtualPorts, this));\r
-        return ok(result.toString()).build();\r
-    }\r
-\r
-    @GET\r
-    @Path("{id}")\r
-    @Produces({ MediaType.APPLICATION_JSON })\r
-    public Response getportsById(@PathParam("id") String id) {\r
-\r
-        if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {\r
-            return ok("The virtualPort does not exists").build();\r
-        }\r
-        VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class)\r
-                .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND);\r
-        ObjectNode result = new ObjectMapper().createObjectNode();\r
-        result.set("port", new VirtualPortCodec().encode(virtualPort, this));\r
-        return ok(result.toString()).build();\r
-    }\r
-\r
-    @POST\r
-    @Consumes(MediaType.APPLICATION_JSON)\r
-    @Produces(MediaType.APPLICATION_JSON)\r
-    public Response createPorts(InputStream input) {\r
-        try {\r
-            ObjectMapper mapper = new ObjectMapper();\r
-            JsonNode cfg = mapper.readTree(input);\r
-            Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);\r
-            Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)\r
-                    .createPorts(vPorts), VPORT_NOT_FOUND);\r
-            if (!issuccess) {\r
-                return Response.status(INTERNAL_SERVER_ERROR)\r
-                        .entity(VPORT_ID_NOT_EXIST).build();\r
-            }\r
-            return Response.status(OK).entity(issuccess.toString()).build();\r
-        } catch (Exception e) {\r
-            log.error("Creates VirtualPort failed because of exception {}",\r
-                      e.toString());\r
-            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())\r
-                    .build();\r
-        }\r
-    }\r
-\r
-    @Path("{portUUID}")\r
-    @DELETE\r
-    public Response deletePorts(@PathParam("portUUID") String id) {\r
-        Set<VirtualPortId> vPortIds = new HashSet<VirtualPortId>();\r
-        try {\r
-            if (id != null) {\r
-                vPortIds.add(VirtualPortId.portId(id));\r
-            }\r
-            Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)\r
-                    .removePorts(vPortIds), VPORT_NOT_FOUND);\r
-            if (!issuccess) {\r
-                return Response.status(INTERNAL_SERVER_ERROR)\r
-                        .entity(VPORT_ID_NOT_EXIST).build();\r
-            }\r
-            return Response.status(OK).entity(issuccess.toString()).build();\r
-        } catch (Exception e) {\r
-            log.error("Deletes VirtualPort failed because of exception {}",\r
-                      e.toString());\r
-            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())\r
-                    .build();\r
-        }\r
-    }\r
-\r
-    @PUT\r
-    @Path("{id}")\r
-    @Consumes(MediaType.APPLICATION_JSON)\r
-    @Produces(MediaType.APPLICATION_JSON)\r
-    public Response updatePorts(@PathParam("id") String id, InputStream input) {\r
-        try {\r
-            ObjectMapper mapper = new ObjectMapper();\r
-            JsonNode cfg = mapper.readTree(input);\r
-            Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);\r
-            Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)\r
-                    .updatePorts(vPorts), VPORT_NOT_FOUND);\r
-            if (!issuccess) {\r
-                return Response.status(INTERNAL_SERVER_ERROR)\r
-                        .entity(VPORT_ID_NOT_EXIST).build();\r
-            }\r
-            return Response.status(OK).entity(issuccess.toString()).build();\r
-        } catch (Exception e) {\r
-            log.error("Updates failed because of exception {}", e.toString());\r
-            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())\r
-                    .build();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Returns a Object of the currently known infrastructure virtualPort.\r
-     *\r
-     * @param vPortNode the virtualPort json node\r
-     * @return a collection of virtualPorts\r
-     */\r
-    public Iterable<VirtualPort> createOrUpdateByInputStream(JsonNode vPortNode) {\r
-        checkNotNull(vPortNode, JSON_NOT_NULL);\r
-        JsonNode vPortNodes = vPortNode.get("ports");\r
-        if (vPortNodes == null) {\r
-            vPortNodes = vPortNode.get("port");\r
-        }\r
-        if (vPortNodes.isArray()) {\r
-            return changeJsonToPorts(vPortNodes);\r
-        } else {\r
-            return changeJsonToPort(vPortNodes);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Returns the iterable collection of virtualports from subnetNodes.\r
-     *\r
-     * @param vPortNodes the virtualPort json node\r
-     * @return virtualPorts a collection of virtualPorts\r
-     */\r
-    public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) {\r
-        checkNotNull(vPortNodes, JSON_NOT_NULL);\r
-        Map<VirtualPortId, VirtualPort> portMap = new HashMap<VirtualPortId, VirtualPort>();\r
-        Map<String, String> strMap = new HashMap<String, String>();\r
-        for (JsonNode vPortnode : vPortNodes) {\r
-            VirtualPortId id = VirtualPortId.portId(vPortnode.get("id")\r
-                    .asText());\r
-            String name = vPortnode.get("name").asText();\r
-            TenantId tenantId = TenantId.tenantId(vPortnode.get("tenant_id")\r
-                    .asText());\r
-            TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode\r
-                    .get("network_id").asText());\r
-            checkArgument(vPortnode.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");\r
-            Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean();\r
-            String state = vPortnode.get("status").asText();\r
-            MacAddress macAddress = MacAddress.valueOf(vPortnode\r
-                    .get("mac_address").asText());\r
-            DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id")\r
-                    .asText());\r
-            String deviceOwner = vPortnode.get("device_owner").asText();\r
-            JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");\r
-            Set<FixedIp> fixedIps = new HashSet<FixedIp>();\r
-            for (JsonNode fixedIpNode : fixedIpNodes) {\r
-                FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);\r
-                fixedIps.add(fixedIp);\r
-            }\r
-\r
-            BindingHostId bindingHostId = BindingHostId\r
-                    .bindingHostId(vPortnode.get("binding:host_id").asText());\r
-            String bindingVnicType = vPortnode.get("binding:vnic_type")\r
-                    .asText();\r
-            String bindingVifType = vPortnode.get("binding:vif_type").asText();\r
-            String bindingVifDetails = vPortnode.get("binding:vif_details")\r
-                    .asText();\r
-            JsonNode allowedAddressPairJsonNode = vPortnode\r
-                    .get("allowed_address_pairs");\r
-            Collection<AllowedAddressPair> allowedAddressPairs =\r
-                    jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);\r
-            JsonNode securityGroupNode = vPortnode.get("security_groups");\r
-            Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);\r
-            strMap.put("name", name);\r
-            strMap.put("deviceOwner", deviceOwner);\r
-            strMap.put("bindingVnicType", bindingVnicType);\r
-            strMap.put("bindingVifType", bindingVifType);\r
-            strMap.put("bindingVifDetails", bindingVifDetails);\r
-            VirtualPort vPort = new DefaultVirtualPort(id, networkId,\r
-                                                       adminStateUp, strMap,\r
-                                                       isState(state),\r
-                                                       macAddress, tenantId,\r
-                                                       deviceId, fixedIps,\r
-                                                       bindingHostId,\r
-                                                       Sets.newHashSet(allowedAddressPairs),\r
-                                                       Sets.newHashSet(securityGroups));\r
-            portMap.put(id, vPort);\r
-        }\r
-        return Collections.unmodifiableCollection(portMap.values());\r
-    }\r
-\r
-    /**\r
-     * Returns a collection of virtualPorts from subnetNodes.\r
-     *\r
-     * @param vPortNodes the virtualPort json node\r
-     * @return virtualPorts a collection of virtualPorts\r
-     */\r
-    public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) {\r
-        checkNotNull(vPortNodes, JSON_NOT_NULL);\r
-        Map<VirtualPortId, VirtualPort> vportMap = new HashMap<VirtualPortId, VirtualPort>();\r
-        Map<String, String> strMap = new HashMap<String, String>();\r
-        VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText());\r
-        String name = vPortNodes.get("name").asText();\r
-        TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id")\r
-                .asText());\r
-        TenantNetworkId networkId = TenantNetworkId.networkId(vPortNodes\r
-                .get("network_id").asText());\r
-        Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean();\r
-        String state = vPortNodes.get("status").asText();\r
-        MacAddress macAddress = MacAddress.valueOf(vPortNodes\r
-                .get("mac_address").asText());\r
-        DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id")\r
-                .asText());\r
-        String deviceOwner = vPortNodes.get("device_owner").asText();\r
-        JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");\r
-        Set<FixedIp> fixedIps = new HashSet<FixedIp>();\r
-        for (JsonNode fixedIpNode : fixedIpNodes) {\r
-            FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);\r
-            fixedIps.add(fixedIp);\r
-        }\r
-\r
-        BindingHostId bindingHostId = BindingHostId\r
-                .bindingHostId(vPortNodes.get("binding:host_id").asText());\r
-        String bindingVnicType = vPortNodes.get("binding:vnic_type").asText();\r
-        String bindingVifType = vPortNodes.get("binding:vif_type").asText();\r
-        String bindingVifDetails = vPortNodes.get("binding:vif_details")\r
-                .asText();\r
-        JsonNode allowedAddressPairJsonNode = vPortNodes\r
-                .get("allowed_address_pairs");\r
-        Collection<AllowedAddressPair> allowedAddressPairs =\r
-                jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);\r
-        JsonNode securityGroupNode = vPortNodes.get("security_groups");\r
-        Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);\r
-        strMap.put("name", name);\r
-        strMap.put("deviceOwner", deviceOwner);\r
-        strMap.put("bindingVnicType", bindingVnicType);\r
-        strMap.put("bindingVifType", bindingVifType);\r
-        strMap.put("bindingVifDetails", bindingVifDetails);\r
-        VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp,\r
-                                                   strMap, isState(state),\r
-                                                   macAddress, tenantId,\r
-                                                   deviceId, fixedIps,\r
-                                                   bindingHostId,\r
-                                                   Sets.newHashSet(allowedAddressPairs),\r
-                                                   Sets.newHashSet(securityGroups));\r
-        vportMap.put(id, vPort);\r
-\r
-        return Collections.unmodifiableCollection(vportMap.values());\r
-    }\r
-\r
-    /**\r
-     * Returns a Object of the currently known infrastructure virtualPort.\r
-     *\r
-     * @param allowedAddressPairs the allowedAddressPairs json node\r
-     * @return a collection of allowedAddressPair\r
-     */\r
-    public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {\r
-        checkNotNull(allowedAddressPairs, JSON_NOT_NULL);\r
-        ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps\r
-                .newConcurrentMap();\r
-        int i = 0;\r
-        for (JsonNode node : allowedAddressPairs) {\r
-            IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());\r
-            MacAddress mac = MacAddress.valueOf(node.get("mac_address")\r
-                    .asText());\r
-            AllowedAddressPair allows = AllowedAddressPair\r
-                    .allowedAddressPair(ip, mac);\r
-            allowMaps.put(i, allows);\r
-            i++;\r
-        }\r
-        log.debug("The jsonNode of allowedAddressPairallow is {}"\r
-                + allowedAddressPairs.toString());\r
-        return Collections.unmodifiableCollection(allowMaps.values());\r
-    }\r
-\r
-    /**\r
-     * Returns a collection of virtualPorts.\r
-     *\r
-     * @param securityGroups the virtualPort jsonnode\r
-     * @return a collection of securityGroups\r
-     */\r
-    public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) {\r
-        checkNotNull(securityGroups, JSON_NOT_NULL);\r
-        ConcurrentMap<Integer, SecurityGroup> securMaps = Maps\r
-                .newConcurrentMap();\r
-        int i = 0;\r
-        for (JsonNode node : securityGroups) {\r
-            SecurityGroup securityGroup = SecurityGroup\r
-                    .securityGroup(node.asText());\r
-            securMaps.put(i, securityGroup);\r
-            i++;\r
-        }\r
-        return Collections.unmodifiableCollection(securMaps.values());\r
-    }\r
-\r
-    /**\r
-     * Returns a collection of fixedIps.\r
-     *\r
-     * @param fixedIpNode the fixedIp jsonnode\r
-     * @return a collection of SecurityGroup\r
-     */\r
-    public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) {\r
-        SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id")\r
-                .asText());\r
-        IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address")\r
-                .asText());\r
-        FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress);\r
-        return fixedIps;\r
-    }\r
-\r
-    /**\r
-     * Returns VirtualPort State.\r
-     *\r
-     * @param state the virtualport state\r
-     * @return the virtualPort state\r
-     */\r
-    private State isState(String state) {\r
-        if (state.equals("ACTIVE")) {\r
-            return VirtualPort.State.ACTIVE;\r
-        } else {\r
-            return VirtualPort.State.DOWN;\r
-        }\r
-\r
-    }\r
-\r
-    /**\r
-     * Returns the specified item if that items is null; otherwise throws not\r
-     * found exception.\r
-     *\r
-     * @param item item to check\r
-     * @param <T> item type\r
-     * @param message not found message\r
-     * @return item if not null\r
-     * @throws org.onlab.util.ItemNotFoundException if item is null\r
-     */\r
-    protected <T> T nullIsNotFound(T item, String message) {\r
-        if (item == null) {\r
-            throw new ItemNotFoundException(message);\r
-        }\r
-        return item;\r
-    }\r
-}\r
+/*
+ * 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.resources;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+import static javax.ws.rs.core.Response.Status.OK;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.util.ItemNotFoundException;
+import org.onosproject.net.DeviceId;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.vtnrsc.AllowedAddressPair;
+import org.onosproject.vtnrsc.BindingHostId;
+import org.onosproject.vtnrsc.DefaultVirtualPort;
+import org.onosproject.vtnrsc.FixedIp;
+import org.onosproject.vtnrsc.SecurityGroup;
+import org.onosproject.vtnrsc.SubnetId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.VirtualPort;
+import org.onosproject.vtnrsc.VirtualPort.State;
+import org.onosproject.vtnrsc.VirtualPortId;
+import org.onosproject.vtnrsc.virtualport.VirtualPortService;
+import org.onosproject.vtnrsc.web.VirtualPortCodec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * REST resource for interacting with the inventory of infrastructure
+ * virtualPort.
+ */
+@Path("ports")
+public class VirtualPortWebResource extends AbstractWebResource {
+    public static final String VPORT_NOT_FOUND = "VirtualPort is not found";
+    public static final String VPORT_ID_EXIST = "VirtualPort id is exist";
+    public static final String VPORT_ID_NOT_EXIST = "VirtualPort id is not exist";
+    public static final String JSON_NOT_NULL = "JsonNode can not be null";
+    protected static final Logger log = LoggerFactory
+            .getLogger(VirtualPortService.class);
+
+    @GET
+    @Produces({ MediaType.APPLICATION_JSON })
+    public Response getPorts() {
+        Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class)
+                .getPorts();
+        ObjectNode result = new ObjectMapper().createObjectNode();
+        result.set("ports", new VirtualPortCodec().encode(virtualPorts, this));
+        return ok(result.toString()).build();
+    }
+
+    @GET
+    @Path("{id}")
+    @Produces({ MediaType.APPLICATION_JSON })
+    public Response getportsById(@PathParam("id") String id) {
+
+        if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {
+            return ok("The virtualPort does not exists").build();
+        }
+        VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class)
+                .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND);
+        ObjectNode result = new ObjectMapper().createObjectNode();
+        result.set("port", new VirtualPortCodec().encode(virtualPort, this));
+        return ok(result.toString()).build();
+    }
+
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response createPorts(InputStream input) {
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode cfg = mapper.readTree(input);
+            Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
+            Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
+                    .createPorts(vPorts), VPORT_NOT_FOUND);
+            if (!issuccess) {
+                return Response.status(INTERNAL_SERVER_ERROR)
+                        .entity(VPORT_ID_NOT_EXIST).build();
+            }
+            return Response.status(OK).entity(issuccess.toString()).build();
+        } catch (Exception e) {
+            log.error("Creates VirtualPort failed because of exception {}",
+                      e.toString());
+            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+                    .build();
+        }
+    }
+
+    @Path("{portUUID}")
+    @DELETE
+    public Response deletePorts(@PathParam("portUUID") String id) {
+        Set<VirtualPortId> vPortIds = new HashSet<>();
+        try {
+            if (id != null) {
+                vPortIds.add(VirtualPortId.portId(id));
+            }
+            Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
+                    .removePorts(vPortIds), VPORT_NOT_FOUND);
+            if (!issuccess) {
+                return Response.status(INTERNAL_SERVER_ERROR)
+                        .entity(VPORT_ID_NOT_EXIST).build();
+            }
+            return Response.status(OK).entity(issuccess.toString()).build();
+        } catch (Exception e) {
+            log.error("Deletes VirtualPort failed because of exception {}",
+                      e.toString());
+            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+                    .build();
+        }
+    }
+
+    @PUT
+    @Path("{id}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response updatePorts(@PathParam("id") String id, InputStream input) {
+        try {
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode cfg = mapper.readTree(input);
+            Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
+            Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
+                    .updatePorts(vPorts), VPORT_NOT_FOUND);
+            if (!issuccess) {
+                return Response.status(INTERNAL_SERVER_ERROR)
+                        .entity(VPORT_ID_NOT_EXIST).build();
+            }
+            return Response.status(OK).entity(issuccess.toString()).build();
+        } catch (Exception e) {
+            log.error("Updates failed because of exception {}", e.toString());
+            return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+                    .build();
+        }
+    }
+
+    /**
+     * Returns a Object of the currently known infrastructure virtualPort.
+     *
+     * @param vPortNode the virtualPort json node
+     * @return a collection of virtualPorts
+     */
+    public Iterable<VirtualPort> createOrUpdateByInputStream(JsonNode vPortNode) {
+        checkNotNull(vPortNode, JSON_NOT_NULL);
+        JsonNode vPortNodes = vPortNode.get("ports");
+        if (vPortNodes == null) {
+            vPortNodes = vPortNode.get("port");
+        }
+        if (vPortNodes.isArray()) {
+            return changeJsonToPorts(vPortNodes);
+        } else {
+            return changeJsonToPort(vPortNodes);
+        }
+    }
+
+    /**
+     * Returns the iterable collection of virtualports from subnetNodes.
+     *
+     * @param vPortNodes the virtualPort json node
+     * @return virtualPorts a collection of virtualPorts
+     */
+    public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) {
+        checkNotNull(vPortNodes, JSON_NOT_NULL);
+        Map<VirtualPortId, VirtualPort> portMap = new HashMap<>();
+        Map<String, String> strMap = new HashMap<>();
+        for (JsonNode vPortnode : vPortNodes) {
+            VirtualPortId id = VirtualPortId.portId(vPortnode.get("id")
+                    .asText());
+            String name = vPortnode.get("name").asText();
+            TenantId tenantId = TenantId.tenantId(vPortnode.get("tenant_id")
+                    .asText());
+            TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode
+                    .get("network_id").asText());
+            checkArgument(vPortnode.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
+            Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean();
+            String state = vPortnode.get("status").asText();
+            MacAddress macAddress = MacAddress.valueOf(vPortnode
+                    .get("mac_address").asText());
+            DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id")
+                    .asText());
+            String deviceOwner = vPortnode.get("device_owner").asText();
+            JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
+            Set<FixedIp> fixedIps = new HashSet<>();
+            for (JsonNode fixedIpNode : fixedIpNodes) {
+                FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
+                fixedIps.add(fixedIp);
+            }
+
+            BindingHostId bindingHostId = BindingHostId
+                    .bindingHostId(vPortnode.get("binding:host_id").asText());
+            String bindingVnicType = vPortnode.get("binding:vnic_type")
+                    .asText();
+            String bindingVifType = vPortnode.get("binding:vif_type").asText();
+            String bindingVifDetails = vPortnode.get("binding:vif_details")
+                    .asText();
+            JsonNode allowedAddressPairJsonNode = vPortnode
+                    .get("allowed_address_pairs");
+            Collection<AllowedAddressPair> allowedAddressPairs =
+                    jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
+            JsonNode securityGroupNode = vPortnode.get("security_groups");
+            Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
+            strMap.put("name", name);
+            strMap.put("deviceOwner", deviceOwner);
+            strMap.put("bindingVnicType", bindingVnicType);
+            strMap.put("bindingVifType", bindingVifType);
+            strMap.put("bindingVifDetails", bindingVifDetails);
+            VirtualPort vPort = new DefaultVirtualPort(id, networkId,
+                                                       adminStateUp, strMap,
+                                                       isState(state),
+                                                       macAddress, tenantId,
+                                                       deviceId, fixedIps,
+                                                       bindingHostId,
+                                                       Sets.newHashSet(allowedAddressPairs),
+                                                       Sets.newHashSet(securityGroups));
+            portMap.put(id, vPort);
+        }
+        return Collections.unmodifiableCollection(portMap.values());
+    }
+
+    /**
+     * Returns a collection of virtualPorts from subnetNodes.
+     *
+     * @param vPortNodes the virtualPort json node
+     * @return virtualPorts a collection of virtualPorts
+     */
+    public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) {
+        checkNotNull(vPortNodes, JSON_NOT_NULL);
+        Map<VirtualPortId, VirtualPort> vportMap = new HashMap<>();
+        Map<String, String> strMap = new HashMap<>();
+        VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText());
+        String name = vPortNodes.get("name").asText();
+        TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id")
+                .asText());
+        TenantNetworkId networkId = TenantNetworkId.networkId(vPortNodes
+                .get("network_id").asText());
+        Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean();
+        String state = vPortNodes.get("status").asText();
+        MacAddress macAddress = MacAddress.valueOf(vPortNodes
+                .get("mac_address").asText());
+        DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id")
+                .asText());
+        String deviceOwner = vPortNodes.get("device_owner").asText();
+        JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
+        Set<FixedIp> fixedIps = new HashSet<>();
+        for (JsonNode fixedIpNode : fixedIpNodes) {
+            FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
+            fixedIps.add(fixedIp);
+        }
+
+        BindingHostId bindingHostId = BindingHostId
+                .bindingHostId(vPortNodes.get("binding:host_id").asText());
+        String bindingVnicType = vPortNodes.get("binding:vnic_type").asText();
+        String bindingVifType = vPortNodes.get("binding:vif_type").asText();
+        String bindingVifDetails = vPortNodes.get("binding:vif_details")
+                .asText();
+        JsonNode allowedAddressPairJsonNode = vPortNodes
+                .get("allowed_address_pairs");
+        Collection<AllowedAddressPair> allowedAddressPairs =
+                jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
+        JsonNode securityGroupNode = vPortNodes.get("security_groups");
+        Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
+        strMap.put("name", name);
+        strMap.put("deviceOwner", deviceOwner);
+        strMap.put("bindingVnicType", bindingVnicType);
+        strMap.put("bindingVifType", bindingVifType);
+        strMap.put("bindingVifDetails", bindingVifDetails);
+        VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp,
+                                                   strMap, isState(state),
+                                                   macAddress, tenantId,
+                                                   deviceId, fixedIps,
+                                                   bindingHostId,
+                                                   Sets.newHashSet(allowedAddressPairs),
+                                                   Sets.newHashSet(securityGroups));
+        vportMap.put(id, vPort);
+
+        return Collections.unmodifiableCollection(vportMap.values());
+    }
+
+    /**
+     * Returns a Object of the currently known infrastructure virtualPort.
+     *
+     * @param allowedAddressPairs the allowedAddressPairs json node
+     * @return a collection of allowedAddressPair
+     */
+    public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {
+        checkNotNull(allowedAddressPairs, JSON_NOT_NULL);
+        ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps
+                .newConcurrentMap();
+        int i = 0;
+        for (JsonNode node : allowedAddressPairs) {
+            IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());
+            MacAddress mac = MacAddress.valueOf(node.get("mac_address")
+                    .asText());
+            AllowedAddressPair allows = AllowedAddressPair
+                    .allowedAddressPair(ip, mac);
+            allowMaps.put(i, allows);
+            i++;
+        }
+        log.debug("The jsonNode of allowedAddressPairallow is {}"
+                + allowedAddressPairs.toString());
+        return Collections.unmodifiableCollection(allowMaps.values());
+    }
+
+    /**
+     * Returns a collection of virtualPorts.
+     *
+     * @param securityGroups the virtualPort jsonnode
+     * @return a collection of securityGroups
+     */
+    public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) {
+        checkNotNull(securityGroups, JSON_NOT_NULL);
+        ConcurrentMap<Integer, SecurityGroup> securMaps = Maps
+                .newConcurrentMap();
+        int i = 0;
+        for (JsonNode node : securityGroups) {
+            SecurityGroup securityGroup = SecurityGroup
+                    .securityGroup(node.asText());
+            securMaps.put(i, securityGroup);
+            i++;
+        }
+        return Collections.unmodifiableCollection(securMaps.values());
+    }
+
+    /**
+     * Returns a collection of fixedIps.
+     *
+     * @param fixedIpNode the fixedIp jsonnode
+     * @return a collection of SecurityGroup
+     */
+    public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) {
+        SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id")
+                .asText());
+        IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address")
+                .asText());
+        FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress);
+        return fixedIps;
+    }
+
+    /**
+     * Returns VirtualPort State.
+     *
+     * @param state the virtualport state
+     * @return the virtualPort state
+     */
+    private State isState(String state) {
+        if (state.equals("ACTIVE")) {
+            return VirtualPort.State.ACTIVE;
+        } else {
+            return VirtualPort.State.DOWN;
+        }
+
+    }
+
+    /**
+     * Returns the specified item if that items is null; otherwise throws not
+     * found exception.
+     *
+     * @param item item to check
+     * @param <T> item type
+     * @param message not found message
+     * @return item if not null
+     * @throws org.onlab.util.ItemNotFoundException if item is null
+     */
+    protected <T> T nullIsNotFound(T item, String message) {
+        if (item == null) {
+            throw new ItemNotFoundException(message);
+        }
+        return item;
+    }
+}
index 0dc2300..68eafd1 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index a9cd180..3d29a26 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 0ab6845..b0cbbdd 100644 (file)
@@ -25,7 +25,6 @@ import org.onosproject.net.ElementId;
 import org.onosproject.net.Port;
 import org.onosproject.net.flow.FlowRule;
 import org.onosproject.net.group.Group;
-import org.onosproject.net.host.PortAddresses;
 import org.onosproject.net.topology.TopologyCluster;
 
 import java.util.Comparator;
@@ -113,13 +112,6 @@ public final class Comparators {
         }
     };
 
-    public static final Comparator<PortAddresses> ADDRESSES_COMPARATOR = new Comparator<PortAddresses>() {
-        @Override
-        public int compare(PortAddresses arg0, PortAddresses arg1) {
-            return CONNECT_POINT_COMPARATOR.compare(arg0.connectPoint(), arg1.connectPoint());
-        }
-    };
-
     public static final Comparator<Interface> INTERFACES_COMPARATOR = (intf1, intf2) ->
             CONNECT_POINT_COMPARATOR.compare(intf1.connectPoint(), intf2.connectPoint());
 
index f05181f..5ab15b0 100644 (file)
@@ -28,7 +28,7 @@ public class MetricNameCompleter extends AbstractChoicesCompleter {
     @Override
     protected List<String> choices() {
         MetricsService metricsService = AbstractShellCommand.get(MetricsService.class);
-        return new ArrayList<String>(metricsService.getMetrics().keySet());
+        return new ArrayList<>(metricsService.getMetrics().keySet());
     }
 
 }
index 5f2f86e..d99a183 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cli.cfg;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -52,7 +53,7 @@ public class NetworkConfigCommand extends AbstractShellCommand {
     @Override
     protected void execute() {
         service = get(NetworkConfigService.class);
-        JsonNode root = new ObjectMapper().createObjectNode();
+        JsonNode root = mapper.createObjectNode();
         if (isNullOrEmpty(subjectKey)) {
             addAll((ObjectNode) root);
         } else {
@@ -68,14 +69,19 @@ public class NetworkConfigCommand extends AbstractShellCommand {
                 }
             }
         }
-        print("%s", root.toString());
+
+        try {
+            print("%s", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException("Error writing JSON to string", e);
+        }
     }
 
     @SuppressWarnings("unchecked")
     private void addAll(ObjectNode root) {
         service.getSubjectClasses()
                 .forEach(sc -> {
-                    SubjectFactory sf = service.getSubjectFactory((Class) sc);
+                    SubjectFactory sf = service.getSubjectFactory(sc);
                     addSubjectClass(newObject(root, sf.subjectKey()), sf);
                 });
     }
index 1929b72..a736f99 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.cli.net;
 
 import org.apache.karaf.shell.commands.Argument;
index d68084c..12e9ab5 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.cli.net;
 
 import java.util.Set;
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java
new file mode 100644 (file)
index 0000000..ff66b80
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.cli.net;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.packet.PacketProcessor;
+import org.onosproject.net.packet.PacketService;
+
+import static org.onosproject.net.packet.PacketProcessor.ADVISOR_MAX;
+import static org.onosproject.net.packet.PacketProcessor.DIRECTOR_MAX;
+
+/**
+ * Lists packet processors.
+ */
+@Command(scope = "onos", name = "packet-processors",
+        description = "Lists packet processors")
+public class PacketProcessorsListCommand extends AbstractShellCommand {
+
+    private static final String FMT = "priority=%s, class=%s";
+
+    @Override
+    protected void execute() {
+        PacketService service = get(PacketService.class);
+        if (outputJson()) {
+            // TODO: implement this
+            print("Not implemented.");
+        } else {
+            service.getProcessors().forEach(this::print);
+        }
+    }
+
+    private void print(int priority, PacketProcessor processor) {
+        print(FMT, priorityFormat(priority), processor.getClass().getName());
+    }
+
+    private String priorityFormat(int priority) {
+        if (priority > DIRECTOR_MAX) {
+            return "observer(" + (priority - DIRECTOR_MAX - 1) + ")";
+        } else if (priority > ADVISOR_MAX) {
+            return "director(" + (priority - ADVISOR_MAX - 1) + ")";
+        }
+        return "advisor(" + (priority - 1) + ")";
+    }
+
+}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java
new file mode 100644 (file)
index 0000000..9bdeadb
--- /dev/null
@@ -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.cli.net;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.packet.PacketRequest;
+import org.onosproject.net.packet.PacketService;
+
+/**
+ * Lists packet requests.
+ */
+@Command(scope = "onos", name = "packet-requests",
+        description = "Lists packet requests")
+public class PacketRequestsListCommand extends AbstractShellCommand {
+
+    private static final String FMT = "priority=%s, appId=%s, criteria=%s";
+
+    @Override
+    protected void execute() {
+        PacketService service = get(PacketService.class);
+        if (outputJson()) {
+            // TODO: implement this
+            print("Not implemented.");
+        } else {
+            service.getRequests().forEach(this::print);
+        }
+    }
+
+    private void print(PacketRequest request) {
+        print(FMT, request.priority(), request.appId().name(), request.selector().criteria());
+    }
+
+}
index 640868f..459ffa9 100644 (file)
                 <ref component-id="hostIdCompleter"/>
             </completers>
         </command>
-        <command>
-            <action class="org.onosproject.cli.net.AddressBindingsListCommand"/>
-        </command>
         <command>
             <action class="org.onosproject.cli.net.InterfacesListCommand"/>
         </command>
             </completers>
         </command>
 
+        <command>
+            <action class="org.onosproject.cli.net.PacketRequestsListCommand"/>
+        </command>
+        <command>
+            <action class="org.onosproject.cli.net.PacketProcessorsListCommand"/>
+        </command>
+
         <command>
             <action class="org.onosproject.cli.net.AddTestFlowsCommand"/>
         </command>
index 7cfb4ac..23a051c 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-core</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index dbe5f71..1ee78b1 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.cluster;
 
 import java.util.Set;
index 3cfc936..2f74ae6 100644 (file)
@@ -23,7 +23,7 @@ import org.onlab.packet.IpAddress;
 public interface ControllerNode {
 
     /** Represents the operational state of the instance. */
-    public enum State {
+    enum State {
         /**
          * Signifies that the instance is active and operating normally.
          */
index 3dfc6b2..303ad39 100644 (file)
@@ -27,12 +27,12 @@ public interface CoreService {
     /**
      * Name of the core "application".
      */
-    static final String CORE_APP_NAME = "org.onosproject.core";
+    String CORE_APP_NAME = "org.onosproject.core";
 
     /**
      * Identifier of the core "provider".
      */
-    static final ProviderId CORE_PROVIDER_ID = new ProviderId("core", CORE_APP_NAME);
+    ProviderId CORE_PROVIDER_ID = new ProviderId("core", CORE_APP_NAME);
 
     /**
      * Returns the product version.
index b5be094..8de0543 100644 (file)
@@ -32,7 +32,7 @@ public interface MetricsHelper {
      *
      * @return MetricService instance
      */
-    abstract MetricsService metricsService();
+    MetricsService metricsService();
 
 
     /**
index d900182..ffbf7f9 100644 (file)
@@ -25,7 +25,7 @@ public interface Device extends Element {
     /**
      * Coarse classification of the type of the infrastructure device.
      */
-    public enum Type {
+    enum Type {
         SWITCH, ROUTER, ROADM, OTN, ROADM_OTN, FIREWALL, BALANCER, IPS, IDS, CONTROLLER,
         VIRTUAL, FIBER_SWITCH, MICROWAVE, OTHER
     }
index 9e19b62..aba8ae4 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net;
 
 import java.util.Objects;
index b6068ee..e962110 100644 (file)
@@ -17,6 +17,7 @@ package org.onosproject.net.config.basics;
 
 import org.onosproject.net.Link;
 import org.onosproject.net.LinkKey;
+import com.fasterxml.jackson.databind.JsonNode;
 
 import java.time.Duration;
 
@@ -28,6 +29,7 @@ public class BasicLinkConfig extends AllowedEntityConfig<LinkKey> {
     public static final String TYPE = "type";
     public static final String LATENCY = "latency";
     public static final String BANDWIDTH = "bandwidth";
+    public static final String IS_DURABLE = "durable";
 
     /**
      * Returns the link type.
@@ -87,4 +89,26 @@ public class BasicLinkConfig extends AllowedEntityConfig<LinkKey> {
         return (BasicLinkConfig) setOrClear(BANDWIDTH, bandwidth);
     }
 
+    /**
+     * Returns if link is durable in the network model or not.
+     *
+     * @return true for durable, false otherwise
+     */
+    public Boolean isDurable() {
+        JsonNode res = object.path(IS_DURABLE);
+        if (res.isMissingNode()) {
+            return null;
+        }
+        return res.asBoolean();
+    }
+
+    /**
+     * Sets durability for this link.
+     *
+     * @param isDurable true for durable, false otherwise
+     * @return this BasicLinkConfig
+     */
+    public BasicLinkConfig isDurable(Boolean isDurable) {
+        return (BasicLinkConfig) setOrClear(IS_DURABLE, isDurable);
+    }
 }
index b06c422..dfb494d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.config.basics;
 
 import java.util.Optional;
index 44a4d36..5492fa9 100644 (file)
@@ -291,6 +291,7 @@ public class DefaultFlowRule implements FlowRule {
     public static final class Builder implements FlowRule.Builder {
 
         private FlowId flowId;
+        private ApplicationId appId;
         private Integer priority;
         private DeviceId deviceId;
         private Integer tableId = 0;
@@ -307,7 +308,7 @@ public class DefaultFlowRule implements FlowRule {
 
         @Override
         public FlowRule.Builder fromApp(ApplicationId appId) {
-            this.flowId = computeFlowId(appId);
+            this.appId = appId;
             return this;
         }
 
@@ -357,16 +358,22 @@ public class DefaultFlowRule implements FlowRule {
 
         @Override
         public FlowRule build() {
-            checkNotNull(flowId != null, "Either an application" +
+            checkArgument(flowId != null || appId != null, "Either an application" +
                     " id or a cookie must be supplied");
-            checkNotNull(selector != null, "Traffic selector cannot be null");
-            checkNotNull(timeout != null || permanent != null, "Must either have " +
+            checkNotNull(selector, "Traffic selector cannot be null");
+            checkArgument(timeout != null || permanent != null, "Must either have " +
                     "a timeout or be permanent");
-            checkNotNull(deviceId != null, "Must refer to a device");
-            checkNotNull(priority != null, "Priority cannot be null");
+            checkNotNull(deviceId, "Must refer to a device");
+            checkNotNull(priority, "Priority cannot be null");
             checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " +
                     MIN_PRIORITY);
 
+            // Computing a flow ID based on appId takes precedence over setting
+            // the flow ID directly
+            if (appId != null) {
+                flowId = computeFlowId(appId);
+            }
+
             return new DefaultFlowRule(deviceId, selector, treatment, priority,
                                        flowId, permanent, timeout, tableId);
         }
index e446a9f..a487cbc 100644 (file)
@@ -25,8 +25,8 @@ import org.onosproject.net.DeviceId;
  */
 public interface FlowRule {
 
-    static final int MAX_TIMEOUT = 60;
-    static final int MIN_PRIORITY = 0;
+    int MAX_TIMEOUT = 60;
+    int MIN_PRIORITY = 0;
 
     /**
      * The FlowRule type is used to determine in which table the flow rule needs
@@ -36,7 +36,7 @@ public interface FlowRule {
      * @deprecated in Cardinal Release
      */
     @Deprecated
-    static enum Type {
+    enum Type {
         /*
          * Default type - used in flow rule for single table switch NOTE: this
          * setting should not be used as Table 0 in a multi-table pipeline
index 8d36be4..d4d2d9e 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.flow;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
index e297115..d4f959c 100644 (file)
@@ -32,7 +32,7 @@ public interface FlowRuleService
     /**
      * The topic used for obtaining globally unique ids.
      */
-    static String FLOW_OP_TOPIC = "flow-ops-ids";
+    String FLOW_OP_TOPIC = "flow-ops-ids";
 
     /**
      * Returns the number of flow rules in the system.
index f2de9a0..534f6b9 100644 (file)
@@ -24,7 +24,6 @@ import org.onlab.packet.MplsLabel;
 import org.onlab.packet.TpPort;
 import org.onlab.packet.VlanId;
 import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector.Builder;
 import org.onosproject.net.flow.criteria.Criterion;
 
 /**
index 1ace893..c8b6690 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.flow.criteria;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
index 090c298..6ac7a7a 100644 (file)
@@ -26,9 +26,9 @@ import java.util.Optional;
 @Beta
 public interface Objective {
 
-    static final boolean DEFAULT_PERMANENT = true;
-    static final int DEFAULT_TIMEOUT = 0;
-    static final int DEFAULT_PRIORITY = 32768;
+    boolean DEFAULT_PERMANENT = true;
+    int DEFAULT_TIMEOUT = 0;
+    int DEFAULT_PRIORITY = 32768;
 
     /**
      * Type of operation.
index d620fed..8676e46 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onosproject.net.host;
 
-import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.HostId;
 
 /**
@@ -30,37 +29,4 @@ public interface HostAdminService extends HostService {
      */
     void removeHost(HostId hostId);
 
-    /**
-     * Binds IP and MAC addresses to the given connection point.
-     * <p>
-     * The addresses are added to the set of addresses already bound to the
-     * connection point.
-     *
-     * @param addresses address object containing addresses to add and the port
-     * to add them to
-     * @deprecated in Drake release: address info now stored in InterfaceService
-     */
-    @Deprecated
-    void bindAddressesToPort(PortAddresses addresses);
-
-    /**
-     * Removes the addresses contained in the given PortAddresses object from
-     * the set of addresses bound to the port.
-     *
-     * @param portAddresses set of addresses to remove and port to remove them
-     * from
-     * @deprecated in Drake release: address info now stored in InterfaceService
-     */
-    @Deprecated
-    void unbindAddressesFromPort(PortAddresses portAddresses);
-
-    /**
-     * Removes all address information for the given connection point.
-     *
-     * @param connectPoint the connection point to remove address information
-     * @deprecated in Drake release: address info now stored in InterfaceService
-     */
-    @Deprecated
-    void clearAddresses(ConnectPoint connectPoint);
-
 }
index 8678a29..f7b7c49 100644 (file)
@@ -30,7 +30,20 @@ public interface HostProviderService extends ProviderService<HostProvider> {
      * @param hostId          id of the host that been detected
      * @param hostDescription description of host and its location
      */
-    void hostDetected(HostId hostId, HostDescription hostDescription);
+    @Deprecated
+    default void hostDetected(HostId hostId, HostDescription hostDescription) {
+        hostDetected(hostId, hostDescription, false);
+    }
+
+    /**
+     * Notifies the core when a host has been detected on a network along with
+     * information that identifies the host location.
+     *
+     * @param hostId          id of the host that been detected
+     * @param hostDescription description of host and its location
+     * @param replaceIps      replace IP set if true, merge IP set otherwise
+     */
+    void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps);
 
     /**
      * Notifies the core when a host is no longer detected on a network.
index be114f0..3901215 100644 (file)
@@ -123,24 +123,4 @@ public interface HostService
      */
     void requestMac(IpAddress ip);
 
-    /**
-     * Returns the addresses information for all connection points.
-     *
-     * @return the set of address bindings for all connection points
-     * @deprecated in Drake release: use InterfaceService instead
-     */
-    @Deprecated
-    Set<PortAddresses> getAddressBindings();
-
-    /**
-     * Retrieves the addresses that have been bound to the given connection
-     * point.
-     *
-     * @param connectPoint the connection point to retrieve address bindings for
-     * @return addresses bound to the port
-     * @deprecated in Drake release: use InterfaceService instead
-     */
-    @Deprecated
-    Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint);
-
 }
index ca11a94..5894fe9 100644 (file)
@@ -39,12 +39,13 @@ public interface HostStore extends Store<HostEvent, HostStoreDelegate> {
      * @param providerId      provider identification
      * @param hostId          host identification
      * @param hostDescription host description data
+     * @param replaceIps      replace IP set if true, merge IP set otherwise
      * @return appropriate event or null if no change resulted
      */
     HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId,
-                                 HostDescription hostDescription);
+                                 HostDescription hostDescription,
+                                 boolean replaceIps);
 
-    // FIXME: API to remove only IpAddress is missing
     /**
      * Removes the specified host from the inventory.
      *
@@ -115,53 +116,4 @@ public interface HostStore extends Store<HostEvent, HostStoreDelegate> {
      */
     Set<Host> getConnectedHosts(DeviceId deviceId);
 
-    /**
-     * Updates the address information for a given port. The given address
-     * information is added to any previously held information for the port.
-     *
-     * @param addresses the port and address information
-     * @deprecated in Drake release: address info now stored in InterfaceService
-     */
-    @Deprecated
-    void updateAddressBindings(PortAddresses addresses);
-
-    /**
-     * Removes the given addresses from the set of address information held for
-     * a port.
-     *
-     * @param addresses the port and address information
-     * @deprecated in Drake release: address info now stored in InterfaceService
-     */
-    @Deprecated
-    void removeAddressBindings(PortAddresses addresses);
-
-    /**
-     * Removes any previously stored address information for a given connection
-     * point.
-     *
-     * @param connectPoint the connection point
-     * @deprecated in Drake release: address info now stored in InterfaceService
-     */
-    @Deprecated
-    void clearAddressBindings(ConnectPoint connectPoint);
-
-    /**
-     * Returns the address bindings stored for all connection points.
-     *
-     * @return the set of address bindings
-     * @deprecated in Drake release: address info now stored in InterfaceService
-     */
-    @Deprecated
-    Set<PortAddresses> getAddressBindings();
-
-    /**
-     * Returns the address bindings for a particular connection point.
-     *
-     * @param connectPoint the connection point to return address information
-     *                     for
-     * @return address information for the connection point
-     * @deprecated in Drake release: address info now stored in InterfaceService
-     */
-    @Deprecated
-    Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint);
 }
index bf469db..7df3c81 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.intent;
 
 import java.util.Collections;
index 3c3c45c..caa5fbb 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.intent;
 
 import java.util.List;
index dffbabf..0c831fd 100644 (file)
@@ -25,7 +25,6 @@ import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 
 import static com.google.common.base.Preconditions.checkArgument;
@@ -159,12 +158,8 @@ public class PathIntent extends ConnectivityIntent {
      * @param links links to be validated
      */
     public static void validate(List<Link> links) {
-        checkArgument(Iterables.all(links, new Predicate<Link>() {
-            @Override
-            public boolean apply(Link link) {
-                return !link.src().elementId().equals(link.dst().elementId());
-            }
-        }), "element of src and dst in a link must be different: {}", links);
+        checkArgument(Iterables.all(links, link -> !link.src().elementId().equals(link.dst().elementId())),
+                "element of src and dst in a link must be different: {}", links);
 
         boolean adjacentSame = true;
         for (int i = 0; i < links.size() - 1; i++) {
index fc2eba7..5a034b4 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.newresource;
 
 import com.google.common.annotations.Beta;
index 68c0a83..3eab938 100644 (file)
@@ -34,7 +34,7 @@ public enum PacketPriority {
 
     private final int priorityValue;
 
-    private PacketPriority(int priorityValue) {
+    PacketPriority(int priorityValue) {
         this.priorityValue = priorityValue;
     }
 
@@ -50,4 +50,4 @@ public enum PacketPriority {
     public String toString() {
         return String.valueOf(priorityValue);
     }
-}
\ No newline at end of file
+}
index 9888677..0eba1b4 100644 (file)
@@ -22,9 +22,9 @@ import static com.google.common.base.Preconditions.checkArgument;
  */
 public interface PacketProcessor {
 
-    static final int ADVISOR_MAX = Integer.MAX_VALUE / 3;
-    static final int DIRECTOR_MAX = (Integer.MAX_VALUE / 3) * 2;
-    static final int OBSERVER_MAX = Integer.MAX_VALUE;
+    int ADVISOR_MAX = Integer.MAX_VALUE / 3;
+    int DIRECTOR_MAX = (Integer.MAX_VALUE / 3) * 2;
+    int OBSERVER_MAX = Integer.MAX_VALUE;
 
     /**
      * Returns a priority in the ADVISOR range, where processors can take early action and
@@ -38,7 +38,7 @@ public interface PacketProcessor {
     static int advisor(int priority) {
         int overallPriority = priority + 1;
         checkArgument(overallPriority > 0 && overallPriority <= ADVISOR_MAX,
-                "Priority not within ADVISOR range");
+                      "Priority not within ADVISOR range");
         return overallPriority;
     }
 
@@ -53,7 +53,7 @@ public interface PacketProcessor {
     static int director(int priority) {
         int overallPriority = ADVISOR_MAX + priority + 1;
         checkArgument(overallPriority > ADVISOR_MAX && overallPriority <= DIRECTOR_MAX,
-                "Priority not within DIRECTOR range");
+                      "Priority not within DIRECTOR range");
         return overallPriority;
     }
 
@@ -68,8 +68,8 @@ public interface PacketProcessor {
      */
     static int observer(int priority) {
         int overallPriority = DIRECTOR_MAX + priority + 1;
-        checkArgument(overallPriority > DIRECTOR_MAX && overallPriority <= OBSERVER_MAX,
-                "Priority not within OBSERVER range");
+        checkArgument(overallPriority > DIRECTOR_MAX,
+                      "Priority not within OBSERVER range");
         return overallPriority;
     }
 
index 06c416e..98f4d8e 100644 (file)
  */
 package org.onosproject.net.packet;
 
+import com.google.common.annotations.Beta;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.flow.TrafficSelector;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * Service for intercepting data plane packets and for emitting synthetic
  * outbound packets.
@@ -47,6 +51,15 @@ public interface PacketService {
      */
     void removeProcessor(PacketProcessor processor);
 
+    /**
+     * Returns priority bindings of all registered packet processors.
+     *
+     * @return list of existing packet processors
+     */
+    @Beta
+    // TODO: Consider returning list of PacketProcessorEntry with processor, priority and stats
+    Map<Integer, PacketProcessor> getProcessors();
+
     /**
      * Requests that packets matching the given selector are punted from the
      * dataplane to the controller.
@@ -69,6 +82,13 @@ public interface PacketService {
     void cancelPackets(TrafficSelector selector, PacketPriority priority,
                        ApplicationId appId);
 
+    /**
+     * Returns list of all existing requests ordered by priority.
+     *
+     * @return list of existing packet requests
+     */
+    List<PacketRequest> getRequests();
+
     /**
      * Emits the specified outbound packet onto the network.
      *
index ff45cc0..97f7cb5 100644 (file)
@@ -17,7 +17,7 @@ package org.onosproject.net.packet;
 
 import org.onosproject.store.Store;
 
-import java.util.Set;
+import java.util.List;
 
 /**
  * Manages routing of outbound packets.
@@ -52,8 +52,8 @@ public interface PacketStore extends Store<PacketEvent, PacketStoreDelegate> {
     /**
      * Obtains all existing requests in the system.
      *
-     * @return a set of packet requests
+     * @return list of packet requests in order of priority
      */
-    Set<PacketRequest> existingRequests();
+    List<PacketRequest> existingRequests();
 
 }
index 8ffe17a..9b27f4f 100644 (file)
@@ -21,7 +21,7 @@ import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.packet.PacketContext;
 
 /**
- * Service for processing arp requests on behalf of applications.
+ * Service for processing ARP or NDP requests on behalf of applications.
  */
 // TODO: move to the peer host package
 public interface ProxyArpService {
index 800135f..4b80dfc 100644 (file)
 package org.onosproject.security;
 
 
+import com.google.common.annotations.Beta;
+
 /**
  * Aids SM-ONOS to perform API-level permission checking.
  */
+@Beta
 public final class AppGuard {
 
     private AppGuard() {
index 21a70d2..09fe17a 100644 (file)
 
 package org.onosproject.security;
 
+import com.google.common.annotations.Beta;
+
 import java.security.BasicPermission;
 
 /**
  * Implementation of API access permission.
  */
+@Beta
 public class AppPermission extends BasicPermission {
 
     public enum Type {
index 16ea94d..30d143c 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.onosproject.security;
 
+import com.google.common.annotations.Beta;
 import org.onosproject.core.ApplicationId;
 
 import java.security.Permission;
@@ -25,6 +26,7 @@ import java.util.Map;
 /**
  * Security-Mode ONOS service.
  */
+@Beta
 public interface SecurityAdminService {
 
     /**
index 34b4e78..444b6bb 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.onosproject.security;
 
+import com.google.common.annotations.Beta;
 import org.onlab.osgi.DefaultServiceDirectory;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.ServiceNotFoundException;
@@ -24,6 +25,7 @@ import org.onosproject.core.ApplicationId;
 /**
  * Utility class to aid Security-Mode ONOS.
  */
+@Beta
 public final class SecurityUtil {
 
     protected static ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
index 8cac596..a62d382 100644 (file)
@@ -31,7 +31,7 @@ public final class DatabaseUpdate {
     /**
      * Type of database update operation.
      */
-    public static enum Type {
+    public enum Type {
         /**
          * Insert/Update entry without any checks.
          */
index 2889422..e0d7d23 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui;
index bd2f2fe..61bc0c2 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui;
index 84d1134..1c42c97 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table;
index 854ac27..895c9d9 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table;
index 6113fc3..31d9f63 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 33ce2ab..08822b7 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 42d684b..0e1c248 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index fee2615..4af6fe2 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 093a20d..2386f8f 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 0efa2eb..8309c54 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index e09982e..981a81b 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index fe87c61..95a7cc2 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 44dc194..58c7093 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index ab2ced3..d30ba2f 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index c37c129..a40383b 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 720eca4..cc2cf4a 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 8c95e15..1217faa 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 7bc0e65..9a42e10 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index ca2eccc..05b7317 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 2985d3d..0ce6592 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index be59c26..12d3b62 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 76669a8..4895949 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index b4e4330..a734c6b 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index d21a872..b11ddec 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 735f816..61e10c5 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index b284de1..4aed903 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 121e083..a165be3 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 38a8f03..0f42b62 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index dc32746..3994744 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index a94068e..8df0316 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index f92d579..b38a7f7 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index c171d52..1ab1729 100644 (file)
@@ -18,8 +18,6 @@ package org.onosproject.net;
 import com.google.common.testing.EqualsTester;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
-
 /**
  * Test for OchSignal.
  */
index 5bfdd76..7b43da6 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.device;
 
 import org.onosproject.net.DeviceId;
index 795e4c0..5f52f6d 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onosproject.net.device;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 
 import org.onosproject.net.Device;
@@ -45,13 +44,7 @@ public class DeviceServiceAdapter implements DeviceService {
     @Override
     public Iterable<Device> getAvailableDevices() {
         return FluentIterable.from(getDevices())
-                .filter(new Predicate<Device>() {
-
-                    @Override
-                    public boolean apply(Device input) {
-                        return isAvailable(input.id());
-                    }
-                });
+                .filter(input -> isAvailable(input.id()));
     }
 
     @Override
index 30326a2..7a61f82 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.flow;
 
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
index 226dad0..0fad54a 100644 (file)
  */
 package org.onosproject.net.host;
 
-import java.util.Set;
-
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Host;
 import org.onosproject.net.HostId;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
+
+import java.util.Set;
 
 /**
  * Test adapter for host service.
@@ -89,14 +89,4 @@ public class HostServiceAdapter implements HostService {
     public void removeListener(HostListener listener) {
     }
 
-    @Override
-    public Set<PortAddresses> getAddressBindings() {
-        return null;
-    }
-
-    @Override
-    public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) {
-        return null;
-    }
-
 }
index 9b9f7ce..a33d369 100644 (file)
@@ -49,30 +49,23 @@ public class FakeIntentManager implements TestableIntentService {
     // Provides an out-of-thread simulation of intent submit life-cycle
     private void executeSubmit(final Intent intent) {
         registerSubclassCompilerIfNeeded(intent);
-        executor.execute(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    executeCompilingPhase(intent);
-                } catch (IntentException e) {
-                    exceptions.add(e);
-                }
+        executor.execute(() -> {
+            try {
+                executeCompilingPhase(intent);
+            } catch (IntentException e) {
+                exceptions.add(e);
             }
         });
     }
 
     // Provides an out-of-thread simulation of intent withdraw life-cycle
     private void executeWithdraw(final Intent intent) {
-        executor.execute(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    List<Intent> installable = getInstallable(intent.key());
-                    executeWithdrawingPhase(intent, installable);
-                } catch (IntentException e) {
-                    exceptions.add(e);
-                }
-
+        executor.execute(() -> {
+            try {
+                List<Intent> installable = getInstallable(intent.key());
+                executeWithdrawingPhase(intent, installable);
+            } catch (IntentException e) {
+                exceptions.add(e);
             }
         });
     }
index 60857ca..0067fb2 100644 (file)
@@ -79,13 +79,8 @@ public class IntentServiceTest {
         service.submit(intent);
 
         // Allow a small window of time until the intent is in the expected state
-        TestTools.assertAfter(GRACE_MS, new Runnable() {
-            @Override
-            public void run() {
-                assertEquals("incorrect intent state", IntentState.INSTALLED,
-                             service.getIntentState(intent.key()));
-            }
-        });
+        TestTools.assertAfter(GRACE_MS, () ->
+                assertEquals("incorrect intent state", IntentState.INSTALLED, service.getIntentState(intent.key())));
 
         // Make sure that all expected events have been emitted
         validateEvents(intent, INSTALL_REQ, INSTALLED);
@@ -100,13 +95,8 @@ public class IntentServiceTest {
         service.withdraw(intent);
 
         // Allow a small window of time until the event is in the expected state
-        TestTools.assertAfter(GRACE_MS, new Runnable() {
-            @Override
-            public void run() {
-                assertEquals("incorrect intent state", IntentState.WITHDRAWN,
-                             service.getIntentState(intent.key()));
-            }
-        });
+        TestTools.assertAfter(GRACE_MS, () ->
+                assertEquals("incorrect intent state", IntentState.WITHDRAWN, service.getIntentState(intent.key())));
 
         // Make sure that all expected events have been emitted
         validateEvents(intent, WITHDRAWN);
@@ -128,13 +118,8 @@ public class IntentServiceTest {
         service.submit(intent);
 
         // Allow a small window of time until the intent is in the expected state
-        TestTools.assertAfter(GRACE_MS, new Runnable() {
-            @Override
-            public void run() {
-                assertEquals("incorrect intent state", IntentState.FAILED,
-                             service.getIntentState(intent.key()));
-            }
-        });
+        TestTools.assertAfter(GRACE_MS, () ->
+                assertEquals("incorrect intent state", IntentState.FAILED, service.getIntentState(intent.key())));
 
         // Make sure that all expected events have been emitted
         validateEvents(intent, INSTALL_REQ, FAILED);
@@ -196,13 +181,8 @@ public class IntentServiceTest {
         service.submit(intent);
 
         // Allow some time for the intent to be compiled and installed
-        TestTools.assertAfter(GRACE_MS, new Runnable() {
-            @Override
-            public void run() {
-                assertEquals("incorrect intent state", IntentState.INSTALLED,
-                             service.getIntentState(intent.key()));
-            }
-        });
+        TestTools.assertAfter(GRACE_MS, () ->
+                assertEquals("incorrect intent state", IntentState.INSTALLED, service.getIntentState(intent.key())));
 
         // Make sure that now we have an implicit registration of the compiler
         // under the intent subclass
index 5cb84b3..7cd87cd 100644 (file)
@@ -22,7 +22,6 @@ import org.onosproject.net.DeviceId;
 import org.onosproject.net.Link;
 import org.onosproject.net.Link.State;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 
 /**
@@ -42,13 +41,7 @@ public class LinkServiceAdapter implements LinkService {
     @Override
     public Iterable<Link> getActiveLinks() {
         return FluentIterable.from(getLinks())
-                .filter(new Predicate<Link>() {
-
-                    @Override
-                    public boolean apply(Link input) {
-                        return input.state() == State.ACTIVE;
-                    }
-                });
+                .filter(input -> input.state() == State.ACTIVE);
     }
 
     @Override
index afe936b..c438659 100644 (file)
@@ -18,6 +18,9 @@ package org.onosproject.net.packet;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.flow.TrafficSelector;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * Test adapter for packet service.
  */
@@ -30,6 +33,16 @@ public class PacketServiceAdapter implements PacketService {
     public void removeProcessor(PacketProcessor processor) {
     }
 
+    @Override
+    public Map<Integer, PacketProcessor> getProcessors() {
+        return null;
+    }
+
+    @Override
+    public List<PacketRequest> getRequests() {
+        return null;
+    }
+
     @Override
     public void requestPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) {
     }
index b498c1c..ad439d6 100644 (file)
@@ -16,7 +16,6 @@
 package org.onosproject.store.service;
 
 import com.google.common.testing.EqualsTester;
-import junit.framework.TestCase;
 import org.junit.Test;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -26,7 +25,7 @@ import static org.hamcrest.Matchers.is;
  * Unit Tests for DatabseUpdate class.
  */
 
-public class DatabaseUpdateTest extends TestCase {
+public class DatabaseUpdateTest {
 
     private final DatabaseUpdate stats1 = DatabaseUpdate.newBuilder()
             .withCurrentValue("1".getBytes())
@@ -124,4 +123,4 @@ public class DatabaseUpdateTest extends TestCase {
         assertThat(stats1.toString(), is(stats1.toString()));
     }
 
-}
\ No newline at end of file
+}
index c241c0e..47fba6c 100644 (file)
@@ -16,7 +16,6 @@
 package org.onosproject.store.service;
 
 import com.google.common.testing.EqualsTester;
-import junit.framework.TestCase;
 import org.junit.Test;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -25,7 +24,7 @@ import static org.hamcrest.Matchers.is;
 /**
  * MapEvent unit tests.
  */
-public class MapEventTest extends TestCase {
+public class MapEventTest {
 
     private final Versioned<Integer> vStats = new Versioned<>(2, 1);
 
@@ -58,4 +57,4 @@ public class MapEventTest extends TestCase {
                 .testEquals();
     }
 
-}
\ No newline at end of file
+}
index 5d991a2..43475e4 100644 (file)
@@ -16,7 +16,6 @@
 package org.onosproject.store.service;
 
 import com.google.common.testing.EqualsTester;
-import junit.framework.TestCase;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -31,7 +30,7 @@ import static org.hamcrest.Matchers.notNullValue;
 /**
  * MultiValuedTimestamp unit tests.
  */
-public class MultiValuedTimestampTest extends TestCase {
+public class MultiValuedTimestampTest {
 
     private final MultiValuedTimestamp<Integer, Integer> stats1 = new MultiValuedTimestamp<>(1, 3);
 
@@ -91,4 +90,4 @@ public class MultiValuedTimestampTest extends TestCase {
             Assert.fail("Exception looking up constructors");
         }
     }
-}
\ No newline at end of file
+}
index 8a401db..fbe3271 100644 (file)
@@ -16,7 +16,6 @@
 package org.onosproject.store.service;
 
 import com.google.common.testing.EqualsTester;
-import junit.framework.TestCase;
 import org.junit.Test;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -25,7 +24,7 @@ import static org.hamcrest.Matchers.is;
 /**
  * Versioned unit tests.
  */
-public class VersionedTest extends TestCase {
+public class VersionedTest {
 
     private final Versioned<Integer> stats1 = new Versioned<>(1, 2, 3);
 
index 7c2f2d7..4456dd3 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table;
index 0b9af23..30125af 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 7a3c34b..41fefd6 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index e74fb47..a7befbd 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 65fd784..f7ad275 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 87c9528..d77c1b2 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 6351a1f..b63793b 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index ad23b02..2f70d43 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index bfbe454..25ec89c 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index f41d82b..1e05ded 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.table.cell;
index 17fcc22..83f4809 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 1acc06f..55f31ac 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index b5bd41e..a6beec8 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 04c6dc1..01a1b97 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 7d6dfe6..fe663a5 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 205f08c..a88de33 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index bb40279..03a18f9 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 60cada4..06a7858 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index b08ee4d..7e6cc22 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 6a3bfa4..ac0051c 100644 (file)
@@ -12,7 +12,6 @@
  * 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.ui.topo;
index 71c0fe4..e4d25ee 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-core</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 6a9b670..c3b6d82 100644 (file)
@@ -30,7 +30,7 @@ public class MockCodecContext implements CodecContext {
 
     private final ObjectMapper mapper = new ObjectMapper();
     private final CodecManager manager = new CodecManager();
-    private final Map<Class<? extends Object>, Object> services = new HashMap<>();
+    private final Map<Class<?>, Object> services = new HashMap<>();
 
     /**
      * Constructs a new mock codec context.
index fc90dfa..72fc1b0 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onosproject.store.trivial;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Maps;
@@ -134,13 +133,7 @@ public class SimpleDeviceStore
     @Override
     public Iterable<Device> getAvailableDevices() {
         return FluentIterable.from(getDevices())
-                .filter(new Predicate<Device>() {
-
-                    @Override
-                    public boolean apply(Device input) {
-                        return isAvailable(input.id());
-                    }
-                });
+                .filter(input -> isAvailable(input.id()));
     }
 
     @Override
index 562e6f3..c9e135d 100644 (file)
@@ -479,31 +479,22 @@ public class SimpleDeviceStoreTest {
     @Test
     public final void testEvents() throws InterruptedException {
         final CountDownLatch addLatch = new CountDownLatch(1);
-        DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() {
-            @Override
-            public void notify(DeviceEvent event) {
-                assertEquals(DEVICE_ADDED, event.type());
-                assertDevice(DID1, SW1, event.subject());
-                addLatch.countDown();
-            }
+        DeviceStoreDelegate checkAdd = event -> {
+            assertEquals(DEVICE_ADDED, event.type());
+            assertDevice(DID1, SW1, event.subject());
+            addLatch.countDown();
         };
         final CountDownLatch updateLatch = new CountDownLatch(1);
-        DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() {
-            @Override
-            public void notify(DeviceEvent event) {
-                assertEquals(DEVICE_UPDATED, event.type());
-                assertDevice(DID1, SW2, event.subject());
-                updateLatch.countDown();
-            }
+        DeviceStoreDelegate checkUpdate = event -> {
+            assertEquals(DEVICE_UPDATED, event.type());
+            assertDevice(DID1, SW2, event.subject());
+            updateLatch.countDown();
         };
         final CountDownLatch removeLatch = new CountDownLatch(1);
-        DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() {
-            @Override
-            public void notify(DeviceEvent event) {
-                assertEquals(DEVICE_REMOVED, event.type());
-                assertDevice(DID1, SW2, event.subject());
-                removeLatch.countDown();
-            }
+        DeviceStoreDelegate checkRemove = event -> {
+            assertEquals(DEVICE_REMOVED, event.type());
+            assertDevice(DID1, SW2, event.subject());
+            removeLatch.countDown();
         };
 
         DeviceDescription description =
index 3b8f1d3..c8c92aa 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onosproject.store.trivial;
 
-import com.google.common.base.Function;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.RemovalListener;
@@ -162,15 +161,7 @@ public class SimpleFlowRuleStore
     public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) {
         // flatten and make iterator unmodifiable
         return FluentIterable.from(getFlowTable(deviceId).values())
-                .transformAndConcat(
-                        new Function<List<StoredFlowEntry>, Iterable<? extends FlowEntry>>() {
-
-                            @Override
-                            public Iterable<? extends FlowEntry> apply(
-                                    List<StoredFlowEntry> input) {
-                                return Collections.unmodifiableList(input);
-                            }
-                        });
+                .transformAndConcat(Collections::unmodifiableList);
     }
 
     @Override
index 71de3e1..230fa33 100644 (file)
@@ -55,7 +55,6 @@ import org.onosproject.net.group.StoredGroupEntry;
 import org.onosproject.store.AbstractStore;
 import org.slf4j.Logger;
 
-import com.google.common.base.Function;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.Sets;
 
@@ -83,8 +82,7 @@ public class SimpleGroupStore
     private final ConcurrentMap<DeviceId, ConcurrentMap<GroupId, Group>>
         extraneousGroupEntriesById = new ConcurrentHashMap<>();
 
-    private final HashMap<DeviceId, Boolean> deviceAuditStatus =
-            new HashMap<DeviceId, Boolean>();
+    private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>();
 
     private final AtomicInteger groupIdGen = new AtomicInteger();
 
@@ -189,15 +187,7 @@ public class SimpleGroupStore
     public Iterable<Group> getGroups(DeviceId deviceId) {
         // flatten and make iterator unmodifiable
         return FluentIterable.from(getGroupKeyTable(deviceId).values())
-            .transform(
-                    new Function<StoredGroupEntry, Group>() {
-
-                        @Override
-                        public Group apply(
-                                StoredGroupEntry input) {
-                            return input;
-                        }
-                    });
+            .transform(input -> input);
     }
 
     /**
@@ -358,8 +348,7 @@ public class SimpleGroupStore
                                    UpdateType type,
                                    GroupBuckets buckets) {
         GroupBuckets oldBuckets = oldGroup.buckets();
-        List<GroupBucket> newBucketList = new ArrayList<GroupBucket>(
-                oldBuckets.buckets());
+        List<GroupBucket> newBucketList = new ArrayList<>(oldBuckets.buckets());
         boolean groupDescUpdated = false;
 
         if (type == UpdateType.ADD) {
index dd6c8a5..b10fca5 100644 (file)
@@ -205,10 +205,10 @@ public class SimpleGroupStoreTest {
     private void testStoreAndGetGroup(GroupKey key) {
         PortNumber[] ports = {PortNumber.portNumber(31),
                               PortNumber.portNumber(32)};
-        List<PortNumber> outPorts = new ArrayList<PortNumber>();
+        List<PortNumber> outPorts = new ArrayList<>();
         outPorts.addAll(Arrays.asList(ports));
 
-        List<GroupBucket> buckets = new ArrayList<GroupBucket>();
+        List<GroupBucket> buckets = new ArrayList<>();
         for (PortNumber portNumber: outPorts) {
             TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
             tBuilder.setOutput(portNumber)
@@ -271,7 +271,7 @@ public class SimpleGroupStoreTest {
         Group existingGroup = simpleGroupStore.getGroup(D1, currKey);
         int totalPkts = 0;
         int totalBytes = 0;
-        List<GroupBucket> newBucketList = new ArrayList<GroupBucket>();
+        List<GroupBucket> newBucketList = new ArrayList<>();
         for (GroupBucket bucket:existingGroup.buckets().buckets()) {
             StoredGroupBucketEntry newBucket =
                     (StoredGroupBucketEntry)
@@ -302,15 +302,15 @@ public class SimpleGroupStoreTest {
     // Testing updateGroupDescription for ADD operation from northbound
     private void testAddBuckets(GroupKey currKey, GroupKey addKey) {
         Group existingGroup = simpleGroupStore.getGroup(D1, currKey);
-        List<GroupBucket> buckets = new ArrayList<GroupBucket>();
+        List<GroupBucket> buckets = new ArrayList<>();
         buckets.addAll(existingGroup.buckets().buckets());
 
         PortNumber[] newNeighborPorts = {PortNumber.portNumber(41),
                                          PortNumber.portNumber(42)};
-        List<PortNumber> newOutPorts = new ArrayList<PortNumber>();
+        List<PortNumber> newOutPorts = new ArrayList<>();
         newOutPorts.addAll(Collections.singletonList(newNeighborPorts[0]));
 
-        List<GroupBucket> toAddBuckets = new ArrayList<GroupBucket>();
+        List<GroupBucket> toAddBuckets = new ArrayList<>();
         for (PortNumber portNumber: newOutPorts) {
             TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
             tBuilder.setOutput(portNumber)
@@ -340,10 +340,10 @@ public class SimpleGroupStoreTest {
     // Testing updateGroupDescription for REMOVE operation from northbound
     private void testRemoveBuckets(GroupKey currKey, GroupKey removeKey) {
         Group existingGroup = simpleGroupStore.getGroup(D1, currKey);
-        List<GroupBucket> buckets = new ArrayList<GroupBucket>();
+        List<GroupBucket> buckets = new ArrayList<>();
         buckets.addAll(existingGroup.buckets().buckets());
 
-        List<GroupBucket> toRemoveBuckets = new ArrayList<GroupBucket>();
+        List<GroupBucket> toRemoveBuckets = new ArrayList<>();
 
         // There should be 4 buckets in the current group
         toRemoveBuckets.add(buckets.remove(0));
@@ -405,11 +405,11 @@ public class SimpleGroupStoreTest {
         GroupKey key = new DefaultGroupKey("group1".getBytes());
         PortNumber[] ports = {PortNumber.portNumber(31),
                 PortNumber.portNumber(32)};
-        List<PortNumber> outPorts = new ArrayList<PortNumber>();
+        List<PortNumber> outPorts = new ArrayList<>();
         outPorts.add(ports[0]);
         outPorts.add(ports[1]);
 
-        List<GroupBucket> buckets = new ArrayList<GroupBucket>();
+        List<GroupBucket> buckets = new ArrayList<>();
         for (PortNumber portNumber: outPorts) {
             TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
             tBuilder.setOutput(portNumber)
index f5604f6..264d049 100644 (file)
  */
 package org.onosproject.store.trivial;
 
-import static org.onosproject.net.DefaultAnnotations.merge;
-import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
-import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED;
-import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
-import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
 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.Service;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
 import org.onosproject.net.Annotations;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DefaultAnnotations;
@@ -44,19 +37,21 @@ import org.onosproject.net.host.HostDescription;
 import org.onosproject.net.host.HostEvent;
 import org.onosproject.net.host.HostStore;
 import org.onosproject.net.host.HostStoreDelegate;
-import org.onosproject.net.host.PortAddresses;
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.store.AbstractStore;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
 import org.slf4j.Logger;
 
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
-import com.google.common.collect.SetMultimap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.onosproject.net.DefaultAnnotations.merge;
+import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED;
+import static org.slf4j.LoggerFactory.getLogger;
 
 // TODO: multi-provider, annotation not supported.
 /**
@@ -77,10 +72,6 @@ public class SimpleHostStore
     // Hosts tracked by their location
     private final Multimap<ConnectPoint, Host> locations = HashMultimap.create();
 
-    private final SetMultimap<ConnectPoint, PortAddresses> portAddresses =
-            Multimaps.synchronizedSetMultimap(
-                    HashMultimap.<ConnectPoint, PortAddresses>create());
-
     @Activate
     public void activate() {
         log.info("Started");
@@ -93,12 +84,14 @@ public class SimpleHostStore
 
     @Override
     public HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId,
-                                        HostDescription hostDescription) {
+                                        HostDescription hostDescription,
+                                        boolean replaceIps) {
+        //TODO We need a way to detect conflicting changes and abort update.
         StoredHost host = hosts.get(hostId);
         if (host == null) {
             return createHost(providerId, hostId, hostDescription);
         }
-        return updateHost(providerId, host, hostDescription);
+        return updateHost(providerId, host, hostDescription, replaceIps);
     }
 
     // creates a new host and sends HOST_ADDED
@@ -119,7 +112,7 @@ public class SimpleHostStore
 
     // checks for type of update to host, sends appropriate event
     private HostEvent updateHost(ProviderId providerId, StoredHost host,
-                                 HostDescription descr) {
+                                 HostDescription descr, boolean replaceIps) {
         HostEvent event;
         if (!host.location().equals(descr.location())) {
             host.setLocation(descr.location());
@@ -131,8 +124,14 @@ public class SimpleHostStore
             return null;
         }
 
-        Set<IpAddress> addresses = new HashSet<>(host.ipAddresses());
-        addresses.addAll(descr.ipAddress());
+        final Set<IpAddress> addresses;
+        if (replaceIps) {
+            addresses = ImmutableSet.copyOf(descr.ipAddress());
+        } else {
+            addresses = new HashSet<>(host.ipAddresses());
+            addresses.addAll(descr.ipAddress());
+        }
+
         Annotations annotations = merge((DefaultAnnotations) host.annotations(),
                                         descr.annotations());
         StoredHost updated = new StoredHost(providerId, host.id(),
@@ -224,41 +223,6 @@ public class SimpleHostStore
         return hostset;
     }
 
-    @Override
-    public void updateAddressBindings(PortAddresses addresses) {
-        portAddresses.put(addresses.connectPoint(), addresses);
-    }
-
-    @Override
-    public void removeAddressBindings(PortAddresses addresses) {
-        portAddresses.remove(addresses.connectPoint(), addresses);
-    }
-
-    @Override
-    public void clearAddressBindings(ConnectPoint connectPoint) {
-        portAddresses.removeAll(connectPoint);
-    }
-
-    @Override
-    public Set<PortAddresses> getAddressBindings() {
-        synchronized (portAddresses) {
-            return ImmutableSet.copyOf(portAddresses.values());
-        }
-    }
-
-    @Override
-    public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) {
-        synchronized (portAddresses) {
-            Set<PortAddresses> addresses = portAddresses.get(connectPoint);
-
-            if (addresses == null) {
-                return Collections.emptySet();
-            } else {
-                return ImmutableSet.copyOf(addresses);
-            }
-        }
-    }
-
     // Auxiliary extension to allow location to mutate.
     private static final class StoredHost extends DefaultHost {
         private HostLocation location;
index d0be2b1..92b882a 100644 (file)
@@ -44,7 +44,6 @@ import org.onosproject.net.provider.ProviderId;
 import org.onosproject.store.AbstractStore;
 import org.slf4j.Logger;
 
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -280,7 +279,7 @@ public class SimpleLinkStore
      */
     private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() {
         return synchronizedSetMultimap(
-               Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(),
+               Multimaps.newSetMultimap(new ConcurrentHashMap<>(),
                                        () -> Sets.newConcurrentHashSet()));
     }
 
index 2d2b275..40649aa 100644 (file)
@@ -498,31 +498,22 @@ public class SimpleLinkStoreTest {
         final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
 
         final CountDownLatch addLatch = new CountDownLatch(1);
-        LinkStoreDelegate checkAdd = new LinkStoreDelegate() {
-            @Override
-            public void notify(LinkEvent event) {
-                assertEquals(LINK_ADDED, event.type());
-                assertLink(linkId1, INDIRECT, event.subject());
-                addLatch.countDown();
-            }
+        LinkStoreDelegate checkAdd = event -> {
+            assertEquals(LINK_ADDED, event.type());
+            assertLink(linkId1, INDIRECT, event.subject());
+            addLatch.countDown();
         };
         final CountDownLatch updateLatch = new CountDownLatch(1);
-        LinkStoreDelegate checkUpdate = new LinkStoreDelegate() {
-            @Override
-            public void notify(LinkEvent event) {
-                assertEquals(LINK_UPDATED, event.type());
-                assertLink(linkId1, DIRECT, event.subject());
-                updateLatch.countDown();
-            }
+        LinkStoreDelegate checkUpdate = event -> {
+            assertEquals(LINK_UPDATED, event.type());
+            assertLink(linkId1, DIRECT, event.subject());
+            updateLatch.countDown();
         };
         final CountDownLatch removeLatch = new CountDownLatch(1);
-        LinkStoreDelegate checkRemove = new LinkStoreDelegate() {
-            @Override
-            public void notify(LinkEvent event) {
-                assertEquals(LINK_REMOVED, event.type());
-                assertLink(linkId1, DIRECT, event.subject());
-                removeLatch.countDown();
-            }
+        LinkStoreDelegate checkRemove = event -> {
+            assertEquals(LINK_REMOVED, event.type());
+            assertLink(linkId1, DIRECT, event.subject());
+            removeLatch.countDown();
         };
 
         linkStore.setDelegate(checkAdd);
index ef92ded..61db2e6 100644 (file)
@@ -375,14 +375,10 @@ public class SimpleMastershipStore
             .filter(entry -> entry.getValue().contains(nodeId))
             .forEach(entry -> toRelinquish.add(entry.getKey()));
 
-        toRelinquish.forEach(deviceId -> {
-            eventFutures.add(relinquishRole(nodeId, deviceId));
-        });
+        toRelinquish.forEach(deviceId -> eventFutures.add(relinquishRole(nodeId, deviceId)));
 
         eventFutures.forEach(future -> {
-            future.whenComplete((event, error) -> {
-                notifyDelegate(event);
-            });
+            future.whenComplete((event, error) -> notifyDelegate(event));
         });
     }
 }
index 4345aba..f835926 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.onosproject.store.trivial;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Sets;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
@@ -26,8 +27,7 @@ import org.onosproject.net.packet.PacketStore;
 import org.onosproject.net.packet.PacketStoreDelegate;
 import org.onosproject.store.AbstractStore;
 
-
-import java.util.Collections;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -57,8 +57,8 @@ public class SimplePacketStore
     }
 
     @Override
-    public Set<PacketRequest> existingRequests() {
-        return Collections.unmodifiableSet(requests);
+    public List<PacketRequest> existingRequests() {
+        return ImmutableList.copyOf(requests);
     }
 
 }
index 4ba04c5..9ea0007 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-core</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 0761229..8a441f6 100644 (file)
@@ -59,7 +59,7 @@ public class CoreManager implements CoreService {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     private static final File VERSION_FILE = new File("../VERSION");
-    private static Version version = Version.version("1.3.0-SNAPSHOT");
+    private static Version version = Version.version("1.4.0-SNAPSHOT");
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected ApplicationIdStore applicationIdStore;
index fd86732..fa5f248 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
+
 /**
  * Core subsystem for interacting with network edges.
  */
index 9926338..43f346b 100644 (file)
@@ -25,6 +25,7 @@ import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.VlanId;
 import org.onosproject.incubator.net.intf.InterfaceService;
+import org.onosproject.net.edge.EdgePortService;
 import org.onosproject.net.provider.AbstractListenerProviderRegistry;
 import org.onosproject.net.config.NetworkConfigEvent;
 import org.onosproject.net.config.NetworkConfigListener;
@@ -45,7 +46,6 @@ import org.onosproject.net.host.HostProviderService;
 import org.onosproject.net.host.HostService;
 import org.onosproject.net.host.HostStore;
 import org.onosproject.net.host.HostStoreDelegate;
-import org.onosproject.net.host.PortAddresses;
 import org.onosproject.net.packet.PacketService;
 import org.onosproject.net.provider.AbstractProviderService;
 import org.slf4j.Logger;
@@ -90,6 +90,9 @@ public class HostManager
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected InterfaceService interfaceService;
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected EdgePortService edgePortService;
+
     private HostMonitor monitor;
 
     @Activate
@@ -97,7 +100,7 @@ public class HostManager
         store.setDelegate(delegate);
         eventDispatcher.addSink(HostEvent.class, listenerRegistry);
         networkConfigService.addListener(networkConfigListener);
-        monitor = new HostMonitor(packetService, this, interfaceService);
+        monitor = new HostMonitor(packetService, this, interfaceService, edgePortService);
         monitor.start();
         log.info("Started");
     }
@@ -195,33 +198,6 @@ public class HostManager
         }
     }
 
-    @Override
-    public void bindAddressesToPort(PortAddresses addresses) {
-        store.updateAddressBindings(addresses);
-    }
-
-    @Override
-    public void unbindAddressesFromPort(PortAddresses portAddresses) {
-        store.removeAddressBindings(portAddresses);
-    }
-
-    @Override
-    public void clearAddresses(ConnectPoint connectPoint) {
-        store.clearAddressBindings(connectPoint);
-    }
-
-    @Override
-    public Set<PortAddresses> getAddressBindings() {
-        checkPermission(HOST_READ);
-        return store.getAddressBindings();
-    }
-
-    @Override
-    public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) {
-        checkPermission(HOST_READ);
-        return store.getAddressBindingsForPort(connectPoint);
-    }
-
     // Personalized host provider service issued to the supplied provider.
     private class InternalHostProviderService
             extends AbstractProviderService<HostProvider>
@@ -231,12 +207,12 @@ public class HostManager
         }
 
         @Override
-        public void hostDetected(HostId hostId, HostDescription hostDescription) {
+        public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) {
             checkNotNull(hostId, HOST_ID_NULL);
             checkValidity();
             hostDescription = validateHost(hostDescription, hostId);
             HostEvent event = store.createOrUpdateHost(provider().id(), hostId,
-                                                       hostDescription);
+                                                       hostDescription, replaceIps);
             if (event != null) {
                 post(event);
             }
index fe25236..44f8cbf 100644 (file)
@@ -31,21 +31,20 @@ import org.onosproject.incubator.net.intf.Interface;
 import org.onosproject.incubator.net.intf.InterfaceService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.Host;
+import org.onosproject.net.edge.EdgePortService;
 import org.onosproject.net.flow.DefaultTrafficTreatment;
 import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.Instruction;
-import org.onosproject.net.flow.instructions.Instructions;
 import org.onosproject.net.host.HostProvider;
 import org.onosproject.net.host.InterfaceIpAddress;
 import org.onosproject.net.packet.DefaultOutboundPacket;
 import org.onosproject.net.packet.OutboundPacket;
 import org.onosproject.net.packet.PacketService;
 import org.onosproject.net.provider.ProviderId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -60,9 +59,13 @@ import java.util.concurrent.TimeUnit;
  * </p>
  */
 public class HostMonitor implements TimerTask {
+
+    private Logger log = LoggerFactory.getLogger(getClass());
+
     private PacketService packetService;
     private HostManager hostManager;
     private InterfaceService interfaceService;
+    private EdgePortService edgePortService;
 
     private final Set<IpAddress> monitoredAddresses;
 
@@ -83,11 +86,13 @@ public class HostMonitor implements TimerTask {
      * @param interfaceService interface service for interface information
      */
     public HostMonitor(PacketService packetService, HostManager hostManager,
-                       InterfaceService interfaceService) {
+                       InterfaceService interfaceService,
+                       EdgePortService edgePortService) {
 
         this.packetService = packetService;
         this.hostManager = hostManager;
         this.interfaceService = interfaceService;
+        this.edgePortService = edgePortService;
 
         monitoredAddresses = Collections.newSetFromMap(new ConcurrentHashMap<>());
         hostProviders = new ConcurrentHashMap<>();
@@ -149,7 +154,7 @@ public class HostMonitor implements TimerTask {
             Set<Host> hosts = hostManager.getHostsByIp(ip);
 
             if (hosts.isEmpty()) {
-                sendArpNdpRequest(ip);
+                sendRequest(ip);
             } else {
                 for (Host host : hosts) {
                     HostProvider provider = hostProviders.get(host.providerId());
@@ -166,45 +171,44 @@ public class HostMonitor implements TimerTask {
     }
 
     /**
-     * Sends an ARP or Neighbor Discovery Protocol request for the given IP
-     * address.
+     * Sends an ARP or NDP request for the given IP address.
      *
      * @param targetIp IP address to send the request for
      */
-    private void sendArpNdpRequest(IpAddress targetIp) {
+    private void sendRequest(IpAddress targetIp) {
         Interface intf = interfaceService.getMatchingInterface(targetIp);
 
         if (intf == null) {
             return;
         }
 
+        if (!edgePortService.isEdgePoint(intf.connectPoint())) {
+            log.warn("Attempt to send probe out non-edge port: {}", intf);
+            return;
+        }
+
         for (InterfaceIpAddress ia : intf.ipAddresses()) {
             if (ia.subnetAddress().contains(targetIp)) {
-                sendArpNdpProbe(intf.connectPoint(), targetIp, ia.ipAddress(),
+                sendProbe(intf.connectPoint(), targetIp, ia.ipAddress(),
                         intf.mac(), intf.vlan());
             }
         }
     }
 
-    private void sendArpNdpProbe(ConnectPoint connectPoint,
-                                 IpAddress targetIp,
-                                 IpAddress sourceIp, MacAddress sourceMac,
-                                 VlanId vlan) {
+    private void sendProbe(ConnectPoint connectPoint,
+                           IpAddress targetIp,
+                           IpAddress sourceIp, MacAddress sourceMac,
+                           VlanId vlan) {
         Ethernet probePacket = null;
 
         if (targetIp.isIp4()) {
             // IPv4: Use ARP
-            probePacket = buildArpRequest(targetIp, sourceIp, sourceMac,
-                                          vlan);
+            probePacket = buildArpRequest(targetIp, sourceIp, sourceMac, vlan);
         } else {
             // IPv6: Use Neighbor Discovery
-            probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac,
-                                          vlan);
+            probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac, vlan);
         }
 
-        List<Instruction> instructions = new ArrayList<>();
-        instructions.add(Instructions.createOutput(connectPoint.port()));
-
         TrafficTreatment treatment = DefaultTrafficTreatment.builder()
             .setOutput(connectPoint.port())
             .build();
@@ -273,7 +277,7 @@ public class HostMonitor implements TimerTask {
         icmp6.setIcmpType(ICMP6.NEIGHBOR_SOLICITATION);
         icmp6.setIcmpCode((byte) 0);
 
-        // Create the Neighbor Solication packet
+        // Create the Neighbor Solicitation packet
         NeighborSolicitation ns = new NeighborSolicitation();
         ns.setTargetAddress(targetIp.toOctets());
         ns.addOption(NeighborDiscoveryOptions.TYPE_SOURCE_LL_ADDRESS,
index 609f9a3..52621e2 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.intent.impl.compiler;
 
 import static java.util.Arrays.asList;
index c60325a..05a20f9 100644 (file)
@@ -51,7 +51,6 @@ import org.onosproject.net.resource.link.LinkResourceRequest;
 import org.onosproject.net.resource.link.LinkResourceService;
 import org.onosproject.net.topology.LinkWeight;
 import org.onosproject.net.topology.Topology;
-import org.onosproject.net.topology.TopologyEdge;
 import org.onosproject.net.topology.TopologyService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -265,34 +264,31 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
     private Set<Path> getOpticalPaths(OpticalConnectivityIntent intent) {
         // Route in WDM topology
         Topology topology = topologyService.currentTopology();
-        LinkWeight weight = new LinkWeight() {
-            @Override
-            public double weight(TopologyEdge edge) {
-                // Disregard inactive or non-optical links
-                if (edge.link().state() == Link.State.INACTIVE) {
-                    return -1;
-                }
-                if (edge.link().type() != Link.Type.OPTICAL) {
-                    return -1;
-                }
-                // Adhere to static port mappings
-                DeviceId srcDeviceId = edge.link().src().deviceId();
-                if (srcDeviceId.equals(intent.getSrc().deviceId())) {
-                    ConnectPoint srcStaticPort = staticPort(intent.getSrc());
-                    if (srcStaticPort != null) {
-                        return srcStaticPort.equals(edge.link().src()) ? 1 : -1;
-                    }
+        LinkWeight weight = edge -> {
+            // Disregard inactive or non-optical links
+            if (edge.link().state() == Link.State.INACTIVE) {
+                return -1;
+            }
+            if (edge.link().type() != Link.Type.OPTICAL) {
+                return -1;
+            }
+            // Adhere to static port mappings
+            DeviceId srcDeviceId = edge.link().src().deviceId();
+            if (srcDeviceId.equals(intent.getSrc().deviceId())) {
+                ConnectPoint srcStaticPort = staticPort(intent.getSrc());
+                if (srcStaticPort != null) {
+                    return srcStaticPort.equals(edge.link().src()) ? 1 : -1;
                 }
-                DeviceId dstDeviceId = edge.link().dst().deviceId();
-                if (dstDeviceId.equals(intent.getDst().deviceId())) {
-                    ConnectPoint dstStaticPort = staticPort(intent.getDst());
-                    if (dstStaticPort != null) {
-                        return dstStaticPort.equals(edge.link().dst()) ? 1 : -1;
-                    }
+            }
+            DeviceId dstDeviceId = edge.link().dst().deviceId();
+            if (dstDeviceId.equals(intent.getDst().deviceId())) {
+                ConnectPoint dstStaticPort = staticPort(intent.getDst());
+                if (dstStaticPort != null) {
+                    return dstStaticPort.equals(edge.link().dst()) ? 1 : -1;
                 }
-
-                return 1;
             }
+
+            return 1;
         };
 
         ConnectPoint start = intent.getSrc();
index a6b08f6..801092f 100644 (file)
 package org.onosproject.net.link.impl;
 
 import static org.slf4j.LoggerFactory.getLogger;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.time.Duration;
 
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.config.ConfigOperator;
 import org.onosproject.net.config.basics.BasicLinkConfig;
+import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DefaultAnnotations;
 import org.onosproject.net.Link;
 import org.onosproject.net.SparseAnnotations;
@@ -81,6 +83,46 @@ public final class BasicLinkOperator implements ConfigOperator {
         if (cfg.bandwidth() != DEF_BANDWIDTH) {
             b.set(AnnotationKeys.BANDWIDTH, String.valueOf(cfg.bandwidth()));
         }
+        if (cfg.isDurable() != null) {
+            b.set(AnnotationKeys.DURABLE, String.valueOf(cfg.isDurable()));
+        }
         return DefaultAnnotations.union(an, b.build());
     }
+
+    /**
+     * Generates a link description from a link description entity. The endpoints
+     * must be specified to indicate directionality.
+     *
+     * @param src the source ConnectPoint
+     * @param dst the destination ConnectPoint
+     * @param link the link config entity
+     * @return a linkDescription based on the config
+     */
+    public static LinkDescription descriptionOf(
+                ConnectPoint src, ConnectPoint dst, Link link) {
+        checkNotNull(src, "Must supply a source endpoint");
+        checkNotNull(dst, "Must supply a destination endpoint");
+        checkNotNull(link, "Must supply a link");
+        return new DefaultLinkDescription(
+                src, dst, link.type(), (SparseAnnotations) link.annotations());
+    }
+
+    /**
+     * Generates a link description from a link config entity. This is for
+     * links that cannot be discovered and has to be injected. The endpoints
+     * must be specified to indicate directionality.
+     *
+     * @param src the source ConnectPoint
+     * @param dst the destination ConnectPoint
+     * @param link the link config entity
+     * @return a linkDescription based on the config
+     */
+    public static LinkDescription descriptionOf(
+                ConnectPoint src, ConnectPoint dst, BasicLinkConfig link) {
+        checkNotNull(src, "Must supply a source endpoint");
+        checkNotNull(dst, "Must supply a destination endpoint");
+        checkNotNull(link, "Must supply a link config");
+        return new DefaultLinkDescription(
+                src, dst, link.type(), combine(link, DefaultAnnotations.EMPTY));
+    }
 }
index 157288a..d6f72fd 100644 (file)
@@ -15,9 +15,9 @@
  */
 package org.onosproject.net.link.impl;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.Sets;
+
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -25,6 +25,7 @@ import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.Service;
 import org.onosproject.net.provider.AbstractListenerProviderRegistry;
+import org.onosproject.net.provider.ProviderId;
 import org.onosproject.net.config.NetworkConfigEvent;
 import org.onosproject.net.config.NetworkConfigListener;
 import org.onosproject.net.config.NetworkConfigService;
@@ -54,7 +55,6 @@ import org.slf4j.Logger;
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
 import static org.onosproject.net.LinkKey.linkKey;
 import static org.onosproject.security.AppGuard.checkPermission;
 import static org.slf4j.LoggerFactory.getLogger;
@@ -125,13 +125,7 @@ public class LinkManager
     public Iterable<Link> getActiveLinks() {
         checkPermission(LINK_READ);
         return FluentIterable.from(getLinks())
-                .filter(new Predicate<Link>() {
-
-                    @Override
-                    public boolean apply(Link input) {
-                        return input.state() == State.ACTIVE;
-                    }
-                });
+                .filter(input -> input.state() == State.ACTIVE);
     }
 
     @Override
@@ -207,6 +201,10 @@ public class LinkManager
         post(store.removeLink(src, dst));
     }
 
+    private boolean isAllowed(BasicLinkConfig cfg) {
+        return (cfg == null || cfg.isAllowed());
+    }
+
     // Auxiliary interceptor for device remove events to prune links that
     // are associated with the removed device or its port.
     private class InternalDeviceListener implements DeviceListener {
@@ -240,11 +238,12 @@ public class LinkManager
             checkNotNull(linkDescription, LINK_DESC_NULL);
             checkValidity();
             linkDescription = validateLink(linkDescription);
-            LinkEvent event = store.createOrUpdateLink(provider().id(),
-                    linkDescription);
-            if (event != null) {
-                log.info("Link {} detected", linkDescription);
-                post(event);
+            if (linkDescription != null) {
+                LinkEvent event = store.createOrUpdateLink(provider().id(), linkDescription);
+                if (event != null) {
+                    log.info("Link {} detected", linkDescription);
+                    post(event);
+                }
             }
         }
 
@@ -258,11 +257,12 @@ public class LinkManager
             BasicLinkConfig cfgTwo = networkConfigService.getConfig(linkKey(linkDescription.dst(),
                                                                             linkDescription.src()),
                                                                     BasicLinkConfig.class);
-
-            checkState(cfg == null || cfg.isAllowed(), "Link " + linkDescription.toString() + " is not allowed");
-            checkState(cfgTwo == null || cfgTwo.isAllowed(), "Link " + linkDescription.toString() + " is not allowed");
-
-            return BasicLinkOperator.combine(cfg, linkDescription);
+            if (isAllowed(cfg) && isAllowed(cfgTwo)) {
+                return BasicLinkOperator.combine(cfg, linkDescription);
+            } else {
+                log.trace("Link " + linkDescription.toString() + " is not allowed");
+                return null;
+            }
         }
 
         @Override
@@ -324,20 +324,41 @@ public class LinkManager
     // listens for NetworkConfigEvents of type BasicLinkConfig and removes
     // links that the config does not allow
     private class InternalNetworkConfigListener implements NetworkConfigListener {
+
+        @Override
+        public boolean isRelevant(NetworkConfigEvent event) {
+            return event.configClass().equals(BasicLinkConfig.class)
+                    && (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED
+                        || event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED);
+        }
+
         @Override
         public void event(NetworkConfigEvent event) {
-            if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
-                    event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) &&
-                    event.configClass().equals(BasicLinkConfig.class)) {
-                log.info("Detected Link network config event {}", event.type());
-                LinkKey lk = (LinkKey) event.subject();
-                BasicLinkConfig cfg = networkConfigService.getConfig(lk, BasicLinkConfig.class);
-                if (cfg != null && !cfg.isAllowed()) {
-                    log.info("Kicking out links between {} and {}", lk.src(), lk.dst());
-                    removeLink(lk.src(), lk.dst());
-                    removeLink(lk.dst(), lk.src());
-                }
+            LinkKey lk = (LinkKey) event.subject();
+            BasicLinkConfig cfg = networkConfigService.getConfig(lk, BasicLinkConfig.class);
+
+            if (!isAllowed(cfg)) {
+                log.info("Kicking out links between {} and {}", lk.src(), lk.dst());
+                removeLink(lk.src(), lk.dst());
+                removeLink(lk.dst(), lk.src());
+                return;
             }
+            Link link = getLink(lk.src(), lk.dst());
+            LinkDescription fldesc;
+            LinkDescription rldesc;
+            if (link == null) {
+                fldesc = BasicLinkOperator.descriptionOf(lk.src(), lk.dst(), cfg);
+                rldesc = BasicLinkOperator.descriptionOf(lk.dst(), lk.src(), cfg);
+            } else {
+                fldesc = BasicLinkOperator.combine(cfg,
+                            BasicLinkOperator.descriptionOf(lk.src(), lk.dst(), link));
+                rldesc = BasicLinkOperator.combine(cfg,
+                            BasicLinkOperator.descriptionOf(lk.dst(), lk.src(), link));
+            }
+            // XXX think of sane way to fetch the LinkProvider
+            store.createOrUpdateLink(ProviderId.NONE, fldesc);
+            store.createOrUpdateLink(ProviderId.NONE, rldesc);
         }
+
     }
 }
index 75239fd..a0bc693 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.onosproject.net.packet.impl;
 
+import com.google.common.collect.ImmutableMap;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -53,6 +54,7 @@ import org.onosproject.net.provider.AbstractProviderRegistry;
 import org.onosproject.net.provider.AbstractProviderService;
 import org.slf4j.Logger;
 
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
@@ -61,8 +63,8 @@ import java.util.concurrent.Executors;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onlab.util.Tools.groupedThreads;
 import static org.onosproject.security.AppGuard.checkPermission;
-import static org.slf4j.LoggerFactory.getLogger;
 import static org.onosproject.security.AppPermission.Type.*;
+import static org.slf4j.LoggerFactory.getLogger;
 
 /**
  * Provides a basic implementation of the packet SB &amp; NB APIs.
@@ -137,6 +139,11 @@ public class PacketManager
         processors.values().remove(processor);
     }
 
+    @Override
+    public Map<Integer, PacketProcessor> getProcessors() {
+        return ImmutableMap.copyOf(processors);
+    }
+
     @Override
     public void requestPackets(TrafficSelector selector, PacketPriority priority,
                                ApplicationId appId) {
@@ -163,6 +170,11 @@ public class PacketManager
         }
     }
 
+    @Override
+    public List<PacketRequest> getRequests() {
+        return store.existingRequests();
+    }
+
     /**
      * Pushes a packet request flow rule to all devices.
      *
index 398260f..25a2640 100644 (file)
@@ -69,11 +69,9 @@ public class ProxyArpManager implements ProxyArpService {
 
     private final Logger log = getLogger(getClass());
 
-    private static final String MAC_ADDR_NULL = "Mac address cannot be null.";
+    private static final String MAC_ADDR_NULL = "MAC address cannot be null.";
     private static final String REQUEST_NULL = "ARP or NDP request cannot be null.";
-    private static final String REQUEST_NOT_ARP = "Ethernet frame does not contain ARP request.";
-    private static final String NOT_ARP_REQUEST = "ARP is not a request.";
-    private static final String NOT_ARP_REPLY = "ARP is not a reply.";
+    private static final String MSG_NOT_REQUEST = "Message is not an ARP or NDP request";
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected EdgePortService edgeService;
@@ -96,6 +94,14 @@ public class ProxyArpManager implements ProxyArpService {
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected InterfaceService interfaceService;
 
+    private enum Protocol {
+        ARP, NDP
+    }
+
+    private enum MessageType {
+        REQUEST, REPLY
+    }
+
     @Activate
     public void activate() {
         store.setDelegate(this::sendTo);
@@ -123,46 +129,48 @@ public class ProxyArpManager implements ProxyArpService {
 
         checkNotNull(eth, REQUEST_NULL);
 
-        if (eth.getEtherType() == Ethernet.TYPE_ARP) {
-            replyArp(eth, inPort);
-        } else if (eth.getEtherType() == Ethernet.TYPE_IPV6) {
-            replyNdp(eth, inPort);
+        MessageContext context = createContext(eth, inPort);
+        if (context != null) {
+            replyInternal(context);
         }
     }
 
-    private void replyArp(Ethernet eth, ConnectPoint inPort) {
-        ARP arp = (ARP) eth.getPayload();
-        checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST);
-        checkNotNull(inPort);
-        Ip4Address targetAddress = Ip4Address.valueOf(arp.getTargetProtocolAddress());
-
-        VlanId vlan = vlanId(eth.getVlanID());
+    /**
+     * Handles a request message.
+     *
+     * If the MAC address of the target is known, we can reply directly to the
+     * requestor. Otherwise, we forward the request out other ports in an
+     * attempt to find the correct host.
+     *
+     * @param context request message context to process
+     */
+    private void replyInternal(MessageContext context) {
+        checkNotNull(context);
+        checkArgument(context.type() == MessageType.REQUEST, MSG_NOT_REQUEST);
 
-        if (hasIpAddress(inPort)) {
+        if (hasIpAddress(context.inPort())) {
             // If the request came from outside the network, only reply if it was
             // for one of our external addresses.
 
-            interfaceService.getInterfacesByPort(inPort)
+            interfaceService.getInterfacesByPort(context.inPort())
                     .stream()
                     .filter(intf -> intf.ipAddresses()
                             .stream()
-                            .anyMatch(ia -> ia.ipAddress().equals(targetAddress)))
-                    .forEach(intf -> buildAndSendArp(targetAddress, intf.mac(), eth, inPort));
+                            .anyMatch(ia -> ia.ipAddress().equals(context.target())))
+                    .forEach(intf -> buildAndSendReply(context, intf.mac()));
 
             // Stop here and don't proxy ARPs if the port has an IP address
             return;
         }
 
         // See if we have the target host in the host store
-
-        Set<Host> hosts = hostService.getHostsByIp(targetAddress);
+        Set<Host> hosts = hostService.getHostsByIp(context.target());
 
         Host dst = null;
-        Host src = hostService.getHost(hostId(eth.getSourceMAC(),
-                vlanId(eth.getVlanID())));
+        Host src = hostService.getHost(hostId(context.srcMac(), context.vlan()));
 
         for (Host host : hosts) {
-            if (host.vlan().equals(vlan)) {
+            if (host.vlan().equals(context.vlan())) {
                 dst = host;
                 break;
             }
@@ -170,22 +178,19 @@ public class ProxyArpManager implements ProxyArpService {
 
         if (src != null && dst != null) {
             // We know the target host so we can respond
-            buildAndSendArp(targetAddress, dst.mac(), eth, inPort);
+            buildAndSendReply(context, dst.mac());
             return;
         }
 
         // If the source address matches one of our external addresses
         // it could be a request from an internal host to an external
         // address. Forward it over to the correct port.
-        Ip4Address source =
-                Ip4Address.valueOf(arp.getSenderProtocolAddress());
-
         boolean matched = false;
-        Set<Interface> interfaces = interfaceService.getInterfacesByIp(source);
+        Set<Interface> interfaces = interfaceService.getInterfacesByIp(context.sender());
         for (Interface intf : interfaces) {
-            if (intf.vlan().equals(vlan)) {
+            if (intf.vlan().equals(context.vlan())) {
                 matched = true;
-                sendTo(eth, intf.connectPoint());
+                sendTo(context.packet(), intf.connectPoint());
                 break;
             }
         }
@@ -196,89 +201,33 @@ public class ProxyArpManager implements ProxyArpService {
 
         // The request couldn't be resolved.
         // Flood the request on all ports except the incoming port.
-        flood(eth, inPort);
+        flood(context.packet(), context.inPort());
     }
 
-    private void replyNdp(Ethernet eth, ConnectPoint inPort) {
-        IPv6 ipv6 = (IPv6) eth.getPayload();
-        ICMP6 icmpv6 = (ICMP6) ipv6.getPayload();
-        NeighborSolicitation nsol = (NeighborSolicitation) icmpv6.getPayload();
-        Ip6Address targetAddress = Ip6Address.valueOf(nsol.getTargetAddress());
-
-        VlanId vlan = vlanId(eth.getVlanID());
-
-        // If the request came from outside the network, only reply if it was
-        // for one of our external addresses.
-        if (hasIpAddress(inPort)) {
-            interfaceService.getInterfacesByPort(inPort)
-                    .stream()
-                    .filter(intf -> intf.ipAddresses()
-                            .stream()
-                            .anyMatch(ia -> ia.ipAddress().equals(targetAddress)))
-                    .forEach(intf -> buildAndSendNdp(targetAddress, intf.mac(), eth, inPort));
-            return;
-        }
-
-        // Continue with normal proxy ARP case
-
-        Set<Host> hosts = hostService.getHostsByIp(targetAddress);
-
-        Host dst = null;
-        Host src = hostService.getHost(hostId(eth.getSourceMAC(),
-                                              vlanId(eth.getVlanID())));
-
-        for (Host host : hosts) {
-            if (host.vlan().equals(vlan)) {
-                dst = host;
-                break;
-            }
-        }
-
-        if (src != null && dst != null) {
-            // We know the target host so we can respond
-            buildAndSendNdp(targetAddress, dst.mac(), eth, inPort);
-            return;
-        }
-
-        // If the source address matches one of our external addresses
-        // it could be a request from an internal host to an external
-        // address. Forward it over to the correct port.
-        Ip6Address source =
-                Ip6Address.valueOf(ipv6.getSourceAddress());
-
-        boolean matched = false;
-
-        Set<Interface> interfaces = interfaceService.getInterfacesByIp(source);
-        for (Interface intf : interfaces) {
-            if (intf.vlan().equals(vlan)) {
-                matched = true;
-                sendTo(eth, intf.connectPoint());
-                break;
-            }
-        }
-
-        if (matched) {
-            return;
+    /**
+     * Builds and sends a reply message given a request context and the resolved
+     * MAC address to answer with.
+     *
+     * @param context message context of request
+     * @param targetMac MAC address to be given in the response
+     */
+    private void buildAndSendReply(MessageContext context, MacAddress targetMac) {
+        switch (context.protocol()) {
+        case ARP:
+            sendTo(ARP.buildArpReply((Ip4Address) context.target(),
+                    targetMac, context.packet()), context.inPort());
+            break;
+        case NDP:
+            sendTo(buildNdpReply((Ip6Address) context.target(), targetMac,
+                    context.packet()), context.inPort());
+            break;
+        default:
+            break;
         }
-
-        // The request couldn't be resolved.
-        // Flood the request on all ports except the incoming ports.
-        flood(eth, inPort);
-    }
-    //TODO checkpoint
-
-    private void buildAndSendArp(Ip4Address srcIp, MacAddress srcMac,
-                                 Ethernet request, ConnectPoint port) {
-        sendTo(ARP.buildArpReply(srcIp, srcMac, request), port);
-    }
-
-    private void buildAndSendNdp(Ip6Address srcIp, MacAddress srcMac,
-                                 Ethernet request, ConnectPoint port) {
-        sendTo(buildNdpReply(srcIp, srcMac, request), port);
     }
 
     /**
-     * Outputs the given packet out the given port.
+     * Outputs a packet out a specific port.
      *
      * @param packet  the packet to send
      * @param outPort the port to send it out
@@ -287,6 +236,12 @@ public class ProxyArpManager implements ProxyArpService {
         sendTo(outPort, ByteBuffer.wrap(packet.serialize()));
     }
 
+    /**
+     * Outputs a packet out a specific port.
+     *
+     * @param outPort port to send it out
+     * @param packet packet to send
+     */
     private void sendTo(ConnectPoint outPort, ByteBuffer packet) {
         if (!edgeService.isEdgePoint(outPort)) {
             // Sanity check to make sure we don't send the packet out an
@@ -298,7 +253,7 @@ public class ProxyArpManager implements ProxyArpService {
         TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
         builder.setOutput(outPort.port());
         packetService.emit(new DefaultOutboundPacket(outPort.deviceId(),
-                                                     builder.build(), packet));
+                builder.build(), packet));
     }
 
     /**
@@ -323,7 +278,7 @@ public class ProxyArpManager implements ProxyArpService {
         checkNotNull(eth, REQUEST_NULL);
 
         Host h = hostService.getHost(hostId(eth.getDestinationMAC(),
-                                            vlanId(eth.getVlanID())));
+                vlanId(eth.getVlanID())));
 
         if (h == null) {
             flood(eth, inPort);
@@ -344,42 +299,24 @@ public class ProxyArpManager implements ProxyArpService {
         if (ethPkt == null) {
             return false;
         }
-        if (ethPkt.getEtherType() == Ethernet.TYPE_ARP) {
-            return handleArp(context, ethPkt);
-        } else if (ethPkt.getEtherType() == Ethernet.TYPE_IPV6) {
-            return handleNdp(context, ethPkt);
-        }
-        return false;
-    }
 
-    private boolean handleArp(PacketContext context, Ethernet ethPkt) {
-        ARP arp = (ARP) ethPkt.getPayload();
+        MessageContext msgContext = createContext(ethPkt, pkt.receivedFrom());
 
-        if (arp.getOpCode() == ARP.OP_REPLY) {
-            forward(ethPkt, context.inPacket().receivedFrom());
-        } else if (arp.getOpCode() == ARP.OP_REQUEST) {
-            reply(ethPkt, context.inPacket().receivedFrom());
-        } else {
+        if (msgContext == null) {
             return false;
         }
-        context.block();
-        return true;
-    }
 
-    private boolean handleNdp(PacketContext context, Ethernet ethPkt) {
-        IPv6 ipv6 = (IPv6) ethPkt.getPayload();
-
-        if (ipv6.getNextHeader() != IPv6.PROTOCOL_ICMP6) {
-            return false;
-        }
-        ICMP6 icmpv6 = (ICMP6) ipv6.getPayload();
-        if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_ADVERTISEMENT) {
-            forward(ethPkt, context.inPacket().receivedFrom());
-        } else if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) {
-            reply(ethPkt, context.inPacket().receivedFrom());
-        } else {
+        switch (msgContext.type()) {
+        case REPLY:
+            forward(msgContext.packet(), msgContext.inPort());
+            break;
+        case REQUEST:
+            replyInternal(msgContext);
+            break;
+        default:
             return false;
         }
+
         context.block();
         return true;
     }
@@ -444,4 +381,148 @@ public class ProxyArpManager implements ProxyArpService {
         eth.setPayload(ipv6);
         return eth;
     }
+
+    /**
+     * Attempts to create a MessageContext for the given Ethernet frame. If the
+     * frame is a valid ARP or NDP request or response, a context will be
+     * created.
+     *
+     * @param eth input Ethernet frame
+     * @param inPort in port
+     * @return MessageContext if the packet was ARP or NDP, otherwise null
+     */
+    private MessageContext createContext(Ethernet eth, ConnectPoint inPort) {
+        if (eth.getEtherType() == Ethernet.TYPE_ARP) {
+            return createArpContext(eth, inPort);
+        } else if (eth.getEtherType() == Ethernet.TYPE_IPV6) {
+            return createNdpContext(eth, inPort);
+        }
+
+        return null;
+    }
+
+    /**
+     * Extracts context information from ARP packets.
+     *
+     * @param eth input Ethernet frame that is thought to be ARP
+     * @param inPort in port
+     * @return MessageContext object if the packet was a valid ARP packet,
+     * otherwise null
+     */
+    private MessageContext createArpContext(Ethernet eth, ConnectPoint inPort) {
+        if (eth.getEtherType() != Ethernet.TYPE_ARP) {
+            return null;
+        }
+
+        ARP arp = (ARP) eth.getPayload();
+
+        IpAddress target = Ip4Address.valueOf(arp.getTargetProtocolAddress());
+        IpAddress sender = Ip4Address.valueOf(arp.getSenderProtocolAddress());
+
+        MessageType type;
+        if (arp.getOpCode() == ARP.OP_REQUEST) {
+            type = MessageType.REQUEST;
+        } else if (arp.getOpCode() == ARP.OP_REPLY) {
+            type = MessageType.REPLY;
+        } else {
+            return null;
+        }
+
+        return new MessageContext(eth, inPort, Protocol.ARP, type, target, sender);
+    }
+
+    /**
+     * Extracts context information from NDP packets.
+     *
+     * @param eth input Ethernet frame that is thought to be NDP
+     * @param inPort in port
+     * @return MessageContext object if the packet was a valid NDP packet,
+     * otherwise null
+     */
+    private MessageContext createNdpContext(Ethernet eth, ConnectPoint inPort) {
+        if (eth.getEtherType() != Ethernet.TYPE_IPV6) {
+            return null;
+        }
+        IPv6 ipv6 = (IPv6) eth.getPayload();
+
+        if (ipv6.getNextHeader() != IPv6.PROTOCOL_ICMP6) {
+            return null;
+        }
+        ICMP6 icmpv6 = (ICMP6) ipv6.getPayload();
+
+        IpAddress sender = Ip6Address.valueOf(ipv6.getSourceAddress());
+        IpAddress target = null;
+
+        MessageType type;
+        if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) {
+            type = MessageType.REQUEST;
+            NeighborSolicitation nsol = (NeighborSolicitation) icmpv6.getPayload();
+            target = Ip6Address.valueOf(nsol.getTargetAddress());
+        } else if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_ADVERTISEMENT) {
+            type = MessageType.REPLY;
+        } else {
+            return null;
+        }
+
+        return new MessageContext(eth, inPort, Protocol.NDP, type, target, sender);
+    }
+
+    /**
+     * Provides context information for a particular ARP or NDP message, with
+     * a unified interface to access data regardless of protocol.
+     */
+    private class MessageContext {
+        private Protocol protocol;
+        private MessageType type;
+
+        private IpAddress target;
+        private IpAddress sender;
+
+        private Ethernet eth;
+        private ConnectPoint inPort;
+
+
+        public MessageContext(Ethernet eth, ConnectPoint inPort,
+                              Protocol protocol, MessageType type,
+                              IpAddress target, IpAddress sender) {
+            this.eth = eth;
+            this.inPort = inPort;
+            this.protocol = protocol;
+            this.type = type;
+            this.target = target;
+            this.sender = sender;
+        }
+
+        public ConnectPoint inPort() {
+            return inPort;
+        }
+
+        public Ethernet packet() {
+            return eth;
+        }
+
+        public Protocol protocol() {
+            return protocol;
+        }
+
+        public MessageType type() {
+            return type;
+        }
+
+        public VlanId vlan() {
+            return VlanId.vlanId(eth.getVlanID());
+        }
+
+        public MacAddress srcMac() {
+            return MacAddress.valueOf(eth.getSourceMACAddress());
+        }
+
+        public IpAddress target() {
+            return target;
+        }
+
+        public IpAddress sender() {
+            return sender;
+        }
+    }
 }
index 996ad14..57964d6 100644 (file)
@@ -348,12 +348,7 @@ public class StatisticManager implements StatisticService {
      * @return predicate
      */
     private static Predicate<FlowEntry> hasApplicationId(ApplicationId appId) {
-        return new Predicate<FlowEntry>() {
-            @Override
-            public boolean apply(FlowEntry flowEntry) {
-                return flowEntry.appId() == appId.id();
-            }
-        };
+        return flowEntry -> flowEntry.appId() == appId.id();
     }
 
     /**
@@ -364,16 +359,13 @@ public class StatisticManager implements StatisticService {
      * @return predicate
      */
     private static Predicate<FlowEntry> hasGroupId(Optional<GroupId> groupId) {
-        return new Predicate<FlowEntry>() {
-            @Override
-            public boolean apply(FlowEntry flowEntry) {
-                if (!groupId.isPresent()) {
-                    return false;
-                }
-                // FIXME: The left hand type and right hand type don't match
-                // FlowEntry.groupId() still returns a short value, not int.
-                return flowEntry.groupId().equals(groupId.get());
+        return flowEntry -> {
+            if (!groupId.isPresent()) {
+                return false;
             }
+            // FIXME: The left hand type and right hand type don't match
+            // FlowEntry.groupId() still returns a short value, not int.
+            return flowEntry.groupId().equals(groupId.get());
         };
     }
 }
index 8827c55..2be0df7 100644 (file)
@@ -24,7 +24,6 @@ import java.net.URI;
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.ChassisId;
-import org.onosproject.net.config.Config;
 import org.onosproject.net.config.ConfigApplyDelegate;
 import org.onosproject.net.config.basics.BasicDeviceConfig;
 import org.onosproject.net.AnnotationKeys;
@@ -55,11 +54,7 @@ public class BasicDeviceOperatorTest {
     private static final DeviceDescription DEV1 = new DefaultDeviceDescription(
             DURI, SWITCH, MFR, HW, SW, SN, CID, SA);
 
-    private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() {
-        @Override
-        public void onApply(Config config) {
-        }
-    };
+    private final ConfigApplyDelegate delegate = config -> { };
     private final ObjectMapper mapper = new ObjectMapper();
 
     private static final BasicDeviceConfig SW_BDC = new BasicDeviceConfig();
index 78bc08e..ba40b2b 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.device.impl;
 
 import org.junit.Before;
index ae7cc87..73ce393 100644 (file)
@@ -276,10 +276,10 @@ public class GroupManagerTest {
         PortNumber[] addPorts = {PortNumber.portNumber(51),
                                  PortNumber.portNumber(52)};
         List<PortNumber> outPorts;
-        outPorts = new ArrayList<PortNumber>();
+        outPorts = new ArrayList<>();
         outPorts.addAll(Arrays.asList(addPorts));
         List<GroupBucket> addBuckets;
-        addBuckets = new ArrayList<GroupBucket>();
+        addBuckets = new ArrayList<>();
         for (PortNumber portNumber: outPorts) {
             TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
             tBuilder.setOutput(portNumber)
index e7f14b5..940ed91 100644 (file)
@@ -22,7 +22,6 @@ import org.junit.Test;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.VlanId;
-import org.onosproject.net.config.Config;
 import org.onosproject.net.config.ConfigApplyDelegate;
 import org.onosproject.net.config.basics.BasicHostConfig;
 import org.onosproject.net.AnnotationKeys;
@@ -49,11 +48,7 @@ public class BasicHostOperatorTest {
     );
     private static final HostDescription HOST = new DefaultHostDescription(MAC, VLAN, LOC, IP);
 
-    private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() {
-        @Override
-        public void onApply(Config config) {
-        }
-    };
+    private final ConfigApplyDelegate delegate = config -> { };
     private final ObjectMapper mapper = new ObjectMapper();
 
     private static final BasicHostConfig BHC = new BasicHostConfig();
index dbb807f..92c6c93 100644 (file)
  */
 package org.onosproject.net.host.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.onosproject.net.NetTestTools.injectEventDispatcher;
-import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
-import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED;
-import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
-import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED;
-
-import java.util.List;
-import java.util.Set;
-
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.VlanId;
-import org.onosproject.event.Event;
 import org.onosproject.common.event.impl.TestEventDispatcher;
-import org.onosproject.net.config.NetworkConfigServiceAdapter;
-import org.onosproject.net.ConnectPoint;
+import org.onosproject.event.Event;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Host;
 import org.onosproject.net.HostId;
 import org.onosproject.net.HostLocation;
 import org.onosproject.net.PortNumber;
+import org.onosproject.net.config.NetworkConfigServiceAdapter;
 import org.onosproject.net.host.DefaultHostDescription;
 import org.onosproject.net.host.HostDescription;
 import org.onosproject.net.host.HostEvent;
@@ -52,14 +38,23 @@ import org.onosproject.net.host.HostListener;
 import org.onosproject.net.host.HostProvider;
 import org.onosproject.net.host.HostProviderRegistry;
 import org.onosproject.net.host.HostProviderService;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
 import org.onosproject.net.provider.AbstractProvider;
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.store.trivial.SimpleHostStore;
 
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.onosproject.net.NetTestTools.injectEventDispatcher;
+import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED;
 
 /**
  * Test codifying the host service & host provider service contracts.
@@ -90,27 +85,6 @@ public class HostManagerTest {
     private static final PortNumber P2 = PortNumber.portNumber(200);
     private static final HostLocation LOC1 = new HostLocation(DID1, P1, 123L);
     private static final HostLocation LOC2 = new HostLocation(DID1, P2, 123L);
-    private static final ConnectPoint CP1 = new ConnectPoint(DID1, P1);
-    private static final ConnectPoint CP2 = new ConnectPoint(DID2, P2);
-
-    private static final InterfaceIpAddress IA1 =
-        new InterfaceIpAddress(IpAddress.valueOf("10.1.1.1"),
-                               IpPrefix.valueOf("10.1.1.0/24"));
-    private static final InterfaceIpAddress IA2 =
-        new InterfaceIpAddress(IpAddress.valueOf("10.2.2.2"),
-                               IpPrefix.valueOf("10.2.0.0/16"));
-    private static final InterfaceIpAddress IA3 =
-        new InterfaceIpAddress(IpAddress.valueOf("10.3.3.3"),
-                               IpPrefix.valueOf("10.3.3.0/24"));
-    private static final InterfaceIpAddress IA4 =
-        new InterfaceIpAddress(IpAddress.valueOf("2001:100::1"),
-                               IpPrefix.valueOf("2001:100::/56"));
-    private static final InterfaceIpAddress IA5 =
-        new InterfaceIpAddress(IpAddress.valueOf("2001:200::1"),
-                               IpPrefix.valueOf("2001:200::/48"));
-    private static final InterfaceIpAddress IA6 =
-        new InterfaceIpAddress(IpAddress.valueOf("2001:300::1"),
-                               IpPrefix.valueOf("2001:300::/56"));
 
     private HostManager mgr;
 
@@ -290,240 +264,6 @@ public class HostManagerTest {
 
     }
 
-    @Test
-    public void bindAddressesToPort() {
-        PortAddresses add1 =
-            new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-
-        // Add some more addresses and check that they're added correctly
-        PortAddresses add2 =
-            new PortAddresses(CP1, Sets.newHashSet(IA3),  null,
-                              VlanId.vlanId((short) 2));
-
-        mgr.bindAddressesToPort(add2);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(2, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-        assertTrue(storedAddresses.contains(add2));
-
-        PortAddresses add3 = new PortAddresses(CP1, null, MAC2, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add3);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(3, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-        assertTrue(storedAddresses.contains(add2));
-        assertTrue(storedAddresses.contains(add3));
-    }
-
-    @Test
-    public void bindAddressesToPortIPv6() {
-        PortAddresses add1 =
-                new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-
-        // Add some more addresses and check that they're added correctly
-        PortAddresses add2 =
-                new PortAddresses(CP1, Sets.newHashSet(IA6),  null,
-                        VlanId.vlanId((short) 2));
-
-        mgr.bindAddressesToPort(add2);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(2, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-        assertTrue(storedAddresses.contains(add2));
-
-        PortAddresses add3 = new PortAddresses(CP1, null, MAC4, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add3);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(3, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-        assertTrue(storedAddresses.contains(add2));
-        assertTrue(storedAddresses.contains(add3));
-    }
-
-    @Test
-    public void unbindAddressesFromPort() {
-        PortAddresses add1 =
-            new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-
-        PortAddresses rem1 =
-            new PortAddresses(CP1, Sets.newHashSet(IA1), null, VlanId.NONE);
-
-        mgr.unbindAddressesFromPort(rem1);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        // It shouldn't have been removed because it didn't match the originally
-        // submitted address object
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-
-        mgr.unbindAddressesFromPort(add1);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertTrue(storedAddresses.isEmpty());
-    }
-
-    @Test
-    public void unbindAddressesFromPortIPv6() {
-        PortAddresses add1 =
-                new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-
-        PortAddresses rem1 =
-                new PortAddresses(CP1, Sets.newHashSet(IA4), null, VlanId.NONE);
-
-        mgr.unbindAddressesFromPort(rem1);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        // It shouldn't have been removed because it didn't match the originally
-        // submitted address object
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-
-        mgr.unbindAddressesFromPort(add1);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertTrue(storedAddresses.isEmpty());
-    }
-
-    @Test
-    public void clearAddresses() {
-        PortAddresses add1 =
-            new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-
-        mgr.clearAddresses(CP1);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertTrue(storedAddresses.isEmpty());
-    }
-
-    @Test
-    public void clearAddressesIPv6() {
-        PortAddresses add1 =
-                new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-
-        mgr.clearAddresses(CP1);
-        storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertTrue(storedAddresses.isEmpty());
-    }
-
-    @Test
-    public void getAddressBindingsForPort() {
-        PortAddresses add1 =
-            new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-    }
-
-    @Test
-    public void getAddressBindingsForPortIPv6() {
-        PortAddresses add1 =
-                new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindingsForPort(CP1);
-
-        assertEquals(1, storedAddresses.size());
-        assertTrue(storedAddresses.contains(add1));
-    }
-
-    @Test
-    public void getAddressBindings() {
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindings();
-
-        assertTrue(storedAddresses.isEmpty());
-
-        PortAddresses add1 =
-            new PortAddresses(CP1, Sets.newHashSet(IA1, IA2), MAC1, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-
-        storedAddresses = mgr.getAddressBindings();
-
-        assertTrue(storedAddresses.size() == 1);
-
-        PortAddresses add2 =
-            new PortAddresses(CP2, Sets.newHashSet(IA3), MAC2, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add2);
-
-        storedAddresses = mgr.getAddressBindings();
-
-        assertTrue(storedAddresses.size() == 2);
-        assertTrue(storedAddresses.equals(Sets.newHashSet(add1, add2)));
-    }
-
-    @Test
-    public void getAddressBindingsIPv6() {
-        Set<PortAddresses> storedAddresses = mgr.getAddressBindings();
-
-        assertTrue(storedAddresses.isEmpty());
-
-        PortAddresses add1 =
-                new PortAddresses(CP1, Sets.newHashSet(IA4, IA5), MAC3, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add1);
-
-        storedAddresses = mgr.getAddressBindings();
-
-        assertTrue(storedAddresses.size() == 1);
-
-        PortAddresses add2 =
-                new PortAddresses(CP2, Sets.newHashSet(IA5), MAC4, VlanId.NONE);
-
-        mgr.bindAddressesToPort(add2);
-
-        storedAddresses = mgr.getAddressBindings();
-
-        assertTrue(storedAddresses.size() == 2);
-        assertTrue(storedAddresses.equals(Sets.newHashSet(add1, add2)));
-    }
-
     private class TestNetworkConfigService extends NetworkConfigServiceAdapter {
     }
 }
index d6ff473..d167197 100644 (file)
@@ -19,6 +19,7 @@ import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Multimap;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.ARP;
 import org.onlab.packet.Ethernet;
@@ -37,11 +38,11 @@ import org.onosproject.net.Port;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.device.DeviceListener;
 import org.onosproject.net.device.DeviceServiceAdapter;
+import org.onosproject.net.edge.EdgePortService;
 import org.onosproject.net.flow.instructions.Instruction;
 import org.onosproject.net.flow.instructions.Instructions.OutputInstruction;
 import org.onosproject.net.host.HostProvider;
 import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
 import org.onosproject.net.packet.OutboundPacket;
 import org.onosproject.net.packet.PacketServiceAdapter;
 import org.onosproject.net.provider.ProviderId;
@@ -51,6 +52,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
+import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
@@ -70,8 +72,18 @@ public class HostMonitorTest {
             new InterfaceIpAddress(SOURCE_ADDR, IpPrefix.valueOf("10.0.0.0/24"));
     private MacAddress sourceMac = MacAddress.valueOf(1L);
 
+    private EdgePortService edgePortService;
+
     private HostMonitor hostMonitor;
 
+    @Before
+    public void setUp() {
+        edgePortService = createMock(EdgePortService.class);
+        expect(edgePortService.isEdgePoint(anyObject(ConnectPoint.class)))
+                .andReturn(true).anyTimes();
+        replay(edgePortService);
+    }
+
     @After
     public void shutdown() {
         hostMonitor.shutdown();
@@ -96,7 +108,7 @@ public class HostMonitorTest {
         expectLastCall().once();
         replay(hostProvider);
 
-        hostMonitor = new HostMonitor(null, hostManager, null);
+        hostMonitor = new HostMonitor(null, hostManager, null, edgePortService);
 
         hostMonitor.registerHostProvider(hostProvider);
         hostMonitor.addMonitoringFor(TARGET_IP_ADDR);
@@ -127,8 +139,6 @@ public class HostMonitorTest {
         deviceService.addDevice(device, Collections.singleton(port));
 
         ConnectPoint cp = new ConnectPoint(devId, portNum);
-        PortAddresses pa =
-                new PortAddresses(cp, Collections.singleton(IA1), sourceMac, VlanId.NONE);
 
         expect(hostManager.getHostsByIp(TARGET_IP_ADDR))
                 .andReturn(Collections.emptySet()).anyTimes();
@@ -144,7 +154,7 @@ public class HostMonitorTest {
 
 
         // Run the test
-        hostMonitor = new HostMonitor(packetService, hostManager, interfaceService);
+        hostMonitor = new HostMonitor(packetService, hostManager, interfaceService, edgePortService);
 
         hostMonitor.addMonitoringFor(TARGET_IP_ADDR);
         hostMonitor.run(null);
@@ -198,9 +208,6 @@ public class HostMonitorTest {
         deviceService.addDevice(device, Collections.singleton(port));
 
         ConnectPoint cp = new ConnectPoint(devId, portNum);
-        PortAddresses pa =
-                new PortAddresses(cp, Collections.singleton(IA1), sourceMac,
-                                  VlanId.vlanId(vlan));
 
         expect(hostManager.getHostsByIp(TARGET_IP_ADDR))
                 .andReturn(Collections.emptySet()).anyTimes();
@@ -216,7 +223,7 @@ public class HostMonitorTest {
 
 
         // Run the test
-        hostMonitor = new HostMonitor(packetService, hostManager, interfaceService);
+        hostMonitor = new HostMonitor(packetService, hostManager, interfaceService, edgePortService);
 
         hostMonitor.addMonitoringFor(TARGET_IP_ADDR);
         hostMonitor.run(null);
index 8bd29bf..f23a049 100644 (file)
@@ -24,13 +24,11 @@ import org.onosproject.net.flow.FlowRule;
 import org.onosproject.net.flow.FlowRuleOperations;
 import org.onosproject.net.flow.FlowRuleServiceAdapter;
 
+import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
-import static org.onosproject.net.flow.FlowRuleOperation.Type.REMOVE;
-
-
 public class MockFlowRuleService extends FlowRuleServiceAdapter {
 
     final Set<FlowRule> flows = Sets.newHashSet();
@@ -87,9 +85,7 @@ public class MockFlowRuleService extends FlowRuleServiceAdapter {
 
     @Override
     public void applyFlowRules(FlowRule... flowRules) {
-        for (FlowRule flow : flowRules) {
-            flows.add(flow);
-        }
+        Collections.addAll(flows, flowRules);
     }
 
     @Override
index 76b26f4..03a38a5 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.net.intent.impl.compiler;
 
 import java.util.List;
index fe9e37c..eadbb5c 100644 (file)
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals;
 import java.time.Duration;
 import org.junit.Before;
 import org.junit.Test;
-import org.onosproject.net.config.Config;
 import org.onosproject.net.config.ConfigApplyDelegate;
 import org.onosproject.net.config.basics.BasicLinkConfig;
 import org.onosproject.net.AnnotationKeys;
@@ -53,11 +52,7 @@ public class BasicLinkOperatorTest {
     private static final SparseAnnotations SA = DefaultAnnotations.builder()
             .set(AnnotationKeys.DURABLE, "true").build();
     private static final LinkDescription LD = new DefaultLinkDescription(SRC, DST, Link.Type.DIRECT, SA);
-    private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() {
-        @Override
-        public void onApply(Config config) {
-        }
-    };
+    private final ConfigApplyDelegate delegate = config -> { };
     private final ObjectMapper mapper = new ObjectMapper();
 
     private static final BasicLinkConfig BLC = new BasicLinkConfig();
index 0f7dd8c..c4f2554 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 67e74a1..8dbc6c0 100644 (file)
@@ -1,4 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
 <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/xsd/maven-4.0.0.xsd">
@@ -7,7 +22,7 @@
     <parent>
         <artifactId>onos-core</artifactId>
         <groupId>org.onosproject</groupId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 8ae1a1a..b043765 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.security.impl;
 
 
index 30b0f8b..325f49b 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.security.impl;
 
 import com.google.common.collect.Lists;
@@ -43,10 +58,11 @@ import org.slf4j.Logger;
 
 import static org.slf4j.LoggerFactory.getLogger;
 
-
-
 /**
  * Security-Mode ONOS management implementation.
+ *
+ * Note: Activating Security-Mode ONOS has significant performance implications in Drake.
+ *       See the wiki for instructions on how to activate it.
  */
 
 @Component(immediate = true)
diff --git a/framework/src/onos/core/security/src/main/java/org/onosproject/security/store/package-info.java b/framework/src/onos/core/security/src/main/java/org/onosproject/security/store/package-info.java
new file mode 100644 (file)
index 0000000..a47f8ea
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Security-Mode ONOS distributed store.
+ */
+package org.onosproject.security.store;
index eb9c38a..cc293da 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-core-store</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 4e28e3c..8b0001d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.cluster.impl;
 
 import com.google.common.collect.ImmutableSet;
index 9e52c3e..ffdd25f 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.cluster.messaging.impl;
 
 import org.apache.felix.scr.annotations.Activate;
index 8b2cc8e..9328817 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.cluster.messaging.impl;
 
 import com.google.common.base.Strings;
index 58aca31..5183924 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.consistent.impl;
 
 import java.util.Collection;
index b7c3794..fbc2c88 100644 (file)
@@ -47,7 +47,6 @@ import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.felix.scr.annotations.Service;
-
 import org.onosproject.app.ApplicationEvent;
 import org.onosproject.app.ApplicationListener;
 import org.onosproject.app.ApplicationService;
@@ -252,7 +251,7 @@ public class DatabaseManager implements StorageService, StorageAdminService {
                     log.info("Successfully closed databases.");
                 }
             });
-        maps.values().forEach(this::unregisterMap);
+        ImmutableList.copyOf(maps.values()).forEach(this::unregisterMap);
         if (applicationService != null) {
             applicationService.removeListener(appListener);
         }
index 9d3505b..9a55ffb 100644 (file)
@@ -84,7 +84,7 @@ public class DefaultDatabaseState implements DatabaseState<String, byte[]> {
         }
         nextVersion = context.get("nextVersion");
         if (nextVersion == null) {
-            nextVersion = new Long(0);
+            nextVersion = 0L;
             context.put("nextVersion", nextVersion);
         }
     }
index e54b0ee..7c3769a 100644 (file)
@@ -19,8 +19,6 @@ import static org.slf4j.LoggerFactory.getLogger;
 
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -61,7 +59,6 @@ public class ConsistentApplicationIdStore implements ApplicationIdStore {
     private ConsistentMap<String, ApplicationId> registeredIds;
     private Map<String, ApplicationId> nameToAppIdCache = Maps.newConcurrentMap();
     private Map<Short, ApplicationId> idToAppIdCache = Maps.newConcurrentMap();
-    private ScheduledExecutorService executor;
 
     private static final Serializer SERIALIZER = Serializer.using(new KryoNamespace.Builder()
                                                                         .register(KryoNamespaces.API)
@@ -88,7 +85,6 @@ public class ConsistentApplicationIdStore implements ApplicationIdStore {
 
     @Deactivate
     public void deactivate() {
-        executor.shutdown();
         log.info("Stopped");
     }
 
index 8913742..c6f48a4 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.core.impl;
 
 import com.google.common.collect.Maps;
index ccf0f32..6a667e3 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.core.impl;
 
 import static org.slf4j.LoggerFactory.getLogger;
index fd7fcd8..2320672 100644 (file)
@@ -82,7 +82,7 @@ class DeviceDescriptions {
         if (oldOne != null) {
             SparseAnnotations merged = union(oldOne.value().annotations(),
                                              newDesc.value().annotations());
-            newOne = new Timestamped<DeviceDescription>(
+            newOne = new Timestamped<>(
                     new DefaultDeviceDescription(newDesc.value(), merged),
                     newDesc.timestamp());
         }
@@ -104,27 +104,27 @@ class DeviceDescriptions {
             switch (newDesc.value().type()) {
                 case OMS:
                     OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value());
-                    newOne = new Timestamped<PortDescription>(
+                    newOne = new Timestamped<>(
                             new OmsPortDescription(
                                     omsDesc, omsDesc.minFrequency(), omsDesc.maxFrequency(), omsDesc.grid(), merged),
                             newDesc.timestamp());
                     break;
                 case OCH:
                     OchPortDescription ochDesc = (OchPortDescription) (newDesc.value());
-                    newOne = new Timestamped<PortDescription>(
+                    newOne = new Timestamped<>(
                             new OchPortDescription(
                                     ochDesc, ochDesc.signalType(), ochDesc.isTunable(), ochDesc.lambda(), merged),
                             newDesc.timestamp());
                     break;
                 case ODUCLT:
                     OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value());
-                    newOne = new Timestamped<PortDescription>(
+                    newOne = new Timestamped<>(
                             new OduCltPortDescription(
                                     ocDesc, ocDesc.signalType(), merged),
                             newDesc.timestamp());
                     break;
                 default:
-                    newOne = new Timestamped<PortDescription>(
+                    newOne = new Timestamped<>(
                             new DefaultPortDescription(newDesc.value(), merged),
                             newDesc.timestamp());
             }
index 6f93963..3c3bbb6 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.device.impl;
 
 import com.google.common.base.MoreObjects;
index 6345643..973db49 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onosproject.store.device.impl;
 
-import com.google.common.base.Function;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Maps;
@@ -564,13 +563,10 @@ public class GossipDeviceStore
                 final DeviceDescriptions descs = device.get(providerId);
                 List<PortDescription> mergedList =
                         FluentIterable.from(portDescriptions)
-                                .transform(new Function<PortDescription, PortDescription>() {
-                                    @Override
-                                    public PortDescription apply(PortDescription input) {
-                                        // lookup merged port description
-                                        return descs.getPortDesc(input.portNumber()).value();
-                                    }
-                                }).toList();
+                                .transform(input ->
+                                    // lookup merged port description
+                                    descs.getPortDesc(input.portNumber()).value()
+                                ).toList();
                 merged = new Timestamped<>(mergedList, newTimestamp);
             }
 
index ed0ccaa..1ff0519 100644 (file)
@@ -41,7 +41,7 @@ public final class PortFragmentId {
     @Override
     public int hashCode() {
         return Objects.hash(providerId, deviceId, portNumber);
-    };
+    }
 
     @Override
     public boolean equals(Object obj) {
index c80f810..971f53d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.device.impl;
 
 import com.google.common.base.MoreObjects;
index cf48dcb..97333eb 100644 (file)
@@ -131,8 +131,7 @@ public class DistributedGroupStore
     private ExecutorService messageHandlingExecutor;
     private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1;
 
-    private final HashMap<DeviceId, Boolean> deviceAuditStatus =
-            new HashMap<DeviceId, Boolean>();
+    private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>();
 
     private final AtomicInteger groupIdGen = new AtomicInteger();
 
@@ -685,8 +684,7 @@ public class DistributedGroupStore
                                                    UpdateType type,
                                                    GroupBuckets buckets) {
         GroupBuckets oldBuckets = oldGroup.buckets();
-        List<GroupBucket> newBucketList = new ArrayList<GroupBucket>(
-                oldBuckets.buckets());
+        List<GroupBucket> newBucketList = new ArrayList<>(oldBuckets.buckets());
         boolean groupDescUpdated = false;
 
         if (type == UpdateType.ADD) {
index d8b9dac..d0b827c 100644 (file)
-package org.onosproject.store.host.impl;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-import static org.onosproject.net.DefaultAnnotations.merge;\r
-import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;\r
-import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;\r
-import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED;\r
-import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;\r
-import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE;\r
-import static org.slf4j.LoggerFactory.getLogger;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.Objects;\r
-import java.util.Set;\r
-import java.util.function.Predicate;\r
-import java.util.stream.Collectors;\r
-\r
-import org.apache.felix.scr.annotations.Activate;\r
-import org.apache.felix.scr.annotations.Component;\r
-import org.apache.felix.scr.annotations.Deactivate;\r
-import org.apache.felix.scr.annotations.Reference;\r
-import org.apache.felix.scr.annotations.ReferenceCardinality;\r
-import org.apache.felix.scr.annotations.Service;\r
-import org.onlab.packet.IpAddress;\r
-import org.onlab.packet.MacAddress;\r
-import org.onlab.packet.VlanId;\r
-import org.onlab.util.KryoNamespace;\r
-import org.onosproject.net.Annotations;\r
-import org.onosproject.net.ConnectPoint;\r
-import org.onosproject.net.DefaultAnnotations;\r
-import org.onosproject.net.DefaultHost;\r
-import org.onosproject.net.DeviceId;\r
-import org.onosproject.net.Host;\r
-import org.onosproject.net.HostId;\r
-import org.onosproject.net.host.HostDescription;\r
-import org.onosproject.net.host.HostEvent;\r
-import org.onosproject.net.host.HostStore;\r
-import org.onosproject.net.host.HostStoreDelegate;\r
-import org.onosproject.net.host.PortAddresses;\r
-import org.onosproject.net.host.HostEvent.Type;\r
-import org.onosproject.net.provider.ProviderId;\r
-import org.onosproject.store.AbstractStore;\r
-import org.onosproject.store.serializers.KryoNamespaces;\r
-import org.onosproject.store.service.EventuallyConsistentMap;\r
-import org.onosproject.store.service.EventuallyConsistentMapEvent;\r
-import org.onosproject.store.service.EventuallyConsistentMapListener;\r
-import org.onosproject.store.service.LogicalClockService;\r
-import org.onosproject.store.service.StorageService;\r
-import org.slf4j.Logger;\r
-\r
-import com.google.common.collect.HashMultimap;\r
-import com.google.common.collect.ImmutableMultimap;\r
-import com.google.common.collect.ImmutableSet;\r
-import com.google.common.collect.Multimaps;\r
-import com.google.common.collect.SetMultimap;\r
-import com.google.common.collect.Sets;\r
-\r
-/**\r
- * Manages the inventory of hosts using a {@code EventuallyConsistentMap}.\r
- */\r
-@Component(immediate = true)\r
-@Service\r
-public class ECHostStore\r
-    extends AbstractStore<HostEvent, HostStoreDelegate>\r
-    implements HostStore {\r
-\r
-    private final Logger log = getLogger(getClass());\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected StorageService storageService;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected LogicalClockService clockService;\r
-\r
-    // Hosts tracked by their location\r
-    private final SetMultimap<ConnectPoint, Host> locations =\r
-            Multimaps.synchronizedSetMultimap(\r
-                    HashMultimap.<ConnectPoint, Host>create());\r
-\r
-    private final SetMultimap<ConnectPoint, PortAddresses> portAddresses =\r
-            Multimaps.synchronizedSetMultimap(\r
-                    HashMultimap.<ConnectPoint, PortAddresses>create());\r
-\r
-    private EventuallyConsistentMap<HostId, DefaultHost> hosts;\r
-\r
-    private EventuallyConsistentMapListener<HostId, DefaultHost> hostLocationTracker =\r
-            new HostLocationTracker();\r
-\r
-    @Activate\r
-    public void activate() {\r
-        KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()\r
-                .register(KryoNamespaces.API);\r
-\r
-        hosts = storageService.<HostId, DefaultHost>eventuallyConsistentMapBuilder()\r
-                .withName("onos-hosts")\r
-                .withSerializer(hostSerializer)\r
-                .withTimestampProvider((k, v) -> clockService.getTimestamp())\r
-                .build();\r
-\r
-        hosts.addListener(hostLocationTracker);\r
-\r
-        log.info("Started");\r
-    }\r
-\r
-    @Deactivate\r
-    public void deactivate() {\r
-        hosts.removeListener(hostLocationTracker);\r
-        hosts.destroy();\r
-        locations.clear();\r
-        portAddresses.clear();\r
-\r
-        log.info("Stopped");\r
-    }\r
-\r
-    @Override\r
-    public HostEvent createOrUpdateHost(ProviderId providerId,\r
-            HostId hostId,\r
-            HostDescription hostDescription) {\r
-        DefaultHost currentHost = hosts.get(hostId);\r
-        if (currentHost == null) {\r
-            DefaultHost newhost = new DefaultHost(\r
-                        providerId,\r
-                        hostId,\r
-                        hostDescription.hwAddress(),\r
-                        hostDescription.vlan(),\r
-                        hostDescription.location(),\r
-                        ImmutableSet.copyOf(hostDescription.ipAddress()),\r
-                        hostDescription.annotations());\r
-            hosts.put(hostId, newhost);\r
-            return new HostEvent(HOST_ADDED, newhost);\r
-        }\r
-        return updateHost(providerId, hostId, hostDescription, currentHost);\r
-    }\r
-\r
-    @Override\r
-    public HostEvent removeHost(HostId hostId) {\r
-        Host host = hosts.remove(hostId);\r
-        return host != null ? new HostEvent(HOST_REMOVED, host) : null;\r
-    }\r
-\r
-    @Override\r
-    public int getHostCount() {\r
-        return hosts.size();\r
-    }\r
-\r
-    @Override\r
-    public Iterable<Host> getHosts() {\r
-        return ImmutableSet.copyOf(hosts.values());\r
-    }\r
-\r
-    @Override\r
-    public Host getHost(HostId hostId) {\r
-        return hosts.get(hostId);\r
-    }\r
-\r
-    @Override\r
-    public Set<Host> getHosts(VlanId vlanId) {\r
-        return filter(hosts.values(), host -> Objects.equals(host.vlan(), vlanId));\r
-    }\r
-\r
-    @Override\r
-    public Set<Host> getHosts(MacAddress mac) {\r
-        return filter(hosts.values(), host -> Objects.equals(host.mac(), mac));\r
-    }\r
-\r
-    @Override\r
-    public Set<Host> getHosts(IpAddress ip) {\r
-        return filter(hosts.values(), host -> host.ipAddresses().contains(ip));\r
-    }\r
-\r
-    @Override\r
-    public Set<Host> getConnectedHosts(ConnectPoint connectPoint) {\r
-        return ImmutableSet.copyOf(locations.get(connectPoint));\r
-    }\r
-\r
-    @Override\r
-    public Set<Host> getConnectedHosts(DeviceId deviceId) {\r
-        return ImmutableMultimap.copyOf(locations)\r
-                .entries()\r
-                .stream()\r
-                .filter(entry -> entry.getKey().deviceId().equals(deviceId))\r
-                .map(entry -> entry.getValue())\r
-                .collect(Collectors.toSet());\r
-    }\r
-\r
-    @Override\r
-    public void updateAddressBindings(PortAddresses addresses) {\r
-        portAddresses.put(addresses.connectPoint(), addresses);\r
-    }\r
-\r
-    @Override\r
-    public void removeAddressBindings(PortAddresses addresses) {\r
-        portAddresses.remove(addresses.connectPoint(), addresses);\r
-    }\r
-\r
-    @Override\r
-    public void clearAddressBindings(ConnectPoint connectPoint) {\r
-        portAddresses.removeAll(connectPoint);\r
-    }\r
-\r
-    @Override\r
-    public Set<PortAddresses> getAddressBindings() {\r
-        return ImmutableSet.copyOf(portAddresses.values());\r
-    }\r
-\r
-    @Override\r
-    public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) {\r
-        synchronized (portAddresses) {\r
-            Set<PortAddresses> addresses = portAddresses.get(connectPoint);\r
-            return addresses == null ? Collections.emptySet() : ImmutableSet.copyOf(addresses);\r
-        }\r
-    }\r
-\r
-    private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) {\r
-        return collection.stream().filter(predicate).collect(Collectors.toSet());\r
-    }\r
-\r
-    // checks for type of update to host, sends appropriate event\r
-    private HostEvent updateHost(ProviderId providerId,\r
-                                 HostId hostId,\r
-                                 HostDescription descr,\r
-                                 DefaultHost currentHost) {\r
-\r
-        final boolean hostMoved = !currentHost.location().equals(descr.location());\r
-        if (hostMoved ||\r
-                !currentHost.ipAddresses().containsAll(descr.ipAddress()) ||\r
-                !descr.annotations().keys().isEmpty()) {\r
-\r
-            Set<IpAddress> addresses = Sets.newHashSet(currentHost.ipAddresses());\r
-            addresses.addAll(descr.ipAddress());\r
-            Annotations annotations = merge((DefaultAnnotations) currentHost.annotations(),\r
-                                            descr.annotations());\r
-\r
-            DefaultHost updatedHost = new DefaultHost(providerId, currentHost.id(),\r
-                                                currentHost.mac(), currentHost.vlan(),\r
-                                                descr.location(),\r
-                                                addresses,\r
-                                                annotations);\r
-\r
-            // TODO: We need a way to detect conflicting changes and abort update.\r
-            hosts.put(hostId, updatedHost);\r
-            locations.remove(currentHost.location(), currentHost);\r
-            locations.put(updatedHost.location(), updatedHost);\r
-\r
-            HostEvent.Type eventType = hostMoved ? Type.HOST_MOVED : Type.HOST_UPDATED;\r
-            return new HostEvent(eventType, updatedHost);\r
-        }\r
-        return null;\r
-    }\r
-\r
-    private class HostLocationTracker implements EventuallyConsistentMapListener<HostId, DefaultHost> {\r
-        @Override\r
-        public void event(EventuallyConsistentMapEvent<HostId, DefaultHost> event) {\r
-            DefaultHost host = checkNotNull(event.value());\r
-            if (event.type() == PUT) {\r
-                boolean isNew = locations.put(host.location(), host);\r
-                notifyDelegate(new HostEvent(isNew ? HOST_ADDED : HOST_UPDATED, host));\r
-            } else if (event.type() == REMOVE) {\r
-                if (locations.remove(host.location(), host)) {\r
-                    notifyDelegate(new HostEvent(HOST_REMOVED, host));\r
-                }\r
-\r
-            }\r
-        }\r
-    }\r
-}\r
+/*
+ * 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.store.host.impl;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.onosproject.net.DefaultAnnotations.merge;
+import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED;
+import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED;
+import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
+import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+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.apache.felix.scr.annotations.Service;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultHost;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Host;
+import org.onosproject.net.HostId;
+import org.onosproject.net.HostLocation;
+import org.onosproject.net.host.HostDescription;
+import org.onosproject.net.host.HostEvent;
+import org.onosproject.net.host.HostStore;
+import org.onosproject.net.host.HostStoreDelegate;
+import org.onosproject.net.host.HostEvent.Type;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.store.AbstractStore;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.EventuallyConsistentMap;
+import org.onosproject.store.service.EventuallyConsistentMapEvent;
+import org.onosproject.store.service.EventuallyConsistentMapListener;
+import org.onosproject.store.service.LogicalClockService;
+import org.onosproject.store.service.StorageService;
+import org.slf4j.Logger;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimaps;
+import com.google.common.collect.SetMultimap;
+import com.google.common.collect.Sets;
+
+/**
+ * Manages the inventory of hosts using a {@code EventuallyConsistentMap}.
+ */
+@Component(immediate = true)
+@Service
+public class ECHostStore
+    extends AbstractStore<HostEvent, HostStoreDelegate>
+    implements HostStore {
+
+    private final Logger log = getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected StorageService storageService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected LogicalClockService clockService;
+
+    // Hosts tracked by their location
+    private final SetMultimap<ConnectPoint, Host> locations =
+            Multimaps.synchronizedSetMultimap(
+                    HashMultimap.<ConnectPoint, Host>create());
+
+    private EventuallyConsistentMap<HostId, DefaultHost> hosts;
+
+    private EventuallyConsistentMapListener<HostId, DefaultHost> hostLocationTracker =
+            new HostLocationTracker();
+
+    @Activate
+    public void activate() {
+        KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
+                .register(KryoNamespaces.API);
+
+        hosts = storageService.<HostId, DefaultHost>eventuallyConsistentMapBuilder()
+                .withName("onos-hosts")
+                .withSerializer(hostSerializer)
+                .withTimestampProvider((k, v) -> clockService.getTimestamp())
+                .build();
+
+        hosts.addListener(hostLocationTracker);
+
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        hosts.removeListener(hostLocationTracker);
+        hosts.destroy();
+        locations.clear();
+
+        log.info("Stopped");
+    }
+
+    @Override
+    public HostEvent createOrUpdateHost(ProviderId providerId,
+                                        HostId hostId,
+                                        HostDescription hostDescription,
+                                        boolean replaceIPs) {
+        // TODO: We need a way to detect conflicting changes and abort update.
+        //       (BOC) Compute might do this for us.
+
+        final AtomicReference<Type> eventType = new AtomicReference<>();
+        final AtomicReference<DefaultHost> oldHost = new AtomicReference<>();
+        DefaultHost host = hosts.compute(hostId, (id, existingHost) -> {
+            if (existingHost != null) {
+                oldHost.set(existingHost);
+                checkState(Objects.equals(hostDescription.hwAddress(), existingHost.mac()),
+                           "Existing and new MAC addresses differ.");
+                checkState(Objects.equals(hostDescription.vlan(), existingHost.vlan()),
+                           "Existing and new VLANs differ.");
+            }
+
+            // TODO do we ever want the existing location?
+            HostLocation location = hostDescription.location();
+
+            final Set<IpAddress> addresses;
+            if (existingHost == null || replaceIPs) {
+                addresses = ImmutableSet.copyOf(hostDescription.ipAddress());
+            } else {
+                addresses = Sets.newHashSet(existingHost.ipAddresses());
+                addresses.addAll(hostDescription.ipAddress());
+            }
+
+            final Annotations annotations;
+            if (existingHost != null) {
+                annotations = merge((DefaultAnnotations) existingHost.annotations(),
+                                    hostDescription.annotations());
+            } else {
+                annotations = hostDescription.annotations();
+            }
+
+            if (existingHost == null) {
+                eventType.set(HOST_ADDED);
+            } else if (!Objects.equals(existingHost.location(), hostDescription.location())) {
+                eventType.set(HOST_MOVED);
+            } else if (!existingHost.ipAddresses().containsAll(hostDescription.ipAddress()) ||
+                    !hostDescription.annotations().keys().isEmpty()) {
+                eventType.set(HOST_UPDATED);
+            } // else, eventType == null; this means we don't send an event
+
+            return new DefaultHost(providerId,
+                                   hostId,
+                                   hostDescription.hwAddress(),
+                                   hostDescription.vlan(),
+                                   location,
+                                   addresses,
+                                   annotations);
+        });
+
+        if (oldHost.get() != null) {
+            DefaultHost old = oldHost.get();
+            locations.remove(old.location(), old);
+        }
+        locations.put(host.location(), host);
+
+        return eventType.get() != null ? new HostEvent(eventType.get(), host) : null;
+    }
+
+    @Override
+    public HostEvent removeHost(HostId hostId) {
+        Host host = hosts.remove(hostId);
+        return host != null ? new HostEvent(HOST_REMOVED, host) : null;
+    }
+
+    @Override
+    public int getHostCount() {
+        return hosts.size();
+    }
+
+    @Override
+    public Iterable<Host> getHosts() {
+        return ImmutableSet.copyOf(hosts.values());
+    }
+
+    @Override
+    public Host getHost(HostId hostId) {
+        return hosts.get(hostId);
+    }
+
+    @Override
+    public Set<Host> getHosts(VlanId vlanId) {
+        return filter(hosts.values(), host -> Objects.equals(host.vlan(), vlanId));
+    }
+
+    @Override
+    public Set<Host> getHosts(MacAddress mac) {
+        return filter(hosts.values(), host -> Objects.equals(host.mac(), mac));
+    }
+
+    @Override
+    public Set<Host> getHosts(IpAddress ip) {
+        return filter(hosts.values(), host -> host.ipAddresses().contains(ip));
+    }
+
+    @Override
+    public Set<Host> getConnectedHosts(ConnectPoint connectPoint) {
+        return ImmutableSet.copyOf(locations.get(connectPoint));
+    }
+
+    @Override
+    public Set<Host> getConnectedHosts(DeviceId deviceId) {
+        return ImmutableMultimap.copyOf(locations)
+                .entries()
+                .stream()
+                .filter(entry -> entry.getKey().deviceId().equals(deviceId))
+                .map(entry -> entry.getValue())
+                .collect(Collectors.toSet());
+    }
+
+    private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) {
+        return collection.stream().filter(predicate).collect(Collectors.toSet());
+    }
+
+    private class HostLocationTracker implements EventuallyConsistentMapListener<HostId, DefaultHost> {
+        @Override
+        public void event(EventuallyConsistentMapEvent<HostId, DefaultHost> event) {
+            DefaultHost host = checkNotNull(event.value());
+            if (event.type() == PUT) {
+                boolean isNew = locations.put(host.location(), host);
+                notifyDelegate(new HostEvent(isNew ? HOST_ADDED : HOST_UPDATED, host));
+            } else if (event.type() == REMOVE) {
+                if (locations.remove(host.location(), host)) {
+                    notifyDelegate(new HostEvent(HOST_REMOVED, host));
+                }
+
+            }
+        }
+    }
+}
index 5ae8b4f..9382960 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.impl;
 
 import static com.google.common.base.Preconditions.checkArgument;
index 4577086..243caf8 100644 (file)
@@ -211,7 +211,10 @@ public class ECLinkStore
         // otherwise signal the actual master.
         if (clusterService.getLocalNode().id().equals(dstNodeId)) {
             LinkKey linkKey = linkKey(linkDescription.src(), linkDescription.dst());
-            Provided<LinkKey> internalLinkKey = new Provided<>(linkKey, providerId);
+            Provided<LinkKey> internalLinkKey = getProvided(linkKey, providerId);
+            if (internalLinkKey == null) {
+                return null;
+            }
             linkDescriptions.compute(internalLinkKey, (k, v) -> createOrUpdateLinkInternal(v  , linkDescription));
             return refreshLinkCache(linkKey);
         } else {
@@ -226,6 +229,18 @@ public class ECLinkStore
         }
     }
 
+    private Provided<LinkKey> getProvided(LinkKey linkKey, ProviderId provId) {
+        ProviderId bpid = getBaseProviderId(linkKey);
+        if (provId == null) {
+            // The LinkService didn't know who this LinkKey belongs to.
+            // A fix is to either modify the getProvider() in LinkService classes
+            // or expose the contents of linkDescriptions to the LinkService.
+            return (bpid == null) ? null : new Provided<>(linkKey, bpid);
+        } else {
+            return new Provided<>(linkKey, provId);
+        }
+    }
+
     private LinkDescription createOrUpdateLinkInternal(LinkDescription current, LinkDescription updated) {
         if (current != null) {
             // we only allow transition from INDIRECT -> DIRECT
index 767ede5..105c77d 100644 (file)
@@ -62,7 +62,6 @@ import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
 import org.slf4j.Logger;
 
 import java.io.IOException;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -551,7 +550,7 @@ public class GossipLinkStore
      */
     private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() {
         return synchronizedSetMultimap(
-               Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(),
+               Multimaps.newSetMultimap(new ConcurrentHashMap<>(),
                                        () -> Sets.newConcurrentHashSet()));
     }
 
index 356033b..b353208 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.link.impl;
 
 import com.google.common.base.MoreObjects;
index 9d3b168..5a38a34 100644 (file)
@@ -45,9 +45,9 @@ final class RoleValue {
      * Constructs empty RoleValue.
      */
     public RoleValue() {
-        value.put(MastershipRole.MASTER, new LinkedList<NodeId>());
-        value.put(MastershipRole.STANDBY, new LinkedList<NodeId>());
-        value.put(MastershipRole.NONE, new LinkedList<NodeId>());
+        value.put(MastershipRole.MASTER, new LinkedList<>());
+        value.put(MastershipRole.STANDBY, new LinkedList<>());
+        value.put(MastershipRole.NONE, new LinkedList<>());
     }
 
     /**
index 24ce215..d4c89c9 100644 (file)
@@ -15,7 +15,7 @@
  */
 package org.onosproject.store.packet.impl;
 
-import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -45,6 +45,7 @@ import org.onosproject.store.service.Versioned;
 import org.slf4j.Logger;
 
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -152,7 +153,7 @@ public class DistributedPacketStore
     }
 
     @Override
-    public Set<PacketRequest> existingRequests() {
+    public List<PacketRequest> existingRequests() {
         return tracker.requests();
     }
 
@@ -197,10 +198,11 @@ public class DistributedPacketStore
             return requests.replace(request.selector(), old.version(), newSet);
         }
 
-        public Set<PacketRequest> requests() {
-            ImmutableSet.Builder<PacketRequest> builder = ImmutableSet.builder();
-            requests.values().forEach(v -> builder.addAll(v.value()));
-            return builder.build();
+        public List<PacketRequest> requests() {
+            List<PacketRequest> list = Lists.newArrayList();
+            requests.values().forEach(v -> list.addAll(v.value()));
+            list.sort((o1, o2) -> o1.priority().priorityValue() - o2.priority().priorityValue());
+            return list;
         }
 
     }
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/proxyarp/impl/package-info.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/proxyarp/impl/package-info.java
new file mode 100644 (file)
index 0000000..e367552
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation of proxy ARP distribution mechanism.
+ */
+package org.onosproject.store.proxyarp.impl;
index ce25f86..3a29635 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.resource.impl;
 
 import java.util.ArrayList;
index d543473..35bdad1 100644 (file)
@@ -97,7 +97,7 @@ public class DistributedStatisticStore implements StatisticStore {
                     // register this store specific classes here
                     .build();
         }
-    };;
+    };
 
     private ExecutorService messageHandlingExecutor;
 
index 0dcc6a1..daeaa12 100644 (file)
@@ -109,7 +109,7 @@ public class ClusterCommunicationManagerTest {
         assertEquals("incorrect event node", nodeId, delegate.nodeId);
     }
 
-    enum Op { DETECTED, VANISHED, REMOVED };
+    enum Op { DETECTED, VANISHED, REMOVED }
 
     private class TestDelegate implements ClusterNodesDelegate {
 
index 7ff94c8..952393a 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.consistent.impl;
 
 import static junit.framework.TestCase.assertEquals;
index 2a3bab8..2d329d1 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.consistent.impl;
 
 import static junit.framework.TestCase.assertEquals;
index 84dc915..ab53710 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.consistent.impl;
 
 import static junit.framework.TestCase.assertEquals;
@@ -15,8 +30,8 @@ public class UpdateResultTest {
 
     @Test
     public void testGetters() {
-        Versioned<String> oldValue = new Versioned<String>("a", 1);
-        Versioned<String> newValue = new Versioned<String>("b", 2);
+        Versioned<String> oldValue = new Versioned<>("a", 1);
+        Versioned<String> newValue = new Versioned<>("b", 2);
         UpdateResult<String, String> ur =
                 new UpdateResult<>(true, "foo", "k", oldValue, newValue);
 
@@ -29,8 +44,8 @@ public class UpdateResultTest {
 
     @Test
     public void testToMapEvent() {
-        Versioned<String> oldValue = new Versioned<String>("a", 1);
-        Versioned<String> newValue = new Versioned<String>("b", 2);
+        Versioned<String> oldValue = new Versioned<>("a", 1);
+        Versioned<String> newValue = new Versioned<>("b", 2);
         UpdateResult<String, String> ur1 =
                 new UpdateResult<>(true, "foo", "k", oldValue, newValue);
         MapEvent<String, String> event1 = ur1.toMapEvent();
@@ -59,8 +74,8 @@ public class UpdateResultTest {
 
     @Test
     public void testMap() {
-        Versioned<String> oldValue = new Versioned<String>("a", 1);
-        Versioned<String> newValue = new Versioned<String>("b", 2);
+        Versioned<String> oldValue = new Versioned<>("a", 1);
+        Versioned<String> newValue = new Versioned<>("b", 2);
         UpdateResult<String, String> ur1 =
                 new UpdateResult<>(true, "foo", "k", oldValue, newValue);
         UpdateResult<Integer, Integer> ur2 = ur1.map(s -> s.length(), s -> s.length());
index 43b11f5..3a16893 100644 (file)
@@ -802,31 +802,22 @@ public class GossipDeviceStoreTest {
     @Test
     public final void testEvents() throws InterruptedException {
         final CountDownLatch addLatch = new CountDownLatch(1);
-        DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() {
-            @Override
-            public void notify(DeviceEvent event) {
-                assertEquals(DEVICE_ADDED, event.type());
-                assertDevice(DID1, SW1, event.subject());
-                addLatch.countDown();
-            }
+        DeviceStoreDelegate checkAdd = event -> {
+            assertEquals(DEVICE_ADDED, event.type());
+            assertDevice(DID1, SW1, event.subject());
+            addLatch.countDown();
         };
         final CountDownLatch updateLatch = new CountDownLatch(1);
-        DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() {
-            @Override
-            public void notify(DeviceEvent event) {
-                assertEquals(DEVICE_UPDATED, event.type());
-                assertDevice(DID1, SW2, event.subject());
-                updateLatch.countDown();
-            }
+        DeviceStoreDelegate checkUpdate = event -> {
+            assertEquals(DEVICE_UPDATED, event.type());
+            assertDevice(DID1, SW2, event.subject());
+            updateLatch.countDown();
         };
         final CountDownLatch removeLatch = new CountDownLatch(1);
-        DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() {
-            @Override
-            public void notify(DeviceEvent event) {
-                assertEquals(DEVICE_REMOVED, event.type());
-                assertDevice(DID1, SW2, event.subject());
-                removeLatch.countDown();
-            }
+        DeviceStoreDelegate checkRemove = event -> {
+            assertEquals(DEVICE_REMOVED, event.type());
+            assertDevice(DID1, SW2, event.subject());
+            removeLatch.countDown();
         };
 
         DeviceDescription description =
index d429752..76ff804 100644 (file)
@@ -101,7 +101,7 @@ public class ReplicaInfoManagerTest {
 
         // fake MastershipEvent
         eventDispatcher.post(new MastershipEvent(Type.MASTER_CHANGED, DID1,
-                new RoleInfo(NID1, new LinkedList<NodeId>())));
+                new RoleInfo(NID1, new LinkedList<>())));
 
         assertTrue(latch.await(1, TimeUnit.SECONDS));
     }
index 0f67572..c47eb27 100644 (file)
@@ -65,7 +65,7 @@ public class TimestampedTest {
 
     @Test
     public final void testValue() {
-       final Integer n = Integer.valueOf(42);
+       final Integer n = 42;
        Timestamped<Integer> tsv = new Timestamped<>(n, TS_1_1);
        assertSame(n, tsv.value());
 
index bf7af46..f8b5b86 100644 (file)
@@ -548,31 +548,22 @@ public class GossipLinkStoreTest {
         final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
 
         final CountDownLatch addLatch = new CountDownLatch(1);
-        LinkStoreDelegate checkAdd = new LinkStoreDelegate() {
-            @Override
-            public void notify(LinkEvent event) {
-                assertEquals(LINK_ADDED, event.type());
-                assertLink(linkId1, INDIRECT, event.subject());
-                addLatch.countDown();
-            }
+        LinkStoreDelegate checkAdd = event -> {
+            assertEquals(LINK_ADDED, event.type());
+            assertLink(linkId1, INDIRECT, event.subject());
+            addLatch.countDown();
         };
         final CountDownLatch updateLatch = new CountDownLatch(1);
-        LinkStoreDelegate checkUpdate = new LinkStoreDelegate() {
-            @Override
-            public void notify(LinkEvent event) {
-                assertEquals(LINK_UPDATED, event.type());
-                assertLink(linkId1, DIRECT, event.subject());
-                updateLatch.countDown();
-            }
+        LinkStoreDelegate checkUpdate = event -> {
+            assertEquals(LINK_UPDATED, event.type());
+            assertLink(linkId1, DIRECT, event.subject());
+            updateLatch.countDown();
         };
         final CountDownLatch removeLatch = new CountDownLatch(1);
-        LinkStoreDelegate checkRemove = new LinkStoreDelegate() {
-            @Override
-            public void notify(LinkEvent event) {
-                assertEquals(LINK_REMOVED, event.type());
-                assertLink(linkId1, DIRECT, event.subject());
-                removeLatch.countDown();
-            }
+        LinkStoreDelegate checkRemove = event -> {
+            assertEquals(LINK_REMOVED, event.type());
+            assertLink(linkId1, DIRECT, event.subject());
+            removeLatch.countDown();
         };
 
         linkStore.setDelegate(checkAdd);
index 59d6664..2b246b8 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-core</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index d869f60..867ce0f 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-core-store</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index febb4ad..ed02c3e 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.store.serializers;
 
 import org.onosproject.net.DefaultAnnotations;
index 1f02054..69ac057 100644 (file)
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
@@ -51,7 +51,7 @@
                     <show>package</show>
                     <excludePackageNames>@external-excludes</excludePackageNames>
                     <docfilessubdirs>true</docfilessubdirs>
-                    <doctitle>ONOS Java API (1.3.0-SNAPSHOT)</doctitle>
+                    <doctitle>ONOS Java API (1.4.0-SNAPSHOT)</doctitle>
                     <groups>
                         <group>
                             <title>Network Model &amp; Services</title>
index 9d8079a..a35d093 100644 (file)
@@ -1,4 +1,2 @@
 org.onosproject
 org.onosproject.*
-org.onosproject.rest
-org.onosproject.security
index 8f24282..f987aa9 100644 (file)
@@ -1,7 +1,28 @@
-*.impl
-*.impl.*
-
+org.onosproject.cfg.impl
+org.onosproject.cluster.impl
+org.onosproject.core.impl
+org.onosproject.event.impl
+org.onosproject.net.config.impl
+org.onosproject.net.device.impl
+org.onosproject.net.driver.impl
+org.onosproject.net.edgeservice.impl
+org.onosproject.net.flow.impl
+org.onosproject.net.flowobjective.impl
+org.onosproject.net.flowobjective.impl.composition
+org.onosproject.net.group.impl
+org.onosproject.net.host.impl
+org.onosproject.net.intent.impl
+org.onosproject.net.intent.impl.compiler
+org.onosproject.net.intent.impl.phase
+org.onosproject.net.link.impl
+org.onosproject.net.newresource.impl
+org.onosproject.net.packet.impl
+org.onosproject.net.proxyarp.impl
+org.onosproject.net.resource.impl
+org.onosproject.net.statistic.impl
+org.onosproject.net.topology.impl
 org.onosproject.json
 org.onosproject.json.*
-:org.onosproject.common.*
-org.onosproject.security.*
+org.onosproject.common.*
+org.onosproject.security.impl
+org.onosproject.security.store
index 619bbb9..58179b6 100644 (file)
@@ -7,3 +7,7 @@ org.onosproject.incubator.store.tunnel.impl
 org.onosproject.incubator.net.config.impl
 org.onosproject.incubator.net.domain.impl
 org.onosproject.incubator.store.config.impl
+org.onosproject.incubator.net.intf.impl
+org.onosproject.incubator.net.meter.impl
+org.onosproject.incubator.net.resource.label
+org.onosproject.incubator.store.meter.impl
\ No newline at end of file
index bcb1215..de9c1c6 100644 (file)
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
@@ -50,7 +50,7 @@
                 <configuration>
                     <show>package</show>
                     <docfilessubdirs>true</docfilessubdirs>
-                    <doctitle>ONOS Java API (1.3.0-SNAPSHOT)</doctitle>
+                    <doctitle>ONOS Java API (1.4.0-SNAPSHOT)</doctitle>
                     <excludePackageNames>@internal-excludes</excludePackageNames>
                     <groups>
                         <group>
index b86e2bc..749a68c 100644 (file)
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
@@ -55,7 +55,7 @@
          <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-core-serializers</artifactId>
-            <version>1.3.0-SNAPSHOT</version>
+            <version>1.4.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
index ed9794c..cd7a1b6 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.driver.pipeline;
 
 
index 0c95731..ccf7307 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.driver.pipeline;
 
 import static org.slf4j.LoggerFactory.getLogger;
index b338719..f72bde0 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.driver.pipeline;
 
 import static org.slf4j.LoggerFactory.getLogger;
index 220be86..23ef5f2 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.driver.pipeline;
 
 import static org.slf4j.LoggerFactory.getLogger;
index c4a22b6..7b36279 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index b417af5..9d7c7a6 100644 (file)
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-incubator</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 071be6a..deeac76 100644 (file)
 
 package org.onosproject.incubator.net.config.basics;
 
+import com.google.common.annotations.Beta;
+
 /**
  * Signals that an error was encountered while reading/writing configuration.
  */
+@Beta
 public class ConfigException extends Exception {
 
     /**
index 474ef6a..260d0af 100644 (file)
  */
 package org.onosproject.incubator.net.config.basics;
 
+import com.google.common.annotations.Beta;
 import org.onosproject.incubator.net.domain.IntentDomainId;
 import org.onosproject.net.config.SubjectFactory;
 
 /**
  * Set of subject factories for potential configuration subjects.
  */
+@Beta
 public final class ExtraSubjectFactories {
 
     // Construction forbidden
index 47adf5c..af2b47d 100644 (file)
@@ -17,6 +17,7 @@
 package org.onosproject.incubator.net.config.basics;
 
 import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.annotations.Beta;
 import com.google.common.collect.Sets;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.VlanId;
@@ -30,6 +31,7 @@ import java.util.Set;
 /**
  * Configuration for interfaces.
  */
+@Beta
 public class InterfaceConfig extends Config<ConnectPoint> {
     public static final String IPS = "ips";
     public static final String MAC = "mac";
index 975708d..2abaab5 100644 (file)
  */
 package org.onosproject.incubator.net.domain;
 
+import com.google.common.annotations.Beta;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.ConnectPoint;
 
 /**
  * Provides connectivity through a domain.
  */
+@Beta
 public class TunnelPrimitive extends IntentPrimitive {
 
     private final ConnectPoint one;
index 15ecf34..69d14bc 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.onosproject.incubator.net.intf;
 
+import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.Sets;
 import org.onlab.packet.MacAddress;
@@ -31,6 +32,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
  * An Interface maps network configuration information (such as addresses and
  * vlans) to a port in the network.
  */
+@Beta
 public class Interface {
     private final ConnectPoint connectPoint;
     private final Set<InterfaceIpAddress> ipAddresses;
index ad1bf34..b164df9 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.onosproject.incubator.net.intf;
 
+import com.google.common.annotations.Beta;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.VlanId;
 import org.onosproject.net.ConnectPoint;
@@ -25,6 +26,7 @@ import java.util.Set;
 /**
  * Service for interacting with interfaces.
  */
+@Beta
 public interface InterfaceService {
 
     /**
index 23663d3..1065503 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import java.util.Objects;
index bb1b316..6d5a90b 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index f20ab59..a6108bb 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index ea053af..ae88be5 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index e77fdaf..dd02ae2 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index 8936954..6fe7067 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index 72de0fb..b7f907c 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index 315abe6..75916af 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import static com.google.common.base.Preconditions.checkArgument;
index 2ef966b..821177a 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index b8e0a29..e623497 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index 93384c0..9a1472d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
index d81d7aa..9ff6a58 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import java.util.Collection;
index 02052c3..bb86d47 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import java.util.Collection;
index 2da3e81..5322d01 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import java.util.Collection;
index 6358ca9..cab9ae4 100644 (file)
@@ -1,29 +1,30 @@
 /*
+ * Copyright 2015 Open Networking Laboratory
  *
- *  * 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.
+ * 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.incubator.net.tunnel;
 
+import com.google.common.annotations.Beta;
+
 import java.time.Duration;
 import java.util.List;
 
 /**
  * Default implementation of immutable tunnel statistics.
  */
+@Beta
 public final class DefaultTunnelStatistics implements TunnelStatistics {
     private final TunnelId tunnelId;
     private final double bwUtilization;
index 964d451..57af670 100644 (file)
@@ -1,6 +1,22 @@
+/*
+ * 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.incubator.net.tunnel;
 
 
+import com.google.common.annotations.Beta;
 import org.onosproject.ui.table.CellFormatter;
 import org.onosproject.ui.table.cell.AbstractCellFormatter;
 
@@ -8,6 +24,7 @@ import org.onosproject.ui.table.cell.AbstractCellFormatter;
  * Formats a optical tunnel endpoint as "(type)/(element-id)/(port)".
  * Formats a ip tunnel endpoint as "ip".
  */
+@Beta
 public final class TunnelEndPointFormatter extends AbstractCellFormatter {
     //non-instantiable
     private TunnelEndPointFormatter() {
index 650f994..c7c9fd9 100644 (file)
@@ -1,29 +1,30 @@
 /*
+ * Copyright 2015 Open Networking Laboratory
  *
- *  * 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.
+ * 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.incubator.net.tunnel;
 
+import com.google.common.annotations.Beta;
+
 import java.time.Duration;
 import java.util.List;
 
 /**
  * Statistics of a tunnel.
  */
+@Beta
 public interface TunnelStatistics {
 
     /**
index 9d56ca2..f2b15b0 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.config.basics;
 
 import static org.junit.Assert.assertEquals;
index 5d7c02f..1055dba 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import org.junit.Test;
index 8783508..25ef57f 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import org.junit.Test;
index 1b08f7c..f41ad28 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label;
 
 import java.util.Collections;
index ae94991..25ec73d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.tunnel;
 
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
index a58e10b..28669a2 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.tunnel;
 
 import static org.hamcrest.MatcherAssert.assertThat;
index a0b5391..e60a271 100644 (file)
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-incubator</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/package-info.java b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/package-info.java
new file mode 100644 (file)
index 0000000..abdce5a
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation of service for interacting with interfaces.
+ */
+package org.onosproject.incubator.net.intf.impl;
diff --git a/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/package-info.java b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/package-info.java
new file mode 100644 (file)
index 0000000..00f42ea
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Service for interacting with interfaces.
+ */
+package org.onosproject.incubator.net.intf;
diff --git a/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/package-info.java b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/package-info.java
new file mode 100644 (file)
index 0000000..5559d90
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides implementation of the meter service APIs.
+ */
+package org.onosproject.incubator.net.meter.impl;
index 56167c4..8ecf1d2 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.net.resource.label.impl;
 
 import com.google.common.collect.Multimap;
diff --git a/framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/intf/impl/InterfaceManagerTest.java b/framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/intf/impl/InterfaceManagerTest.java
new file mode 100644 (file)
index 0000000..cc2908b
--- /dev/null
@@ -0,0 +1,287 @@
+/*
+ * 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.incubator.net.intf.impl;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
+import org.onosproject.incubator.net.config.basics.ConfigException;
+import org.onosproject.incubator.net.config.basics.InterfaceConfig;
+import org.onosproject.incubator.net.intf.Interface;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.config.Config;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigServiceAdapter;
+import org.onosproject.net.host.InterfaceIpAddress;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Unit tests for InterfaceManager.
+ */
+public class InterfaceManagerTest {
+    private static final Class<InterfaceConfig> CONFIG_CLASS = InterfaceConfig.class;
+
+    private static final int NUM_INTERFACES = 4;
+
+    private Set<ConnectPoint> subjects = Sets.newHashSet();
+    private Map<ConnectPoint, InterfaceConfig> configs = Maps.newHashMap();
+
+    private Set<Interface> interfaces = Sets.newHashSet();
+
+    private NetworkConfigListener listener;
+
+    private InterfaceManager interfaceManager;
+
+    @Before
+    public void setUp() throws Exception {
+        for (int i = 0; i < NUM_INTERFACES; i++) {
+            ConnectPoint cp = createConnectPoint(i);
+            subjects.add(cp);
+
+            Interface intf = createInterface(i);
+
+            interfaces.add(intf);
+
+            InterfaceConfig ic = new TestInterfaceConfig(cp, Sets.newHashSet(intf));
+
+            configs.put(cp, ic);
+        }
+
+        TestNetworkConfigService configService =
+                new TestNetworkConfigService(subjects, configs);
+
+        interfaceManager = new InterfaceManager();
+        interfaceManager.configService = configService;
+        interfaceManager.activate();
+    }
+
+    private Interface createInterface(int i) {
+        ConnectPoint cp = createConnectPoint(i);
+
+        InterfaceIpAddress ia = InterfaceIpAddress.valueOf("192.168." + i + ".1/24");
+
+        Interface intf = new Interface(cp,
+                Sets.newHashSet(ia),
+                MacAddress.valueOf(i),
+                VlanId.vlanId((short) i));
+
+        return intf;
+    }
+
+    private ConnectPoint createConnectPoint(int i) {
+        return  ConnectPoint.deviceConnectPoint("of:000000000000000" + i + "/1");
+    }
+
+    @Test
+    public void testGetInterfaces() throws Exception {
+        assertEquals(interfaces, interfaceManager.getInterfaces());
+    }
+
+    @Test
+    public void testGetInterfacesByPort() throws Exception {
+        ConnectPoint cp = ConnectPoint.deviceConnectPoint("of:0000000000000001/1");
+
+        Set<Interface> byPort = Collections.singleton(createInterface(1));
+
+        assertEquals(byPort, interfaceManager.getInterfacesByPort(cp));
+    }
+
+    @Test
+    public void testGetInterfacesByIp() throws Exception {
+        IpAddress ip = Ip4Address.valueOf("192.168.2.1");
+
+        Set<Interface> byIp = Collections.singleton(createInterface(2));
+
+        assertEquals(byIp, interfaceManager.getInterfacesByIp(ip));
+    }
+
+    @Test
+    public void testGetMatchingInterface() throws Exception {
+        IpAddress ip = Ip4Address.valueOf("192.168.1.100");
+
+        Interface matchingIntf = createInterface(1);
+
+        assertEquals(matchingIntf, interfaceManager.getMatchingInterface(ip));
+
+        // Searching for an IP with no match should return null
+        ip = Ip4Address.valueOf("1.1.1.1");
+
+        assertNull(interfaceManager.getMatchingInterface(ip));
+    }
+
+    @Test
+    public void testGetInterfacesByVlan() throws Exception {
+        VlanId vlanId = VlanId.vlanId((short) 1);
+
+        Set<Interface> byVlan = Collections.singleton(createInterface(1));
+
+        assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId));
+    }
+
+    @Test
+    public void testAddInterface() throws Exception {
+        // Create a new InterfaceConfig which will get added
+        VlanId vlanId = VlanId.vlanId((short) 1);
+        ConnectPoint cp = ConnectPoint.deviceConnectPoint("of:0000000000000001/2");
+        Interface newIntf = new Interface(cp,
+                Collections.emptySet(),
+                MacAddress.valueOf(100),
+                vlanId);
+
+        InterfaceConfig ic = new TestInterfaceConfig(cp, Collections.singleton(newIntf));
+
+        subjects.add(cp);
+        configs.put(cp, ic);
+        interfaces.add(newIntf);
+
+        NetworkConfigEvent event = new NetworkConfigEvent(
+                NetworkConfigEvent.Type.CONFIG_ADDED, cp, CONFIG_CLASS);
+
+        assertEquals(NUM_INTERFACES, interfaceManager.getInterfaces().size());
+
+        // Send in a config event containing a new interface config
+        listener.event(event);
+
+        // Check the new interface exists in the InterfaceManager's inventory
+        assertEquals(interfaces, interfaceManager.getInterfaces());
+        assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
+
+        // There are now two interfaces with vlan ID 1
+        Set<Interface> byVlan = Sets.newHashSet(createInterface(1), newIntf);
+        assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId));
+    }
+
+    @Test
+    public void testUpdateInterface() throws Exception {
+        ConnectPoint cp = createConnectPoint(1);
+
+        // Create an interface that is the same as the existing one, but adds a
+        // new IP address
+        Interface intf = createInterface(1);
+        Set<InterfaceIpAddress> addresses = Sets.newHashSet(intf.ipAddresses());
+        addresses.add(InterfaceIpAddress.valueOf("192.168.100.1/24"));
+        intf = new Interface(intf.connectPoint(), addresses, intf.mac(), intf.vlan());
+
+        // Create a new interface on the same connect point as the existing one
+        InterfaceIpAddress newAddr = InterfaceIpAddress.valueOf("192.168.101.1/24");
+        Interface newIntf = new Interface(cp,
+                Collections.singleton(newAddr),
+                MacAddress.valueOf(101),
+                VlanId.vlanId((short) 101));
+
+        Set<Interface> interfaces = Sets.newHashSet(intf, newIntf);
+
+        // New interface config updates the existing interface and adds a new
+        // interface to the same connect point
+        InterfaceConfig ic = new TestInterfaceConfig(cp, interfaces);
+
+        configs.put(cp, ic);
+
+        NetworkConfigEvent event = new NetworkConfigEvent(
+                NetworkConfigEvent.Type.CONFIG_UPDATED, cp, CONFIG_CLASS);
+
+        // Send in the event signalling the interfaces for this connect point
+        // have been updated
+        listener.event(event);
+
+        assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
+        assertEquals(interfaces, interfaceManager.getInterfacesByPort(cp));
+    }
+
+    @Test
+    public void testRemoveInterface() throws Exception {
+        ConnectPoint cp = createConnectPoint(1);
+
+        NetworkConfigEvent event = new NetworkConfigEvent(
+                NetworkConfigEvent.Type.CONFIG_REMOVED, cp, CONFIG_CLASS);
+
+        assertEquals(NUM_INTERFACES, interfaceManager.getInterfaces().size());
+
+        // Send in a config event removing an interface config
+        listener.event(event);
+
+        assertEquals(NUM_INTERFACES - 1, interfaceManager.getInterfaces().size());
+    }
+
+    /**
+     * Test version of NetworkConfigService which allows us to pass in subjects
+     * and InterfaceConfigs directly.
+     */
+    private class TestNetworkConfigService extends NetworkConfigServiceAdapter {
+        private final Set<ConnectPoint> subjects;
+        private final Map<ConnectPoint, InterfaceConfig> configs;
+
+        public TestNetworkConfigService(Set<ConnectPoint> subjects,
+                                        Map<ConnectPoint, InterfaceConfig> configs) {
+            this.subjects = subjects;
+            this.configs = configs;
+        }
+
+        @Override
+        public <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass,
+                                                           Class<C> configClass) {
+            return (Set<S>) subjects;
+        }
+
+        @Override
+        public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
+            return (C) configs.get(subject);
+        }
+
+        @Override
+        public void addListener(NetworkConfigListener listener) {
+            InterfaceManagerTest.this.listener = listener;
+        }
+    }
+
+    /**
+     * Test version of InterfaceConfig where we can inject interfaces directly,
+     * rather than parsing them from JSON.
+     */
+    private class TestInterfaceConfig extends InterfaceConfig {
+        private final ConnectPoint subject;
+        private final Set<Interface> interfaces;
+
+        @Override
+        public ConnectPoint subject() {
+            return subject;
+        }
+
+        public TestInterfaceConfig(ConnectPoint subject, Set<Interface> interfaces) {
+            this.subject = subject;
+            this.interfaces = interfaces;
+        }
+
+        @Override
+        public Set<Interface> getInterfaces() throws ConfigException {
+            return interfaces;
+        }
+    }
+
+}
index 6e6c229..c94243d 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 5457558..797ccc0 100644 (file)
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-incubator</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/package-info.java b/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/package-info.java
new file mode 100644 (file)
index 0000000..c1992f0
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * A distributed meter store implementation that stores meter data consistently
+ * across the cluster.
+ */
+package org.onosproject.incubator.store.meter.impl;
index a014504..d129def 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.store.resource.impl;
 
 import static org.onlab.util.Tools.groupedThreads;
index 0a6f164..1b2f651 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.incubator.store.resource.impl;
 
 import org.onosproject.store.cluster.messaging.MessageSubject;
index 2fc4f50..e535ac6 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-of</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 271e183..af678d6 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.openflow.controller;
 
 /**
index b5d4743..3a0f1a0 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.openflow.controller;
 
 /**
index 8108afe..59ef33c 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.openflow.controller;
 
 import org.jboss.netty.buffer.ChannelBuffer;
index b78124b..8b82b4a 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.openflow.controller;
 
 import java.util.List;
index 683a09a..56d4855 100644 (file)
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-of</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index deed497..437f743 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index c180879..7089216 100644 (file)
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-ovsdb</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
     </parent>
     <artifactId>onos-ovsdb-api</artifactId>
     <packaging>bundle</packaging>
index 60c1b43..b836629 100644 (file)
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-ovsdb</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index e7a7ffc..930978a 100644 (file)
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
     </parent>
     <artifactId>onos-ovsdb</artifactId>
     <name>onos-ovsdb</name>
index 856ddf0..2868845 100644 (file)
@@ -1,19 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- ~ Copyright 2014 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. -->
+<!--
+  ~ 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.
+  -->
 <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.onosproject</groupId>
                <artifactId>onos-ovsdb</artifactId>
-               <version>1.3.0-SNAPSHOT</version>
+               <version>1.4.0-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
        <artifactId>onos-ovsdb-rfc</artifactId>
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/package-info.java
new file mode 100644 (file)
index 0000000..274c8d4
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Exceptions used by the OVSDB implementation.
+ */
+package org.onosproject.ovsdb.rfc.exception;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/package-info.java
new file mode 100644 (file)
index 0000000..7edf5b4
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * RFC 7047 implementation.
+ */
+package org.onosproject.ovsdb.rfc.jsonrpc;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/package-info.java
new file mode 100644 (file)
index 0000000..1b30126
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB message definitions.
+ */
+package org.onosproject.ovsdb.rfc.message;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/package-info.java
new file mode 100644 (file)
index 0000000..eb2e7c6
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB JSON utilities.
+ */
+package org.onosproject.ovsdb.rfc.notation.json;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/package-info.java
new file mode 100644 (file)
index 0000000..1900dfe
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB primitives.
+ */
+package org.onosproject.ovsdb.rfc.notation;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/package-info.java
new file mode 100644 (file)
index 0000000..77fb9f3
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB operations.
+ */
+package org.onosproject.ovsdb.rfc.operations;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/package-info.java
new file mode 100644 (file)
index 0000000..9a27037
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB schema.
+ */
+package org.onosproject.ovsdb.rfc.schema;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/package-info.java
new file mode 100644 (file)
index 0000000..eade2e2
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB schema types.
+ */
+package org.onosproject.ovsdb.rfc.schema.type;
index 73d7ca1..9d20b98 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.ovsdb.rfc.table;
 
 import java.util.Map;
index 996e93f..1e1ab7d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.ovsdb.rfc.table;
 
 import java.util.Map;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/package-info.java
new file mode 100644 (file)
index 0000000..e235b16
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB table definitions.
+ */
+package org.onosproject.ovsdb.rfc.table;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/package-info.java
new file mode 100644 (file)
index 0000000..cc607da
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB table service definitions.
+ */
+package org.onosproject.ovsdb.rfc.tableservice;
index 00e7dbe..9ec62d3 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.ovsdb.rfc.utils;
 
 import org.onosproject.ovsdb.rfc.notation.Mutation;
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/package-info.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/package-info.java
new file mode 100644 (file)
index 0000000..0a0a4f7
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * OVSDB utilities.
+ */
+package org.onosproject.ovsdb.rfc.utils;
index 2926cbe..4588ad6 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-pcep-controller</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 0a872de..f0ed5c2 100644 (file)
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-pcep-controller</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index ef25d40..d121a83 100755 (executable)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-pcep-controller</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index e8801c2..927d83d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.protocol.ver1;
 
 import java.util.LinkedList;
index dc8c828..48a337f 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.protocol.ver1;
 
 import java.util.LinkedList;
index 37bae23..49c738f 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.protocol.ver1;
 
 import org.jboss.netty.buffer.ChannelBuffer;
index 5730026..40f89f4 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.types;
 
 import java.util.LinkedList;
index 34fad29..3e8f967 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.types;
 
 import java.util.Objects;
index 7c2f134..b8ae1e8 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.types;
 
 import java.util.Objects;
index c2b91bc..7a61245 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.types;
 
 import java.util.Objects;
index 268ac4c..e2ad069 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.types;
 
 import java.util.LinkedList;
index 1faf01a..4e8926c 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.types;
 
 import java.util.Objects;
index 0de5543..4da1ec6 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.types;
 
 import org.jboss.netty.buffer.ChannelBuffer;
index 60ff884..c39f606 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.pcepio.util;
 
 import org.jboss.netty.buffer.ChannelBuffer;
index e3d470b..f0b9f8c 100755 (executable)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index d16919b..1bce8cd 100644 (file)
@@ -33,7 +33,7 @@
     <groupId>org.onosproject</groupId>
     <artifactId>onos</artifactId>
     <packaging>pom</packaging>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
 
     <name>${project.artifactId}</name>
     <description>Open Network Operating System root project</description>
index d5231f8..e8f32ca 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index b9d9097..d010f17 100644 (file)
@@ -243,7 +243,7 @@ public class HostLocationProviderTest {
         }
 
         @Override
-        public void hostDetected(HostId hostId, HostDescription hostDescription) {
+        public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) {
             DeviceId descr = hostDescription.location().deviceId();
             if (added == null) {
                 added = descr;
index bc13793..e47d26c 100644 (file)
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/DiscoveryContext.java b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/DiscoveryContext.java
new file mode 100644 (file)
index 0000000..0cd1924
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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.provider.lldp.impl;
+
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.LinkKey;
+import org.onosproject.net.link.LinkProviderService;
+import org.onosproject.net.packet.PacketService;
+
+/**
+ * Shared context for use by link discovery.
+ */
+interface DiscoveryContext {
+
+    /**
+     * Returns the shared mastership service reference.
+     *
+     * @return mastership service
+     */
+    MastershipService mastershipService();
+
+    /**
+     * Returns the shared link provider service reference.
+     *
+     * @return link provider service
+     */
+    LinkProviderService providerService();
+
+    /**
+     * Returns the shared packet service reference.
+     *
+     * @return packet service
+     */
+    PacketService packetService();
+
+    /**
+     * Returns the probe rate in millis.
+     *
+     * @return probe rate
+     */
+    long probeRate();
+
+    /**
+     * Indicates whether to emit BDDP.
+     *
+     * @return true to emit BDDP
+     */
+    boolean useBDDP();
+
+    /**
+     * Touches the link identified by the given key to indicate that it's active.
+     *
+     * @param key link key
+     */
+    void touchLink(LinkKey key);
+}
index e9e2bfa..386d838 100644 (file)
@@ -15,9 +15,9 @@
  */
 package org.onosproject.provider.lldp.impl;
 
-import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -35,15 +35,18 @@ import org.onosproject.mastership.MastershipService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
+import org.onosproject.net.LinkKey;
 import org.onosproject.net.Port;
 import org.onosproject.net.device.DeviceEvent;
 import org.onosproject.net.device.DeviceListener;
 import org.onosproject.net.device.DeviceService;
 import org.onosproject.net.flow.DefaultTrafficSelector;
 import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.link.DefaultLinkDescription;
 import org.onosproject.net.link.LinkProvider;
 import org.onosproject.net.link.LinkProviderRegistry;
 import org.onosproject.net.link.LinkProviderService;
+import org.onosproject.net.link.LinkService;
 import org.onosproject.net.packet.PacketContext;
 import org.onosproject.net.packet.PacketPriority;
 import org.onosproject.net.packet.PacketProcessor;
@@ -57,29 +60,29 @@ import java.io.IOException;
 import java.util.Dictionary;
 import java.util.EnumSet;
 import java.util.Map;
+import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledExecutorService;
 
+import static com.google.common.base.Strings.isNullOrEmpty;
 import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
 import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.onlab.util.Tools.get;
 import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.net.Link.Type.DIRECT;
 import static org.slf4j.LoggerFactory.getLogger;
 
 /**
- * Provider which uses an OpenFlow controller to detect network
- * infrastructure links.
+ * Provider which uses LLDP and BDDP packets to detect network infrastructure links.
  */
 @Component(immediate = true)
 public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
 
     private static final String PROVIDER_NAME = "org.onosproject.provider.lldp";
 
-    private static final String PROP_USE_BDDP = "useBDDP";
-    private static final String PROP_DISABLE_LD = "disableLinkDiscovery";
-    private static final String PROP_LLDP_SUPPRESSION = "lldpSuppression";
-
-    private static final String DEFAULT_LLDP_SUPPRESSION_CONFIG = "../config/lldp_suppression.json";
+    private static final String FORMAT =
+            "Settings: enabled={}, useBDDP={}, probeRate={}, " +
+                    "staleLinkAge={}, lldpSuppression={}";
 
     private final Logger log = getLogger(getClass());
 
@@ -92,6 +95,9 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected DeviceService deviceService;
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected LinkService linkService;
+
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected PacketService packetService;
 
@@ -105,28 +111,51 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
 
     private ScheduledExecutorService executor;
 
+    // TODO: Add sanity checking for the configurable params based on the delays
+    private static final long DEVICE_SYNC_DELAY = 5;
+    private static final long LINK_PRUNER_DELAY = 3;
+
+    private static final String PROP_ENABLED = "enabled";
+    @Property(name = PROP_ENABLED, boolValue = true,
+            label = "If false, link discovery is disabled")
+    private boolean enabled = false;
+
+    private static final String PROP_USE_BDDP = "useBDDP";
     @Property(name = PROP_USE_BDDP, boolValue = true,
             label = "Use BDDP for link discovery")
     private boolean useBDDP = true;
 
-    @Property(name = PROP_DISABLE_LD, boolValue = false,
-            label = "Permanently disable link discovery")
-    private boolean disableLinkDiscovery = false;
+    private static final String PROP_PROBE_RATE = "probeRate";
+    private static final int DEFAULT_PROBE_RATE = 3_000;
+    @Property(name = PROP_PROBE_RATE, intValue = DEFAULT_PROBE_RATE,
+            label = "LLDP and BDDP probe rate specified in millis")
+    private int probeRate = DEFAULT_PROBE_RATE;
 
-    private static final long INIT_DELAY = 5;
-    private static final long DELAY = 5;
+    private static final String PROP_STALE_LINK_AGE = "staleLinkAge";
+    private static final int DEFAULT_STALE_LINK_AGE = 10_000;
+    @Property(name = PROP_STALE_LINK_AGE, intValue = DEFAULT_STALE_LINK_AGE,
+            label = "Number of millis beyond which links will be considered stale")
+    private int staleLinkAge = DEFAULT_STALE_LINK_AGE;
 
+    // FIXME: convert to use network config subsystem instead
+    private static final String PROP_LLDP_SUPPRESSION = "lldpSuppression";
+    private static final String DEFAULT_LLDP_SUPPRESSION_CONFIG = "../config/lldp_suppression.json";
     @Property(name = PROP_LLDP_SUPPRESSION, value = DEFAULT_LLDP_SUPPRESSION_CONFIG,
             label = "Path to LLDP suppression configuration file")
     private String lldpSuppression = DEFAULT_LLDP_SUPPRESSION_CONFIG;
 
-
-    private final InternalLinkProvider listener = new InternalLinkProvider();
-
+    private final DiscoveryContext context = new InternalDiscoveryContext();
     private final InternalRoleListener roleListener = new InternalRoleListener();
+    private final InternalDeviceListener deviceListener = new InternalDeviceListener();
+    private final InternalPacketProcessor packetProcessor = new InternalPacketProcessor();
 
+    // Device link discovery helpers.
     protected final Map<DeviceId, LinkDiscovery> discoverers = new ConcurrentHashMap<>();
 
+    // Most recent time a tracked link was seen; links are tracked if their
+    // destination connection point is mastered by this controller instance.
+    private final Map<LinkKey, Long> linkTimes = Maps.newConcurrentMap();
+
     private SuppressionRules rules;
     private ApplicationId appId;
 
@@ -141,39 +170,125 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
     public void activate(ComponentContext context) {
         cfgService.registerProperties(getClass());
         appId = coreService.registerApplication(PROVIDER_NAME);
-
-        // to load configuration at startup
         modified(context);
-        if (disableLinkDiscovery) {
-            log.info("LinkDiscovery has been permanently disabled by configuration");
-            return;
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        cfgService.unregisterProperties(getClass(), false);
+        disable();
+        log.info("Stopped");
+    }
+
+    @Modified
+    public void modified(ComponentContext context) {
+        Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
+
+        boolean newEnabled, newUseBddp;
+        int newProbeRate, newStaleLinkAge;
+        String newLldpSuppression;
+        try {
+            String s = get(properties, PROP_ENABLED);
+            newEnabled = isNullOrEmpty(s) || Boolean.parseBoolean(s.trim());
+
+            s = get(properties, PROP_USE_BDDP);
+            newUseBddp = isNullOrEmpty(s) || Boolean.parseBoolean(s.trim());
+
+            s = get(properties, PROP_PROBE_RATE);
+            newProbeRate = isNullOrEmpty(s) ? probeRate : Integer.parseInt(s.trim());
+
+            s = get(properties, PROP_STALE_LINK_AGE);
+            newStaleLinkAge = isNullOrEmpty(s) ? staleLinkAge : Integer.parseInt(s.trim());
+
+            s = get(properties, PROP_LLDP_SUPPRESSION);
+            newLldpSuppression = isNullOrEmpty(s) ? DEFAULT_LLDP_SUPPRESSION_CONFIG : s;
+
+        } catch (NumberFormatException e) {
+            log.warn(e.getMessage());
+            newEnabled = enabled;
+            newUseBddp = useBDDP;
+            newProbeRate = probeRate;
+            newStaleLinkAge = staleLinkAge;
+            newLldpSuppression = lldpSuppression;
+        }
+
+        boolean wasEnabled = enabled;
+
+        enabled = newEnabled;
+        useBDDP = newUseBddp;
+        probeRate = newProbeRate;
+        staleLinkAge = newStaleLinkAge;
+        lldpSuppression = newLldpSuppression;
+
+        if (!wasEnabled && enabled) {
+            enable();
+        } else if (wasEnabled && !enabled) {
+            disable();
         }
 
+        log.info(FORMAT, enabled, useBDDP, probeRate, staleLinkAge, lldpSuppression);
+    }
+
+    /**
+     * Enables link discovery processing.
+     */
+    private void enable() {
         providerService = providerRegistry.register(this);
-        deviceService.addListener(listener);
-        packetService.addProcessor(listener, PacketProcessor.advisor(0));
         masterService.addListener(roleListener);
+        deviceService.addListener(deviceListener);
+        packetService.addProcessor(packetProcessor, PacketProcessor.advisor(0));
+
+        loadSuppressionRules();
+        loadDevices();
+
+        executor = newSingleThreadScheduledExecutor(groupedThreads("onos/link", "discovery-%d"));
+        executor.scheduleAtFixedRate(new SyncDeviceInfoTask(),
+                                     DEVICE_SYNC_DELAY, DEVICE_SYNC_DELAY, SECONDS);
+        executor.scheduleAtFixedRate(new LinkPrunerTask(),
+                                     LINK_PRUNER_DELAY, LINK_PRUNER_DELAY, SECONDS);
+
+        requestIntercepts();
+    }
+
+    /**
+     * Disables link discovery processing.
+     */
+    private void disable() {
+        withdrawIntercepts();
+
+        providerRegistry.unregister(this);
+        masterService.removeListener(roleListener);
+        deviceService.removeListener(deviceListener);
+        packetService.removeProcessor(packetProcessor);
+
+        if (executor != null) {
+            executor.shutdownNow();
+        }
+        discoverers.values().forEach(LinkDiscovery::stop);
+        discoverers.clear();
 
-        LinkDiscovery ld;
+        providerService = null;
+    }
+
+    /**
+     * Loads available devices and registers their ports to be probed.
+     */
+    private void loadDevices() {
         for (Device device : deviceService.getAvailableDevices()) {
             if (rules.isSuppressed(device)) {
                 log.debug("LinkDiscovery from {} disabled by configuration", device.id());
                 continue;
             }
-            ld = new LinkDiscovery(device, packetService, masterService,
-                                   providerService, useBDDP);
+            LinkDiscovery ld = new LinkDiscovery(device, context);
             discoverers.put(device.id(), ld);
             addPorts(ld, device.id());
         }
-
-        executor = newSingleThreadScheduledExecutor(groupedThreads("onos/device", "sync-%d"));
-        executor.scheduleAtFixedRate(new SyncDeviceInfoTask(), INIT_DELAY, DELAY, SECONDS);
-
-        requestIntercepts();
-
-        log.info("Started");
     }
 
+    /**
+     * Adds ports of the specified device to the specified discovery helper.
+     */
     private void addPorts(LinkDiscovery discoverer, DeviceId deviceId) {
         for (Port p : deviceService.getPorts(deviceId)) {
             if (rules.isSuppressed(p)) {
@@ -185,54 +300,12 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
         }
     }
 
-    @Deactivate
-    public void deactivate() {
-        cfgService.unregisterProperties(getClass(), false);
-        if (disableLinkDiscovery) {
-            return;
-        }
-
-        withdrawIntercepts();
-
-        providerRegistry.unregister(this);
-        deviceService.removeListener(listener);
-        packetService.removeProcessor(listener);
-        masterService.removeListener(roleListener);
-
-        executor.shutdownNow();
-        discoverers.values().forEach(LinkDiscovery::stop);
-        discoverers.clear();
-        providerService = null;
-
-        log.info("Stopped");
-    }
-
-    @Modified
-    public void modified(ComponentContext context) {
-        if (context == null) {
-            loadSuppressionRules();
-            return;
-        }
-        @SuppressWarnings("rawtypes")
-        Dictionary properties = context.getProperties();
-
-        String s = get(properties, PROP_DISABLE_LD);
-        if (!Strings.isNullOrEmpty(s)) {
-            disableLinkDiscovery = Boolean.valueOf(s);
-        }
-        s = get(properties, PROP_USE_BDDP);
-        if (!Strings.isNullOrEmpty(s)) {
-            useBDDP = Boolean.valueOf(s);
-        }
-        s = get(properties, PROP_LLDP_SUPPRESSION);
-        if (!Strings.isNullOrEmpty(s)) {
-            lldpSuppression = s;
-        }
-        requestIntercepts();
-        loadSuppressionRules();
-    }
 
+    /**
+     * Loads LLDP suppression rules.
+     */
     private void loadSuppressionRules() {
+        // FIXME: convert to use network configuration
         SuppressionRulesStore store = new SuppressionRulesStore(lldpSuppression);
         try {
             log.info("Reading suppression rules from {}", lldpSuppression);
@@ -249,7 +322,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
     }
 
     /**
-     * Request packet intercepts.
+     * Requests packet intercepts.
      */
     private void requestIntercepts() {
         TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
@@ -265,7 +338,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
     }
 
     /**
-     * Withdraw packet intercepts.
+     * Withdraws packet intercepts.
      */
     private void withdrawIntercepts() {
         TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
@@ -275,13 +348,10 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
         packetService.cancelPackets(selector.build(), PacketPriority.CONTROL, appId);
     }
 
-    private LinkDiscovery createLinkDiscovery(Device device) {
-        return new LinkDiscovery(device, packetService, masterService,
-                                 providerService, useBDDP);
-    }
-
+    /**
+     * Processes device mastership role changes.
+     */
     private class InternalRoleListener implements MastershipListener {
-
         @Override
         public void event(MastershipEvent event) {
             if (MastershipEvent.Type.BACKUPS_CHANGED.equals(event.type())) {
@@ -298,22 +368,18 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
             if (rules.isSuppressed(device)) {
                 return;
             }
-            synchronized (discoverers) {
-                if (!discoverers.containsKey(deviceId)) {
-                    // ideally, should never reach here
-                    log.debug("Device mastership changed ({}) {}", event.type(), deviceId);
-                    discoverers.put(deviceId, createLinkDiscovery(device));
-                }
-            }
+            discoverers.computeIfAbsent(deviceId, k -> new LinkDiscovery(device, context));
         }
 
     }
 
-    private class InternalLinkProvider implements PacketProcessor, DeviceListener {
-
+    /**
+     * Processes device events.
+     */
+    private class InternalDeviceListener implements DeviceListener {
         @Override
         public void event(DeviceEvent event) {
-            LinkDiscovery ld = null;
+            LinkDiscovery ld;
             Device device = event.subject();
             Port port = event.port();
             if (device == null) {
@@ -333,7 +399,7 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
                                 return;
                             }
                             log.debug("Device added ({}) {}", event.type(), deviceId);
-                            discoverers.put(deviceId, createLinkDiscovery(device));
+                            discoverers.put(deviceId, new LinkDiscovery(device, context));
                         } else {
                             if (ld.isStopped()) {
                                 log.debug("Device restarted ({}) {}", event.type(), deviceId);
@@ -400,7 +466,12 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
                     log.debug("Unknown event {}", event);
             }
         }
+    }
 
+    /**
+     * Processes incoming packets.
+     */
+    private class InternalPacketProcessor implements PacketProcessor {
         @Override
         public void process(PacketContext context) {
             if (context == null) {
@@ -417,8 +488,10 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
         }
     }
 
+    /**
+     * Auxiliary task to keep device ports up to date.
+     */
     private final class SyncDeviceInfoTask implements Runnable {
-
         @Override
         public void run() {
             if (Thread.currentThread().isInterrupted()) {
@@ -433,20 +506,90 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider {
                     }
                     DeviceId did = dev.id();
                     synchronized (discoverers) {
-                        LinkDiscovery discoverer = discoverers.get(did);
-                        if (discoverer == null) {
-                            discoverer = createLinkDiscovery(dev);
-                            discoverers.put(did, discoverer);
-                        }
-
-                        addPorts(discoverer, did);
+                        LinkDiscovery ld = discoverers
+                                .computeIfAbsent(did, k -> new LinkDiscovery(dev, context));
+                        addPorts(ld, did);
                     }
                 }
             } catch (Exception e) {
-                // catch all Exception to avoid Scheduled task being suppressed.
+                // Catch all exceptions to avoid task being suppressed
                 log.error("Exception thrown during synchronization process", e);
             }
         }
     }
 
+    /**
+     * Auxiliary task for pruning stale links.
+     */
+    private class LinkPrunerTask implements Runnable {
+        @Override
+        public void run() {
+            if (Thread.currentThread().isInterrupted()) {
+                log.info("Interrupted, quitting");
+                return;
+            }
+
+            try {
+                // TODO: There is still a slight possibility of mastership
+                // change occurring right with link going stale. This will
+                // result in the stale link not being pruned.
+                Maps.filterEntries(linkTimes, e -> {
+                    if (!masterService.isLocalMaster(e.getKey().dst().deviceId())) {
+                        return true;
+                    }
+                    if (isStale(e.getValue())) {
+                        providerService.linkVanished(new DefaultLinkDescription(e.getKey().src(),
+                                                                                e.getKey().dst(),
+                                                                                DIRECT));
+                        return true;
+                    }
+                    return false;
+                }).clear();
+
+            } catch (Exception e) {
+                // Catch all exceptions to avoid task being suppressed
+                log.error("Exception thrown during link pruning process", e);
+            }
+        }
+
+        private boolean isStale(long lastSeen) {
+            return lastSeen < System.currentTimeMillis() - staleLinkAge;
+        }
+    }
+
+    /**
+     * Provides processing context for the device link discovery helpers.
+     */
+    private class InternalDiscoveryContext implements DiscoveryContext {
+        @Override
+        public MastershipService mastershipService() {
+            return masterService;
+        }
+
+        @Override
+        public LinkProviderService providerService() {
+            return providerService;
+        }
+
+        @Override
+        public PacketService packetService() {
+            return packetService;
+        }
+
+        @Override
+        public long probeRate() {
+            return probeRate;
+        }
+
+        @Override
+        public boolean useBDDP() {
+            return useBDDP;
+        }
+
+        @Override
+        public void touchLink(LinkKey key) {
+            linkTimes.put(key, System.currentTimeMillis());
+        }
+    }
+
 }
index a81eeb1..8cdfd50 100644 (file)
  */
 package org.onosproject.provider.lldp.impl;
 
-import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import org.jboss.netty.util.Timeout;
 import org.jboss.netty.util.TimerTask;
 import org.onlab.packet.Ethernet;
 import org.onlab.packet.ONOSLLDP;
 import org.onlab.util.Timer;
-import org.onosproject.mastership.MastershipService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Link.Type;
+import org.onosproject.net.LinkKey;
 import org.onosproject.net.Port;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.link.DefaultLinkDescription;
 import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkProviderService;
 import org.onosproject.net.packet.DefaultOutboundPacket;
 import org.onosproject.net.packet.OutboundPacket;
 import org.onosproject.net.packet.PacketContext;
-import org.onosproject.net.packet.PacketService;
 import org.slf4j.Logger;
 
 import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
 
-import static com.google.common.base.Preconditions.checkNotNull;
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.onosproject.net.PortNumber.portNumber;
 import static org.onosproject.net.flow.DefaultTrafficTreatment.builder;
 import static org.slf4j.LoggerFactory.getLogger;
 
-// TODO: add 'fast discovery' mode: drop LLDPs in destination switch but listen for flow_removed messages
-// FIXME: add ability to track links using port pairs or the link inventory
-
 /**
  * Run discovery process from a physical switch. Ports are initially labeled as
  * slow ports. When an LLDP is successfully received, label the remote port as
@@ -60,57 +50,36 @@ import static org.slf4j.LoggerFactory.getLogger;
  * LLDP, send an LLDP for a single slow port. Based on FlowVisor topology
  * discovery implementation.
  */
-public class LinkDiscovery implements TimerTask {
+class LinkDiscovery implements TimerTask {
 
     private final Logger log = getLogger(getClass());
 
-    private static final short MAX_PROBE_COUNT = 3; // probes to send before link is removed
-    private static final short DEFAULT_PROBE_RATE = 3000; // millis
     private static final String SRC_MAC = "DE:AD:BE:EF:BA:11";
-    private static final String SERVICE_NULL = "Service cannot be null";
 
     private final Device device;
-
-    // send 1 probe every probeRate milliseconds
-    private final long probeRate = DEFAULT_PROBE_RATE;
-
-    private final Set<Long> slowPorts = Sets.newConcurrentHashSet();
-    // ports, known to have incoming links
-    private final Set<Long> fastPorts = Sets.newConcurrentHashSet();
-
-    // number of unacknowledged probes per port
-    private final Map<Long, AtomicInteger> portProbeCount = Maps.newHashMap();
+    private final DiscoveryContext context;
 
     private final ONOSLLDP lldpPacket;
     private final Ethernet ethPacket;
     private Ethernet bddpEth;
-    private final boolean useBDDP;
 
     private Timeout timeout;
     private volatile boolean isStopped;
 
-    private final LinkProviderService linkProvider;
-    private final PacketService pktService;
-    private final MastershipService mastershipService;
+    // Set of ports to be probed
+    private final Set<Long> ports = Sets.newConcurrentHashSet();
 
     /**
      * Instantiates discovery manager for the given physical switch. Creates a
      * generic LLDP packet that will be customized for the port it is sent out on.
      * Starts the the timer for the discovery process.
      *
-     * @param device          the physical switch
-     * @param pktService      packet service
-     * @param masterService   mastership service
-     * @param providerService link provider service
-     * @param useBDDP         flag to also use BDDP for discovery
+     * @param device  the physical switch
+     * @param context discovery context
      */
-    public LinkDiscovery(Device device, PacketService pktService,
-                         MastershipService masterService,
-                         LinkProviderService providerService, Boolean... useBDDP) {
+    LinkDiscovery(Device device, DiscoveryContext context) {
         this.device = device;
-        this.linkProvider = checkNotNull(providerService, SERVICE_NULL);
-        this.pktService = checkNotNull(pktService, SERVICE_NULL);
-        this.mastershipService = checkNotNull(masterService, SERVICE_NULL);
+        this.context = context;
 
         lldpPacket = new ONOSLLDP();
         lldpPacket.setChassisId(device.chassisId());
@@ -122,15 +91,11 @@ public class LinkDiscovery implements TimerTask {
         ethPacket.setPayload(this.lldpPacket);
         ethPacket.setPad(true);
 
-        this.useBDDP = useBDDP.length > 0 ? useBDDP[0] : false;
-        if (this.useBDDP) {
-            bddpEth = new Ethernet();
-            bddpEth.setPayload(lldpPacket);
-            bddpEth.setEtherType(Ethernet.TYPE_BSN);
-            bddpEth.setDestinationMACAddress(ONOSLLDP.BDDP_MULTICAST);
-            bddpEth.setPad(true);
-            log.info("Using BDDP to discover network");
-        }
+        bddpEth = new Ethernet();
+        bddpEth.setPayload(lldpPacket);
+        bddpEth.setEtherType(Ethernet.TYPE_BSN);
+        bddpEth.setDestinationMACAddress(ONOSLLDP.BDDP_MULTICAST);
+        bddpEth.setPad(true);
 
         isStopped = true;
         start();
@@ -138,82 +103,52 @@ public class LinkDiscovery implements TimerTask {
 
     }
 
-    /**
-     * Add physical port port to discovery process.
-     * Send out initial LLDP and label it as slow port.
-     *
-     * @param port the port
-     */
-    public void addPort(Port port) {
-        boolean newPort = false;
-        synchronized (this) {
-            if (!containsPort(port.number().toLong())) {
-                newPort = true;
-                slowPorts.add(port.number().toLong());
-            }
+    synchronized void stop() {
+        if (!isStopped) {
+            isStopped = true;
+            timeout.cancel();
+        } else {
+            log.warn("LinkDiscovery stopped multiple times?");
         }
+    }
 
-        boolean isMaster = mastershipService.isLocalMaster(device.id());
-        if (newPort && isMaster) {
-            log.debug("Sending init probe to port {}@{}", port.number().toLong(), device.id());
-            sendProbes(port.number().toLong());
+    synchronized void start() {
+        if (isStopped) {
+            isStopped = false;
+            timeout = Timer.getTimer().newTimeout(this, 0, MILLISECONDS);
+        } else {
+            log.warn("LinkDiscovery started multiple times?");
         }
     }
 
-    /**
-     * Removes physical port from discovery process.
-     *
-     * @param port the port
-     */
-    public void removePort(Port port) {
-        // Ignore ports that are not on this switch
-        long portnum = port.number().toLong();
-        synchronized (this) {
-            if (slowPorts.contains(portnum)) {
-                slowPorts.remove(portnum);
-
-            } else if (fastPorts.contains(portnum)) {
-                fastPorts.remove(portnum);
-                portProbeCount.remove(portnum);
-                // no iterator to update
-            } else {
-                log.warn("Tried to dynamically remove non-existing port {}", portnum);
-            }
-        }
+    synchronized boolean isStopped() {
+        return isStopped || timeout.isCancelled();
     }
 
     /**
-     * Method called by remote port to acknowledge receipt of LLDP sent by
-     * this port. If slow port, updates label to fast. If fast port, decrements
-     * number of unacknowledged probes.
+     * Add physical port port to discovery process.
+     * Send out initial LLDP and label it as slow port.
      *
-     * @param portNumber the port
+     * @param port the port
      */
-    public void ackProbe(Long portNumber) {
-        synchronized (this) {
-            if (slowPorts.contains(portNumber)) {
-                log.debug("Setting slow port to fast: {}:{}", device.id(), portNumber);
-                slowPorts.remove(portNumber);
-                fastPorts.add(portNumber);
-                portProbeCount.put(portNumber, new AtomicInteger(0));
-            } else if (fastPorts.contains(portNumber)) {
-                portProbeCount.get(portNumber).set(0);
-            } else {
-                log.debug("Got ackProbe for non-existing port: {}", portNumber);
-            }
+    void addPort(Port port) {
+        boolean newPort = ports.add(port.number().toLong());
+        boolean isMaster = context.mastershipService().isLocalMaster(device.id());
+        if (newPort && isMaster) {
+            log.debug("Sending initial probe to port {}@{}", port.number().toLong(), device.id());
+            sendProbes(port.number().toLong());
         }
     }
 
-
     /**
-     * Handles an incoming LLDP packet. Creates link in topology and sends ACK
-     * to port where LLDP originated.
+     * Handles an incoming LLDP packet. Creates link in topology and adds the
+     * link for staleness tracking.
      *
-     * @param context packet context
+     * @param packetContext packet context
      * @return true if handled
      */
-    public boolean handleLLDP(PacketContext context) {
-        Ethernet eth = context.inPacket().parsed();
+    boolean handleLLDP(PacketContext packetContext) {
+        Ethernet eth = packetContext.inPacket().parsed();
         if (eth == null) {
             return false;
         }
@@ -221,10 +156,9 @@ public class LinkDiscovery implements TimerTask {
         ONOSLLDP onoslldp = ONOSLLDP.parseONOSLLDP(eth);
         if (onoslldp != null) {
             PortNumber srcPort = portNumber(onoslldp.getPort());
-            PortNumber dstPort = context.inPacket().receivedFrom().port();
+            PortNumber dstPort = packetContext.inPacket().receivedFrom().port();
             DeviceId srcDeviceId = DeviceId.deviceId(onoslldp.getDeviceString());
-            DeviceId dstDeviceId = context.inPacket().receivedFrom().deviceId();
-            ackProbe(dstPort.toLong());
+            DeviceId dstDeviceId = packetContext.inPacket().receivedFrom().deviceId();
 
             ConnectPoint src = new ConnectPoint(srcDeviceId, srcPort);
             ConnectPoint dst = new ConnectPoint(dstDeviceId, dstPort);
@@ -234,7 +168,8 @@ public class LinkDiscovery implements TimerTask {
                     new DefaultLinkDescription(src, dst, Type.INDIRECT);
 
             try {
-                linkProvider.linkDetected(ld);
+                context.providerService().linkDetected(ld);
+                context.touchLink(LinkKey.linkKey(src, dst));
             } catch (IllegalStateException e) {
                 return true;
             }
@@ -256,61 +191,14 @@ public class LinkDiscovery implements TimerTask {
         if (isStopped()) {
             return;
         }
-        if (!mastershipService.isLocalMaster(device.id())) {
-            if (!isStopped()) {
-                // reschedule timer
-                timeout = Timer.getTimer().newTimeout(this, probeRate, MILLISECONDS);
-            }
-            return;
-        }
 
-        log.trace("Sending probes from {}", device.id());
-        synchronized (this) {
-            Iterator<Long> fastIterator = fastPorts.iterator();
-            while (fastIterator.hasNext()) {
-                long portNumber = fastIterator.next();
-                int probeCount = portProbeCount.get(portNumber).getAndIncrement();
-
-                if (probeCount < LinkDiscovery.MAX_PROBE_COUNT) {
-                    log.trace("Sending fast probe to port {}", portNumber);
-                    sendProbes(portNumber);
-
-                } else {
-                    // Link down, demote to slowPorts; update fast and slow ports
-                    fastIterator.remove();
-                    slowPorts.add(portNumber);
-                    portProbeCount.remove(portNumber);
-
-                    ConnectPoint cp = new ConnectPoint(device.id(), portNumber(portNumber));
-                    log.debug("Link down -> {}", cp);
-                    linkProvider.linksVanished(cp);
-                }
-            }
-
-            // send a probe for the next slow port
-            for (long portNumber : slowPorts) {
-                log.trace("Sending slow probe to port {}", portNumber);
-                sendProbes(portNumber);
-            }
+        if (context.mastershipService().isLocalMaster(device.id())) {
+            log.trace("Sending probes from {}", device.id());
+            ports.forEach(this::sendProbes);
         }
 
         if (!isStopped()) {
-            // reschedule timer
-            timeout = Timer.getTimer().newTimeout(this, probeRate, MILLISECONDS);
-        }
-    }
-
-    public synchronized void stop() {
-        isStopped = true;
-        timeout.cancel();
-    }
-
-    public synchronized void start() {
-        if (isStopped) {
-            isStopped = false;
-            timeout = Timer.getTimer().newTimeout(this, 0, MILLISECONDS);
-        } else {
-            log.warn("LinkDiscovery started multiple times?");
+            timeout = Timer.getTimer().newTimeout(this, context.probeRate(), MILLISECONDS);
         }
     }
 
@@ -351,19 +239,15 @@ public class LinkDiscovery implements TimerTask {
     private void sendProbes(Long portNumber) {
         log.trace("Sending probes out to {}@{}", portNumber, device.id());
         OutboundPacket pkt = createOutBoundLLDP(portNumber);
-        pktService.emit(pkt);
-        if (useBDDP) {
+        context.packetService().emit(pkt);
+        if (context.useBDDP()) {
             OutboundPacket bpkt = createOutBoundBDDP(portNumber);
-            pktService.emit(bpkt);
+            context.packetService().emit(bpkt);
         }
     }
 
-    public boolean containsPort(Long portNumber) {
-        return slowPorts.contains(portNumber) || fastPorts.contains(portNumber);
-    }
-
-    public synchronized boolean isStopped() {
-        return isStopped || timeout.isCancelled();
+    boolean containsPort(long portNumber) {
+        return ports.contains(portNumber);
     }
 
 }
index 1d63a15..b4b7b7b 100644 (file)
@@ -48,6 +48,7 @@ import org.onosproject.net.link.LinkDescription;
 import org.onosproject.net.link.LinkProvider;
 import org.onosproject.net.link.LinkProviderRegistry;
 import org.onosproject.net.link.LinkProviderService;
+import org.onosproject.net.link.LinkServiceAdapter;
 import org.onosproject.net.packet.DefaultInboundPacket;
 import org.onosproject.net.packet.InboundPacket;
 import org.onosproject.net.packet.OutboundPacket;
@@ -79,7 +80,8 @@ public class LLDPLinkProviderTest {
     private static Port pd4;
 
     private final LLDPLinkProvider provider = new LLDPLinkProvider();
-    private final TestLinkRegistry linkService = new TestLinkRegistry();
+    private final TestLinkRegistry linkRegistry = new TestLinkRegistry();
+    private final TestLinkService linkService = new TestLinkService();
     private final TestPacketService packetService = new TestPacketService();
     private final TestDeviceService deviceService = new TestDeviceService();
     private final TestMasterShipService masterService = new TestMasterShipService();
@@ -104,11 +106,11 @@ public class LLDPLinkProviderTest {
         provider.coreService = coreService;
 
         provider.deviceService = deviceService;
+        provider.linkService = linkService;
         provider.packetService = packetService;
-        provider.providerRegistry = linkService;
+        provider.providerRegistry = linkRegistry;
         provider.masterService = masterService;
 
-
         provider.activate(null);
     }
 
@@ -499,4 +501,6 @@ public class LLDPLinkProviderTest {
     }
 
 
+    private class TestLinkService extends LinkServiceAdapter {
+    }
 }
index 52f0bb1..03d431a 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.provider.lldp.impl;
 
 import static org.junit.Assert.*;
index 6a3d1a2..bc7491e 100644 (file)
@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <!--
-  ~ 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      
+  ~ 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.
   -->
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
index 8cf56b3..dbd0a52 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-netconf-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index be05e3c..3465bc3 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-netconf-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 8ee4c4e..7ccd552 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-netconf-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index ac08dd4..f73940f 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index ce54758..1db0753 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 7c41017..9dbae8a 100644 (file)
@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <!--
-  ~ 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      
+  ~ 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.
   -->
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
index 62e5eb8..cb55463 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-of-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 5f27d42..0408f73 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-of-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 24c430e..1f65656 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-of-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 97ac5ff..049ccaf 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-of-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index d66ba09..f923c6f 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.provider.of.group.impl;
 
 import com.google.common.collect.Lists;
index 9de5c1b..55068cd 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-of-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index f7f62d8..cc2316c 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-of-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 99ff664..c098a60 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 7bb506b..b615d12 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-ovsdb-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index e5010fa..8f9b834 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-ovsdb-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>onos-ovsdb-provider-device</artifactId>
index 0bd8855..f54a496 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-ovsdb-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>onos-ovsdb-provider-host</artifactId>
index 8d2fd14..0e3e156 100644 (file)
-/*\r
- * Copyright 2015 Open Networking Laboratory\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onosproject.ovsdb.provider.host;\r
-\r
-import static com.google.common.base.Preconditions.checkNotNull;\r
-import static org.onlab.util.Tools.toHex;\r
-import static org.slf4j.LoggerFactory.getLogger;\r
-\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-\r
-import org.apache.felix.scr.annotations.Activate;\r
-import org.apache.felix.scr.annotations.Component;\r
-import org.apache.felix.scr.annotations.Deactivate;\r
-import org.apache.felix.scr.annotations.Reference;\r
-import org.apache.felix.scr.annotations.ReferenceCardinality;\r
-import org.apache.felix.scr.annotations.Service;\r
-import org.onlab.packet.VlanId;\r
-import org.onosproject.core.CoreService;\r
-import org.onosproject.net.DefaultAnnotations;\r
-import org.onosproject.net.DeviceId;\r
-import org.onosproject.net.Host;\r
-import org.onosproject.net.HostId;\r
-import org.onosproject.net.HostLocation;\r
-import org.onosproject.net.PortNumber;\r
-import org.onosproject.net.SparseAnnotations;\r
-import org.onosproject.net.host.DefaultHostDescription;\r
-import org.onosproject.net.host.HostDescription;\r
-import org.onosproject.net.host.HostProvider;\r
-import org.onosproject.net.host.HostProviderRegistry;\r
-import org.onosproject.net.host.HostProviderService;\r
-import org.onosproject.net.host.HostService;\r
-import org.onosproject.net.provider.AbstractProvider;\r
-import org.onosproject.net.provider.ProviderId;\r
-import org.onosproject.ovsdb.controller.EventSubject;\r
-import org.onosproject.ovsdb.controller.OvsdbController;\r
-import org.onosproject.ovsdb.controller.OvsdbEvent;\r
-import org.onosproject.ovsdb.controller.OvsdbEventListener;\r
-import org.onosproject.ovsdb.controller.OvsdbEventSubject;\r
-import org.slf4j.Logger;\r
-\r
-/**\r
- * Provider which uses an ovsdb controller to detect host.\r
- */\r
-@Component(immediate = true)\r
-@Service\r
-public class OvsdbHostProvider extends AbstractProvider implements HostProvider {\r
-    private final Logger log = getLogger(getClass());\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected HostProviderRegistry providerRegistry;\r
-\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected HostService hostService;\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected CoreService coreService;\r
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)\r
-    protected OvsdbController controller;\r
-\r
-    private HostProviderService providerService;\r
-    private OvsdbEventListener innerEventListener = new InnerOvsdbEventListener();\r
-\r
-    @Activate\r
-    public void activate() {\r
-        providerService = providerRegistry.register(this);\r
-        controller.addOvsdbEventListener(innerEventListener);\r
-        log.info("Started");\r
-    }\r
-\r
-    @Deactivate\r
-    public void deactivate() {\r
-        providerRegistry.unregister(this);\r
-        providerService = null;\r
-        log.info("Stopped");\r
-    }\r
-\r
-    public OvsdbHostProvider() {\r
-        super(new ProviderId("ovsdb", "org.onosproject.ovsdb.provider.host"));\r
-    }\r
-\r
-    @Override\r
-    public void triggerProbe(Host host) {\r
-        log.info("Triggering probe on host {}", host);\r
-    }\r
-\r
-    private class InnerOvsdbEventListener implements OvsdbEventListener {\r
-\r
-        @Override\r
-        public void handle(OvsdbEvent<EventSubject> event) {\r
-            OvsdbEventSubject subject = null;\r
-            if (event.subject() instanceof OvsdbEventSubject) {\r
-                subject = (OvsdbEventSubject) event.subject();\r
-            }\r
-            checkNotNull(subject, "EventSubject is not null");\r
-            // If ifaceid is null,it indicates this is not a vm port.\r
-            if (subject.ifaceid() == null) {\r
-                return;\r
-            }\r
-            switch (event.type()) {\r
-            case PORT_ADDED:\r
-                HostId hostId = HostId.hostId(subject.hwAddress(), null);\r
-                DeviceId deviceId = DeviceId.deviceId(uri(subject.dpid().value()));\r
-                PortNumber portNumber = PortNumber.portNumber(subject\r
-                        .portNumber().value(), subject.portName().value());\r
-                HostLocation loaction = new HostLocation(deviceId, portNumber,\r
-                                                         0L);\r
-                SparseAnnotations annotations = DefaultAnnotations.builder()\r
-                        .set("ifaceid", subject.ifaceid().value()).build();\r
-                HostDescription hostDescription = new DefaultHostDescription(\r
-                                                                             subject.hwAddress(),\r
-                                                                             VlanId.vlanId(),\r
-                                                                             loaction,\r
-                                                                             annotations);\r
-                providerService.hostDetected(hostId, hostDescription);\r
-                break;\r
-            case PORT_REMOVED:\r
-                HostId host = HostId.hostId(subject.hwAddress(), null);\r
-                providerService.hostVanished(host);\r
-                break;\r
-            default:\r
-                break;\r
-            }\r
-\r
-        }\r
-\r
-    }\r
-\r
-    public URI uri(String value) {\r
-        try {\r
-            return new URI("of", toHex(Long.valueOf(value)), null);\r
-        } catch (URISyntaxException e) {\r
-            return null;\r
-        }\r
-    }\r
-}\r
+/*
+ * 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.ovsdb.provider.host;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.toHex;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+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.apache.felix.scr.annotations.Service;
+import org.onlab.packet.VlanId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Host;
+import org.onosproject.net.HostId;
+import org.onosproject.net.HostLocation;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.host.DefaultHostDescription;
+import org.onosproject.net.host.HostDescription;
+import org.onosproject.net.host.HostProvider;
+import org.onosproject.net.host.HostProviderRegistry;
+import org.onosproject.net.host.HostProviderService;
+import org.onosproject.net.host.HostService;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.ovsdb.controller.EventSubject;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbEvent;
+import org.onosproject.ovsdb.controller.OvsdbEventListener;
+import org.onosproject.ovsdb.controller.OvsdbEventSubject;
+import org.slf4j.Logger;
+
+/**
+ * Provider which uses an ovsdb controller to detect host.
+ */
+@Component(immediate = true)
+@Service
+public class OvsdbHostProvider extends AbstractProvider implements HostProvider {
+    private final Logger log = getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected HostProviderRegistry providerRegistry;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected HostService hostService;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected OvsdbController controller;
+
+    private HostProviderService providerService;
+    private OvsdbEventListener innerEventListener = new InnerOvsdbEventListener();
+
+    @Activate
+    public void activate() {
+        providerService = providerRegistry.register(this);
+        controller.addOvsdbEventListener(innerEventListener);
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        providerRegistry.unregister(this);
+        providerService = null;
+        log.info("Stopped");
+    }
+
+    public OvsdbHostProvider() {
+        super(new ProviderId("ovsdb", "org.onosproject.ovsdb.provider.host"));
+    }
+
+    @Override
+    public void triggerProbe(Host host) {
+        log.info("Triggering probe on host {}", host);
+    }
+
+    private class InnerOvsdbEventListener implements OvsdbEventListener {
+
+        @Override
+        public void handle(OvsdbEvent<EventSubject> event) {
+            OvsdbEventSubject subject = null;
+            if (event.subject() instanceof OvsdbEventSubject) {
+                subject = (OvsdbEventSubject) event.subject();
+            }
+            checkNotNull(subject, "EventSubject is not null");
+            // If ifaceid is null,it indicates this is not a vm port.
+            if (subject.ifaceid() == null) {
+                return;
+            }
+            switch (event.type()) {
+            case PORT_ADDED:
+                HostId hostId = HostId.hostId(subject.hwAddress(), null);
+                DeviceId deviceId = DeviceId.deviceId(uri(subject.dpid().value()));
+                PortNumber portNumber = PortNumber.portNumber(subject
+                        .portNumber().value(), subject.portName().value());
+                HostLocation loaction = new HostLocation(deviceId, portNumber,
+                                                         0L);
+                SparseAnnotations annotations = DefaultAnnotations.builder()
+                        .set("ifaceid", subject.ifaceid().value()).build();
+                HostDescription hostDescription = new DefaultHostDescription(
+                                                                             subject.hwAddress(),
+                                                                             VlanId.vlanId(),
+                                                                             loaction,
+                                                                             annotations);
+                providerService.hostDetected(hostId, hostDescription);
+                break;
+            case PORT_REMOVED:
+                HostId host = HostId.hostId(subject.hwAddress(), null);
+                providerService.hostVanished(host);
+                break;
+            default:
+                break;
+            }
+
+        }
+
+    }
+
+    public URI uri(String value) {
+        try {
+            return new URI("of", toHex(Long.valueOf(value)), null);
+        } catch (URISyntaxException e) {
+            return null;
+        }
+    }
+}
index bf18606..ad720c8 100644 (file)
@@ -143,7 +143,7 @@ public class OvsdbHostProviderTest {
         }
 
         @Override
-        public void hostDetected(HostId hostId, HostDescription hostDescription) {
+        public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) {
             DeviceId descr = hostDescription.location().deviceId();
             if (added == null) {
                 added = descr;
index bf215bc..cce971d 100644 (file)
@@ -1,4 +1,19 @@
 <?xml version="1.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.
+  -->
 <project
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
     xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>onos-ovsdb-providers</artifactId>
index 46ea585..3eae258 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-ovsdb-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>onos-ovsdb-provider-tunnel</artifactId>
index 65a221b..ee20536 100644 (file)
@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <!--
-  ~ 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      
+  ~ 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.
   -->
 <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
index bce88d9..96a04e8 100644 (file)
@@ -1,10 +1,25 @@
+<!--
+  ~ 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.
+  -->
 <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/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
                <groupId>org.onosproject</groupId>
                <artifactId>onos-pcep-providers</artifactId>
-               <version>1.3.0-SNAPSHOT</version>
+               <version>1.4.0-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 66a7114..0f885e6 100644 (file)
@@ -1,9 +1,24 @@
+<!--
+  ~ 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.
+  -->
 <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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.onosproject</groupId>
     <artifactId>onos-providers</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
     <relativePath>../pom.xml</relativePath>
   </parent>
   <artifactId>onos-pcep-providers</artifactId>
index cd8589b..ff14b65 100644 (file)
@@ -1,9 +1,24 @@
+<!--
+  ~ 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.
+  -->
 <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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.onosproject</groupId>
     <artifactId>onos-pcep-providers</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
     <relativePath>../pom.xml</relativePath>
   </parent>
   <artifactId>onos-pcep-provider-topology</artifactId>
index 09efb8a..2613c41 100644 (file)
@@ -1,10 +1,25 @@
+<!--
+  ~ 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.
+  -->
 <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/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-pcep-providers</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <artifactId>onos-pcep-provider-tunnel</artifactId>
index 39249c5..cab2bf4 100644 (file)
@@ -1,19 +1,17 @@
 /*
+ * Copyright 2015 Open Networking Laboratory
  *
- *  * 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.
+ * 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.provider.pcep.tunnel.impl;
index 49e2951..5b010f5 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.provider.pcep.tunnel.impl;
 
 import static org.junit.Assert.assertNotNull;
index 74aa590..2d2aaaf 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.provider.pcep.tunnel.impl;
 
 import java.util.Collection;
index 7292d0b..0de914c 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.provider.pcep.tunnel.impl;
 
 import java.util.Set;
index 1dd7733..0603cb3 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.provider.pcep.tunnel.impl;
 
 import org.onosproject.core.ApplicationId;
index 87dd565..a02f8d4 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 57c1f67..34fcccb 100644 (file)
@@ -18,8 +18,8 @@ export PATH="$PATH:$ONOS_ROOT/tools/build"
 export BUILD_NUMBER=${BUILD_NUMBER:-$(id -un)~$(date +'%Y/%m/%d@%H:%M')}
 
 # ONOS Version and onos.tar.gz staging environment
-export ONOS_POM_VERSION="1.3.0-SNAPSHOT"
-export ONOS_VERSION=${ONOS_VERSION:-1.3.0.$BUILD_NUMBER}
+export ONOS_POM_VERSION="1.4.0-SNAPSHOT"
+export ONOS_VERSION=${ONOS_VERSION:-1.4.0.$BUILD_NUMBER}
 
 # ONOS production bits (onos.tar.gz, onos.zip, onos.deb, onos.rpm) staging environment
 export ONOS_BITS=onos-${ONOS_VERSION%~*}
index 8f6127d..3279445 100755 (executable)
@@ -30,7 +30,7 @@ function build_stage_dir() {
 
     # Stage the ONOS admin scripts and patch in Karaf service wrapper extras
     cp -r $ONOS_ROOT/tools/package/bin .
-    cp -r $ONOS_ROOT/tools/package/debian $ONOS_STAGE/debian
+    cp -r $ONOS_ROOT/tools/package/init $ONOS_STAGE/init
     cp -r $ONOS_ROOT/tools/package/etc/* $ONOS_STAGE/$KARAF_DIST/etc
 
     # Stage all builtin ONOS apps for factory install
@@ -49,7 +49,7 @@ function build_stage_dir() {
     # Stage the ONOS bundles, but only those that match the version
     mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/onosproject
     find $M2_REPO/org/onosproject -type f -path "*/$ONOS_POM_VERSION/*" \
-        -name '*.jar' -o -name '*.pom' -o -name '*-features.xml' \
+        \( -name '*.jar' -o -name '*.pom' -o -name '*-features.xml' \) \
             | grep -v -Ee '-tests.jar|-[0-9]{8}.[0-9]{6}-' \
             | while read src; do
         dst=$ONOS_STAGE/$KARAF_DIST/system/${src#$M2_REPO/*}
@@ -93,25 +93,19 @@ function build_compressed_package() {
 
 # Build a DEB package
 function build_deb() {
-    echo "You need to be root in order to generate a proper DEB package."
+    echo "This command may ask for your password to run commands as sudo,"
+    echo "  because you need to be root in order to generate a proper DEB package."
 
     sudo rm -fr $ONOS_DEB_ROOT
 
     mkdir -p $ONOS_DEB_ROOT/{DEBIAN,opt,etc/init}
 
-    {
-        echo "Package: ONOS"
-        echo "Architecture: all"
-        echo "Maintainer: ONOS Project"
-        echo "Depends: debconf (>= 0.5.00), default-jre-headless (>= 1.8) | openjdk-8-jre | oracle-java8-installer"
-        echo "Priority: optional"
-        echo "Version: $ONOS_POM_VERSION"
-        echo "Description: Open Network Operating System (ONOS) is an"
-        echo "  opensource SDN controller."
-    } > $ONOS_DEB_ROOT/DEBIAN/control
+    # Copy the debian directory and fill in version
+    cp -r $ONOS_ROOT/tools/package/deb/* $ONOS_DEB_ROOT/DEBIAN/
+    sed -i'' -E "s/@ONOS_POM_VERSION/$ONOS_POM_VERSION/" $ONOS_DEB_ROOT/DEBIAN/control
 
     cp -r $ONOS_STAGE $ONOS_DEB_ROOT/opt/onos
-    cp $ONOS_ROOT/tools/package/debian/onos.conf $ONOS_DEB_ROOT/etc/init/
+    cp $ONOS_ROOT/tools/package/init/onos.conf $ONOS_DEB_ROOT/etc/init/
 
     mkdir -p $ONOS_DEB_ROOT/opt/onos/var/
 
@@ -119,69 +113,33 @@ function build_deb() {
 
     sudo dpkg-deb --build $ONOS_DEB_ROOT > /dev/null &&
     sudo mv $ONOS_STAGE_ROOT/deb.deb $ONOS_DEB && ls -l $ONOS_DEB
+
+    #TODO run lintian on .deb
 }
 
 # Build an RPM package
 function build_rpm() {
     read -r -p "WARN: rpm-build utility and root priviledges are need to build the package. Do you want to continue? [Y/n] " response
-    case $response in
-        [nN][oO])
-            exit 0
-            ;;
-        *)
-            sudo rm -fr $ONOS_RPM_ROOT
-
-            sudo yum -y install rpm-build
-
-            mkdir -p $ONOS_RPM_ROOT/{BUILD,RPMS,SOURCES/ONOS-$ONOS_RPM_VERSION/{etc/init,opt},SPECS,SRPMS}
-
-            cp -r $ONOS_STAGE $ONOS_RPM_ROOT/SOURCES/ONOS-$ONOS_RPM_VERSION/opt/onos
-            cp $ONOS_ROOT/tools/package/debian/onos.conf $ONOS_RPM_ROOT/SOURCES/ONOS-$ONOS_RPM_VERSION/etc/init/
-
-            cd $ONOS_RPM_ROOT/SOURCES
-            COPYFILE_DISABLE=1 tar zcf ONOS-$ONOS_RPM_VERSION.tar.gz ONOS-$ONOS_RPM_VERSION
-
-            {
-                echo "Name: ONOS"
-                echo "Version: $ONOS_RPM_VERSION"
-                echo "Release: 1"
-                echo "Summary: Open Networking Operating System (ONOS)"
-                echo "Vendor: ONOS Project"
-                echo "Packager: ONOS Project"
-                echo "Group: Applications/Engineering"
-                echo "Requires: jre >= 1:8"
-                echo "License: Apache 2.0"
-                echo "URL: http://www.onosproject.org"
-                echo "Source0: ONOS-$ONOS_RPM_VERSION.tar.gz"
-                echo "BuildArch: noarch"
-                echo "BuildRoot: %{_tmppath}/%{name}-buildroot"
-                echo "%description"
-                echo "Open Network Operating System (ONOS) is an opensource SDN controller."
-                echo -e "\n"
-                echo "%prep"
-                echo "%setup -q"
-                echo -e "\n"
-                echo "%install"
-                echo "mkdir -p %{buildroot}"
-                echo "cp -R * %{buildroot}"
-                echo -e "\n"
-                echo "%clean"
-                echo "rm -rf %{buildroot}"
-                echo -e "\n"
-                echo "%files"
-                echo "%defattr(-,root,root,-)"
-                echo "/etc/init/onos.conf"
-                echo "/opt/onos/"
-                echo -e "\n"
-                echo "%post"
-                echo "echo ONOS successfully installed at /opt/onos"
-            } > $ONOS_RPM_ROOT/SPECS/onos.spec
-
-            rpmbuild --define "_topdir $ONOS_RPM_ROOT" -bb $ONOS_RPM_ROOT/SPECS/onos.spec
-
-            cp $ONOS_RPM_ROOT/RPMS/noarch/ONOS-$ONOS_RPM_VERSION-1.noarch.rpm $ONOS_STAGE_ROOT && ls -l $ONOS_STAGE_ROOT/ONOS-$ONOS_RPM_VERSION-1.noarch.rpm
-            ;;
-    esac
+    [[ "$response" =~ ^[Nn] ]] && exit 0
+
+    sudo rm -fr $ONOS_RPM_ROOT
+
+    sudo yum -y install rpm-build
+
+    mkdir -p $ONOS_RPM_ROOT/{BUILD,RPMS,SOURCES/onos-$ONOS_RPM_VERSION/{etc/init,opt},SPECS,SRPMS}
+
+    cp -r $ONOS_STAGE $ONOS_RPM_ROOT/SOURCES/onos-$ONOS_RPM_VERSION/opt/onos
+    cp $ONOS_ROOT/tools/package/init/onos.conf $ONOS_RPM_ROOT/SOURCES/onos-$ONOS_RPM_VERSION/etc/init/
+
+    cd $ONOS_RPM_ROOT/SOURCES
+    COPYFILE_DISABLE=1 tar zcf onos-$ONOS_RPM_VERSION.tar.gz onos-$ONOS_RPM_VERSION
+
+    cp $ONOS_ROOT/tools/package/rpm/onos.spec $ONOS_RPM_ROOT/SPECS/
+    sed -i'' -E "s/@ONOS_RPM_VERSION/$ONOS_RPM_VERSION/g" $ONOS_RPM_ROOT/SPECS/onos.spec
+
+    rpmbuild --define "_topdir $ONOS_RPM_ROOT" -bb $ONOS_RPM_ROOT/SPECS/onos.spec
+
+    cp $ONOS_RPM_ROOT/RPMS/noarch/onos-$ONOS_RPM_VERSION-1.noarch.rpm $ONOS_STAGE_ROOT && ls -l $ONOS_STAGE_ROOT/onos-$ONOS_RPM_VERSION-1.noarch.rpm
 }
 
 # Script entry point
index b86f45d..dc2f0a4 100755 (executable)
@@ -16,7 +16,7 @@ bitsPath = '/tmp'
 
 prefix = 'onos-(\d+\.\d+\.\d+)'
 buildNum = '\.?([\w-]*)'
-ext = '\.(?:tar\.gz|zip)'
+ext = '\.(?:tar\.gz|zip|deb|noarch\.rpm)'
 
 def findBits( path ):
     for file in listdir( path ):
index d34db1f..8deaada 100644 (file)
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.onosproject</groupId>
     <artifactId>onos-archetypes</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>onos-api-archetype</artifactId>
index f29a327..a0e54f3 100644 (file)
@@ -26,7 +26,7 @@
     <url>http://onosproject.org</url>
 
     <properties>
-        <onos.version>1.3.0-SNAPSHOT</onos.version>
+        <onos.version>1.4.0-SNAPSHOT</onos.version>
     </properties>
 
     <dependencies>
index ff6aa52..65b55b2 100644 (file)
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.onosproject</groupId>
     <artifactId>onos-archetypes</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>onos-bundle-archetype</artifactId>
index c9e747c..222e8b0 100644 (file)
@@ -26,7 +26,7 @@
     <url>http://onosproject.org</url>
 
     <properties>
-        <onos.version>1.3.0-SNAPSHOT</onos.version>
+        <onos.version>1.4.0-SNAPSHOT</onos.version>
         <!-- Uncomment to generate ONOS app from this module.
         <onos.app.name>org.foo.app</onos.app.name>
         <onos.app.origin>Foo, Inc.</onos.app.origin>
index 1ab9c1f..a071eed 100644 (file)
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.onosproject</groupId>
     <artifactId>onos-archetypes</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>onos-cli-archetype</artifactId>
index cb3862c..f460269 100644 (file)
@@ -26,7 +26,7 @@
     <url>http://onosproject.org</url>
 
     <properties>
-        <onos.version>1.3.0-SNAPSHOT</onos.version>
+        <onos.version>1.4.0-SNAPSHOT</onos.version>
     </properties>
 
     <dependencies>
index 2fd5f87..525a2f6 100644 (file)
@@ -28,7 +28,7 @@
 
     <groupId>org.onosproject</groupId>
     <artifactId>onos-archetypes</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <description>ONOS archetypes project</description>
index ca7b2d8..8dd3a8e 100644 (file)
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.onosproject</groupId>
     <artifactId>onos-archetypes</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>onos-ui-archetype</artifactId>
index a6beae9..2e1f091 100644 (file)
@@ -26,7 +26,7 @@
     <url>http://onosproject.org</url>
 
     <properties>
-        <onos.version>1.3.0-SNAPSHOT</onos.version>
+        <onos.version>1.4.0-SNAPSHOT</onos.version>
         <!-- Uncomment to generate ONOS app from this module.
         <onos.app.name>org.foo.app</onos.app.name>
         <onos.app.origin>Foo, Inc.</onos.app.origin>
index 452a03c..be9c416 100644 (file)
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../../../pom.xml</relativePath>
     </parent>
 
diff --git a/framework/src/onos/tools/package/deb/control b/framework/src/onos/tools/package/deb/control
new file mode 100644 (file)
index 0000000..c581ac2
--- /dev/null
@@ -0,0 +1,8 @@
+Package: onos
+Architecture: all
+Maintainer: ONOS Project
+Depends: debconf (>= 0.5.00), default-jre-headless (>= 1.8) | openjdk-8-jre | oracle-java8-installer
+Priority: optional
+Version: @ONOS_POM_VERSION
+Description: Open Network Operating System (ONOS)
+  Open Network Operating System (ONOS) is an opensource SDN controller.
diff --git a/framework/src/onos/tools/package/deb/copyright b/framework/src/onos/tools/package/deb/copyright
new file mode 100644 (file)
index 0000000..09ec05e
--- /dev/null
@@ -0,0 +1,20 @@
+Upstream-Name: onos
+Source: http://github.com/opennetworkinglab/onos
+
+Files: *
+Copyright: 2014-2015 Open Networking Laboratory
+License: Apache 2.0
+ 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.
+ .
+ On Debian systems, the complete text of the Apache License 2.0 can
+ be found in "/usr/share/common-licenses/Apache-2.0"
diff --git a/framework/src/onos/tools/package/deb/postinst b/framework/src/onos/tools/package/deb/postinst
new file mode 100755 (executable)
index 0000000..60de14a
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+ONOS_USER=sdn
+
+# Check to see if user exists, and if not, create a service account
+getent passwd $ONOS_USER >/dev/null 2&>1 || ( useradd -M $ONOS_USER && usermod -L $ONOS_USER )
+
+# Create ONOS options file
+[ ! -f /opt/onos/options ] && cat << EOF > /opt/onos/options
+export ONOS_OPTS=server
+export ONOS_USER="$ONOS_USER"
+EOF
+
+# Change permissions for onos directory
+[ -d /opt/onos ] && chown -R $ONOS_USER.$ONOS_USER /opt/onos
+
diff --git a/framework/src/onos/tools/package/deb/postrm b/framework/src/onos/tools/package/deb/postrm
new file mode 100755 (executable)
index 0000000..90dd616
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# FIXME dpkg will remove /opt if it is empty after removing onos
+#       We should recreate /opt if it was deleted.
+sudo mkdir -p /opt
diff --git a/framework/src/onos/tools/package/deb/prerm b/framework/src/onos/tools/package/deb/prerm
new file mode 100755 (executable)
index 0000000..2a1633d
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# Check if onos is running; if it is, stop onos
+[ -z "$(status onos 2>/dev/null | grep start)" ] && echo "onos is not running." || (
+    stop onos
+
+    # Wait for onos to stop up to 5 seconds
+    for i in $(seq 1 5); do
+      [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && break
+      sleep 1
+    done
+    [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && echo 'Stopped onos service' || echo 'Failed to stop onos'
+)
+
+# Clean up onos runtime directories
+#      TODO don't hardcode karaf version
+rm -rf /opt/onos/apache-karaf-3.0.3/
+rm -rf /opt/onos/var/*
+rm -rf /opt/onos/config
+rm -rf /opt/onos/options
+rm -rf /opt/onos/log
+
+#TODO consider removing the sdn user if we created it
diff --git a/framework/src/onos/tools/package/init/onos.conf b/framework/src/onos/tools/package/init/onos.conf
new file mode 100644 (file)
index 0000000..779df90
--- /dev/null
@@ -0,0 +1,37 @@
+description  "Open Network Operating System"
+author       "ON.Lab"
+
+start on (net-device-up
+          and local-filesystems
+          and runlevel [2345])
+stop on runlevel [016]
+
+console output
+kill timeout 60
+respawn
+
+env LANG=en_US.UTF-8
+
+pre-start script
+    [ -f /opt/onos/options ] && . /opt/onos/options
+    ONOS_USER=${ONOS_USER:-root}
+
+    # Ensure that the environment is initialized
+    [ -d /opt/onos ] && mkdir /opt/onos/var 2>/dev/null && chown $ONOS_USER.$ONOS_USER /opt/onos/var
+    [ -d /opt/onos ] && mkdir /opt/onos/config 2>/dev/null && chown $ONOS_USER.$ONOS_USER /opt/onos/config
+    # TODO make karaf version configurable
+    [ -d /opt/onos ] && [ ! -h /opt/onos/log ] \
+         && ln -s /opt/onos/apache-karaf-3.0.3/data/log /opt/onos/log || :
+end script
+
+pre-stop script
+    /opt/onos/bin/onos halt 2>>/opt/onos/var/stderr.log
+    sleep 1
+end script
+
+script
+  [ -f /opt/onos/options ] && . /opt/onos/options
+  start-stop-daemon --signal INT --start --chuid ${ONOS_USER:-root} \
+    --exec /opt/onos/bin/onos-service -- ${ONOS_OPTS:-server} \
+        >/opt/onos/var/stdout.log 2>/opt/onos/var/stderr.log
+end script
diff --git a/framework/src/onos/tools/package/rpm/onos.spec b/framework/src/onos/tools/package/rpm/onos.spec
new file mode 100644 (file)
index 0000000..df0a05d
--- /dev/null
@@ -0,0 +1,71 @@
+Name:        onos
+Version:     @ONOS_RPM_VERSION
+Release:     1
+Summary:     Open Networking Operating System (ONOS)
+Vendor:      ONOS Project
+Packager:    ONOS Project
+
+Group:       Applications/Engineering
+License:     Apache 2.0
+Requires:    jre >= 1:8
+URL:         http://www.onosproject.org
+Source0:     %{name}-@ONOS_RPM_VERSION.tar.gz
+
+BuildArch: noarch
+BuildRoot: %{_tmppath}/%{name}-buildroot
+
+%description
+Open Network Operating System (ONOS) is an open source SDN controller.
+
+%prep
+%setup -q
+
+%install
+mkdir -p %{buildroot}
+cp -R * %{buildroot}
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+/etc/init/onos.conf
+/opt/onos/
+
+%post
+ONOS_USER=sdn
+
+# Check to see if user exists, and if not, create a service account
+getent passwd $ONOS_USER >/dev/null 2&>1 || ( useradd -M $ONOS_USER && usermod -L $ONOS_USER )
+
+# Create ONOS options file
+[ ! -f /opt/onos/options ] && cat << EOF > /opt/onos/options
+export ONOS_OPTS=server
+export ONOS_USER="$ONOS_USER"
+EOF
+
+# Change permissions for onos directory
+[ -d /opt/onos ] && chown -R $ONOS_USER.$ONOS_USER /opt/onos
+
+echo ONOS successfully installed at /opt/onos
+
+%preun
+# Check if onos is running; if it is, stop onos
+[ -z "$(status onos 2>/dev/null | grep start)" ] && echo "onos is not running." || (
+    stop onos
+
+    # Wait for onos to stop up to 5 seconds
+    for i in $(seq 1 5); do
+      [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && break
+      sleep 1
+    done
+    [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && echo 'Stopped onos service' || echo 'Failed to stop onos'
+)
+
+%postun
+#TODO this should be less brute-force
+rm -rf /opt/onos
+
+%changelog
+# TODO
+
index 55f40e7..7ae0033 100755 (executable)
@@ -6,7 +6,7 @@
 set -e
 
 export AROOT=/tmp/foo
-export ARCHETYPE_OPTS="-DarchetypeGroupId=org.onosproject -DarchetypeVersion=1.3.0-SNAPSHOT"
+export ARCHETYPE_OPTS="-DarchetypeGroupId=org.onosproject -DarchetypeVersion=1.4.0-SNAPSHOT"
 
 mkdir -p $AROOT
 for an in api bundle cli ui; do
index e332dc5..760afaf 100755 (executable)
@@ -13,7 +13,7 @@ target=${1:-$OCI}
 echo onos-check-intent: $*
 
 set -x
-for i in {1..10}; do
+for i in {1..15}; do
     onos $target "onos:intents" | tee $aux
     ( cat $aux | grep "key=$2" | grep "state=$3" ) && cat $aux && exit 0
     sleep 1
index ec1013a..40e3e10 100755 (executable)
@@ -3,6 +3,25 @@
 # Checks the logs of the remote ONOS instance and makes sure they are clean.
 # -----------------------------------------------------------------------------
 
+function __usage() {
+cat << _EOM_
+
+usage:
+ $(basename $0) [node] ['old']
+
+options:
+ - [node]  : The node whose logs to inspect. The default is \$OCI.
+ - ['old'] : If 'old' is specified, the logs are simply searched for errors
+             and exceptions, and they are displayed.
+
+summary:
+ Checks the logs of the remote ONOS instance and makes sure they are clean.
+
+_EOM_
+}
+
+[ "$1" = "-h" ] && __usage && exit 0
+
 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
 . $ONOS_ROOT/tools/build/envDefaults
 
@@ -17,6 +36,7 @@ if [ "$2" = "old" ]; then
 
 else
     ssh $remote "
+        [ "'`uname`'" != "'"Linux"'" ] && alias tac='tail -r'
         tac $LOG | awk '
             BEGIN { off = 0; fail = 0; }
             / org.apache.karaf.main.lock.SimpleFileLock lock/ {
index 0f4cc9d..7384c2e 100755 (executable)
@@ -43,7 +43,7 @@ ssh $remote "
     mkdir -p -- $ONOS_INSTALL_DIR/$KARAF_DIST/data/raft
 
     # Install the upstart configuration file and setup options for debugging
-    [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf
+    [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/init/onos.conf /etc/init/onos.conf
     echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options
 
     # Setup correct user to run onos-service
index 1e162fb..5412e09 100755 (executable)
@@ -1,17 +1,39 @@
 #!/bin/bash
 # -----------------------------------------------------------------------------
-# Verifies connectivity to each node in ONOS cell.
+# Starts a Mininet network topology connected to all nodes in a cell.
 # -----------------------------------------------------------------------------
 
+function __usage() {
+cat << _EOM_
+
+usage:
+ $(basename $0) [file]
+
+options:
+ - [file] : a Mininet topology file. Default is *sol.py* .
+
+summary:
+ Starts a Mininet network topology connected to all nodes in a cell.
+
+ Currently, all topology files are assumed to be found in
+ \$OCN's ~/topos directory. Therefore [file] must be specified as
+ topos/filename.
+
+_EOM_
+}
+
+[ "$1" = "-h" ] && __usage && exit 0
+
 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
 . $ONOS_ROOT/tools/build/envDefaults
 
 SSHCMD="ssh -o PasswordAuthentication=no"
 SCPCMD="scp -q -o PasswordAuthentication=no"
+topo=${1:-topos/sol.py}
 
 echo "Copying topology files to mininet vm."
 $SSHCMD -n $ONOS_USER@$OCN mkdir -p topos
 $SCPCMD $ONOS_ROOT/tools/test/topos/* $ONOS_USER@$OCN:topos/
 
 echo "Starting Network."
-$SSHCMD -t $ONOS_USER@$OCN sudo python topos/sol.py $(env | sort | egrep "OC[0-9]+" | cut -d= -f2) 
+$SSHCMD -t $ONOS_USER@$OCN sudo python $topo $(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
index 5f40d8e..489083f 100755 (executable)
@@ -8,7 +8,8 @@
 
 node="${1:-$OCI}"
 file="${2:-$ONOS_ROOT/tools/test/topos/oe-linear-3.json}"
+url="${3:-config/topology}"
 
 curl -sS --fail -L --user $ONOS_WEB_USER:$ONOS_WEB_PASS \
     -X POST -H 'Content-Type:application/json' \
-    http://$node:8181/onos/v1/config/topology -d@$file
+    http://$node:8181/onos/v1/${url} -d@$file
index c04db7a..7a8b9a5 100755 (executable)
@@ -10,5 +10,15 @@ remote=$ONOS_USER@${1:-$OCI}
 
 ssh $remote "
     sudo stop onos 1>/dev/null 2>/dev/null
+
+    # Wait for onos to stop up to 5 seconds
+    for i in \$(seq 1 5); do
+      [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] && break
+      sleep 1
+    done
+    [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] || echo 'ONOS failed to stop.'
+
+    # Remove onos directory and init file
     sudo rm -fr $ONOS_INSTALL_DIR
+    [ -f /etc/init/onos.conf ] && sudo rm /etc/init/onos.conf
 "
index fe8a5af..8737cf3 100755 (executable)
@@ -3,7 +3,7 @@
 #   System Test Coordinator
 #-------------------------------------------------------------------------------
 
-VER=1.3.0-SNAPSHOT
+VER=1.4.0-SNAPSHOT
 JAR=~/.m2/repository/org/onosproject/onlab-stc/$VER/onlab-stc-$VER.jar
 SCENARIOS=$ONOS_ROOT/tools/test/scenarios
 
@@ -15,9 +15,19 @@ scenario=${1:-smoke}
 [ ! -f $scenario ] && scenario=$scenario.xml
 [ ! -f $scenario ] && echo "Scenario $scenario file not found" && exit 1
 
+# Remove the test name from the list of parameters, if one is specified
 [ $# -ge 1 ] && shift
 
-[ -t 1 ] && stcColor=true || unset stcColor
+# If stcColor is not set, we will enable color if this is an interactive session
+[ -t 1 ] && interactive=true || interactive=false
 
+# stc requires that ONOS_USE_SSH=true, but we will store the old value and reset it after
+sshSet=$([ -z ${ONOS_USE_SSH+x} ]) && oldSSH=$ONOS_USE_SSH
+export ONOS_USE_SSH=true
+
+# Run stc
 [ -z "$stcDebug" ] && DEBUG_OPTS=""
-java $DEBUG_OPTS -jar $JAR $scenario "$@"
+stcColor=${stcColor:-$interactive} java $DEBUG_OPTS -jar $JAR $scenario "$@"
+
+# Reset the old value of ONOS_USE_SSH
+[ $sshSet ] && export ONOS_USE_SSH=oldSSH || unset ONOS_USE_SSH
index 2cd933e..c8dc599 100644 (file)
@@ -3,5 +3,6 @@
 export ONOS_NIC="10.1.10.*"
 export OC1="10.1.10.223"
 
-export ONOS_APPS="drivers,openflow,fwd,proxyarp,mobility"
+unset ONOS_USE_SSH
+export ONOS_APPS="drivers,openflow,fwd,proxyarp,mobility,dhcp"
 
diff --git a/framework/src/onos/tools/test/configs/office-dhcp.json b/framework/src/onos/tools/test/configs/office-dhcp.json
new file mode 100644 (file)
index 0000000..f0cf3fb
--- /dev/null
@@ -0,0 +1,22 @@
+{
+  "apps": {
+    "org.onosproject.dhcp" : {
+      "dhcp" : {
+        "ip": "10.1.11.50",
+        "mac": "ca:fe:ca:fe:ca:fe",
+        "subnet": "255.255.252.0",
+        "broadcast": "10.1.11.255",
+        "router": "10.1.8.1",
+        "domain": "8.8.8.8",
+        "ttl": "63",
+        "lease": "300",
+        "renew": "150",
+        "rebind": "200",
+        "delay": "2",
+        "timeout": "150",
+        "startip": "10.1.11.51",
+        "endip": "10.1.11.100"
+      }
+    }
+  }
+}
diff --git a/framework/src/onos/tools/test/scenarios/bin/curl-with-retry b/framework/src/onos/tools/test/scenarios/bin/curl-with-retry
new file mode 100755 (executable)
index 0000000..c9546ae
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+aux=/tmp/stc-$$.log
+trap "rm -f $aux 2>/dev/null" EXIT
+
+url=$1
+
+
+echo curl-with-retry: $*
+
+set -x
+for i in {1..3}; do
+    curl -f -uonos:rocks ${url} >$aux
+    if [ $? = 0 ]; then
+        cat $aux
+        exit 0
+    fi
+    sleep 1
+done
+
+cat $aux
+exit 1
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py b/framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py
new file mode 100755 (executable)
index 0000000..928531f
--- /dev/null
@@ -0,0 +1,54 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+
+from requests.auth import HTTPBasicAuth
+
+if len(sys.argv) != 9:
+    print "usage: find-link-in-cluster onos-node name cluster-id expected-length src-device-id src-port dst-device-id dst-port"
+    sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+cluster = sys.argv[3]
+length = int(sys.argv[4])
+srcDeviceId = sys.argv[5]
+srcPort = sys.argv[6]
+dstDeviceId = sys.argv[7]
+dstPort = sys.argv[8]
+
+
+linksRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/'
+                            + cluster + '/links',
+                            auth=HTTPBasicAuth('onos', 'rocks'))
+
+if linksRequest.status_code != 200:
+    print linksRequest.text
+    sys.exit(1)
+
+linksJson = linksRequest.json()
+linksLength = len(linksJson["links"])
+
+if  linksLength != length:
+    print "Expected length {} but got {}".format(length, linksLength)
+    sys.exit(1)
+
+for link in linksJson["links"]:
+    if srcDeviceId == link["src"]["device"] and srcPort == link["src"]["port"]:
+        if dstDeviceId == link["dst"]["device"] and dstPort == link["dst"]["port"]:
+            print "@stc " + name + "SrcDevice=" + link["src"]["device"]
+            print "@stc " + name + "SrcPort=" + link["src"]["port"]
+            print "@stc " + name + "DstDevice=" + link["dst"]["device"]
+            print "@stc " + name + "DstPort=" + link["dst"]["port"]
+            print "@stc " + name + "Type=" + link["type"]
+            print "@stc " + name + "State=" + link["state"]
+            sys.exit(0)
+
+print "Could not find link from {}:{} to {}:{}"\
+    .format(srcDeviceId, srcPort, dstDeviceId, dstPort)
+sys.exit(1)
+
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py b/framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py
new file mode 100755 (executable)
index 0000000..6d1970f
--- /dev/null
@@ -0,0 +1,34 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+import urllib
+
+from requests.auth import HTTPBasicAuth
+
+if len(sys.argv) != 4:
+    print "usage: find-topo-infrastructure onos-node name connect-point"
+    sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+id = sys.argv[3]
+
+infrastructureRequest = requests.get('http://' + node + ':8181/onos/v1/topology/infrastructure/' +
+                           urllib.quote_plus(id),
+                           auth=HTTPBasicAuth('onos', 'rocks'))
+
+if infrastructureRequest.status_code != 200:
+    print infrastructureRequest.text
+    sys.exit(1)
+
+infrastructureJson = infrastructureRequest.json()
+
+print "@stc " + name + "Infrastructure=" + str(infrastructureJson["infrastructure"])
+
+sys.exit(0)
+
+
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/query-cluster.py b/framework/src/onos/tools/test/scenarios/bin/query-cluster.py
new file mode 100755 (executable)
index 0000000..0cac7ac
--- /dev/null
@@ -0,0 +1,37 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+import urllib
+
+from requests.auth import HTTPBasicAuth
+
+if len(sys.argv) != 4:
+    print "usage: query-cluster onos-node name cluster-number"
+    sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+cluster = sys.argv[3]
+
+topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/'
+                           + cluster,
+                           auth=HTTPBasicAuth('onos', 'rocks'))
+
+if topoRequest.status_code != 200:
+    print topoRequest.text
+    sys.exit(1)
+
+topoJson = topoRequest.json()
+
+print "@stc " + name + "Id=" + str(topoJson["id"])
+print "@stc " + name + "DeviceCount=" + str(topoJson["deviceCount"])
+print "@stc " + name + "LinkCount=" + str(topoJson["linkCount"])
+print "@stc " + name + "Root=" + topoJson["root"]
+
+sys.exit(0)
+
+
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/query-topo.py b/framework/src/onos/tools/test/scenarios/bin/query-topo.py
new file mode 100755 (executable)
index 0000000..9b81b4e
--- /dev/null
@@ -0,0 +1,35 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+import urllib
+
+from requests.auth import HTTPBasicAuth
+
+if len(sys.argv) != 3:
+    print "usage: query-topo onos-node name"
+    sys.exit(1)
+
+node = sys.argv[1]
+name = sys.argv[2]
+
+topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/',
+                           auth=HTTPBasicAuth('onos', 'rocks'))
+
+if topoRequest.status_code != 200:
+    print topoRequest.text
+    sys.exit(1)
+
+topoJson = topoRequest.json()
+
+print "@stc " + name + "Time=" + str(topoJson["time"])
+print "@stc " + name + "Devices=" + str(topoJson["devices"])
+print "@stc " + name + "Links=" + str(topoJson["links"])
+print "@stc " + name + "Clusters=" + str(topoJson["clusters"])
+
+sys.exit(0)
+
+
+
+
+
diff --git a/framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py b/framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py
new file mode 100755 (executable)
index 0000000..be834b9
--- /dev/null
@@ -0,0 +1,51 @@
+#! /usr/bin/env python
+
+import requests
+import sys
+import urllib
+
+from requests.auth import HTTPBasicAuth
+
+if len(sys.argv) != 5:
+    print "usage: verify-topo-links onos-node cluster-id first-index last-index"
+    sys.exit(1)
+
+node = sys.argv[1]
+cluster = sys.argv[2]
+first = int(sys.argv[3])
+last = int(sys.argv[4])
+
+found = 0
+
+topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/'
+                           + cluster
+                           + "/devices",
+                           auth=HTTPBasicAuth('onos', 'rocks'))
+
+if topoRequest.status_code != 200:
+    print topoRequest.text
+    sys.exit(1)
+
+topoJson = topoRequest.json()
+
+for deviceIndex in range(first, last+1):
+    lookingFor = "of:" + format(deviceIndex, '016x')
+    print lookingFor
+    for arrayIndex in range(0, len(topoJson["devices"])):
+        device = topoJson["devices"][arrayIndex]
+        if device == lookingFor:
+            found = found + 1
+            print "Match found for " + device
+            break
+
+
+if found == last - first:
+    sys.exit(0)
+
+print "Found " + str(found) + " matches, need " + str(last - first)
+sys.exit(2)
+
+
+
+
+
index 8bcbfa7..eb4727b 100644 (file)
@@ -20,7 +20,9 @@
               exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
         <step name="Link-1-Down" requires="~Ping-1"
               exec="onos-mininet sendAndExpect link s4 s7 down --expect ."/>
-        <step name="Ping-2" requires="~Link-1-Down"
+        <step name="Ping-2-Prep" requires="~Link-1-Down"
+              exec="onos-mininet sendAndExpect h1 ping -c5 h4 --expect ."/>
+        <step name="Ping-2" requires="~Ping-2-Prep"
               exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
         <step name="Link-2-Down" requires="~Ping-2"
               exec="onos-mininet sendAndExpect link s4 s5 down --expect ."/>
               exec="onos-mininet sendAndExpect h1 ping -c1 -w1 h4 --expect 100% packet loss"/>
         <step name="Link-1-Up" requires="~Ping-3"
               exec="onos-mininet sendAndExpect link s4 s7 up --expect ."/>
-        <step name="Ping-4" requires="~Link-1-Up"
+        <step name="Ping-4-Prep" requires="~Link-1-Up"
+              exec="onos-mininet sendAndExpect h1 ping -c5 h4 --expect ."/>
+        <step name="Ping-4" requires="~Ping-4-Prep"
               exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
         <step name="Link-2-Up" requires="~Ping-4"
               exec="onos-mininet sendAndExpect link s4 s5 up --expect ."/>
-        <step name="Ping-5" requires="~Link-2-Up"
+        <step name="Ping-5-Prep" requires="~Link-2-Up"
+              exec="onos-mininet sendAndExpect h1 ping -c5 h4 --expect ."/>
+        <step name="Ping-5" requires="~Ping-5-Prep"
               exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
     </group>
-</scenario>
\ No newline at end of file
+</scenario>
index 8968e0d..87c1322 100644 (file)
@@ -23,7 +23,7 @@
 
         <!-- TODO: take this out when initial pingall sweep is 100% -->
         <step name="Initial-Ping-All" requires="Check-Apps"
-              exec="onos-mininet sendAndExpect py net.pingAll(1) --expect 600 received"/>
+              exec="onos-mininet sendAndExpect py net.pingAll(1) --expect received"/>
 
         <step name="Ping-All-And-Verify" requires="Check-Apps,Initial-Ping-All"
               exec="onos-mininet sendAndExpect py net.pingAll(1) --expect 600/600 received"/>
@@ -34,4 +34,4 @@
         <step name="Config-Topo" requires="~Check-Summary-For-Hosts"
               exec="onos-topo-cfg ${OC1} ${ONOS_ROOT}/tools/test/topos/attmpls.json"/>
     </group>
-</scenario>
\ No newline at end of file
+</scenario>
index fc7b1d0..ab7804d 100644 (file)
         <!-- Check that the intents can be fetched via the REST API -->
         <step name="Net-REST.Validate-Intent-XY-Installed"
               requires="Net-REST.Create-Intent-YX"
-              exec="curl -f -uonos:rocks ${xyLocation}"/>
+              exec="curl-with-retry ${xyLocation}"/>
         <step name="Net-REST.Validate-Intent-YX-Installed"
               requires="^"
-              exec="curl -f -uonos:rocks ${yxLocation}"/>
+              exec="curl-with-retry ${yxLocation}"/>
 
         <!-- Use REST API to query flows created by the intents -->
         <step name="Net-REST.Validate-Intent-XY-Flow-Installed"
         <step name="Net-REST.Validate-YX-Flow-State" requires="^"
               exec="test '${dev4outFlowState}' == 'ADDED' -o '${dev4outFlowState}' == 'PENDING_ADD'"/>
         <step name="Net-REST.Validate-YX-Flow-Port" requires="^"
-              exec="test '${dev4outFlowPort}' == '3'"/>
+              exec="test ${dev4outFlowPort} -ge 1 -a ${dev4outFlowPort} -le 5"/>
 
         <!-- Check that connectivity was established -->
         <step name="Net-REST.Ping-XY" requires="Net-REST.Create-Intent-XY,Net-REST.Create-Intent-YX"
               exec="curl -f -X DELETE -uonos:rocks ${xyLocation}"/>
         <step name="Net-REST.Delete-Intent-YX" requires="^"
               exec="curl -f -X DELETE -uonos:rocks ${yxLocation}"/>
+        <step name="Net-REST.Allow-Intents-To-Purge"
+              exec="onos-check-intent ${OC1} xy INSTALLED" env="!"
+              requires="Net-REST.Delete-Intent-XY,Net-REST.Delete-Intent-YX"/>
 
         <!-- Use REST API to be sure that flows are no longer installed -->
-        <step name="Net-REST.Validate-XY-Flows-Removed" requires="Net-REST.Delete-Intent-XY"
+        <step name="Net-REST.Validate-XY-Flows-Removed" requires="Net-REST.Allow-Intents-To-Purge"
               exec="find-flow.py ${OC1} dev1out of:0000000000000001"
               env="!"/>
-        <step name="Net-REST.Validate-YX-Flows-Removed" requires="Net-REST.Delete-Intent-YX"
+        <step name="Net-REST.Validate-YX-Flows-Removed" requires="Net-REST.Allow-Intents-To-Purge"
               exec="find-flow.py ${OC1} dev4out of:0000000000000004"
               env="!"/>
 
         <!-- Check that the deleted intents no longer appear in the REST API -->
-        <step name="Net-REST.Allow-Intents-To-Purge" requires="Net-REST.Delete-Intent-XY"
-              exec="sleep 1"/>
         <step name="Net-REST.Validate-Intent-XY-Removed" requires="Net-REST.Allow-Intents-To-Purge"
-              exec="curl -f -uonos:rocks ${xyLocation}" env="!"/>
+              exec="curl-with-retry ${xyLocation}" env="!"/>
         <step name="Net-REST.Validate-Intent-YX-Removed" requires="Net-REST.Allow-Intents-To-Purge"
-              exec="curl -f -uonos:rocks ${yxLocation}" env="!"/>
+              exec="curl-with-retry ${yxLocation}" env="!"/>
 
     </group>
 </scenario>
index e179ec5..13252d0 100644 (file)
@@ -17,9 +17,9 @@
     <!-- TODO: parametrize this via recipes -->
     <group name="Net-Setup">
         <step name="Push-Topos" exec="onos-push-topos ${OCN}"/>
-        <step name="Stop-Mininet-If-Needed" env="~" exec="onos-mininet stop"/>
 
-        <step name="Wipe-Out-Data-Before" exec="onos-wipe-out"/>
+        <step name="Stop-Mininet-If-Needed" env="~" exec="onos-mininet stop"/>
+        <step name="Wipe-Out-Data-Before" exec="onos-wipe-out" requires="^"/>
 
         <step name="Initial-Summary-Check" requires="~Wipe-Out-Data-Before"
               exec="onos-check-summary ${OC1} [0-9]* 0 0 0"/>
@@ -43,4 +43,4 @@
         <step name="Check-Flows" requires="~Pause-For-Masters,~Check-Summary"
               exec="onos-check-flows ${OC1}"/>
     </group>
-</scenario>
\ No newline at end of file
+</scenario>
index 53a5729..91131c6 100644 (file)
         <import file="${ONOS_SCENARIOS}/net-create-flows.xml"/>
         <dependency name="Net-Create-Flows" requires="Net-Setup,P2P-Intent-Connectivity,Net-REST"/>
 
+        <import file="${ONOS_SCENARIOS}/net-topo.xml"/>
+        <dependency name="Net-topo" requires="Net-Setup,Net-Create-Flows"/>
+
         <import file="${ONOS_SCENARIOS}/net-teardown.xml"/>
         <dependency name="Net-Teardown" requires="~Host-Intent-Connectivity,
                                                   ~P2P-Intent-Connectivity,
                                                   ~Net-REST,
-                                                  ~Net-Create-Flows"/>
+                                                  ~Net-Create-Flows,
+                                                  ~Net-topo"/>
     </group>
 </scenario>
diff --git a/framework/src/onos/tools/test/scenarios/net-topo.xml b/framework/src/onos/tools/test/scenarios/net-topo.xml
new file mode 100644 (file)
index 0000000..e8e2399
--- /dev/null
@@ -0,0 +1,76 @@
+<!--
+  ~ 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.
+  -->
+<scenario name="net-topo"
+          description="Network topology test">
+    <!-- TODO: parametrize this via recipes -->
+    <group name="Net-topo">
+
+        <!-- Verify the overall topology using the REST API -->
+        <step name="Net-topo.Query-Topo"
+              exec="query-topo.py ${OC1} topo"/>
+        <step name="Net-topo.Verify-Topo-Devices" requires="Net-topo.Query-Topo"
+              exec="test ${topoDevices} == 25"/>
+        <step name="Net-topo.Verify-Topo-Links" requires="Net-topo.Query-Topo"
+              exec="test ${topoLinks} == 140"/>
+        <step name="Net-topo.Verify-Topo-Clusters" requires="Net-topo.Query-Topo"
+              exec="test ${topoClusters} == 1"/>
+
+        <!-- Verify the cluster topology using the REST API -->
+        <step name="Net-topo.Query-Cluster0"
+              exec="query-cluster.py ${OC1} clusterTopo0 0"/>
+        <step name="Net-topo.Verify-Cluster0-Id" requires="Net-topo.Query-Cluster0"
+              exec="test ${clusterTopo0Id} == 0"/>
+        <step name="Net-topo.Verify-Cluster0-DeviceCount" requires="Net-topo.Query-Cluster0"
+              exec="test ${clusterTopo0DeviceCount} == 25"/>
+        <step name="Net-topo.Verify-Cluster0-LinkCount" requires="Net-topo.Query-Cluster0"
+              exec="test ${clusterTopo0LinkCount} == 140"/>
+        <step name="Net-topo.Verify-Cluster0-Root" requires="Net-topo.Query-Cluster0"
+              exec="test '${clusterTopo0Root}' == 'of:000000000000000a'"/>
+
+        <!-- Verify the list of devices for the cluster -->
+        <step name="Net-topo.Verify-Cluster0-Devices"
+              exec="verify-topo-devices.py ${OC1} 0 0 24"/>
+
+        <!-- Spot check some known links in the topology -->
+        <step name="Net-topo.Verify-Cluster0-Link1"
+              exec="find-link-in-cluster.py ${OC1} link1 0 140 of:000000000000000f 8 of:0000000000000015 3"/>
+        <step name="Net-topo.Verify-Cluster0-Link2"
+              exec="find-link-in-cluster.py ${OC1} link2 0 140 of:0000000000000008 3 of:0000000000000005 4"/>
+        <step name="Net-topo.Verify-Cluster0-Link3"
+              exec="find-link-in-cluster.py ${OC1} link3 0 140 of:0000000000000011 2 of:0000000000000002 9"/>
+        <step name="Net-topo.Verify-Cluster0-Link4"
+              exec="find-link-in-cluster.py ${OC1} link4 0 140 of:000000000000000f 3 of:000000000000000d 10"/>
+        <step name="Net-topo.Verify-Cluster0-Link5"
+              exec="find-link-in-cluster.py ${OC1} link5 0 140 of:000000000000000d 13 of:0000000000000010 6"/>
+
+        <!--  Verify the topology infrastructure query -->
+        <step name="Net-topo.Query-Cluster0-Infra1"
+              exec="find-topo-infrastructure.py ${OC1} infra1 of:000000000000000f:8"/>
+        <step name="Net-topo.Verify-Cluster0-Infra1" requires="Net-topo.Query-Cluster0-Infra1"
+              exec="test '${infra1Infrastructure}' == 'True'"/>
+
+        <step name="Net-topo.Query-Cluster0-Infra2"
+              exec="find-topo-infrastructure.py ${OC1} infra2 of:000000000000000d:8"/>
+        <step name="Net-topo.Verify-Cluster0-Infra2" requires="Net-topo.Query-Cluster0-Infra2"
+              exec="test '${infra2Infrastructure}' == 'True'"/>
+
+        <step name="Net-topo.Query-Cluster0-Infra3"
+              exec="find-topo-infrastructure.py ${OC1} infra3 of:0000000000000012:8"/>
+        <step name="Net-topo.Verify-Cluster0-Infra3" requires="Net-topo.Query-Cluster0-Infra3"
+              exec="test '${infra3Infrastructure}' == 'False'"/>
+
+    </group>
+</scenario>
index 650aa41..2c541d5 100644 (file)
@@ -15,7 +15,7 @@
   -->
 <scenario name="prerequisites" description="ONOS test pre-requisites">
     <group name="Prerequisites">
-        <step name="Check-Environment" exec="test -n ${ONOS_ROOT} -a -n ${ONOS_NIC} -a -n ${OC1}"/>
+        <step name="Check-Environment" exec="test -n ${ONOS_ROOT} -a -n ${ONOS_NIC} -a -n ${OC1} -a '${ONOS_USE_SSH}' == 'true'"/>
         <step name="Check-ONOS-Bits" exec="onos-check-bits"/>
 
         <parallel var="${OC#}">
index 3e5bff7..ae6045e 100755 (executable)
@@ -62,7 +62,7 @@ class ONOS( Controller ):
    
     def start( self ):
         if self.inNamespace:
-            instanceOpts = ( '-furl mvn:org.onosproject/onos-features/1.3.0-SNAPSHOT/xml/features '
+            instanceOpts = ( '-furl mvn:org.onosproject/onos-features/1.4.0-SNAPSHOT/xml/features '
                              '-s 8101' )
             if self.ip is not None:
                 instanceOpts += (' -a %s' % self.IP() )
index bef9dec..a1ae834 100644 (file)
@@ -70,9 +70,6 @@ from mininet.cli import CLI
 SLEEP_TIME = 2
 TIMEOUT = 60
 
-REST_USER = 'onos'
-REST_PW = 'rocks'
-
 class OpticalSwitch(Switch):
     """
     For now, same as Switch class.
@@ -152,6 +149,17 @@ class LINCSwitch(OpticalSwitch):
             error('Please set ONOS_ROOT environment variable!\n')
         else:
             os.environ[ 'ONOS_ROOT' ] = onosDir
+    ### REST USER/PASS ###
+    try:
+        restUser = os.environ[ 'ONOS_WEB_USER' ]
+        restPass = os.environ[ 'ONOS_WEB_PASS' ]
+    except:
+        error('***WARNING: $ONOS_WEB_USER and $ONOS_WEB_PASS aren\'t set!\n')
+        error('***WARNING: Setting (probably) sane WEB user/pass values\n')
+        restUser = 'onos'
+        restPass = 'rocks'
+        os.environ[ 'ONOS_WEB_USER' ] = restUser
+        os.environ[ 'ONOS_WEB_PASS' ] = restPass
     ### LINC-directory
     lincDir = findDir.__func__('linc-oe', user)
     if not lincDir:
@@ -283,7 +291,7 @@ class LINCSwitch(OpticalSwitch):
             json.dump(crossConnectJSON, fd, indent=4, separators=(',', ': '))
         info('*** Pushing crossConnect.json to ONOS\n')
         output = quietRun('%s/tools/test/bin/onos-topo-cfg %s\
-         Topology.json' % (self.onosDir, self.controllers[ 0 ].ip), shell=True)
+         Topology.json network/configuration/' % (self.onosDir, self.controllers[ 0 ].ip), shell=True)
 
     def stop_oe(self):
         '''
@@ -366,16 +374,17 @@ class LINCSwitch(OpticalSwitch):
         LINCSwitch.opticalJSON[ 'links' ] = linkConfig
 
         info('*** Writing Topology.json file\n')
+        topoJSON = LINCSwitch.makeTopoJSON()
         with open('Topology.json', 'w') as outfile:
-            json.dump(LINCSwitch.opticalJSON, outfile, indent=4, separators=(',', ': '))
+            json.dump(topoJSON, outfile, indent=4, separators=(',', ': '))
 
         info('*** Converting Topology.json to linc-oe format (TopoConfig.json) file (no oecfg) \n')
         
-        topoConfigJson = {};
-        dpIdToName = {};
+        topoConfigJson = {}
+        dpIdToName = {}
 
-        topoConfigJson["switchConfig"] = LINCSwitch.getSwitchConfig(dpIdToName);
-        topoConfigJson["linkConfig"] = LINCSwitch.getLinkConfig(dpIdToName);
+        topoConfigJson["switchConfig"] = LINCSwitch.getSwitchConfig(dpIdToName)
+        topoConfigJson["linkConfig"] = LINCSwitch.getLinkConfig(dpIdToName)
 
         #Writing to TopoConfig.json
         with open( 'TopoConfig.json', 'w' ) as outfile:
@@ -433,7 +442,7 @@ class LINCSwitch(OpticalSwitch):
         time = 0
         # Set up password authentication
         pw_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
-        pw_mgr.add_password(None, url, REST_USER, REST_PW)
+        pw_mgr.add_password(None, url, LINCSwitch.restUser, LINCSwitch.restPass)
         handler = urllib2.HTTPBasicAuthHandler(pw_mgr)
         opener = urllib2.build_opener(handler)
         opener.open(url)
@@ -462,7 +471,8 @@ class LINCSwitch(OpticalSwitch):
 
         info('*** Pushing Topology.json to ONOS\n')
         for index in range(len(LINCSwitch.controllers)):
-            output = quietRun('%s/tools/test/bin/onos-topo-cfg %s Topology.json &' % (LINCSwitch.onosDir, LINCSwitch.controllers[ index ].ip), shell=True)
+            output = quietRun('%s/tools/test/bin/onos-topo-cfg %s Topology.json network/configuration/ &'\
+                               % (LINCSwitch.onosDir, LINCSwitch.controllers[ index ].ip), shell=True)
             # successful output contains the two characters '{}'
             # if there is more output than this, there is an issue
             if output.strip('{}'):
@@ -477,6 +487,48 @@ class LINCSwitch(OpticalSwitch):
             nodeDpid += (id[i:(i + 2):]) + ":"
         return nodeDpid[0:-1];
 
+    @staticmethod
+    def makeTopoJSON():
+        """
+        Builds ONOS network conifg system compatible dicts to be written as Topology.json file.
+        """
+        topology = {}
+        links = {}
+        devices = {}
+        ports = {}
+
+        for switch in LINCSwitch.opticalJSON[ 'devices' ]:
+            # build device entries - keyed on uri (DPID) and config key 'basic'
+            devDict = {}
+            devDict[ 'driver' ] = switch[ 'hw' ]
+            devDict[ 'mfr' ] = switch[ 'mfr' ]
+            devDict[ 'mac' ] = switch[ 'mac' ]
+            devDict[ 'type' ] = switch[ 'type' ]
+            devDict.update(switch[ 'annotations' ])
+
+            devSubj = switch[ 'uri' ]
+            devices[ devSubj ] = { 'basic': devDict }
+
+            # build port entries - keyed on "uri/port" and config key 'optical'
+            for port in switch[ 'ports' ]:
+                portSubj = devSubj + '/' + str(port[ 'port' ])
+                ports[ portSubj ] = { 'optical': port }
+
+        # build link entries - keyed on "uri/port-uri/port" and config key 'basic'
+        for link in LINCSwitch.opticalJSON[ 'links' ]:
+            linkDict = {}
+            linkDict[ 'type' ] = link[ 'type' ]
+            linkDict.update(link[ 'annotations' ])
+
+            linkSubj = link[ 'src' ] + '-' + link[ 'dst' ]
+            links[ linkSubj ] = { 'basic': linkDict }
+
+        topology[ 'links' ] = links
+        topology[ 'devices' ] = devices
+        topology[ 'ports' ] = ports
+
+        return topology
+
     @staticmethod
     def getSwitchConfig (dpIdToName):
         switchConfig = [];
index 86adfb4..3dda596 100755 (executable)
@@ -8,7 +8,7 @@
 
 JDVUE_ROOT=${JDVUE_ROOT:-$(dirname $0)/..}
 cd $JDVUE_ROOT
-VER=1.3.0-SNAPSHOT
+VER=1.4.0-SNAPSHOT
 JAR=$PWD/target/jdvue-${VER}.jar # start with the dev jar first
 cd - >/dev/null
 
index 3399a8a..d150102 100644 (file)
@@ -1,5 +1,21 @@
 <?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<!--
+  ~ 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.
+  -->
+<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/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <prerequisites>
@@ -9,7 +25,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
                 <version>2.3</version>
                 <configuration>
                     <transformers>
-                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                            <mainClass>org.onlab.jdvue.DependencyViewer</mainClass>
+                        <transformer
+                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                            <mainClass>org.onlab.jdvue.DependencyViewer
+                            </mainClass>
                         </transformer>
                     </transformers>
                 </configuration>
index 8f611c5..40cb99a 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 
index 7fc3409..21fae47 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import java.util.Objects;
index 65e3cfb..444995b 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import java.util.ArrayList;
index a210d71..32e9ef1 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import com.fasterxml.jackson.databind.JsonNode;
index 3195930..e74bdc6 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import java.util.Objects;
index 7bf4be1..a15cb4d 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import java.util.Collections;
index 8919a13..1376cfe 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import java.util.*;
index 99d2208..b792abc 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import org.junit.Test;
index a0a7c7c..895c713 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import org.junit.Test;
index 4dfe961..94740da 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import com.google.common.testing.EqualsTester;
index cdac0c2..0937c06 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.jdvue;
 
 import org.junit.Test;
index a70bfbe..6d0f834 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 9017834..c9787a4 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 1795121..2e72113 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 230609f..a0e0570 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.graph;
 
 /**
index ae7f182..c5fa9b4 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.graph;
 
 import java.util.ArrayList;
index d75b50a..a5c5f4f 100644 (file)
@@ -35,6 +35,7 @@ public class IPv4 extends BasePacket {
     public static final byte PROTOCOL_IGMP = 0x2;
     public static final byte PROTOCOL_TCP = 0x6;
     public static final byte PROTOCOL_UDP = 0x11;
+    public static final byte PROTOCOL_PIM = 0x67;
     public static final Map<Byte, Deserializer<? extends IPacket>> PROTOCOL_DESERIALIZER_MAP =
             new HashMap<>();
 
@@ -43,6 +44,7 @@ public class IPv4 extends BasePacket {
         IPv4.PROTOCOL_DESERIALIZER_MAP.put(IPv4.PROTOCOL_IGMP, IGMP.deserializer());
         IPv4.PROTOCOL_DESERIALIZER_MAP.put(IPv4.PROTOCOL_TCP, TCP.deserializer());
         IPv4.PROTOCOL_DESERIALIZER_MAP.put(IPv4.PROTOCOL_UDP, UDP.deserializer());
+        IPv4.PROTOCOL_DESERIALIZER_MAP.put(IPv4.PROTOCOL_PIM, PIM.deserializer());
     }
 
     private static final byte DSCP_MASK = 0x3f;
index 47dbeed..71c5803 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.onlab.packet;
 
 import java.nio.ByteBuffer;
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java
new file mode 100755 (executable)
index 0000000..d9a5e83
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+ * 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.onlab.packet;
+
+import org.onlab.packet.pim.PIMHello;
+import org.onlab.packet.pim.PIMJoinPrune;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.onlab.packet.PacketUtils.checkInput;
+
+/**
+ * Implements PIM control packet format.
+ */
+public class PIM extends BasePacket {
+
+    public static final IpAddress PIM_ADDRESS = IpAddress.valueOf("224.0.0.13");
+
+    public static final byte TYPE_HELLO = 0x00;
+    public static final byte TYPE_REGISTER = 0x01;
+    public static final byte TYPE_REGISTER_STOP = 0x02;
+    public static final byte TYPE_JOIN_PRUNE_REQUEST = 0x03;
+    public static final byte TYPE_BOOTSTRAP = 0x04;
+    public static final byte TYPE_ASSERT = 0x05;
+    public static final byte TYPE_GRAFT = 0x06;
+    public static final byte TYPE_GRAFT_ACK = 0x07;
+    public static final byte TYPE_CANDIDATE_RP_ADV = 0x08;
+
+    public static final int PIM_HEADER_LEN = 4;
+
+    public static final Map<Byte, Deserializer<? extends IPacket>> PROTOCOL_DESERIALIZER_MAP =
+            new HashMap<>();
+
+    static {
+        PIM.PROTOCOL_DESERIALIZER_MAP.put(PIM.TYPE_HELLO, PIMHello.deserializer());
+        PIM.PROTOCOL_DESERIALIZER_MAP.put(PIM.TYPE_JOIN_PRUNE_REQUEST, PIMJoinPrune.deserializer());
+    }
+
+    /*
+     * PIM Header fields
+     */
+    protected byte version;
+    protected byte type;
+    protected byte reserved;
+    protected short checksum;
+
+    /**
+     * Default constructor.
+     */
+    public PIM() {
+        super();
+        this.version = 2;
+        this.reserved = 0;
+    }
+
+    /**
+     * Return the PIM message type.
+     *
+     * @return the pimMsgType
+     */
+    public byte getPimMsgType() {
+        return this.type;
+    }
+
+    /**
+     * Set the PIM message type. Currently PIMJoinPrune and PIMHello are
+     * supported.
+     *
+     * @param type PIM message type
+     * @return PIM Header
+     */
+     public PIM setPIMType(final byte type) {
+            this.type = type;
+            return this;
+     }
+
+    /**
+     * Get the version of PIM.
+     *
+     * @return the PIM version.   Must be 2.
+     */
+    public byte getVersion() {
+         return version;
+    }
+
+    /**
+     * Set the PIM version type. Should not change from 2.
+     *
+     * @param version PIM version
+     */
+    public void setVersion(byte version) {
+         this.version = version;
+    }
+
+    /**
+     * Get the reserved field.
+     *
+     * @return the reserved field.  Must be ignored.
+     */
+    public byte getReserved() {
+        return reserved;
+    }
+
+    /**
+     * Set the reserved field.
+     *
+     * @param reserved should be 0
+     */
+    public void setReserved(byte reserved) {
+        this.reserved = reserved;
+    }
+
+    /**
+     * Get the checksum of this packet.
+     *
+     * @return the checksum
+     */
+    public short getChecksum() {
+        return checksum;
+    }
+
+    /**
+     * Set the checksum.
+     *
+     * @param checksum the checksum
+     */
+    public void setChecksum(short checksum) {
+        this.checksum = checksum;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 5807;
+        int result = super.hashCode();
+        result = prime * result + this.type;
+        result = prime * result + this.version;
+        result = prime * result + this.checksum;
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof PIM)) {
+            return false;
+        }
+        final PIM other = (PIM) obj;
+        if (this.type != other.type) {
+            return false;
+        }
+        if (this.version != other.version) {
+            return false;
+        }
+        if (this.checksum != other.checksum) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Serializes the packet. Will compute and set the following fields if they
+     * are set to specific values at the time serialize is called: -checksum : 0
+     * -length : 0
+     *
+     * @return will return the serialized packet
+     */
+    @Override
+    public byte[] serialize() {
+        int length = 4;
+        byte[] payloadData = null;
+        if (this.payload != null) {
+            this.payload.setParent(this);
+            payloadData = this.payload.serialize();
+            length += payloadData.length;
+        }
+
+        final byte[] data = new byte[length];
+        final ByteBuffer bb = ByteBuffer.wrap(data);
+
+        bb.put((byte) ((this.version & 0xf) << 4 | this.type & 0xf));
+        bb.put(this.reserved);
+        bb.putShort(this.checksum);
+        if (payloadData != null) {
+            bb.put(payloadData);
+        }
+
+        if (this.parent != null && this.parent instanceof PIM) {
+            ((PIM) this.parent).setPIMType(TYPE_JOIN_PRUNE_REQUEST);
+        }
+
+        // compute checksum if needed
+        if (this.checksum == 0) {
+            bb.rewind();
+            int accumulation = 0;
+
+            for (int i = 0; i < length / 2; ++i) {
+                accumulation += 0xffff & bb.getShort();
+            }
+            // pad to an even number of shorts
+            if (length % 2 > 0) {
+                accumulation += (bb.get() & 0xff) << 8;
+            }
+
+            accumulation = (accumulation >> 16 & 0xffff)
+                    + (accumulation & 0xffff);
+            this.checksum = (short) (~accumulation & 0xffff);
+            bb.putShort(2, this.checksum);
+        }
+        return data;
+    }
+
+    /**
+     * Deserialize the PIM packet.
+     *
+     * @param data bytes to deserialize.
+     * @param offset offset to start deserializing from
+     * @param length length of the data to deserialize
+     *
+     * @return the deserialized PIM packet.
+     */
+    @Override
+    public IPacket deserialize(final byte[] data, final int offset,
+            final int length) {
+        final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+        this.type = bb.get();
+        this.version = bb.get();
+        this.checksum = bb.getShort();
+
+        //this.payload = new Data();
+        this.payload = this.payload.deserialize(data, bb.position(), bb.limit() - bb.position());
+        this.payload.setParent(this);
+        return this;
+    }
+    /**
+     * Deserializer function for IPv4 packets.
+     *
+     * @return deserializer function
+     */
+    public static Deserializer<PIM> deserializer() {
+        return (data, offset, length) -> {
+            checkInput(data, offset, length, PIM_HEADER_LEN);
+
+            PIM pim = new PIM();
+
+            final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+
+            byte versionByte = bb.get();
+            pim.version = (byte) (versionByte >> 4 & 0xf);
+            pim.setPIMType((byte) (versionByte & 0xf));
+            pim.reserved = bb.get();
+            pim.checksum = bb.getShort();
+
+            Deserializer<? extends IPacket> deserializer;
+            if (PIM.PROTOCOL_DESERIALIZER_MAP.containsKey(pim.getPimMsgType())) {
+                deserializer = PIM.PROTOCOL_DESERIALIZER_MAP.get(pim.getPimMsgType());
+            } else {
+                deserializer = Data.deserializer();
+            }
+
+            pim.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position());
+            pim.payload.setParent(pim);
+
+            return pim;
+        };
+    }
+}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java
new file mode 100644 (file)
index 0000000..891a019
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * 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.onlab.packet.pim;
+
+import org.onlab.packet.DeserializationException;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip6Address;
+
+import java.nio.ByteBuffer;
+
+import static org.onlab.packet.PacketUtils.checkInput;
+
+public class PIMAddrGroup {
+    private byte family;
+    private byte encType;
+    private byte reserved;
+    private boolean bBit;
+    private boolean zBit;
+    private byte masklen;
+    IpAddress addr;
+
+    public static final int ENC_GROUP_IPV4_BYTE_LENGTH = 4 + Ip4Address.BYTE_LENGTH;
+    public static final int ENC_GROUP_IPV6_BYTE_LENGTH = 4 + Ip6Address.BYTE_LENGTH;
+
+    /**
+     * PIM Encoded Group Address.
+     */
+    public PIMAddrGroup() {
+        this.family = 4;
+        this.encType = 0;
+        this.reserved = 0;
+        this.bBit = false;
+        this.zBit = false;
+    }
+
+    /**
+     * PIM Encoded Source Address.
+     *
+     * @param addr IPv4 or IPv6
+     */
+    public PIMAddrGroup(String addr) {
+        this.setAddr(addr);
+    }
+
+    /**
+     * PIM Encoded Group Address.
+     *
+     * @param gpfx PIM encoded group address.
+     */
+    public PIMAddrGroup(IpPrefix gpfx) {
+        this.setAddr(gpfx);
+    }
+
+    /**
+     * PIM encoded source address.
+     *
+     * @param addr IPv4 or IPv6
+     */
+    public void setAddr(String addr) {
+        setAddr(IpPrefix.valueOf(addr));
+    }
+
+    /**
+     * Set the encoded source address.
+     *
+     * @param pfx address prefix
+     */
+    public void setAddr(IpPrefix pfx) {
+        this.addr = pfx.address();
+        this.masklen = (byte) pfx.prefixLength();
+        this.family = (byte) ((this.addr.isIp4()) ? 4 : 6);
+    }
+
+    /**
+     * Get the IP family of this address: 4 or 6.
+     *
+     * @return the IP address family
+     */
+    public int getFamily() {
+        return this.family;
+    }
+
+    /**
+     * Get the address of this encoded address.
+     *
+     * @return source address
+     */
+    public IpAddress getAddr() {
+        return this.addr;
+    }
+
+    /**
+     * Get the masklen of the group address.
+     *
+     * @return the masklen
+     */
+    public int getMasklen() {
+        return this.masklen;
+    }
+
+    /**
+     * Return the z bit for admin scoping. Only used for the Bootstrap router.
+     *
+     * @return true or false
+     */
+    public boolean getZBit() {
+        return this.zBit;
+    }
+
+    /**
+     * Return the bBit. Used to indicate this is a bidir
+     *
+     * @return return true or false.
+     */
+    public boolean getBBit() {
+        return this.bBit;
+    }
+
+    /**
+     * The size in bytes of a serialized address.
+     *
+     * @return the number of bytes when serialized
+     */
+    public int getByteSize() {
+        int size = 4;
+        size += addr.isIp4() ? 4 : 16;
+        return size;
+    }
+
+    /**
+     * Serialize this group address.
+     *
+     * @return the serialized address in a buffer
+     */
+    public byte[] serialize() {
+        int len = getByteSize();
+
+        final byte[] data = new byte[len];
+        final ByteBuffer bb = ByteBuffer.wrap(data);
+
+        bb.put(this.family);
+        bb.put(this.encType);
+
+        // Todo: technically we should be setting the B and Z bits, but we'll never use them.
+        bb.put(reserved);
+
+        bb.put(this.masklen);
+        bb.put(this.addr.toOctets());
+        return data;
+    }
+
+    /**
+     * Deserialze from a ByteBuffer.
+     *
+     * @param bb the ByteBuffer
+     * @return an encoded PIM group address
+     * @throws DeserializationException if unable to deserialize the packet data
+     */
+    public PIMAddrGroup deserialize(ByteBuffer bb) throws DeserializationException {
+
+        /*
+         * We need to verify that we have enough buffer space.  First we'll assume that
+         * we are decoding an IPv4 address.  After we read the first by (address family),
+         * we'll determine if we actually need more buffer space for an IPv6 address.
+         */
+        checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_GROUP_IPV4_BYTE_LENGTH);
+
+        this.family = bb.get();
+        if (family != 4 && family != 6) {
+            throw new DeserializationException("Illegal IP version number: " + family + "\n");
+        } else if (family == 6) {
+
+            // Check for one less by since we have already read the first byte of the packet.
+            checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_GROUP_IPV6_BYTE_LENGTH - 1);
+        }
+
+        this.encType = bb.get();
+        this.reserved = bb.get();
+        if ((this.reserved & 0x80) != 0) {
+            this.bBit = true;
+        }
+        if ((this.reserved & 0x01) != 0) {
+            this.zBit = true;
+        }
+        // Remove the z and b bits from reserved
+        this.reserved |= 0x7d;
+
+        this.masklen = bb.get();
+        if (this.family == 4) {
+            this.addr = IpAddress.valueOf(bb.getInt());
+        } else if (this.family == 6) {
+            this.addr = Ip6Address.valueOf(bb.array(), 2);
+        }
+        return this;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 2521;
+        int result = super.hashCode();
+        result = prime * result + this.family;
+        result = prime * result + this.encType;
+        result = prime * result + this.reserved;
+        result = prime * result + this.masklen;
+        result = prime * result + this.addr.hashCode();
+        return result;
+    }
+
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#equals()
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof PIMAddrGroup)) {
+            return false;
+        }
+        final PIMAddrGroup other = (PIMAddrGroup) obj;
+        if (this.family != this.family) {
+            return false;
+        }
+
+        if (this.encType != other.encType) {
+            return false;
+        }
+
+        if (!this.addr.equals(other.addr)) {
+            return false;
+        }
+        return true;
+    }
+}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java
new file mode 100644 (file)
index 0000000..2d4a781
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * 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.onlab.packet.pim;
+
+import org.onlab.packet.DeserializationException;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip6Address;
+
+import java.nio.ByteBuffer;
+
+import static org.onlab.packet.PacketUtils.checkInput;
+
+public class PIMAddrSource {
+    private byte family;
+    private byte encType;
+    private byte reserved;
+    private boolean sBit;
+    private boolean wBit;
+    private boolean rBit;
+    private byte masklen;
+    IpAddress addr;
+
+    public static final int ENC_SOURCE_IPV4_BYTE_LENGTH = 4 + Ip4Address.BYTE_LENGTH;
+    public static final int ENC_SOURCE_IPV6_BYTE_LENGTH = 4 + Ip6Address.BYTE_LENGTH;
+
+    /**
+     * PIM Encoded Source Address.
+     *
+     * @param addr IPv4 or IPv6
+     */
+    public PIMAddrSource(String addr) {
+        this.init();
+        this.setAddr(addr);
+    }
+
+    /**
+     * PIM Encoded Source Address.
+     *
+     * @param spfx IPv4 or IPv6
+     */
+    public PIMAddrSource(IpPrefix spfx) {
+        this.init();
+        this.setAddr(spfx);
+    }
+
+    /**
+     * PIM Encoded Group Address.
+     */
+    public PIMAddrSource() {
+        this.init();
+    }
+
+    private void init() {
+        this.family = 4;
+        this.encType = 0;
+        this.reserved = 0;
+        this.sBit = true;
+        this.wBit = false;
+        this.rBit = false;
+    }
+
+    /**
+     * PIM Encoded Source Address.
+     *
+     * @param addr IPv4 or IPv6
+     */
+    public void setAddr(String addr) {
+        IpPrefix spfx = IpPrefix.valueOf(addr);
+        setAddr(spfx);
+    }
+
+    /**
+     * PIM Encoded Source Address.
+     *
+     * @param spfx IPv4 or IPv6 address prefix
+     */
+    public void setAddr(IpPrefix spfx) {
+        this.addr = spfx.address();
+        this.masklen = (byte) spfx.prefixLength();
+        this.family = (byte) ((this.addr.isIp4()) ? 4 : 6);
+    }
+
+    /**
+     * Get the IP family of this address: 4 or 6.
+     *
+     * @return the IP address family
+     */
+    public byte getFamily() {
+        return this.family;
+    }
+
+    /**
+     * Get the address of this encoded address.
+     *
+     * @return source address
+     */
+    public IpAddress getAddr() {
+        return this.addr;
+    }
+
+    /**
+     * Get the masklen of the group address.
+     *
+     * @return the masklen
+     */
+    public int getMasklen() {
+        return this.masklen;
+    }
+
+    /**
+     * Return the sparse bit.
+     *
+     * @return true or false
+     */
+    public boolean getSBit() {
+        return this.sBit;
+    }
+
+    /**
+     * Return the wBit, used in Join/Prune messages.
+     *
+     * @return return true or false.
+     */
+    public boolean getWBit() {
+        return this.wBit;
+    }
+
+    /**
+     * Return the rBit. Used by Rendezvous Point.
+     *
+     * @return the rBit.
+     */
+    public boolean getRBit() {
+        return this.rBit;
+    }
+
+    /**
+     * The size in bytes of a serialized address.
+     *
+     * @return the number of bytes when serialized
+     */
+    public int getByteSize() {
+        int size = 4;
+        size += addr.isIp4() ? 4 : 16;
+        return size;
+    }
+
+    public byte[] serialize() {
+        int len = addr.isIp4() ? ENC_SOURCE_IPV4_BYTE_LENGTH : ENC_SOURCE_IPV6_BYTE_LENGTH;
+
+        final byte[] data = new byte[len];
+        final ByteBuffer bb = ByteBuffer.wrap(data);
+
+        bb.put(this.family);
+        bb.put(this.encType);
+
+        // Todo: technically we should be setting the B and Z bits, but we'll never use them.
+        byte mask = 0x0;
+        if (this.sBit) {
+            this.reserved |= 0x4;
+        }
+        if (this.wBit) {
+            this.reserved |= 0x2;
+        }
+        if (this.rBit) {
+            this.reserved |= 0x1;
+        }
+        bb.put(reserved);
+
+        bb.put(this.masklen);
+        bb.put(this.addr.toOctets());
+        return data;
+    }
+
+    public PIMAddrSource deserialize(byte[] data, int offset, int length) throws DeserializationException {
+        final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+        return deserialize(bb);
+    }
+
+    public PIMAddrSource deserialize(ByteBuffer bb) throws DeserializationException {
+
+        /*
+         * We need to verify that we have enough buffer space.  First we'll assume that
+         * we are decoding an IPv4 address.  After we read the first by (address family),
+         * we'll determine if we actually need more buffer space for an IPv6 address.
+         */
+        checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_SOURCE_IPV4_BYTE_LENGTH);
+
+        this.family = bb.get();
+        if (family != 4 && family != 6) {
+            throw new DeserializationException("Illegal IP version number: " + family + "\n");
+        } else if (family == 6) {
+
+            // Check for one less by since we have already read the first byte of the packet.
+            checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_SOURCE_IPV6_BYTE_LENGTH - 1);
+        }
+
+        this.encType = bb.get();
+        this.reserved = bb.get();
+        if ((this.reserved & 0x01) != 0) {
+            this.rBit = true;
+        }
+        if ((this.reserved & 0x02) != 0) {
+            this.wBit = true;
+        }
+        if ((this.reserved & 0x4) != 0) {
+            this.sBit = true;
+        }
+
+        // Remove the s, reserved
+        this.reserved &= 0xf8;
+
+        this.masklen = bb.get();
+        if (this.family == 4) {
+            this.addr = IpAddress.valueOf(bb.getInt());
+        } else if (this.family == 6) {
+            this.addr = Ip6Address.valueOf(bb.array(), 2);
+        }
+        return this;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 2521;
+        int result = super.hashCode();
+        result = prime * result + this.family;
+        result = prime * result + this.encType;
+        result = prime * result + this.reserved;
+        result = prime * result + this.masklen;
+        result = prime * result + this.addr.hashCode();
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof PIMAddrSource)) {
+            return false;
+        }
+        final PIMAddrSource other = (PIMAddrSource) obj;
+        if (this.family != this.family) {
+            return false;
+        }
+
+        if (this.encType != other.encType) {
+            return false;
+        }
+
+        if (!this.addr.equals(other.addr)) {
+            return false;
+        }
+        return true;
+    }
+}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java
new file mode 100644 (file)
index 0000000..0c2d676
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * 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.onlab.packet.pim;
+
+import org.onlab.packet.DeserializationException;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.Ip6Address;
+
+import java.nio.ByteBuffer;
+
+import static org.onlab.packet.PacketUtils.checkInput;
+
+public class PIMAddrUnicast {
+    private byte family;
+    private byte encType;
+    IpAddress addr;
+
+    public static final int ENC_UNICAST_IPV4_BYTE_LENGTH = 2 + Ip4Address.BYTE_LENGTH;
+    public static final int ENC_UNICAST_IPV6_BYTE_LENGTH = 2 + Ip6Address.BYTE_LENGTH;
+
+    /**
+     * PIM Encoded Source Address.
+     */
+    public PIMAddrUnicast() {
+        this.family = 4;
+        this.encType = 0;
+    }
+
+    /**
+     * PIM Encoded Source Address.
+     *
+     * @param addr IPv4 or IPv6
+     */
+    public PIMAddrUnicast(String addr) {
+        this.addr = IpAddress.valueOf(addr);
+        if (this.addr.isIp4()) {
+            this.family = 4;
+        } else {
+            this.family = 6;
+        }
+        this.encType = 0;
+    }
+
+    /**
+     * PIM Encoded Source Address.
+     *
+     * @param addr IPv4 or IPv6
+     */
+    public void setAddr(IpAddress addr) {
+        this.addr = addr;
+        if (this.addr.isIp4()) {
+            this.family = 4;
+        } else {
+            this.family = 6;
+        }
+    }
+
+    /**
+     * Get the address of this encoded address.
+     *
+     * @return source address
+     */
+    public IpAddress getAddr() {
+        return this.addr;
+    }
+
+    /**
+     * Get the IP family of this address: 4 or 6.
+     *
+     * @return the IP address family
+     */
+    public int getFamily() {
+        return this.family;
+    }
+
+    /**
+     * The size in bytes of a serialized address.
+     *
+     * @return the number of bytes when serialized
+     */
+    public int getByteSize() {
+        int size = 2;
+        if (addr != null) {
+            size += addr.isIp4() ? 4 : 16;
+        } else {
+            size += 4;
+        }
+        return size;
+    }
+
+    public byte[] serialize() {
+        int len = getByteSize();
+
+        final byte[] data = new byte[len];
+        final ByteBuffer bb = ByteBuffer.wrap(data);
+
+        bb.put(family);
+        bb.put(encType);
+        bb.put(addr.toOctets());
+        return data;
+    }
+
+    public PIMAddrUnicast deserialize(ByteBuffer bb) throws DeserializationException {
+
+        // Assume IPv4 for check length until we read the encoded family.
+        checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_UNICAST_IPV4_BYTE_LENGTH);
+        this.family = bb.get();
+
+        // If we have IPv6 we need to ensure we have adequate buffer space.
+        if (this.family != 4 && this.family != 6) {
+            throw new DeserializationException("Invalid address family: " + this.family);
+        } else if (this.family == 6) {
+            // Subtract -1 from ENC_UNICAST_IPv6 BYTE_LENGTH because we read one byte for family previously.
+            checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_UNICAST_IPV6_BYTE_LENGTH - 1);
+        }
+
+        this.encType = bb.get();
+        if (this.family == 4) {
+            this.addr = IpAddress.valueOf(bb.getInt());
+        } else if (this.family == 6) {
+            this.addr = Ip6Address.valueOf(bb.array(), 2);
+        }
+        return this;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 2521;
+        int result = super.hashCode();
+        result = prime * result + this.family;
+        result = prime * result + this.encType;
+        result = prime * result + this.addr.hashCode();
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof PIMAddrUnicast)) {
+            return false;
+        }
+        final PIMAddrUnicast other = (PIMAddrUnicast) obj;
+        if (this.family != this.family) {
+            return false;
+        }
+
+        if (this.encType != other.encType) {
+            return false;
+        }
+
+        if (!this.addr.equals(other.addr)) {
+            return false;
+        }
+        return true;
+    }
+}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHello.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHello.java
new file mode 100644 (file)
index 0000000..9ad3fdb
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * 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.onlab.packet.pim;
+
+import org.onlab.packet.BasePacket;
+import org.onlab.packet.Deserializer;
+import org.onlab.packet.IPacket;
+import org.onlab.packet.IpAddress;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.onlab.packet.PacketUtils.checkInput;
+
+public class PIMHello extends BasePacket {
+
+    private IpAddress nbrIpAddress;
+    private boolean priorityPresent = false;
+
+    private Map<Short, PIMHelloOption> options = new HashMap<>();
+
+    /**
+     * Create a PIM Hello packet with the most common hello options and default
+     * values.  The values of any options can be easily changed by modifying the value of
+     * the option with the desired change.
+     */
+    public void createDefaultOptions() {
+        options.put(PIMHelloOption.OPT_HOLDTIME, new PIMHelloOption(PIMHelloOption.OPT_HOLDTIME));
+        options.put(PIMHelloOption.OPT_PRIORITY, new PIMHelloOption(PIMHelloOption.OPT_PRIORITY));
+        options.put(PIMHelloOption.OPT_GENID, new PIMHelloOption(PIMHelloOption.OPT_GENID));
+    }
+
+    /**
+     * Add a PIM Hello option to this hello message.  Note
+     *
+     * @param opt the PIM Hello option we are adding
+     */
+    public void addOption(PIMHelloOption opt) {
+        this.options.put(opt.getOptType(), opt);
+    }
+
+    public Map<Short, PIMHelloOption> getOptions() {
+        return this.options;
+    }
+
+    /**
+     * Sets all payloads parent packet if applicable, then serializes this
+     * packet and all payloads.
+     *
+     * @return a byte[] containing this packet and payloads
+     */
+    @Override
+    public byte[] serialize() {
+        int totalLen = 0;
+
+
+         // Since we are likely to only have 3-4 options, go head and walk the
+         // hashmap twice, once to calculate the space needed to allocate a
+         // buffer, the second time serialize the options into the buffer.  This
+         // saves us from allocating an over sized buffer the re-allocating and
+         // copying.
+        for (Short optType : options.keySet()) {
+            PIMHelloOption opt = options.get(optType);
+            totalLen += PIMHelloOption.MINIMUM_OPTION_LEN_BYTES + opt.getOptLength();
+        }
+
+        byte[] data = new byte[totalLen];
+        ByteBuffer bb = ByteBuffer.wrap(data);
+
+        // Now serialize the data.
+        for (Short optType : options.keySet()) {
+            PIMHelloOption opt = options.get(optType);
+            bb.put(opt.serialize());
+        }
+        return data;
+    }
+
+    /**
+     * XXX: This is deprecated, DO NOT USE, use the deserializer() function instead.
+     */
+    public IPacket deserialize(final byte[] data, final int offset,
+                               final int length) {
+        // TODO: throw an expection?
+        return null;
+    }
+
+    /**
+     * Deserialize this hello message.
+     *
+     * @return a deserialized hello message
+     */
+    public static Deserializer<PIMHello> deserializer() {
+        return (data, offset, length) -> {
+            checkInput(data, offset, length, PIMHelloOption.MINIMUM_OPTION_LEN_BYTES);
+            final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+
+            PIMHello hello = new PIMHello();
+            while (bb.hasRemaining()) {
+                PIMHelloOption opt = PIMHelloOption.deserialize(bb);
+                hello.addOption(opt);
+            }
+            return hello;
+        };
+    }
+}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHelloOption.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHelloOption.java
new file mode 100644 (file)
index 0000000..bf021fb
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * 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.onlab.packet.pim;
+
+import org.onlab.packet.DeserializationException;
+
+import java.nio.ByteBuffer;
+import java.text.MessageFormat;
+
+import static org.onlab.packet.PacketUtils.checkBufferLength;
+import static org.onlab.packet.PacketUtils.checkInput;
+
+public class PIMHelloOption {
+
+    /**
+     * PIM Option types.
+     */
+    public static final short OPT_HOLDTIME = 1;
+    public static final short OPT_PRUNEDELAY = 2;
+    public static final short OPT_PRIORITY = 19;
+    public static final short OPT_GENID = 20;
+    public static final short OPT_ADDRLIST = 24;
+
+    public static final short DEFAULT_HOLDTIME = 105;
+    public static final int DEFAULT_PRUNEDELAY = 2000; // 2,000 ms
+    public static final int DEFAULT_PRIORITY = 1;
+    public static final int DEFAULT_GENID = 0;
+
+    public static final int MINIMUM_OPTION_LEN_BYTES = 4;
+
+    // Values for this particular hello option.
+    private short optType;
+    private short optLength;
+    private byte[] optValue;
+
+    public PIMHelloOption() {
+    }
+
+    /**
+     * Set a PIM Hello option by type. The length and default value of the
+     * type will be auto filled in by default.
+     *
+     * @param type hello option type
+     */
+    public PIMHelloOption(short type) {
+        this.optType = type;
+        switch (type) {
+            case OPT_HOLDTIME:
+                this.optLength = 2;
+                this.optValue = new byte[optLength];
+                ByteBuffer.wrap(this.optValue).putShort(PIMHelloOption.DEFAULT_HOLDTIME);
+                break;
+
+            case OPT_PRUNEDELAY:
+                this.optLength = 4;
+                this.optValue = new byte[this.optLength];
+                ByteBuffer.wrap(this.optValue).putInt(PIMHelloOption.DEFAULT_PRUNEDELAY);
+                break;
+
+            case OPT_PRIORITY:
+                this.optLength = 4;
+                this.optValue = new byte[this.optLength];
+                ByteBuffer.wrap(this.optValue).putInt(PIMHelloOption.DEFAULT_PRIORITY);
+                break;
+
+            case OPT_GENID:
+                this.optLength = 4;
+                this.optValue = new byte[this.optLength];
+                ByteBuffer.wrap(this.optValue).putInt(PIMHelloOption.DEFAULT_GENID);
+                break;
+
+            case OPT_ADDRLIST:
+                this.optLength = 0;   // We don't know what the length will be yet.
+                this.optValue = null;
+
+            default:
+                //log.error("Unkown option type: " + type + "\n" );
+                return;
+        }
+    }
+
+    public void setOptType(short type) {
+        this.optType = type;
+    }
+
+    public short getOptType() {
+        return this.optType;
+    }
+
+    public void setOptLength(short len) {
+        this.optLength = len;
+    }
+
+    public short getOptLength() {
+        return this.optLength;
+    }
+
+    public void setValue(ByteBuffer bb) throws DeserializationException {
+        this.optValue = new byte[this.optLength];
+        bb.get(this.optValue, 0, this.optLength);
+    }
+
+    public byte[] getValue() {
+        return this.optValue;
+    }
+
+    public static PIMHelloOption deserialize(ByteBuffer bb) throws DeserializationException {
+        checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), 4);
+
+        PIMHelloOption opt = new PIMHelloOption();
+        opt.setOptType(bb.getShort());
+        opt.setOptLength(bb.getShort());
+
+        checkBufferLength(bb.limit(), bb.position(), opt.getOptLength());
+        opt.setValue(bb);
+
+        return opt;
+    }
+
+    public byte [] serialize() {
+        int len = 4 + this.optLength;
+        ByteBuffer bb = ByteBuffer.allocate(len);
+        bb.putShort(this.optType);
+        bb.putShort(this.optLength);
+        bb.put(this.optValue);
+        return bb.array();
+    }
+
+    public String toString() {
+        return MessageFormat.format("Type: {0}, len: {1} value: {2}", this.optType, this.optLength,
+                (this.optValue == null) ? "null" : this.optValue.toString());
+    }
+
+}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMJoinPrune.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMJoinPrune.java
new file mode 100644 (file)
index 0000000..9653115
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * 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.onlab.packet.pim;
+
+import org.onlab.packet.BasePacket;
+import org.onlab.packet.Deserializer;
+import org.onlab.packet.IPacket;
+import org.onlab.packet.IpPrefix;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+
+import static org.onlab.packet.PacketUtils.checkInput;
+
+public class PIMJoinPrune extends BasePacket {
+
+    private PIMAddrUnicast upstreamAddr = new PIMAddrUnicast();
+    private short holdTime = (short) 0xffff;
+
+    private class JoinPruneGroup {
+        protected IpPrefix group;
+        protected HashMap<IpPrefix, IpPrefix> joins = new HashMap<>();
+        protected HashMap<IpPrefix, IpPrefix> prunes = new HashMap<>();
+
+        public JoinPruneGroup(IpPrefix grp) {
+            group = grp;
+        }
+    }
+    private HashMap<IpPrefix, JoinPruneGroup> joinPrunes = new HashMap<>();
+
+    /**
+     * Get the J/P hold time.
+     *
+     * @return specified in seconds.
+     */
+    public short getHoldTime() {
+        return holdTime;
+    }
+
+    /**
+     * Set the J/P holdtime in seconds.
+     *
+     * @param holdTime return the holdtime.
+     */
+    public void setHoldTime(short holdTime) {
+        this.holdTime = holdTime;
+    }
+
+    /**
+     * Get the upstreamAddr for this J/P request.
+     *
+     * @return the upstream address.
+     */
+    public PIMAddrUnicast getUpstreamAddr() {
+        return upstreamAddr;
+    }
+
+    /**
+     * Set the upstream address of this PIM J/P request.
+     *
+     * @param upstr the PIM Upstream unicast address
+     */
+    public void setUpstreamAddr(PIMAddrUnicast upstr) {
+        this.upstreamAddr = upstr;
+    }
+
+    /**
+     * Add the specified s,g to join field.
+     *
+     * @param saddr the source address of the route
+     * @param gaddr the group address of the route
+     * @param join true for a join, false for a prune.
+     */
+    public void addJoinPrune(String saddr, String gaddr, boolean join) {
+        IpPrefix gpfx = IpPrefix.valueOf(gaddr);
+        IpPrefix spfx = IpPrefix.valueOf(saddr);
+        addJoinPrune(spfx, gpfx, join);
+    }
+
+    /**
+     * Add the specified S, G to the join field.
+     *
+     * @param spfx the source prefix of the route
+     * @param gpfx the group prefix of the route
+     * @param join true for join, false for prune
+     */
+    public void addJoinPrune(IpPrefix spfx, IpPrefix gpfx, boolean join) {
+        JoinPruneGroup jpg = joinPrunes.get(gpfx);
+        if (jpg == null) {
+            jpg = new JoinPruneGroup(gpfx);
+            joinPrunes.put(gpfx, jpg);
+        }
+
+        HashMap<IpPrefix, IpPrefix> members = (join) ? jpg.joins : jpg.prunes;
+        if (members.get(spfx) == null) {
+            members.put(spfx, spfx);
+        }
+    }
+
+    /**
+     * Add a join given strings represending the source and group addresses.
+     *
+     * @param saddr source address
+     * @param gaddr group address
+     */
+    public void addJoin(String saddr, String gaddr) {
+        this.addJoinPrune(saddr, gaddr, true);
+    }
+
+    /**
+     * Add a prune given strings represending the source and group addresses.
+     *
+     * @param saddr source address
+     * @param gaddr group address
+     */
+    public void addPrune(String saddr, String gaddr) {
+        this.addJoinPrune(saddr, gaddr, false);
+    }
+
+    /**
+     * Sets all payloads parent packet if applicable, then serializes this
+     * packet and all payloads.
+     *
+     * @return a byte[] containing this packet and payloads
+     */
+    @Override
+    public byte[] serialize() {
+
+        byte[] data = new byte[8096];      // Come up with something better
+        ByteBuffer bb = ByteBuffer.wrap(data);
+
+        bb.put(upstreamAddr.serialize());
+        bb.put((byte) 0);    // reserved
+
+        int ngrps = joinPrunes.size();
+        bb.put((byte) ngrps);
+        bb.putShort(this.holdTime);
+
+        // Walk the group list and input all groups
+        for (JoinPruneGroup jpg : joinPrunes.values()) {
+            PIMAddrGroup grp = new PIMAddrGroup(jpg.group);
+            bb.put(grp.serialize());
+
+            // put the number of joins and prunes
+            bb.putShort((short) jpg.joins.size());
+            bb.putShort((short) jpg.prunes.size());
+
+            // Set all of the joins
+            for (IpPrefix spfx : jpg.joins.values()) {
+                PIMAddrSource src = new PIMAddrSource(spfx);
+                bb.put(src.serialize());
+            }
+
+            // Set all of the prunes
+            for (IpPrefix spfx : jpg.prunes.values()) {
+                PIMAddrSource src = new PIMAddrSource(spfx);
+                bb.put(src.serialize());
+            }
+        }
+
+        int len = bb.position();
+        byte[] data2 = new byte[len];
+        bb = ByteBuffer.wrap(data2, 0, len);
+        bb.put(data, 0, len);
+        return data2;
+    }
+
+    // TODO: I suppose I really need to implement this?
+    @Override
+    public IPacket deserialize(final byte[] data, final int offset,
+                               final int length) {
+        final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+        return this;
+    }
+
+    /**
+     * Return the J/P deserializer function.
+     *
+     * @return a function that will deserialize a J/P message.
+     */
+    public static Deserializer<PIMJoinPrune> deserializer() {
+        return (data, offset, length) -> {
+
+            /*
+             * Delay buffer checks until we read enough of the packet to know how
+             * much data we will require.  Each encoded address deserializer function
+             * will ensure there is enough data for that address.
+             */
+            PIMJoinPrune jp = new PIMJoinPrune();
+            final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+
+            // We must get a PIM encoded unicast address
+            PIMAddrUnicast upstream = new PIMAddrUnicast();
+            upstream.deserialize(bb);
+            jp.setUpstreamAddr(upstream);
+
+            // Use this boolean to determine the buffer space we need according to address sizes
+            boolean ipv4 = upstream.getAddr().isIp4();
+
+            // We need at minimum 4 bytes for reserved(1), ngroups(1) & holdtime(2)
+            checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), 4);
+
+            // get and skip the reserved byte
+            bb.get();
+
+            // Get the number of groups.
+            int ngroups = bb.get();
+
+            // Save the holdtime.
+            jp.setHoldTime(bb.getShort());
+
+
+            for (int i = 0; i < ngroups; i++) {
+                PIMAddrGroup grp = new PIMAddrGroup();
+
+                /*
+                 * grp.deserialize will ensure the buffer has enough data to read the group address.
+                 */
+                grp.deserialize(bb);
+
+                checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), 4);
+                int njoins = bb.getShort();
+                int nprunes = bb.getShort();
+
+                /*
+                 * Now we'll verify we have enough buffer to read the next
+                 * group of join and prune addresses for this group.
+                 */
+                int required = (njoins + nprunes) *
+                        (ipv4 ? PIMAddrSource.ENC_SOURCE_IPV4_BYTE_LENGTH : PIMAddrSource.ENC_SOURCE_IPV6_BYTE_LENGTH);
+                checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), required);
+
+                // Now iterate through the joins for this group
+                for (; njoins > 0; njoins--) {
+
+                    PIMAddrSource src = new PIMAddrSource();
+                    src.deserialize(bb);
+
+                    jp.addJoinPrune(
+                            src.getAddr().toIpPrefix(),
+                            grp.getAddr().toIpPrefix(), true);
+                }
+
+                // Now iterate through the prunes for this group
+                for (; nprunes > 0; nprunes--) {
+
+                    PIMAddrSource src = new PIMAddrSource();
+                    src.deserialize(bb);
+                    jp.addJoinPrune(
+                            src.getAddr().toIpPrefix(),
+                            grp.getAddr().toIpPrefix(), false);
+                }
+            }
+
+            return jp;
+        };
+    }
+}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/package-info.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/package-info.java
new file mode 100755 (executable)
index 0000000..88a1ad5
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Utilities for managing PIM packets.
+ */
+package org.onlab.packet.pim;
+
diff --git a/framework/src/onos/utils/misc/src/test/java/org/onlab/packet/PIMTest.java b/framework/src/onos/utils/misc/src/test/java/org/onlab/packet/PIMTest.java
new file mode 100644 (file)
index 0000000..7fba3cd
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * 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.onlab.packet;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.pim.PIMAddrUnicast;
+import org.onlab.packet.pim.PIMHello;
+import org.onlab.packet.pim.PIMJoinPrune;
+
+import static junit.framework.Assert.assertTrue;
+
+public final class PIMTest {
+
+    public static final String SADDR = "10.2.1.2";
+    public static final String PIMADDR = "224.0.0.13";
+    public static final String PIMUADDR = "10.23.3.5";
+
+    public static final String SADDR1 = "10.1.1.1/32";
+    public static final String SADDR2 = "10.1.2.1/32";
+    public static final String GADDR1 = "232.1.1.1/32";
+    public static final String GADDR2 = "232.1.2.1/32";
+
+    public static final String CPSTR1 = "of:deadbeefball/8";
+    public static final String CPSTR2 = "of:deadbeefcafe/3";
+    public static final String CPSTR3 = "of:2badcafef00d/3";
+
+    private Deserializer<PIM> deserializer;
+
+    private PIM pimHello;
+    private PIMHello hello;
+
+    private PIM pimJoinPrune;
+    private PIMJoinPrune joinPrune;
+
+    /**
+     * Create PIM Hello and Join/Prune packets to be used in testing.
+     *
+     * @throws Exception if packet creation fails
+     */
+    @Before
+    public void setUp() throws Exception {
+
+        // Create a PIM Hello
+        pimHello = new PIM();
+        pimHello.setVersion((byte) 2);
+        pimHello.setPIMType((byte) PIM.TYPE_HELLO);
+        pimHello.setChecksum((short) 0);
+
+        hello = new PIMHello();
+        hello.createDefaultOptions();
+        pimHello.setPayload(hello);
+        hello.setParent(pimHello);
+
+        // Create PIM Join Prune
+        pimJoinPrune = new PIM();
+        pimJoinPrune.setVersion((byte) 2);
+        pimJoinPrune.setPIMType((byte) PIM.TYPE_JOIN_PRUNE_REQUEST);
+        pimJoinPrune.setChecksum((short) 0);
+
+        joinPrune = new PIMJoinPrune();
+        joinPrune.setUpstreamAddr(new PIMAddrUnicast(SADDR));
+        joinPrune.addJoin(GADDR1, SADDR1);
+        joinPrune.addJoin(GADDR2, SADDR2);
+        joinPrune.addPrune(GADDR1, SADDR2);
+        joinPrune.addPrune(GADDR2, SADDR1);
+
+        pimJoinPrune.setPayload(joinPrune);
+        joinPrune.setParent(pimJoinPrune);
+
+        deserializer = PIM.deserializer();
+    }
+
+    /**
+     * Make sure our deserializer throws an exception if we recieve bad input.
+     *
+     * @throws Exception if we are given bad input.
+     */
+    @Test
+    public void testDeserializeBadInput() throws Exception {
+        PacketTestUtils.testDeserializeBadInput(deserializer);
+    }
+
+    /**
+     * Verify we throw an exception if we receive a truncated Join/Prune message.
+     *
+     * @throws Exception if we receive a truncated Join/Prune message.
+     */
+    @Test
+    public void testDeserializeTruncated() throws Exception {
+        byte [] bits = pimJoinPrune.serialize();
+        PacketTestUtils.testDeserializeTruncated(deserializer, bits);
+    }
+
+    /**
+     * Verify that we correctly deserialize hello messages.
+     *
+     * @throws Exception if our input is bad or truncated.
+     */
+    @Test
+    public void testDeserializeHello() throws Exception {
+        byte [] data = pimHello.serialize();
+        PIM pim = deserializer.deserialize(data, 0, data.length);
+        assertTrue(pim.equals(pimHello));
+    }
+
+    /**
+     * Verify that we correctly deserialize Join/Prune messages.
+     *
+     * @throws Exception if our input is bad or truncated.
+     */
+    @Test
+    public void testDeserializeJoinPrune() throws Exception {
+        byte [] data = pimJoinPrune.serialize();
+        PIM pim = deserializer.deserialize(data, 0, data.length);
+        assertTrue(pim.equals(pimJoinPrune));
+    }
+
+}
\ No newline at end of file
index 2765212..e04e29a 100644 (file)
@@ -21,12 +21,14 @@ import com.esotericsoftware.minlog.Log;
 
 import junit.framework.TestCase;
 
+import static org.junit.Assert.fail;
+
 /**
  * Test of the Hexstring.
  *
  */
 
-public class HexStringTest extends TestCase {
+public class HexStringTest {
 
     @Test
     public void testMarshalling() throws Exception {
index fa320d5..5ce4838 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index b9e4d44..8395766 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 7be6c69..cf79312 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 2adbba7..c2fa5dc 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index ce2bd84..c9a7df7 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 23affc4..241822c 100755 (executable)
@@ -5,7 +5,7 @@
 
 STC_ROOT=${STC_ROOT:-$(dirname $0)/..}
 cd $STC_ROOT
-VER=1.3.0-SNAPSHOT
+VER=1.4.0-SNAPSHOT
 
 PATH=$PWD/bin:$PATH
 
index a3f9643..a71dcfe 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onlab-utils</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 8e3aad5..ef1c31f 100644 (file)
@@ -108,6 +108,15 @@ public class Coordinator {
         // FIXME: implement this
     }
 
+    /**
+     * Returns number of milliseconds it took to execute.
+     *
+     * @return number of millis elapsed during the run
+     */
+    public long duration() {
+        return store.endTime() - store.startTime();
+    }
+
     /**
      * Returns a list of steps that match the specified list of patterns.
      *
index 09b8945..bc10ec7 100644 (file)
@@ -44,11 +44,12 @@ public final class Main {
     private static final String GREEN = "\u001B[32;1m";
     private static final String BLUE = "\u001B[36m";
 
-    private static final String SUCCESS_SUMMARY = "%sPassed! %d steps succeeded%s";
+    private static final String SUCCESS_SUMMARY =
+            "%s %sPassed! %d steps succeeded%s";
     private static final String MIXED_SUMMARY =
             "%s%d steps succeeded; %s%d steps failed; %s%d steps skipped%s";
-    private static final String FAILURE_SUMMARY = "%sFailed! " + MIXED_SUMMARY;
-    private static final String ABORTED_SUMMARY = "%sAborted! " + MIXED_SUMMARY;
+    private static final String FAILURE_SUMMARY = "%s %sFailed! " + MIXED_SUMMARY;
+    private static final String ABORTED_SUMMARY = "%s %sAborted! " + MIXED_SUMMARY;
 
     private boolean isReported = false;
 
@@ -180,6 +181,7 @@ public final class Main {
     private void processList() {
         coordinator.getRecords()
                 .forEach(event -> logStatus(event.time(), event.name(), event.status(), event.command()));
+        printSummary(0, false);
         System.exit(0);
     }
 
@@ -201,14 +203,15 @@ public final class Main {
         if (!isReported) {
             isReported = true;
             Set<Step> steps = coordinator.getSteps();
+            String duration = formatDuration((int) (coordinator.duration() / 1_000));
             int count = steps.size();
             if (exitCode == 0) {
-                print(SUCCESS_SUMMARY, color(SUCCEEDED), count, color(null));
+                print(SUCCESS_SUMMARY, duration, color(SUCCEEDED), count, color(null));
             } else {
                 long success = steps.stream().filter(s -> coordinator.getStatus(s) == SUCCEEDED).count();
                 long failed = steps.stream().filter(s -> coordinator.getStatus(s) == FAILED).count();
                 long skipped = steps.stream().filter(s -> coordinator.getStatus(s) == SKIPPED).count();
-                print(isAborted ? ABORTED_SUMMARY : FAILURE_SUMMARY,
+                print(isAborted ? ABORTED_SUMMARY : FAILURE_SUMMARY, duration,
                       color(FAILED), color(SUCCEEDED), success,
                       color(FAILED), failed, color(SKIPPED), skipped, color(null));
             }
@@ -281,6 +284,17 @@ public final class Main {
         }
     }
 
+    // Formats time duration
+    private static String formatDuration(int totalSeconds) {
+        int seconds = totalSeconds % 60;
+        int totalMinutes = totalSeconds / 60;
+        int minutes = totalMinutes % 60;
+        int hours = totalMinutes / 60;
+        return hours > 0 ?
+                String.format("%d:%02d:%02d", hours, minutes, seconds) :
+                String.format("%d:%02d", minutes, seconds);
+    }
+
     // Shutdown hook to report status even when aborted.
     private class ShutdownHook extends Thread {
         @Override
index d37222b..7313462 100644 (file)
@@ -43,6 +43,9 @@ class ScenarioStore {
     private final List<StepEvent> events = Lists.newArrayList();
     private final Map<String, Status> statusMap = Maps.newConcurrentMap();
 
+    private long startTime = Long.MAX_VALUE;
+    private long endTime = Long.MIN_VALUE;
+
     /**
      * Creates a new scenario store for the specified process flow.
      *
@@ -69,6 +72,8 @@ class ScenarioStore {
             PropertiesConfiguration cfg = new PropertiesConfiguration(storeFile);
             cfg.clear();
             cfg.save();
+            startTime = Long.MAX_VALUE;
+            endTime = Long.MIN_VALUE;
         } catch (ConfigurationException e) {
             print("Unable to store file %s", storeFile);
         }
@@ -156,6 +161,8 @@ class ScenarioStore {
     private synchronized void add(StepEvent event) {
         events.add(event);
         statusMap.put(event.name(), event.status());
+        startTime = Math.min(startTime, event.time());
+        endTime = Math.max(endTime, event.time());
     }
 
     /**
@@ -198,4 +205,22 @@ class ScenarioStore {
         }
     }
 
+    /**
+     * Returns the scenario run start time.
+     *
+     * @return start time in mills since start of epoch
+     */
+    public long startTime() {
+        return startTime;
+    }
+
+    /**
+     * Returns the scenario run end time or current time if the scenario
+     * is still running.
+     *
+     * @return end time (or current time) in mills since start of epoch
+     */
+    public long endTime() {
+        return endTime > 0 ? endTime : System.currentTimeMillis();
+    }
 }
index f5c8167..bb5e3e0 100644 (file)
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.onosproject</groupId>
     <artifactId>onlab-utils</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.4.0-SNAPSHOT</version>
     <relativePath>../pom.xml</relativePath>
   </parent>
 
index b420186..99aeab2 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-web</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 4ce7e93..6b8480a 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos-web</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
index 13ce939..1684818 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * 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.ui.impl;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
diff --git a/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java b/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java
new file mode 100644 (file)
index 0000000..07f4802
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Topology resources for the ONOS GUI.
+ */
+package org.onosproject.ui.impl.topo;
index 46f4232..d7b6fe0 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onosproject</groupId>
         <artifactId>onos</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.4.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>