From 81391595dca425ae58e2294898f09f11d9a32dbc Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Tue, 22 Sep 2015 12:49:09 -0700 Subject: bringing src to commit tag 65d551b50e782b0c1ea76c1a9ed1c5a801a5a7e4 Change-Id: Ib2da78962eaef856f418636c31b0f5c84286244f --- framework/src/onos/apps/aaa/pom.xml | 2 +- framework/src/onos/apps/acl/pom.xml | 6 +- .../org/onos/acl/impl/DistributedAclStore.java | 4 +- .../main/java/org/onos/acl/impl/package-info.java | 20 + .../src/main/java/org/onos/acl/package-info.java | 20 + framework/src/onos/apps/bgprouter/app.xml | 1 - framework/src/onos/apps/bgprouter/features.xml | 1 - framework/src/onos/apps/bgprouter/pom.xml | 8 +- framework/src/onos/apps/cip/pom.xml | 2 +- .../java/org/onosproject/cip/package-info.java | 21 + framework/src/onos/apps/cordfabric/pom.xml | 2 +- framework/src/onos/apps/cordvtn/pom.xml | 54 ++ .../org/onosproject/cordvtn/ConnectionHandler.java | 36 + .../main/java/org/onosproject/cordvtn/CordVtn.java | 311 ++++++++ .../org/onosproject/cordvtn/CordVtnConfig.java | 101 +++ .../org/onosproject/cordvtn/CordVtnService.java | 57 ++ .../org/onosproject/cordvtn/DefaultOvsdbNode.java | 97 +++ .../onosproject/cordvtn/NodeConnectionManager.java | 145 ++++ .../java/org/onosproject/cordvtn/OvsdbNode.java | 74 ++ framework/src/onos/apps/demo/cord-gui/pom.xml | 2 +- .../cord/gui/model/XosFunctionFactory.java | 15 + .../onos/apps/demo/cord-gui/src/scripts/pullwar.sh | 2 +- .../src/onos/apps/demo/cord-gui/src/scripts/run.me | 2 +- framework/src/onos/apps/dhcp/pom.xml | 2 +- .../java/org/onosproject/dhcp/DhcpService.java | 3 +- .../main/java/org/onosproject/dhcp/DhcpStore.java | 23 +- .../java/org/onosproject/dhcp/IpAssignment.java | 19 +- .../onosproject/dhcp/cli/DhcpListAllMappings.java | 6 +- .../org/onosproject/dhcp/cli/package-info.java | 20 + .../java/org/onosproject/dhcp/impl/DhcpConfig.java | 148 +++- .../org/onosproject/dhcp/impl/DhcpManager.java | 214 +++--- .../dhcp/impl/DhcpViewMessageHandler.java | 19 +- .../dhcp/impl/DistributedDhcpStore.java | 186 ++--- .../org/onosproject/dhcp/impl/package-info.java | 20 + .../java/org/onosproject/dhcp/package-info.java | 20 + .../org/onosproject/dhcp/rest/DHCPWebResource.java | 13 +- .../org/onosproject/dhcp/rest/package-info.java | 20 + .../src/main/resources/app/view/dhcp/dhcp.html | 8 +- .../org/onosproject/dhcp/IpAssignmentTest.java | 5 +- .../org/onosproject/dhcp/impl/DhcpManagerTest.java | 25 +- .../apps/dhcp/src/test/resources/dhcp-cfg.json | 4 +- framework/src/onos/apps/flowanalyzer/pom.xml | 2 +- framework/src/onos/apps/fwd/pom.xml | 2 +- framework/src/onos/apps/metrics/pom.xml | 2 +- .../onosproject/metrics/intent/IntentMetrics.java | 2 +- .../metrics/topology/TopologyMetrics.java | 2 +- framework/src/onos/apps/mobility/pom.xml | 2 +- framework/src/onos/apps/olt/pom.xml | 2 +- framework/src/onos/apps/optical/pom.xml | 2 +- .../optical/cfg/OpticalNetworkConfig.java | 4 +- framework/src/onos/apps/pcep-api/pom.xml | 37 +- framework/src/onos/apps/pom.xml | 6 +- framework/src/onos/apps/proxyarp/pom.xml | 2 +- .../java/org/onosproject/proxyarp/ProxyArp.java | 6 +- framework/src/onos/apps/reactive-routing/pom.xml | 2 +- framework/src/onos/apps/routing-api/pom.xml | 2 +- .../org/onosproject/routing/config/Interface.java | 13 - framework/src/onos/apps/routing/pom.xml | 2 +- .../onosproject/routing/bgp/BgpSessionManager.java | 27 +- .../config/impl/RoutingConfigurationImpl.java | 14 +- .../java/org/onosproject/routing/impl/Router.java | 7 +- .../routing/bgp/BgpSessionManagerTest.java | 22 +- framework/src/onos/apps/sdnip/pom.xml | 8 +- .../org/onosproject/sdnip/IntentSynchronizer.java | 2 +- framework/src/onos/apps/segmentrouting/pom.xml | 2 +- .../segmentrouting/DeviceConfiguration.java | 25 +- .../segmentrouting/ECMPShortestPathGraph.java | 26 +- .../org/onosproject/segmentrouting/IpHandler.java | 4 +- .../segmentrouting/RoutingRulePopulator.java | 2 +- .../segmentrouting/config/NetworkConfig.java | 19 +- .../config/NetworkConfigException.java | 15 + .../config/NetworkConfigManager.java | 29 +- .../config/NetworkConfigService.java | 15 + .../segmentrouting/config/PktLinkConfig.java | 17 +- .../segmentrouting/config/SegmentRouterConfig.java | 23 +- .../grouphandler/DefaultEdgeGroupHandler.java | 6 +- .../grouphandler/DefaultGroupHandler.java | 16 +- .../grouphandler/DefaultTransitGroupHandler.java | 8 +- .../segmentrouting/grouphandler/NeighborSet.java | 6 +- framework/src/onos/apps/test/demo/pom.xml | 2 +- .../main/java/org/onosproject/demo/DemoAPI.java | 2 +- .../java/org/onosproject/demo/DemoInstaller.java | 9 +- .../onos/apps/test/distributed-primitives/pom.xml | 4 +- .../cli/CounterTestIncrementCommand.java | 4 +- .../cli/SetTestAddCommand.java | 2 +- .../cli/SetTestGetCommand.java | 4 +- .../cli/SetTestRemoveCommand.java | 2 +- framework/src/onos/apps/test/election/pom.xml | 2 +- framework/src/onos/apps/test/intent-perf/pom.xml | 2 +- .../src/onos/apps/test/messaging-perf/pom.xml | 2 +- .../messagingperf/MessagingPerfApp.java | 15 + framework/src/onos/apps/test/pom.xml | 2 +- framework/src/onos/apps/virtualbng/pom.xml | 2 +- framework/src/onos/apps/vtn/pom.xml | 26 +- .../java/org/onosproject/vtn/impl/VTNManager.java | 46 +- framework/src/onos/apps/vtnrsc/pom.xml | 17 +- .../org/onosproject/vtnrsc/AllocationPool.java | 76 +- .../org/onosproject/vtnrsc/AllowedAddressPair.java | 188 ++--- .../java/org/onosproject/vtnrsc/BindingHostId.java | 129 ++-- .../onosproject/vtnrsc/DefaultAllocationPool.java | 162 ++-- .../org/onosproject/vtnrsc/DefaultHostRoute.java | 158 ++-- .../java/org/onosproject/vtnrsc/DefaultSubnet.java | 366 ++++----- .../onosproject/vtnrsc/DefaultTenantNetwork.java | 320 ++++---- .../org/onosproject/vtnrsc/DefaultVirtualPort.java | 458 ++++++------ .../main/java/org/onosproject/vtnrsc/FixedIp.java | 186 ++--- .../java/org/onosproject/vtnrsc/HostRoute.java | 78 +- .../org/onosproject/vtnrsc/PhysicalNetwork.java | 156 ++-- .../java/org/onosproject/vtnrsc/SecurityGroup.java | 154 ++-- .../org/onosproject/vtnrsc/SegmentationId.java | 154 ++-- .../main/java/org/onosproject/vtnrsc/Subnet.java | 258 +++---- .../main/java/org/onosproject/vtnrsc/SubnetId.java | 152 ++-- .../main/java/org/onosproject/vtnrsc/TenantId.java | 154 ++-- .../java/org/onosproject/vtnrsc/TenantNetwork.java | 260 +++---- .../org/onosproject/vtnrsc/TenantNetworkId.java | 152 ++-- .../java/org/onosproject/vtnrsc/VirtualPort.java | 312 ++++---- .../java/org/onosproject/vtnrsc/VirtualPortId.java | 140 ++-- .../vtnrsc/cli/network/package-info.java | 20 + .../vtnrsc/cli/subnet/SubnetUpdateCommand.java | 2 +- .../vtnrsc/cli/subnet/package-info.java | 20 + .../vtnrsc/cli/virtualport/package-info.java | 20 + .../onosproject/vtnrsc/subnet/SubnetService.java | 144 ++-- .../vtnrsc/subnet/impl/SubnetManager.java | 362 ++++----- .../vtnrsc/subnet/impl/package-info.java | 20 + .../onosproject/vtnrsc/subnet/package-info.java | 20 + .../vtnrsc/tenantnetwork/TenantNetworkService.java | 160 ++-- .../tenantnetwork/impl/TenantNetworkManager.java | 334 ++++----- .../vtnrsc/tenantnetwork/impl/package-info.java | 20 + .../vtnrsc/tenantnetwork/package-info.java | 20 + .../vtnrsc/tunnel/TunnelConfigService.java | 144 ++-- .../onosproject/vtnrsc/tunnel/package-info.java | 20 + .../vtnrsc/virtualport/VirtualPortService.java | 200 ++--- .../virtualport/impl/VirtualPortManager.java | 444 +++++------ .../vtnrsc/virtualport/impl/package-info.java | 20 + .../vtnrsc/virtualport/package-info.java | 20 + .../vtnrsc/web/AllocationPoolsCodec.java | 80 +- .../vtnrsc/web/AllowedAddressPairCodec.java | 80 +- .../org/onosproject/vtnrsc/web/FixedIpCodec.java | 80 +- .../onosproject/vtnrsc/web/HostRoutesCodec.java | 80 +- .../onosproject/vtnrsc/web/SecurityGroupCodec.java | 78 +- .../org/onosproject/vtnrsc/web/SubnetCodec.java | 106 +-- .../onosproject/vtnrsc/web/TenantNetworkCodec.java | 94 +-- .../onosproject/vtnrsc/web/VirtualPortCodec.java | 114 +-- .../org/onosproject/vtnrsc/web/package-info.java | 20 + framework/src/onos/apps/vtnweb/pom.xml | 150 ++-- .../vtnweb/resources/SubnetWebResource.java | 730 +++++++++--------- .../vtnweb/resources/TenantNetworkWebResource.java | 743 ++++++++++--------- .../vtnweb/resources/VirtualPortWebResource.java | 820 ++++++++++----------- framework/src/onos/apps/xos-integration/pom.xml | 2 +- framework/src/onos/cli/pom.xml | 2 +- .../main/java/org/onosproject/cli/Comparators.java | 8 - .../org/onosproject/cli/MetricNameCompleter.java | 2 +- .../onosproject/cli/cfg/NetworkConfigCommand.java | 12 +- .../org/onosproject/cli/net/AddMplsIntent.java | 15 + .../cli/net/LinkResourceTestCommand.java | 15 + .../cli/net/PacketProcessorsListCommand.java | 59 ++ .../cli/net/PacketRequestsListCommand.java | 47 ++ .../resources/OSGI-INF/blueprint/shell-config.xml | 10 +- framework/src/onos/core/api/pom.xml | 2 +- .../cluster/ClusterDefinitionService.java | 15 + .../org/onosproject/cluster/ControllerNode.java | 2 +- .../java/org/onosproject/core/CoreService.java | 4 +- .../java/org/onosproject/core/MetricsHelper.java | 2 +- .../src/main/java/org/onosproject/net/Device.java | 2 +- .../main/java/org/onosproject/net/IpElementId.java | 15 + .../net/config/basics/BasicLinkConfig.java | 24 + .../net/config/basics/OpticalPortConfig.java | 15 + .../org/onosproject/net/flow/DefaultFlowRule.java | 19 +- .../java/org/onosproject/net/flow/FlowRule.java | 6 +- .../onosproject/net/flow/FlowRuleExtPayLoad.java | 15 + .../org/onosproject/net/flow/FlowRuleService.java | 2 +- .../org/onosproject/net/flow/TrafficSelector.java | 1 - .../net/flow/criteria/MplsBosCriterion.java | 15 + .../onosproject/net/flowobjective/Objective.java | 6 +- .../org/onosproject/net/host/HostAdminService.java | 34 - .../onosproject/net/host/HostProviderService.java | 15 +- .../java/org/onosproject/net/host/HostService.java | 20 - .../java/org/onosproject/net/host/HostStore.java | 54 +- .../org/onosproject/net/intent/MplsIntent.java | 15 + .../org/onosproject/net/intent/MplsPathIntent.java | 15 + .../org/onosproject/net/intent/PathIntent.java | 9 +- .../onosproject/net/newresource/ResourceStore.java | 15 + .../org/onosproject/net/packet/PacketPriority.java | 4 +- .../onosproject/net/packet/PacketProcessor.java | 14 +- .../org/onosproject/net/packet/PacketService.java | 20 + .../org/onosproject/net/packet/PacketStore.java | 6 +- .../onosproject/net/proxyarp/ProxyArpService.java | 2 +- .../java/org/onosproject/security/AppGuard.java | 3 + .../org/onosproject/security/AppPermission.java | 3 + .../java/org/onosproject/security/Permission.java | 3 + .../onosproject/security/SecurityAdminService.java | 2 + .../org/onosproject/security/SecurityUtil.java | 2 + .../onosproject/store/service/DatabaseUpdate.java | 2 +- .../java/org/onosproject/ui/UiTopoOverlay.java | 1 - .../org/onosproject/ui/UiTopoOverlayFactory.java | 1 - .../org/onosproject/ui/table/CellComparator.java | 1 - .../org/onosproject/ui/table/CellFormatter.java | 1 - .../ui/table/cell/AbstractCellComparator.java | 1 - .../ui/table/cell/AbstractCellFormatter.java | 1 - .../onosproject/ui/table/cell/AppIdFormatter.java | 1 - .../ui/table/cell/ConnectPointFormatter.java | 1 - .../ui/table/cell/DefaultCellComparator.java | 1 - .../ui/table/cell/DefaultCellFormatter.java | 1 - .../onosproject/ui/table/cell/HexFormatter.java | 1 - .../ui/table/cell/HostLocationFormatter.java | 1 - .../onosproject/ui/table/cell/TimeFormatter.java | 1 - .../org/onosproject/ui/topo/AbstractHighlight.java | 1 - .../java/org/onosproject/ui/topo/BaseLink.java | 1 - .../java/org/onosproject/ui/topo/BaseLinkMap.java | 1 - .../main/java/org/onosproject/ui/topo/BiLink.java | 1 - .../java/org/onosproject/ui/topo/BiLinkMap.java | 1 - .../java/org/onosproject/ui/topo/ButtonId.java | 1 - .../org/onosproject/ui/topo/DeviceHighlight.java | 1 - .../java/org/onosproject/ui/topo/Highlights.java | 1 - .../org/onosproject/ui/topo/HostHighlight.java | 1 - .../org/onosproject/ui/topo/LinkHighlight.java | 1 - .../src/main/java/org/onosproject/ui/topo/Mod.java | 1 - .../org/onosproject/ui/topo/NodeHighlight.java | 1 - .../org/onosproject/ui/topo/NodeSelection.java | 1 - .../org/onosproject/ui/topo/PropertyPanel.java | 1 - .../org/onosproject/ui/topo/TopoConstants.java | 1 - .../org/onosproject/ui/topo/TopoElementType.java | 1 - .../java/org/onosproject/ui/topo/TopoJson.java | 1 - .../java/org/onosproject/ui/topo/TopoUtils.java | 1 - .../event/EventDeliveryServiceAdapter.java | 2 - .../java/org/onosproject/net/OchSignalTest.java | 2 - .../net/device/DeviceClockServiceAdapter.java | 15 + .../net/device/DeviceServiceAdapter.java | 9 +- .../net/flow/FlowRuleExtPayLoadTest.java | 15 + .../onosproject/net/host/HostServiceAdapter.java | 20 +- .../onosproject/net/intent/FakeIntentManager.java | 29 +- .../onosproject/net/intent/IntentServiceTest.java | 36 +- .../net/intent/PartitionServiceAdapter.java | 2 - .../onosproject/net/link/LinkServiceAdapter.java | 9 +- .../net/packet/PacketServiceAdapter.java | 13 + .../store/service/DatabaseUpdateTest.java | 5 +- .../onosproject/store/service/MapEventTest.java | 5 +- .../store/service/MultiValuedTimestampTest.java | 5 +- .../onosproject/store/service/VersionedTest.java | 3 +- .../org/onosproject/ui/table/TableUtilsTest.java | 1 - .../ui/table/cell/AbstractCellComparatorTest.java | 1 - .../ui/table/cell/AbstractCellFormatterTest.java | 1 - .../ui/table/cell/AppIdFormatterTest.java | 1 - .../ui/table/cell/ConnectPointFormatterTest.java | 1 - .../ui/table/cell/DefaultCellComparatorTest.java | 1 - .../ui/table/cell/DefaultCellFormatterTest.java | 1 - .../ui/table/cell/HexFormatterTest.java | 1 - .../ui/table/cell/HostLocationFormatterTest.java | 1 - .../ui/table/cell/TimeFormatterTest.java | 1 - .../org/onosproject/ui/topo/BiLinkMapTest.java | 1 - .../java/org/onosproject/ui/topo/BiLinkTest.java | 1 - .../org/onosproject/ui/topo/BiLinkTestBase.java | 1 - .../java/org/onosproject/ui/topo/ButtonIdTest.java | 1 - .../org/onosproject/ui/topo/HighlightsTest.java | 1 - .../org/onosproject/ui/topo/LinkHighlightTest.java | 1 - .../test/java/org/onosproject/ui/topo/ModTest.java | 1 - .../org/onosproject/ui/topo/NodeSelectionTest.java | 1 - .../org/onosproject/ui/topo/PropertyPanelTest.java | 1 - .../java/org/onosproject/ui/topo/TopoJsonTest.java | 1 - framework/src/onos/core/common/pom.xml | 2 +- .../onosproject/codec/impl/MockCodecContext.java | 2 +- .../store/trivial/SimpleDeviceStore.java | 9 +- .../store/trivial/SimpleDeviceStoreTest.java | 33 +- .../store/trivial/SimpleFlowRuleStore.java | 11 +- .../store/trivial/SimpleGroupStore.java | 17 +- .../store/trivial/SimpleGroupStoreTest.java | 20 +- .../onosproject/store/trivial/SimpleHostStore.java | 96 +-- .../onosproject/store/trivial/SimpleLinkStore.java | 3 +- .../store/trivial/SimpleLinkStoreTest.java | 33 +- .../store/trivial/SimpleMastershipStore.java | 8 +- .../store/trivial/SimplePacketStore.java | 8 +- framework/src/onos/core/net/pom.xml | 2 +- .../org/onosproject/core/impl/CoreManager.java | 2 +- .../net/edgeservice/impl/package-info.java | 16 + .../org/onosproject/net/host/impl/HostManager.java | 38 +- .../org/onosproject/net/host/impl/HostMonitor.java | 48 +- .../intent/impl/compiler/MplsIntentCompiler.java | 15 + .../OpticalConnectivityIntentCompiler.java | 48 +- .../net/link/impl/BasicLinkOperator.java | 42 ++ .../org/onosproject/net/link/impl/LinkManager.java | 81 +- .../onosproject/net/packet/impl/PacketManager.java | 14 +- .../net/proxyarp/impl/ProxyArpManager.java | 359 +++++---- .../net/statistic/impl/StatisticManager.java | 22 +- .../net/device/impl/BasicDeviceOperatorTest.java | 7 +- .../net/device/impl/OpticalPortOperatorTest.java | 15 + .../net/group/impl/GroupManagerTest.java | 4 +- .../net/host/impl/BasicHostOperatorTest.java | 7 +- .../onosproject/net/host/impl/HostManagerTest.java | 294 +------- .../onosproject/net/host/impl/HostMonitorTest.java | 25 +- .../net/intent/impl/MockFlowRuleService.java | 8 +- .../impl/compiler/MplsIntentCompilerTest.java | 15 + .../net/link/impl/BasicLinkOperatorTest.java | 7 +- framework/src/onos/core/pom.xml | 2 +- framework/src/onos/core/security/pom.xml | 17 +- .../security/impl/DefaultPolicyBuilder.java | 15 + .../security/impl/SecurityModeManager.java | 20 +- .../onosproject/security/store/package-info.java | 20 + framework/src/onos/core/store/dist/pom.xml | 2 +- .../cluster/impl/ClusterDefinitionManager.java | 15 + .../messaging/impl/IOLoopMessagingManager.java | 15 + .../messaging/impl/NettyMessagingManager.java | 15 + .../impl/ConsistentMapBackedJavaMap.java | 15 + .../store/consistent/impl/DatabaseManager.java | 3 +- .../consistent/impl/DefaultDatabaseState.java | 2 +- .../core/impl/ConsistentApplicationIdStore.java | 4 - .../store/core/impl/ConsistentIdBlockStore.java | 15 + .../store/core/impl/LogicalClockManager.java | 15 + .../store/device/impl/DeviceDescriptions.java | 10 +- .../store/device/impl/DeviceInjectedEvent.java | 15 + .../store/device/impl/GossipDeviceStore.java | 12 +- .../store/device/impl/PortFragmentId.java | 2 +- .../store/device/impl/PortInjectedEvent.java | 15 + .../onosproject/store/flow/ReplicaInfoEvent.java | 2 +- .../store/group/impl/DistributedGroupStore.java | 6 +- .../onosproject/store/host/impl/ECHostStore.java | 530 +++++++------ .../onosproject/store/impl/LogicalTimestamp.java | 15 + .../onosproject/store/link/impl/ECLinkStore.java | 17 +- .../store/link/impl/GossipLinkStore.java | 3 +- .../store/link/impl/LinkInjectedEvent.java | 15 + .../store/mastership/impl/RoleValue.java | 6 +- .../store/packet/impl/DistributedPacketStore.java | 14 +- .../store/proxyarp/impl/package-info.java | 20 + .../resource/impl/ConsistentLinkResourceStore.java | 15 + .../statistic/impl/DistributedStatisticStore.java | 2 +- .../impl/ClusterCommunicationManagerTest.java | 2 +- .../store/consistent/impl/MatchTest.java | 15 + .../store/consistent/impl/ResultTest.java | 15 + .../store/consistent/impl/UpdateResultTest.java | 27 +- .../store/device/impl/GossipDeviceStoreTest.java | 33 +- .../store/flow/impl/ReplicaInfoManagerTest.java | 2 +- .../onosproject/store/impl/TimestampedTest.java | 2 +- .../store/link/impl/GossipLinkStoreTest.java | 33 +- framework/src/onos/core/store/pom.xml | 2 +- framework/src/onos/core/store/serializers/pom.xml | 2 +- .../store/serializers/AnnotationsSerializer.java | 15 + framework/src/onos/docs/external.xml | 4 +- framework/src/onos/docs/internal-apis | 2 - framework/src/onos/docs/internal-core | 31 +- framework/src/onos/docs/internal-incubator | 4 + framework/src/onos/docs/internal.xml | 4 +- framework/src/onos/drivers/pom.xml | 4 +- .../driver/pipeline/CentecV350Pipeline.java | 15 + .../onosproject/driver/pipeline/CorsaPipeline.java | 15 + .../driver/pipeline/CpqdOFDPA1Pipeline.java | 15 + .../driver/pipeline/SoftRouterPipeline.java | 15 + framework/src/onos/features/pom.xml | 2 +- framework/src/onos/incubator/api/pom.xml | 2 +- .../net/config/basics/ConfigException.java | 3 + .../net/config/basics/ExtraSubjectFactories.java | 2 + .../net/config/basics/InterfaceConfig.java | 2 + .../incubator/net/domain/TunnelPrimitive.java | 2 + .../onosproject/incubator/net/intf/Interface.java | 2 + .../incubator/net/intf/InterfaceService.java | 2 + .../net/resource/label/DefaultLabelResource.java | 15 + .../net/resource/label/LabelResource.java | 15 + .../resource/label/LabelResourceAdminService.java | 15 + .../net/resource/label/LabelResourceDelegate.java | 15 + .../net/resource/label/LabelResourceEvent.java | 15 + .../net/resource/label/LabelResourceId.java | 15 + .../net/resource/label/LabelResourceListener.java | 15 + .../net/resource/label/LabelResourcePool.java | 15 + .../net/resource/label/LabelResourceProvider.java | 15 + .../label/LabelResourceProviderRegistry.java | 15 + .../label/LabelResourceProviderService.java | 15 + .../net/resource/label/LabelResourceRequest.java | 15 + .../net/resource/label/LabelResourceService.java | 15 + .../net/resource/label/LabelResourceStore.java | 15 + .../net/tunnel/DefaultTunnelStatistics.java | 27 +- .../net/tunnel/TunnelEndPointFormatter.java | 17 + .../incubator/net/tunnel/TunnelStatistics.java | 27 +- .../net/config/basics/OpticalPortConfigTest.java | 15 + .../resource/label/DefaultLabelResourceTest.java | 15 + .../net/resource/label/LabelResourcePoolTest.java | 15 + .../resource/label/LabelResourceRequestTest.java | 15 + .../incubator/net/tunnel/DefaultTunnelTest.java | 15 + .../incubator/net/tunnel/TunnelEventTest.java | 15 + framework/src/onos/incubator/net/pom.xml | 2 +- .../incubator/net/intf/impl/package-info.java | 20 + .../incubator/net/intf/package-info.java | 20 + .../incubator/net/meter/impl/package-info.java | 20 + .../resource/label/impl/LabelResourceManager.java | 15 + .../net/intf/impl/InterfaceManagerTest.java | 287 ++++++++ framework/src/onos/incubator/pom.xml | 2 +- framework/src/onos/incubator/store/pom.xml | 2 +- .../incubator/store/meter/impl/package-info.java | 21 + .../impl/DistributedLabelResourceStore.java | 15 + .../impl/LabelResourceMessageSubjects.java | 15 + framework/src/onos/openflow/api/pom.xml | 2 +- .../openflow/controller/OpenFlowOpticalSwitch.java | 15 + .../openflow/controller/PortDescPropertyType.java | 15 + .../openflow/controller/ThirdPartyMessage.java | 15 + .../openflow/controller/WithTypedPorts.java | 15 + framework/src/onos/openflow/ctl/pom.xml | 2 +- framework/src/onos/openflow/pom.xml | 2 +- framework/src/onos/ovsdb/api/pom.xml | 2 +- framework/src/onos/ovsdb/ctl/pom.xml | 2 +- framework/src/onos/ovsdb/pom.xml | 2 +- framework/src/onos/ovsdb/rfc/pom.xml | 25 +- .../ovsdb/rfc/exception/package-info.java | 20 + .../ovsdb/rfc/jsonrpc/package-info.java | 20 + .../ovsdb/rfc/message/package-info.java | 20 + .../ovsdb/rfc/notation/json/package-info.java | 20 + .../ovsdb/rfc/notation/package-info.java | 20 + .../ovsdb/rfc/operations/package-info.java | 20 + .../onosproject/ovsdb/rfc/schema/package-info.java | 20 + .../ovsdb/rfc/schema/type/package-info.java | 20 + .../onosproject/ovsdb/rfc/table/OpenVSwitch.java | 15 + .../java/org/onosproject/ovsdb/rfc/table/Port.java | 15 + .../onosproject/ovsdb/rfc/table/package-info.java | 20 + .../ovsdb/rfc/tableservice/package-info.java | 20 + .../onosproject/ovsdb/rfc/utils/MutationUtil.java | 15 + .../onosproject/ovsdb/rfc/utils/package-info.java | 20 + framework/src/onos/pcep/api/pom.xml | 2 +- framework/src/onos/pcep/ctl/pom.xml | 2 +- framework/src/onos/pcep/pcepio/pom.xml | 2 +- .../pcepio/protocol/ver1/PcepErrorMsgVer1.java | 15 + .../pcepio/protocol/ver1/PcepErrorObjectVer1.java | 15 + .../pcepio/protocol/ver1/PcepMsgPathVer1.java | 15 + .../pcepio/types/ErrorObjListWithOpen.java | 15 + .../onosproject/pcepio/types/PathSetupTypeTlv.java | 15 + .../pcepio/types/PceccCapabilityTlv.java | 15 + .../pcepio/types/PcepLabelDbVerTlv.java | 15 + .../pcepio/types/PcepLabelDownload.java | 15 + .../types/PcepNaiUnnumberedAdjacencyIpv4.java | 15 + .../pcepio/types/PcepRsvpIpv6ErrorSpec.java | 15 + .../java/org/onosproject/pcepio/util/HexDump.java | 15 + framework/src/onos/pcep/pom.xml | 2 +- framework/src/onos/pom.xml | 2 +- framework/src/onos/providers/host/pom.xml | 2 +- .../host/impl/HostLocationProviderTest.java | 2 +- framework/src/onos/providers/lldp/pom.xml | 2 +- .../provider/lldp/impl/DiscoveryContext.java | 69 ++ .../provider/lldp/impl/LLDPLinkProvider.java | 357 ++++++--- .../provider/lldp/impl/LinkDiscovery.java | 228 ++---- .../provider/lldp/impl/LLDPLinkProviderTest.java | 10 +- .../provider/lldp/impl/SuppressionRulesTest.java | 15 + .../src/onos/providers/netconf/app/features.xml | 24 +- framework/src/onos/providers/netconf/app/pom.xml | 2 +- .../src/onos/providers/netconf/device/pom.xml | 2 +- framework/src/onos/providers/netconf/flow/pom.xml | 2 +- framework/src/onos/providers/netconf/pom.xml | 2 +- framework/src/onos/providers/null/pom.xml | 2 +- .../src/onos/providers/openflow/app/features.xml | 24 +- framework/src/onos/providers/openflow/app/pom.xml | 2 +- .../src/onos/providers/openflow/device/pom.xml | 2 +- framework/src/onos/providers/openflow/flow/pom.xml | 2 +- .../src/onos/providers/openflow/group/pom.xml | 2 +- .../of/group/impl/OpenFlowGroupProviderTest.java | 15 + .../src/onos/providers/openflow/meter/pom.xml | 2 +- .../src/onos/providers/openflow/packet/pom.xml | 2 +- framework/src/onos/providers/openflow/pom.xml | 2 +- framework/src/onos/providers/ovsdb/app/pom.xml | 2 +- framework/src/onos/providers/ovsdb/device/pom.xml | 2 +- framework/src/onos/providers/ovsdb/host/pom.xml | 2 +- .../ovsdb/provider/host/OvsdbHostProvider.java | 296 ++++---- .../ovsdb/provider/host/OvsdbHostProviderTest.java | 2 +- framework/src/onos/providers/ovsdb/pom.xml | 17 +- framework/src/onos/providers/ovsdb/tunnel/pom.xml | 2 +- framework/src/onos/providers/pcep/app/features.xml | 24 +- framework/src/onos/providers/pcep/app/pom.xml | 17 +- framework/src/onos/providers/pcep/pom.xml | 17 +- framework/src/onos/providers/pcep/topology/pom.xml | 17 +- framework/src/onos/providers/pcep/tunnel/pom.xml | 17 +- .../pcep/tunnel/impl/TunnelStatsCollector.java | 24 +- .../pcep/tunnel/impl/PcepClientAdapter.java | 15 + .../tunnel/impl/PcepClientControllerAdapter.java | 15 + .../tunnel/impl/TunnelProviderRegistryAdapter.java | 15 + .../pcep/tunnel/impl/TunnelServiceAdapter.java | 15 + framework/src/onos/providers/pom.xml | 2 +- framework/src/onos/tools/build/envDefaults | 4 +- framework/src/onos/tools/build/onos-package | 102 +-- framework/src/onos/tools/build/onosUploadBits.py | 2 +- .../src/onos/tools/package/archetypes/api/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../onos/tools/package/archetypes/bundle/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/onos/tools/package/archetypes/cli/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/onos/tools/package/archetypes/pom.xml | 2 +- .../src/onos/tools/package/archetypes/ui/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- framework/src/onos/tools/package/branding/pom.xml | 2 +- framework/src/onos/tools/package/deb/control | 8 + framework/src/onos/tools/package/deb/copyright | 20 + framework/src/onos/tools/package/deb/postinst | 16 + framework/src/onos/tools/package/deb/postrm | 5 + framework/src/onos/tools/package/deb/prerm | 23 + framework/src/onos/tools/package/init/onos.conf | 37 + framework/src/onos/tools/package/rpm/onos.spec | 71 ++ .../src/onos/tools/test/bin/onos-archetypes-test | 2 +- .../src/onos/tools/test/bin/onos-check-intent | 2 +- framework/src/onos/tools/test/bin/onos-check-logs | 20 + framework/src/onos/tools/test/bin/onos-install | 2 +- .../src/onos/tools/test/bin/onos-start-network | 26 +- framework/src/onos/tools/test/bin/onos-topo-cfg | 3 +- framework/src/onos/tools/test/bin/onos-uninstall | 10 + framework/src/onos/tools/test/bin/stc | 16 +- framework/src/onos/tools/test/cells/office | 3 +- .../src/onos/tools/test/configs/office-dhcp.json | 22 + .../onos/tools/test/scenarios/bin/curl-with-retry | 23 + .../test/scenarios/bin/find-link-in-cluster.py | 54 ++ .../test/scenarios/bin/find-topo-infrastructure.py | 34 + .../onos/tools/test/scenarios/bin/query-cluster.py | 37 + .../onos/tools/test/scenarios/bin/query-topo.py | 35 + .../test/scenarios/bin/verify-topo-devices.py | 51 ++ .../onos/tools/test/scenarios/net-link-down-up.xml | 14 +- .../src/onos/tools/test/scenarios/net-pingall.xml | 4 +- .../src/onos/tools/test/scenarios/net-rest.xml | 19 +- .../src/onos/tools/test/scenarios/net-setup.xml | 6 +- .../src/onos/tools/test/scenarios/net-smoke.xml | 6 +- .../src/onos/tools/test/scenarios/net-topo.xml | 76 ++ .../onos/tools/test/scenarios/prerequisites.xml | 2 +- framework/src/onos/tools/test/topos/onos.py | 2 +- .../src/onos/tools/test/topos/opticalUtils.py | 74 +- framework/src/onos/utils/jdvue/bin/jdvue | 2 +- framework/src/onos/utils/jdvue/pom.xml | 26 +- .../src/main/java/org/onlab/jdvue/Catalog.java | 15 + .../src/main/java/org/onlab/jdvue/Dependency.java | 15 + .../main/java/org/onlab/jdvue/DependencyCycle.java | 15 + .../java/org/onlab/jdvue/DependencyViewer.java | 15 + .../src/main/java/org/onlab/jdvue/JavaEntity.java | 15 + .../src/main/java/org/onlab/jdvue/JavaPackage.java | 15 + .../src/main/java/org/onlab/jdvue/JavaSource.java | 15 + .../src/test/java/org/onlab/jdvue/CatalogTest.java | 15 + .../java/org/onlab/jdvue/DependencyCycleTest.java | 15 + .../test/java/org/onlab/jdvue/DependencyTest.java | 15 + .../java/org/onlab/jdvue/DependencyViewerTest.java | 15 + framework/src/onos/utils/jnc/pom.xml | 2 +- framework/src/onos/utils/junit/pom.xml | 2 +- framework/src/onos/utils/misc/pom.xml | 2 +- .../src/main/java/org/onlab/graph/GAOrganism.java | 15 + .../main/java/org/onlab/graph/GAPopulation.java | 15 + .../misc/src/main/java/org/onlab/packet/IPv4.java | 2 + .../misc/src/main/java/org/onlab/packet/MPLS.java | 15 + .../misc/src/main/java/org/onlab/packet/PIM.java | 296 ++++++++ .../java/org/onlab/packet/pim/PIMAddrGroup.java | 257 +++++++ .../java/org/onlab/packet/pim/PIMAddrSource.java | 281 +++++++ .../java/org/onlab/packet/pim/PIMAddrUnicast.java | 182 +++++ .../main/java/org/onlab/packet/pim/PIMHello.java | 118 +++ .../java/org/onlab/packet/pim/PIMHelloOption.java | 147 ++++ .../java/org/onlab/packet/pim/PIMJoinPrune.java | 271 +++++++ .../java/org/onlab/packet/pim/package-info.java | 21 + .../src/test/java/org/onlab/packet/PIMTest.java | 132 ++++ .../test/java/org/onlab/util/HexStringTest.java | 4 +- framework/src/onos/utils/netty/pom.xml | 2 +- framework/src/onos/utils/nio/pom.xml | 2 +- framework/src/onos/utils/osgi/pom.xml | 2 +- framework/src/onos/utils/pom.xml | 2 +- framework/src/onos/utils/rest/pom.xml | 2 +- framework/src/onos/utils/stc/bin/stc | 2 +- framework/src/onos/utils/stc/pom.xml | 2 +- .../src/main/java/org/onlab/stc/Coordinator.java | 9 + .../stc/src/main/java/org/onlab/stc/Main.java | 24 +- .../src/main/java/org/onlab/stc/ScenarioStore.java | 25 + framework/src/onos/utils/thirdparty/pom.xml | 2 +- framework/src/onos/web/api/pom.xml | 2 +- framework/src/onos/web/gui/pom.xml | 2 +- .../ui/impl/TunnelViewMessageHandler.java | 15 + .../org/onosproject/ui/impl/topo/package-info.java | 20 + framework/src/onos/web/pom.xml | 2 +- 559 files changed, 13083 insertions(+), 7115 deletions(-) create mode 100644 framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java create mode 100644 framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java create mode 100644 framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java create mode 100644 framework/src/onos/apps/cordvtn/pom.xml create mode 100644 framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java create mode 100644 framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java create mode 100644 framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java create mode 100644 framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java create mode 100644 framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java create mode 100644 framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java create mode 100644 framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java create mode 100644 framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java create mode 100644 framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java create mode 100644 framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java create mode 100644 framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java create mode 100644 framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java create mode 100644 framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java create mode 100644 framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java create mode 100644 framework/src/onos/core/security/src/main/java/org/onosproject/security/store/package-info.java create mode 100644 framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/proxyarp/impl/package-info.java create mode 100644 framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/package-info.java create mode 100644 framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/package-info.java create mode 100644 framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/package-info.java create mode 100644 framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/intf/impl/InterfaceManagerTest.java create mode 100644 framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/package-info.java create mode 100644 framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/package-info.java create mode 100644 framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/DiscoveryContext.java create mode 100644 framework/src/onos/tools/package/deb/control create mode 100644 framework/src/onos/tools/package/deb/copyright create mode 100755 framework/src/onos/tools/package/deb/postinst create mode 100755 framework/src/onos/tools/package/deb/postrm create mode 100755 framework/src/onos/tools/package/deb/prerm create mode 100644 framework/src/onos/tools/package/init/onos.conf create mode 100644 framework/src/onos/tools/package/rpm/onos.spec create mode 100644 framework/src/onos/tools/test/configs/office-dhcp.json create mode 100755 framework/src/onos/tools/test/scenarios/bin/curl-with-retry create mode 100755 framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py create mode 100755 framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py create mode 100755 framework/src/onos/tools/test/scenarios/bin/query-cluster.py create mode 100755 framework/src/onos/tools/test/scenarios/bin/query-topo.py create mode 100755 framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py create mode 100644 framework/src/onos/tools/test/scenarios/net-topo.xml create mode 100755 framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java create mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java create mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java create mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java create mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHello.java create mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHelloOption.java create mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMJoinPrune.java create mode 100755 framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/package-info.java create mode 100644 framework/src/onos/utils/misc/src/test/java/org/onlab/packet/PIMTest.java create mode 100644 framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java (limited to 'framework') diff --git a/framework/src/onos/apps/aaa/pom.xml b/framework/src/onos/apps/aaa/pom.xml index 6f850750..78fd4a62 100644 --- a/framework/src/onos/apps/aaa/pom.xml +++ b/framework/src/onos/apps/aaa/pom.xml @@ -23,7 +23,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/acl/pom.xml b/framework/src/onos/apps/acl/pom.xml index 20f784fc..54dee432 100644 --- a/framework/src/onos/apps/acl/pom.xml +++ b/framework/src/onos/apps/acl/pom.xml @@ -24,19 +24,19 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml onos-app-acl - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT bundle ONOS ACL application http://onosproject.org - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT org.onosproject.acl DLUT /onos/acl diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java index 6d909a97..5c8a93cb 100644 --- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java +++ b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java @@ -234,7 +234,7 @@ public class DistributedAclStore extends AbstractStore implements AclStore { ruleToDevice.computeIf(ruleId, deviceIdSet -> (deviceIdSet == null || !deviceIdSet.contains(deviceId)), (id, deviceIdSet) -> { - Set newSet = new HashSet(); + Set 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 index 00000000..e9aa1448 --- /dev/null +++ b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java @@ -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 index 00000000..fa4131ee --- /dev/null +++ b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java @@ -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; diff --git a/framework/src/onos/apps/bgprouter/app.xml b/framework/src/onos/apps/bgprouter/app.xml index c85e469a..2fc47be9 100644 --- a/framework/src/onos/apps/bgprouter/app.xml +++ b/framework/src/onos/apps/bgprouter/app.xml @@ -22,5 +22,4 @@ mvn:${project.groupId}/onos-app-routing-api/${project.version} mvn:${project.groupId}/onos-app-routing/${project.version} mvn:${project.groupId}/onos-app-proxyarp/${project.version} - mvn:${project.groupId}/onos-app-config/${project.version} diff --git a/framework/src/onos/apps/bgprouter/features.xml b/framework/src/onos/apps/bgprouter/features.xml index 3457321c..c91a7f10 100644 --- a/framework/src/onos/apps/bgprouter/features.xml +++ b/framework/src/onos/apps/bgprouter/features.xml @@ -20,7 +20,6 @@ description="${project.description}"> onos-api mvn:${project.groupId}/onos-app-routing-api/${project.version} - mvn:${project.groupId}/onos-app-config/${project.version} mvn:${project.groupId}/onos-app-proxyarp/${project.version} mvn:${project.groupId}/onos-app-bgprouter/${project.version} mvn:${project.groupId}/onos-app-routing/${project.version} diff --git a/framework/src/onos/apps/bgprouter/pom.xml b/framework/src/onos/apps/bgprouter/pom.xml index d3f6f522..decdf5c2 100644 --- a/framework/src/onos/apps/bgprouter/pom.xml +++ b/framework/src/onos/apps/bgprouter/pom.xml @@ -20,7 +20,7 @@ onos-apps org.onosproject - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml 4.0.0 @@ -58,12 +58,6 @@ guava - - org.onosproject - onos-app-config - ${project.version} - - org.onosproject onos-app-proxyarp diff --git a/framework/src/onos/apps/cip/pom.xml b/framework/src/onos/apps/cip/pom.xml index a3645931..77cfe150 100644 --- a/framework/src/onos/apps/cip/pom.xml +++ b/framework/src/onos/apps/cip/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml 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 index 00000000..1d358eb0 --- /dev/null +++ b/framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java @@ -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; diff --git a/framework/src/onos/apps/cordfabric/pom.xml b/framework/src/onos/apps/cordfabric/pom.xml index f5388553..a10db440 100644 --- a/framework/src/onos/apps/cordfabric/pom.xml +++ b/framework/src/onos/apps/cordfabric/pom.xml @@ -20,7 +20,7 @@ onos-apps org.onosproject - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml 4.0.0 diff --git a/framework/src/onos/apps/cordvtn/pom.xml b/framework/src/onos/apps/cordvtn/pom.xml new file mode 100644 index 00000000..a019bec2 --- /dev/null +++ b/framework/src/onos/apps/cordvtn/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + + org.onosproject + onos-apps + 1.4.0-SNAPSHOT + ../pom.xml + + + onos-app-cordvtn + bundle + + Virtual tenant network service for CORD + + + org.onosproject.cordvtn + + + + + org.osgi + org.osgi.compendium + + + org.onosproject + onos-api + + + org.onosproject + onos-core-serializers + ${project.version} + + + + 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 index 00000000..af738230 --- /dev/null +++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java @@ -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 { + + /** + * 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 index 00000000..072254de --- /dev/null +++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java @@ -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 nodeStore; + private NodeConnectionManager nodeConnectionManager; + + @Activate + protected void activate() { + appId = coreService.registerApplication("org.onosproject.cordvtn"); + + local = clusterService.getLocalNode().id(); + nodeStore = storageService.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 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 { + + @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 { + + @Override + public void connected(Device device) { + // create vxlan port + } + + @Override + public void disconnected(Device device) { + + } + } + + private class VirtualMachineHandler implements ConnectionHandler { + + @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 index 00000000..c2c37aba --- /dev/null +++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java @@ -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 { + + 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 ovsdbNodes() { + Set 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 index 00000000..d26a10aa --- /dev/null +++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java @@ -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 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 index 00000000..b8cdbe94 --- /dev/null +++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java @@ -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 index 00000000..0b7029ef --- /dev/null +++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java @@ -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 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 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 index 00000000..bb2a0b7d --- /dev/null +++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java @@ -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(); +} diff --git a/framework/src/onos/apps/demo/cord-gui/pom.xml b/framework/src/onos/apps/demo/cord-gui/pom.xml index eeda585a..16ed5d95 100644 --- a/framework/src/onos/apps/demo/cord-gui/pom.xml +++ b/framework/src/onos/apps/demo/cord-gui/pom.xml @@ -27,7 +27,7 @@ cord-gui - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT war Demo CORD Subscriber Web GUI diff --git a/framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java b/framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java index a91dbfbf..dffabceb 100644 --- a/framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java +++ b/framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java @@ -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; diff --git a/framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh b/framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh index e7ad3322..d5a75289 100644 --- a/framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh +++ b/framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh @@ -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 . diff --git a/framework/src/onos/apps/demo/cord-gui/src/scripts/run.me b/framework/src/onos/apps/demo/cord-gui/src/scripts/run.me index db76fb6d..496b18e4 100644 --- a/framework/src/onos/apps/demo/cord-gui/src/scripts/run.me +++ b/framework/src/onos/apps/demo/cord-gui/src/scripts/run.me @@ -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 diff --git a/framework/src/onos/apps/dhcp/pom.xml b/framework/src/onos/apps/dhcp/pom.xml index 13298163..0daa4f7b 100644 --- a/framework/src/onos/apps/dhcp/pom.xml +++ b/framework/src/onos/apps/dhcp/pom.xml @@ -21,7 +21,7 @@ onos-apps org.onosproject - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java index 20e1c614..7c2127f9 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java @@ -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 listMapping(); + Map listMapping(); /** * Returns the default lease time granted by the DHCP Server. diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java index 4e2d67d6..c9fade9e 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java @@ -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 listAssignedMapping(); /** * Returns a collection of all the MacAddress to IPAddress mapping. * * @return the collection of the mappings */ - Map listMapping(); + Map listAllMapping(); /** * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time. diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java index c8bd1906..9b3aa686 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java @@ -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; } diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java index fc470ce3..209ba683 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java @@ -16,10 +16,10 @@ 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 allocationMap = dhcpService.listMapping(); + Map allocationMap = dhcpService.listMapping(); - for (Map.Entry entry : allocationMap.entrySet()) { + for (Map.Entry 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 index 00000000..f8780195 --- /dev/null +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java @@ -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 diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java index f8d5e63b..4353d623 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java @@ -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 { 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 { * * @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 { * * @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 { * * @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 { /** * 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 { * @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 { * @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 { * @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 { * @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 { * * @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 { * * @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 { 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); + } } diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java index 24cb0878..345d5ad0 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java @@ -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 factories = ImmutableSet.of( new ConfigFactory(APP_SUBJECT_FACTORY, @@ -96,14 +101,6 @@ public class DhcpManager implements DhcpService { public DhcpConfig createConfig() { return new DhcpConfig(); } - }, - new ConfigFactory(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 listMapping() { - return dhcpStore.listMapping(); + public Map 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 ipAssignmentMap = dhcpStore.listAllMapping(); + for (Map.Entry 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 diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java index 89ed5720..9ce65d5e 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java @@ -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 allocationMap = dhcpService.listMapping(); + Map allocationMap = dhcpService.listMapping(); - for (Map.Entry entry : allocationMap.entrySet()) { + for (Map.Entry entry : allocationMap.entrySet()) { populateRow(tm.addRow(), entry); } } - private void populateRow(TableModel.Row row, Map.Entry entry) { + private void populateRow(TableModel.Row row, Map.Entry 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"); } diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java index 6e29216a..dbdadb34 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java @@ -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 allocationMap; + private ConsistentMap allocationMap; private DistributedSet 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.consistentMapBuilder() + allocationMap = storageService.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 listAssignedMapping() { - @Override - public Map listMapping() { - - Map allMapping = new HashMap<>(); - for (Map.Entry> entry: allocationMap.entrySet()) { - IpAssignment assignment = entry.getValue().value(); + Map validMapping = new HashMap<>(); + IpAssignment assignment; + for (Map.Entry> 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 listAllMapping() { + Map validMapping = new HashMap<>(); + for (Map.Entry> 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 getAvailableIPs() { - return ImmutableSet.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> 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 index 00000000..12e14e48 --- /dev/null +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java @@ -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 index 00000000..56778a35 --- /dev/null +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java @@ -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 diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java index bfa2767d..646ab7ea 100644 --- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java @@ -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 intents = service.listMapping(); + final Map 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 intents = service.listMapping(); + final Map 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 intents = service.listMapping(); + final Map 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 index 00000000..73173c55 --- /dev/null +++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java @@ -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 diff --git a/framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html b/framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html index 3e14570a..5782badf 100644 --- a/framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html +++ b/framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html @@ -17,7 +17,7 @@
- + @@ -25,7 +25,7 @@
-
MAC AddressHost ID IP Address Lease Expiry
+
- + ng-repeat-complete row-id="{{dhcp.host}}"> + diff --git a/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java b/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java index dad5ef55..3ecc5cfa 100644 --- a/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java +++ b/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java @@ -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 +} diff --git a/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java b/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java index 42ac73d3..3ea3b1b8 100644 --- a/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java +++ b/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java @@ -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 listAssignedMapping() { + return listAllMapping(); } - public Map listMapping() { - Map map = new HashMap<>(); + public Map listAllMapping() { + Map 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 diff --git a/framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json b/framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json index 8ce5486f..abc48a83 100644 --- a/framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json +++ b/framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json @@ -11,9 +11,7 @@ "ttl": "63", "lease": "300", "renew": "150", - "rebind": "200" - }, - "dhcpstore" : { + "rebind": "200", "delay": "3", "timeout": "150", "startip": "10.0.0.110", diff --git a/framework/src/onos/apps/flowanalyzer/pom.xml b/framework/src/onos/apps/flowanalyzer/pom.xml index e068be6c..f5dfcf2b 100644 --- a/framework/src/onos/apps/flowanalyzer/pom.xml +++ b/framework/src/onos/apps/flowanalyzer/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/fwd/pom.xml b/framework/src/onos/apps/fwd/pom.xml index 324f46cd..977a75a4 100644 --- a/framework/src/onos/apps/fwd/pom.xml +++ b/framework/src/onos/apps/fwd/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/metrics/pom.xml b/framework/src/onos/apps/metrics/pom.xml index 89757c9a..8a39990a 100644 --- a/framework/src/onos/apps/metrics/pom.xml +++ b/framework/src/onos/apps/metrics/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java b/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java index 78a540c9..9a42e9ee 100644 --- a/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java +++ b/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java @@ -107,7 +107,7 @@ public class IntentMetrics implements IntentMetricsService, @Override public List getEvents() { synchronized (lastEvents) { - return ImmutableList.copyOf(lastEvents); + return ImmutableList.copyOf(lastEvents); } } diff --git a/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java b/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java index 5785f5f2..fb984c9e 100644 --- a/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java +++ b/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java @@ -138,7 +138,7 @@ public class TopologyMetrics implements TopologyMetricsService { @Override public List getEvents() { synchronized (lastEvents) { - return ImmutableList.copyOf(lastEvents); + return ImmutableList.copyOf(lastEvents); } } diff --git a/framework/src/onos/apps/mobility/pom.xml b/framework/src/onos/apps/mobility/pom.xml index bc50813f..59fd6668 100644 --- a/framework/src/onos/apps/mobility/pom.xml +++ b/framework/src/onos/apps/mobility/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/olt/pom.xml b/framework/src/onos/apps/olt/pom.xml index a2a7b968..180e026a 100644 --- a/framework/src/onos/apps/olt/pom.xml +++ b/framework/src/onos/apps/olt/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/optical/pom.xml b/framework/src/onos/apps/optical/pom.xml index ac298e0b..9ae6f85e 100644 --- a/framework/src/onos/apps/optical/pom.xml +++ b/framework/src/onos/apps/optical/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java index f3f8d174..2ef5cd57 100644 --- a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java +++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java @@ -34,8 +34,8 @@ public class OpticalNetworkConfig { private List opticalLinks; public OpticalNetworkConfig() { - opticalSwitches = new ArrayList(); - opticalLinks = new ArrayList(); + opticalSwitches = new ArrayList<>(); + opticalLinks = new ArrayList<>(); } public List getOpticalSwitches() { diff --git a/framework/src/onos/apps/pcep-api/pom.xml b/framework/src/onos/apps/pcep-api/pom.xml index 80b4a436..5e871678 100644 --- a/framework/src/onos/apps/pcep-api/pom.xml +++ b/framework/src/onos/apps/pcep-api/pom.xml @@ -1,12 +1,29 @@ - - 4.0.0 - - org.onosproject - onos-apps - 1.3.0-SNAPSHOT - - onos-app-pcep-api - bundle + + + 4.0.0 + + org.onosproject + onos-apps + 1.4.0-SNAPSHOT + + onos-app-pcep-api + bundle - PCEP protocol API + PCEP protocol API \ No newline at end of file diff --git a/framework/src/onos/apps/pom.xml b/framework/src/onos/apps/pom.xml index e5ceddde..334c690b 100644 --- a/framework/src/onos/apps/pom.xml +++ b/framework/src/onos/apps/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml @@ -37,7 +37,6 @@ fwd mobility proxyarp - config sdnip optical metrics @@ -58,7 +57,8 @@ vtn vtnweb dhcp - + cordvtn + default diff --git a/framework/src/onos/apps/proxyarp/pom.xml b/framework/src/onos/apps/proxyarp/pom.xml index e6e76585..69f64ddb 100644 --- a/framework/src/onos/apps/proxyarp/pom.xml +++ b/framework/src/onos/apps/proxyarp/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java b/framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java index 742d7af7..2eb96df2 100644 --- a/framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java +++ b/framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java @@ -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); diff --git a/framework/src/onos/apps/reactive-routing/pom.xml b/framework/src/onos/apps/reactive-routing/pom.xml index 1d93cbf1..58fb91ee 100644 --- a/framework/src/onos/apps/reactive-routing/pom.xml +++ b/framework/src/onos/apps/reactive-routing/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/routing-api/pom.xml b/framework/src/onos/apps/routing-api/pom.xml index 1b9fc2fa..48fc2920 100644 --- a/framework/src/onos/apps/routing-api/pom.xml +++ b/framework/src/onos/apps/routing-api/pom.xml @@ -20,7 +20,7 @@ onos-apps org.onosproject - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml 4.0.0 diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java index d6f6e574..8d563b87 100644 --- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java +++ b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java @@ -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. * diff --git a/framework/src/onos/apps/routing/pom.xml b/framework/src/onos/apps/routing/pom.xml index 1d9f19b7..c461ef3f 100644 --- a/framework/src/onos/apps/routing/pom.xml +++ b/framework/src/onos/apps/routing/pom.xml @@ -20,7 +20,7 @@ onos-apps org.onosproject - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml 4.0.0 diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java index 57481c20..ab8a0493 100644 --- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java +++ b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java @@ -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); diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java index 1078319d..0a6f9d4c 100644 --- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java +++ b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java @@ -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 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 diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java index c4f291ba..6700d530 100644 --- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java +++ b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java @@ -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 diff --git a/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java b/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java index 634e87b9..3f5a6b8b 100644 --- a/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java +++ b/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java @@ -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); diff --git a/framework/src/onos/apps/sdnip/pom.xml b/framework/src/onos/apps/sdnip/pom.xml index 68b500d5..99314aa8 100644 --- a/framework/src/onos/apps/sdnip/pom.xml +++ b/framework/src/onos/apps/sdnip/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml @@ -68,12 +68,6 @@ ${project.version} - - org.onosproject - onos-app-config - ${project.version} - - org.apache.karaf.shell org.apache.karaf.shell.console diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java index 35ff7054..d8d8f45d 100644 --- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java +++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java @@ -887,7 +887,7 @@ public class IntentSynchronizer implements FibListener, IntentRequestListener { checkNotNull(dstMacAddress); checkNotNull(srcConnectPoint); - Set ingressPoints = new HashSet(); + Set ingressPoints = new HashSet<>(); ingressPoints.add(srcConnectPoint); IpPrefix dstIpPrefix = dstIpAddress.toIpPrefix(); diff --git a/framework/src/onos/apps/segmentrouting/pom.xml b/framework/src/onos/apps/segmentrouting/pom.xml index 3ed4c4fe..83ae76db 100644 --- a/framework/src/onos/apps/segmentrouting/pom.xml +++ b/framework/src/onos/apps/segmentrouting/pom.xml @@ -21,7 +21,7 @@ onos-apps org.onosproject - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java index d82eb5ec..ef9d444a 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java @@ -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 allSegmentIds = new ArrayList(); + private final List allSegmentIds = new ArrayList<>(); private final HashMap 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(); + 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(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(deviceConfigMap. - get(deviceId).subnets.values()); + return new ArrayList<>(deviceConfigMap.get(deviceId).subnets.values()); } else { return null; } diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java index cd28fcf9..2e2041c4 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java @@ -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 distanceSwArray = distanceDeviceMap .get(currDistance + 1); if (distanceSwArray == null) { - distanceSwArray = new ArrayList(); + distanceSwArray = new ArrayList<>(); distanceSwArray.add(reachedDevice); distanceDeviceMap.put(currDistance + 1, distanceSwArray); } else { @@ -120,7 +120,7 @@ public class ECMPShortestPathGraph { ArrayList upstreamLinkArray = upstreamLinks.get(reachedDevice); if (upstreamLinkArray == null) { - upstreamLinkArray = new ArrayList(); + 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 distanceSwArray = distanceDeviceMap .get(currDistance + 1); if (distanceSwArray == null) { - distanceSwArray = new ArrayList(); + distanceSwArray = new ArrayList<>(); distanceSwArray.add(reachedDevice); distanceDeviceMap.put(currDistance + 1, distanceSwArray); } else { @@ -194,7 +194,7 @@ public class ECMPShortestPathGraph { ArrayList upstreamLinkArray = upstreamLinks.get(reachedDevice); if (upstreamLinkArray == null) { - upstreamLinkArray = new ArrayList(); + 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 sofarLinks = new ArrayList(); + ArrayList sofarLinks = new ArrayList<>(); if (path != null && !path.links().isEmpty()) { sofarLinks.addAll(path.links()); } @@ -288,12 +288,10 @@ public class ECMPShortestPathGraph { public HashMap>> getCompleteLearnedDeviceesAndPaths() { - HashMap>> pathGraph = new - HashMap>>(); + HashMap>> pathGraph = new HashMap<>(); for (Integer itrIndx : distanceDeviceMap.keySet()) { - HashMap> swMap = new - HashMap>(); + HashMap> swMap = new HashMap<>(); for (DeviceId sw : distanceDeviceMap.get(itrIndx)) { swMap.put(sw, getECMPPaths(sw)); } @@ -314,12 +312,10 @@ public class ECMPShortestPathGraph { public HashMap>>> getAllLearnedSwitchesAndVia() { - HashMap>>> deviceViaMap = - new HashMap>>>(); + HashMap>>> deviceViaMap = new HashMap<>(); for (Integer itrIndx : distanceDeviceMap.keySet()) { - HashMap>> swMap = - new HashMap>>(); + HashMap>> swMap = new HashMap<>(); for (DeviceId sw : distanceDeviceMap.get(itrIndx)) { ArrayList> swViaArray = new ArrayList<>(); diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java index 81d00f50..e37fe52a 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java @@ -50,7 +50,7 @@ public class IpHandler { public IpHandler(SegmentRoutingManager srManager) { this.srManager = srManager; this.config = checkNotNull(srManager.deviceConfiguration); - ipPacketQueue = new ConcurrentHashMap>(); + ipPacketQueue = new ConcurrentHashMap<>(); } /** @@ -104,7 +104,7 @@ public class IpHandler { Ip4Address destIpAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress()); if (ipPacketQueue.get(destIpAddress) == null) { - ConcurrentLinkedQueue queue = new ConcurrentLinkedQueue(); + ConcurrentLinkedQueue queue = new ConcurrentLinkedQueue<>(); queue.add(ipPacket); ipPacketQueue.put(destIpAddress, queue); } else { diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java index 59fc4ca7..d802be91 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java @@ -221,7 +221,7 @@ public class RoutingRulePopulator { Set nextHops) { TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); - List fwdObjBuilders = new ArrayList(); + List fwdObjBuilders = new ArrayList<>(); // TODO Handle the case of Bos == false sbuilder.matchMplsLabel(MplsLabel.mplsLabel(config.getSegmentId(destSwId))); diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java index 6ae0779e..0c7749e6 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java @@ -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(); - links = new ArrayList(); + switches = new ArrayList<>(); + links = new ArrayList<>(); } @JsonProperty("comment") diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java index 91942216..0c0dac86 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java @@ -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; diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java index 44e4f1c6..f034f372 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java @@ -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 getConfiguredAllowedSwitches() { - List allowed = new ArrayList(); + List 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 getConfiguredAllowedLinks() { - List allowed = new ArrayList(); + List 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 swConfList) { - Set swDpids = new HashSet(); - Set swNames = new HashSet(); + Set swDpids = new HashSet<>(); + Set 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(); - configuredLinks = new ConcurrentHashMap(); - nameToDpid = new HashMap(); + configuredSwitches = new ConcurrentHashMap<>(); + configuredLinks = new ConcurrentHashMap<>(); + nameToDpid = new HashMap<>(); parseNetworkConfig(); } } diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java index 56855271..afbb0fcc 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java @@ -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; diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java index c66ac3c7..3c51fa9d 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java @@ -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(); + publishAttributes = new ConcurrentHashMap<>(); parseParams(); validateParams(); setPublishAttributes(); diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java index 4775c77f..c8d4a54a 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java @@ -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(); - adjacencySids = new ArrayList(); - subnets = new ArrayList(); + 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 i = fe.getValue().elements(); - ports = new ArrayList(); + ports = new ArrayList<>(); while (i.hasNext()) { ports.add(i.next().asInt()); } diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java index 41cf8acc..3dc312df 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java @@ -69,7 +69,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { Set> powerSet = getPowerSetOfNeighbors(neighbors); log.trace("createGroupsAtEdgeRouter: The size of neighbor powerset " + "for sw {} is {}", deviceId, powerSet.size()); - Set nsSet = new HashSet(); + Set nsSet = new HashSet<>(); for (Set combo : powerSet) { if (combo.isEmpty()) { continue; @@ -148,7 +148,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { Set updatedNeighbors) { Set> powerSet = getPowerSetOfNeighbors(updatedNeighbors); - Set tmp = new HashSet(); + Set tmp = new HashSet<>(); tmp.addAll(updatedNeighbors); tmp.remove(impactedNeighbor); Set> tmpPowerSet = getPowerSetOfNeighbors(tmp); @@ -156,7 +156,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { // Compute the impacted neighbor sets powerSet.removeAll(tmpPowerSet); - Set nsSet = new HashSet(); + Set nsSet = new HashSet<>(); for (Set combo : powerSet) { if (combo.isEmpty()) { continue; diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java index a43a0f09..9bbde2f3 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java @@ -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 ports = new HashSet(); + Set ports = new HashSet<>(); ports.add(portToNeighbor); devicePortMap.put(neighborId, ports); } @@ -383,8 +383,8 @@ public class DefaultGroupHandler { } protected Set> getPowerSetOfNeighbors(Set neighbors) { - List list = new ArrayList(neighbors); - Set> sets = new HashSet>(); + List list = new ArrayList<>(neighbors); + Set> 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 neighborSubSet = new HashSet(); + Set 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 getSegmentIdsTobePairedWithNeighborSet(Set neighbors) { - List nsSegmentIds = new ArrayList(); + List nsSegmentIds = new ArrayList<>(); // Always pair up with no edge label // If (neighbors.size() == 1) { diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java index e12426c2..3cb73aba 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java @@ -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 nsSet = new HashSet(); + Set nsSet = new HashSet<>(); for (Set combo : sets) { if (combo.isEmpty()) { continue; @@ -137,7 +137,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { Set updatedNeighbors) { Set> powerSet = getPowerSetOfNeighbors(updatedNeighbors); - Set tmp = new HashSet(); + Set tmp = new HashSet<>(); tmp.addAll(updatedNeighbors); tmp.remove(impactedNeighbor); Set> tmpPowerSet = getPowerSetOfNeighbors(tmp); @@ -146,7 +146,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { powerSet.removeAll(tmpPowerSet); powerSet = filterEdgeRouterOnlyPairings(powerSet); - Set nsSet = new HashSet(); + Set nsSet = new HashSet<>(); for (Set combo : powerSet) { if (combo.isEmpty()) { continue; @@ -163,7 +163,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { } private Set> filterEdgeRouterOnlyPairings(Set> sets) { - Set> fiteredSets = new HashSet>(); + Set> fiteredSets = new HashSet<>(); for (Set deviceSubSet : sets) { if (deviceSubSet.size() > 1) { boolean avoidEdgeRouterPairing = true; diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java index 7ada3224..44715d24 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java @@ -44,7 +44,7 @@ public class NeighborSet { public NeighborSet(Set neighbors) { checkNotNull(neighbors); this.edgeLabel = NO_EDGE_LABEL; - this.neighbors = new HashSet(); + this.neighbors = new HashSet<>(); this.neighbors.addAll(neighbors); } @@ -57,7 +57,7 @@ public class NeighborSet { public NeighborSet(Set neighbors, int edgeLabel) { checkNotNull(neighbors); this.edgeLabel = edgeLabel; - this.neighbors = new HashSet(); + 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(); + this.neighbors = new HashSet<>(); } /** diff --git a/framework/src/onos/apps/test/demo/pom.xml b/framework/src/onos/apps/test/demo/pom.xml index 27dd6675..4b08430d 100644 --- a/framework/src/onos/apps/test/demo/pom.xml +++ b/framework/src/onos/apps/test/demo/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps-test - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java index 4197bb60..00956763 100644 --- a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java +++ b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java @@ -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. diff --git a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java index 27d1ca96..a408e695 100644 --- a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java +++ b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java @@ -393,13 +393,8 @@ public class DemoInstaller implements DemoAPI { } private Predicate hasLocalMaster() { - return new Predicate() { - @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); } diff --git a/framework/src/onos/apps/test/distributed-primitives/pom.xml b/framework/src/onos/apps/test/distributed-primitives/pom.xml index e0376ee7..f77fd57f 100644 --- a/framework/src/onos/apps/test/distributed-primitives/pom.xml +++ b/framework/src/onos/apps/test/distributed-primitives/pom.xml @@ -23,7 +23,7 @@ org.onosproject onos-apps-test - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml @@ -54,7 +54,7 @@ org.onosproject onos-core-dist - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT org.osgi diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java index d8e8e0be..12c8140a 100644 --- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java +++ b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java @@ -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(); } } diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java index 0ccc2d3c..204471c2 100644 --- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java +++ b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java @@ -44,7 +44,7 @@ public class SetTestAddCommand extends AbstractShellCommand { String[] values = null; Set set; - Set toAdd = new HashSet(); + Set toAdd = new HashSet<>(); Serializer serializer = Serializer.using( diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java index 792eab90..fb36a06a 100644 --- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java +++ b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java @@ -49,8 +49,8 @@ public class SetTestGetCommand extends AbstractShellCommand { String[] values = null; Set set; - Set toCheck = new HashSet(); - String output = new String(); + Set toCheck = new HashSet<>(); + String output = ""; Serializer serializer = Serializer.using( new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build()); diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java index 7e3a3e82..d1f81e42 100644 --- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java +++ b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java @@ -54,7 +54,7 @@ public class SetTestRemoveCommand extends AbstractShellCommand { String[] values = null; Set set; - Set givenValues = new HashSet(); + Set givenValues = new HashSet<>(); Serializer serializer = Serializer.using( new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build()); diff --git a/framework/src/onos/apps/test/election/pom.xml b/framework/src/onos/apps/test/election/pom.xml index 4c18baee..3ceadb4d 100644 --- a/framework/src/onos/apps/test/election/pom.xml +++ b/framework/src/onos/apps/test/election/pom.xml @@ -23,7 +23,7 @@ org.onosproject onos-apps-test - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/test/intent-perf/pom.xml b/framework/src/onos/apps/test/intent-perf/pom.xml index 7d325394..b837d114 100644 --- a/framework/src/onos/apps/test/intent-perf/pom.xml +++ b/framework/src/onos/apps/test/intent-perf/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps-test - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/test/messaging-perf/pom.xml b/framework/src/onos/apps/test/messaging-perf/pom.xml index 66a7c306..28de5b7c 100644 --- a/framework/src/onos/apps/test/messaging-perf/pom.xml +++ b/framework/src/onos/apps/test/messaging-perf/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps-test - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java b/framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java index 24697933..8b41bd5a 100644 --- a/framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java +++ b/framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java @@ -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; diff --git a/framework/src/onos/apps/test/pom.xml b/framework/src/onos/apps/test/pom.xml index 41e1f201..ead2252e 100644 --- a/framework/src/onos/apps/test/pom.xml +++ b/framework/src/onos/apps/test/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/virtualbng/pom.xml b/framework/src/onos/apps/virtualbng/pom.xml index 835272ae..01caa66c 100644 --- a/framework/src/onos/apps/virtualbng/pom.xml +++ b/framework/src/onos/apps/virtualbng/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/vtn/pom.xml b/framework/src/onos/apps/vtn/pom.xml index 56aa99d6..fb8fcb13 100644 --- a/framework/src/onos/apps/vtn/pom.xml +++ b/framework/src/onos/apps/vtn/pom.xml @@ -1,12 +1,28 @@ + + 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"> 4.0.0 org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml @@ -24,10 +40,6 @@ jsr311-api 1.1.1 - - org.onosproject - onos-api - org.onosproject onos-incubator-api diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java index 01c98825..ba4745b6 100644 --- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java +++ b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java @@ -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 ifaceIds = new HashSet(); + Collection ifaceIds = new HashSet<>(); Collection ports = virtualPortService .getPorts(network.id()); Sets.newHashSet(ports).stream() diff --git a/framework/src/onos/apps/vtnrsc/pom.xml b/framework/src/onos/apps/vtnrsc/pom.xml index ce4e2c8c..0874f6d9 100644 --- a/framework/src/onos/apps/vtnrsc/pom.xml +++ b/framework/src/onos/apps/vtnrsc/pom.xml @@ -1,4 +1,19 @@ + @@ -6,7 +21,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java index 85d1fa9d..3d6ba8e8 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java @@ -1,38 +1,38 @@ -/* - * 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(); -} +/* + * 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(); +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java index b60cb676..4e1028d8 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java @@ -1,94 +1,94 @@ -/* - * 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 & - * 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(); - } - -} +/* + * 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 & + * 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(); + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java index da403876..c715d08a 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java @@ -1,57 +1,72 @@ -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; - } -} +/* + * 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; + } +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java index 6a6a4750..8a480194 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java @@ -1,81 +1,81 @@ -/* - * 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(); - } -} - +/* + * 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(); + } +} + diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java index c84ae181..8679100d 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java @@ -1,79 +1,79 @@ -/* - * 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; - } - -} +/* + * 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; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java index 88fabffb..6049b558 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java @@ -1,183 +1,183 @@ -/* - * 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 hostRoutes; - private final Set 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 hostRoutes, Mode ipV6AddressMode, - Mode ipV6RaMode, - Set 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 hostRoutes() { - return hostRoutes; - } - - @Override - public Mode ipV6AddressMode() { - return ipV6AddressMode; - } - - @Override - public Mode ipV6RaMode() { - return ipV6RaMode; - } - - @Override - public Iterable 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(); - } - -} +/* + * 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 hostRoutes; + private final Set 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 hostRoutes, Mode ipV6AddressMode, + Mode ipV6RaMode, + Set 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 hostRoutes() { + return hostRoutes; + } + + @Override + public Mode ipV6AddressMode() { + return ipV6AddressMode; + } + + @Override + public Mode ipV6RaMode() { + return ipV6RaMode; + } + + @Override + public Iterable 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(); + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java index 21650789..8c941ea2 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java @@ -1,160 +1,160 @@ -/* - * 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(); - } - -} +/* + * 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(); + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java index adf3a3a3..9ee85da7 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java @@ -1,229 +1,229 @@ -/* - * 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 fixedIps; - private final BindingHostId bindingHostId; - private final String bindingVnicType; - private final String bindingVifType; - private final String bindingVifDetails; - private final Set allowedAddressPairs; - private final Set 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 strMap, - State state, - MacAddress macAddress, - TenantId tenantId, - DeviceId deviceId, - Set fixedIps, - BindingHostId bindingHostId, - Set allowedAddressPairs, - Set 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 allowedAddressPairs() { - return allowedAddressPairs; - } - - @Override - public Set 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 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(); - } - -} +/* + * 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 fixedIps; + private final BindingHostId bindingHostId; + private final String bindingVnicType; + private final String bindingVifType; + private final String bindingVifDetails; + private final Set allowedAddressPairs; + private final Set 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 strMap, + State state, + MacAddress macAddress, + TenantId tenantId, + DeviceId deviceId, + Set fixedIps, + BindingHostId bindingHostId, + Set allowedAddressPairs, + Set 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 allowedAddressPairs() { + return allowedAddressPairs; + } + + @Override + public Set 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 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(); + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java index dcfb72ac..c6569a7b 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java @@ -1,93 +1,93 @@ -/* - * 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(); - } - -} +/* + * 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(); + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java index 74c28165..b18cb950 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java @@ -1,39 +1,39 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc; - -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(); -} +/* + * 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(); +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java index 6a0c5cb6..e96e666a 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java @@ -1,78 +1,78 @@ -/* - * 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; - } - -} +/* + * 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; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java index 7f098064..9ec1dc63 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java @@ -1,77 +1,77 @@ -/* - * 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(); - } - -} +/* + * 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(); + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java index 69f9dce7..a076265f 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java @@ -1,77 +1,77 @@ -/* - * 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; - } - -} +/* + * 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; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java index 1104d7ee..f563a78f 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java @@ -1,129 +1,129 @@ -/* - *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. - */ - public 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 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 allocationPools(); -} +/* + * 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 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 allocationPools(); +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java index e0c1aee9..4bcc3329 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java @@ -1,76 +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. - */ -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; - } -} +/* + * 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; + } +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java index 9d44c469..c4d99e49 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java @@ -1,77 +1,77 @@ -/* - * 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; - } - -} +/* + * 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; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java index d9238f92..256352f4 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java @@ -1,130 +1,130 @@ -/* - * 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. - */ - public 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. - */ - public 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(); -} +/* + * 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(); +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java index 81c9962f..fbb9e480 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java @@ -1,76 +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. - */ -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; - } - -} +/* + * 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; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java index a6071094..d2d7c146 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java @@ -1,156 +1,156 @@ -/* - * 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. - */ - public 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 allowedAddressPairs(); - - /** - * Returns set of IP addresses for the port, include the IP addresses and subnet - * identity. - * - * @return FixedIps Set of fixedIp - */ - Set 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 securityGroups(); -} +/* + * 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 allowedAddressPairs(); + + /** + * Returns set of IP addresses for the port, include the IP addresses and subnet + * identity. + * + * @return FixedIps Set of fixedIp + */ + Set 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 securityGroups(); +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java index 0969ce10..3038bdff 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java @@ -1,70 +1,70 @@ -/* - * 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; - } - -} +/* + * 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 index 00000000..1622c800 --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java @@ -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; diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java index f8ee6b97..b0578a1e 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java @@ -92,7 +92,7 @@ public class SubnetUpdateCommand extends AbstractShellCommand { @Option(name = "-a", aliases = "--allocationPools", description = "Subnet jsonnode allocationPools", required = false, multiValued = false) - Set allocationPools = Sets.newHashSet();; + Set 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 index 00000000..b3a2ff51 --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java @@ -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 index 00000000..fac214a1 --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java @@ -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; diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java index 71ea9ba3..82eb9611 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java @@ -1,72 +1,72 @@ -/* - * 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 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 subnets); - - /** - * Updates existing subnets. - * - * @param subnets the iterable collection of subnets - * @return true if all subnets were updated successfully - */ - boolean updateSubnets(Iterable 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 subnetIds); - - -} +/* + * 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 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 subnets); + + /** + * Updates existing subnets. + * + * @param subnets the iterable collection of subnets + * @return true if all subnets were updated successfully + */ + boolean updateSubnets(Iterable 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 subnetIds); + + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java index ab810a80..890beb29 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java @@ -1,179 +1,183 @@ -/* - * 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.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 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.consistentMapBuilder() - .withName(SUBNET) - .withApplicationId(appId) - .withPurgeOnUninstall() - .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API), - Subnet.class, - SubnetId.class, - TenantNetworkId.class, - TenantId.class, - HostRoute.class, - Subnet.Mode.class, - AllocationPool.class, - DefaultSubnet.class, - IpAddress.Version.class)) - .build().asJavaMap(); - - log.info("Started"); - } - - @Deactivate - public void deactivate() { - log.info("Stopped"); - } - - @Override - public Iterable 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 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 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 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; - } - -} +/* + * 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 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.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 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 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 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 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 index 00000000..79040d8d --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java @@ -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 index 00000000..7b2bdb90 --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java @@ -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; diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java index 56e8bcee..e246cc4e 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java @@ -1,80 +1,80 @@ -/* - * 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 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 networks); - - /** - * Updates tenantNetworks by tenantNetworks. - * - * @param networks the collection of tenantNetworks - * @return true if all given identifiers updated successfully. - */ - boolean updateNetworks(Iterable networks); - - /** - * Deletes tenantNetwork by tenantNetworkIds. - * - * @param networksIds the collection of tenantNetworkIds - * @return true if the specified tenantNetworks deleted successfully. - */ - boolean removeNetworks(Iterable networksIds); -} +/* + * 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 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 networks); + + /** + * Updates tenantNetworks by tenantNetworks. + * + * @param networks the collection of tenantNetworks + * @return true if all given identifiers updated successfully. + */ + boolean updateNetworks(Iterable networks); + + /** + * Deletes tenantNetwork by tenantNetworkIds. + * + * @param networksIds the collection of tenantNetworkIds + * @return true if the specified tenantNetworks deleted successfully. + */ + boolean removeNetworks(Iterable networksIds); +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java index c5290ad2..0dfc99e2 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java @@ -1,167 +1,167 @@ -/* - * 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 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.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 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 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 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 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; - } -} +/* + * 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 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.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 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 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 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 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 index 00000000..f381fda6 --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java @@ -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 index 00000000..1489c973 --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java @@ -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; diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java index f09caf29..6f3cf653 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java @@ -1,72 +1,72 @@ -/* - * 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 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 subnets); - - /** - * Updates existing subnets. - * - * @param subnets the iterable collection of subnets - * @return true if all subnets were updated successfully - */ - boolean updateSubnets(Iterable 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 subnetIds); - - -} +/* + * 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 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 subnets); + + /** + * Updates existing subnets. + * + * @param subnets the iterable collection of subnets + * @return true if all subnets were updated successfully + */ + boolean updateSubnets(Iterable 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 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 index 00000000..3a84e6e3 --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java @@ -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; diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java index 24ddb9f1..05ebccf9 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java @@ -1,100 +1,100 @@ -/* - * Copyright 2015 Open Porting 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 getPorts(); - - /** - * Returns the collection of the virtualPorts associated with the networkId. - * - * @param networkId the network identifer - * @return collection of virtualPort. - */ - Collection getPorts(TenantNetworkId networkId); - - /** - * Returns the collection of the virtualPorts associated with the tenantId. - * - * @param tenantId the tenant identifier - * @return collection of virtualPorts. - */ - Collection getPorts(TenantId tenantId); - - /** - * Returns the collection of the virtualPorts associated with the deviceId. - * - * @param deviceId the device identifier - * @return collection of virtualPort. - */ - Collection 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 virtualPorts); - - /** - * Updates virtualPorts by virtualPorts. - * - * @param virtualPorts the iterable collection of virtualPorts - * @return true if all given identifiers updated successfully. - */ - boolean updatePorts(Iterable 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 virtualPortIds); -} +/* + * 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 getPorts(); + + /** + * Returns the collection of the virtualPorts associated with the networkId. + * + * @param networkId the network identifer + * @return collection of virtualPort. + */ + Collection getPorts(TenantNetworkId networkId); + + /** + * Returns the collection of the virtualPorts associated with the tenantId. + * + * @param tenantId the tenant identifier + * @return collection of virtualPorts. + */ + Collection getPorts(TenantId tenantId); + + /** + * Returns the collection of the virtualPorts associated with the deviceId. + * + * @param deviceId the device identifier + * @return collection of virtualPort. + */ + Collection 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 virtualPorts); + + /** + * Updates virtualPorts by virtualPorts. + * + * @param virtualPorts the iterable collection of virtualPorts + * @return true if all given identifiers updated successfully. + */ + boolean updatePorts(Iterable 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 virtualPortIds); +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java index e0c49f5b..bea0fd55 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java @@ -1,222 +1,222 @@ -/* - * 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 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.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 getPorts() { - return Collections.unmodifiableCollection(vPortStore.values()); - } - - @Override - public Collection getPorts(TenantNetworkId networkId) { - checkNotNull(networkId, NETWORKID_NOT_NULL); - Collection vPortWithNetworkIds = vPortStore.values(); - for (VirtualPort vPort : vPortWithNetworkIds) { - if (!vPort.networkId().equals(networkId)) { - vPortWithNetworkIds.remove(vPort); - } - } - return vPortWithNetworkIds; - } - - @Override - public Collection getPorts(TenantId tenantId) { - checkNotNull(tenantId, TENANTID_NOT_NULL); - Collection vPortWithTenantIds = vPortStore.values(); - for (VirtualPort vPort : vPortWithTenantIds) { - if (!vPort.tenantId().equals(tenantId)) { - vPortWithTenantIds.remove(vPort); - } - } - return vPortWithTenantIds; - } - - @Override - public Collection getPorts(DeviceId deviceId) { - checkNotNull(deviceId, DEVICEID_NOT_NULL); - Collection vPortWithDeviceIds = vPortStore.values(); - for (VirtualPort vPort : vPortWithDeviceIds) { - if (!vPort.deviceId().equals(deviceId)) { - vPortWithDeviceIds.remove(vPort); - } - } - return vPortWithDeviceIds; - } - - @Override - public boolean createPorts(Iterable 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 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 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; - } - -} +/* + * 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 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.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 getPorts() { + return Collections.unmodifiableCollection(vPortStore.values()); + } + + @Override + public Collection getPorts(TenantNetworkId networkId) { + checkNotNull(networkId, NETWORKID_NOT_NULL); + Collection vPortWithNetworkIds = vPortStore.values(); + for (VirtualPort vPort : vPortWithNetworkIds) { + if (!vPort.networkId().equals(networkId)) { + vPortWithNetworkIds.remove(vPort); + } + } + return vPortWithNetworkIds; + } + + @Override + public Collection getPorts(TenantId tenantId) { + checkNotNull(tenantId, TENANTID_NOT_NULL); + Collection vPortWithTenantIds = vPortStore.values(); + for (VirtualPort vPort : vPortWithTenantIds) { + if (!vPort.tenantId().equals(tenantId)) { + vPortWithTenantIds.remove(vPort); + } + } + return vPortWithTenantIds; + } + + @Override + public Collection getPorts(DeviceId deviceId) { + checkNotNull(deviceId, DEVICEID_NOT_NULL); + Collection vPortWithDeviceIds = vPortStore.values(); + for (VirtualPort vPort : vPortWithDeviceIds) { + if (!vPort.deviceId().equals(deviceId)) { + vPortWithDeviceIds.remove(vPort); + } + } + return vPortWithDeviceIds; + } + + @Override + public boolean createPorts(Iterable 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 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 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 index 00000000..24eb0d3f --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java @@ -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 index 00000000..06a01a04 --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java @@ -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; diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java index 4a6c3210..57c97c1c 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java @@ -1,40 +1,40 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.AllocationPool; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Subnet AllocationPool codec. - */ -public final class AllocationPoolsCodec extends JsonCodec { - - @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; - } - -} +/* + * 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 { + + @Override + public ObjectNode encode(AllocationPool alocPool, CodecContext context) { + checkNotNull(alocPool, "AllocationPools cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put("start", alocPool.startIp().toString()) + .put("end", alocPool.endIp().toString()); + return result; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java index 6c5cc2e8..7960808f 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java @@ -1,40 +1,40 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.AllowedAddressPair; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * VirtualPort AllowedAddressPair codec. - */ -public final class AllowedAddressPairCodec extends JsonCodec { - - @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; - } - -} +/* + * 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 { + + @Override + public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) { + checkNotNull(alocAddPair, "AllowedAddressPair cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put("ip_address", alocAddPair.ip().toString()) + .put("mac_address", alocAddPair.mac().toString()); + return result; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java index a69b8213..96c9bb4e 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java @@ -1,40 +1,40 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.FixedIp; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * VirtualPort FixedIp codec. - */ -public final class FixedIpCodec extends JsonCodec { - - @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; - } - -} +/* + * 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 { + + @Override + public ObjectNode encode(FixedIp fixIp, CodecContext context) { + checkNotNull(fixIp, "FixedIp cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put("subnet_id", fixIp.subnetId().toString()) + .put("ip_address", fixIp.ip().toString()); + return result; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java index ba977a0b..69ca6b3f 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java @@ -1,40 +1,40 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.HostRoute; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Subnet HostRoute codec. - */ -public final class HostRoutesCodec extends JsonCodec { - - @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; - } - -} +/* + * 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 { + + @Override + public ObjectNode encode(HostRoute hostRoute, CodecContext context) { + checkNotNull(hostRoute, "HostRoute cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put("nexthop", hostRoute.nexthop().toString()) + .put("destination", hostRoute.destination().toString()); + return result; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java index 83bab6b1..c2ded196 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java @@ -1,39 +1,39 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.SecurityGroup; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Virtualport SecurityGroup codec. - */ -public final class SecurityGroupCodec extends JsonCodec { - - @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; - } - -} +/* + * 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 { + + @Override + public ObjectNode encode(SecurityGroup securGroup, CodecContext context) { + checkNotNull(securGroup, "SecurityGroup cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put("security_group", securGroup.securityGroup()); + return result; + } + +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java index afd561fe..122b75a9 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java @@ -1,53 +1,53 @@ -/* - * 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 { - @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().toString()) - .put("ip_version", subnet.ipVersion().toString()) - .put("cidr", subnet.cidr().toString()) - .put("shared", subnet.shared()) - .put("enabled_dchp", subnet.dhcpEnabled()) - .put("tenant_id", subnet.tenantId().toString()) - .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; - } -} +/* + * 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 { + @Override + public ObjectNode encode(Subnet subnet, CodecContext context) { + checkNotNull(subnet, "Subnet cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put("id", subnet.id().toString()) + .put("gateway_ip", subnet.gatewayIp().toString()) + .put("network_id", subnet.networkId().toString()) + .put("name", subnet.subnetName()) + .put("ip_version", subnet.ipVersion().toString()) + .put("cidr", subnet.cidr().toString()) + .put("shared", subnet.shared()) + .put("enabled_dchp", subnet.dhcpEnabled()) + .put("tenant_id", subnet.tenantId().toString()) + .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null + : subnet.ipV6AddressMode().toString()) + .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null + : subnet.ipV6RaMode().toString()); + result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet + .allocationPools(), context)); + result.set("host_routes", + new HostRoutesCodec().encode(subnet.hostRoutes(), context)); + return result; + } +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java index 07ae9f8e..48ba3b97 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java @@ -1,47 +1,47 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.TenantNetwork; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * TenantNetwork JSON codec. - */ -public final class TenantNetworkCodec extends JsonCodec { - - @Override - public ObjectNode encode(TenantNetwork network, CodecContext context) { - checkNotNull(network, "Network cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("id", network.id().toString()) - .put("name", network.name().toString()) - .put("admin_state_up", network.adminStateUp()) - .put("status", "" + network.state()) - .put("shared", network.shared()) - .put("tenant_id", network.tenantId().toString()) - .put("router:external", network.routerExternal()) - .put("provider:network_type", "" + network.type()) - .put("provider:physical_network", network.physicalNetwork().toString()) - .put("provider:segmentation_id", network.segmentationId().toString()); - return result; - } -} +/* + * 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 { + + @Override + public ObjectNode encode(TenantNetwork network, CodecContext context) { + checkNotNull(network, "Network cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put("id", network.id().toString()) + .put("name", network.name()) + .put("admin_state_up", network.adminStateUp()) + .put("status", "" + network.state()) + .put("shared", network.shared()) + .put("tenant_id", network.tenantId().toString()) + .put("router:external", network.routerExternal()) + .put("provider:network_type", "" + network.type()) + .put("provider:physical_network", network.physicalNetwork().toString()) + .put("provider:segmentation_id", network.segmentationId().toString()); + return result; + } +} diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java index aa3c0c73..e57d56bc 100644 --- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java @@ -1,57 +1,57 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc.web; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.VirtualPort; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * VirtualPort JSON codec. - */ -public final class VirtualPortCodec extends JsonCodec { - @Override - public ObjectNode encode(VirtualPort vPort, CodecContext context) { - checkNotNull(vPort, "VPort cannot be null"); - ObjectNode result = context - .mapper() - .createObjectNode() - .put("id", vPort.portId().toString()) - .put("network_id", vPort.networkId().toString()) - .put("admin_state_up", vPort.adminStateUp()) - .put("name", vPort.name().toString()) - .put("status", vPort.state().toString()) - .put("mac_address", vPort.macAddress().toString()) - .put("tenant_id", vPort.tenantId().toString()) - .put("device_id", vPort.deviceId().toString()) - .put("device_owner", vPort.deviceOwner().toString()) - .put("binding:vnic_type", vPort.bindingVnicType().toString()) - .put("binding:Vif_type", vPort.bindingVifType().toString()) - .put("binding:host_id", vPort.bindingHostId().toString()) - .put("binding:vif_details", vPort.bindingVifDetails().toString()); - result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode( - vPort.allowedAddressPairs(), context)); - result.set("fixed_ips", new FixedIpCodec().encode( - vPort.fixedIps(), context)); - result.set("security_groups", new SecurityGroupCodec().encode( - vPort.securityGroups(), context)); - return result; - } -} +/* + * 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 { + @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 index 00000000..34636a9f --- /dev/null +++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java @@ -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; diff --git a/framework/src/onos/apps/vtnweb/pom.xml b/framework/src/onos/apps/vtnweb/pom.xml index 974d3bf1..543bcfbb 100644 --- a/framework/src/onos/apps/vtnweb/pom.xml +++ b/framework/src/onos/apps/vtnweb/pom.xml @@ -1,76 +1,88 @@ + - 4.0.0 - - org.onosproject - onos-apps - 1.3.0-SNAPSHOT - ../pom.xml - + 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"> + 4.0.0 + + org.onosproject + onos-apps + 1.4.0-SNAPSHOT + ../pom.xml + - onos-app-vtnweb - bundle - - org.onosproject.vtnweb - /onos/vtn - + onos-app-vtnweb + bundle + + org.onosproject.vtnweb + /onos/vtn + - - - javax.ws.rs - jsr311-api - 1.1.1 - - - org.onosproject - onos-api - - - org.onosproject - onos-app-vtnrsc - ${project.version} - - - - - - org.apache.felix - maven-bundle-plugin - true - - - <_wab>src/main/webapp/ - - ${project.groupId}.${project.artifactId} - - - 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.* - - ${web.context} - - - - - + + + javax.ws.rs + jsr311-api + 1.1.1 + + + org.onosproject + onos-app-vtnrsc + ${project.version} + + + + + + org.apache.felix + maven-bundle-plugin + true + + + <_wab>src/main/webapp/ + + ${project.groupId}.${project.artifactId} + + + 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.* + + ${web.context} + + + + + \ No newline at end of file diff --git a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java index c46af6ef..3979e1e3 100644 --- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java +++ b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java @@ -1,365 +1,365 @@ -/* - * 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 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 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 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 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 createOrUpdateByInputStream(JsonNode subnode) { - checkNotNull(subnode, JSON_NOT_NULL); - Iterable 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 changeJsonToSubs(JsonNode subnetNodes) { - checkNotNull(subnetNodes, JSON_NOT_NULL); - Map 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 hostRoutesIt = jsonNodeToHostRoutes(hostRoutes); - JsonNode allocationPools = subnetNode.get("allocation_pools"); - Iterable 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 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 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 hostRoutesIt = jsonNodeToHostRoutes(hostRoutes); - JsonNode allocationPools = subnetNodes.get("allocation_pools"); - Iterable 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 jsonNodeToAllocationPools(JsonNode allocationPools) { - checkNotNull(allocationPools, JSON_NOT_NULL); - ConcurrentMap 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 jsonNodeToHostRoutes(JsonNode hostRoutes) { - checkNotNull(hostRoutes, JSON_NOT_NULL); - ConcurrentMap 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 item type - * @param message not found message - * @return item if not null - * @throws org.onlab.util.ItemNotFoundException if item is null - */ - protected T nullIsNotFound(T item, String message) { - if (item == null) { - throw new ItemNotFoundException(message); - } - return item; - } - -} +/* + * 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 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 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 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 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 createOrUpdateByInputStream(JsonNode subnode) { + checkNotNull(subnode, JSON_NOT_NULL); + Iterable 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 changeJsonToSubs(JsonNode subnetNodes) { + checkNotNull(subnetNodes, JSON_NOT_NULL); + Map 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 hostRoutesIt = jsonNodeToHostRoutes(hostRoutes); + JsonNode allocationPools = subnetNode.get("allocation_pools"); + Iterable 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 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 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 hostRoutesIt = jsonNodeToHostRoutes(hostRoutes); + JsonNode allocationPools = subnetNodes.get("allocation_pools"); + Iterable 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 jsonNodeToAllocationPools(JsonNode allocationPools) { + checkNotNull(allocationPools, JSON_NOT_NULL); + ConcurrentMap 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 jsonNodeToHostRoutes(JsonNode hostRoutes) { + checkNotNull(hostRoutes, JSON_NOT_NULL); + ConcurrentMap 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 item type + * @param message not found message + * @return item if not null + * @throws org.onlab.util.ItemNotFoundException if item is null + */ + protected T nullIsNotFound(T item, String message) { + if (item == null) { + throw new ItemNotFoundException(message); + } + return item; + } + +} diff --git a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java index 7a0d43d2..b3888db1 100644 --- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java +++ b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java @@ -1,372 +1,371 @@ -/* - * 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 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 networks = get(TenantNetworkService.class) - .getNetworks(); - Iterator networkors = networks.iterator(); - while (networkors.hasNext()) { - TenantNetwork network = networkors.next(); - if ((queryId == null || queryId.equals(network.id().toString())) - && (queryName == null || queryName.equals(network.name() - .toString())) - && (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 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 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 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 changeJson2obj(String flag, - TenantNetworkId networkId, - JsonNode node) { - checkNotNull(node, JSON_NOT_NULL); - TenantNetwork network = null; - ConcurrentMap 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 changeJson2objs(JsonNode nodes) { - checkNotNull(nodes, JSON_NOT_NULL); - TenantNetwork network = null; - ConcurrentMap 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 item type - * @param message not found message - * @return item if not null - * @throws org.onlab.util.ItemNotFoundException if item is null - */ - protected T nullIsNotFound(T item, String message) { - if (item == null) { - throw new ItemNotFoundException(message); - } - return item; - } -} +/* + * 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 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 networks = get(TenantNetworkService.class) + .getNetworks(); + Iterator 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 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 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 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 changeJson2obj(String flag, + TenantNetworkId networkId, + JsonNode node) { + checkNotNull(node, JSON_NOT_NULL); + TenantNetwork network = null; + ConcurrentMap 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 changeJson2objs(JsonNode nodes) { + checkNotNull(nodes, JSON_NOT_NULL); + TenantNetwork network = null; + ConcurrentMap 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 item type + * @param message not found message + * @return item if not null + * @throws org.onlab.util.ItemNotFoundException if item is null + */ + protected T nullIsNotFound(T item, String message) { + if (item == null) { + throw new ItemNotFoundException(message); + } + return item; + } +} diff --git a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java index 0a427bba..d0b7ed2d 100644 --- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java +++ b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java @@ -1,410 +1,410 @@ -/* - * 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 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 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 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 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 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 changeJsonToPorts(JsonNode vPortNodes) { - checkNotNull(vPortNodes, JSON_NOT_NULL); - Map portMap = new HashMap(); - Map 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 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 allowedAddressPairs = - jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode); - JsonNode securityGroupNode = vPortnode.get("security_groups"); - Collection 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 changeJsonToPort(JsonNode vPortNodes) { - checkNotNull(vPortNodes, JSON_NOT_NULL); - Map vportMap = new HashMap(); - Map 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 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 allowedAddressPairs = - jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode); - JsonNode securityGroupNode = vPortNodes.get("security_groups"); - Collection 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 jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) { - checkNotNull(allowedAddressPairs, JSON_NOT_NULL); - ConcurrentMap 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 jsonNodeToSecurityGroup(JsonNode securityGroups) { - checkNotNull(securityGroups, JSON_NOT_NULL); - ConcurrentMap 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 item type - * @param message not found message - * @return item if not null - * @throws org.onlab.util.ItemNotFoundException if item is null - */ - protected T nullIsNotFound(T item, String message) { - if (item == null) { - throw new ItemNotFoundException(message); - } - return item; - } -} +/* + * 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 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 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 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 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 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 changeJsonToPorts(JsonNode vPortNodes) { + checkNotNull(vPortNodes, JSON_NOT_NULL); + Map portMap = new HashMap<>(); + Map 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 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 allowedAddressPairs = + jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode); + JsonNode securityGroupNode = vPortnode.get("security_groups"); + Collection 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 changeJsonToPort(JsonNode vPortNodes) { + checkNotNull(vPortNodes, JSON_NOT_NULL); + Map vportMap = new HashMap<>(); + Map 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 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 allowedAddressPairs = + jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode); + JsonNode securityGroupNode = vPortNodes.get("security_groups"); + Collection 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 jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) { + checkNotNull(allowedAddressPairs, JSON_NOT_NULL); + ConcurrentMap 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 jsonNodeToSecurityGroup(JsonNode securityGroups) { + checkNotNull(securityGroups, JSON_NOT_NULL); + ConcurrentMap 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 item type + * @param message not found message + * @return item if not null + * @throws org.onlab.util.ItemNotFoundException if item is null + */ + protected T nullIsNotFound(T item, String message) { + if (item == null) { + throw new ItemNotFoundException(message); + } + return item; + } +} diff --git a/framework/src/onos/apps/xos-integration/pom.xml b/framework/src/onos/apps/xos-integration/pom.xml index 0dc2300e..68eafd16 100644 --- a/framework/src/onos/apps/xos-integration/pom.xml +++ b/framework/src/onos/apps/xos-integration/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-apps - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/cli/pom.xml b/framework/src/onos/cli/pom.xml index a9cd180d..3d29a26e 100644 --- a/framework/src/onos/cli/pom.xml +++ b/framework/src/onos/cli/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java index 0ab6845f..b0cbbdd6 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java @@ -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 ADDRESSES_COMPARATOR = new Comparator() { - @Override - public int compare(PortAddresses arg0, PortAddresses arg1) { - return CONNECT_POINT_COMPARATOR.compare(arg0.connectPoint(), arg1.connectPoint()); - } - }; - public static final Comparator INTERFACES_COMPARATOR = (intf1, intf2) -> CONNECT_POINT_COMPARATOR.compare(intf1.connectPoint(), intf2.connectPoint()); diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java index f05181f5..5ab15b08 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java @@ -28,7 +28,7 @@ public class MetricNameCompleter extends AbstractChoicesCompleter { @Override protected List choices() { MetricsService metricsService = AbstractShellCommand.get(MetricsService.class); - return new ArrayList(metricsService.getMetrics().keySet()); + return new ArrayList<>(metricsService.getMetrics().keySet()); } } diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java index 5f2f86ee..d99a1839 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java @@ -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); }); } diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java index 1929b726..a736f99a 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java @@ -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; diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java index d68084c7..12e9ab5f 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java @@ -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 index 00000000..ff66b803 --- /dev/null +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java @@ -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 index 00000000..9bdeadb3 --- /dev/null +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java @@ -0,0 +1,47 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.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()); + } + +} diff --git a/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml index 640868fa..459ffa96 100644 --- a/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml +++ b/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml @@ -330,9 +330,6 @@ - - - @@ -353,6 +350,13 @@ + + + + + + + diff --git a/framework/src/onos/core/api/pom.xml b/framework/src/onos/core/api/pom.xml index 7cfb4acc..23a051c4 100644 --- a/framework/src/onos/core/api/pom.xml +++ b/framework/src/onos/core/api/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-core - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java index dbe5f71c..1ee78b15 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ClusterDefinitionService.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java index 3cfc9367..2f74ae69 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/ControllerNode.java @@ -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. */ diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java index 3dfc6b26..303ad395 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java @@ -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. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java index b5be0944..8de05439 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/MetricsHelper.java @@ -32,7 +32,7 @@ public interface MetricsHelper { * * @return MetricService instance */ - abstract MetricsService metricsService(); + MetricsService metricsService(); /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java index d9001825..ffbf7f96 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/Device.java @@ -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 } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java index 9e19b624..aba8ae47 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/IpElementId.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java index b6068ee7..e962110c 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicLinkConfig.java @@ -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 { 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 { 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); + } } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java index b06c4228..dfb494d6 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/OpticalPortConfig.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java index 44a4d364..5492fa98 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java @@ -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); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java index e446a9fe..a487cbc4 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java @@ -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 diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java index 8d36be49..d4d2d9ec 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java index e2971158..d4f959c3 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java @@ -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. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java index f2de9a0f..534f6b9e 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java @@ -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; /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java index 1ace8931..c8b6690d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java index 090c298c..6ac7a7a2 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java @@ -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. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java index d620fedb..8676e46a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostAdminService.java @@ -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. - *

- * 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); - } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java index 8678a297..f7b7c499 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java @@ -30,7 +30,20 @@ public interface HostProviderService extends ProviderService { * @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. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java index be114f05..39012159 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostService.java @@ -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 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 getAddressBindingsForPort(ConnectPoint connectPoint); - } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java index ca11a942..5894fe92 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostStore.java @@ -39,12 +39,13 @@ public interface HostStore extends Store { * @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 { */ Set 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 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 getAddressBindingsForPort(ConnectPoint connectPoint); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java index bf469dbe..7df3c81e 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsIntent.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java index 3c3c45ce..caa5fbb9 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java index dffbabfe..0c831fd5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java @@ -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 links) { - checkArgument(Iterables.all(links, new Predicate() { - @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++) { diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java index fc2eba70..5a034b4d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java index 68c0a838..3eab9386 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketPriority.java @@ -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 +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java index 98886775..0eba1b4e 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketProcessor.java @@ -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; } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java index 06c416ec..98f4d8e0 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketService.java @@ -15,9 +15,13 @@ */ 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 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 getRequests(); + /** * Emits the specified outbound packet onto the network. * diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java index ff45cc0c..97f7cb55 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/packet/PacketStore.java @@ -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 { /** * Obtains all existing requests in the system. * - * @return a set of packet requests + * @return list of packet requests in order of priority */ - Set existingRequests(); + List existingRequests(); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java index 8ffe17a4..9b27f4f8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/proxyarp/ProxyArpService.java @@ -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 { diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java index 800135f4..4b80dfcd 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppGuard.java @@ -17,9 +17,12 @@ 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() { diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java index 21a70d2b..09fe17a8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/AppPermission.java @@ -16,11 +16,14 @@ 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 { diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java index 75d9433f..0c874c9d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/Permission.java @@ -16,6 +16,9 @@ package org.onosproject.security; +import com.google.common.annotations.Beta; + +@Beta public class Permission { protected String classname; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java index 16ea94d1..30d143c0 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityAdminService.java @@ -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 { /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java b/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java index 34b4e78a..444b6bb5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/security/SecurityUtil.java @@ -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(); diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java index 8cac5968..a62d3823 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java @@ -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. */ diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java index 2889422a..e0d7d239 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlay.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java index bd2f2fe6..61bc0c23 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiTopoOverlayFactory.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java index 84d11344..1c42c97a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java index 854ac27f..895c9d93 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/CellFormatter.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java index 6113fc3f..31d9f634 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java index 33ce2ab5..08822b7b 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java index 42d684b6..0e1c248b 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java index fee26154..4af6fe2f 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java index 093a20d3..2386f8f3 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java index 0efa2ebd..8309c545 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java index e09982ea..981a81bb 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java index fe87c61b..95a7cc23 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java index 44dc1940..58c70930 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java index ab2ced36..d30ba2f6 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/AbstractHighlight.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java index c37c129b..a40383b8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLink.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java index 720eca49..cc2cf4af 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BaseLinkMap.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java index 8c95e15d..1217faae 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLink.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java index 7bc0e65d..9a42e107 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/BiLinkMap.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java index ca2ecccd..05b7317d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java index 2985d3d4..0ce6592c 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java index be59c26b..12d3b629 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java index 76669a84..48959496 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java index b4e43304..a734c6b7 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/LinkHighlight.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java index d21a8724..b11ddecd 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/Mod.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java index 735f8166..61e10c56 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java index b284de1b..4aed9038 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java index 121e0834..a165be33 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java index 38a8f036..0f42b628 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoConstants.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java index dc327464..39947440 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoElementType.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java index a94068ee..8df03169 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoJson.java @@ -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; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java index f92d5798..b38a7f7d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/TopoUtils.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java index 6d5e8934..b81155e6 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/event/EventDeliveryServiceAdapter.java @@ -17,8 +17,6 @@ package org.onosproject.event; import java.util.Set; -import static org.junit.Assert.*; - /** * Testing adapter for the event delivery service. */ diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java index c171d523..1ab17293 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/OchSignalTest.java @@ -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. */ diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java index 5bfdd76b..7b43da6a 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceClockServiceAdapter.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java index 795e4c0a..5f52f6db 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java @@ -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 getAvailableDevices() { return FluentIterable.from(getDevices()) - .filter(new Predicate() { - - @Override - public boolean apply(Device input) { - return isAvailable(input.id()); - } - }); + .filter(input -> isAvailable(input.id())); } @Override diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java index 30326a2e..7a61f823 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java index 226dad06..0fad54a8 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/HostServiceAdapter.java @@ -15,15 +15,15 @@ */ 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 getAddressBindings() { - return null; - } - - @Override - public Set getAddressBindingsForPort(ConnectPoint connectPoint) { - return null; - } - } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java index 9b9f7cec..a33d3692 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java @@ -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 installable = getInstallable(intent.key()); - executeWithdrawingPhase(intent, installable); - } catch (IntentException e) { - exceptions.add(e); - } - + executor.execute(() -> { + try { + List installable = getInstallable(intent.key()); + executeWithdrawingPhase(intent, installable); + } catch (IntentException e) { + exceptions.add(e); } }); } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java index 60857cac..0067fb2d 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java @@ -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 diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java index ffb2635e..2a38cbb3 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PartitionServiceAdapter.java @@ -17,8 +17,6 @@ package org.onosproject.net.intent; import org.onosproject.cluster.NodeId; -import static org.junit.Assert.*; - /** * Testing adapter for the partition service. */ diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java index 5cb84b31..7cd87cd1 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java @@ -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 getActiveLinks() { return FluentIterable.from(getLinks()) - .filter(new Predicate() { - - @Override - public boolean apply(Link input) { - return input.state() == State.ACTIVE; - } - }); + .filter(input -> input.state() == State.ACTIVE); } @Override diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java index afe936b7..c4386593 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/packet/PacketServiceAdapter.java @@ -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 getProcessors() { + return null; + } + + @Override + public List getRequests() { + return null; + } + @Override public void requestPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) { } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java index b498c1c7..ad439d66 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/DatabaseUpdateTest.java @@ -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 +} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java index c241c0e0..47fba6c9 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MapEventTest.java @@ -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 vStats = new Versioned<>(2, 1); @@ -58,4 +57,4 @@ public class MapEventTest extends TestCase { .testEquals(); } -} \ No newline at end of file +} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java index 5d991a26..43475e45 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/MultiValuedTimestampTest.java @@ -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 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 +} diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java index 8a401db2..fbe3271b 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/store/service/VersionedTest.java @@ -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 stats1 = new Versioned<>(1, 2, 3); diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java index 7c2f2d73..4456dd3d 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/TableUtilsTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java index 0b9af23d..30125afb 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellComparatorTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java index 7a3c34bc..41fefd65 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AbstractCellFormatterTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java index e74fb47c..a7befbdb 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/AppIdFormatterTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java index 65fd7843..f7ad2751 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/ConnectPointFormatterTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java index 87c95288..d77c1b2b 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellComparatorTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java index 6351a1f4..b63793b9 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/DefaultCellFormatterTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java index ad23b02c..2f70d43c 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HexFormatterTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java index bfbe4541..25ec89cd 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/HostLocationFormatterTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java index f41d82b3..1e05ded1 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java index 17fcc229..83f4809c 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkMapTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java index 1acc06fa..55f31ac9 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java index b5bd41ef..a6beec86 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/BiLinkTestBase.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java index 04c6dc18..01a1b975 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ButtonIdTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java index 7d6dfe67..fe663a5b 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/HighlightsTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java index 205f08ce..a88de33a 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/LinkHighlightTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java index bb40279c..03a18f97 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/ModTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java index 60cada45..06a78580 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/NodeSelectionTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java index b08ee4dc..7e6cc227 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java @@ -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; diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java index 6a3bfa43..ac0051cd 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/TopoJsonTest.java @@ -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; diff --git a/framework/src/onos/core/common/pom.xml b/framework/src/onos/core/common/pom.xml index 71c0fe40..e4d25eed 100644 --- a/framework/src/onos/core/common/pom.xml +++ b/framework/src/onos/core/common/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-core - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java index 6a9b6708..c3b6d821 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/MockCodecContext.java @@ -30,7 +30,7 @@ public class MockCodecContext implements CodecContext { private final ObjectMapper mapper = new ObjectMapper(); private final CodecManager manager = new CodecManager(); - private final Map, Object> services = new HashMap<>(); + private final Map, Object> services = new HashMap<>(); /** * Constructs a new mock codec context. diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java index fc90dfad..72fc1b05 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java @@ -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 getAvailableDevices() { return FluentIterable.from(getDevices()) - .filter(new Predicate() { - - @Override - public boolean apply(Device input) { - return isAvailable(input.id()); - } - }); + .filter(input -> isAvailable(input.id())); } @Override diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java index 562e6f3c..c9e135d9 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java @@ -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 = diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java index 3b8f1d35..c8c92aa5 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java @@ -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 getFlowEntries(DeviceId deviceId) { // flatten and make iterator unmodifiable return FluentIterable.from(getFlowTable(deviceId).values()) - .transformAndConcat( - new Function, Iterable>() { - - @Override - public Iterable apply( - List input) { - return Collections.unmodifiableList(input); - } - }); + .transformAndConcat(Collections::unmodifiableList); } @Override diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java index 71de3e13..230fa339 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java @@ -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> extraneousGroupEntriesById = new ConcurrentHashMap<>(); - private final HashMap deviceAuditStatus = - new HashMap(); + private final HashMap deviceAuditStatus = new HashMap<>(); private final AtomicInteger groupIdGen = new AtomicInteger(); @@ -189,15 +187,7 @@ public class SimpleGroupStore public Iterable getGroups(DeviceId deviceId) { // flatten and make iterator unmodifiable return FluentIterable.from(getGroupKeyTable(deviceId).values()) - .transform( - new Function() { - - @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 newBucketList = new ArrayList( - oldBuckets.buckets()); + List newBucketList = new ArrayList<>(oldBuckets.buckets()); boolean groupDescUpdated = false; if (type == UpdateType.ADD) { diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java index dd6c8a58..b10fca5c 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStoreTest.java @@ -205,10 +205,10 @@ public class SimpleGroupStoreTest { private void testStoreAndGetGroup(GroupKey key) { PortNumber[] ports = {PortNumber.portNumber(31), PortNumber.portNumber(32)}; - List outPorts = new ArrayList(); + List outPorts = new ArrayList<>(); outPorts.addAll(Arrays.asList(ports)); - List buckets = new ArrayList(); + List 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 newBucketList = new ArrayList(); + List 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 buckets = new ArrayList(); + List buckets = new ArrayList<>(); buckets.addAll(existingGroup.buckets().buckets()); PortNumber[] newNeighborPorts = {PortNumber.portNumber(41), PortNumber.portNumber(42)}; - List newOutPorts = new ArrayList(); + List newOutPorts = new ArrayList<>(); newOutPorts.addAll(Collections.singletonList(newNeighborPorts[0])); - List toAddBuckets = new ArrayList(); + List 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 buckets = new ArrayList(); + List buckets = new ArrayList<>(); buckets.addAll(existingGroup.buckets().buckets()); - List toRemoveBuckets = new ArrayList(); + List 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 outPorts = new ArrayList(); + List outPorts = new ArrayList<>(); outPorts.add(ports[0]); outPorts.add(ports[1]); - List buckets = new ArrayList(); + List buckets = new ArrayList<>(); for (PortNumber portNumber: outPorts) { TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); tBuilder.setOutput(portNumber) diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java index f5604f68..264d0493 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java @@ -15,23 +15,16 @@ */ 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 locations = HashMultimap.create(); - private final SetMultimap portAddresses = - Multimaps.synchronizedSetMultimap( - HashMultimap.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 addresses = new HashSet<>(host.ipAddresses()); - addresses.addAll(descr.ipAddress()); + final Set 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 getAddressBindings() { - synchronized (portAddresses) { - return ImmutableSet.copyOf(portAddresses.values()); - } - } - - @Override - public Set getAddressBindingsForPort(ConnectPoint connectPoint) { - synchronized (portAddresses) { - Set 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; diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java index d0be2b1f..92b882a6 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStore.java @@ -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 SetMultimap createSynchronizedHashMultiMap() { return synchronizedSetMultimap( - Multimaps.newSetMultimap(new ConcurrentHashMap>(), + Multimaps.newSetMultimap(new ConcurrentHashMap<>(), () -> Sets.newConcurrentHashSet())); } diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java index 2d2b2759..40649aa5 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java @@ -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); diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java index ef92ded2..61db2e66 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java @@ -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)); }); } } diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java index 4345abaf..f8359262 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimplePacketStore.java @@ -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 existingRequests() { - return Collections.unmodifiableSet(requests); + public List existingRequests() { + return ImmutableList.copyOf(requests); } } diff --git a/framework/src/onos/core/net/pom.xml b/framework/src/onos/core/net/pom.xml index 4ba04c50..9ea00070 100644 --- a/framework/src/onos/core/net/pom.xml +++ b/framework/src/onos/core/net/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-core - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java index 07612292..8a441f61 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java @@ -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; diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java index fd867326..fa5f2480 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/edgeservice/impl/package-info.java @@ -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. */ diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java index 99263381..43f346b7 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java @@ -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 getAddressBindings() { - checkPermission(HOST_READ); - return store.getAddressBindings(); - } - - @Override - public Set getAddressBindingsForPort(ConnectPoint connectPoint) { - checkPermission(HOST_READ); - return store.getAddressBindingsForPort(connectPoint); - } - // Personalized host provider service issued to the supplied provider. private class InternalHostProviderService extends AbstractProviderService @@ -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); } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java index fe252368..44f8cbf0 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java @@ -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; *

*/ 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 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 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 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, diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java index 609f9a34..52621e2f 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompiler.java @@ -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; diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java index c60325a7..05a20f96 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java @@ -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 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(); diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java index a6b08f62..801092f4 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/BasicLinkOperator.java @@ -16,12 +16,14 @@ 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)); + } } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java index 157288a4..d6f72fd9 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java @@ -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 getActiveLinks() { checkPermission(LINK_READ); return FluentIterable.from(getLinks()) - .filter(new Predicate() { - - @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); } + } } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java index 75239fdd..a0bc693c 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java @@ -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 & NB APIs. @@ -137,6 +139,11 @@ public class PacketManager processors.values().remove(processor); } + @Override + public Map 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 getRequests() { + return store.existingRequests(); + } + /** * Pushes a packet request flow rule to all devices. * diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java index 398260ff..25a2640d 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/proxyarp/impl/ProxyArpManager.java @@ -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 hosts = hostService.getHostsByIp(targetAddress); + Set 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 interfaces = interfaceService.getInterfacesByIp(source); + Set 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 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 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; + } + } } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java index 996ad14e..57964d69 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java @@ -348,12 +348,7 @@ public class StatisticManager implements StatisticService { * @return predicate */ private static Predicate hasApplicationId(ApplicationId appId) { - return new Predicate() { - @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 hasGroupId(Optional groupId) { - return new Predicate() { - @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()); }; } } diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java index 8827c558..2be0df7a 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java @@ -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(); diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java index 78bc08e0..ba40b2b1 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/device/impl/OpticalPortOperatorTest.java @@ -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; diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java index ae7cc874..73ce3936 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java @@ -276,10 +276,10 @@ public class GroupManagerTest { PortNumber[] addPorts = {PortNumber.portNumber(51), PortNumber.portNumber(52)}; List outPorts; - outPorts = new ArrayList(); + outPorts = new ArrayList<>(); outPorts.addAll(Arrays.asList(addPorts)); List addBuckets; - addBuckets = new ArrayList(); + addBuckets = new ArrayList<>(); for (PortNumber portNumber: outPorts) { TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); tBuilder.setOutput(portNumber) diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java index e7f14b5d..940ed919 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java @@ -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(); diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java index dbb807f8..92c6c931 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostManagerTest.java @@ -15,36 +15,22 @@ */ 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 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 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 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 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 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 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 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 storedAddresses = mgr.getAddressBindingsForPort(CP1); - - assertEquals(1, storedAddresses.size()); - assertTrue(storedAddresses.contains(add1)); - } - - @Test - public void getAddressBindings() { - Set 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 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 { } } diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java index d6ff473a..d167197a 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java @@ -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); diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java index 8bd29bf8..f23a049d 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/MockFlowRuleService.java @@ -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 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 diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java index 76b26f46..03a38a5a 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsIntentCompilerTest.java @@ -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; diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java index fe9e37cd..eadbb5c9 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java @@ -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(); diff --git a/framework/src/onos/core/pom.xml b/framework/src/onos/core/pom.xml index 0f7dd8c8..c4f25545 100644 --- a/framework/src/onos/core/pom.xml +++ b/framework/src/onos/core/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/core/security/pom.xml b/framework/src/onos/core/security/pom.xml index 67e74a1e..8dbc6c0d 100644 --- a/framework/src/onos/core/security/pom.xml +++ b/framework/src/onos/core/security/pom.xml @@ -1,4 +1,19 @@ + @@ -7,7 +22,7 @@ onos-core org.onosproject - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java b/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java index 8ae1a1ae..b043765a 100644 --- a/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java +++ b/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/DefaultPolicyBuilder.java @@ -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; diff --git a/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java b/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java index 30b0f8bb..325f49be 100644 --- a/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java +++ b/framework/src/onos/core/security/src/main/java/org/onosproject/security/impl/SecurityModeManager.java @@ -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 index 00000000..a47f8eaf --- /dev/null +++ b/framework/src/onos/core/security/src/main/java/org/onosproject/security/store/package-info.java @@ -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; diff --git a/framework/src/onos/core/store/dist/pom.xml b/framework/src/onos/core/store/dist/pom.xml index eb9c38a5..cc293da4 100644 --- a/framework/src/onos/core/store/dist/pom.xml +++ b/framework/src/onos/core/store/dist/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-core-store - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java index 4e28e3c2..8b0001d8 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/ClusterDefinitionManager.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java index 9e52c3e3..ffdd25f2 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/IOLoopMessagingManager.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java index 8b2cc8e2..9328817b 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java index 58aca31a..5183924c 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapBackedJavaMap.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java index b7c3794b..fbc2c88d 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DatabaseManager.java @@ -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); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java index 9d3505bd..9a55ffb1 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultDatabaseState.java @@ -84,7 +84,7 @@ public class DefaultDatabaseState implements DatabaseState { } nextVersion = context.get("nextVersion"); if (nextVersion == null) { - nextVersion = new Long(0); + nextVersion = 0L; context.put("nextVersion", nextVersion); } } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java index e54b0ee5..7c3769a3 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java @@ -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 registeredIds; private Map nameToAppIdCache = Maps.newConcurrentMap(); private Map 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"); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java index 8913742d..c6f48a44 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java index ccf0f326..6a667e32 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java index fd7fcd80..23206725 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java @@ -82,7 +82,7 @@ class DeviceDescriptions { if (oldOne != null) { SparseAnnotations merged = union(oldOne.value().annotations(), newDesc.value().annotations()); - newOne = new Timestamped( + 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( + 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( + 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( + newOne = new Timestamped<>( new OduCltPortDescription( ocDesc, ocDesc.signalType(), merged), newDesc.timestamp()); break; default: - newOne = new Timestamped( + newOne = new Timestamped<>( new DefaultPortDescription(newDesc.value(), merged), newDesc.timestamp()); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java index 6f93963a..3c3bbb65 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java index 63456433..973db494 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java @@ -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 mergedList = FluentIterable.from(portDescriptions) - .transform(new Function() { - @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); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java index ed0ccaa1..1ff05198 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortFragmentId.java @@ -41,7 +41,7 @@ public final class PortFragmentId { @Override public int hashCode() { return Objects.hash(providerId, deviceId, portNumber); - }; + } @Override public boolean equals(Object obj) { diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java index c80f8105..971f53db 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java index 5eafc7ed..962fe8f4 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/flow/ReplicaInfoEvent.java @@ -60,5 +60,5 @@ public class ReplicaInfoEvent extends AbstractEvent deviceAuditStatus = - new HashMap(); + private final HashMap 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 newBucketList = new ArrayList( - oldBuckets.buckets()); + List newBucketList = new ArrayList<>(oldBuckets.buckets()); boolean groupDescUpdated = false; if (type == UpdateType.ADD) { diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java index d8b9daca..d0b827cd 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java @@ -1,267 +1,263 @@ -package org.onosproject.store.host.impl; - -import static com.google.common.base.Preconditions.checkNotNull; -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_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.Collections; -import java.util.Objects; -import java.util.Set; -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.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.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 - 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 locations = - Multimaps.synchronizedSetMultimap( - HashMultimap.create()); - - private final SetMultimap portAddresses = - Multimaps.synchronizedSetMultimap( - HashMultimap.create()); - - private EventuallyConsistentMap hosts; - - private EventuallyConsistentMapListener hostLocationTracker = - new HostLocationTracker(); - - @Activate - public void activate() { - KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder() - .register(KryoNamespaces.API); - - hosts = storageService.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(); - portAddresses.clear(); - - log.info("Stopped"); - } - - @Override - public HostEvent createOrUpdateHost(ProviderId providerId, - HostId hostId, - HostDescription hostDescription) { - DefaultHost currentHost = hosts.get(hostId); - if (currentHost == null) { - DefaultHost newhost = new DefaultHost( - providerId, - hostId, - hostDescription.hwAddress(), - hostDescription.vlan(), - hostDescription.location(), - ImmutableSet.copyOf(hostDescription.ipAddress()), - hostDescription.annotations()); - hosts.put(hostId, newhost); - return new HostEvent(HOST_ADDED, newhost); - } - return updateHost(providerId, hostId, hostDescription, currentHost); - } - - @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 getHosts() { - return ImmutableSet.copyOf(hosts.values()); - } - - @Override - public Host getHost(HostId hostId) { - return hosts.get(hostId); - } - - @Override - public Set getHosts(VlanId vlanId) { - return filter(hosts.values(), host -> Objects.equals(host.vlan(), vlanId)); - } - - @Override - public Set getHosts(MacAddress mac) { - return filter(hosts.values(), host -> Objects.equals(host.mac(), mac)); - } - - @Override - public Set getHosts(IpAddress ip) { - return filter(hosts.values(), host -> host.ipAddresses().contains(ip)); - } - - @Override - public Set getConnectedHosts(ConnectPoint connectPoint) { - return ImmutableSet.copyOf(locations.get(connectPoint)); - } - - @Override - public Set getConnectedHosts(DeviceId deviceId) { - return ImmutableMultimap.copyOf(locations) - .entries() - .stream() - .filter(entry -> entry.getKey().deviceId().equals(deviceId)) - .map(entry -> entry.getValue()) - .collect(Collectors.toSet()); - } - - @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 getAddressBindings() { - return ImmutableSet.copyOf(portAddresses.values()); - } - - @Override - public Set getAddressBindingsForPort(ConnectPoint connectPoint) { - synchronized (portAddresses) { - Set addresses = portAddresses.get(connectPoint); - return addresses == null ? Collections.emptySet() : ImmutableSet.copyOf(addresses); - } - } - - private Set filter(Collection collection, Predicate predicate) { - return collection.stream().filter(predicate).collect(Collectors.toSet()); - } - - // checks for type of update to host, sends appropriate event - private HostEvent updateHost(ProviderId providerId, - HostId hostId, - HostDescription descr, - DefaultHost currentHost) { - - final boolean hostMoved = !currentHost.location().equals(descr.location()); - if (hostMoved || - !currentHost.ipAddresses().containsAll(descr.ipAddress()) || - !descr.annotations().keys().isEmpty()) { - - Set addresses = Sets.newHashSet(currentHost.ipAddresses()); - addresses.addAll(descr.ipAddress()); - Annotations annotations = merge((DefaultAnnotations) currentHost.annotations(), - descr.annotations()); - - DefaultHost updatedHost = new DefaultHost(providerId, currentHost.id(), - currentHost.mac(), currentHost.vlan(), - descr.location(), - addresses, - annotations); - - // TODO: We need a way to detect conflicting changes and abort update. - hosts.put(hostId, updatedHost); - locations.remove(currentHost.location(), currentHost); - locations.put(updatedHost.location(), updatedHost); - - HostEvent.Type eventType = hostMoved ? Type.HOST_MOVED : Type.HOST_UPDATED; - return new HostEvent(eventType, updatedHost); - } - return null; - } - - private class HostLocationTracker implements EventuallyConsistentMapListener { - @Override - public void event(EventuallyConsistentMapEvent 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)); - } - - } - } - } -} +/* + * 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 + 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 locations = + Multimaps.synchronizedSetMultimap( + HashMultimap.create()); + + private EventuallyConsistentMap hosts; + + private EventuallyConsistentMapListener hostLocationTracker = + new HostLocationTracker(); + + @Activate + public void activate() { + KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder() + .register(KryoNamespaces.API); + + hosts = storageService.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 eventType = new AtomicReference<>(); + final AtomicReference 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 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 getHosts() { + return ImmutableSet.copyOf(hosts.values()); + } + + @Override + public Host getHost(HostId hostId) { + return hosts.get(hostId); + } + + @Override + public Set getHosts(VlanId vlanId) { + return filter(hosts.values(), host -> Objects.equals(host.vlan(), vlanId)); + } + + @Override + public Set getHosts(MacAddress mac) { + return filter(hosts.values(), host -> Objects.equals(host.mac(), mac)); + } + + @Override + public Set getHosts(IpAddress ip) { + return filter(hosts.values(), host -> host.ipAddresses().contains(ip)); + } + + @Override + public Set getConnectedHosts(ConnectPoint connectPoint) { + return ImmutableSet.copyOf(locations.get(connectPoint)); + } + + @Override + public Set 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 filter(Collection collection, Predicate predicate) { + return collection.stream().filter(predicate).collect(Collectors.toSet()); + } + + private class HostLocationTracker implements EventuallyConsistentMapListener { + @Override + public void event(EventuallyConsistentMapEvent 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)); + } + + } + } + } +} diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java index 5ae8b4f4..9382960f 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java index 4577086c..243caf80 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java @@ -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 internalLinkKey = new Provided<>(linkKey, providerId); + Provided 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 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 diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java index 767ede54..105c77df 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java @@ -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 SetMultimap createSynchronizedHashMultiMap() { return synchronizedSetMultimap( - Multimaps.newSetMultimap(new ConcurrentHashMap>(), + Multimaps.newSetMultimap(new ConcurrentHashMap<>(), () -> Sets.newConcurrentHashSet())); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java index 356033b0..b353208d 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/link/impl/LinkInjectedEvent.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java index 9d3b1686..5a38a34a 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/mastership/impl/RoleValue.java @@ -45,9 +45,9 @@ final class RoleValue { * Constructs empty RoleValue. */ public RoleValue() { - value.put(MastershipRole.MASTER, new LinkedList()); - value.put(MastershipRole.STANDBY, new LinkedList()); - value.put(MastershipRole.NONE, new LinkedList()); + value.put(MastershipRole.MASTER, new LinkedList<>()); + value.put(MastershipRole.STANDBY, new LinkedList<>()); + value.put(MastershipRole.NONE, new LinkedList<>()); } /** diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java index 24ce2155..d4c89c93 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java @@ -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 existingRequests() { + public List existingRequests() { return tracker.requests(); } @@ -197,10 +198,11 @@ public class DistributedPacketStore return requests.replace(request.selector(), old.version(), newSet); } - public Set requests() { - ImmutableSet.Builder builder = ImmutableSet.builder(); - requests.values().forEach(v -> builder.addAll(v.value())); - return builder.build(); + public List requests() { + List 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 index 00000000..e3675524 --- /dev/null +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/proxyarp/impl/package-info.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java index ce25f868..3a296353 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java index d5434730..35bdad14 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/statistic/impl/DistributedStatisticStore.java @@ -97,7 +97,7 @@ public class DistributedStatisticStore implements StatisticStore { // register this store specific classes here .build(); } - };; + }; private ExecutorService messageHandlingExecutor; diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java index 0dcc6a10..daeaa12c 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManagerTest.java @@ -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 { diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java index 7ff94c88..952393aa 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/MatchTest.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java index 2a3bab87..2d329d14 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/ResultTest.java @@ -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; diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java index 84dc9153..ab53710b 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/consistent/impl/UpdateResultTest.java @@ -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 oldValue = new Versioned("a", 1); - Versioned newValue = new Versioned("b", 2); + Versioned oldValue = new Versioned<>("a", 1); + Versioned newValue = new Versioned<>("b", 2); UpdateResult ur = new UpdateResult<>(true, "foo", "k", oldValue, newValue); @@ -29,8 +44,8 @@ public class UpdateResultTest { @Test public void testToMapEvent() { - Versioned oldValue = new Versioned("a", 1); - Versioned newValue = new Versioned("b", 2); + Versioned oldValue = new Versioned<>("a", 1); + Versioned newValue = new Versioned<>("b", 2); UpdateResult ur1 = new UpdateResult<>(true, "foo", "k", oldValue, newValue); MapEvent event1 = ur1.toMapEvent(); @@ -59,8 +74,8 @@ public class UpdateResultTest { @Test public void testMap() { - Versioned oldValue = new Versioned("a", 1); - Versioned newValue = new Versioned("b", 2); + Versioned oldValue = new Versioned<>("a", 1); + Versioned newValue = new Versioned<>("b", 2); UpdateResult ur1 = new UpdateResult<>(true, "foo", "k", oldValue, newValue); UpdateResult ur2 = ur1.map(s -> s.length(), s -> s.length()); diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java index 43b11f52..3a168936 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java @@ -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 = diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java index d429752c..76ff8045 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/flow/impl/ReplicaInfoManagerTest.java @@ -101,7 +101,7 @@ public class ReplicaInfoManagerTest { // fake MastershipEvent eventDispatcher.post(new MastershipEvent(Type.MASTER_CHANGED, DID1, - new RoleInfo(NID1, new LinkedList()))); + new RoleInfo(NID1, new LinkedList<>()))); assertTrue(latch.await(1, TimeUnit.SECONDS)); } diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java index 0f67572f..c47eb27a 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/impl/TimestampedTest.java @@ -65,7 +65,7 @@ public class TimestampedTest { @Test public final void testValue() { - final Integer n = Integer.valueOf(42); + final Integer n = 42; Timestamped tsv = new Timestamped<>(n, TS_1_1); assertSame(n, tsv.value()); diff --git a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java index bf7af464..f8b5b860 100644 --- a/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java +++ b/framework/src/onos/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java @@ -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); diff --git a/framework/src/onos/core/store/pom.xml b/framework/src/onos/core/store/pom.xml index 59d66642..2b246b83 100644 --- a/framework/src/onos/core/store/pom.xml +++ b/framework/src/onos/core/store/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-core - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/core/store/serializers/pom.xml b/framework/src/onos/core/store/serializers/pom.xml index d869f60c..867ce0f0 100644 --- a/framework/src/onos/core/store/serializers/pom.xml +++ b/framework/src/onos/core/store/serializers/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-core-store - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java index febb4adb..ed02c3e3 100644 --- a/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java +++ b/framework/src/onos/core/store/serializers/src/main/java/org/onosproject/store/serializers/AnnotationsSerializer.java @@ -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; diff --git a/framework/src/onos/docs/external.xml b/framework/src/onos/docs/external.xml index 1f020548..69ac0577 100644 --- a/framework/src/onos/docs/external.xml +++ b/framework/src/onos/docs/external.xml @@ -26,7 +26,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml @@ -51,7 +51,7 @@ package @external-excludes true - ONOS Java API (1.3.0-SNAPSHOT) + ONOS Java API (1.4.0-SNAPSHOT) Network Model & Services diff --git a/framework/src/onos/docs/internal-apis b/framework/src/onos/docs/internal-apis index 9d8079a5..a35d093c 100644 --- a/framework/src/onos/docs/internal-apis +++ b/framework/src/onos/docs/internal-apis @@ -1,4 +1,2 @@ org.onosproject org.onosproject.* -org.onosproject.rest -org.onosproject.security diff --git a/framework/src/onos/docs/internal-core b/framework/src/onos/docs/internal-core index 8f242822..f987aa94 100644 --- a/framework/src/onos/docs/internal-core +++ b/framework/src/onos/docs/internal-core @@ -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 diff --git a/framework/src/onos/docs/internal-incubator b/framework/src/onos/docs/internal-incubator index 619bbb90..58179b68 100644 --- a/framework/src/onos/docs/internal-incubator +++ b/framework/src/onos/docs/internal-incubator @@ -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 diff --git a/framework/src/onos/docs/internal.xml b/framework/src/onos/docs/internal.xml index bcb1215d..de9c1c64 100644 --- a/framework/src/onos/docs/internal.xml +++ b/framework/src/onos/docs/internal.xml @@ -26,7 +26,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml @@ -50,7 +50,7 @@ package true - ONOS Java API (1.3.0-SNAPSHOT) + ONOS Java API (1.4.0-SNAPSHOT) @internal-excludes diff --git a/framework/src/onos/drivers/pom.xml b/framework/src/onos/drivers/pom.xml index b86e2bc2..749a68c4 100644 --- a/framework/src/onos/drivers/pom.xml +++ b/framework/src/onos/drivers/pom.xml @@ -23,7 +23,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml @@ -55,7 +55,7 @@ org.onosproject onos-core-serializers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT org.onosproject diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java index ed9794c0..cd7a1b66 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java @@ -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; diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CorsaPipeline.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CorsaPipeline.java index 0c957319..ccf73079 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CorsaPipeline.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CorsaPipeline.java @@ -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; diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA1Pipeline.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA1Pipeline.java index b338719c..f72bde09 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA1Pipeline.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA1Pipeline.java @@ -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; diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java index 220be864..23ef5f2b 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java @@ -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; diff --git a/framework/src/onos/features/pom.xml b/framework/src/onos/features/pom.xml index c4a22b60..7b362791 100644 --- a/framework/src/onos/features/pom.xml +++ b/framework/src/onos/features/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/incubator/api/pom.xml b/framework/src/onos/incubator/api/pom.xml index b417af53..9d7c7a6b 100644 --- a/framework/src/onos/incubator/api/pom.xml +++ b/framework/src/onos/incubator/api/pom.xml @@ -24,7 +24,7 @@ org.onosproject onos-incubator - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ConfigException.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ConfigException.java index 071be6a0..deeac765 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ConfigException.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ConfigException.java @@ -16,9 +16,12 @@ 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 { /** diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ExtraSubjectFactories.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ExtraSubjectFactories.java index 474ef6ad..260d0af4 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ExtraSubjectFactories.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/ExtraSubjectFactories.java @@ -15,12 +15,14 @@ */ 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 diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java index 47adf5c7..af2b47d8 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java @@ -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 { public static final String IPS = "ips"; public static final String MAC = "mac"; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/TunnelPrimitive.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/TunnelPrimitive.java index 975708d6..2abaab5f 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/TunnelPrimitive.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/TunnelPrimitive.java @@ -15,12 +15,14 @@ */ 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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java index 15ecf340..69d14bce 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java @@ -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 ipAddresses; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java index ad1bf34a..b164df93 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java @@ -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 { /** diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/DefaultLabelResource.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/DefaultLabelResource.java index 23663d38..1065503a 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/DefaultLabelResource.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/DefaultLabelResource.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResource.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResource.java index bb1b3167..6d5a90be 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResource.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResource.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceAdminService.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceAdminService.java index f20ab59b..a6108bb6 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceAdminService.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceAdminService.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceDelegate.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceDelegate.java index ea053afc..ae88be57 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceDelegate.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceDelegate.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceEvent.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceEvent.java index e77fdaf5..dd02ae21 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceEvent.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceEvent.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java index 8936954a..6fe7067d 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceListener.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceListener.java index 72de0fb4..b7f907c6 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceListener.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceListener.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourcePool.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourcePool.java index 315abe61..75916af0 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourcePool.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourcePool.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProvider.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProvider.java index 2ef966b6..821177a7 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProvider.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProvider.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderRegistry.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderRegistry.java index b8e0a299..e6234974 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderRegistry.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderRegistry.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderService.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderService.java index 93384c04..9a1472d6 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderService.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceProviderService.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceRequest.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceRequest.java index d81d7aa8..9ff6a587 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceRequest.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceRequest.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceService.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceService.java index 02052c37..bb86d475 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceService.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceService.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceStore.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceStore.java index 2da3e814..5322d013 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceStore.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceStore.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelStatistics.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelStatistics.java index 6358ca92..cab9ae43 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelStatistics.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelStatistics.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java index 964d451a..57af670c 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java @@ -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() { diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStatistics.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStatistics.java index 650f9941..c7c9fd96 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStatistics.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStatistics.java @@ -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 { /** diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/config/basics/OpticalPortConfigTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/config/basics/OpticalPortConfigTest.java index 9d56ca23..f2b15b09 100644 --- a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/config/basics/OpticalPortConfigTest.java +++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/config/basics/OpticalPortConfigTest.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/DefaultLabelResourceTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/DefaultLabelResourceTest.java index 5d7c02fc..1055dbad 100644 --- a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/DefaultLabelResourceTest.java +++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/DefaultLabelResourceTest.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourcePoolTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourcePoolTest.java index 87835080..25ef57f7 100644 --- a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourcePoolTest.java +++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourcePoolTest.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourceRequestTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourceRequestTest.java index 1b08f7c0..f41ad289 100644 --- a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourceRequestTest.java +++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/resource/label/LabelResourceRequestTest.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java index ae94991f..25ec73d4 100644 --- a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java +++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java @@ -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; diff --git a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java index a58e10b5..28669a21 100644 --- a/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java +++ b/framework/src/onos/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java @@ -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; diff --git a/framework/src/onos/incubator/net/pom.xml b/framework/src/onos/incubator/net/pom.xml index a0b5391d..e60a2710 100644 --- a/framework/src/onos/incubator/net/pom.xml +++ b/framework/src/onos/incubator/net/pom.xml @@ -23,7 +23,7 @@ org.onosproject onos-incubator - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml 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 index 00000000..abdce5a4 --- /dev/null +++ b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/package-info.java @@ -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 index 00000000..00f42ead --- /dev/null +++ b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/intf/package-info.java @@ -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 index 00000000..5559d90b --- /dev/null +++ b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/meter/impl/package-info.java @@ -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; diff --git a/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java index 56167c48..8ecf1d29 100644 --- a/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java +++ b/framework/src/onos/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java @@ -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 index 00000000..cc2908bc --- /dev/null +++ b/framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/intf/impl/InterfaceManagerTest.java @@ -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 CONFIG_CLASS = InterfaceConfig.class; + + private static final int NUM_INTERFACES = 4; + + private Set subjects = Sets.newHashSet(); + private Map configs = Maps.newHashMap(); + + private Set 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 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 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 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 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 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 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 subjects; + private final Map configs; + + public TestNetworkConfigService(Set subjects, + Map configs) { + this.subjects = subjects; + this.configs = configs; + } + + @Override + public > Set getSubjects(Class subjectClass, + Class configClass) { + return (Set) subjects; + } + + @Override + public > C getConfig(S subject, Class 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 interfaces; + + @Override + public ConnectPoint subject() { + return subject; + } + + public TestInterfaceConfig(ConnectPoint subject, Set interfaces) { + this.subject = subject; + this.interfaces = interfaces; + } + + @Override + public Set getInterfaces() throws ConfigException { + return interfaces; + } + } + +} diff --git a/framework/src/onos/incubator/pom.xml b/framework/src/onos/incubator/pom.xml index 6e6c229d..c94243d2 100644 --- a/framework/src/onos/incubator/pom.xml +++ b/framework/src/onos/incubator/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/incubator/store/pom.xml b/framework/src/onos/incubator/store/pom.xml index 54575582..797ccc0b 100644 --- a/framework/src/onos/incubator/store/pom.xml +++ b/framework/src/onos/incubator/store/pom.xml @@ -23,7 +23,7 @@ org.onosproject onos-incubator - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml 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 index 00000000..c1992f07 --- /dev/null +++ b/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/package-info.java @@ -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; diff --git a/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java b/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java index a014504c..d129def7 100644 --- a/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java +++ b/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java @@ -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; diff --git a/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/LabelResourceMessageSubjects.java b/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/LabelResourceMessageSubjects.java index 0a6f1640..1b2f6515 100644 --- a/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/LabelResourceMessageSubjects.java +++ b/framework/src/onos/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/LabelResourceMessageSubjects.java @@ -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; diff --git a/framework/src/onos/openflow/api/pom.xml b/framework/src/onos/openflow/api/pom.xml index 2fc4f509..e535ac64 100644 --- a/framework/src/onos/openflow/api/pom.xml +++ b/framework/src/onos/openflow/api/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-of - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java index 271e1830..af678d63 100644 --- a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java +++ b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java @@ -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; /** diff --git a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java index b5d4743d..3a0f1a0d 100644 --- a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java +++ b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java @@ -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; /** diff --git a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java index 8108afe9..59ef33cf 100644 --- a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java +++ b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java @@ -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; diff --git a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java index b78124b8..8b82b4a7 100644 --- a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java +++ b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java @@ -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; diff --git a/framework/src/onos/openflow/ctl/pom.xml b/framework/src/onos/openflow/ctl/pom.xml index 683a09af..56d48550 100644 --- a/framework/src/onos/openflow/ctl/pom.xml +++ b/framework/src/onos/openflow/ctl/pom.xml @@ -21,7 +21,7 @@ org.onosproject onos-of - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/openflow/pom.xml b/framework/src/onos/openflow/pom.xml index deed497f..437f7437 100644 --- a/framework/src/onos/openflow/pom.xml +++ b/framework/src/onos/openflow/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/ovsdb/api/pom.xml b/framework/src/onos/ovsdb/api/pom.xml index c1808794..7089216f 100644 --- a/framework/src/onos/ovsdb/api/pom.xml +++ b/framework/src/onos/ovsdb/api/pom.xml @@ -21,7 +21,7 @@ org.onosproject onos-ovsdb - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT onos-ovsdb-api bundle diff --git a/framework/src/onos/ovsdb/ctl/pom.xml b/framework/src/onos/ovsdb/ctl/pom.xml index 60c1b439..b8366296 100644 --- a/framework/src/onos/ovsdb/ctl/pom.xml +++ b/framework/src/onos/ovsdb/ctl/pom.xml @@ -21,7 +21,7 @@ org.onosproject onos-ovsdb - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/ovsdb/pom.xml b/framework/src/onos/ovsdb/pom.xml index e7a7ffcc..930978a4 100644 --- a/framework/src/onos/ovsdb/pom.xml +++ b/framework/src/onos/ovsdb/pom.xml @@ -21,7 +21,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT onos-ovsdb onos-ovsdb diff --git a/framework/src/onos/ovsdb/rfc/pom.xml b/framework/src/onos/ovsdb/rfc/pom.xml index 856ddf07..2868845a 100644 --- a/framework/src/onos/ovsdb/rfc/pom.xml +++ b/framework/src/onos/ovsdb/rfc/pom.xml @@ -1,19 +1,26 @@ - + 4.0.0 org.onosproject onos-ovsdb - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml onos-ovsdb-rfc 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 index 00000000..274c8d43 --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/package-info.java @@ -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 index 00000000..7edf5b46 --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/package-info.java @@ -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 index 00000000..1b301262 --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/package-info.java @@ -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 index 00000000..eb2e7c66 --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/package-info.java @@ -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 index 00000000..1900dfef --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/package-info.java @@ -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 index 00000000..77fb9f3c --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/package-info.java @@ -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 index 00000000..9a27037c --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/package-info.java @@ -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 index 00000000..eade2e28 --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/package-info.java @@ -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; diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java index 73d7ca1e..9d20b982 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java @@ -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/Port.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Port.java index 996e93ff..1e1ab7d7 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Port.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Port.java @@ -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 index 00000000..e235b168 --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/package-info.java @@ -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 index 00000000..cc607da7 --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/package-info.java @@ -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; diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java index 00e7dbe8..9ec62d31 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java @@ -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 index 00000000..0a0a4f78 --- /dev/null +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/package-info.java @@ -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; diff --git a/framework/src/onos/pcep/api/pom.xml b/framework/src/onos/pcep/api/pom.xml index 2926cbea..4588ad6f 100644 --- a/framework/src/onos/pcep/api/pom.xml +++ b/framework/src/onos/pcep/api/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-pcep-controller - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/pcep/ctl/pom.xml b/framework/src/onos/pcep/ctl/pom.xml index 0a872ded..f0ed5c2f 100644 --- a/framework/src/onos/pcep/ctl/pom.xml +++ b/framework/src/onos/pcep/ctl/pom.xml @@ -21,7 +21,7 @@ org.onosproject onos-pcep-controller - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/pcep/pcepio/pom.xml b/framework/src/onos/pcep/pcepio/pom.xml index ef25d402..d121a83e 100755 --- a/framework/src/onos/pcep/pcepio/pom.xml +++ b/framework/src/onos/pcep/pcepio/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-pcep-controller - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java index e8801c24..927d83d6 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java index dc8c828d..48a337f4 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java index 37bae237..49c738fc 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java index 5730026f..40f89f4c 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java index 34fad299..3e8f9676 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java index 7c2f1343..b8ae1e87 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java index c2b91bc2..7a612454 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java index 268ac4ce..e2ad069c 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java index 1faf01a7..4e8926cf 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java index 0de5543e..4da1ec6d 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java @@ -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; diff --git a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java index 60ff8848..c39f606b 100644 --- a/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java +++ b/framework/src/onos/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java @@ -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; diff --git a/framework/src/onos/pcep/pom.xml b/framework/src/onos/pcep/pom.xml index e3d470b7..f0b9f8c3 100755 --- a/framework/src/onos/pcep/pom.xml +++ b/framework/src/onos/pcep/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/pom.xml b/framework/src/onos/pom.xml index d16919b5..1bce8cdb 100644 --- a/framework/src/onos/pom.xml +++ b/framework/src/onos/pom.xml @@ -33,7 +33,7 @@ org.onosproject onos pom - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ${project.artifactId} Open Network Operating System root project diff --git a/framework/src/onos/providers/host/pom.xml b/framework/src/onos/providers/host/pom.xml index d5231f8d..e8f32ca1 100644 --- a/framework/src/onos/providers/host/pom.xml +++ b/framework/src/onos/providers/host/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java b/framework/src/onos/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java index b9d90976..d010f178 100644 --- a/framework/src/onos/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java +++ b/framework/src/onos/providers/host/src/test/java/org/onosproject/provider/host/impl/HostLocationProviderTest.java @@ -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; diff --git a/framework/src/onos/providers/lldp/pom.xml b/framework/src/onos/providers/lldp/pom.xml index bc13793e..e47d26c7 100644 --- a/framework/src/onos/providers/lldp/pom.xml +++ b/framework/src/onos/providers/lldp/pom.xml @@ -23,7 +23,7 @@ org.onosproject onos-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml 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 index 00000000..0cd19242 --- /dev/null +++ b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/DiscoveryContext.java @@ -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); +} diff --git a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java index e9e2bfad..386d838f 100644 --- a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java +++ b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LLDPLinkProvider.java @@ -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 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 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()); + } + } + } diff --git a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java index a81eeb1d..8cdfd50f 100644 --- a/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java +++ b/framework/src/onos/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LinkDiscovery.java @@ -15,44 +15,34 @@ */ 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 slowPorts = Sets.newConcurrentHashSet(); - // ports, known to have incoming links - private final Set fastPorts = Sets.newConcurrentHashSet(); - - // number of unacknowledged probes per port - private final Map 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 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 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); } } diff --git a/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java b/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java index 1d63a15d..b4b7b7b6 100644 --- a/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java +++ b/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/LLDPLinkProviderTest.java @@ -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 { + } } diff --git a/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/SuppressionRulesTest.java b/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/SuppressionRulesTest.java index 52f0bb1e..03d431af 100644 --- a/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/SuppressionRulesTest.java +++ b/framework/src/onos/providers/lldp/src/test/java/org/onosproject/provider/lldp/impl/SuppressionRulesTest.java @@ -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.*; diff --git a/framework/src/onos/providers/netconf/app/features.xml b/framework/src/onos/providers/netconf/app/features.xml index 6a3d1a2c..bc7491e6 100644 --- a/framework/src/onos/providers/netconf/app/features.xml +++ b/framework/src/onos/providers/netconf/app/features.xml @@ -1,17 +1,17 @@ diff --git a/framework/src/onos/providers/netconf/app/pom.xml b/framework/src/onos/providers/netconf/app/pom.xml index 8cf56b3f..dbd0a520 100644 --- a/framework/src/onos/providers/netconf/app/pom.xml +++ b/framework/src/onos/providers/netconf/app/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-netconf-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/netconf/device/pom.xml b/framework/src/onos/providers/netconf/device/pom.xml index be05e3cd..3465bc3a 100644 --- a/framework/src/onos/providers/netconf/device/pom.xml +++ b/framework/src/onos/providers/netconf/device/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-netconf-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/netconf/flow/pom.xml b/framework/src/onos/providers/netconf/flow/pom.xml index 8ee4c4e4..7ccd552f 100644 --- a/framework/src/onos/providers/netconf/flow/pom.xml +++ b/framework/src/onos/providers/netconf/flow/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-netconf-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/netconf/pom.xml b/framework/src/onos/providers/netconf/pom.xml index ac08dd4a..f73940fe 100644 --- a/framework/src/onos/providers/netconf/pom.xml +++ b/framework/src/onos/providers/netconf/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/null/pom.xml b/framework/src/onos/providers/null/pom.xml index ce547588..1db0753f 100644 --- a/framework/src/onos/providers/null/pom.xml +++ b/framework/src/onos/providers/null/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/openflow/app/features.xml b/framework/src/onos/providers/openflow/app/features.xml index 7c410172..9dbae8af 100644 --- a/framework/src/onos/providers/openflow/app/features.xml +++ b/framework/src/onos/providers/openflow/app/features.xml @@ -1,17 +1,17 @@ diff --git a/framework/src/onos/providers/openflow/app/pom.xml b/framework/src/onos/providers/openflow/app/pom.xml index 62e5eb87..cb55463b 100644 --- a/framework/src/onos/providers/openflow/app/pom.xml +++ b/framework/src/onos/providers/openflow/app/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-of-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/openflow/device/pom.xml b/framework/src/onos/providers/openflow/device/pom.xml index 5f27d42b..0408f73e 100644 --- a/framework/src/onos/providers/openflow/device/pom.xml +++ b/framework/src/onos/providers/openflow/device/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-of-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/openflow/flow/pom.xml b/framework/src/onos/providers/openflow/flow/pom.xml index 24c430e3..1f65656e 100644 --- a/framework/src/onos/providers/openflow/flow/pom.xml +++ b/framework/src/onos/providers/openflow/flow/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-of-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/openflow/group/pom.xml b/framework/src/onos/providers/openflow/group/pom.xml index 97ac5ffe..049ccaff 100644 --- a/framework/src/onos/providers/openflow/group/pom.xml +++ b/framework/src/onos/providers/openflow/group/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-of-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/openflow/group/src/test/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProviderTest.java b/framework/src/onos/providers/openflow/group/src/test/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProviderTest.java index d66ba090..f923c6f8 100644 --- a/framework/src/onos/providers/openflow/group/src/test/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProviderTest.java +++ b/framework/src/onos/providers/openflow/group/src/test/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProviderTest.java @@ -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; diff --git a/framework/src/onos/providers/openflow/meter/pom.xml b/framework/src/onos/providers/openflow/meter/pom.xml index 9de5c1b0..55068cd7 100644 --- a/framework/src/onos/providers/openflow/meter/pom.xml +++ b/framework/src/onos/providers/openflow/meter/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-of-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/openflow/packet/pom.xml b/framework/src/onos/providers/openflow/packet/pom.xml index f7f62d8e..cc2316c9 100644 --- a/framework/src/onos/providers/openflow/packet/pom.xml +++ b/framework/src/onos/providers/openflow/packet/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-of-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/openflow/pom.xml b/framework/src/onos/providers/openflow/pom.xml index 99ff6649..c098a609 100644 --- a/framework/src/onos/providers/openflow/pom.xml +++ b/framework/src/onos/providers/openflow/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/ovsdb/app/pom.xml b/framework/src/onos/providers/ovsdb/app/pom.xml index 7bb506ba..b615d124 100644 --- a/framework/src/onos/providers/ovsdb/app/pom.xml +++ b/framework/src/onos/providers/ovsdb/app/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-ovsdb-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/ovsdb/device/pom.xml b/framework/src/onos/providers/ovsdb/device/pom.xml index e5010fa6..8f9b834b 100644 --- a/framework/src/onos/providers/ovsdb/device/pom.xml +++ b/framework/src/onos/providers/ovsdb/device/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-ovsdb-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT onos-ovsdb-provider-device diff --git a/framework/src/onos/providers/ovsdb/host/pom.xml b/framework/src/onos/providers/ovsdb/host/pom.xml index 0bd88555..f54a496b 100644 --- a/framework/src/onos/providers/ovsdb/host/pom.xml +++ b/framework/src/onos/providers/ovsdb/host/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-ovsdb-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT onos-ovsdb-provider-host diff --git a/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java b/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java index 8d2fd142..0e3e1564 100644 --- a/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java +++ b/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java @@ -1,148 +1,148 @@ -/* - * 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 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; - } - } -} +/* + * 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 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; + } + } +} diff --git a/framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java b/framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java index bf18606c..ad720c85 100644 --- a/framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java +++ b/framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java @@ -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; diff --git a/framework/src/onos/providers/ovsdb/pom.xml b/framework/src/onos/providers/ovsdb/pom.xml index bf215bc0..cce971d5 100644 --- a/framework/src/onos/providers/ovsdb/pom.xml +++ b/framework/src/onos/providers/ovsdb/pom.xml @@ -1,4 +1,19 @@ + @@ -7,7 +22,7 @@ org.onosproject onos-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT onos-ovsdb-providers diff --git a/framework/src/onos/providers/ovsdb/tunnel/pom.xml b/framework/src/onos/providers/ovsdb/tunnel/pom.xml index 46ea585b..3eae2588 100644 --- a/framework/src/onos/providers/ovsdb/tunnel/pom.xml +++ b/framework/src/onos/providers/ovsdb/tunnel/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-ovsdb-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT onos-ovsdb-provider-tunnel diff --git a/framework/src/onos/providers/pcep/app/features.xml b/framework/src/onos/providers/pcep/app/features.xml index 65a221bb..ee205365 100644 --- a/framework/src/onos/providers/pcep/app/features.xml +++ b/framework/src/onos/providers/pcep/app/features.xml @@ -1,17 +1,17 @@ diff --git a/framework/src/onos/providers/pcep/app/pom.xml b/framework/src/onos/providers/pcep/app/pom.xml index bce88d99..96a04e88 100644 --- a/framework/src/onos/providers/pcep/app/pom.xml +++ b/framework/src/onos/providers/pcep/app/pom.xml @@ -1,10 +1,25 @@ + 4.0.0 org.onosproject onos-pcep-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/providers/pcep/pom.xml b/framework/src/onos/providers/pcep/pom.xml index 66a71141..0f885e67 100644 --- a/framework/src/onos/providers/pcep/pom.xml +++ b/framework/src/onos/providers/pcep/pom.xml @@ -1,9 +1,24 @@ + 4.0.0 org.onosproject onos-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml onos-pcep-providers diff --git a/framework/src/onos/providers/pcep/topology/pom.xml b/framework/src/onos/providers/pcep/topology/pom.xml index cd8589b9..ff14b653 100644 --- a/framework/src/onos/providers/pcep/topology/pom.xml +++ b/framework/src/onos/providers/pcep/topology/pom.xml @@ -1,9 +1,24 @@ + 4.0.0 org.onosproject onos-pcep-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml onos-pcep-provider-topology diff --git a/framework/src/onos/providers/pcep/tunnel/pom.xml b/framework/src/onos/providers/pcep/tunnel/pom.xml index 09efb8ae..2613c41c 100644 --- a/framework/src/onos/providers/pcep/tunnel/pom.xml +++ b/framework/src/onos/providers/pcep/tunnel/pom.xml @@ -1,10 +1,25 @@ + 4.0.0 org.onosproject onos-pcep-providers - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml onos-pcep-provider-tunnel diff --git a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java index 39249c5c..cab2bf4c 100644 --- a/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java +++ b/framework/src/onos/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java @@ -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; diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java index 49e29514..5b010f51 100644 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java +++ b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java @@ -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; diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java index 74aa590c..2d2aaafe 100644 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java +++ b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java @@ -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; diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java index 7292d0b1..0de914c5 100644 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java +++ b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java @@ -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; diff --git a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelServiceAdapter.java b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelServiceAdapter.java index 1dd77332..0603cb3d 100644 --- a/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelServiceAdapter.java +++ b/framework/src/onos/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelServiceAdapter.java @@ -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; diff --git a/framework/src/onos/providers/pom.xml b/framework/src/onos/providers/pom.xml index 87dd5656..a02f8d4f 100644 --- a/framework/src/onos/providers/pom.xml +++ b/framework/src/onos/providers/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/tools/build/envDefaults b/framework/src/onos/tools/build/envDefaults index 57c1f677..34fcccb2 100644 --- a/framework/src/onos/tools/build/envDefaults +++ b/framework/src/onos/tools/build/envDefaults @@ -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%~*} diff --git a/framework/src/onos/tools/build/onos-package b/framework/src/onos/tools/build/onos-package index 8f6127da..32794457 100755 --- a/framework/src/onos/tools/build/onos-package +++ b/framework/src/onos/tools/build/onos-package @@ -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 diff --git a/framework/src/onos/tools/build/onosUploadBits.py b/framework/src/onos/tools/build/onosUploadBits.py index b86f45d0..dc2f0a4a 100755 --- a/framework/src/onos/tools/build/onosUploadBits.py +++ b/framework/src/onos/tools/build/onosUploadBits.py @@ -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 ): diff --git a/framework/src/onos/tools/package/archetypes/api/pom.xml b/framework/src/onos/tools/package/archetypes/api/pom.xml index d34db1f0..8deaada9 100644 --- a/framework/src/onos/tools/package/archetypes/api/pom.xml +++ b/framework/src/onos/tools/package/archetypes/api/pom.xml @@ -20,7 +20,7 @@ org.onosproject onos-archetypes - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT onos-api-archetype diff --git a/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml index f29a327a..a0e54f3f 100644 --- a/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml +++ b/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml @@ -26,7 +26,7 @@ http://onosproject.org - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT diff --git a/framework/src/onos/tools/package/archetypes/bundle/pom.xml b/framework/src/onos/tools/package/archetypes/bundle/pom.xml index ff6aa52e..65b55b2b 100644 --- a/framework/src/onos/tools/package/archetypes/bundle/pom.xml +++ b/framework/src/onos/tools/package/archetypes/bundle/pom.xml @@ -20,7 +20,7 @@ org.onosproject onos-archetypes - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT onos-bundle-archetype diff --git a/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml index c9e747c9..222e8b03 100644 --- a/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml +++ b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml @@ -26,7 +26,7 @@ http://onosproject.org - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT + exec="onos-mininet sendAndExpect py net.pingAll(1) --expect received"/> @@ -34,4 +34,4 @@ - \ No newline at end of file + diff --git a/framework/src/onos/tools/test/scenarios/net-rest.xml b/framework/src/onos/tools/test/scenarios/net-rest.xml index fc7b1d08..ab7804df 100644 --- a/framework/src/onos/tools/test/scenarios/net-rest.xml +++ b/framework/src/onos/tools/test/scenarios/net-rest.xml @@ -101,10 +101,10 @@ + exec="curl-with-retry ${xyLocation}"/> + exec="curl-with-retry ${yxLocation}"/> + exec="test ${dev4outFlowPort} -ge 1 -a ${dev4outFlowPort} -le 5"/> + - - - + exec="curl-with-retry ${xyLocation}" env="!"/> + exec="curl-with-retry ${yxLocation}" env="!"/> diff --git a/framework/src/onos/tools/test/scenarios/net-setup.xml b/framework/src/onos/tools/test/scenarios/net-setup.xml index e179ec5a..13252d0f 100644 --- a/framework/src/onos/tools/test/scenarios/net-setup.xml +++ b/framework/src/onos/tools/test/scenarios/net-setup.xml @@ -17,9 +17,9 @@ - - + + @@ -43,4 +43,4 @@ - \ No newline at end of file + diff --git a/framework/src/onos/tools/test/scenarios/net-smoke.xml b/framework/src/onos/tools/test/scenarios/net-smoke.xml index 53a5729c..91131c62 100644 --- a/framework/src/onos/tools/test/scenarios/net-smoke.xml +++ b/framework/src/onos/tools/test/scenarios/net-smoke.xml @@ -35,10 +35,14 @@ + + + + ~Net-Create-Flows, + ~Net-topo"/> 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 index 00000000..e8e23997 --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/net-topo.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/src/onos/tools/test/scenarios/prerequisites.xml b/framework/src/onos/tools/test/scenarios/prerequisites.xml index 650aa411..2c541d5b 100644 --- a/framework/src/onos/tools/test/scenarios/prerequisites.xml +++ b/framework/src/onos/tools/test/scenarios/prerequisites.xml @@ -15,7 +15,7 @@ --> - + diff --git a/framework/src/onos/tools/test/topos/onos.py b/framework/src/onos/tools/test/topos/onos.py index 3e5bff7c..ae6045e3 100755 --- a/framework/src/onos/tools/test/topos/onos.py +++ b/framework/src/onos/tools/test/topos/onos.py @@ -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() ) diff --git a/framework/src/onos/tools/test/topos/opticalUtils.py b/framework/src/onos/tools/test/topos/opticalUtils.py index bef9deca..a1ae834b 100644 --- a/framework/src/onos/tools/test/topos/opticalUtils.py +++ b/framework/src/onos/tools/test/topos/opticalUtils.py @@ -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 = []; diff --git a/framework/src/onos/utils/jdvue/bin/jdvue b/framework/src/onos/utils/jdvue/bin/jdvue index 86adfb4f..3dda5969 100755 --- a/framework/src/onos/utils/jdvue/bin/jdvue +++ b/framework/src/onos/utils/jdvue/bin/jdvue @@ -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 diff --git a/framework/src/onos/utils/jdvue/pom.xml b/framework/src/onos/utils/jdvue/pom.xml index 3399a8ab..d1501027 100644 --- a/framework/src/onos/utils/jdvue/pom.xml +++ b/framework/src/onos/utils/jdvue/pom.xml @@ -1,5 +1,21 @@ - + 4.0.0 @@ -9,7 +25,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml @@ -70,8 +86,10 @@ 2.3 - - org.onlab.jdvue.DependencyViewer + + org.onlab.jdvue.DependencyViewer + diff --git a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Catalog.java b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Catalog.java index 8f611c52..40cb99a3 100644 --- a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Catalog.java +++ b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Catalog.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Dependency.java b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Dependency.java index 7fc3409a..21fae479 100644 --- a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Dependency.java +++ b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/Dependency.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java index 65e3cfbc..444995bf 100644 --- a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java +++ b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyViewer.java b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyViewer.java index a210d717..32e9ef1c 100644 --- a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyViewer.java +++ b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyViewer.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaEntity.java b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaEntity.java index 31959307..e74bdc60 100644 --- a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaEntity.java +++ b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaEntity.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaPackage.java b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaPackage.java index 7bf4be16..a15cb4d3 100644 --- a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaPackage.java +++ b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaPackage.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaSource.java b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaSource.java index 8919a13e..1376cfee 100644 --- a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaSource.java +++ b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/JavaSource.java @@ -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.*; diff --git a/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/CatalogTest.java b/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/CatalogTest.java index 99d22087..b792abcc 100644 --- a/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/CatalogTest.java +++ b/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/CatalogTest.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyCycleTest.java b/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyCycleTest.java index a0a7c7cb..895c713f 100644 --- a/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyCycleTest.java +++ b/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyCycleTest.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyTest.java b/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyTest.java index 4dfe9615..94740dae 100644 --- a/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyTest.java +++ b/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyTest.java @@ -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; diff --git a/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyViewerTest.java b/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyViewerTest.java index cdac0c24..0937c068 100644 --- a/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyViewerTest.java +++ b/framework/src/onos/utils/jdvue/src/test/java/org/onlab/jdvue/DependencyViewerTest.java @@ -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; diff --git a/framework/src/onos/utils/jnc/pom.xml b/framework/src/onos/utils/jnc/pom.xml index a70bfbe7..6d0f8343 100644 --- a/framework/src/onos/utils/jnc/pom.xml +++ b/framework/src/onos/utils/jnc/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/junit/pom.xml b/framework/src/onos/utils/junit/pom.xml index 90178346..c9787a41 100644 --- a/framework/src/onos/utils/junit/pom.xml +++ b/framework/src/onos/utils/junit/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/misc/pom.xml b/framework/src/onos/utils/misc/pom.xml index 17951215..2e721135 100644 --- a/framework/src/onos/utils/misc/pom.xml +++ b/framework/src/onos/utils/misc/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAOrganism.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAOrganism.java index 230609f8..a0e0570d 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAOrganism.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAOrganism.java @@ -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; /** diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAPopulation.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAPopulation.java index ae7f182e..c5fa9b45 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAPopulation.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/GAPopulation.java @@ -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; diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IPv4.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IPv4.java index d75b50a2..a5c5f4f1 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IPv4.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IPv4.java @@ -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> 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; diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MPLS.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MPLS.java index 47dbeed2..71c5803e 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MPLS.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MPLS.java @@ -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 index 00000000..d9a5e83f --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java @@ -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> 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 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 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 index 00000000..891a0193 --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java @@ -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 index 00000000..2d4a7816 --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java @@ -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 index 00000000..0c2d676b --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java @@ -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 index 00000000..9ad3fdbd --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHello.java @@ -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 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 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 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 index 00000000..bf021fbd --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMHelloOption.java @@ -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 index 00000000..9653115b --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMJoinPrune.java @@ -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 joins = new HashMap<>(); + protected HashMap prunes = new HashMap<>(); + + public JoinPruneGroup(IpPrefix grp) { + group = grp; + } + } + private HashMap 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 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 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 index 00000000..88a1ad5d --- /dev/null +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/package-info.java @@ -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 index 00000000..7fba3cd7 --- /dev/null +++ b/framework/src/onos/utils/misc/src/test/java/org/onlab/packet/PIMTest.java @@ -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 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 diff --git a/framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java b/framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java index 27652123..e04e29a2 100644 --- a/framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java +++ b/framework/src/onos/utils/misc/src/test/java/org/onlab/util/HexStringTest.java @@ -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 { diff --git a/framework/src/onos/utils/netty/pom.xml b/framework/src/onos/utils/netty/pom.xml index fa320d52..5ce4838b 100644 --- a/framework/src/onos/utils/netty/pom.xml +++ b/framework/src/onos/utils/netty/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/nio/pom.xml b/framework/src/onos/utils/nio/pom.xml index b9e4d447..83957669 100644 --- a/framework/src/onos/utils/nio/pom.xml +++ b/framework/src/onos/utils/nio/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/osgi/pom.xml b/framework/src/onos/utils/osgi/pom.xml index 7be6c69d..cf79312d 100644 --- a/framework/src/onos/utils/osgi/pom.xml +++ b/framework/src/onos/utils/osgi/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/pom.xml b/framework/src/onos/utils/pom.xml index 2adbba70..c2fa5dc6 100644 --- a/framework/src/onos/utils/pom.xml +++ b/framework/src/onos/utils/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/rest/pom.xml b/framework/src/onos/utils/rest/pom.xml index ce2bd845..c9a7df75 100644 --- a/framework/src/onos/utils/rest/pom.xml +++ b/framework/src/onos/utils/rest/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/stc/bin/stc b/framework/src/onos/utils/stc/bin/stc index 23affc4a..241822c5 100755 --- a/framework/src/onos/utils/stc/bin/stc +++ b/framework/src/onos/utils/stc/bin/stc @@ -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 diff --git a/framework/src/onos/utils/stc/pom.xml b/framework/src/onos/utils/stc/pom.xml index a3f96430..a71dcfe3 100644 --- a/framework/src/onos/utils/stc/pom.xml +++ b/framework/src/onos/utils/stc/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java index 8e3aad5b..ef1c31f3 100644 --- a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java +++ b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java @@ -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. * diff --git a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java index 09b89456..bc10ec7a 100644 --- a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java +++ b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java @@ -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 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 diff --git a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/ScenarioStore.java b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/ScenarioStore.java index d37222b1..7313462e 100644 --- a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/ScenarioStore.java +++ b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/ScenarioStore.java @@ -43,6 +43,9 @@ class ScenarioStore { private final List events = Lists.newArrayList(); private final Map 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(); + } } diff --git a/framework/src/onos/utils/thirdparty/pom.xml b/framework/src/onos/utils/thirdparty/pom.xml index f5c81677..bb5e3e06 100644 --- a/framework/src/onos/utils/thirdparty/pom.xml +++ b/framework/src/onos/utils/thirdparty/pom.xml @@ -22,7 +22,7 @@ org.onosproject onlab-utils - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/web/api/pom.xml b/framework/src/onos/web/api/pom.xml index b4201865..99aeab22 100644 --- a/framework/src/onos/web/api/pom.xml +++ b/framework/src/onos/web/api/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-web - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/web/gui/pom.xml b/framework/src/onos/web/gui/pom.xml index 4ce7e93f..6b8480ad 100644 --- a/framework/src/onos/web/gui/pom.xml +++ b/framework/src/onos/web/gui/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos-web - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml diff --git a/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TunnelViewMessageHandler.java b/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TunnelViewMessageHandler.java index 13ce9398..16848188 100644 --- a/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TunnelViewMessageHandler.java +++ b/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TunnelViewMessageHandler.java @@ -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 index 00000000..07f4802a --- /dev/null +++ b/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/topo/package-info.java @@ -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; diff --git a/framework/src/onos/web/pom.xml b/framework/src/onos/web/pom.xml index 46f42322..d7b6fe05 100644 --- a/framework/src/onos/web/pom.xml +++ b/framework/src/onos/web/pom.xml @@ -22,7 +22,7 @@ org.onosproject onos - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT ../pom.xml -- cgit 1.2.3-korg
No mappings found @@ -34,8 +34,8 @@
{{dhcp.mac}}{{dhcp.host}} {{dhcp.ip}} {{dhcp.lease}}