aboutsummaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-10-19 10:14:31 -0700
committerAshlee Young <ashlee@onosfw.com>2015-10-19 10:14:31 -0700
commite9bb60be43af477f17b30ee1f2ba205565b7fa15 (patch)
tree981fd759a44b751fc45cde774f46fda37c11c257 /framework
parent74f3941756a1386cbc1fa99ee73fdc8376a0b6a0 (diff)
Updated onos src tree to commit id 1e60f97ae50c05b94fcb6a10520738bfb5efdfd1
Diffstat (limited to 'framework')
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclRule.java302
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclService.java53
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclStore.java132
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclWebResource.java216
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/RuleId.java85
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/AclManager.java337
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java251
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java20
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java1
-rw-r--r--framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/AclWebResourceTest.java133
-rw-r--r--framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/ResourceTest.java58
-rw-r--r--framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/TestServiceDirectory.java51
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java49
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java76
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java166
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java25
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java21
-rw-r--r--framework/src/onos/apps/config/src/main/resources/addresses.json36
-rw-r--r--framework/src/onos/apps/cordvtn/pom.xml5
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java194
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java13
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java46
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java32
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java20
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java165
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java13
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java1
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpStoreConfig.java107
-rw-r--r--framework/src/onos/apps/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java2
-rw-r--r--framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java6
-rw-r--r--framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java4
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java27
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java22
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java15
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java32
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java25
-rw-r--r--framework/src/onos/apps/mlb/pom.xml45
-rw-r--r--framework/src/onos/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java165
-rw-r--r--framework/src/onos/apps/pom.xml1
-rw-r--r--framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java94
-rw-r--r--framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptorTest.java210
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpService.java31
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java19
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java22
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/NetworkConfigHandler.java157
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java56
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java351
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java215
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java338
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java271
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java159
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java445
-rw-r--r--framework/src/onos/apps/vtn/features.xml27
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/VTNService.java68
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java665
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java8
-rw-r--r--framework/src/onos/apps/vtnrsc/pom.xml71
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java94
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java72
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java81
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java79
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java183
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java160
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java229
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java93
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java78
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java77
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java77
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java129
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java76
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java77
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java130
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java76
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java156
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java70
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java97
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java60
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java45
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java99
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetCreateCommand.java118
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java61
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java46
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java118
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortCreateCommand.java134
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java94
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java45
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java135
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java72
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java183
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java80
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java167
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java72
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java100
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java222
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java40
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java40
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java40
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java40
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java39
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java53
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java47
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java57
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/resources/OSGI-INF/blueprint/shell-config.xml56
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/webapp/WEB-INF/web.xml45
-rw-r--r--framework/src/onos/apps/vtnweb/pom.xml88
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java365
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java371
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java410
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/webapp/WEB-INF/web.xml45
-rwxr-xr-xframework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java28
-rwxr-xr-xframework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeer.java161
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsg.java10
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPLSNlri.java54
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPMessage.java21
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNodeLSNlri.java (renamed from framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java)14
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNotificationMsg.java87
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java40
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPPrefixLSNlri.java (renamed from framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java)27
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java44
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java (renamed from framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java)29
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSIdentifier.java113
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSNlriVer4.java212
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPPrefixIPv4LSNlriVer4.java205
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPKeepaliveMsgVer4.java15
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java266
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java136
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java114
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java160
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java62
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java124
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java124
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java119
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIGPFlags.java180
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java125
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java37
-rwxr-xr-xframework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPChannelHandler.java601
-rwxr-xr-xframework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPControllerImpl.java179
-rwxr-xr-xframework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPKeepAliveTimer.java72
-rwxr-xr-xframework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPacketStatsImpl.java12
-rwxr-xr-xframework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPeerImpl.java191
-rwxr-xr-xframework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPSessionInfo.java149
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddressBindingsListCommand.java69
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/OduSignalId.java139
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java1
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java22
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java82
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java81
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OpticalSignalTypeCriterion.java83
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java6
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java13
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java88
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/host/HostProviderService.java5
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/host/PortAddresses.java127
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java85
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java89
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java1
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java14
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java30
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java1
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/OduSignalIdTest.java39
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java91
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java41
-rw-r--r--framework/src/onos/core/api/src/test/java/org/onosproject/net/host/PortAddressesTest.java113
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java8
-rw-r--r--framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java25
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java3
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java4
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java6
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java104
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java2
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java43
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java225
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java2
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java9
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/RequestContext.java54
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkProvider.java1
-rw-r--r--framework/src/onos/netconf/api/pom.xml50
-rw-r--r--framework/src/onos/netconf/api/src/main/java/org/onosproject/netconf/Foo.java7
-rw-r--r--framework/src/onos/netconf/ctl/pom.xml (renamed from framework/src/onos/apps/config/pom.xml)28
-rw-r--r--framework/src/onos/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/Foo.java7
-rw-r--r--framework/src/onos/netconf/pom.xml77
-rw-r--r--framework/src/onos/netconf/rfc/pom.xml31
-rw-r--r--framework/src/onos/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/Foo.java7
-rw-r--r--framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java28
-rw-r--r--framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java92
-rw-r--r--framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java11
-rw-r--r--framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java2
-rw-r--r--framework/src/onos/pom.xml1
-rw-r--r--framework/src/onos/providers/netconf/app/pom.xml2
-rw-r--r--framework/src/onos/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java1
-rw-r--r--framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java1
-rw-r--r--framework/src/onos/tools/dev/bash_profile2
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css35
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html46
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js139
-rw-r--r--framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java12
-rw-r--r--framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovDemo.js6
-rw-r--r--framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovOverlay.js2
-rw-r--r--framework/src/onos/tools/package/config/samples/segmentrouting.conf78
-rw-r--r--framework/src/onos/tools/package/debian/onos.conf27
-rwxr-xr-xframework/src/onos/tools/test/bin/onos-secure-ssh8
-rw-r--r--framework/src/onos/tools/test/scenarios/fast.xml30
-rw-r--r--framework/src/onos/tools/test/scenarios/net-fast.xml29
-rw-r--r--framework/src/onos/tools/test/scenarios/net-pingall.xml2
-rw-r--r--framework/src/onos/tools/test/scenarios/net-smoke.xml4
-rw-r--r--framework/src/onos/tools/test/scenarios/net-topo.xml44
-rw-r--r--framework/src/onos/tools/test/scenarios/prerequisites.xml2
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IGMP.java2
-rw-r--r--framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java2
-rw-r--r--framework/src/onos/web/gui/src/main/webapp/app/fw/widget/button.js2
-rw-r--r--framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js1
-rw-r--r--framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoOverlay.js28
-rw-r--r--framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js17
231 files changed, 5312 insertions, 13056 deletions
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclRule.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclRule.java
deleted file mode 100644
index edfa9355..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclRule.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.Ip4Prefix;
-import org.onosproject.core.IdGenerator;
-
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- * ACL rule class.
- */
-public final class AclRule {
-
- private final RuleId id;
-
- private final Ip4Prefix srcIp;
- private final Ip4Prefix dstIp;
- private final byte ipProto;
- private final short dstTpPort;
- private final Action action;
-
- private static IdGenerator idGenerator;
-
- /**
- * Enum type for ACL rule's action.
- */
- public enum Action {
- DENY, ALLOW
- }
-
- /**
- * Constructor for serializer.
- */
- private AclRule() {
- this.id = null;
- this.srcIp = null;
- this.dstIp = null;
- this.ipProto = 0;
- this.dstTpPort = 0;
- this.action = null;
- }
-
- /**
- * Create a new ACL rule.
- *
- * @param srcIp source IP address
- * @param dstIp destination IP address
- * @param ipProto IP protocol
- * @param dstTpPort destination transport layer port
- * @param action ACL rule's action
- */
- private AclRule(Ip4Prefix srcIp,
- Ip4Prefix dstIp,
- byte ipProto,
- short dstTpPort,
- Action action) {
- checkState(idGenerator != null, "Id generator is not bound.");
- this.id = RuleId.valueOf(idGenerator.getNewId());
- this.srcIp = srcIp;
- this.dstIp = dstIp;
- this.ipProto = ipProto;
- this.dstTpPort = dstTpPort;
- this.action = action;
- }
-
- /**
- * Check if the first CIDR address is in (or the same as) the second CIDR address.
- */
- private boolean checkCIDRinCIDR(Ip4Prefix cidrAddr1, Ip4Prefix cidrAddr2) {
- if (cidrAddr2 == null) {
- return true;
- } else if (cidrAddr1 == null) {
- return false;
- }
- if (cidrAddr1.prefixLength() < cidrAddr2.prefixLength()) {
- return false;
- }
- int offset = 32 - cidrAddr2.prefixLength();
-
- int cidr1Prefix = cidrAddr1.address().toInt();
- int cidr2Prefix = cidrAddr2.address().toInt();
- cidr1Prefix = cidr1Prefix >> offset;
- cidr2Prefix = cidr2Prefix >> offset;
- cidr1Prefix = cidr1Prefix << offset;
- cidr2Prefix = cidr2Prefix << offset;
-
- return (cidr1Prefix == cidr2Prefix);
- }
-
- /**
- * Check if this ACL rule match the given ACL rule.
- * @param r ACL rule to check against
- * @return true if this ACL rule matches the given ACL ruleule.
- */
- public boolean checkMatch(AclRule r) {
- return (this.dstTpPort == r.dstTpPort || r.dstTpPort == 0)
- && (this.ipProto == r.ipProto || r.ipProto == 0)
- && (checkCIDRinCIDR(this.srcIp(), r.srcIp()))
- && (checkCIDRinCIDR(this.dstIp(), r.dstIp()));
- }
-
- /**
- * Returns a new ACL rule builder.
- *
- * @return ACL rule builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder of an ACL rule.
- */
- public static final class Builder {
-
- private Ip4Prefix srcIp = null;
- private Ip4Prefix dstIp = null;
- private byte ipProto = 0;
- private short dstTpPort = 0;
- private Action action = Action.DENY;
-
- private Builder() {
- // Hide constructor
- }
-
- /**
- * Sets the source IP address for the ACL rule that will be built.
- *
- * @param srcIp source IP address to use for built ACL rule
- * @return this builder
- */
- public Builder srcIp(String srcIp) {
- this.srcIp = Ip4Prefix.valueOf(srcIp);
- return this;
- }
-
- /**
- * Sets the destination IP address for the ACL rule that will be built.
- *
- * @param dstIp destination IP address to use for built ACL rule
- * @return this builder
- */
- public Builder dstIp(String dstIp) {
- this.dstIp = Ip4Prefix.valueOf(dstIp);
- return this;
- }
-
- /**
- * Sets the IP protocol for the ACL rule that will be built.
- *
- * @param ipProto IP protocol to use for built ACL rule
- * @return this builder
- */
- public Builder ipProto(byte ipProto) {
- this.ipProto = ipProto;
- return this;
- }
-
- /**
- * Sets the destination transport layer port for the ACL rule that will be built.
- *
- * @param dstTpPort destination transport layer port to use for built ACL rule
- * @return this builder
- */
- public Builder dstTpPort(short dstTpPort) {
- if ((ipProto == IPv4.PROTOCOL_TCP || ipProto == IPv4.PROTOCOL_UDP)) {
- this.dstTpPort = dstTpPort;
- }
- return this;
- }
-
- /**
- * Sets the action for the ACL rule that will be built.
- *
- * @param action action to use for built ACL rule
- * @return this builder
- */
- public Builder action(Action action) {
- this.action = action;
- return this;
- }
-
- /**
- * Builds an ACL rule from the accumulated parameters.
- * @return ACL rule instance
- */
- public AclRule build() {
- checkState(srcIp != null && dstIp != null, "Either srcIp or dstIp must be assigned.");
- checkState(ipProto == 0 || ipProto == IPv4.PROTOCOL_ICMP
- || ipProto == IPv4.PROTOCOL_TCP || ipProto == IPv4.PROTOCOL_UDP,
- "ipProto must be assigned to TCP, UDP, or ICMP.");
- return new AclRule(
- srcIp,
- dstIp,
- ipProto,
- dstTpPort,
- action
- );
- }
-
- }
-
- /**
- * Binds an id generator for unique ACL rule id generation.
- *
- * Note: A generator cannot be bound if there is already a generator bound.
- *
- * @param newIdGenerator id generator
- */
- public static void bindIdGenerator(IdGenerator newIdGenerator) {
- checkState(idGenerator == null, "Id generator is already bound.");
- idGenerator = checkNotNull(newIdGenerator);
- }
-
- public RuleId id() {
- return id;
- }
-
- public Ip4Prefix srcIp() {
- return srcIp;
- }
-
- public Ip4Prefix dstIp() {
- return this.dstIp;
- }
-
- public byte ipProto() {
- return ipProto;
- }
-
- public short dstTpPort() {
- return dstTpPort;
- }
-
- public Action action() {
- return action;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(action,
- id.fingerprint(),
- ipProto,
- srcIp,
- dstIp,
- dstTpPort);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AclRule) {
- AclRule that = (AclRule) obj;
- return Objects.equals(id, that.id) &&
- Objects.equals(srcIp, that.srcIp) &&
- Objects.equals(dstIp, that.dstIp) &&
- Objects.equals(ipProto, that.ipProto) &&
- Objects.equals(dstTpPort, that.dstTpPort) &&
- Objects.equals(action, that.action);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .omitNullValues()
- .add("id", id)
- .add("srcIp", srcIp)
- .add("dstIp", dstIp)
- .add("ipProto", ipProto)
- .add("dstTpPort", dstTpPort)
- .add("action", action)
- .toString();
- }
-
-}
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclService.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclService.java
deleted file mode 100644
index afa561e4..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclService.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl;
-
-import java.util.List;
-
-/**
- * Service interface exported by ACL application.
- */
-public interface AclService {
-
- /**
- * Gets a list containing all ACL rules.
- * @return a list containing all ACL rules
- */
- List<AclRule> getAclRules();
-
- /**
- * Adds a new ACL rule.
- * @param rule ACL rule
- * @return true if successfully added, otherwise false
- */
- boolean addAclRule(AclRule rule);
-
- /**
- * Removes an exsiting ACL rule by rule id.
- * @param ruleId ACL rule identifier
- */
- void removeAclRule(RuleId ruleId);
-
- /**
- * Clears ACL and resets all.
- */
- void clearAcl();
-
-} \ No newline at end of file
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclStore.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclStore.java
deleted file mode 100644
index 88e49a73..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclStore.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.store.Store;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Service interface exported by ACL distributed store.
- */
-public interface AclStore extends Store {
-
- /**
- * Gets a list containing all ACL rules.
- * @return a list containing all ACL rules
- */
- List<AclRule> getAclRules();
-
- /**
- * Adds a new ACL rule.
- * @param rule new ACL rule
- */
- void addAclRule(AclRule rule);
-
- /**
- * Gets an existing ACL rule.
- * @param ruleId ACL rule id
- * @return ACL rule with the given id
- */
- AclRule getAclRule(RuleId ruleId);
-
- /**
- * Removes an existing ACL rule by rule id.
- * @param ruleId ACL rule id
- */
- void removeAclRule(RuleId ruleId);
-
- /**
- * Clears ACL and reset all.
- */
- void clearAcl();
-
- /**
- * Gets the current priority for new ACL flow rule by device id.
- * @param deviceId device id
- * @return new ACL flow rule's priority in the given device
- */
- int getPriorityByDevice(DeviceId deviceId);
-
- /**
- * Gets a set containing all ACL flow rules belonging to a given ACL rule.
- * @param ruleId ACL rule id
- * @return a set containing all ACL flow rules belonging to the given ACL rule
- */
- Set<FlowRule> getFlowByRule(RuleId ruleId);
-
- /**
- * Adds a new mapping from ACL rule to ACL flow rule.
- * @param ruleId ACL rule id
- * @param flowRule ACL flow rule
- */
- void addRuleToFlowMapping(RuleId ruleId, FlowRule flowRule);
-
- /**
- * Removes an existing mapping from ACL rule to ACL flow rule.
- * @param ruleId ACL rule id
- */
- void removeRuleToFlowMapping(RuleId ruleId);
-
- /**
- * Gets a list containing all allowing ACL rules matching a given denying ACL rule.
- * @param denyingRuleId denying ACL rule id
- * @return a list containing all allowing ACL rules matching the given denying ACL rule
- */
- List<RuleId> getAllowingRuleByDenyingRule(RuleId denyingRuleId);
-
- /**
- * Adds a new mapping from denying ACL rule to allowing ACL rule.
- * @param denyingRuleId denying ACL rule id
- * @param allowingRuleId allowing ACL rule id
- */
- void addDenyToAllowMapping(RuleId denyingRuleId, RuleId allowingRuleId);
-
- /**
- * Removes an exsiting mapping from denying ACL rule to allowing ACL rule.
- * @param denyingRuleId denying ACL rule id
- */
- void removeDenyToAllowMapping(RuleId denyingRuleId);
-
- /**
- * Checks if an existing ACL rule already works in a given device.
- * @param ruleId ACL rule id
- * @param deviceId devide id
- * @return true if the given ACL rule works in the given device
- */
- boolean checkIfRuleWorksInDevice(RuleId ruleId, DeviceId deviceId);
-
- /**
- * Adds a new mapping from ACL rule to device.
- * @param ruleId ACL rule id
- * @param deviceId device id
- */
- void addRuleToDeviceMapping(RuleId ruleId, DeviceId deviceId);
-
- /**
- * Removes an existing mapping from ACL rule to device.
- * @param ruleId ACL rule id
- */
- void removeRuleToDeviceMapping(RuleId ruleId);
-
-}
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclWebResource.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclWebResource.java
deleted file mode 100644
index 3f4dc769..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclWebResource.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onlab.packet.IPv4;
-import org.onosproject.rest.AbstractWebResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-// FIXME: This does now follow REST-full principles and should be refactored.
-/**
- * Manage ACL rules.
- */
-@Path("")
-public class AclWebResource extends AbstractWebResource {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- /**
- * Processes user's GET HTTP request for querying ACL rules.
- * @return response to the request
- */
- @GET
- public Response queryAclRule() {
- List<AclRule> rules = get(AclService.class).getAclRules();
- ObjectMapper mapper = new ObjectMapper();
- ObjectNode root = mapper.createObjectNode();
- ArrayNode arrayNode = mapper.createArrayNode();
- for (AclRule rule : rules) {
- ObjectNode node = mapper.createObjectNode();
- node.put("id", rule.id().toString());
- if (rule.srcIp() != null) {
- node.put("srcIp", rule.srcIp().toString());
- }
- if (rule.dstIp() != null) {
- node.put("dstIp", rule.dstIp().toString());
- }
- if (rule.ipProto() != 0) {
- switch (rule.ipProto()) {
- case IPv4.PROTOCOL_ICMP:
- node.put("ipProto", "ICMP");
- break;
- case IPv4.PROTOCOL_TCP:
- node.put("ipProto", "TCP");
- break;
- case IPv4.PROTOCOL_UDP:
- node.put("ipProto", "UDP");
- break;
- default:
- break;
- }
- }
- if (rule.dstTpPort() != 0) {
- node.put("dstTpPort", rule.dstTpPort());
- }
- node.put("action", rule.action().toString());
- arrayNode.add(node);
- }
- root.set("ACL rules", arrayNode);
- return Response.ok(root.toString(), MediaType.APPLICATION_JSON_TYPE).build();
- }
-
- /**
- * Processes user's POST HTTP request for add ACL rules.
- * @param stream input stream
- * @return response to the request
- */
- @POST
- @Path("add")
- public Response addAclRule(InputStream stream) {
- AclRule newRule;
- try {
- newRule = jsonToRule(stream);
- } catch (Exception e) {
- return Response.ok("{\"status\" : \"Failed! " + e.getMessage() + "\"}").build();
- }
-
- String status;
- if (get(AclService.class).addAclRule(newRule)) {
- status = "Success! New ACL rule is added.";
- } else {
- status = "Failed! New ACL rule matches an existing rule.";
- }
- return Response.ok("{\"status\" : \"" + status + "\"}").build();
- }
-
- /**
- * Processes user's GET HTTP request for removing ACL rule.
- * @param id ACL rule id (in hex string format)
- * @return response to the request
- */
- @GET
- @Path("remove/{id}")
- public Response removeAclRule(@PathParam("id") String id) {
- String status;
- RuleId ruleId = new RuleId(Long.parseLong(id.substring(2), 16));
- if (get(AclStore.class).getAclRule(ruleId) == null) {
- status = "Failed! There is no ACL rule with this id.";
- } else {
- get(AclService.class).removeAclRule(ruleId);
- status = "Success! ACL rule(id:" + id + ") is removed.";
- }
- return Response.ok("{\"status\" : \"" + status + "\"}").build();
- }
-
- /**
- * Processes user's GET HTTP request for clearing ACL.
- * @return response to the request
- */
- @GET
- @Path("clear")
- public Response clearACL() {
- get(AclService.class).clearAcl();
- return Response.ok("{\"status\" : \"ACL is cleared.\"}").build();
- }
-
- /**
- * Exception class for parsing a invalid ACL rule.
- */
- private class AclRuleParseException extends Exception {
- public AclRuleParseException(String message) {
- super(message);
- }
- }
-
- /**
- * Turns a JSON string into an ACL rule instance.
- */
- private AclRule jsonToRule(InputStream stream) throws AclRuleParseException, IOException {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode jsonNode = mapper.readTree(stream);
- JsonParser jp = jsonNode.traverse();
- AclRule.Builder rule = AclRule.builder();
- jp.nextToken();
- if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
- throw new AclRuleParseException("Expected START_OBJECT");
- }
-
- while (jp.nextToken() != JsonToken.END_OBJECT) {
- if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
- throw new AclRuleParseException("Expected FIELD_NAME");
- }
-
- String key = jp.getCurrentName();
- jp.nextToken();
- String value = jp.getText();
- if ("".equals(value)) {
- continue;
- }
-
- if ("srcIp".equals(key)) {
- rule.srcIp(value);
- } else if ("dstIp".equals(key)) {
- rule.dstIp(value);
- } else if ("ipProto".equals(key)) {
- if ("TCP".equalsIgnoreCase(value)) {
- rule.ipProto(IPv4.PROTOCOL_TCP);
- } else if ("UDP".equalsIgnoreCase(value)) {
- rule.ipProto(IPv4.PROTOCOL_UDP);
- } else if ("ICMP".equalsIgnoreCase(value)) {
- rule.ipProto(IPv4.PROTOCOL_ICMP);
- } else {
- throw new AclRuleParseException("ipProto must be assigned to TCP, UDP, or ICMP.");
- }
- } else if ("dstTpPort".equals(key)) {
- try {
- rule.dstTpPort(Short.parseShort(value));
- } catch (NumberFormatException e) {
- throw new AclRuleParseException("dstTpPort must be assigned to a numerical value.");
- }
- } else if ("action".equals(key)) {
- if (!"allow".equalsIgnoreCase(value) && !"deny".equalsIgnoreCase(value)) {
- throw new AclRuleParseException("action must be assigned to ALLOW or DENY.");
- }
- if ("allow".equalsIgnoreCase(value)) {
- rule.action(AclRule.Action.ALLOW);
- }
- }
- }
- return rule.build();
- }
-
-} \ No newline at end of file
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/RuleId.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/RuleId.java
deleted file mode 100644
index 754a6435..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/RuleId.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li and Heng Qi
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl;
-
-/**
- * ACL rule identifier suitable as an external key.
- * <p>This class is immutable.</p>
- */
-public final class RuleId {
- private final long value;
-
- /**
- * Creates an ACL rule identifier from the specified long value.
- *
- * @param value long value
- * @return ACL rule identifier
- */
- public static RuleId valueOf(long value) {
- return new RuleId(value);
- }
-
- /**
- * Constructor for serializer.
- */
- RuleId() {
- this.value = 0;
- }
-
- /**
- * Constructs the ID corresponding to a given long value.
- *
- * @param value the underlying value of this ID
- */
- RuleId(long value) {
- this.value = value;
- }
-
- /**
- * Returns the backing value.
- *
- * @return the value
- */
- public long fingerprint() {
- return value;
- }
-
- @Override
- public int hashCode() {
- return Long.hashCode(value);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof RuleId)) {
- return false;
- }
- RuleId that = (RuleId) obj;
- return this.value == that.value;
- }
-
- @Override
- public String toString() {
- return "0x" + Long.toHexString(value);
- }
-}
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/AclManager.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/AclManager.java
deleted file mode 100644
index 0ffd4bcd..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/AclManager.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl.impl;
-
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.TpPort;
-import org.onos.acl.AclRule;
-import org.onos.acl.AclService;
-import org.onos.acl.AclStore;
-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.onos.acl.RuleId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultFlowEntry;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowEntry;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostListener;
-import org.onosproject.net.host.HostService;
-import org.slf4j.Logger;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of the ACL service.
- */
-@Component(immediate = true)
-@Service
-public class AclManager implements AclService {
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowRuleService flowRuleService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected AclStore aclStore;
-
- private final Logger log = getLogger(getClass());
- private ApplicationId appId;
- private final HostListener hostListener = new InternalHostListener();
- private IdGenerator idGenerator;
-
- /**
- * Checks if the given IP address is in the given CIDR address.
- */
- private boolean checkIpInCIDR(Ip4Address ip, Ip4Prefix cidr) {
- int offset = 32 - cidr.prefixLength();
- int cidrPrefix = cidr.address().toInt();
- int ipIntValue = ip.toInt();
- cidrPrefix = cidrPrefix >> offset;
- ipIntValue = ipIntValue >> offset;
- cidrPrefix = cidrPrefix << offset;
- ipIntValue = ipIntValue << offset;
-
- return (cidrPrefix == ipIntValue);
- }
-
- private class InternalHostListener implements HostListener {
-
- /**
- * Generate new ACL flow rules for new host following the given ACL rule.
- */
- private void processHostAddedEvent(HostEvent event, AclRule rule) {
- DeviceId deviceId = event.subject().location().deviceId();
- for (IpAddress address : event.subject().ipAddresses()) {
- if ((rule.srcIp() != null) ?
- (checkIpInCIDR(address.getIp4Address(), rule.srcIp())) :
- (checkIpInCIDR(address.getIp4Address(), rule.dstIp()))) {
- if (!aclStore.checkIfRuleWorksInDevice(rule.id(), deviceId)) {
- List<RuleId> allowingRuleList = aclStore
- .getAllowingRuleByDenyingRule(rule.id());
- if (allowingRuleList != null) {
- for (RuleId allowingRuleId : allowingRuleList) {
- generateACLFlow(aclStore.getAclRule(allowingRuleId), deviceId);
- }
- }
- generateACLFlow(rule, deviceId);
- }
- }
- }
- }
-
- @Override
- public void event(HostEvent event) {
- // if a new host appears and an existing rule denies
- // its traffic, a new ACL flow rule is generated.
- if (event.type() == HostEvent.Type.HOST_ADDED) {
- DeviceId deviceId = event.subject().location().deviceId();
- if (mastershipService.getLocalRole(deviceId) == MastershipRole.MASTER) {
- for (AclRule rule : aclStore.getAclRules()) {
- if (rule.action() != AclRule.Action.ALLOW) {
- processHostAddedEvent(event, rule);
- }
- }
- }
- }
- }
- }
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication("org.onos.acl");
- hostService.addListener(hostListener);
- idGenerator = coreService.getIdGenerator("acl-ids");
- AclRule.bindIdGenerator(idGenerator);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- hostService.removeListener(hostListener);
- flowRuleService.removeFlowRulesById(appId);
- aclStore.clearAcl();
- log.info("Stopped");
- }
-
- @Override
- public List<AclRule> getAclRules() {
- return aclStore.getAclRules();
- }
-
- /**
- * Checks if the new ACL rule matches an existing rule.
- * If existing allowing rules matches the new denying rule, store the mappings.
- * @return true if the new ACL rule matches an existing rule, false otherwise
- */
- private boolean matchCheck(AclRule newRule) {
- for (AclRule existingRule : aclStore.getAclRules()) {
- if (newRule.checkMatch(existingRule)) {
- return true;
- }
-
- if (existingRule.action() == AclRule.Action.ALLOW
- && newRule.action() == AclRule.Action.DENY) {
- if (existingRule.checkMatch(newRule)) {
- aclStore.addDenyToAllowMapping(newRule.id(), existingRule.id());
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean addAclRule(AclRule rule) {
- if (matchCheck(rule)) {
- return false;
- }
- aclStore.addAclRule(rule);
- log.info("ACL rule(id:{}) is added.", rule.id());
- if (rule.action() != AclRule.Action.ALLOW) {
- enforceRuleAdding(rule);
- }
- return true;
- }
-
- /**
- * Gets a set containing all devices connecting with the hosts
- * whose IP address is in the given CIDR IP address.
- */
- private Set<DeviceId> getDeviceIdSet(Ip4Prefix cidrAddr) {
- Set<DeviceId> deviceIdSet = new HashSet<>();
- final Iterable<Host> hosts = hostService.getHosts();
-
- if (cidrAddr.prefixLength() != 32) {
- for (Host h : hosts) {
- for (IpAddress a : h.ipAddresses()) {
- if (checkIpInCIDR(a.getIp4Address(), cidrAddr)) {
- deviceIdSet.add(h.location().deviceId());
- }
- }
- }
- } else {
- for (Host h : hosts) {
- for (IpAddress a : h.ipAddresses()) {
- if (checkIpInCIDR(a.getIp4Address(), cidrAddr)) {
- deviceIdSet.add(h.location().deviceId());
- return deviceIdSet;
- }
- }
- }
- }
- return deviceIdSet;
- }
-
- /**
- * Enforces denying ACL rule by ACL flow rules.
- */
- private void enforceRuleAdding(AclRule rule) {
- Set<DeviceId> dpidSet;
- if (rule.srcIp() != null) {
- dpidSet = getDeviceIdSet(rule.srcIp());
- } else {
- dpidSet = getDeviceIdSet(rule.dstIp());
- }
-
- for (DeviceId deviceId : dpidSet) {
- List<RuleId> allowingRuleList = aclStore.getAllowingRuleByDenyingRule(rule.id());
- if (allowingRuleList != null) {
- for (RuleId allowingRuleId : allowingRuleList) {
- generateACLFlow(aclStore.getAclRule(allowingRuleId), deviceId);
- }
- }
- generateACLFlow(rule, deviceId);
- }
- }
-
- /**
- * Generates ACL flow rule according to ACL rule
- * and install it into related device.
- */
- private void generateACLFlow(AclRule rule, DeviceId deviceId) {
- if (rule == null || aclStore.checkIfRuleWorksInDevice(rule.id(), deviceId)) {
- return;
- }
-
- TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- FlowEntry.Builder flowEntry = DefaultFlowEntry.builder();
-
- selectorBuilder.matchEthType(Ethernet.TYPE_IPV4);
- if (rule.srcIp() != null) {
- selectorBuilder.matchIPSrc(rule.srcIp());
- if (rule.dstIp() != null) {
- selectorBuilder.matchIPDst(rule.dstIp());
- }
- } else {
- selectorBuilder.matchIPDst(rule.dstIp());
- }
- if (rule.ipProto() != 0) {
- selectorBuilder.matchIPProtocol(Integer.valueOf(rule.ipProto()).byteValue());
- }
- if (rule.dstTpPort() != 0) {
- switch (rule.ipProto()) {
- case IPv4.PROTOCOL_TCP:
- selectorBuilder.matchTcpDst(TpPort.tpPort(rule.dstTpPort()));
- break;
- case IPv4.PROTOCOL_UDP:
- selectorBuilder.matchUdpDst(TpPort.tpPort(rule.dstTpPort()));
- break;
- default:
- break;
- }
- }
- if (rule.action() == AclRule.Action.ALLOW) {
- treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
- }
- flowEntry.forDevice(deviceId);
- flowEntry.withPriority(aclStore.getPriorityByDevice(deviceId));
- flowEntry.withSelector(selectorBuilder.build());
- flowEntry.withTreatment(treatment.build());
- flowEntry.fromApp(appId);
- flowEntry.makePermanent();
- // install flow rule
- flowRuleService.applyFlowRules(flowEntry.build());
- log.debug("ACL flow rule {} is installed in {}.", flowEntry.build(), deviceId);
- aclStore.addRuleToFlowMapping(rule.id(), flowEntry.build());
- aclStore.addRuleToDeviceMapping(rule.id(), deviceId);
- }
-
- @Override
- public void removeAclRule(RuleId ruleId) {
- aclStore.removeAclRule(ruleId);
- log.info("ACL rule(id:{}) is removed.", ruleId);
- enforceRuleRemoving(ruleId);
- }
-
- /**
- * Enforces removing an existing ACL rule.
- */
- private void enforceRuleRemoving(RuleId ruleId) {
- Set<FlowRule> flowSet = aclStore.getFlowByRule(ruleId);
- if (flowSet != null) {
- for (FlowRule flowRule : flowSet) {
- flowRuleService.removeFlowRules(flowRule);
- log.debug("ACL flow rule {} is removed from {}.", flowRule.toString(), flowRule.deviceId().toString());
- }
- }
- aclStore.removeRuleToFlowMapping(ruleId);
- aclStore.removeRuleToDeviceMapping(ruleId);
- aclStore.removeDenyToAllowMapping(ruleId);
- }
-
- @Override
- public void clearAcl() {
- aclStore.clearAcl();
- flowRuleService.removeFlowRulesById(appId);
- log.info("ACL is cleared.");
- }
-
-}
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
deleted file mode 100644
index 5c8a93cb..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl.impl;
-
-import com.google.common.collect.Collections2;
-import org.onos.acl.AclRule;
-import org.onos.acl.AclStore;
-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.util.KryoNamespace;
-import org.onos.acl.RuleId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.store.AbstractStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.Versioned;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of the ACL store service.
- */
-@Component(immediate = true)
-@Service
-public class DistributedAclStore extends AbstractStore implements AclStore {
-
- private final Logger log = getLogger(getClass());
- private final int defaultFlowMaxPriority = 30000;
-
- private ConsistentMap<RuleId, AclRule> ruleSet;
- private ConsistentMap<DeviceId, Integer> deviceToPriority;
- private ConsistentMap<RuleId, Set<DeviceId>> ruleToDevice;
- private ConsistentMap<RuleId, Set<FlowRule>> ruleToFlow;
- private ConsistentMap<RuleId, List<RuleId>> denyRuleToAllowRule;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Activate
- public void activate() {
- ApplicationId appId = coreService.getAppId("org.onosproject.acl");
-
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(AclRule.class)
- .register(AclRule.Action.class)
- .register(RuleId.class);
-
- ruleSet = storageService.<RuleId, AclRule>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("acl-rule-set")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- deviceToPriority = storageService.<DeviceId, Integer>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("device-to-priority")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- ruleToFlow = storageService.<RuleId, Set<FlowRule>>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("rule-to-flow")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- denyRuleToAllowRule = storageService.<RuleId, List<RuleId>>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("deny-to-allow")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- ruleToDevice = storageService.<RuleId, Set<DeviceId>>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("rule-to-device")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactive() {
- log.info("Stopped");
- }
-
- @Override
- public List<AclRule> getAclRules() {
- List<AclRule> aclRules = new ArrayList<>();
- aclRules.addAll(Collections2.transform(ruleSet.values(), Versioned::value));
- return aclRules;
- }
-
- @Override
- public void addAclRule(AclRule rule) {
- ruleSet.putIfAbsent(rule.id(), rule);
- }
-
- @Override
- public AclRule getAclRule(RuleId ruleId) {
- Versioned<AclRule> rule = ruleSet.get(ruleId);
- if (rule != null) {
- return rule.value();
- } else {
- return null;
- }
- }
-
- @Override
- public void removeAclRule(RuleId ruleId) {
- ruleSet.remove(ruleId);
- }
-
- @Override
- public void clearAcl() {
- ruleSet.clear();
- deviceToPriority.clear();
- ruleToFlow.clear();
- denyRuleToAllowRule.clear();
- ruleToDevice.clear();
- }
-
- @Override
- public int getPriorityByDevice(DeviceId deviceId) {
- return deviceToPriority.compute(deviceId,
- (id, priority) -> (priority == null) ? defaultFlowMaxPriority : (priority - 1))
- .value();
- }
-
- @Override
- public Set<FlowRule> getFlowByRule(RuleId ruleId) {
- Versioned<Set<FlowRule>> flowRuleSet = ruleToFlow.get(ruleId);
- if (flowRuleSet != null) {
- return flowRuleSet.value();
- } else {
- return null;
- }
- }
-
- @Override
- public void addRuleToFlowMapping(RuleId ruleId, FlowRule flowRule) {
- ruleToFlow.computeIf(ruleId,
- flowRuleSet -> (flowRuleSet == null || !flowRuleSet.contains(flowRule)),
- (id, flowRuleSet) -> {
- Set<FlowRule> newSet = new HashSet<>();
- if (flowRuleSet != null) {
- newSet.addAll(flowRuleSet);
- }
- newSet.add(flowRule);
- return newSet;
- });
- }
-
- @Override
- public void removeRuleToFlowMapping(RuleId ruleId) {
- ruleToFlow.remove(ruleId);
- }
-
- @Override
- public List<RuleId> getAllowingRuleByDenyingRule(RuleId denyingRuleId) {
- Versioned<List<RuleId>> allowRuleIdSet = denyRuleToAllowRule.get(denyingRuleId);
- if (allowRuleIdSet != null) {
- return allowRuleIdSet.value();
- } else {
- return null;
- }
- }
-
- @Override
- public void addDenyToAllowMapping(RuleId denyingRuleId, RuleId allowingRuleId) {
- denyRuleToAllowRule.computeIf(denyingRuleId,
- ruleIdList -> (ruleIdList == null || !ruleIdList.contains(allowingRuleId)),
- (id, ruleIdList) -> {
- ArrayList<RuleId> newList = new ArrayList<>();
- if (ruleIdList != null) {
- newList.addAll(ruleIdList);
- }
- newList.add(allowingRuleId);
- return newList;
- });
- }
-
- @Override
- public void removeDenyToAllowMapping(RuleId denyingRuleId) {
- denyRuleToAllowRule.remove(denyingRuleId);
- }
-
- @Override
- public boolean checkIfRuleWorksInDevice(RuleId ruleId, DeviceId deviceId) {
- return ruleToDevice.containsKey(ruleId) && ruleToDevice.get(ruleId).value().contains(deviceId);
- }
-
- @Override
- public void addRuleToDeviceMapping(RuleId ruleId, DeviceId deviceId) {
- ruleToDevice.computeIf(ruleId,
- deviceIdSet -> (deviceIdSet == null || !deviceIdSet.contains(deviceId)),
- (id, deviceIdSet) -> {
- Set<DeviceId> newSet = new HashSet<>();
- if (deviceIdSet != null) {
- newSet.addAll(deviceIdSet);
- }
- newSet.add(deviceId);
- return newSet;
- });
- }
-
- @Override
- public void removeRuleToDeviceMapping(RuleId ruleId) {
- ruleToDevice.remove(ruleId);
- }
-
-}
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
deleted file mode 100644
index fa4131ee..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * ACL application.
- */
-package org.onos.acl;
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java
index e792efba..9ec4c883 100644
--- a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java
+++ b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java
@@ -98,6 +98,7 @@ public class AclWebResource extends AbstractWebResource {
*
* @param stream JSON data describing the rule
* @return 200 OK
+ * @throws URISyntaxException uri syntax exception
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
diff --git a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/AclWebResourceTest.java b/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/AclWebResourceTest.java
deleted file mode 100644
index bb7d8051..00000000
--- a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/AclWebResourceTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li and Heng Qi
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onos.acl.web;
-
-import com.sun.jersey.api.client.WebResource;
-import org.onos.acl.AclService;
-import org.onos.acl.AclStore;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.rest.BaseResource;
-import org.onos.acl.AclRule;
-import org.onosproject.core.IdGenerator;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static org.easymock.EasyMock.*;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
-
-/**
- * Test class for ACL application REST resource.
- */
-public class AclWebResourceTest extends ResourceTest {
-
- final AclService mockAclService = createMock(AclService.class);
- final AclStore mockAclStore = createMock(AclStore.class);
- final List<AclRule> rules = new ArrayList<>();
-
- @Before
- public void setUp() {
- expect(mockAclService.getAclRules()).andReturn(rules).anyTimes();
- ServiceDirectory testDirectory = new TestServiceDirectory().add(AclService.class, mockAclService)
- .add(AclStore.class, mockAclStore);
- BaseResource.setServiceDirectory(testDirectory);
- }
-
- @After
- public void tearDown() {
- verify(mockAclService);
- }
-
- /**
- * Mock id generator for testing.
- */
- private class MockIdGenerator implements IdGenerator {
- private AtomicLong nextId = new AtomicLong(0);
-
- @Override
- public long getNewId() {
- return nextId.getAndIncrement();
- }
- }
-
- @Test
- public void testaddRule() throws IOException {
- WebResource rs = resource();
- String response;
- String json;
- IdGenerator idGenerator = new MockIdGenerator();
- AclRule.bindIdGenerator(idGenerator);
-
- replay(mockAclService);
-
- // input a invalid JSON string that contains neither nw_src and nw_dst
- json = "{\"ipProto\":\"TCP\",\"dstTpPort\":\"80\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Failed! Either srcIp or dstIp must be assigned."));
-
- // input a invalid JSON string that doesn't contain CIDR mask bits
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Malformed IPv4 prefix string: 10.0.0.1. " +
- "Address must take form \"x.x.x.x/y\""));
-
- // input a invalid JSON string that contains a invalid IP address
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.256/32\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Invalid IP address string: 10.0.0.256"));
-
- // input a invalid JSON string that contains a invalid IP address
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.01/32\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Invalid IP address string: 10.0.01"));
-
- // input a invalid JSON string that contains a invalid CIDR mask bits
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1/a\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Failed! For input string: \"a\""));
-
- // input a invalid JSON string that contains a invalid CIDR mask bits
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1/33\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Invalid prefix length 33. The value must be in the interval [0, 32]"));
-
- // input a invalid JSON string that contains a invalid ipProto value
- json = "{\"ipProto\":\"ARP\",\"srcIp\":\"10.0.0.1/32\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("ipProto must be assigned to TCP, UDP, or ICMP."));
-
- // input a invalid JSON string that contains a invalid dstTpPort value
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1/32\",\"dstTpPort\":\"a\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("dstTpPort must be assigned to a numerical value."));
-
- // input a invalid JSON string that contains a invalid action value
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1/32\",\"dstTpPort\":\"80\",\"action\":\"PERMIT\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("action must be assigned to ALLOW or DENY."));
- }
-}
diff --git a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/ResourceTest.java b/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/ResourceTest.java
deleted file mode 100644
index 04cd10bd..00000000
--- a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/ResourceTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li and Heng Qi
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl.web;
-
-import com.sun.jersey.test.framework.AppDescriptor;
-import com.sun.jersey.test.framework.JerseyTest;
-import com.sun.jersey.test.framework.WebAppDescriptor;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-
-/**
- * Base class for REST API tests. Performs common configuration operations.
- */
-public class ResourceTest extends JerseyTest {
-
- /**
- * Assigns an available port for the test.
- *
- * @param defaultPort If a port cannot be determined, this one is used.
- * @return free port
- */
- @Override
- public int getPort(int defaultPort) {
- try {
- ServerSocket socket = new ServerSocket(0);
- socket.setReuseAddress(true);
- int port = socket.getLocalPort();
- socket.close();
- return port;
- } catch (IOException ioe) {
- return defaultPort;
- }
- }
-
- @Override
- public AppDescriptor configure() {
- return new WebAppDescriptor.Builder("org.onos.acl").build();
- }
-
-}
diff --git a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/TestServiceDirectory.java b/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/TestServiceDirectory.java
deleted file mode 100644
index 6dbd302c..00000000
--- a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/TestServiceDirectory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li and Heng Qi
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onos.acl.web;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.MutableClassToInstanceMap;
-import org.onlab.osgi.ServiceDirectory;
-
-/**
- * Service directory implementation suitable for testing.
- */
-public class TestServiceDirectory implements ServiceDirectory {
-
-
- private ClassToInstanceMap<Object> services = MutableClassToInstanceMap.create();
-
- @Override
- public <T> T get(Class<T> serviceClass) {
- return services.getInstance(serviceClass);
- }
-
- /**
- * Adds a new service to the directory.
- *
- * @param serviceClass service class
- * @param service service instance
- * @return self
- */
- public TestServiceDirectory add(Class serviceClass, Object service) {
- services.putInstance(serviceClass, service);
- return this;
- }
-
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java
deleted file mode 100644
index e092586a..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.config;
-
-import java.util.Collections;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Object to store address configuration read from a JSON file.
- */
-public class AddressConfiguration {
-
- private List<AddressEntry> addresses;
-
- /**
- * Gets a list of addresses in the system.
- *
- * @return the list of addresses
- */
- public List<AddressEntry> getAddresses() {
- return Collections.unmodifiableList(addresses);
- }
-
- /**
- * Sets a list of addresses in the system.
- *
- * @param addresses the list of addresses
- */
- @JsonProperty("addresses")
- public void setAddresses(List<AddressEntry> addresses) {
- this.addresses = addresses;
- }
-
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java
deleted file mode 100644
index 35fc4434..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.config;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-
-/**
- * Represents a set of addresses bound to a port.
- */
-public class AddressEntry {
- private String dpid;
- private long portNumber;
- private List<String> ipAddresses;
- private String macAddress;
- private Short vlan;
-
- public String getDpid() {
- return dpid;
- }
-
- @JsonProperty("dpid")
- public void setDpid(String strDpid) {
- this.dpid = strDpid;
- }
-
- public long getPortNumber() {
- return portNumber;
- }
-
- @JsonProperty("port")
- public void setPortNumber(long portNumber) {
- this.portNumber = portNumber;
- }
-
- public List<String> getIpAddresses() {
- return ipAddresses;
- }
-
- @JsonProperty("ips")
- public void setIpAddresses(List<String> strIps) {
- this.ipAddresses = strIps;
- }
-
- public String getMacAddress() {
- return macAddress;
- }
-
- @JsonProperty("mac")
- public void setMacAddress(String macAddress) {
- this.macAddress = macAddress;
- }
-
- public Short getVlan() {
- return vlan;
- }
-
- @JsonProperty("vlan")
- public void setVlan(short vlan) {
- this.vlan = vlan;
- }
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java
deleted file mode 100644
index 4eb87b4a..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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.config;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-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.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.host.HostAdminService;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
-import org.slf4j.Logger;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Simple configuration module to read in supplementary network configuration
- * from a file.
- */
-@Component(immediate = true)
-@Service
-public class NetworkConfigReader implements NetworkConfigService {
-
- private final Logger log = getLogger(getClass());
-
- // Current working is /opt/onos/apache-karaf-*
- // TODO: Set the path to /opt/onos/config
- private static final String CONFIG_DIR = "../config";
- private static final String DEFAULT_CONFIG_FILE = "addresses.json";
- private String configFileName = DEFAULT_CONFIG_FILE;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostAdminService hostAdminService;
-
- @Activate
- protected void activate() {
- AddressConfiguration config = readNetworkConfig();
- if (config != null) {
- applyNetworkConfig(config);
- }
- log.info("Started network config reader");
- }
-
- @Deactivate
- protected void deactivate() {
- log.info("Stopped");
- }
-
- /**
- * Reads the network configuration.
- *
- * @return the network configuration on success, otherwise null
- */
- private AddressConfiguration readNetworkConfig() {
- File configFile = new File(CONFIG_DIR, configFileName);
- ObjectMapper mapper = new ObjectMapper();
-
- try {
- log.info("Loading config: {}", configFile.getAbsolutePath());
- AddressConfiguration config =
- mapper.readValue(configFile, AddressConfiguration.class);
-
- return config;
- } catch (FileNotFoundException e) {
- log.warn("Configuration file not found: {}", configFileName);
- } catch (IOException e) {
- log.error("Error loading configuration", e);
- }
-
- return null;
- }
-
- /**
- * Applies the network configuration.
- *
- * @param config the network configuration to apply
- */
- private void applyNetworkConfig(AddressConfiguration config) {
- for (AddressEntry entry : config.getAddresses()) {
- ConnectPoint cp = new ConnectPoint(
- DeviceId.deviceId(dpidToUri(entry.getDpid())),
- PortNumber.portNumber(entry.getPortNumber()));
-
- Set<InterfaceIpAddress> interfaceIpAddresses = new HashSet<>();
- for (String strIp : entry.getIpAddresses()) {
- // Get the IP address and the subnet mask length
- try {
- String[] splits = strIp.split("/");
- if (splits.length != 2) {
- throw new IllegalArgumentException(
- "Invalid IP address and prefix length format");
- }
- // NOTE: IpPrefix will mask-out the bits after the prefix length.
- IpPrefix subnet = IpPrefix.valueOf(strIp);
- IpAddress addr = IpAddress.valueOf(splits[0]);
- InterfaceIpAddress ia =
- new InterfaceIpAddress(addr, subnet);
- interfaceIpAddresses.add(ia);
- } catch (IllegalArgumentException e) {
- log.warn("Bad format for IP address in config: {}", strIp);
- }
- }
-
- MacAddress macAddress = null;
- if (entry.getMacAddress() != null) {
- try {
- macAddress = MacAddress.valueOf(entry.getMacAddress());
- } catch (IllegalArgumentException e) {
- log.warn("Bad format for MAC address in config: {}",
- entry.getMacAddress());
- }
- }
-
- VlanId vlan = null;
- if (entry.getVlan() == null) {
- vlan = VlanId.NONE;
- } else {
- try {
- vlan = VlanId.vlanId(entry.getVlan());
- } catch (IllegalArgumentException e) {
- log.warn("Bad format for VLAN id in config: {}",
- entry.getVlan());
- vlan = VlanId.NONE;
- }
- }
-
- PortAddresses addresses = new PortAddresses(cp,
- interfaceIpAddresses, macAddress, vlan);
- hostAdminService.bindAddressesToPort(addresses);
- }
- }
-
- private static String dpidToUri(String dpid) {
- return "of:" + dpid.replace(":", "");
- }
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java
deleted file mode 100644
index 1d9a895d..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.config;
-
-/**
- * Service interface exported by the Network Configuration.
- *
- * @deprecated in Drake; see org.onosproject.net.config
- */
-@Deprecated
-public interface NetworkConfigService {
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java
deleted file mode 100644
index 6552f206..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Simple configuration module to read in supplementary network configuration
- * from a file.
- */
-package org.onosproject.config;
diff --git a/framework/src/onos/apps/config/src/main/resources/addresses.json b/framework/src/onos/apps/config/src/main/resources/addresses.json
deleted file mode 100644
index a88ed62a..00000000
--- a/framework/src/onos/apps/config/src/main/resources/addresses.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "addresses" : [
- {
- "dpid" : "00:00:00:00:00:00:00:a3",
- "port" : "1",
- "ips" : ["192.168.10.101/24"],
- "mac" : "00:00:00:00:00:01",
- "vlan" : "1"
- },
- {
- "dpid" : "00:00:00:00:00:00:00:a5",
- "port" : "1",
- "ips" : ["192.168.20.101/24"],
- "mac" : "00:00:00:00:00:01",
- "vlan" : "2"
- },
- {
- "dpid" : "00:00:00:00:00:00:00:a2",
- "port" : "1",
- "ips" : ["192.168.30.101/24"],
- "mac" : "00:00:00:00:00:01"
- },
- {
- "dpid" : "00:00:00:00:00:00:00:a6",
- "port" : "1",
- "ips" : ["192.168.40.101/24"],
- "mac" : "00:00:00:00:00:01"
- },
- {
- "dpid" : "00:00:00:00:00:00:00:a4",
- "port" : "4",
- "ips" : ["192.168.60.101/24"],
- "mac" : "00:00:00:00:00:01"
- }
- ]
-}
diff --git a/framework/src/onos/apps/cordvtn/pom.xml b/framework/src/onos/apps/cordvtn/pom.xml
index a019bec2..b8e913d4 100644
--- a/framework/src/onos/apps/cordvtn/pom.xml
+++ b/framework/src/onos/apps/cordvtn/pom.xml
@@ -49,6 +49,11 @@
<artifactId>onos-core-serializers</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
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
index cb8acab2..ba707800 100644
--- 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
@@ -15,6 +15,8 @@
*/
package org.onosproject.cordvtn;
+import com.google.common.collect.Collections2;
+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;
@@ -22,31 +24,39 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.util.KryoNamespace;
+import org.onosproject.cluster.ClusterService;
+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.behaviour.ControllerInfo;
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.ovsdb.controller.OvsdbClientService;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.LogicalClockService;
+import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.Versioned;
import org.slf4j.Logger;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.cordvtn.OvsdbNode.State;
-import static org.onosproject.cordvtn.OvsdbNode.State.INIT;
-import static org.onosproject.cordvtn.OvsdbNode.State.DISCONNECT;
import static org.onosproject.net.Device.Type.SWITCH;
import static org.slf4j.LoggerFactory.getLogger;
@@ -63,7 +73,17 @@ public class CordVtn implements CordVtnService {
private static final int NUM_THREADS = 1;
private static final KryoNamespace.Builder NODE_SERIALIZER = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
- .register(OvsdbNode.class);
+ .register(DefaultOvsdbNode.class);
+ private static final String DEFAULT_BRIDGE_NAME = "br-int";
+ private static final Map<String, String> VXLAN_OPTIONS = new HashMap<String, String>() {
+ {
+ put("key", "flow");
+ put("local_ip", "flow");
+ put("remote_ip", "flow");
+ }
+ };
+ private static final int DPID_BEGIN = 3;
+ private static final int OFPORT = 6653;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -72,14 +92,20 @@ public class CordVtn implements CordVtnService {
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LogicalClockService clockService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected HostService hostService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipService mastershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected OvsdbController controller;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClusterService clusterService;
+
private final ExecutorService eventExecutor = Executors
.newFixedThreadPool(NUM_THREADS, groupedThreads("onos/cordvtn", "event-handler"));
@@ -90,15 +116,16 @@ public class CordVtn implements CordVtnService {
private final BridgeHandler bridgeHandler = new BridgeHandler();
private final VmHandler vmHandler = new VmHandler();
- private EventuallyConsistentMap<DeviceId, OvsdbNode> nodeStore;
+ private ConsistentMap<DeviceId, OvsdbNode> nodeStore;
+ private ApplicationId appId;
@Activate
protected void activate() {
- coreService.registerApplication("org.onosproject.cordvtn");
- nodeStore = storageService.<DeviceId, OvsdbNode>eventuallyConsistentMapBuilder()
+ appId = coreService.registerApplication("org.onosproject.cordvtn");
+ nodeStore = storageService.<DeviceId, OvsdbNode>consistentMapBuilder()
+ .withSerializer(Serializer.using(NODE_SERIALIZER.build()))
.withName("cordvtn-nodestore")
- .withSerializer(NODE_SERIALIZER)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
+ .withApplicationId(appId)
.build();
deviceService.addListener(deviceListener);
@@ -113,43 +140,59 @@ public class CordVtn implements CordVtnService {
hostService.removeListener(hostListener);
eventExecutor.shutdown();
- nodeStore.destroy();
+ nodeStore.clear();
log.info("Stopped");
}
@Override
- public void addNode(OvsdbNode ovsdbNode) {
- if (nodeStore.containsKey(ovsdbNode.deviceId())) {
- log.warn("Node {} already exists", ovsdbNode.host());
+ public void addNode(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+ nodeStore.put(ovsdb.deviceId(), ovsdb);
+ }
+
+ @Override
+ public void deleteNode(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ if (!nodeStore.containsKey(ovsdb.deviceId())) {
return;
}
- nodeStore.put(ovsdbNode.deviceId(), ovsdbNode);
- if (ovsdbNode.state() != INIT) {
- updateNode(ovsdbNode, INIT);
+
+ // check ovsdb and integration bridge connection state first
+ if (isNodeConnected(ovsdb)) {
+ log.warn("Cannot delete connected node {}", ovsdb.host());
+ } else {
+ nodeStore.remove(ovsdb.deviceId());
}
}
@Override
- public void deleteNode(OvsdbNode ovsdbNode) {
- if (!nodeStore.containsKey(ovsdbNode.deviceId())) {
- log.warn("Node {} does not exist", ovsdbNode.host());
+ public void connect(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ if (!nodeStore.containsKey(ovsdb.deviceId())) {
+ log.warn("Node {} does not exist", ovsdb.host());
return;
}
- updateNode(ovsdbNode, DISCONNECT);
+ controller.connect(ovsdb.ip(), ovsdb.port());
}
@Override
- public void updateNode(OvsdbNode ovsdbNode, State state) {
- if (!nodeStore.containsKey(ovsdbNode.deviceId())) {
- log.warn("Node {} does not exist", ovsdbNode.host());
+ public void disconnect(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ if (!nodeStore.containsKey(ovsdb.deviceId())) {
+ log.warn("Node {} does not exist", ovsdb.host());
return;
}
- DefaultOvsdbNode updatedNode = new DefaultOvsdbNode(ovsdbNode.host(),
- ovsdbNode.ip(),
- ovsdbNode.port(),
- state);
- nodeStore.put(ovsdbNode.deviceId(), updatedNode);
+
+ OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+ checkNotNull(ovsdbClient);
+
+ if (ovsdbClient.isConnected()) {
+ ovsdbClient.disconnect();
+ }
}
@Override
@@ -159,14 +202,42 @@ public class CordVtn implements CordVtnService {
@Override
public OvsdbNode getNode(DeviceId deviceId) {
- return nodeStore.get(deviceId);
+ Versioned<OvsdbNode> ovsdb = nodeStore.get(deviceId);
+ if (ovsdb != null) {
+ return ovsdb.value();
+ } else {
+ return null;
+ }
}
@Override
public List<OvsdbNode> getNodes() {
- return nodeStore.values()
- .stream()
- .collect(Collectors.toList());
+ List<OvsdbNode> ovsdbs = new ArrayList<>();
+ ovsdbs.addAll(Collections2.transform(nodeStore.values(), Versioned::value));
+ return ovsdbs;
+ }
+
+ @Override
+ public boolean isNodeConnected(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+ if (ovsdbClient == null) {
+ return false;
+ } else {
+ return ovsdbClient.isConnected();
+ }
+ }
+
+ private OvsdbClientService getOvsdbClient(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ OvsdbClientService ovsdbClient = controller.getOvsdbClient(
+ new OvsdbNodeId(ovsdb.ip(), ovsdb.port().toInt()));
+ if (ovsdbClient == null) {
+ log.warn("Couldn't find ovsdb client of node {}", ovsdb.host());
+ }
+ return ovsdbClient;
}
private class InternalDeviceListener implements DeviceListener {
@@ -182,6 +253,7 @@ public class CordVtn implements CordVtnService {
break;
case DEVICE_AVAILABILITY_CHANGED:
eventExecutor.submit(() -> handler.disconnected(device));
+ // TODO handle the case that the device is recovered
break;
default:
break;
@@ -212,14 +284,27 @@ public class CordVtn implements CordVtnService {
@Override
public void connected(Device device) {
- // create bridge and set bridgeId
- // set node state connected
+ log.info("Ovsdb {} is connected", device.id());
+
+ if (!mastershipService.isLocalMaster(device.id())) {
+ return;
+ }
+
+ // TODO change to use bridge config
+ OvsdbNode ovsdb = getNode(device.id());
+ OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+
+ List<ControllerInfo> controllers = new ArrayList<>();
+ Sets.newHashSet(clusterService.getNodes()).forEach(controller ->
+ controllers.add(new ControllerInfo(controller.ip(), OFPORT, "tcp")));
+ String dpid = ovsdb.intBrId().toString().substring(DPID_BEGIN);
+
+ ovsdbClient.createBridge(DEFAULT_BRIDGE_NAME, dpid, controllers);
}
@Override
public void disconnected(Device device) {
- // set node state disconnected if the node exists
- // which means that the node is not deleted explicitly
+ log.warn("Ovsdb {} is disconnected", device.id());
}
}
@@ -227,12 +312,29 @@ public class CordVtn implements CordVtnService {
@Override
public void connected(Device device) {
- // create vxlan port
+ log.info("Integration Bridge {} is detected", device.id());
+
+ OvsdbNode ovsdb = getNodes().stream()
+ .filter(node -> node.intBrId().equals(device.id()))
+ .findFirst().get();
+
+ if (ovsdb == null) {
+ log.warn("Couldn't find OVSDB associated with {}", device.id());
+ return;
+ }
+
+ if (!mastershipService.isLocalMaster(ovsdb.deviceId())) {
+ return;
+ }
+
+ // TODO change to use tunnel config and tunnel description
+ OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+ ovsdbClient.createTunnel(DEFAULT_BRIDGE_NAME, "vxlan", "vxlan", VXLAN_OPTIONS);
}
@Override
public void disconnected(Device device) {
-
+ log.info("Integration Bridge {} is vanished", device.id());
}
}
@@ -240,12 +342,12 @@ public class CordVtn implements CordVtnService {
@Override
public void connected(Host host) {
- // install flow rules for this vm
+ log.info("VM {} is detected", host.id());
}
@Override
public void disconnected(Host host) {
- // uninstall flow rules associated with this vm
+ log.info("VM {} is vanished", host.id());
}
}
}
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
index fdaf752a..550452ce 100644
--- 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
@@ -20,6 +20,7 @@ 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.DeviceId;
import org.onosproject.net.config.Config;
import java.util.Set;
@@ -35,6 +36,7 @@ public class CordVtnConfig extends Config<ApplicationId> {
public static final String HOST = "host";
public static final String IP = "ip";
public static final String PORT = "port";
+ public static final String BRIDGE_ID = "bridgeId";
/**
* Returns the set of ovsdb nodes read from network config.
@@ -51,7 +53,8 @@ public class CordVtnConfig extends Config<ApplicationId> {
nodes.forEach(jsonNode -> ovsdbNodes.add(new OvsdbNodeConfig(
jsonNode.path(HOST).asText(),
IpAddress.valueOf(jsonNode.path(IP).asText()),
- TpPort.tpPort(jsonNode.path(PORT).asInt()))));
+ TpPort.tpPort(jsonNode.path(PORT).asInt()),
+ DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()))));
return ovsdbNodes;
}
@@ -64,11 +67,13 @@ public class CordVtnConfig extends Config<ApplicationId> {
private final String host;
private final IpAddress ip;
private final TpPort port;
+ private final DeviceId bridgeId;
- public OvsdbNodeConfig(String host, IpAddress ip, TpPort port) {
+ public OvsdbNodeConfig(String host, IpAddress ip, TpPort port, DeviceId bridgeId) {
this.host = checkNotNull(host);
this.ip = checkNotNull(ip);
this.port = checkNotNull(port);
+ this.bridgeId = checkNotNull(bridgeId);
}
/**
@@ -97,5 +102,9 @@ public class CordVtnConfig extends Config<ApplicationId> {
public TpPort port() {
return this.port;
}
+
+ public DeviceId bridgeId() {
+ return this.bridgeId;
+ }
}
}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
index 043b3760..f276c7ca 100644
--- a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
@@ -20,11 +20,6 @@ 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.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.net.config.ConfigFactory;
@@ -35,7 +30,6 @@ import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.basics.SubjectFactories;
import org.slf4j.Logger;
-import static org.onosproject.cordvtn.OvsdbNode.State.INIT;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -58,12 +52,6 @@ public class CordVtnConfigManager {
protected NetworkConfigService configService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LeadershipService leadershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CordVtnService cordVtnService;
private final ConfigFactory configFactory =
@@ -74,29 +62,22 @@ public class CordVtnConfigManager {
}
};
- private final LeadershipEventListener leadershipListener = new InternalLeadershipListener();
private final NetworkConfigListener configListener = new InternalConfigListener();
- private NodeId local;
private ApplicationId appId;
@Activate
protected void active() {
- local = clusterService.getLocalNode().id();
appId = coreService.getAppId(CordVtnService.CORDVTN_APP_ID);
configService.addListener(configListener);
configRegistry.registerConfigFactory(configFactory);
- leadershipService.addListener(leadershipListener);
- leadershipService.runForLeadership(CordVtnService.CORDVTN_APP_ID);
+ readConfiguration();
}
@Deactivate
protected void deactivate() {
- leadershipService.removeListener(leadershipListener);
- leadershipService.withdraw(appId.name());
-
configRegistry.unregisterConfigFactory(configFactory);
configService.removeListener(configListener);
}
@@ -110,30 +91,13 @@ public class CordVtnConfigManager {
}
config.ovsdbNodes().forEach(node -> {
- DefaultOvsdbNode ovsdbNode =
- new DefaultOvsdbNode(node.host(), node.ip(), node.port(), INIT);
- cordVtnService.addNode(ovsdbNode);
- log.info("Add new node {}", node.host());
+ DefaultOvsdbNode ovsdb = new DefaultOvsdbNode(
+ node.host(), node.ip(), node.port(), node.bridgeId());
+ cordVtnService.addNode(ovsdb);
+ cordVtnService.connect(ovsdb);
});
}
- private synchronized void processLeadershipChange(NodeId leader) {
- if (leader == null || !leader.equals(local)) {
- return;
- }
- readConfiguration();
- }
-
- private class InternalLeadershipListener implements LeadershipEventListener {
-
- @Override
- public void event(LeadershipEvent event) {
- if (event.subject().topic().equals(appId.name())) {
- processLeadershipChange(event.subject().leader());
- }
- }
- }
-
private class InternalConfigListener implements NetworkConfigListener {
@Override
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
index 1f75dceb..7e01a452 100644
--- 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
@@ -15,7 +15,6 @@
*/
package org.onosproject.cordvtn;
-import org.onosproject.cordvtn.OvsdbNode.State;
import org.onosproject.net.DeviceId;
import java.util.List;
@@ -29,25 +28,30 @@ public interface CordVtnService {
/**
* Adds a new node to the service.
*
- * @param ovsdbNode ovsdb node
+ * @param ovsdb ovsdb node
*/
- void addNode(OvsdbNode ovsdbNode);
+ void addNode(OvsdbNode ovsdb);
/**
* Deletes a node from the service.
*
- * @param ovsdbNode ovsdb node
+ * @param ovsdb ovsdb node
*/
- void deleteNode(OvsdbNode ovsdbNode);
+ void deleteNode(OvsdbNode ovsdb);
/**
- * Updates ovsdb node.
- * It only used for updating node's connection state.
+ * Connect to a node.
*
- * @param ovsdbNode ovsdb node
- * @param state ovsdb connection state
+ * @param ovsdb ovsdb node
*/
- void updateNode(OvsdbNode ovsdbNode, State state);
+ void connect(OvsdbNode ovsdb);
+
+ /**
+ * Disconnect a node.
+ *
+ * @param ovsdb ovsdb node
+ */
+ void disconnect(OvsdbNode ovsdb);
/**
* Returns the number of the nodes known to the service.
@@ -65,6 +69,14 @@ public interface CordVtnService {
OvsdbNode getNode(DeviceId deviceId);
/**
+ * Returns connection state of the node.
+ *
+ * @param ovsdb ovsdb node
+ * @return true if the node is connected, false otherwise
+ */
+ boolean isNodeConnected(OvsdbNode ovsdb);
+
+ /**
* Returns all nodes known to the service.
*
* @return list of nodes
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
index ce8b0f1d..eba52108 100644
--- 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
@@ -30,13 +30,13 @@ public class DefaultOvsdbNode implements OvsdbNode {
private final String host;
private final IpAddress ip;
private final TpPort port;
- private final State state;
+ private final DeviceId brId;
- public DefaultOvsdbNode(String host, IpAddress ip, TpPort port, State state) {
+ public DefaultOvsdbNode(String host, IpAddress ip, TpPort port, DeviceId brId) {
this.host = host;
this.ip = ip;
this.port = port;
- this.state = state;
+ this.brId = brId;
}
@Override
@@ -55,8 +55,8 @@ public class DefaultOvsdbNode implements OvsdbNode {
}
@Override
- public State state() {
- return this.state;
+ public DeviceId intBrId() {
+ return this.brId;
}
@Override
@@ -65,11 +65,6 @@ public class DefaultOvsdbNode implements OvsdbNode {
}
@Override
- public DeviceId intBrId() {
- return DeviceId.deviceId("of:" + this.host);
- }
-
- @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -79,7 +74,8 @@ public class DefaultOvsdbNode implements OvsdbNode {
DefaultOvsdbNode that = (DefaultOvsdbNode) o;
if (this.host.equals(that.host) &&
this.ip.equals(that.ip) &&
- this.port.equals(that.port)) {
+ this.port.equals(that.port) &&
+ this.brId.equals(that.brId)) {
return true;
}
}
@@ -97,7 +93,7 @@ public class DefaultOvsdbNode implements OvsdbNode {
.add("host", host)
.add("ip", ip)
.add("port", port)
- .add("state", state)
+ .add("bridgeId", brId)
.toString();
}
}
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
deleted file mode 100644
index ebba4cd5..00000000
--- a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.LeadershipService;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.Device;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-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.onosproject.cordvtn.OvsdbNode.State.CONNECTED;
-import static org.onosproject.cordvtn.OvsdbNode.State.DISCONNECTED;
-import static org.onosproject.cordvtn.OvsdbNode.State.READY;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides the connection state management of all nodes registered to the service
- * so that the nodes keep connected unless it is requested to be deleted.
- */
-@Component(immediate = true)
-public class NodeConnectionManager {
- protected final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- LeadershipService leadershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- CordVtnService cordVtnService;
-
- private static final int DELAY_SEC = 5;
-
- private final DeviceListener deviceListener = new InternalDeviceListener();
- private final ScheduledExecutorService connectionExecutor = Executors
- .newSingleThreadScheduledExecutor(groupedThreads("onos/cordvtn", "connection-manager"));
-
- private NodeId localId;
-
- @Activate
- protected void activate() {
- localId = clusterService.getLocalNode().id();
- deviceService.addListener(deviceListener);
-
- connectionExecutor.scheduleWithFixedDelay(() -> cordVtnService.getNodes()
- .stream()
- .filter(node -> localId.equals(getMaster(node)))
- .forEach(node -> {
- connect(node);
- disconnect(node);
- }), 0, DELAY_SEC, TimeUnit.SECONDS);
- }
-
- @Deactivate
- public void stop() {
- connectionExecutor.shutdown();
- deviceService.removeListener(deviceListener);
- }
-
- public void connect(OvsdbNode ovsdbNode) {
- switch (ovsdbNode.state()) {
- case INIT:
- case DISCONNECTED:
- setPassiveMode(ovsdbNode);
- case READY:
- setupConnection(ovsdbNode);
- break;
- default:
- break;
- }
- }
-
- public void disconnect(OvsdbNode ovsdbNode) {
- switch (ovsdbNode.state()) {
- case DISCONNECT:
- // TODO: disconnect
- break;
- default:
- break;
- }
- }
-
- private class InternalDeviceListener implements DeviceListener {
-
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- if (device.type() != Device.Type.CONTROLLER) {
- return;
- }
-
- DefaultOvsdbNode node;
- switch (event.type()) {
- case DEVICE_ADDED:
- node = (DefaultOvsdbNode) cordVtnService.getNode(device.id());
- if (node != null) {
- cordVtnService.updateNode(node, CONNECTED);
- }
- break;
- case DEVICE_AVAILABILITY_CHANGED:
- node = (DefaultOvsdbNode) cordVtnService.getNode(device.id());
- if (node != null) {
- cordVtnService.updateNode(node, DISCONNECTED);
- }
- break;
- default:
- break;
- }
- }
- }
-
- private NodeId getMaster(OvsdbNode ovsdbNode) {
- NodeId master = mastershipService.getMasterFor(ovsdbNode.intBrId());
-
- // master is null if there's no such device
- if (master == null) {
- master = leadershipService.getLeader(CordVtnService.CORDVTN_APP_ID);
- }
- return master;
- }
-
- private void setPassiveMode(OvsdbNode ovsdbNode) {
- // TODO: need ovsdb client implementation first
- // TODO: set the remove ovsdb server passive mode
- cordVtnService.updateNode(ovsdbNode, READY);
- }
-
- private void setupConnection(OvsdbNode ovsdbNode) {
- // TODO initiate connection
- }
-}
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
index 296bd439..c5b7a078 100644
--- 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
@@ -23,12 +23,6 @@ import org.onosproject.net.DeviceId;
* Representation of a node with ovsdb server.
*/
public interface OvsdbNode {
- /**
- * Ovsdb connection state.
- */
- enum State {
- INIT, READY, CONNECTED, DISCONNECT, DISCONNECTED
- }
/**
* Returns the IP address of the ovsdb server.
@@ -53,13 +47,6 @@ public interface OvsdbNode {
String host();
/**
- * Returns the connection state of the ovsdb server.
- *
- * @return connection state
- */
- State state();
-
- /**
* Returns the device id of the ovsdb server.
*
* @return device id
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 5615af1a..e263b3a2 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
@@ -64,6 +64,7 @@ public interface DhcpStore {
* Releases the IP assigned to a Mac ID into the free pool.
*
* @param hostId the host ID for which the mapping needs to be changed
+ * @return released ip
*/
Ip4Address releaseIP(HostId hostId);
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpStoreConfig.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpStoreConfig.java
deleted file mode 100644
index 0059e7e5..00000000
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpStoreConfig.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.dhcp.impl;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.basics.BasicElementConfig;
-
-/**
- * DHCP Store Config class.
- */
-public class DhcpStoreConfig extends Config<ApplicationId> {
-
- 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";
-
- /**
- * Returns the delay after which the dhcp server will purge expired entries.
- *
- * @return time delay or null if not set
- */
- public String timerDelay() {
- return get(TIMER_DELAY, null);
- }
-
- /**
- * 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(String delay) {
- return (BasicElementConfig) setOrClear(TIMER_DELAY, delay);
- }
-
- /**
- * Returns the default timeout for pending assignments.
- *
- * @return default timeout or null if not set
- */
- public String defaultTimeout() {
- return get(DEFAULT_TIMEOUT, null);
- }
-
- /**
- * Sets the default timeout for pending assignments.
- *
- * @param defaultTimeout new default timeout; null to clear
- * @return self
- */
- public BasicElementConfig defaultTimeout(String 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 String startIP() {
- return get(START_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 String endIP() {
- return get(END_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/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java b/framework/src/onos/apps/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java
index 6aaaaee8..86ab37fa 100644
--- a/framework/src/onos/apps/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java
+++ b/framework/src/onos/apps/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java
@@ -85,6 +85,8 @@ public class FlowAnalyzer {
* the network. The possible states are: Cleared (implying that the entry leads to
* a host), Cycle (implying that it is part of cycle), and Black Hole (implying
* that the entry does not lead to a single host).
+ *
+ * @return result string
*/
public String analyze() {
graph = topologyService.getGraph(topologyService.currentTopology());
diff --git a/framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java b/framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java
index ae539c62..b7827406 100644
--- a/framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java
+++ b/framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java
@@ -111,18 +111,18 @@ public class IGMPComponent {
"\tingress port: " + context.inPacket().receivedFrom().toString());
if (ip.getProtocol() != IPv4.PROTOCOL_IGMP) {
- log.error("IGMP Picked up a non IGMP packet.");
+ log.debug("IGMP Picked up a non IGMP packet.");
return;
}
IpPrefix mcast = IpPrefix.valueOf("224.0.0.0/4");
if (!mcast.contains(gaddr)) {
- log.error("IGMP Picked up a non multicast packet.");
+ log.debug("IGMP Picked up a non multicast packet.");
return;
}
if (mcast.contains(saddr)) {
- log.error("IGMP Picked up a packet with a multicast source address.");
+ log.debug("IGMP Picked up a packet with a multicast source address.");
return;
}
IpPrefix spfx = IpPrefix.valueOf(saddr, 32);
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 fb984c9e..1f0df456 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
@@ -196,10 +196,10 @@ public class TopologyMetrics implements TopologyMetricsService {
// Ignore PORT_STATS_UPDATED probe event from interfering with
// other device event timestamps
if (event.type() == DeviceEvent.Type.PORT_STATS_UPDATED) {
- log.info("PORT_STATS_UPDATED event ignored from metrics");
+ log.debug("PORT_STATS_UPDATED event ignored from metrics");
} else {
recordEvent(event, topologyDeviceEventMetric);
- log.info("Device Event: time = {} type = {} event = {}",
+ log.debug("Device Event: time = {} type = {} event = {}",
event.time(), event.type(), event);
}
}
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
index ae5d9e93..c794c800 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
@@ -37,9 +37,32 @@ public class McastDeleteCommand extends AbstractShellCommand {
required = true, multiValued = false)
String gAddr = null;
+ @Argument(index = 2, name = "egressList",
+ description = "Egress id/port",
+ required = false, multiValued = true)
+ String[] egressList = null;
+
+
@Override
protected void execute() {
+
+ boolean deleted = false;
McastRouteTable mrib = McastRouteTable.getInstance();
- mrib.removeRoute(sAddr, gAddr);
+
+ if (egressList == null) {
+ mrib.removeRoute(sAddr, gAddr);
+ deleted = true;
+ } else {
+ // check list for validity before we begin to delete.
+ for (String egress : egressList) {
+ deleted = mrib.removeEgress(sAddr, gAddr, egress);
+ }
+ }
+
+ if (deleted) {
+ print("Successful delete");
+ } else {
+ print("Failed to delete");
+ }
}
-} \ No newline at end of file
+}
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
index 90f65c94..b7f1f3ce 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
@@ -79,8 +79,7 @@ public class McastIntentManager {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
- if (mroute.getIngressPoint() == null ||
- mroute.getEgressPoints().isEmpty()) {
+ if (mroute.getIngressPoint() == null) {
return null;
}
@@ -96,16 +95,22 @@ public class McastIntentManager {
.matchIPDst(mroute.getGaddr())
.matchIPSrc(mroute.getSaddr());
- SinglePointToMultiPointIntent intent =
- SinglePointToMultiPointIntent.builder()
+
+ SinglePointToMultiPointIntent.Builder builder = SinglePointToMultiPointIntent.builder()
.appId(McastForwarding.getAppId())
.selector(selector.build())
.treatment(treatment)
- .ingressPoint(mroute.getIngressPoint().getConnectPoint())
- .egressPoints(mroute.getEgressConnectPoints()).
- build();
+ .ingressPoint(mroute.getIngressPoint().getConnectPoint());
+
+ // allowing intent to be pushed without egress points means we can drop packets.
+ if (!mroute.getEgressPoints().isEmpty()) {
+ builder.egressPoints(mroute.getEgressConnectPoints());
+ }
+ SinglePointToMultiPointIntent intent = builder.build();
intentService.submit(intent);
+ mroute.setDirty(false);
+
return intent;
}
@@ -114,9 +119,10 @@ public class McastIntentManager {
*
* @param mroute the mcast route whose intent we want to remove
*/
- public void withdrawIntent(McastRouteBase mroute) {
+ public void withdrawIntent(McastRoute mroute) {
Intent intent = intentService.getIntent(mroute.getIntentKey());
intentService.withdraw(intent);
+ mroute.setDirty(false);
}
/**
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
index 12b7e6d4..a67725d7 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
@@ -57,6 +57,21 @@ interface McastRoute {
public boolean isIp6();
/**
+ * Get the dirty state.
+ *
+ * @return whether this route is dirty or not.
+ */
+ public boolean getDirty();
+
+ /**
+ * Set the dirty state to indicate that something changed.
+ * This may require an update to the flow tables (intents).
+ *
+ * @param dirty set the dirty bit
+ */
+ public void setDirty(boolean dirty);
+
+ /**
* Add the ingress ConnectPoint.
*
* @param cpstr string representing a ConnectPoint
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
index 730acfa7..4da1f33c 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
@@ -17,7 +17,6 @@ package org.onosproject.mfwd.impl;
import static com.google.common.base.Preconditions.checkNotNull;
-import org.apache.commons.collections.set.ListOrderedSet;
import org.onlab.packet.IpPrefix;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
@@ -267,6 +266,33 @@ public class McastRouteBase implements McastRoute {
}
/**
+ * Remove an egress from McastConnectPoint.
+ *
+ * @param connectPoint the egress connect point
+ * @return boolean result of removal
+ */
+ public boolean removeEgressPoint(String connectPoint) {
+ checkNotNull(connectPoint);
+ return this.removeEgressPoint(ConnectPoint.deviceConnectPoint(connectPoint));
+ }
+
+ /**
+ * Remove an egress from McastConnectPoint.
+ *
+ * @param cp the egress connect point
+ * @return boolean result of removal
+ */
+ public boolean removeEgressPoint(ConnectPoint cp) {
+ boolean removed = false;
+ McastConnectPoint mcp = this.findEgressConnectPoint(checkNotNull(cp));
+ if (mcp != null) {
+ removed = egressPoints.remove(mcp);
+ setDirty(true);
+ }
+ return removed;
+ }
+
+ /**
* Add an egress McastConnectPoint.
*
* @param cpstr deviceId/port of the connect point
@@ -292,7 +318,7 @@ public class McastRouteBase implements McastRoute {
* @return Set of egress ConnectPoints
*/
public Set<ConnectPoint> getEgressConnectPoints() {
- Set<ConnectPoint> cps = new ListOrderedSet();
+ Set<ConnectPoint> cps = new HashSet<ConnectPoint>();
for (McastConnectPoint mcp : egressPoints) {
cps.add(mcp.getConnectPoint());
@@ -417,7 +443,7 @@ public class McastRouteBase implements McastRoute {
out += "intent: ";
out += (intentKey == null) ? "not installed" : this.intentKey.toString();
out += "\n\tingress: ";
- out += (ingressPoint == null) ? "NULL" : ingressPoint.toString();
+ out += (ingressPoint == null) ? "NULL" : ingressPoint.getConnectPoint().toString();
out += "\n\tegress: {\n";
if (egressPoints != null && !egressPoints.isEmpty()) {
for (McastConnectPoint eg : egressPoints) {
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
index 5a07bec7..1140c3a8 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
@@ -17,6 +17,7 @@ package org.onosproject.mfwd.impl;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpPrefix;
+
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -191,6 +192,30 @@ public final class McastRouteTable {
}
/**
+ * Delete a specific egress from the MRIB.
+ *
+ * @param saddr source address * or x.x.x.x or x.x.x.x/y
+ * @param gaddr group address x.x.x.x or x.x.x.x/y
+ * @param egress group address x.x.x.x or x.x.x.x/y
+ * @return boolean if egress was deleted
+ */
+ public boolean removeEgress(String saddr, String gaddr, String egress) {
+
+ IpPrefix gpfx = IpPrefix.valueOf(gaddr);
+ IpPrefix spfx = IpPrefix.valueOf(0, 0);
+ if (saddr != null && !saddr.equals("*")) {
+ spfx = IpPrefix.valueOf(saddr);
+ }
+
+ McastRouteSource src = (McastRouteSource) findBestMatch(spfx, gpfx);
+ boolean removed = src.removeEgressPoint(egress);
+ if (removed) {
+ src.setIntent();
+ }
+ return removed;
+ }
+
+ /**
* Delete a multicast route from the MRIB.
*
* @param saddr source address * or x.x.x.x or x.x.x.x/y
diff --git a/framework/src/onos/apps/mlb/pom.xml b/framework/src/onos/apps/mlb/pom.xml
new file mode 100644
index 00000000..21692374
--- /dev/null
+++ b/framework/src/onos/apps/mlb/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-app-mlb</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Balances mastership among nodes</description>
+
+ <properties>
+ <onos.app.name>org.onosproject.mlb</onos.app.name>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java b/framework/src/onos/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java
new file mode 100644
index 00000000..bcf4e2ef
--- /dev/null
+++ b/framework/src/onos/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.mlb;
+
+import com.google.common.util.concurrent.ListenableScheduledFuture;
+import com.google.common.util.concurrent.ListeningScheduledExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+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.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.mastership.MastershipAdminService;
+import org.onosproject.mastership.MastershipEvent;
+import org.onosproject.mastership.MastershipListener;
+import org.onosproject.mastership.MastershipService;
+import org.slf4j.Logger;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * An app to perform automatic load balancing in response to events. Load balancing events are triggered by any
+ * change in mastership and are limited to a frequency of one every 30 seconds, all load balancing is run on an outside
+ * thread executor that must only have one thread due to issues that can occur is multiple balancing events occur in
+ * parallel.
+ */
+@Component(immediate = true)
+public class MastershipLoadBalancer {
+
+ private final Logger log = getLogger(getClass());
+
+ private static final String REBALANCE_MASTERSHIP = "rebalance/mastership";
+
+ private NodeId localId;
+
+ private AtomicBoolean isLeader = new AtomicBoolean(false);
+
+ private AtomicReference<Future> nextTask = new AtomicReference<>();
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipService mastershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipAdminService mastershipAdminService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LeadershipService leadershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClusterService clusterService;
+
+ private InnerLeadershipListener leadershipListener = new InnerLeadershipListener();
+
+ /* This listener is used to trigger balancing for any mastership event which will include switches changing state
+ between active and inactive states as well as the same variety of event occurring with ONOS nodes. Must
+ use a listenable executor to ensure events are triggered with no frequency greater than once every 30 seconds.
+ */
+ private InnerMastershipListener mastershipListener = new InnerMastershipListener();
+
+ //Ensures that all executions do not interfere with one another (single thread)
+ private ListeningScheduledExecutorService executorService = MoreExecutors.
+ listeningDecorator(Executors.newSingleThreadScheduledExecutor());
+
+ @Activate
+ public void activate() {
+ mastershipService.addListener(mastershipListener);
+ localId = clusterService.getLocalNode().id();
+ leadershipService.addListener(leadershipListener);
+ leadershipService.runForLeadership(REBALANCE_MASTERSHIP);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ mastershipService.removeListener(mastershipListener);
+ leadershipService.withdraw(REBALANCE_MASTERSHIP);
+ leadershipService.removeListener(leadershipListener);
+ cancelBalance();
+ executorService.shutdown();
+ log.info("Stopped");
+ }
+
+ private synchronized void processLeadershipChange(NodeId newLeader) {
+ if (newLeader == null) {
+ return;
+ }
+ boolean currLeader = newLeader.equals(localId);
+ if (isLeader.getAndSet(currLeader) != currLeader) {
+ if (currLeader) {
+ scheduleBalance();
+ } else {
+ cancelBalance();
+ }
+ }
+ }
+
+ private void scheduleBalance() {
+ if (isLeader.get() && nextTask.get() == null) {
+
+ ListenableScheduledFuture task = executorService.schedule(mastershipAdminService::balanceRoles, 30,
+ TimeUnit.SECONDS);
+ task.addListener(() -> {
+ log.info("Completed balance roles");
+ nextTask.set(null);
+ }, MoreExecutors.directExecutor()
+ );
+ if (!nextTask.compareAndSet(null, task)) {
+ task.cancel(false);
+ }
+ }
+ }
+
+ private void cancelBalance() {
+ Future task = nextTask.getAndSet(null);
+ if (task != null) {
+ task.cancel(false);
+ }
+ }
+
+ private class InnerMastershipListener implements MastershipListener {
+
+ @Override
+ public void event(MastershipEvent event) {
+ //Sets flag at execution to indicate there is currently a scheduled rebalancing, reverts upon completion
+ scheduleBalance();
+ }
+ }
+
+ private class InnerLeadershipListener implements LeadershipEventListener {
+ @Override
+ public boolean isRelevant(LeadershipEvent event) {
+ return REBALANCE_MASTERSHIP.equals(event.subject().topic());
+ }
+
+ @Override
+ public void event(LeadershipEvent event) {
+ processLeadershipChange(event.subject().leader());
+ }
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/apps/pom.xml b/framework/src/onos/apps/pom.xml
index b955130a..98210736 100644
--- a/framework/src/onos/apps/pom.xml
+++ b/framework/src/onos/apps/pom.xml
@@ -59,6 +59,7 @@
<module>mfwd</module>
<module>igmp</module>
<module>pim</module>
+ <module>mlb</module>
</modules>
<properties>
diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java
deleted file mode 100644
index 78eecb86..00000000
--- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.routing.config.impl;
-
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
-import org.onosproject.routing.config.Interface;
-
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Adapts PortAddresses data from the HostService into Interface data used by
- * the routing module.
- */
-public class HostToInterfaceAdaptor {
-
- private final HostService hostService;
-
- public HostToInterfaceAdaptor(HostService hostService) {
- this.hostService = checkNotNull(hostService);
- }
-
- public Set<Interface> getInterfaces() {
- Set<PortAddresses> addresses = hostService.getAddressBindings();
- Set<Interface> interfaces = Sets.newHashSetWithExpectedSize(addresses.size());
- for (PortAddresses a : addresses) {
- interfaces.add(new Interface(a));
- }
- return interfaces;
- }
-
- public Interface getInterface(ConnectPoint connectPoint) {
- checkNotNull(connectPoint);
-
- Set<PortAddresses> portAddresses =
- hostService.getAddressBindingsForPort(connectPoint);
-
- for (PortAddresses addresses : portAddresses) {
- if (addresses.connectPoint().equals(connectPoint)) {
- return new Interface(addresses);
- }
- }
-
- return null;
- }
-
- public Interface getInterface(IpAddress ip) {
- Set<PortAddresses> portAddresses = hostService.getAddressBindings();
-
- for (PortAddresses portAddress : portAddresses) {
- for (InterfaceIpAddress portIp : portAddress.ipAddresses()) {
- if (portIp.ipAddress().equals(ip)) {
- return new Interface(portAddress);
- }
- }
- }
-
- return null;
- }
-
- public Interface getMatchingInterface(IpAddress ipAddress) {
- checkNotNull(ipAddress);
-
- for (PortAddresses portAddresses : hostService.getAddressBindings()) {
- for (InterfaceIpAddress ia : portAddresses.ipAddresses()) {
- if (ia.subnetAddress().contains(ipAddress)) {
- return new Interface(portAddresses);
- }
- }
- }
-
- return null;
- }
-
-}
diff --git a/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptorTest.java b/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptorTest.java
deleted file mode 100644
index 0347fc5f..00000000
--- a/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptorTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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.routing.config.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.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
-import org.onosproject.routing.config.Interface;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit tests for the HostToInterfaceAdaptor class.
- */
-public class HostToInterfaceAdaptorTest {
-
- private HostService hostService;
- private HostToInterfaceAdaptor adaptor;
-
- private Set<PortAddresses> portAddresses;
- private Map<ConnectPoint, Interface> interfaces;
-
- private static final ConnectPoint CP1 = new ConnectPoint(
- DeviceId.deviceId("of:1"), PortNumber.portNumber(1));
- private static final ConnectPoint CP2 = new ConnectPoint(
- DeviceId.deviceId("of:1"), PortNumber.portNumber(2));
- private static final ConnectPoint CP3 = new ConnectPoint(
- DeviceId.deviceId("of:2"), PortNumber.portNumber(1));
-
- private static final ConnectPoint NON_EXISTENT_CP = new ConnectPoint(
- DeviceId.deviceId("doesnotexist"), PortNumber.portNumber(1));
-
- @Before
- public void setUp() throws Exception {
- hostService = createMock(HostService.class);
-
- portAddresses = Sets.newHashSet();
- interfaces = Maps.newHashMap();
-
- InterfaceIpAddress ia11 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.1.1"),
- IpPrefix.valueOf("192.168.1.0/24"));
- createPortAddressesAndInterface(CP1,
- Sets.newHashSet(ia11),
- MacAddress.valueOf("00:00:00:00:00:01"),
- VlanId.NONE);
-
- // Two addresses in the same subnet
- InterfaceIpAddress ia21 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.2.1"),
- IpPrefix.valueOf("192.168.2.0/24"));
- InterfaceIpAddress ia22 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.2.2"),
- IpPrefix.valueOf("192.168.2.0/24"));
- createPortAddressesAndInterface(CP2,
- Sets.newHashSet(ia21, ia22),
- MacAddress.valueOf("00:00:00:00:00:02"),
- VlanId.vlanId((short) 4));
-
- // Two addresses in different subnets
- InterfaceIpAddress ia31 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.3.1"),
- IpPrefix.valueOf("192.168.3.0/24"));
- InterfaceIpAddress ia41 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.4.1"),
- IpPrefix.valueOf("192.168.4.0/24"));
- createPortAddressesAndInterface(CP3,
- Sets.newHashSet(ia31, ia41),
- MacAddress.valueOf("00:00:00:00:00:03"),
- VlanId.NONE);
-
- expect(hostService.getAddressBindings()).andReturn(portAddresses).anyTimes();
-
- replay(hostService);
-
- adaptor = new HostToInterfaceAdaptor(hostService);
- }
-
- /**
- * Creates both a PortAddresses and an Interface for the given inputs and
- * places them in the correct global data stores.
- *
- * @param cp the connect point
- * @param ipAddresses the set of interface IP addresses
- * @param mac the MAC address
- * @param vlan the VLAN ID
- */
- private void createPortAddressesAndInterface(
- ConnectPoint cp, Set<InterfaceIpAddress> ipAddresses,
- MacAddress mac, VlanId vlan) {
- PortAddresses pa = new PortAddresses(cp, ipAddresses, mac, vlan);
- portAddresses.add(pa);
- expect(hostService.getAddressBindingsForPort(cp)).andReturn(
- Collections.singleton(pa)).anyTimes();
-
- Interface intf = new Interface(cp, ipAddresses, mac, vlan);
- interfaces.put(cp, intf);
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getInterfaces()}.
- * Verifies that the set of interfaces returned matches what is expected
- * based on the input PortAddresses data.
- */
- @Test
- public void testGetInterfaces() {
- Set<Interface> adaptorIntfs = adaptor.getInterfaces();
-
- assertEquals(3, adaptorIntfs.size());
- assertTrue(adaptorIntfs.contains(this.interfaces.get(CP1)));
- assertTrue(adaptorIntfs.contains(this.interfaces.get(CP2)));
- assertTrue(adaptorIntfs.contains(this.interfaces.get(CP3)));
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getInterface(ConnectPoint)}.
- * Verifies that the correct interface is returned for a given connect
- * point.
- */
- @Test
- public void testGetInterface() {
- assertEquals(this.interfaces.get(CP1), adaptor.getInterface(CP1));
- assertEquals(this.interfaces.get(CP2), adaptor.getInterface(CP2));
- assertEquals(this.interfaces.get(CP3), adaptor.getInterface(CP3));
-
- // Try and get an interface for a connect point with no addresses
- reset(hostService);
- expect(hostService.getAddressBindingsForPort(NON_EXISTENT_CP))
- .andReturn(Collections.<PortAddresses>emptySet()).anyTimes();
- replay(hostService);
-
- assertNull(adaptor.getInterface(NON_EXISTENT_CP));
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getInterface(ConnectPoint)} in the
- * case that the input connect point is null.
- * Verifies that a NullPointerException is thrown.
- */
- @Test(expected = NullPointerException.class)
- public void testGetInterfaceNull() {
- ConnectPoint c = null;
- adaptor.getInterface(c);
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getMatchingInterface(IpAddress)}.
- * Verifies that the correct interface is returned based on the given IP
- * address.
- */
- @Test
- public void testGetMatchingInterface() {
- assertEquals(this.interfaces.get(CP1),
- adaptor.getMatchingInterface(IpAddress.valueOf("192.168.1.100")));
- assertEquals(this.interfaces.get(CP2),
- adaptor.getMatchingInterface(IpAddress.valueOf("192.168.2.100")));
- assertEquals(this.interfaces.get(CP3),
- adaptor.getMatchingInterface(IpAddress.valueOf("192.168.3.100")));
- assertEquals(this.interfaces.get(CP3),
- adaptor.getMatchingInterface(IpAddress.valueOf("192.168.4.100")));
-
- // Try and match an address we don't have subnet configured for
- assertNull(adaptor.getMatchingInterface(IpAddress.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getMatchingInterface(IpAddress)} in the
- * case that the input IP address is null.
- * Verifies that a NullPointerException is thrown.
- */
- @Test(expected = NullPointerException.class)
- public void testGetMatchingInterfaceNull() {
- adaptor.getMatchingInterface(null);
- }
-
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpService.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpService.java
deleted file mode 100644
index d26d3060..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.sdnip;
-
-/**
- * Service interface exported by SDN-IP.
- */
-public interface SdnIpService {
-
- /**
- * Changes whether this SDN-IP instance is the primary or not based on the
- * boolean parameter.
- *
- * @param isPrimary true if the instance is primary, false if it is not
- */
- void modifyPrimary(boolean isPrimary);
-
-}
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java
index 6ca6d193..f42f84b1 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java
@@ -88,7 +88,6 @@ public class ArpHandler {
}
private void handleArpRequest(DeviceId deviceId, ConnectPoint inPort, Ethernet payload) {
-
ARP arpRequest = (ARP) payload.getPayload();
HostId targetHostId = HostId.hostId(MacAddress.valueOf(
arpRequest.getTargetHardwareAddress()));
@@ -98,14 +97,16 @@ public class ArpHandler {
Ip4Address targetAddress = Ip4Address.valueOf(arpRequest.getTargetProtocolAddress());
sendArpResponse(arpRequest, config.getRouterMacForAGatewayIp(targetAddress));
- // ARP request for known hosts
- } else if (srManager.hostService.getHost(targetHostId) != null) {
- MacAddress targetMac = srManager.hostService.getHost(targetHostId).mac();
- sendArpResponse(arpRequest, targetMac);
-
- // ARP request for unknown host in the subnet
- } else if (isArpReqForSubnet(deviceId, arpRequest)) {
- flood(payload, inPort);
+ } else {
+ Host targetHost = srManager.hostService.getHost(targetHostId);
+ // ARP request for known hosts
+ if (targetHost != null) {
+ sendArpResponse(arpRequest, targetHost.mac());
+
+ // ARP request for unknown host in the subnet
+ } else if (isArpReqForSubnet(deviceId, arpRequest)) {
+ flood(payload, inPort);
+ }
}
}
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 8fdf81a2..eef1b147 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
@@ -62,11 +62,18 @@ public class DeviceConfiguration implements DeviceProperties {
HashMap<PortNumber, Ip4Address> gatewayIps;
HashMap<PortNumber, Ip4Prefix> subnets;
List<AdjacencySid> adjacencySids;
+
+ public SegmentRouterInfo() {
+ this.gatewayIps = new HashMap<>();
+ this.subnets = new HashMap<>();
+ }
}
/**
* Constructor. Reads all the configuration for all devices of type
* Segment Router and organizes into various maps for easier access.
+ *
+ * @param cfgService config service
*/
public DeviceConfiguration(NetworkConfigRegistry cfgService) {
// Read config from device subject, excluding gatewayIps and subnets.
@@ -82,8 +89,6 @@ public class DeviceConfiguration implements DeviceProperties {
info.mac = config.getMac();
info.isEdge = config.isEdgeRouter();
info.adjacencySids = config.getAdjacencySids();
- info.gatewayIps = new HashMap<>();
- info.subnets = new HashMap<>();
this.deviceConfigMap.put(info.deviceId, info);
this.allSegmentIds.add(info.nodeSid);
@@ -107,11 +112,14 @@ public class DeviceConfiguration implements DeviceProperties {
PortNumber port = networkInterface.connectPoint().port();
SegmentRouterInfo info = this.deviceConfigMap.get(dpid);
- Set<InterfaceIpAddress> interfaceAddresses = networkInterface.ipAddresses();
- interfaceAddresses.forEach(interfaceAddress -> {
- info.gatewayIps.put(port, interfaceAddress.ipAddress().getIp4Address());
- info.subnets.put(port, interfaceAddress.subnetAddress().getIp4Prefix());
- });
+ // skip if there is no corresponding device for this ConenctPoint
+ if (info != null) {
+ Set<InterfaceIpAddress> interfaceAddresses = networkInterface.ipAddresses();
+ interfaceAddresses.forEach(interfaceAddress -> {
+ info.gatewayIps.put(port, interfaceAddress.ipAddress().getIp4Address());
+ info.subnets.put(port, interfaceAddress.subnetAddress().getIp4Prefix());
+ });
+ }
});
});
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/NetworkConfigHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/NetworkConfigHandler.java
deleted file mode 100644
index d3468178..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/NetworkConfigHandler.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting;
-
-import com.google.common.collect.Lists;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.PortNumber;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * This class is temporary class and used only for test.
- * It will be replaced with "real" Network Config Manager.
- *
- * TODO: Knock off this wrapper and directly use DeviceConfiguration class
- */
-
-public class NetworkConfigHandler {
-
- private static Logger log = LoggerFactory.getLogger(NetworkConfigHandler.class);
- private SegmentRoutingManager srManager;
- private DeviceConfiguration deviceConfig;
-
- public NetworkConfigHandler(SegmentRoutingManager srManager,
- DeviceConfiguration deviceConfig) {
- this.srManager = srManager;
- this.deviceConfig = deviceConfig;
- }
-
- public List<Ip4Address> getGatewayIpAddress(DeviceId deviceId) {
- return this.deviceConfig.getSubnetGatewayIps(deviceId);
- }
-
- public IpPrefix getRouterIpAddress(DeviceId deviceId) {
- return IpPrefix.valueOf(deviceConfig.getRouterIp(deviceId), 32);
- }
-
- public MacAddress getRouterMacAddress(DeviceId deviceId) {
- return deviceConfig.getDeviceMac(deviceId);
- }
-
- public boolean inSameSubnet(DeviceId deviceId, Ip4Address destIp) {
-
- List<Ip4Prefix> subnets = getSubnetInfo(deviceId);
- if (subnets == null) {
- return false;
- }
-
- return subnets.stream()
- .anyMatch((subnet) -> subnet.contains(destIp));
- }
-
- public boolean inSameSubnet(Ip4Address address, int sid) {
- DeviceId deviceId = deviceConfig.getDeviceId(sid);
- if (deviceId == null) {
- log.warn("Cannot find a device for SID {}", sid);
- return false;
- }
-
- return inSameSubnet(deviceId, address);
- }
-
- public List<Ip4Prefix> getSubnetInfo(DeviceId deviceId) {
- return deviceConfig.getSubnets(deviceId);
- }
-
- public int getMplsId(DeviceId deviceId) {
- return deviceConfig.getSegmentId(deviceId);
- }
-
- public int getMplsId(MacAddress routerMac) {
- return deviceConfig.getSegmentId(routerMac);
- }
-
- public int getMplsId(Ip4Address routerIpAddress) {
- return deviceConfig.getSegmentId(routerIpAddress);
- }
-
- public boolean isEcmpNotSupportedInTransit(DeviceId deviceId) {
- //TODO: temporarily changing to true to test with Dell
- return true;
- }
-
- public boolean isTransitRouter(DeviceId deviceId) {
- return !(deviceConfig.isEdgeDevice(deviceId));
- }
-
-
- public boolean isEdgeRouter(DeviceId deviceId) {
- return deviceConfig.isEdgeDevice(deviceId);
- }
-
- private List<PortNumber> getPortsToNeighbors(DeviceId deviceId, List<DeviceId> fwdSws) {
-
- List<PortNumber> portNumbers = Lists.newArrayList();
-
- Set<Link> links = srManager.linkService.getDeviceEgressLinks(deviceId);
- for (Link link: links) {
- for (DeviceId swId: fwdSws) {
- if (link.dst().deviceId().equals(swId)) {
- portNumbers.add(link.src().port());
- break;
- }
- }
- }
-
- return portNumbers;
- }
-
- public List<PortNumber> getPortsToDevice(DeviceId deviceId) {
- List<PortNumber> portNumbers = Lists.newArrayList();
-
- Set<Link> links = srManager.linkService.getDeviceEgressLinks(deviceId);
- for (Link link: links) {
- if (link.dst().deviceId().equals(deviceId)) {
- portNumbers.add(link.src().port());
- }
- }
-
- return portNumbers;
- }
-
-
- public Ip4Address getDestinationRouterAddress(Ip4Address destIpAddress) {
- return deviceConfig.getRouterIpAddressForASubnetHost(destIpAddress);
- }
-
- public DeviceId getDeviceId(Ip4Address ip4Address) {
- return deviceConfig.getDeviceId(ip4Address);
- }
-
- public MacAddress getRouterMac(Ip4Address targetAddress) {
- return deviceConfig.getRouterMacForAGatewayIp(targetAddress);
- }
-}
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index 05663129..9011160c 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -116,11 +116,12 @@ public class SegmentRoutingManager implements SegmentRoutingService {
protected ApplicationId appId;
protected DeviceConfiguration deviceConfiguration = null;
-
private DefaultRoutingHandler defaultRoutingHandler = null;
private TunnelHandler tunnelHandler = null;
private PolicyHandler policyHandler = null;
- private InternalPacketProcessor processor = new InternalPacketProcessor();
+ private InternalPacketProcessor processor = null;
+ private InternalLinkListener linkListener = null;
+ private InternalDeviceListener deviceListener = null;
private InternalEventHandler eventHandler = new InternalEventHandler();
private ScheduledExecutorService executorService = Executors
@@ -214,6 +215,16 @@ public class SegmentRoutingManager implements SegmentRoutingService {
cfgService.addListener(cfgListener);
cfgService.registerConfigFactory(cfgFactory);
+ processor = new InternalPacketProcessor();
+ linkListener = new InternalLinkListener();
+ deviceListener = new InternalDeviceListener();
+
+ packetService.addProcessor(processor, PacketProcessor.director(2));
+ linkService.addListener(linkListener);
+ deviceService.addListener(deviceListener);
+
+ cfgListener.configureNetwork();
+
log.info("Started");
}
@@ -223,7 +234,14 @@ public class SegmentRoutingManager implements SegmentRoutingService {
cfgService.unregisterConfigFactory(cfgFactory);
packetService.removeProcessor(processor);
+ linkService.removeListener(linkListener);
+ deviceService.removeListener(deviceListener);
processor = null;
+ linkListener = null;
+ deviceService = null;
+
+ groupHandlerMap.clear();
+
log.info("Stopped");
}
@@ -284,7 +302,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
* @return GroupKey object for the NeighborSet
*/
public GroupKey getGroupKey(NeighborSet ns) {
-
for (DefaultGroupHandler groupHandler : groupHandlerMap.values()) {
return groupHandler.getGroupKey(ns);
}
@@ -301,7 +318,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
* @return next objective ID
*/
public int getNextObjectiveId(DeviceId deviceId, NeighborSet ns) {
-
if (groupHandlerMap.get(deviceId) != null) {
log.trace("getNextObjectiveId query in device {}", deviceId);
return groupHandlerMap
@@ -313,7 +329,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
}
private class InternalPacketProcessor implements PacketProcessor {
-
@Override
public void process(PacketContext context) {
@@ -350,16 +365,8 @@ public class SegmentRoutingManager implements SegmentRoutingService {
}
private class InternalDeviceListener implements DeviceListener {
-
@Override
public void event(DeviceEvent event) {
- /*if (mastershipService.getLocalRole(event.subject().id()) != MastershipRole.MASTER) {
- log.debug("Local role {} is not MASTER for device {}",
- mastershipService.getLocalRole(event.subject().id()),
- event.subject().id());
- return;
- }*/
-
switch (event.type()) {
case DEVICE_ADDED:
case PORT_REMOVED:
@@ -374,7 +381,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
}
private void scheduleEventHandlerIfNotScheduled(Event event) {
-
synchronized (threadSchedulerLock) {
eventQueue.add(event);
numOfEventsQueued++;
@@ -392,7 +398,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
}
private class InternalEventHandler implements Runnable {
-
@Override
public void run() {
try {
@@ -413,8 +418,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
processLinkAdded((Link) event.subject());
} else if (event.type() == LinkEvent.Type.LINK_REMOVED) {
processLinkRemoved((Link) event.subject());
- //} else if (event.type() == GroupEvent.Type.GROUP_ADDED) {
- // processGroupAdded((Group) event.subject());
} else if (event.type() == DeviceEvent.Type.DEVICE_ADDED ||
event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
event.type() == DeviceEvent.Type.DEVICE_UPDATED) {
@@ -526,10 +529,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
flowObjectiveService,
tunnelHandler, policyStore);
- packetService.addProcessor(processor, PacketProcessor.director(2));
- linkService.addListener(new InternalLinkListener());
- deviceService.addListener(new InternalDeviceListener());
-
for (Device device : deviceService.getDevices()) {
//Irrespective whether the local is a MASTER or not for this device,
//create group handler instance and push default TTP flow rules.
@@ -550,12 +549,15 @@ public class SegmentRoutingManager implements SegmentRoutingService {
@Override
public void event(NetworkConfigEvent event) {
- if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
- event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) &&
- event.configClass().equals(SegmentRoutingConfig.class)) {
- log.info("Network configuration change detected. (Re)Configuring...");
- configureNetwork();
- return;
+ if (event.configClass().equals(SegmentRoutingConfig.class)) {
+ if (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED) {
+ log.info("Network configuration added.");
+ configureNetwork();
+ }
+ if (event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) {
+ log.info("Network configuration updated.");
+ // TODO support dynamic configuration
+ }
}
}
}
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
deleted file mode 100644
index 0c7749e6..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.onosproject.net.DeviceId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Public class corresponding to JSON described data model. Defines the network
- * configuration at startup.
- */
-public class NetworkConfig {
- protected static final Logger log = LoggerFactory.getLogger(NetworkConfig.class);
-
- @SuppressWarnings("unused")
- private String comment;
-
- private Boolean restrictSwitches;
- private Boolean restrictLinks;
- private List<SwitchConfig> switches;
- private List<LinkConfig> links;
-
- /**
- * Default constructor.
- */
- public NetworkConfig() {
- switches = new ArrayList<>();
- links = new ArrayList<>();
- }
-
- @JsonProperty("comment")
- public void setComment(String c) {
- log.trace("NetworkConfig: comment={}", c);
- comment = c;
- }
-
- @JsonProperty("restrictSwitches")
- public void setRestrictSwitches(boolean rs) {
- log.trace("NetworkConfig: restrictSwitches={}", rs);
- restrictSwitches = rs;
- }
-
- /**
- * Returns default restrict configuration for switches.
- *
- * @return boolean
- */
- public Boolean getRestrictSwitches() {
- return restrictSwitches;
- }
-
- @JsonProperty("restrictLinks")
- public void setRestrictLinks(boolean rl) {
- log.trace("NetworkConfig: restrictLinks={}", rl);
- restrictLinks = rl;
- }
-
- /**
- * Returns default restrict configuration for links.
- *
- * @return boolean
- */
- public Boolean getRestrictLinks() {
- return restrictLinks;
- }
-
- /**
- * Returns configuration for switches.
- *
- * @return list of switch configuration
- */
- public List<SwitchConfig> getSwitchConfig() {
- return switches;
- }
-
- @JsonProperty("switchConfig")
- public void setSwitchConfig(List<SwitchConfig> switches2) {
- log.trace("NetworkConfig: switchConfig={}", switches2);
- this.switches = switches2;
- }
-
- /**
- * Java class corresponding to JSON described switch
- * configuration data model.
- */
- public static class SwitchConfig {
- protected String nodeDpid;
- protected String name;
- protected String type;
- protected boolean allowed;
- protected double latitude;
- protected double longitude;
- protected Map<String, JsonNode> params;
- protected Map<String, String> publishAttributes;
- protected DeviceId dpid;
-
- /**
- * Returns the configured "name" of a switch.
- *
- * @return string
- */
- public String getName() {
- return name;
- }
-
- @JsonProperty("name")
- public void setName(String name) {
- log.trace("SwitchConfig: name={}", name);
- this.name = name;
- }
-
- /**
- * Returns the data plane identifier of a switch.
- *
- * @return ONOS device identifier
- */
- public DeviceId getDpid() {
- return dpid;
- }
-
- public void setDpid(DeviceId dpid) {
- this.dpid = dpid;
- this.nodeDpid = dpid.toString();
- }
-
- /**
- * Returns the data plane identifier of a switch.
- *
- * @return string
- */
- public String getNodeDpid() {
- return nodeDpid;
- }
-
- // mapper sets both DeviceId and string fields for dpid
- @JsonProperty("nodeDpid")
- public void setNodeDpid(String nodeDpid) {
- log.trace("SwitchConfig: nodeDpid={}", nodeDpid);
- this.nodeDpid = nodeDpid;
- this.dpid = DeviceId.deviceId(nodeDpid);
- }
-
- /**
- * Returns the type of a switch.
- *
- * @return string
- */
- public String getType() {
- return type;
- }
-
- @JsonProperty("type")
- public void setType(String type) {
- log.trace("SwitchConfig: type={}", type);
- this.type = type;
- }
-
- /**
- * Returns the latitude of a switch.
- *
- * @return double
- */
- public double getLatitude() {
- return latitude;
- }
-
- @JsonProperty("latitude")
- public void setLatitude(double latitude) {
- log.trace("SwitchConfig: latitude={}", latitude);
- this.latitude = latitude;
- }
-
- /**
- * Returns the longitude of a switch.
- *
- * @return double
- */
- public double getLongitude() {
- return longitude;
- }
-
- @JsonProperty("longitude")
- public void setLongitude(double longitude) {
- log.trace("SwitchConfig: longitude={}", longitude);
- this.longitude = longitude;
- }
-
- /**
- * Returns the allowed flag for a switch.
- *
- * @return boolean
- */
- public boolean isAllowed() {
- return allowed;
- }
-
- @JsonProperty("allowed")
- public void setAllowed(boolean allowed) {
- this.allowed = allowed;
- }
-
- /**
- * Returns the additional configured parameters of a switch.
- *
- * @return key value map
- */
- public Map<String, JsonNode> getParams() {
- return params;
- }
-
- @JsonProperty("params")
- public void setParams(Map<String, JsonNode> params) {
- this.params = params;
- }
-
- /**
- * Reserved for future use.
- *
- * @return key value map
- */
- public Map<String, String> getPublishAttributes() {
- return publishAttributes;
- }
-
- @JsonProperty("publishAttributes")
- public void setPublishAttributes(Map<String, String> publishAttributes) {
- this.publishAttributes = publishAttributes;
- }
-
- }
-
- @JsonProperty("linkConfig")
- public void setLinkConfig(List<LinkConfig> links2) {
- this.links = links2;
- }
-
- /**
- * Reserved for future use.
- *
- * @return list of configured link configuration
- */
- public List<LinkConfig> getLinkConfig() {
- return links;
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkConfig {
- protected String type;
- protected Boolean allowed;
- protected DeviceId dpid1;
- protected DeviceId dpid2;
- protected String nodeDpid1;
- protected String nodeDpid2;
- protected Map<String, JsonNode> params;
- protected Map<String, String> publishAttributes;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public Boolean isAllowed() {
- return allowed;
- }
-
- public void setAllowed(Boolean allowed) {
- this.allowed = allowed;
- }
-
- public String getNodeDpid1() {
- return nodeDpid1;
- }
-
- // mapper sets both long and string fields for dpid
- public void setNodeDpid1(String nodeDpid1) {
- this.nodeDpid1 = nodeDpid1;
- this.dpid1 = DeviceId.deviceId(nodeDpid1);
- }
-
- public String getNodeDpid2() {
- return nodeDpid2;
- }
-
- // mapper sets both long and string fields for dpid
- public void setNodeDpid2(String nodeDpid2) {
- this.nodeDpid2 = nodeDpid2;
- this.dpid2 = DeviceId.deviceId(nodeDpid2);
- }
-
- public DeviceId getDpid1() {
- return dpid1;
- }
-
- public void setDpid1(DeviceId dpid1) {
- this.dpid1 = dpid1;
- this.nodeDpid1 = dpid1.toString();
- }
-
- public DeviceId getDpid2() {
- return dpid2;
- }
-
- public void setDpid2(DeviceId dpid2) {
- this.dpid2 = dpid2;
- this.nodeDpid2 = dpid2.toString();
- }
-
- public Map<String, JsonNode> getParams() {
- return params;
- }
-
- public void setParams(Map<String, JsonNode> params) {
- this.params = params;
- }
-
- public Map<String, String> getPublishAttributes() {
- return publishAttributes;
- }
-
- public void setPublishAttributes(Map<String, String> publishAttributes) {
- this.publishAttributes = publishAttributes;
- }
- }
-}
-
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
deleted file mode 100644
index 0c0dac86..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import org.onosproject.net.DeviceId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * NetworkConfigExceptions specifies a set of unchecked runtime exceptions that
- * can be thrown by the {@link NetworkConfigManager}. It indicates errors that
- * must be fixed in the config file before controller execution can proceed.
- */
-public class NetworkConfigException extends RuntimeException {
-
- private static final long serialVersionUID = 4959684709803000652L;
- protected static final Logger log = LoggerFactory
- .getLogger(NetworkConfigException.class);
-
- /**
- * Exception for duplicate device identifier configuration.
- */
- public static class DuplicateDpid extends RuntimeException {
- private static final long serialVersionUID = 5491113234592145335L;
-
- public DuplicateDpid(DeviceId dpid) {
- super();
- log.error("Duplicate dpid found in switch-config Dpid:{}",
- dpid);
- }
- }
-
- /**
- * Exception for duplicate device name configuration.
- */
- public static class DuplicateName extends RuntimeException {
- private static final long serialVersionUID = -4090171438031376129L;
-
- public DuplicateName(String name) {
- super();
- log.error("Duplicate name found in switch-config name:{}", name);
- }
- }
-
- /**
- * Exception for unspecified device identifier for a switch.
- */
- public static class DpidNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -8494418855597117254L;
-
- public DpidNotSpecified(String name) {
- super();
- log.error("Dpid not specified for switch-config name:{}", name);
- }
- }
-
- /**
- * Exception for unspecified device name for a switch.
- */
- public static class NameNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -3518881744110422891L;
-
- public NameNotSpecified(DeviceId dpid) {
- super();
- log.error("Name not specified for switch-config dpid:{}",
- dpid);
- }
- }
-
- /**
- * Exception for unspecified device type for a switch.
- */
- public static class SwitchTypeNotSpecified extends RuntimeException {
- private static final long serialVersionUID = 2527453336226053753L;
-
- public SwitchTypeNotSpecified(DeviceId dpid) {
- super();
- log.error("Switch type not specified for switch-config dpid:{}",
- dpid);
- }
- }
-
- /**
- * Exception for unknown device type configured for a switch.
- */
- public static class UnknownSwitchType extends RuntimeException {
- private static final long serialVersionUID = 7758418165512249170L;
-
- public UnknownSwitchType(String type, String name) {
- super();
- log.error("Unknown switch type {} for switch name:{}", type, name);
- }
- }
-
- /**
- * Exception for missing required parameter configuration for a switch.
- */
- public static class ParamsNotSpecified extends RuntimeException {
- private static final long serialVersionUID = 6247582323691265513L;
-
- public ParamsNotSpecified(String name) {
- super();
- log.error("Params required - not specified for switch:{}", name);
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkTypeNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -2089470389588542215L;
-
- public LinkTypeNotSpecified(String dpid1, String dpid2) {
- super();
- log.error("Link type not specified for link-config between "
- + "dpid1:{} and dpid2:{}", dpid1, dpid2);
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkDpidNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -5701825916378616004L;
-
- public LinkDpidNotSpecified(String dpid1, String dpid2) {
- super();
- if (dpid1 == null) {
- log.error("nodeDpid1 not specified for link-config ");
- }
- if (dpid2 == null) {
- log.error("nodeDpid2 not specified for link-config ");
- }
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkForUnknownSwitchConfig extends RuntimeException {
- private static final long serialVersionUID = -2910458439881964094L;
-
- public LinkForUnknownSwitchConfig(String dpid) {
- super();
- log.error("Link configuration was specified for a switch-dpid {} "
- + "that has not been configured", dpid);
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class UnknownLinkType extends RuntimeException {
- private static final long serialVersionUID = -5505376193106542305L;
-
- public UnknownLinkType(String linktype, String dpid1, String dpid2) {
- super();
- log.error("unknown link type {} for links between dpid1:{} "
- + "and dpid2:{}", linktype, dpid1, dpid2);
- }
- }
-
- /**
- * Exception for generic configuration errors.
- */
- public static class ErrorConfig extends RuntimeException {
- private static final long serialVersionUID = -2827406314700193147L;
-
- public ErrorConfig(String errorMsg) {
- super();
- log.error(errorMsg);
- }
-
- }
-
- /**
- * Reserved for future use.
- */
- public static class SwitchDpidNotConverted extends RuntimeException {
- private static final long serialVersionUID = 5640347104590170426L;
-
- public SwitchDpidNotConverted(String name) {
- super();
- log.error("Switch dpid specified as a HexString {} does not match "
- + "with long value", name);
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkDpidNotConverted extends RuntimeException {
- private static final long serialVersionUID = 2397245646094080774L;
-
- public LinkDpidNotConverted(String dpid1, String dpid2) {
- log.error("Dpids expressed as HexStrings for links between dpid1:{} "
- + "and dpid2:{} do not match with long values", dpid1, dpid2);
- }
- }
-
-}
-
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
deleted file mode 100644
index f034f372..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.segmentrouting.config.NetworkConfig.LinkConfig;
-import org.onosproject.segmentrouting.config.NetworkConfig.SwitchConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * NetworkConfigManager manages all network configuration for switches, links
- * and any other state that needs to be configured for correct network
- * operation.
- *
- */
-public class NetworkConfigManager implements NetworkConfigService {
- protected static final Logger log = LoggerFactory
- .getLogger(NetworkConfigManager.class);
- private static final String CONFIG_DIR = "../config";
- private static final String DEFAULT_CONFIG_FILE = "segmentrouting.conf";
- private final String configFileName = DEFAULT_CONFIG_FILE;
- /**
- * JSON Config file needs to use one of the following types for defining the
- * kind of switch or link it wishes to configure.
- */
- public static final String SEGMENT_ROUTER = "Router_SR";
-
- public static final String PKT_LINK = "pktLink";
-
- NetworkConfig networkConfig;
- private ConcurrentMap<DeviceId, SwitchConfig> configuredSwitches;
- private ConcurrentMap<Link, LinkConfig> configuredLinks;
- private Map<String, DeviceId> nameToDpid;
-
- @Override
- public SwitchConfigStatus checkSwitchConfig(DeviceId dpid) {
- SwitchConfig swc = configuredSwitches.get(dpid);
- if (networkConfig.getRestrictSwitches()) {
- // default deny behavior
- if (swc == null) {
- // switch is not configured - we deny this switch
- return new SwitchConfigStatus(NetworkConfigState.DENY, null,
- "Switch not configured, in network denying switches by default.");
- }
- if (swc.isAllowed()) {
- // switch is allowed in config, return configured attributes
- return new SwitchConfigStatus(NetworkConfigState.ACCEPT_ADD, swc);
- } else {
- // switch has been configured off (administratively down)
- return new SwitchConfigStatus(NetworkConfigState.DENY, null,
- "Switch configured down (allowed=false).");
- }
- } else {
- // default allow behavior
- if (swc == null) {
- // no config to add
- return new SwitchConfigStatus(NetworkConfigState.ACCEPT, null);
- }
- if (swc.isAllowed()) {
- // switch is allowed in config, return configured attributes
- return new SwitchConfigStatus(NetworkConfigState.ACCEPT_ADD, swc);
- } else {
- // switch has been configured off (administratively down)
- return new SwitchConfigStatus(NetworkConfigState.DENY, null,
- "Switch configured down (allowed=false).");
- }
- }
-
- }
-
- @Override
- public LinkConfigStatus checkLinkConfig(Link linkTuple) {
- LinkConfig lkc = getConfiguredLink(linkTuple);
- // links are always disallowed if any one of the nodes that make up the
- // link are disallowed
- DeviceId linkNode1 = linkTuple.src().deviceId();
- SwitchConfigStatus scs1 = checkSwitchConfig(linkNode1);
- if (scs1.getConfigState() == NetworkConfigState.DENY) {
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link-node: " + linkNode1 + " denied by config: " + scs1.getMsg());
- }
- DeviceId linkNode2 = linkTuple.dst().deviceId();
- SwitchConfigStatus scs2 = checkSwitchConfig(linkNode2);
- if (scs2.getConfigState() == NetworkConfigState.DENY) {
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link-node: " + linkNode2 + " denied by config: " + scs2.getMsg());
- }
- if (networkConfig.getRestrictLinks()) {
- // default deny behavior
- if (lkc == null) {
- // link is not configured - we deny this link
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link not configured, in network denying links by default.");
- }
- if (lkc.isAllowed()) {
- // link is allowed in config, return configured attributes
- return new LinkConfigStatus(NetworkConfigState.ACCEPT_ADD, lkc);
- } else {
- // link has been configured off (administratively down)
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link configured down (allowed=false).");
- }
- } else {
- // default allow behavior
- if (lkc == null) {
- // no config to add
- return new LinkConfigStatus(NetworkConfigState.ACCEPT, null);
- }
- if (lkc.isAllowed()) {
- // link is allowed in config, return configured attributes
- return new LinkConfigStatus(NetworkConfigState.ACCEPT_ADD, lkc);
- } else {
- // link has been configured off (administratively down)
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link configured down (allowed=false).");
- }
- }
-
- }
-
- @Override
- public List<SwitchConfig> getConfiguredAllowedSwitches() {
- List<SwitchConfig> allowed = new ArrayList<>();
- for (SwitchConfig swc : configuredSwitches.values()) {
- if (swc.isAllowed()) {
- allowed.add(swc);
- }
- }
- return allowed;
- }
-
- @Override
- public List<LinkConfig> getConfiguredAllowedLinks() {
- List<LinkConfig> allowed = new ArrayList<>();
- for (LinkConfig lkc : configuredLinks.values()) {
- if (lkc.isAllowed()) {
- allowed.add(lkc);
- }
- }
- return allowed;
- }
-
- @Override
- public DeviceId getDpidForName(String name) {
- if (nameToDpid.get(name) != null) {
- return nameToDpid.get(name);
- }
- return null;
- }
-
- // **************
- // Private methods
- // **************
-
- private void loadNetworkConfig() {
- File configFile = new File(CONFIG_DIR, configFileName);
- ObjectMapper mapper = new ObjectMapper();
- networkConfig = new NetworkConfig();
-
- try {
- networkConfig = mapper.readValue(configFile,
- NetworkConfig.class);
- } catch (JsonParseException e) {
- String err = String.format("JsonParseException while loading network "
- + "config from file: %s: %s", configFileName,
- e.getMessage());
- throw new NetworkConfigException.ErrorConfig(err);
- } catch (JsonMappingException e) {
- String err = String.format(
- "JsonMappingException while loading network config "
- + "from file: %s: %s",
- configFileName,
- e.getMessage());
- throw new NetworkConfigException.ErrorConfig(err);
- } catch (IOException e) {
- String err = String.format("IOException while loading network config "
- + "from file: %s %s", configFileName, e.getMessage());
- throw new NetworkConfigException.ErrorConfig(err);
- }
-
- log.info("Network config specifies: {} switches and {} links",
- (networkConfig.getRestrictSwitches())
- ? networkConfig.getSwitchConfig().size() : "default allow",
- (networkConfig.getRestrictLinks())
- ? networkConfig.getLinkConfig().size() : "default allow");
- }
-
- private void parseNetworkConfig() {
- List<SwitchConfig> swConfList = networkConfig.getSwitchConfig();
- List<LinkConfig> lkConfList = networkConfig.getLinkConfig();
- validateSwitchConfig(swConfList);
- createTypeSpecificSwitchConfig(swConfList);
- validateLinkConfig(lkConfList);
- createTypeSpecificLinkConfig(lkConfList);
- // TODO validate reachability matrix 'names' for configured dpids
- }
-
- private void createTypeSpecificSwitchConfig(List<SwitchConfig> swConfList) {
- for (SwitchConfig swc : swConfList) {
- nameToDpid.put(swc.getName(), swc.getDpid());
- String swtype = swc.getType();
- switch (swtype) {
- case SEGMENT_ROUTER:
- SwitchConfig sr = new SegmentRouterConfig(swc);
- configuredSwitches.put(sr.getDpid(), sr);
- break;
- default:
- throw new NetworkConfigException.UnknownSwitchType(swtype,
- swc.getName());
- }
- }
- }
-
- private void createTypeSpecificLinkConfig(List<LinkConfig> lkConfList) {
- for (LinkConfig lkc : lkConfList) {
- String lktype = lkc.getType();
- switch (lktype) {
- case PKT_LINK:
- PktLinkConfig pk = new PktLinkConfig(lkc);
- for (Link lt : pk.getLinkTupleList()) {
- configuredLinks.put(lt, pk);
- }
- break;
- default:
- throw new NetworkConfigException.UnknownLinkType(lktype,
- lkc.getNodeDpid1(), lkc.getNodeDpid2());
- }
- }
- }
-
- private void validateSwitchConfig(List<SwitchConfig> swConfList) {
- Set<DeviceId> swDpids = new HashSet<>();
- Set<String> swNames = new HashSet<>();
- for (SwitchConfig swc : swConfList) {
- if (swc.getNodeDpid() == null || swc.getDpid() == null) {
- throw new NetworkConfigException.DpidNotSpecified(swc.getName());
- }
- // ensure both String and DeviceId values of dpid are set
- if (!swc.getDpid().equals(DeviceId.deviceId(swc.getNodeDpid()))) {
- throw new NetworkConfigException.SwitchDpidNotConverted(
- swc.getName());
- }
- if (swc.getName() == null) {
- throw new NetworkConfigException.NameNotSpecified(swc.getDpid());
- }
- if (swc.getType() == null) {
- throw new NetworkConfigException.SwitchTypeNotSpecified(
- swc.getDpid());
- }
- if (!swDpids.add(swc.getDpid())) {
- throw new NetworkConfigException.DuplicateDpid(swc.getDpid());
- }
- if (!swNames.add(swc.getName())) {
- throw new NetworkConfigException.DuplicateName(swc.getName());
- }
- // TODO Add more validations
- }
- }
-
- private void validateLinkConfig(List<LinkConfig> lkConfList) {
- for (LinkConfig lkc : lkConfList) {
- if (lkc.getNodeDpid1() == null || lkc.getNodeDpid2() == null) {
- throw new NetworkConfigException.LinkDpidNotSpecified(
- lkc.getNodeDpid1(), lkc.getNodeDpid2());
- }
- // ensure both String and Long values are set
- if (!lkc.getDpid1().equals(DeviceId.deviceId(lkc.getNodeDpid1())) ||
- !lkc.getDpid2().equals(DeviceId.deviceId(lkc.getNodeDpid2()))) {
- throw new NetworkConfigException.LinkDpidNotConverted(
- lkc.getNodeDpid1(), lkc.getNodeDpid2());
- }
- if (lkc.getType() == null) {
- throw new NetworkConfigException.LinkTypeNotSpecified(
- lkc.getNodeDpid1(), lkc.getNodeDpid2());
- }
- if (configuredSwitches.get(lkc.getDpid1()) == null) {
- throw new NetworkConfigException.LinkForUnknownSwitchConfig(
- lkc.getNodeDpid1());
- }
- if (configuredSwitches.get(lkc.getDpid2()) == null) {
- throw new NetworkConfigException.LinkForUnknownSwitchConfig(
- lkc.getNodeDpid2());
- }
- // TODO add more validations
- }
-
- }
-
- private LinkConfig getConfiguredLink(Link linkTuple) {
- LinkConfig lkc = null;
- // first try the unidirectional link with the ports assigned
- lkc = configuredLinks.get(linkTuple);
- return lkc;
- }
-
-
- /**
- * Initializes the network configuration manager module by
- * loading and parsing the network configuration file.
- */
- public void init() {
- loadNetworkConfig();
- 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
deleted file mode 100644
index afbb0fcc..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.util.List;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.segmentrouting.config.NetworkConfig.LinkConfig;
-import org.onosproject.segmentrouting.config.NetworkConfig.SwitchConfig;
-
-/**
- * Exposes methods to retrieve network configuration.
- *
- * TODO: currently only startup-configuration is exposed and such configuration
- * cannot be changed at runtime. Need to add runtime support for changes to
- * configuration (via REST/CLI) in future releases.
- *
- * TODO: return immutable objects or defensive copies of network config so that
- * users of this API do not inadvertently or maliciously change network config.
- *
- * @deprecated in Drake; see org.onosproject.net.config
- */
-@Deprecated
-public interface NetworkConfigService {
-
- /**
- * Suggests the action to be taken by the caller given the configuration
- * associated with the queried network-object (eg. switch, link etc.).
- */
- enum NetworkConfigState {
- /**
- * Associated network object has been configured to not be allowed in
- * the network.
- */
- DENY,
-
- /**
- * Associated network object has been configured to be allowed in the
- * network.
- */
- ACCEPT,
-
- /**
- * Associated network object has been configured to be allowed in the
- * network. In addition, there are configured parameters that should be
- * added to the object.
- */
- ACCEPT_ADD,
- }
-
- /**
- * Returns the configuration outcome (accept, deny etc.), and any configured
- * parameters to the caller, in response to a query for the configuration
- * associated with a switch.
- */
- class SwitchConfigStatus {
- private NetworkConfigState configState;
- private SwitchConfig switchConfig;
- private String msg;
-
- SwitchConfigStatus(NetworkConfigState configState,
- SwitchConfig switchConfig, String msg) {
- this.configState = configState;
- this.switchConfig = switchConfig;
- this.msg = msg;
- }
-
- SwitchConfigStatus(NetworkConfigState configState,
- SwitchConfig switchConfig) {
- this.configState = configState;
- this.switchConfig = switchConfig;
- this.msg = "";
- }
-
- /**
- * Returns the configuration state for the switch.
- *
- * @return non-null NetworkConfigState
- */
- public NetworkConfigState getConfigState() {
- return configState;
- }
-
- /**
- * Returns the switch configuration, which may be null if no
- * configuration exists, or if the configuration state disallows the
- * switch.
- *
- * @return SwitchConfig, the switch configuration, or null
- */
- public SwitchConfig getSwitchConfig() {
- return switchConfig;
- }
-
- /**
- * User readable string typically used to specify the reason why a
- * switch is being disallowed.
- *
- * @return A non-null but possibly empty String
- */
- public String getMsg() {
- return msg;
- }
-
- }
-
- /**
- * Reserved for future use.
- *
- * Returns the configuration outcome (accept, deny etc.), and any configured
- * parameters to the caller, in response to a query for the configuration
- * associated with a link.
- */
- class LinkConfigStatus {
- private NetworkConfigState configState;
- private LinkConfig linkConfig;
- private String msg;
-
- LinkConfigStatus(NetworkConfigState configState,
- LinkConfig linkConfig, String msg) {
- this.configState = configState;
- this.linkConfig = linkConfig;
- this.msg = msg;
- }
-
- LinkConfigStatus(NetworkConfigState configState,
- LinkConfig linkConfig) {
- this.configState = configState;
- this.linkConfig = linkConfig;
- this.msg = "";
- }
-
- /**
- * Returns the configuration state for the link.
- *
- * @return non-null NetworkConfigState
- */
- public NetworkConfigState getConfigState() {
- return configState;
- }
-
- /**
- * Returns the link configuration, which may be null if no configuration
- * exists, or if the configuration state disallows the link.
- *
- * @return SwitchConfig, the switch configuration, or null
- */
- public LinkConfig getLinkConfig() {
- return linkConfig;
- }
-
- /**
- * User readable string typically used to specify the reason why a link
- * is being disallowed.
- *
- * @return msg A non-null but possibly empty String
- */
- public String getMsg() {
- return msg;
- }
-
- }
-
- /**
- * Checks the switch configuration (if any) associated with the 'dpid'.
- * Determines if the switch should be allowed or denied according to
- * configuration rules.
- *
- * The method always returns a non-null SwitchConfigStatus. The enclosed
- * ConfigState contains the result of the check. The enclosed SwitchConfig
- * may or may not be null, depending on the outcome of the check.
- *
- * @param dpid device id of the switch to be queried
- * @return SwitchConfigStatus with outcome of check and associated config.
- */
- SwitchConfigStatus checkSwitchConfig(DeviceId dpid);
-
- /**
- * Reserved for future use.
- *
- * Checks the link configuration (if any) associated with the 'link'.
- * Determines if the link should be allowed or denied according to
- * configuration rules. Note that the 'link' is a unidirectional link which
- * checked against configuration that is typically defined for a
- * bidirectional link. The caller may make a second call if it wishes to
- * check the 'reverse' direction.
- *
- * Also note that the configuration may not specify ports for a given
- * bidirectional link. In such cases, the configuration applies to all links
- * between the two switches. This method will check the given 'link' against
- * such configuration.
-
- * The method always returns a non-null LinkConfigStatus. The enclosed
- * ConfigState contains the result of the check. The enclosed LinkConfig may
- * or may not be null, depending on the outcome of the check.
- *
- * @param linkTuple unidirectional link to be queried
- * @return LinkConfigStatus with outcome of check and associated config.
- */
- LinkConfigStatus checkLinkConfig(Link linkTuple);
-
- /**
- * Retrieves a list of switches that have been configured, and have been
- * determined to be 'allowed' in the network, according to configuration
- * rules.
- *
- * Note that it is possible that there are other switches that are allowed
- * in the network that have NOT been configured. Such switches will not be a
- * part of the returned list.
- *
- * Also note that it is possible that some switches will not be discovered
- * and the only way the controller can know about these switches is via
- * configuration. Such switches will be included in this list. It is up to
- * the caller to determine which SwitchConfig applies to non-discovered
- * switches.
- *
- * @return a non-null List of SwitchConfig which may be empty
- */
- List<SwitchConfig> getConfiguredAllowedSwitches();
-
- /**
- * Reserved for future use.
- *
- * Retrieves a list of links that have been configured, and have been
- * determined to be 'allowed' in the network, according to configuration
- * rules.
- *
- * Note that it is possible that there are other links that are allowed in
- * the network that have NOT been configured. Such links will not be a part
- * of the returned list.
- *
- * Also note that it is possible that some links will not be discovered and
- * the only way the controller can know about these links is via
- * configuration. Such links will be included in this list. It is up to the
- * caller to determine which LinkConfig applies to non-discovered links.
- *
- * In addition, note that the LinkConfig applies to the configured
- * bi-directional link, which may or may not have declared ports. The
- * associated unidirectional LinkTuple can be retrieved from the
- * getLinkTupleList() method in the LinkConfig object.
- *
- * @return a non-null List of LinkConfig which may be empty
- */
- List<LinkConfig> getConfiguredAllowedLinks();
-
- /**
- * Retrieves the Dpid associated with a 'name' for a configured switch
- * object. This method does not check of the switches are 'allowed' by
- * config.
- *
- * @param name device name
- * @return the Dpid corresponding to a given 'name', or null if no
- * configured switch was found for the given 'name'.
- */
- DeviceId getDpidForName(String name);
-
-}
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
deleted file mode 100644
index 3c51fa9d..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.onosproject.net.Link;
-import org.onosproject.segmentrouting.config.NetworkConfig.LinkConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Reserved for future use.
- * Configuration for a link between two packet-switches.
- */
-public class PktLinkConfig extends LinkConfig {
- protected static final Logger log = LoggerFactory
- .getLogger(PktLinkConfig.class);
- private int port1;
- private int port2;
- private String nodeName1;
- private String nodeName2;
- private List<Link> linkTupleList;
-
- public PktLinkConfig(LinkConfig lkc) {
- nodeDpid1 = lkc.getNodeDpid1();
- nodeDpid2 = lkc.getNodeDpid2();
- dpid1 = lkc.getDpid1();
- dpid2 = lkc.getDpid2();
- type = lkc.getType();
- allowed = lkc.isAllowed();
- params = lkc.getParams();
- publishAttributes = new ConcurrentHashMap<>();
- parseParams();
- validateParams();
- setPublishAttributes();
- }
-
- // ********************
- // Packet Link Configuration
- // ********************
-
- public int getPort1() {
- return port1;
- }
-
- public void setPort1(int port1) {
- this.port1 = port1;
- }
-
- public int getPort2() {
- return port2;
- }
-
- public void setPort2(int port2) {
- this.port2 = port2;
- }
-
- public String getNodeName1() {
- return nodeName1;
- }
-
- public void setNodeName1(String nodeName1) {
- this.nodeName1 = nodeName1;
- }
-
- public String getNodeName2() {
- return nodeName2;
- }
-
- public void setNodeName2(String nodeName2) {
- this.nodeName2 = nodeName2;
- }
-
- /**
- * Returns the two unidirectional links corresponding to the packet-link
- * configuration. It is possible that the ports in the LinkTuple have
- * portnumber '0', implying that the configuration applies to all links
- * between the two switches.
- *
- * @return a list of LinkTuple with exactly 2 unidirectional links
- */
- public List<Link> getLinkTupleList() {
- return linkTupleList;
- }
-
- private void setPublishAttributes() {
-
- }
-
- private void parseParams() {
- if (params == null) {
- throw new PktLinkParamsNotSpecified(nodeDpid1, nodeDpid2);
- }
- Set<Entry<String, JsonNode>> m = params.entrySet();
- for (Entry<String, JsonNode> e : m) {
- String key = e.getKey();
- JsonNode j = e.getValue();
- if (key.equals("nodeName1")) {
- setNodeName1(j.asText());
- } else if (key.equals("nodeName2")) {
- setNodeName2(j.asText());
- } else if (key.equals("port1")) {
- setPort1(j.asInt());
- } else if (key.equals("port2")) {
- setPort2(j.asInt());
- } else {
- throw new UnknownPktLinkConfig(key, nodeDpid1, nodeDpid2);
- }
- }
- }
-
- private void validateParams() {
- // TODO - wrong-names, duplicate links,
- // duplicate use of port, is switch-allowed for which link is allowed?
- // valid port numbers
- }
-
- public static class PktLinkParamsNotSpecified extends RuntimeException {
- private static final long serialVersionUID = 6247582323691265513L;
-
- public PktLinkParamsNotSpecified(String dpidA, String dpidB) {
- super();
- log.error("Params required for packet link - not specified "
- + "for link between switch1:{} and switch2:{}",
- dpidA, dpidB);
- }
- }
-
- public static class UnknownPktLinkConfig extends RuntimeException {
- private static final long serialVersionUID = -5750132094884129179L;
-
- public UnknownPktLinkConfig(String key, String dpidA, String dpidB) {
- super();
- log.error("Unknown packet-link config {} for link between"
- + " dpid1: {} and dpid2: {}", key,
- dpidA, dpidB);
- }
- }
-
-}
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
deleted file mode 100644
index c8d4a54a..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.segmentrouting.config.NetworkConfig.SwitchConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Manages additional configuration for switches configured as Segment Routers.
- */
-public class SegmentRouterConfig extends SwitchConfig {
- protected static final Logger log = LoggerFactory
- .getLogger(SegmentRouterConfig.class);
- private String routerIp;
- private String routerMac;
- private int nodeSid;
- private boolean isEdgeRouter;
- private List<AdjacencySid> adjacencySids;
- private List<Subnet> subnets;
-
- public static final String ROUTER_IP = "routerIp";
- public static final String ROUTER_MAC = "routerMac";
- public static final String NODE_SID = "nodeSid";
- public static final String ADJACENCY_SIDS = "adjacencySids";
- public static final String SUBNETS = "subnets";
- public static final String ISEDGE = "isEdgeRouter";
- private static final int SRGB_MAX = 1000;
-
- /**
- * Parses and validates the additional configuration parameters applicable
- * to segment routers.
- *
- * @param swc switch configuration
- */
- public SegmentRouterConfig(SwitchConfig swc) {
- this.setName(swc.getName());
- this.setDpid(swc.getDpid());
- this.setType(swc.getType());
- this.setLatitude(swc.getLatitude());
- this.setLongitude(swc.getLongitude());
- this.setParams(swc.getParams());
- this.setAllowed(swc.isAllowed());
- publishAttributes = new ConcurrentHashMap<>();
- adjacencySids = new ArrayList<>();
- subnets = new ArrayList<>();
- parseParams();
- validateParams();
- setPublishAttributes();
- }
-
- /**
- * Returns the configured segment router IP address.
- *
- * @return ip address in string format
- */
- public String getRouterIp() {
- return routerIp;
- }
-
- public void setRouterIp(String routerIp) {
- this.routerIp = routerIp;
- }
-
- /**
- * Returns the configured segment router mac address.
- *
- * @return mac address in string format
- */
- public String getRouterMac() {
- return routerMac;
- }
-
- public void setRouterMac(String routerMac) {
- this.routerMac = routerMac;
- }
-
- /**
- * Returns the configured sID for a segment router.
- *
- * @return segment identifier
- */
- public int getNodeSid() {
- return nodeSid;
- }
-
- public void setNodeSid(int nodeSid) {
- this.nodeSid = nodeSid;
- }
-
- /**
- * Returns the flag that indicates the configured segment router
- * is edge or backbone router.
- *
- * @return boolean
- */
- public boolean isEdgeRouter() {
- return isEdgeRouter;
- }
-
- public void setIsEdgeRouter(boolean isEdge) {
- this.isEdgeRouter = isEdge;
- }
-
- /**
- * Class representing segment router adjacency identifier.
- */
- public static class AdjacencySid {
- private int adjSid;
- private List<Integer> ports;
-
- public AdjacencySid(int adjSid, List<Integer> ports) {
- this.ports = ports;
- this.adjSid = adjSid;
- }
-
- /**
- * Returns the list of ports part of a segment
- * router adjacency identifier.
- *
- * @return list of integers
- */
- public List<Integer> getPorts() {
- return ports;
- }
-
- public void setPorts(List<Integer> ports) {
- this.ports = ports;
- }
-
- /**
- * Returns the configured adjacency id of a segment router.
- *
- * @return integer
- */
- public int getAdjSid() {
- return adjSid;
- }
-
- public void setAdjSid(int adjSid) {
- this.adjSid = adjSid;
- }
- }
-
- /**
- * Returns the configured adjacent segment IDs for a segment router.
- *
- * @return list of adjacency identifier
- */
- public List<AdjacencySid> getAdjacencySids() {
- return adjacencySids;
- }
-
- public void setAdjacencySids(List<AdjacencySid> adjacencySids) {
- this.adjacencySids = adjacencySids;
- }
-
- /**
- * Class representing a subnet attached to a segment router.
- */
- public static class Subnet {
- private int portNo;
- private String subnetIp;
-
- public Subnet(int portNo, String subnetIp) {
- this.portNo = portNo;
- this.subnetIp = subnetIp;
- }
-
- /**
- * Returns the port number of segment router on
- * which subnet is attached.
- *
- * @return integer
- */
- public int getPortNo() {
- return portNo;
- }
-
- public void setPortNo(int portNo) {
- this.portNo = portNo;
- }
-
- /**
- * Returns the configured subnet address.
- *
- * @return subnet ip address in string format
- */
- public String getSubnetIp() {
- return subnetIp;
- }
-
- public void setSubnetIp(String subnetIp) {
- this.subnetIp = subnetIp;
- }
- }
-
- /**
- * Returns the configured subnets for a segment router.
- *
- * @return list of subnets
- */
- public List<Subnet> getSubnets() {
- return subnets;
- }
-
- public void setSubnets(List<Subnet> subnets) {
- this.subnets = subnets;
- }
-
- // ********************
- // Helper methods
- // ********************
-
- private void parseParams() {
- if (params == null) {
- throw new NetworkConfigException.ParamsNotSpecified(name);
- }
-
- Set<Entry<String, JsonNode>> m = params.entrySet();
- for (Entry<String, JsonNode> e : m) {
- String key = e.getKey();
- JsonNode j = e.getValue();
- if (key.equals("routerIp")) {
- setRouterIp(j.asText());
- } else if (key.equals("routerMac")) {
- setRouterMac(j.asText());
- } else if (key.equals("nodeSid")) {
- setNodeSid(j.asInt());
- } else if (key.equals("isEdgeRouter")) {
- setIsEdgeRouter(j.asBoolean());
- } else if (key.equals("adjacencySids") || key.equals("subnets")) {
- getInnerParams(j, key);
- } else {
- throw new UnknownSegmentRouterConfig(key, dpid);
- }
- }
- }
-
- private void getInnerParams(JsonNode j, String innerParam) {
- Iterator<JsonNode> innerList = j.elements();
- while (innerList.hasNext()) {
- Iterator<Entry<String, JsonNode>> f = innerList.next().fields();
- int portNo = -1;
- int adjSid = -1;
- String subnetIp = null;
- List<Integer> ports = null;
- while (f.hasNext()) {
- Entry<String, JsonNode> fe = f.next();
- if (fe.getKey().equals("portNo")) {
- portNo = fe.getValue().asInt();
- } else if (fe.getKey().equals("adjSid")) {
- adjSid = fe.getValue().asInt();
- } else if (fe.getKey().equals("subnetIp")) {
- subnetIp = fe.getValue().asText();
- } else if (fe.getKey().equals("ports")) {
- if (fe.getValue().isArray()) {
- Iterator<JsonNode> i = fe.getValue().elements();
- ports = new ArrayList<>();
- while (i.hasNext()) {
- ports.add(i.next().asInt());
- }
- }
- } else {
- throw new UnknownSegmentRouterConfig(fe.getKey(), dpid);
- }
- }
- if (innerParam.equals("adjacencySids")) {
- AdjacencySid ads = new AdjacencySid(adjSid, ports);
- adjacencySids.add(ads);
- } else {
- Subnet sip = new Subnet(portNo, subnetIp);
- subnets.add(sip);
- }
- }
- }
-
- private void validateParams() {
- if (routerIp == null) {
- throw new IpNotSpecified(dpid);
- }
- if (routerMac == null) {
- throw new MacNotSpecified(dpid);
- }
- if (isEdgeRouter && subnets.isEmpty()) {
- throw new SubnetNotSpecifiedInEdgeRouter(dpid);
- }
- if (!isEdgeRouter && !subnets.isEmpty()) {
- throw new SubnetSpecifiedInBackboneRouter(dpid);
- }
- if (nodeSid > SRGB_MAX) {
- throw new NodeLabelNotInSRGB(nodeSid, dpid);
- }
- for (AdjacencySid as : adjacencySids) {
- int label = as.getAdjSid();
- List<Integer> plist = as.getPorts();
- if (label <= SRGB_MAX) {
- throw new AdjacencyLabelInSRGB(label, dpid);
- }
- if (plist.size() <= 1) {
- throw new AdjacencyLabelNotEnoughPorts(label, dpid);
- }
- }
-
-
- // TODO more validations
- }
-
- /**
- * Setting publishAttributes implies that this is the configuration that
- * will be added to Topology.Switch object before it is published on the
- * channel to other controller instances.
- */
- private void setPublishAttributes() {
- publishAttributes.put(ROUTER_IP, routerIp);
- publishAttributes.put(ROUTER_MAC, routerMac);
- publishAttributes.put(NODE_SID, String.valueOf(nodeSid));
- publishAttributes.put(ISEDGE, String.valueOf(isEdgeRouter));
- ObjectMapper mapper = new ObjectMapper();
- try {
- publishAttributes.put(ADJACENCY_SIDS,
- mapper.writeValueAsString(adjacencySids));
- publishAttributes.put(SUBNETS,
- mapper.writeValueAsString(subnets));
- } catch (JsonProcessingException e) {
- log.error("Error while writing SR config: {}", e.getCause());
- } catch (IOException e) {
- log.error("Error while writing SR config: {}", e.getCause());
- }
- }
-
- // ********************
- // Exceptions
- // ********************
-
- public static class IpNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -3001502553646331686L;
-
- public IpNotSpecified(DeviceId dpid) {
- super();
- log.error("Router IP address not specified for SR config dpid:{}",
- dpid);
- }
- }
-
- public static class MacNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -5850132094884129179L;
-
- public MacNotSpecified(DeviceId dpid) {
- super();
- log.error("Router Mac address not specified for SR config dpid:{}",
- dpid);
- }
- }
-
- public static class UnknownSegmentRouterConfig extends RuntimeException {
- private static final long serialVersionUID = -5750132094884129179L;
-
- public UnknownSegmentRouterConfig(String key, DeviceId dpid) {
- super();
- log.error("Unknown Segment Router config {} in dpid: {}", key,
- dpid);
- }
- }
-
- public static class SubnetNotSpecifiedInEdgeRouter extends RuntimeException {
- private static final long serialVersionUID = -5855458472668581268L;
-
- public SubnetNotSpecifiedInEdgeRouter(DeviceId dpid) {
- super();
- log.error("Subnet was not specified for edge router in dpid: {}",
- dpid);
- }
- }
-
- public static class SubnetSpecifiedInBackboneRouter extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public SubnetSpecifiedInBackboneRouter(DeviceId dpid) {
- super();
- log.error("Subnet was specified in backbone router in dpid: {}",
- dpid);
- }
- }
-
- public static class NodeLabelNotInSRGB extends RuntimeException {
- private static final long serialVersionUID = -8482670903748519526L;
-
- public NodeLabelNotInSRGB(int label, DeviceId dpid) {
- super();
- log.error("Node sif {} specified in not in global label-base "
- + "in dpid: {}", label,
- dpid);
- }
- }
-
- public static class AdjacencyLabelInSRGB extends RuntimeException {
- private static final long serialVersionUID = -8482670903748519526L;
-
- public AdjacencyLabelInSRGB(int label, DeviceId dpid) {
- super();
- log.error("Adjaceny label {} specified from global label-base "
- + "in dpid: {}", label,
- dpid);
- }
- }
-
- public static class AdjacencyLabelNotEnoughPorts extends RuntimeException {
- private static final long serialVersionUID = -8482670903748519526L;
-
- public AdjacencyLabelNotEnoughPorts(int label, DeviceId dpid) {
- super();
- log.error("Adjaceny label {} must be specified for at least 2 ports. "
- + "Adjacency labels for single ports are auto-generated "
- + "in dpid: {}", label,
- dpid);
- }
- }
-}
diff --git a/framework/src/onos/apps/vtn/features.xml b/framework/src/onos/apps/vtn/features.xml
deleted file mode 100644
index a8f9cb49..00000000
--- a/framework/src/onos/apps/vtn/features.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
- <repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
- <feature name="${project.artifactId}" version="${project.version}"
- description="${project.description}">
- <feature>onos-api</feature>
- <feature>onos-drivers</feature>
- <feature>onos-app-vtnrsc</feature>
- <feature>onos-app-vtnweb</feature>
- <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
- </feature>
-</features>
diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/VTNService.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/VTNService.java
deleted file mode 100644
index a20f852b..00000000
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/VTNService.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn;
-
-import org.onosproject.net.Device;
-import org.onosproject.net.Host;
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-public interface VTNService {
-
- /**
- * Creates a vxlan tunnel and creates the ovs when a ovs controller node is detected.
- *
- * @param device controller-type device
- */
- void onServerDetected(Device device);
-
- /**
- * Drops a vxlan tunnel and drops the ovs when a ovs controller node is vanished.
- *
- * @param device controller-type device
- */
- void onServerVanished(Device device);
-
- /**
- * Applies default forwarding flows when a ovs is detected.
- *
- * @param device switch-type device
- */
- void onOvsDetected(Device device);
-
- /**
- * Remove default forwarding flows when a ovs is vanished.
- *
- * @param device switch-type device
- */
- void onOvsVanished(Device device);
-
- /**
- * Applies multicast flows and tunnel flows when a VM is detected.
- *
- * @param host a VM
- */
- void onHostDetected(Host host);
-
- /**
- * Remove multicast flows and tunnel flows when a VM is vanished.
- *
- * @param host a VM
- */
- void onHostVanished(Host host);
-
-}
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
deleted file mode 100644
index ba4745b6..00000000
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.impl;
-
-import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
-import static org.onlab.util.Tools.groupedThreads;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-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;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.BridgeConfig;
-import org.onosproject.net.behaviour.BridgeDescription;
-import org.onosproject.net.behaviour.BridgeName;
-import org.onosproject.net.behaviour.DefaultTunnelDescription;
-import org.onosproject.net.behaviour.IpTunnelEndPoint;
-import org.onosproject.net.behaviour.Pipeliner;
-import org.onosproject.net.behaviour.PipelinerContext;
-import org.onosproject.net.behaviour.TunnelConfig;
-import org.onosproject.net.behaviour.TunnelDescription;
-import org.onosproject.net.behaviour.TunnelEndPoint;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DefaultDriverData;
-import org.onosproject.net.driver.Driver;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.criteria.Criteria;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.FlowObjectiveStore;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-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.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtn.VTNService;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantNetwork;
-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 com.google.common.collect.Sets;
-
-/**
- * Provides implementation of VTNService.
- */
-@Component(immediate = true)
-@Service
-public class VTNManager implements VTNService {
- private final Logger log = getLogger(getClass());
-
- private static final String APP_ID = "org.onosproject.app.vtn";
- private ScheduledExecutorService backgroundService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowRuleService flowRuleService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TenantNetworkService tenantNetworkService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected VirtualPortService virtualPortService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DriverService driverService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowObjectiveService flowObjectiveService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowObjectiveStore flowObjectiveStore;
- protected ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- private EventuallyConsistentMap<HostId, SegmentationId> binding;
- private ApplicationId appId;
- private HostListener hostListener = new InnerHostListener();
- private DeviceListener deviceListener = new InnerDeviceListener();
- private static final String IFACEID = "ifaceid";
- private static final String PORT_HEAD = "vxlan";
- private static final String DEFAULT_BRIDGE_NAME = "br-int";
- private static final String CONTROLLER_IP_KEY = "ipaddress";
- private static final int DEFAULT_MAC_PRIORITY = 0x0000;
- private static final int MAC_PRIORITY = 0xffff;
- private static final int DEFAULT_PORT_PRIORITY = 0x0000;
- private static final int PORT_PRIORITY = 0xffff;
- private static final String SWITCH_CHANNEL_ID = "channelId";
- private static final String DRIVER_NAME = "onosfw";
-
- @Activate
- public void activate() {
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API);
- appId = coreService.registerApplication(APP_ID);
- deviceService.addListener(deviceListener);
- hostService.addListener(hostListener);
- backgroundService = newSingleThreadScheduledExecutor(groupedThreads("onos-apps/vtn",
- "manager-background"));
- binding = storageService
- .<HostId, SegmentationId>eventuallyConsistentMapBuilder()
- .withName("all_tunnel").withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- backgroundService.shutdown();
- binding.destroy();
- log.info("Stopped");
- }
-
- @Override
- public void onServerDetected(Device device) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- DriverHandler handler = driverService.createHandler(device.id());
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME));
- String ipAddress = device.annotations().value(CONTROLLER_IP_KEY);
- IpAddress ip = IpAddress.valueOf(ipAddress);
- Sets.newHashSet(devices).stream()
- .filter(d -> Device.Type.CONTROLLER == d.type())
- .filter(d -> !device.id().equals(d.id())).forEach(d -> {
- String ipAddress1 = d.annotations()
- .value(CONTROLLER_IP_KEY);
- IpAddress ip1 = IpAddress.valueOf(ipAddress1);
- applyTunnelConfig(ip, ip1, handler);
- DriverHandler handler1 = driverService
- .createHandler(d.id());
- applyTunnelConfig(ip1, ip, handler1);
-
- });
- }
-
- @Override
- public void onServerVanished(Device device) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- String ipAddress = device.annotations().value(CONTROLLER_IP_KEY);
- IpAddress dst = IpAddress.valueOf(ipAddress);
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER)
- .filter(d -> !device.id().equals(d.id())).forEach(d -> {
- String ipAddress1 = d.annotations()
- .value(CONTROLLER_IP_KEY);
- DriverHandler handler = driverService.createHandler(d.id());
- IpAddress src = IpAddress.valueOf(ipAddress1);
- removeTunnelConfig(src, dst, handler);
- });
- }
-
- private void applyTunnelConfig(IpAddress src, IpAddress dst,
- DriverHandler handler) {
- TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src);
- TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst);
- TunnelDescription tunnel = new DefaultTunnelDescription(
- tunnelAsSrc,
- tunnelAsDst,
- TunnelDescription.Type.VXLAN,
- null);
- TunnelConfig config = handler.behaviour(TunnelConfig.class);
- config.createTunnel(tunnel);
- }
-
- private void removeTunnelConfig(IpAddress src, IpAddress dst,
- DriverHandler handler) {
- TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src);
- TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst);
- TunnelDescription tunnel = new DefaultTunnelDescription(
- tunnelAsSrc,
- tunnelAsDst,
- TunnelDescription.Type.VXLAN,
- null);
- TunnelConfig config = handler.behaviour(TunnelConfig.class);
- config.removeTunnel(tunnel);
- }
-
- @Override
- public void onOvsDetected(Device device) {
- programMacDefaultRules(device.id(), appId, Objective.Operation.ADD);
- programPortDefaultRules(device.id(), appId, Objective.Operation.ADD);
- }
-
- @Override
- public void onOvsVanished(Device device) {
- programMacDefaultRules(device.id(), appId, Objective.Operation.REMOVE);
- programPortDefaultRules(device.id(), appId, Objective.Operation.REMOVE);
- }
-
- @Override
- public void onHostDetected(Host host) {
- String ifaceId = host.annotations().value(IFACEID);
- DeviceId deviceId = host.location().deviceId();
- String currentControllerIp = getControllerIpOfSwitch(deviceId);
- Iterable<Device> devices = deviceService.getAvailableDevices();
- VirtualPortId portId = VirtualPortId.portId(ifaceId);
- VirtualPort port = virtualPortService.getPort(portId);
- TenantNetwork network = tenantNetworkService
- .getNetwork(port.networkId());
- String tunnelName = "vxlan-" + currentControllerIp;
- binding.put(host.id(), network.segmentationId());
- List<Port> allPorts = deviceService.getPorts(deviceId);
- PortNumber inPort = host.location().port();
- List<PortNumber> localVmPorts = getLocalPorts(deviceId, ifaceId);
- List<PortNumber> localTunnelPorts = new ArrayList<>();
- Sets.newHashSet(allPorts.iterator()).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL)).forEach(p -> {
- if (p.annotations().value("portName").startsWith(PORT_HEAD)) {
- localTunnelPorts.add(p.number());
- }
- });
-
- localVmPorts.forEach(lp -> programLocalBcastRules(deviceId, network.segmentationId(), lp, localVmPorts,
- localTunnelPorts, appId, Objective.Operation.ADD));
- programLocalOut(deviceId, network.segmentationId(), inPort, host.mac(),
- appId, Objective.Operation.ADD);
- localTunnelPorts
- .forEach(tp -> programTunnelFloodOut(deviceId,
- network.segmentationId(),
- tp, localVmPorts,
- appId,
- Objective.Operation.ADD));
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER).forEach(d -> {
- DriverHandler handler = driverService.createHandler(d.id());
- BridgeConfig bridgeConfig = handler
- .behaviour(BridgeConfig.class);
- Collection<BridgeDescription> bridgeDescriptions = bridgeConfig
- .getBridges();
-
- Iterator<BridgeDescription> it = bridgeDescriptions
- .iterator();
- if (it.hasNext()) {
- BridgeDescription sw = it.next();
- Set<PortNumber> ports = bridgeConfig.getPortNumbers();
- ports.stream()
- .filter(p -> p.name()
- .equalsIgnoreCase(tunnelName))
- .forEach(p -> programTunnelOut(sw.deviceId(),
- network.segmentationId(), p,
- host.mac(), appId,
- Objective.Operation.ADD));
- }
- });
- programLocalIn(deviceId, network.segmentationId(), inPort, host.mac(),
- appId, Objective.Operation.ADD);
- localTunnelPorts
- .forEach(tp -> programTunnelIn(deviceId,
- network.segmentationId(),
- tp, inPort, host.mac(),
- appId, Objective.Operation.ADD));
-
- }
-
- @Override
- public void onHostVanished(Host host) {
- String ifaceId = host.annotations().value(IFACEID);
- SegmentationId segId = binding.remove(host.id());
- DeviceId deviceId = host.location().deviceId();
- String currentControllerIp = getControllerIpOfSwitch(deviceId);
- Iterable<Device> devices = deviceService.getAvailableDevices();
-
- String tunnelName = "vxlan-" + currentControllerIp;
- List<Port> allPorts = deviceService.getPorts(deviceId);
- PortNumber inPort = host.location().port();
-
- List<PortNumber> localTunnelPorts = new ArrayList<>();
- Sets.newHashSet(allPorts.iterator()).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL)).forEach(p -> {
- if (p.annotations().value("portName").startsWith(PORT_HEAD)) {
- localTunnelPorts.add(p.number());
- }
- });
-
- List<PortNumber> localVmPorts = getLocalPorts(deviceId, ifaceId);
- localVmPorts.add(inPort);
- localVmPorts.forEach(lp -> programLocalBcastRules(deviceId, segId, lp, localVmPorts,
- localTunnelPorts, appId, Objective.Operation.REMOVE));
- programLocalOut(deviceId, segId, inPort, host.mac(),
- appId, Objective.Operation.REMOVE);
- localTunnelPorts
- .forEach(tp -> programTunnelFloodOut(deviceId,
- segId,
- tp, localVmPorts,
- appId,
- Objective.Operation.REMOVE));
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER).forEach(d -> {
- DriverHandler handler = driverService.createHandler(d.id());
- BridgeConfig bridgeConfig = handler
- .behaviour(BridgeConfig.class);
- Collection<BridgeDescription> bridgeDescriptions = bridgeConfig
- .getBridges();
-
- Iterator<BridgeDescription> it = bridgeDescriptions
- .iterator();
- if (it.hasNext()) {
- BridgeDescription sw = it.next();
- Set<PortNumber> ports = bridgeConfig.getPortNumbers();
- ports.stream()
- .filter(p -> p.name()
- .equalsIgnoreCase(tunnelName))
- .forEach(p -> programTunnelOut(sw.deviceId(),
- segId, p,
- host.mac(), appId,
- Objective.Operation.REMOVE));
- }
- });
- programLocalIn(deviceId, segId, inPort, host.mac(),
- appId, Objective.Operation.REMOVE);
- localTunnelPorts
- .forEach(tp -> programTunnelIn(deviceId,
- segId,
- tp, inPort, host.mac(),
- appId, Objective.Operation.REMOVE));
- }
-
- private class InnerDeviceListener implements DeviceListener {
-
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- if (Device.Type.CONTROLLER == device.type()
- && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- backgroundService.execute(() -> onServerDetected(device));
- } else if (Device.Type.CONTROLLER == device.type()
- && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
- .type()) {
- backgroundService.execute(() -> onServerVanished(device));
- } else if (Device.Type.SWITCH == device.type()
- && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- backgroundService.execute(() -> onOvsDetected(device));
- } else if (Device.Type.SWITCH == device.type()
- && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
- .type()) {
- backgroundService.execute(() -> onOvsVanished(device));
- } else {
- log.info("Do nothing for this device type");
- }
- }
-
- }
-
- private class InnerHostListener implements HostListener {
-
- @Override
- public void event(HostEvent event) {
- Host host = event.subject();
- if (HostEvent.Type.HOST_ADDED == event.type()) {
- backgroundService.execute(() -> onHostDetected(host));
- } else if (HostEvent.Type.HOST_REMOVED == event.type()) {
- backgroundService.execute(() -> onHostVanished(host));
- } else if (HostEvent.Type.HOST_UPDATED == event.type()) {
- backgroundService.execute(() -> {
- onHostVanished(host);
- onHostDetected(host);
- });
- }
- }
-
- }
-
- // Used to forward the flows to the local VM.
- private void programLocalOut(DeviceId dpid, SegmentationId segmentationId,
- PortNumber outPort, MacAddress sourceMac,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchTunnelId(Long.parseLong(segmentationId.toString()))
- .matchEthDst(sourceMac).build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(outPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
-
- }
-
- // Used to forward the flows into the VXLAN tunnel.
- private void programTunnelOut(DeviceId dpid, SegmentationId segmentationId,
- PortNumber tunnelOutPort, MacAddress dstMac,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthDst(dstMac).add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
-
- .setOutput(tunnelOutPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
-
- }
-
- // Used to forward multicast flows to remote VMs of the same tenant via
- // VXLAN tunnel.
- private void programTunnelFloodOut(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber ofPortOut,
- List<PortNumber> localVmPorts,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(ofPortOut)
-
- .add(Criteria.matchTunnelId(Long.parseLong(segmentationId
- .toString()))).matchEthDst(MacAddress.BROADCAST)
- .build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
-
- for (PortNumber outPort : localVmPorts) {
- treatment.setOutput(outPort);
- }
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(deviceId, objective.add());
- } else {
- flowServiceForward(deviceId, objective.remove());
- }
- }
-
- // Applies default flows to mac table.
- private void programMacDefaultRules(DeviceId dpid, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder().build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().drop()
- .build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(DEFAULT_MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to forward the flows to the local VMs with the same tenant.
- private void programLocalBcastRules(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber inPort,
- List<PortNumber> localVmPorts,
- List<PortNumber> localTunnelPorts,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthDst(MacAddress.BROADCAST)
- .add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- for (PortNumber outPort : localVmPorts) {
- if (inPort != outPort) {
- treatment.setOutput(outPort);
- }
- }
- for (PortNumber outport : localTunnelPorts) {
- treatment.setOutput(outport);
- }
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(deviceId, objective.add());
- } else {
- flowServiceForward(deviceId, objective.remove());
- }
- }
-
- // Used to apply local entry flow.
- private void programLocalIn(DeviceId dpid, SegmentationId segmentationId,
- PortNumber inPort, MacAddress srcMac,
- ApplicationId appid, Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthSrc(srcMac).build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.add(Instructions.modTunnelId(Long.parseLong(segmentationId
- .toString())));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to forward the flows from the egress tunnel to the VM.
- private void programTunnelIn(DeviceId dpid, SegmentationId segmentationId,
- PortNumber tunnelInPort, PortNumber outPort,
- MacAddress sourceMac, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(tunnelInPort).add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Applies the default flows to port table.
- private void programPortDefaultRules(DeviceId dpid, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder().build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(DEFAULT_PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to get channelId from the device annotations.
- private String getControllerIpOfSwitch(DeviceId deviceId) {
- Device device = deviceService.getDevice(deviceId);
- String url = device.annotations().value(SWITCH_CHANNEL_ID);
- return url.substring(0, url.lastIndexOf(":"));
- }
-
- private Iterable<String> getIfaceIds(String ifaceId) {
- VirtualPortId portId = VirtualPortId.portId(ifaceId);
- VirtualPort port = virtualPortService.getPort(portId);
- TenantNetwork network = tenantNetworkService
- .getNetwork(port.networkId());
- Collection<String> ifaceIds = new HashSet<>();
- Collection<VirtualPort> ports = virtualPortService
- .getPorts(network.id());
- Sets.newHashSet(ports).stream()
- .forEach(p -> ifaceIds.add(p.portId().portId()));
- return ifaceIds;
- }
-
- private List<PortNumber> getLocalPorts(DeviceId deviceId, String ifaceId) {
- DriverHandler handler = driverService
- .createHandler(getController(deviceId));
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- Iterable<String> ifaceIds = getIfaceIds(ifaceId);
- return bridgeConfig.getLocalPorts(ifaceIds);
- }
-
- private DeviceId getController(DeviceId deviceId) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- for (Device device : devices) {
- if (device.type() == Device.Type.CONTROLLER && device.id()
- .toString().contains(getControllerIpOfSwitch(deviceId))) {
- return device.id();
- }
- }
- log.info("Can not find controller for device : {}", deviceId);
- return null;
- }
-
- //Used to apply flowRule
- private void flowServiceForward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
- Driver driver = driverService.getDriver(DRIVER_NAME);
- Pipeliner pipeLiner = driver.createBehaviour(new DefaultDriverData(driver, deviceId), Pipeliner.class);
- if (pipeLiner != null) {
- final PipelinerContext context = new InnerPipelineContext();
- pipeLiner.init(deviceId, context);
- pipeLiner.forward(forwardingObjective);
- }
- }
-
- // Processing context for initializing pipeline driver behaviours.
- private class InnerPipelineContext implements PipelinerContext {
- @Override
- public ServiceDirectory directory() {
- return serviceDirectory;
- }
-
- @Override
- public FlowObjectiveStore store() {
- return flowObjectiveStore;
- }
- }
-
-}
diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/package-info.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/package-info.java
deleted file mode 100644
index f18dbf8a..00000000
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.impl;
diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/package-info.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/package-info.java
deleted file mode 100644
index 371466c3..00000000
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn;
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
index deb9ca37..251dcffc 100644
--- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
+++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
@@ -69,8 +69,8 @@ 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 not found";
+ public static final String SUBNET_NOT_CREATED = "Subnet failed to create!";
+ public static final String SUBNET_NOT_FOUND = "Subnet is not found";
public static final String JSON_NOT_NULL = "JsonNode can not be null";
@GET
@@ -111,11 +111,11 @@ public class SubnetWebResource extends AbstractWebResource {
Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
Boolean result = nullIsNotFound((get(SubnetService.class)
.createSubnets(subnets)),
- SUBNET_NOT_CREATE);
+ SUBNET_NOT_CREATED);
if (!result) {
return Response.status(INTERNAL_SERVER_ERROR)
- .entity(SUBNET_NOT_CREATE).build();
+ .entity(SUBNET_NOT_CREATED).build();
}
return Response.status(202).entity(result.toString()).build();
} catch (Exception e) {
diff --git a/framework/src/onos/apps/vtnrsc/pom.xml b/framework/src/onos/apps/vtnrsc/pom.xml
deleted file mode 100644
index 0874f6d9..00000000
--- a/framework/src/onos/apps/vtnrsc/pom.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-apps</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
-
- <artifactId>onos-app-vtnrsc</artifactId>
- <packaging>bundle</packaging>
-
- <properties>
- <onos.app.name>org.onosproject.vtnrsc</onos.app.name>
- </properties>
- <dependencies>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-cli</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-junit</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-core-serializers</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
-
-</project>
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
deleted file mode 100644
index 4e1028d8..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-
-/**
- * Immutable representation of a allowed address pair.
- */
-public final class AllowedAddressPair {
- private final IpAddress ip;
- private final MacAddress mac;
- // Public construction is prohibited
- private AllowedAddressPair(IpAddress ip, MacAddress mac) {
- checkNotNull(ip, "IpAddress cannot be null");
- checkNotNull(mac, "MacAddress cannot be null");
- this.ip = ip;
- this.mac = mac;
- }
- /**
- * Returns the AllowedAddressPair ip address.
- *
- * @return ip address
- */
- public IpAddress ip() {
- return ip;
- }
-
- /**
- * Returns the AllowedAddressPair MAC address.
- *
- * @return MAC address
- */
- public MacAddress mac() {
- return mac;
- }
-
-
- /**
- * Creates a allowedAddressPair using the supplied ipAddress &amp;
- * macAddress.
- *
- * @param ip IP address
- * @param mac MAC address
- * @return AllowedAddressPair
- */
- public static AllowedAddressPair allowedAddressPair(IpAddress ip,
- MacAddress mac) {
- return new AllowedAddressPair(ip, mac);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ip, mac);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AllowedAddressPair) {
- final AllowedAddressPair that = (AllowedAddressPair) obj;
- return Objects.equals(this.ip, that.ip)
- && Objects.equals(this.mac, that.mac);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("ip", ip).add("mac", mac).toString();
- }
-
-}
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
deleted file mode 100644
index c715d08a..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index 8a480194..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index 8679100d..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index 6049b558..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Objects;
-import java.util.Set;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Default implementation of Subnet interface .
- */
-public final class DefaultSubnet implements Subnet {
- private final SubnetId id;
- private final String subnetName;
- private final TenantNetworkId networkId;
- private final TenantId tenantId;
- private final Version ipVersion;
- private final IpPrefix cidr;
- private final IpAddress gatewayIp;
- private final boolean dhcpEnabled;
- private final boolean shared;
- private final Mode ipV6AddressMode;
- private final Mode ipV6RaMode;
- private final Set<HostRoute> hostRoutes;
- private final Set<AllocationPool> allocationPools;
-
- /**
- * Creates a subnet object.
- *
- * @param id subnet identifier
- * @param subnetName the name of subnet
- * @param networkId network identifier
- * @param tenantId tenant identifier
- * @param ipVersion Version of ipv4 or ipv6
- * @param cidr the cidr
- * @param gatewayIp gateway ip
- * @param dhcpEnabled dhcp enabled or not
- * @param shared indicates whether this network is shared across all
- * tenants, By default, only administrative user can change this
- * value
- * @param hostRoutes a collection of host routes
- * @param ipV6AddressMode ipV6AddressMode
- * @param ipV6RaMode ipV6RaMode
- * @param allocationPoolsIt a collection of allocationPools
- */
- public DefaultSubnet(SubnetId id, String subnetName,
- TenantNetworkId networkId, TenantId tenantId,
- Version ipVersion, IpPrefix cidr, IpAddress gatewayIp,
- boolean dhcpEnabled, boolean shared,
- Set<HostRoute> hostRoutes, Mode ipV6AddressMode,
- Mode ipV6RaMode,
- Set<AllocationPool> allocationPoolsIt) {
- this.id = id;
- this.subnetName = subnetName;
- this.networkId = networkId;
- this.tenantId = tenantId;
- this.ipVersion = ipVersion;
- this.cidr = cidr;
- this.gatewayIp = gatewayIp;
- this.dhcpEnabled = dhcpEnabled;
- this.shared = shared;
- this.ipV6AddressMode = ipV6AddressMode;
- this.ipV6RaMode = ipV6RaMode;
- this.hostRoutes = hostRoutes;
- this.allocationPools = allocationPoolsIt;
- }
-
- @Override
- public SubnetId id() {
- return id;
- }
-
- @Override
- public String subnetName() {
- return subnetName;
- }
-
- @Override
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public Version ipVersion() {
- return ipVersion;
- }
-
- @Override
- public IpPrefix cidr() {
- return cidr;
- }
-
- @Override
- public IpAddress gatewayIp() {
- return gatewayIp;
- }
-
- @Override
- public boolean dhcpEnabled() {
- return dhcpEnabled;
- }
-
- @Override
- public boolean shared() {
- return shared;
- }
-
- @Override
- public Iterable<HostRoute> hostRoutes() {
- return hostRoutes;
- }
-
- @Override
- public Mode ipV6AddressMode() {
- return ipV6AddressMode;
- }
-
- @Override
- public Mode ipV6RaMode() {
- return ipV6RaMode;
- }
-
- @Override
- public Iterable<AllocationPool> allocationPools() {
- return allocationPools;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, subnetName, ipVersion, cidr, gatewayIp,
- dhcpEnabled, shared, tenantId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultSubnet) {
- final DefaultSubnet that = (DefaultSubnet) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.subnetName, that.subnetName)
- && Objects.equals(this.ipVersion, that.ipVersion)
- && Objects.equals(this.cidr, that.cidr)
- && Objects.equals(this.shared, that.shared)
- && Objects.equals(this.gatewayIp, that.gatewayIp)
- && Objects.equals(this.dhcpEnabled, that.dhcpEnabled);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("subnetName", subnetName)
- .add("ipVersion", ipVersion).add("cidr", cidr)
- .add("shared", shared).add("gatewayIp", gatewayIp)
- .add("dhcpEnabled", dhcpEnabled).toString();
- }
-
-}
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
deleted file mode 100644
index 8c941ea2..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index 9ee85da7..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-
-/**
- * Default implementation of VirtualPort interface .
- */
-public final class DefaultVirtualPort implements VirtualPort {
- private final VirtualPortId id;
- private final TenantNetworkId networkId;
- private final Boolean adminStateUp;
- private final String name;
- private final State state;
- private final MacAddress macAddress;
- private final TenantId tenantId;
- private final String deviceOwner;
- private final DeviceId deviceId;
- private final Set<FixedIp> fixedIps;
- private final BindingHostId bindingHostId;
- private final String bindingVnicType;
- private final String bindingVifType;
- private final String bindingVifDetails;
- private final Set<AllowedAddressPair> allowedAddressPairs;
- private final Set<SecurityGroup> securityGroups;
-
- /**
- * Creates a VirtualPort object.
- *
- * @param id the virtual port identifier
- * @param networkId the network identifier
- * @param adminStateUp adminStateup true or false
- * @param strMap the map of properties of virtual port
- * @param state virtual port state
- * @param macAddress the MAC address
- * @param tenantId the tenant identifier
- * @param deviceId the device identifier
- * @param fixedIps set of fixed IP
- * @param bindingHostId the binding host identifier
- * @param allowedAddressPairs the collection of allowdeAddressPairs
- * @param securityGroups the collection of securityGroups
- */
- public DefaultVirtualPort(VirtualPortId id,
- TenantNetworkId networkId,
- Boolean adminStateUp,
- Map<String, String> strMap,
- State state,
- MacAddress macAddress,
- TenantId tenantId,
- DeviceId deviceId,
- Set<FixedIp> fixedIps,
- BindingHostId bindingHostId,
- Set<AllowedAddressPair> allowedAddressPairs,
- Set<SecurityGroup> securityGroups) {
- this.id = id;
- this.networkId = networkId;
- this.adminStateUp = adminStateUp;
- this.name = strMap.get("name");
- this.state = state;
- this.macAddress = macAddress;
- this.tenantId = tenantId;
- this.deviceOwner = strMap.get("deviceOwner");
- this.deviceId = deviceId;
- this.fixedIps = fixedIps;
- this.bindingHostId = bindingHostId;
- this.bindingVnicType = strMap.get("bindingVnicType");
- this.bindingVifType = strMap.get("bindingVifType");
- this.bindingVifDetails = strMap.get("bindingVifDetails");
- this.allowedAddressPairs = allowedAddressPairs;
- this.securityGroups = securityGroups;
- }
-
- @Override
- public VirtualPortId portId() {
- return id;
- }
-
- @Override
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public boolean adminStateUp() {
- return adminStateUp;
- }
-
- @Override
- public State state() {
- return state;
- }
-
- @Override
- public MacAddress macAddress() {
- return macAddress;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public DeviceId deviceId() {
- return deviceId;
- }
-
- @Override
- public String deviceOwner() {
- return deviceOwner;
- }
-
- @Override
- public Collection<AllowedAddressPair> allowedAddressPairs() {
- return allowedAddressPairs;
- }
-
- @Override
- public Set<FixedIp> fixedIps() {
- return fixedIps;
- }
-
- @Override
- public BindingHostId bindingHostId() {
- return bindingHostId;
- }
-
- @Override
- public String bindingVnicType() {
- return bindingVifType;
- }
-
- @Override
- public String bindingVifType() {
- return bindingVifType;
- }
-
- @Override
- public String bindingVifDetails() {
- return bindingVifDetails;
- }
-
- @Override
- public Collection<SecurityGroup> securityGroups() {
- return securityGroups;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, networkId, adminStateUp, name, state,
- macAddress, tenantId, deviceId, deviceOwner,
- allowedAddressPairs, fixedIps, bindingHostId,
- bindingVnicType, bindingVifType, bindingVifDetails,
- securityGroups);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultVirtualPort) {
- final DefaultVirtualPort that = (DefaultVirtualPort) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.networkId, that.networkId)
- && Objects.equals(this.adminStateUp, that.adminStateUp)
- && Objects.equals(this.state, that.state)
- && Objects.equals(this.name, that.name)
- && Objects.equals(this.tenantId, that.tenantId)
- && Objects.equals(this.macAddress, that.macAddress)
- && Objects.equals(this.deviceId, that.deviceId)
- && Objects.equals(this.deviceOwner, that.deviceOwner)
- && Objects.equals(this.allowedAddressPairs,
- that.allowedAddressPairs)
- && Objects.equals(this.fixedIps, that.fixedIps)
- && Objects.equals(this.bindingHostId, that.bindingHostId)
- && Objects.equals(this.bindingVifDetails,
- that.bindingVifDetails)
- && Objects.equals(this.bindingVifType, that.bindingVifType)
- && Objects.equals(this.bindingVnicType,
- that.bindingVnicType)
- && Objects.equals(this.securityGroups, that.securityGroups);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("network_id", networkId)
- .add("adminStateUp", adminStateUp).add("state", state)
- .add("name", name).add("state", state)
- .add("macAddress", macAddress).add("tenantId", tenantId)
- .add("deviced", deviceId).add("deviceOwner", deviceOwner)
- .add("allowedAddressPairs", allowedAddressPairs)
- .add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)
- .add("bindingVnicType", bindingVnicType)
- .add("bindingVifDetails", bindingVifDetails)
- .add("bindingVifType", bindingVifType)
- .add("securityGroups", securityGroups).toString();
- }
-
-}
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
deleted file mode 100644
index c6569a7b..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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/PhysicalNetwork.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
deleted file mode 100644
index e96e666a..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index 9ec1dc63..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index a076265f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index f563a78f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Representation of a subnet.
- */
-public interface Subnet {
-
- /**
- * Coarse classification of the type of the ipV6Mode.
- */
- enum Mode {
- DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC
- }
-
- /**
- * Returns the subnet identifier.
- *
- * @return identifier
- */
- SubnetId id();
-
- /**
- * Returns the name of the subnet.
- *
- * @return subnetName
- */
- String subnetName();
-
- /**
- * Returns the network identifier.
- *
- * @return the network identifier
- */
- TenantNetworkId networkId();
-
- /**
- * Returns tenant identifier.
- *
- * @return the tenant identifier
- */
- TenantId tenantId();
-
- /**
- * Returns the IP version, which is 4 or 6.
- *
- * @return ipVersion
- */
- Version ipVersion();
-
- /**
- * Returns the cidr.
- *
- * @return cidr
- */
- IpPrefix cidr();
-
- /**
- * Returns the gateway IP address.
- *
- * @return gatewayIp
- */
- IpAddress gatewayIp();
-
- /**
- * Returns true if DHCP is enabled and return false if DHCP is disabled.
- *
- * @return true or false
- */
- boolean dhcpEnabled();
-
- /**
- * Indicates whether this tenantNetwork is shared across all tenants. By
- * default, only administrative user can change this value.
- *
- * @return true or false
- */
- boolean shared();
-
- /**
- * Returns a collection of hostRoutes.
- *
- * @return a collection of hostRoutes
- */
- Iterable<HostRoute> hostRoutes();
-
- /**
- * Returns the ipV6AddressMode. A valid value is dhcpv6-stateful,
- * dhcpv6-stateless, or slaac.
- *
- * @return ipV6AddressMode whose value is dhcpv6-stateful, dhcpv6-stateless
- * or slaac
- */
- Mode ipV6AddressMode();
-
- /**
- * Returns the ipV6RaMode.A valid value is dhcpv6-stateful,
- * dhcpv6-stateless, or slaac.
- *
- * @return ipV6RaMode whose value is dhcpv6-stateful, dhcpv6-stateless or
- * slaac
- */
- Mode ipV6RaMode();
-
- /**
- * Returns a collection of allocation_pools.
- *
- * @return a collection of allocationPools
- */
- Iterable<AllocationPool> allocationPools();
-}
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
deleted file mode 100644
index 4bcc3329..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index c4d99e49..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index 256352f4..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index fbb9e480..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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
deleted file mode 100644
index d2d7c146..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-
-/**
- * Representation of the VirtualPort.
- */
-public interface VirtualPort {
- /**
- * Coarse classification of the type of the virtual port.
- */
- enum State {
- /**
- * Signifies that a virtualPort is currently active,This state mean that
- * this virtualPort is available.
- */
- ACTIVE,
- /**
- * Signifies that a virtualPort is currently unavailable.
- */
- DOWN;
- }
-
- /**
- * Returns the virtualPort identifier.
- *
- * @return virtualPort identifier
- */
- VirtualPortId portId();
-
- /**
- * Returns the network identifier.
- *
- * @return tenantNetwork identifier
- */
- TenantNetworkId networkId();
-
- /**
- * Returns the symbolic name for the virtualPort.
- *
- * @return virtualPort name
- */
- String name();
-
- /**
- * Returns the administrative status of the port,which is up(true) or
- * down(false).
- *
- * @return true if the administrative status of the port is up
- */
- boolean adminStateUp();
-
- /**
- * Returns the state.
- *
- * @return state
- */
- State state();
-
- /**
- * Returns the MAC address.
- *
- * @return MAC Address
- */
- MacAddress macAddress();
-
- /**
- * Returns the port tenantId.
- *
- * @return port tenantId
- */
- TenantId tenantId();
-
- /**
- * Returns the device identifier.
- *
- * @return deviceId
- */
- DeviceId deviceId();
-
- /**
- * Returns the identifier of the entity that uses this port.
- *
- * @return deviceOwner
- */
- String deviceOwner();
-
- /**
- * Returns the virtualPort allowedAddressPairs.
- *
- * @return virtualPort allowedAddressPairs
- */
- Collection<AllowedAddressPair> allowedAddressPairs();
-
- /**
- * Returns set of IP addresses for the port, include the IP addresses and subnet
- * identity.
- *
- * @return FixedIps Set of fixedIp
- */
- Set<FixedIp> fixedIps();
-
- /**
- * Returns the virtualPort bindinghostId.
- *
- * @return virtualPort bindinghostId
- */
- BindingHostId bindingHostId();
-
- /**
- * Returns the virtualPort bindingVnicType.
- *
- * @return virtualPort bindingVnicType
- */
- String bindingVnicType();
-
- /**
- * Returns the virtualPort bindingVifType.
- *
- * @return virtualPort bindingVifType
- */
- String bindingVifType();
-
- /**
- * Returns the virtualPort bindingvifDetail.
- *
- * @return virtualPort bindingvifDetail
- */
- String bindingVifDetails();
-
- /**
- * Returns the security groups.
- *
- * @return port security groups
- */
- Iterable<SecurityGroup> securityGroups();
-}
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
deleted file mode 100644
index 3038bdff..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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/TenantNetworkCreateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java
deleted file mode 100644
index bcfdacfa..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-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 com.google.common.collect.Sets;
-
-/**
- * Supports for creating a TenantNetwork.
- */
-@Command(scope = "onos", name = "tenantnetwork-create",
- description = "Supports for creating a TenantNetwork")
-public class TenantNetworkCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork network id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "tenantID", description = "The tenant id of TenantNetwork",
- required = true, multiValued = false)
- String tenantID = null;
-
- @Argument(index = 2, name = "type", description = "The type of TenantNetwork", required = true,
- multiValued = false)
- String type = null;
-
- @Argument(index = 3, name = "segmentationID", description = "The segmentation id of TenantNetwork",
- required = true, multiValued = false)
- String segmentationID = "";
-
- @Option(name = "-n", aliases = "--name", description = "TenantNetwork name", required = false,
- multiValued = false)
- String name = null;
-
- @Option(name = "-a", aliases = "--adminStateUp", description = "TenantNetwork adminStateUp is true or false",
- required = false, multiValued = false)
- boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "The state of TenantNetwork",
- required = false, multiValued = false)
- String state = null;
-
- @Option(name = "-d", aliases = "--shared", description = "TenantNetwork is shared or not",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-r", aliases = "--routerExternal",
- description = "TenantNetwork is routerExternal or not", required = false,
- multiValued = false)
- boolean routerExternal = false;
-
- @Option(name = "-p", aliases = "--physicalNetwork", description = "The physical network of Tenant",
- required = false, multiValued = false)
- String physicalNetwork = "";
-
- @Override
- protected void execute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- TenantNetwork network = new DefaultTenantNetwork(TenantNetworkId.networkId(id), name,
- adminStateUp,
- TenantNetwork.State.valueOf(state),
- shared, TenantId.tenantId(tenantID),
- routerExternal,
- TenantNetwork.Type.valueOf(type),
- PhysicalNetwork.physicalNetwork(physicalNetwork),
- SegmentationId.segmentationId(segmentationID));
-
- Set<TenantNetwork> networksSet = Sets.newHashSet(network);
- service.createNetworks(networksSet);
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java
deleted file mode 100644
index 47ea83c2..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-/**
- * Supports for querying TenantNetworks by network id.
- */
-@Command(scope = "onos", name = "tenantnetworks", description = "Supports for querying"
- + "tenantNetworks by networkid")
-public class TenantNetworkQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-i", aliases = "--id", description = "TenantNetwork id", required = false,
- multiValued = false)
- String id = null;
-
- private static final String FMT = "networkId=%s, networkName=%s, segmentationId=%s,"
- + "tenantId=%s, type=%s, adminStateUp=%s";
-
- @Override
- protected void execute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- if (id != null) {
- TenantNetwork network = service.getNetwork(TenantNetworkId.networkId(id));
- printNetwork(network);
- } else {
- Iterable<TenantNetwork> networks = service.getNetworks();
- for (TenantNetwork network : networks) {
- printNetwork(network);
- }
- }
- }
-
- private void printNetwork(TenantNetwork network) {
- if (network == null) {
- return;
- }
- print(FMT, network.id(), network.name(), network.segmentationId(),
- network.tenantId(), network.type(), network.adminStateUp());
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java
deleted file mode 100644
index 0ea22853..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a TenantNetwork by network id.
- */
-@Command(scope = "onos", name = "tenantnetwork-remove", description = "Supports for removing"
- + " a tenantNetwork by tenantNetworkid")
-public class TenantNetworkRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork neutronNetwork Id",
- required = true, multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- Set<TenantNetworkId> networkIds = Sets.newHashSet(TenantNetworkId.networkId(id));
- service.removeNetworks(networkIds);
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java
deleted file mode 100644
index 2a738f72..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-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 com.google.common.collect.Sets;
-
-/**
- * Supports for updating a TenantNetwork.
- */
-@Command(scope = "onos", name = "tenantnetwork-update",
- description = "Supports for updating a TenantNetwork")
-public class TenantNetworkUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork network id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "tenantID", description = "The tenant id of TenantNetwork",
- required = true, multiValued = false)
- String tenantID = null;
-
- @Argument(index = 2, name = "type", description = "The type of TenantNetwork", required = true,
- multiValued = false)
- String type = null;
-
- @Argument(index = 3, name = "segmentationID", description = "The segmentation id of TenantNetwork",
- required = true, multiValued = false)
- String segmentationID = "";
-
- @Option(name = "-n", aliases = "--name", description = "TenantNetwork name", required = false,
- multiValued = false)
- String name = null;
-
- @Option(name = "-a", aliases = "--adminStateUp", description = "TenantNetwork adminStateUp is true or false",
- required = false, multiValued = false)
- boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "The state of TenantNetwork",
- required = false, multiValued = false)
- String state = null;
-
- @Option(name = "-d", aliases = "--shared", description = "TenantNetwork is shared or not",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-r", aliases = "--routerExternal",
- description = "TenantNetwork is routerExternal or not", required = false,
- multiValued = false)
- boolean routerExternal = false;
-
- @Option(name = "-p", aliases = "--physicalNetwork", description = "The physical network of Tenant",
- required = false, multiValued = false)
- String physicalNetwork = "";
-
- @Override
- protected void execute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- TenantNetwork network = new DefaultTenantNetwork(TenantNetworkId.networkId(id), name,
- adminStateUp,
- TenantNetwork.State.valueOf(state),
- shared, TenantId.tenantId(tenantID),
- routerExternal,
- TenantNetwork.Type.valueOf(type),
- PhysicalNetwork.physicalNetwork(physicalNetwork),
- SegmentationId.segmentationId(segmentationID));
-
- Set<TenantNetwork> networksSet = Sets.newHashSet();
- networksSet.add(network);
- service.updateNetworks(networksSet);
- }
-
-}
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
deleted file mode 100644
index 1622c800..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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/SubnetCreateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetCreateCommand.java
deleted file mode 100644
index 56236408..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetCreateCommand.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for creating a subnet.
- */
-@Command(scope = "onos", name = "subnet-create", description = "Supports for creating a subnet")
-public class SubnetCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet Id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "subnetName", description = "Subnet String name", required = true,
- multiValued = false)
- String subnetName = null;
-
- @Argument(index = 2, name = "networkId", description = "Subnet Network Id", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 3, name = "tenantId", description = "Subnet Tenant Id", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Option(name = "-i", aliases = "--ipVersion", description = "Subnet Version ipVersion",
- required = false, multiValued = false)
- Version ipVersion = null;
-
- @Option(name = "-c", aliases = "--cidr", description = "Subnet IpPrefix cidr",
- required = false, multiValued = false)
- String cidr = "0.0.0.0/0";
-
- @Option(name = "-g", aliases = "--gatewayIp", description = "Subnet IpAddress gatewayIp",
- required = false, multiValued = false)
- String gatewayIp = "0.0.0.0";
-
- @Option(name = "-d", aliases = "--dhcpEnabled", description = "Subnet boolean dhcpEnabled",
- required = false, multiValued = false)
- boolean dhcpEnabled = false;
-
- @Option(name = "-s", aliases = "--shared", description = "Subnet boolean shared",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-m", aliases = "--ipV6AddressMode",
- description = "Subnet Mode ipV6AddressMode", required = false, multiValued = false)
- String ipV6AddressMode = null;
-
- @Option(name = "-r", aliases = "--ipV6RaMode", description = "Subnet Mode ipV6RaMode",
- required = false, multiValued = false)
- String ipV6RaMode = null;
-
- @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes",
- required = false, multiValued = false)
- Set<HostRoute> hostRoutes = Sets.newHashSet();
-
- @Option(name = "-a", aliases = "--allocationPools",
- description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
- Set<AllocationPool> allocationPools = Sets.newHashSet();
-
- @Override
- protected void execute() {
- SubnetService service = get(SubnetService.class);
- if (id == null || networkId == null || tenantId == null) {
- print(null, "id,networkId,tenantId can not be null");
- return;
- }
- Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
- TenantNetworkId.networkId(networkId),
- TenantId.tenantId(tenantId), ipVersion,
- cidr == null ? null : IpPrefix.valueOf(cidr),
- gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
- dhcpEnabled, shared, hostRoutes,
- ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
- ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
- allocationPools);
-
- Set<Subnet> subnetsSet = Sets.newHashSet(subnet);
- service.createSubnets(subnetsSet);
- }
-
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java
deleted file mode 100644
index f5a94f0f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-/**
- * Supports for querying a subnet.
- */
-@Command(scope = "onos", name = "subnets", description = "Supports for querying a subnet")
-public class SubnetQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-i", aliases = "--id", description = "Subnet id", required = false,
- multiValued = false)
- String id = null;
-
- private static final String FMT = "subnetId=%s, networkId=%s, subnetName=%s,"
- + "tenantId=%s, cidr=%s, dhcpEnabled=%s, gatewayIp=%s," + "ipVersion=%s";
-
- @Override
- protected void execute() {
- SubnetService service = get(SubnetService.class);
- if (id != null) {
- Subnet subnet = service.getSubnet(SubnetId.subnetId(id));
- printSubnet(subnet);
- } else {
- Iterable<Subnet> subnets = service.getSubnets();
- if (subnets == null) {
- return;
- }
- for (Subnet subnet : subnets) {
- printSubnet(subnet);
- }
- }
- }
-
- private void printSubnet(Subnet subnet) {
- print(FMT, subnet.id(), subnet.networkId(), subnet.subnetName(),
- subnet.tenantId(), subnet.cidr(), subnet.dhcpEnabled(), subnet
- .gatewayIp(), subnet.ipVersion());
-
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java
deleted file mode 100644
index 241af87e..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a subnet.
- */
-@Command(scope = "onos", name = "subnet-remove", description = "Supports for removing a subnet")
-public class SubnetRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet SubnetId Id", required = true,
- multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- SubnetService service = get(SubnetService.class);
- Set<SubnetId> subnetsSet = Sets.newHashSet();
- subnetsSet.add(SubnetId.subnetId(id));
- service.removeSubnets(subnetsSet);
- }
-
-}
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
deleted file mode 100644
index b0578a1e..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for updating a subnet.
- */
-@Command(scope = "onos", name = "subnet-update", description = "Supports for updating a subnet")
-public class SubnetUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet Id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "subnetName", description = "Subnet String name", required = true,
- multiValued = false)
- String subnetName = null;
-
- @Argument(index = 2, name = "networkId", description = "Subnet Network Id", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 3, name = "tenantId", description = "Subnet Tenant Id", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Option(name = "-i", aliases = "--ipVersion", description = "Subnet Version ipVersion",
- required = false, multiValued = false)
- Version ipVersion = null;
-
- @Option(name = "-c", aliases = "--cidr", description = "Subnet IpPrefix cidr", required = false,
- multiValued = false)
- String cidr = "0.0.0.0/0";
-
- @Option(name = "-g", aliases = "--gatewayIp", description = "Subnet IpAddress gatewayIp",
- required = false, multiValued = false)
- String gatewayIp = "0.0.0.0";
-
- @Option(name = "-d", aliases = "--dhcpEnabled", description = "Subnet boolean dhcpEnabled",
- required = false, multiValued = false)
- boolean dhcpEnabled = false;
-
- @Option(name = "-s", aliases = "--shared", description = "Subnet boolean shared", required = false,
- multiValued = false)
- boolean shared = false;
-
- @Option(name = "-m", aliases = "--ipV6AddressMode", description = "Subnet Mode ipV6AddressMode",
- required = false, multiValued = false)
- String ipV6AddressMode = null;
-
- @Option(name = "-r", aliases = "--ipV6RaMode", description = "Subnet Mode ipV6RaMode",
- required = false, multiValued = false)
- String ipV6RaMode = null;
-
- @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes",
- required = false, multiValued = false)
- Set<HostRoute> hostRoutes = Sets.newHashSet();
-
- @Option(name = "-a", aliases = "--allocationPools",
- description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
- Set<AllocationPool> allocationPools = Sets.newHashSet();
-
- @Override
- protected void execute() {
- SubnetService service = get(SubnetService.class);
- if (id == null || networkId == null || tenantId == null) {
- print(null, "id,networkId,tenantId can not be null");
- return;
- }
- Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
- TenantNetworkId.networkId(networkId),
- TenantId.tenantId(tenantId), ipVersion,
- cidr == null ? null : IpPrefix.valueOf(cidr),
- gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
- dhcpEnabled, shared, hostRoutes,
- ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
- ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
- allocationPools);
- Set<Subnet> subnetsSet = Sets.newHashSet();
- subnetsSet.add(subnet);
- service.updateSubnets(subnetsSet);
- }
-
-}
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
deleted file mode 100644
index b3a2ff51..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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/VirtualPortCreateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortCreateCommand.java
deleted file mode 100644
index 4c555e33..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortCreateCommand.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-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.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Supports for creating a virtualPort.
- */
-@Command(scope = "onos", name = "virtualport-create",
- description = "Supports for creating a virtualPort.")
-public class VirtualPortCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "networkId", description = "network id.", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 2, name = "name", description = "virtualPort name.", required = true,
- multiValued = false)
- String name = null;
-
- @Argument(index = 3, name = "tenantId", description = "tenant id.", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Argument(index = 4, name = "deviceId", description = "device id.", required = true,
- multiValued = false)
- String deviceId = null;
-
- @Option(name = "-a", aliases = "--adminStateUp",
- description = "administrative status of the virtualPort which is true or false.",
- required = false, multiValued = false)
- Boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "virtualPort state.", required = false,
- multiValued = false)
- String state = null;
-
- @Option(name = "-m", aliases = "--macAddress", description = "MAC address.", required = false,
- multiValued = false)
- String macAddress = "";
-
- @Option(name = "-d", aliases = "--deviceOwner", description = "ID of the entity that uses this "
- + "virtualPort.", required = false, multiValued = false)
- String deviceOwner = null;
-
- @Option(name = "-f", aliases = "--fixedIp",
- description = "The IP address for the port,include the IP address "
- + "and subnet identity.", required = false, multiValued = false)
- FixedIp fixedIp = null;
-
- @Option(name = "-i", aliases = "--bindingHostId", description = "virtualPort bindingHostId.",
- required = false, multiValued = false)
- String bindingHostId = null;
-
- @Option(name = "-t", aliases = "--bindingvnicType", description = "virtualPort bindingvnicType.",
- required = false, multiValued = false)
- String bindingvnicType = null;
-
- @Option(name = "-v", aliases = "--bindingvifType", description = "virtualPort bindingvifType.",
- required = false, multiValued = false)
- String bindingvifType = null;
-
- @Option(name = "-b", aliases = "--bindingvnicDetails",
- description = "virtualPort bindingvnicDetails.", required = false, multiValued = false)
- String bindingvnicDetails = null;
-
- @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.",
- required = false, multiValued = false)
- Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
-
- @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.",
- required = false, multiValued = false)
- Set<SecurityGroup> securityGroups = Sets.newHashSet();
-
- @Override
- protected void execute() {
- Map<String, String> strMap = Maps.newHashMap();
- strMap.putIfAbsent("name", name);
- strMap.putIfAbsent("deviceOwner", deviceOwner);
- strMap.putIfAbsent("bindingvnicType", bindingvnicType);
- strMap.putIfAbsent("bindingvifType", bindingvifType);
- strMap.putIfAbsent("bindingvnicDetails", bindingvnicDetails);
- VirtualPortService service = get(VirtualPortService.class);
- VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId(id),
- TenantNetworkId.networkId(networkId),
- false, strMap, VirtualPort.State.ACTIVE,
- MacAddress.valueOf(macAddress),
- TenantId.tenantId(tenantId),
- DeviceId.deviceId(deviceId), Sets.newHashSet(fixedIp),
- BindingHostId.bindingHostId(bindingHostId),
- allowedAddressPairs, securityGroups);
- Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
- service.createPorts(virtualPorts);
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java
deleted file mode 100644
index 47126d1b..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Collection;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-/**
- * Supports for querying virtualPorts.
- */
-@Command(scope = "onos", name = "virtualports", description = "Supports for querying virtualPorts.")
-public class VirtualPortQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-v", aliases = "--vPortId", description = "virtualPort ID.", required = false,
- multiValued = false)
- String vPortId;
-
- @Option(name = "-n", aliases = "--networkId", description = "network ID.", required = false,
- multiValued = false)
- String networkId;
-
- @Option(name = "-d", aliases = "--deviceId", description = "device ID.", required = false,
- multiValued = false)
- String deviceId;
-
- @Option(name = "-t", aliases = "--tenantId", description = "tenant ID.", required = false,
- multiValued = false)
- String tenantId;
-
- private static final String FMT = "virtualPortId=%s, networkId=%s, name=%s,"
- + " tenantId=%s, deviceId=%s, adminStateUp=%s, state=%s,"
- + " macAddress=%s, deviceOwner=%s, fixedIp=%s, bindingHostId=%s,"
- + " bindingvnicType=%s, bindingvifType=%s, bindingvnicDetails=%s,"
- + " allowedAddress=%s, securityGroups=%s";
-
- @Override
- protected void execute() {
- VirtualPortService service = get(VirtualPortService.class);
- if (vPortId != null && networkId == null && deviceId == null && tenantId == null) {
- VirtualPort port = service.getPort(VirtualPortId.portId(vPortId));
- printPort(port);
- } else if (vPortId == null && networkId != null && deviceId == null && tenantId == null) {
- Collection<VirtualPort> ports = service.getPorts(TenantNetworkId.networkId(networkId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId != null && tenantId == null) {
- Collection<VirtualPort> ports = service.getPorts(DeviceId.deviceId(deviceId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId == null && tenantId != null) {
- Collection<VirtualPort> ports = service.getPorts(DeviceId.deviceId(tenantId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId == null && tenantId == null) {
- Collection<VirtualPort> ports = service.getPorts();
- printPorts(ports);
- } else {
- print("cannot input more than one parameter");
- }
-
- }
-
- private void printPorts(Collection<VirtualPort> ports) {
- for (VirtualPort port : ports) {
- printPort(port);
- }
- }
-
- private void printPort(VirtualPort port) {
- print(FMT, port.portId(), port.networkId(), port.name(), port.tenantId(), port.deviceId(),
- port.adminStateUp(), port.state(), port.macAddress(), port.deviceOwner(), port
- .fixedIps(), port.bindingHostId(), port.bindingVnicType(),
- port.bindingVifType(), port.bindingVifDetails(), port.allowedAddressPairs(),
- port.securityGroups());
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java
deleted file mode 100644
index 1a3cb4f0..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a virtualPort.
- */
-@Command(scope = "onos", name = "virtualport-remove",
- description = "Supports for removing a virtualPort.")
-public class VirtualPortRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- VirtualPortService service = get(VirtualPortService.class);
- Set<VirtualPortId> virtualPorts = Sets.newHashSet(VirtualPortId.portId(id));
- service.removePorts(virtualPorts);
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java
deleted file mode 100644
index 6df4b23c..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-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.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Supports for updating a virtualPort.
- */
-@Command(scope = "onos", name = "virtualport-update",
- description = "Supports for updating a virtualPort.")
-public class VirtualPortUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "networkId", description = "network id.", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 2, name = "name", description = "virtualPort name.", required = true,
- multiValued = false)
- String name = null;
-
- @Argument(index = 3, name = "tenantId", description = "tenant id.", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Argument(index = 4, name = "deviceId", description = "device id.", required = true,
- multiValued = false)
- String deviceId = null;
-
- @Option(name = "-a", aliases = "--adminStateUp",
- description = "administrative status of the virtualPort which is true or false.",
- required = false, multiValued = false)
- Boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "virtualPort state.", required = false,
- multiValued = false)
- String state = null;
-
- @Option(name = "-m", aliases = "--macAddress", description = "MAC address.", required = false,
- multiValued = false)
- String macAddress = "";
-
- @Option(name = "-d", aliases = "--deviceOwner",
- description = "ID of the entity that uses this " + "virtualPort.", required = false,
- multiValued = false)
- String deviceOwner = null;
-
- @Option(name = "-f", aliases = "--fixedIp",
- description = "The IP address for the port,include the IP address "
- + "and subnet identity.", required = false, multiValued = false)
- FixedIp fixedIp = null;
-
- @Option(name = "-i", aliases = "--bindingHostId", description = "virtualPort bindingHostId.",
- required = false, multiValued = false)
- String bindingHostId = "";
-
- @Option(name = "-t", aliases = "--bindingvnicType",
- description = "virtualPort bindingvnicType.", required = false, multiValued = false)
- String bindingvnicType = null;
-
- @Option(name = "-v", aliases = "--bindingvifType", description = "virtualPort bindingvifType.",
- required = false, multiValued = false)
- String bindingvifType = null;
-
- @Option(name = "-b", aliases = "--bindingvnicDetails",
- description = "virtualPort bindingvnicDetails.", required = false, multiValued = false)
- String bindingvnicDetails = null;
-
- @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.",
- required = false, multiValued = false)
- Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
-
- @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.",
- required = false, multiValued = false)
- Set<SecurityGroup> securityGroups = Sets.newHashSet();
-
- @Override
- protected void execute() {
- VirtualPortService service = get(VirtualPortService.class);
- Map<String, String> strMap = Maps.newHashMap();
- strMap.putIfAbsent("name", name);
- strMap.putIfAbsent("deviceOwner", deviceOwner);
- strMap.putIfAbsent("bindingvnicType", bindingvnicType);
- strMap.putIfAbsent("bindingvifType", bindingvifType);
- strMap.putIfAbsent("bindingvnicDetails", bindingvnicDetails);
- VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId(id),
- TenantNetworkId.networkId(networkId),
- false, strMap, VirtualPort.State.ACTIVE,
- MacAddress.valueOf(macAddress),
- TenantId.tenantId(tenantId),
- DeviceId.deviceId(deviceId), Sets.newHashSet(fixedIp),
- BindingHostId.bindingHostId(bindingHostId),
- allowedAddressPairs, securityGroups);
- Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
- service.updatePorts(virtualPorts);
- }
-}
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
deleted file mode 100644
index fac214a1..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/package-info.java
deleted file mode 100644
index b245fb14..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN resources that used by virtual tenant network.
- */
-package org.onosproject.vtnrsc;
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
deleted file mode 100644
index 82eb9611..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.subnet;
-
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-
-
-/**
- * Service for interacting with the inventory of subnets.
- */
-public interface SubnetService {
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return true or false
- */
- boolean exists(SubnetId subnetId);
- /**
- * Returns a collection of the currently known subnets.
- *
- * @return iterable collection of subnets
- */
- Iterable<Subnet> getSubnets();
-
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return subnet or null if one with the given identifier is not known
- */
- Subnet getSubnet(SubnetId subnetId);
- /**
- * Creates new subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if the identifier subnet has been created right
- */
- boolean createSubnets(Iterable<Subnet> subnets);
-
- /**
- * Updates existing subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if all subnets were updated successfully
- */
- boolean updateSubnets(Iterable<Subnet> subnets);
-
- /**
- * Administratively removes the specified subnets from the store.
- *
- * @param subnetIds the iterable collection of subnets identifier
- * @return true if remove identifier subnets successfully
- */
- boolean removeSubnets(Iterable<SubnetId> subnetIds);
-
-
-}
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
deleted file mode 100644
index 890beb29..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.subnet.impl;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultAllocationPool;
-import org.onosproject.vtnrsc.DefaultHostRoute;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.slf4j.Logger;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the Subnet service.
- */
-@Component(immediate = true)
-@Service
-public class SubnetManager implements SubnetService {
-
- private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";
- private static final String SUBNET_NOT_NULL = "Subnet cannot be null";
- private static final String SUBNET = "vtn-subnet-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
-
- private final Logger log = getLogger(getClass());
-
- protected Map<SubnetId, Subnet> subnetStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TenantNetworkService tenantNetworkService;
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()
- .withName(SUBNET)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
- Subnet.class,
- SubnetId.class,
- TenantNetworkId.class,
- TenantId.class,
- HostRoute.class,
- DefaultHostRoute.class,
- Subnet.Mode.class,
- AllocationPool.class,
- DefaultAllocationPool.class,
- DefaultSubnet.class,
- IpAddress.Version.class))
- .build().asJavaMap();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public Iterable<Subnet> getSubnets() {
- return Collections.unmodifiableCollection(subnetStore.values());
- }
-
- @Override
- public Subnet getSubnet(SubnetId subnetId) {
- checkNotNull(subnetId, SUBNET_ID_NULL);
- return subnetStore.get(subnetId);
- }
-
- @Override
- public boolean exists(SubnetId subnetId) {
- checkNotNull(subnetId, SUBNET_ID_NULL);
- return subnetStore.containsKey(subnetId);
- }
-
- @Override
- public boolean createSubnets(Iterable<Subnet> subnets) {
- checkNotNull(subnets, SUBNET_NOT_NULL);
- for (Subnet subnet : subnets) {
- if (!tenantNetworkService.exists(subnet.networkId())) {
- log.debug("The network identifier that the subnet {} belong to is not exist",
- subnet.networkId().toString(), subnet.id().toString());
- return false;
- }
- subnetStore.put(subnet.id(), subnet);
- if (!subnetStore.containsKey(subnet.id())) {
- log.debug("The identified subnet whose identifier is {} create failed",
- subnet.id().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateSubnets(Iterable<Subnet> subnets) {
- checkNotNull(subnets, SUBNET_NOT_NULL);
- if (subnets != null) {
- for (Subnet subnet : subnets) {
- if (!subnetStore.containsKey(subnet.id())) {
- log.debug("The subnet is not exist whose identifier is {}",
- subnet.id().toString());
- return false;
- }
-
- subnetStore.put(subnet.id(), subnet);
-
- if (!subnet.equals(subnetStore.get(subnet.id()))) {
- log.debug("The subnet is updated failed whose identifier is {}",
- subnet.id().toString());
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean removeSubnets(Iterable<SubnetId> subnetIds) {
- checkNotNull(subnetIds, SUBNET_ID_NULL);
- if (subnetIds != null) {
- for (SubnetId subnetId : subnetIds) {
- subnetStore.remove(subnetId);
- if (subnetStore.containsKey(subnetId)) {
- log.debug("The subnet created is failed whose identifier is {}",
- subnetId.toString());
- return false;
- }
- }
- }
- return true;
- }
-
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java
deleted file mode 100644
index 79040d8d..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 7b2bdb90..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index e246cc4e..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.tenantnetwork;
-
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-
-/**
- * Service for interacting with the inventory of tenantNetwork.
- */
-public interface TenantNetworkService {
-
- /**
- * Returns if the tenantNetwork is existed.
- *
- * @param networkId tenantNetwork identifier
- * @return true or false if one with the given identifier exists.
- */
- boolean exists(TenantNetworkId networkId);
-
- /**
- * Returns the number of tenantNetwork known to the system.
- *
- * @return number of tenantNetwork.
- */
- int getNetworkCount();
-
- /**
- * Returns an iterable collection of the currently known tenantNetwork.
- *
- * @return collection of tenantNetwork.
- */
- Iterable<TenantNetwork> getNetworks();
-
- /**
- * Returns the tenantNetwork with the identifier.
- *
- * @param networkId TenantNetwork identifier
- * @return TenantNetwork or null if one with the given identifier is not
- * known.
- */
- TenantNetwork getNetwork(TenantNetworkId networkId);
-
- /**
- * Creates tenantNetworks by networks.
- *
- * @param networks the collection of tenantNetworks
- * @return true if all given identifiers created successfully.
- */
- boolean createNetworks(Iterable<TenantNetwork> networks);
-
- /**
- * Updates tenantNetworks by tenantNetworks.
- *
- * @param networks the collection of tenantNetworks
- * @return true if all given identifiers updated successfully.
- */
- boolean updateNetworks(Iterable<TenantNetwork> networks);
-
- /**
- * Deletes tenantNetwork by tenantNetworkIds.
- *
- * @param networksIds the collection of tenantNetworkIds
- * @return true if the specified tenantNetworks deleted successfully.
- */
- boolean removeNetworks(Iterable<TenantNetworkId> networksIds);
-}
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
deleted file mode 100644
index 0dfc99e2..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.tenantnetwork.impl;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.slf4j.Logger;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the tenantNetworkService.
- */
-@Component(immediate = true)
-@Service
-public class TenantNetworkManager implements TenantNetworkService {
-
- private static final String NETWORK_ID_NULL = "Network ID cannot be null";
- private static final String NETWORK_NOT_NULL = "Network ID cannot be null";
- private static final String TENANTNETWORK = "vtn-tenant-network-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
- protected Map<TenantNetworkId, TenantNetwork> networkIdAsKeyStore;
- protected ApplicationId appId;
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- networkIdAsKeyStore = storageService.<TenantNetworkId, TenantNetwork>consistentMapBuilder()
- .withName(TENANTNETWORK)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
- TenantNetworkId.class,
- DefaultTenantNetwork.class,
- TenantNetwork.State.class,
- TenantId.class,
- TenantNetwork.Type.class,
- PhysicalNetwork.class,
- SegmentationId.class))
- .build().asJavaMap();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORK_ID_NULL);
- return networkIdAsKeyStore.containsKey(networkId);
- }
-
- @Override
- public int getNetworkCount() {
- return networkIdAsKeyStore.size();
- }
-
- @Override
- public Iterable<TenantNetwork> getNetworks() {
- return Collections.unmodifiableCollection(networkIdAsKeyStore.values());
- }
-
- @Override
- public TenantNetwork getNetwork(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORK_ID_NULL);
- return networkIdAsKeyStore.get(networkId);
- }
-
- @Override
- public boolean createNetworks(Iterable<TenantNetwork> networks) {
- checkNotNull(networks, NETWORK_NOT_NULL);
- for (TenantNetwork network : networks) {
- networkIdAsKeyStore.put(network.id(), network);
- if (!networkIdAsKeyStore.containsKey(network.id())) {
- log.debug("The tenantNetwork is created failed which identifier was {}", network.id()
- .toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateNetworks(Iterable<TenantNetwork> networks) {
- checkNotNull(networks, NETWORK_NOT_NULL);
- for (TenantNetwork network : networks) {
- if (!networkIdAsKeyStore.containsKey(network.id())) {
- log.debug("The tenantNetwork is not exist whose identifier was {} ",
- network.id().toString());
- return false;
- }
-
- networkIdAsKeyStore.put(network.id(), network);
-
- if (!network.equals(networkIdAsKeyStore.get(network.id()))) {
- log.debug("The tenantNetwork is updated failed whose identifier was {} ",
- network.id().toString());
- return false;
- }
-
- }
- return true;
- }
-
- @Override
- public boolean removeNetworks(Iterable<TenantNetworkId> networkIds) {
- checkNotNull(networkIds, NETWORK_NOT_NULL);
- for (TenantNetworkId networkId : networkIds) {
- networkIdAsKeyStore.remove(networkId);
- if (networkIdAsKeyStore.containsKey(networkId)) {
- log.debug("The tenantNetwork is removed failed whose identifier was {}",
- networkId.toString());
- return false;
- }
- }
- return true;
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java
deleted file mode 100644
index f381fda6..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 1489c973..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 6f3cf653..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.tunnel;
-
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-
-
-/**
- * Service for interacting with the inventory of subnets.
- */
-public interface TunnelConfigService {
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return true or false
- */
- boolean exists(SubnetId subnetId);
- /**
- * Returns a collection of the currently known subnets.
- *
- * @return iterable collection of subnets
- */
- Iterable<Subnet> getSubnets();
-
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return subnet or null if one with the given identifier is not known
- */
- Subnet getSubnet(SubnetId subnetId);
- /**
- * Creates new subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if the identifier subnet has been created right
- */
- boolean createSubnets(Iterable<Subnet> subnets);
-
- /**
- * Updates existing subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if all subnets were updated successfully
- */
- boolean updateSubnets(Iterable<Subnet> subnets);
-
- /**
- * Administratively removes the specified subnets from the store.
- *
- * @param subnetIds the iterable collection of subnets identifier
- * @return true if remove identifier subnets successfully
- */
- boolean removeSubnets(Iterable<SubnetId> subnetIds);
-
-
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java
deleted file mode 100644
index 3a84e6e3..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 05ebccf9..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.virtualport;
-
-import java.util.Collection;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-
-/**
- * Service for interacting with the inventory of virtualPort.
- */
-public interface VirtualPortService {
- /**
- * Returns if the virtualPort is existed.
- *
- * @param virtualPortId virtualPort identifier
- * @return true or false if one with the given identifier is not existed.
- */
- boolean exists(VirtualPortId virtualPortId);
-
- /**
- * Returns the virtualPort with the identifier.
- *
- * @param virtualPortId virtualPort ID
- * @return VirtualPort or null if one with the given ID is not know.
- */
- VirtualPort getPort(VirtualPortId virtualPortId);
-
- /**
- * Returns the collection of the currently known virtualPort.
- * @return collection of VirtualPort.
- */
- Collection<VirtualPort> getPorts();
-
- /**
- * Returns the collection of the virtualPorts associated with the networkId.
- *
- * @param networkId the network identifer
- * @return collection of virtualPort.
- */
- Collection<VirtualPort> getPorts(TenantNetworkId networkId);
-
- /**
- * Returns the collection of the virtualPorts associated with the tenantId.
- *
- * @param tenantId the tenant identifier
- * @return collection of virtualPorts.
- */
- Collection<VirtualPort> getPorts(TenantId tenantId);
-
- /**
- * Returns the collection of the virtualPorts associated with the deviceId.
- *
- * @param deviceId the device identifier
- * @return collection of virtualPort.
- */
- Collection<VirtualPort> getPorts(DeviceId deviceId);
-
- /**
- * Creates virtualPorts by virtualPorts.
- *
- * @param virtualPorts the iterable collection of virtualPorts
- * @return true if all given identifiers created successfully.
- */
- boolean createPorts(Iterable<VirtualPort> virtualPorts);
-
- /**
- * Updates virtualPorts by virtualPorts.
- *
- * @param virtualPorts the iterable collection of virtualPorts
- * @return true if all given identifiers updated successfully.
- */
- boolean updatePorts(Iterable<VirtualPort> virtualPorts);
-
- /**
- * Deletes virtualPortIds by virtualPortIds.
- *
- * @param virtualPortIds the iterable collection of virtualPort identifiers
- * @return true or false if one with the given identifier to delete is
- * successfully.
- */
- boolean removePorts(Iterable<VirtualPortId> virtualPortIds);
-}
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
deleted file mode 100644
index bea0fd55..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.virtualport.impl;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Provides implementation of the VirtualPort APIs.
- */
-@Component(immediate = true)
-@Service
-public class VirtualPortManager implements VirtualPortService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private static final String VIRTUALPORT = "vtn-virtual-port";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
- private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null";
- private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null";
- private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
- private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
- private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
-
- protected Map<VirtualPortId, VirtualPort> vPortStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TenantNetworkService networkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder()
- .withName(VIRTUALPORT)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
- VirtualPortId.class,
- TenantNetworkId.class,
- VirtualPort.State.class,
- TenantId.class,
- AllowedAddressPair.class,
- FixedIp.class,
- BindingHostId.class,
- SecurityGroup.class,
- SubnetId.class,
- IpAddress.class,
- DefaultVirtualPort.class))
- .build().asJavaMap();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- vPortStore.clear();
- log.info("Stoppped");
- }
-
- @Override
- public boolean exists(VirtualPortId vPortId) {
- checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
- return vPortStore.containsKey(vPortId);
- }
-
- @Override
- public VirtualPort getPort(VirtualPortId vPortId) {
- checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
- return vPortStore.get(vPortId);
- }
-
- @Override
- public Collection<VirtualPort> getPorts() {
- return Collections.unmodifiableCollection(vPortStore.values());
- }
-
- @Override
- public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORKID_NOT_NULL);
- Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithNetworkIds) {
- if (!vPort.networkId().equals(networkId)) {
- vPortWithNetworkIds.remove(vPort);
- }
- }
- return vPortWithNetworkIds;
- }
-
- @Override
- public Collection<VirtualPort> getPorts(TenantId tenantId) {
- checkNotNull(tenantId, TENANTID_NOT_NULL);
- Collection<VirtualPort> vPortWithTenantIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithTenantIds) {
- if (!vPort.tenantId().equals(tenantId)) {
- vPortWithTenantIds.remove(vPort);
- }
- }
- return vPortWithTenantIds;
- }
-
- @Override
- public Collection<VirtualPort> getPorts(DeviceId deviceId) {
- checkNotNull(deviceId, DEVICEID_NOT_NULL);
- Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithDeviceIds) {
- if (!vPort.deviceId().equals(deviceId)) {
- vPortWithDeviceIds.remove(vPort);
- }
- }
- return vPortWithDeviceIds;
- }
-
- @Override
- public boolean createPorts(Iterable<VirtualPort> vPorts) {
- checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
- for (VirtualPort vPort : vPorts) {
- log.debug("vPortId is {} ", vPort.portId().toString());
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- log.debug("The virtualPort is created failed whose identifier is {} ",
- vPort.portId().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updatePorts(Iterable<VirtualPort> vPorts) {
- checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
- if (vPorts != null) {
- for (VirtualPort vPort : vPorts) {
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- log.debug("The virtualPort is not exist whose identifier is {}",
- vPort.portId().toString());
- return false;
- }
-
- vPortStore.put(vPort.portId(), vPort);
-
- if (!vPort.equals(vPortStore.get(vPort.portId()))) {
- log.debug("The virtualPort is updated failed whose identifier is {}",
- vPort.portId().toString());
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean removePorts(Iterable<VirtualPortId> vPortIds) {
- checkNotNull(vPortIds, VIRTUALPORT_ID_NULL);
- if (vPortIds != null) {
- for (VirtualPortId vPortId : vPortIds) {
- vPortStore.remove(vPortId);
- if (vPortStore.containsKey(vPortId)) {
- log.debug("The virtualPort is removed failed whose identifier is {}",
- vPortId.toString());
- return false;
- }
- }
- }
- return true;
- }
-
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java
deleted file mode 100644
index 24eb0d3f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 06a01a04..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 57c97c1c..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.AllocationPool;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet AllocationPool codec.
- */
-public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> {
-
- @Override
- public ObjectNode encode(AllocationPool alocPool, CodecContext context) {
- checkNotNull(alocPool, "AllocationPools cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("start", alocPool.startIp().toString())
- .put("end", alocPool.endIp().toString());
- return result;
- }
-
-}
diff --git a/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
deleted file mode 100644
index 7960808f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort AllowedAddressPair codec.
- */
-public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> {
-
- @Override
- public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) {
- checkNotNull(alocAddPair, "AllowedAddressPair cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("ip_address", alocAddPair.ip().toString())
- .put("mac_address", alocAddPair.mac().toString());
- return result;
- }
-
-}
diff --git a/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
deleted file mode 100644
index 96c9bb4e..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.FixedIp;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort FixedIp codec.
- */
-public final class FixedIpCodec extends JsonCodec<FixedIp> {
-
- @Override
- public ObjectNode encode(FixedIp fixIp, CodecContext context) {
- checkNotNull(fixIp, "FixedIp cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("subnet_id", fixIp.subnetId().toString())
- .put("ip_address", fixIp.ip().toString());
- return result;
- }
-
-}
diff --git a/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
deleted file mode 100644
index 69ca6b3f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.HostRoute;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet HostRoute codec.
- */
-public final class HostRoutesCodec extends JsonCodec<HostRoute> {
-
- @Override
- public ObjectNode encode(HostRoute hostRoute, CodecContext context) {
- checkNotNull(hostRoute, "HostRoute cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("nexthop", hostRoute.nexthop().toString())
- .put("destination", hostRoute.destination().toString());
- return result;
- }
-
-}
diff --git a/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
deleted file mode 100644
index c2ded196..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.SecurityGroup;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Virtualport SecurityGroup codec.
- */
-public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> {
-
- @Override
- public ObjectNode encode(SecurityGroup securGroup, CodecContext context) {
- checkNotNull(securGroup, "SecurityGroup cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("security_group", securGroup.securityGroup());
- return result;
- }
-
-}
diff --git a/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
deleted file mode 100644
index 122b75a9..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.Subnet;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet JSON codec.
- */
-public final class SubnetCodec extends JsonCodec<Subnet> {
- @Override
- public ObjectNode encode(Subnet subnet, CodecContext context) {
- checkNotNull(subnet, "Subnet cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("id", subnet.id().toString())
- .put("gateway_ip", subnet.gatewayIp().toString())
- .put("network_id", subnet.networkId().toString())
- .put("name", subnet.subnetName())
- .put("ip_version", subnet.ipVersion().toString())
- .put("cidr", subnet.cidr().toString())
- .put("shared", subnet.shared())
- .put("enabled_dchp", subnet.dhcpEnabled())
- .put("tenant_id", subnet.tenantId().toString())
- .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null
- : subnet.ipV6AddressMode().toString())
- .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null
- : subnet.ipV6RaMode().toString());
- result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet
- .allocationPools(), context));
- result.set("host_routes",
- new HostRoutesCodec().encode(subnet.hostRoutes(), context));
- return result;
- }
-}
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
deleted file mode 100644
index 48ba3b97..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.TenantNetwork;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * TenantNetwork JSON codec.
- */
-public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> {
-
- @Override
- public ObjectNode encode(TenantNetwork network, CodecContext context) {
- checkNotNull(network, "Network cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("id", network.id().toString())
- .put("name", network.name())
- .put("admin_state_up", network.adminStateUp())
- .put("status", "" + network.state())
- .put("shared", network.shared())
- .put("tenant_id", network.tenantId().toString())
- .put("router:external", network.routerExternal())
- .put("provider:network_type", "" + network.type())
- .put("provider:physical_network", network.physicalNetwork().toString())
- .put("provider:segmentation_id", network.segmentationId().toString());
- return result;
- }
-}
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
deleted file mode 100644
index e57d56bc..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.VirtualPort;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort JSON codec.
- */
-public final class VirtualPortCodec extends JsonCodec<VirtualPort> {
- @Override
- public ObjectNode encode(VirtualPort vPort, CodecContext context) {
- checkNotNull(vPort, "VPort cannot be null");
- ObjectNode result = context
- .mapper()
- .createObjectNode()
- .put("id", vPort.portId().toString())
- .put("network_id", vPort.networkId().toString())
- .put("admin_state_up", vPort.adminStateUp())
- .put("name", vPort.name())
- .put("status", vPort.state().toString())
- .put("mac_address", vPort.macAddress().toString())
- .put("tenant_id", vPort.tenantId().toString())
- .put("device_id", vPort.deviceId().toString())
- .put("device_owner", vPort.deviceOwner())
- .put("binding:vnic_type", vPort.bindingVnicType())
- .put("binding:Vif_type", vPort.bindingVifType())
- .put("binding:host_id", vPort.bindingHostId().toString())
- .put("binding:vif_details", vPort.bindingVifDetails());
- result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode(
- vPort.allowedAddressPairs(), context));
- result.set("fixed_ips", new FixedIpCodec().encode(
- vPort.fixedIps(), context));
- result.set("security_groups", new SecurityGroupCodec().encode(
- vPort.securityGroups(), context));
- return result;
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java
deleted file mode 100644
index 34636a9f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Codecs for virtual tenant objects.
- */
-package org.onosproject.vtnrsc.web;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/apps/vtnrsc/src/main/resources/OSGI-INF/blueprint/shell-config.xml
deleted file mode 100644
index c6a9c81b..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.onosproject.vtnrsc.cli.network.TenantNetworkCreateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.network.TenantNetworkQueryCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.network.TenantNetworkRemoveCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.network.TenantNetworkUpdateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.subnet.SubnetCreateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.subnet.SubnetQueryCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.subnet.SubnetRemoveCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.subnet.SubnetUpdateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.virtualport.VirtualPortCreateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.virtualport.VirtualPortQueryCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.virtualport.VirtualPortRemoveCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.virtualport.VirtualPortUpdateCommand"/>
- </command>
- </command-bundle>
-</blueprint>
diff --git a/framework/src/onos/apps/vtnrsc/src/main/webapp/WEB-INF/web.xml b/framework/src/onos/apps/vtnrsc/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 9c0c69bb..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- id="ONOS" version="2.5">
- <display-name>Vtnrsc Routing REST API v1.0</display-name>
-
- <servlet>
- <servlet-name>JAX-RS Service</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
- <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
- </init-param>
- <init-param>
- <param-name>com.sun.jersey.config.property.classnames</param-name>
- <param-value>
- org.onosproject.app.vtnrsc.web.SubnetWebResource,
- org.onosproject.app.vtnrsc.web.NeutronNetworkWebResource,
- org.onosproject.app.vtnrsc.web.VirtualPortWebResource
- </param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAX-RS Service</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>
diff --git a/framework/src/onos/apps/vtnweb/pom.xml b/framework/src/onos/apps/vtnweb/pom.xml
deleted file mode 100644
index 543bcfbb..00000000
--- a/framework/src/onos/apps/vtnweb/pom.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-apps</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
-
- <artifactId>onos-app-vtnweb</artifactId>
- <packaging>bundle</packaging>
- <properties>
- <onos.app.name>org.onosproject.vtnweb</onos.app.name>
- <web.context>/onos/vtn</web.context>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-vtnrsc</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <_wab>src/main/webapp/</_wab>
- <Bundle-SymbolicName>
- ${project.groupId}.${project.artifactId}
- </Bundle-SymbolicName>
- <Import-Package>
- org.slf4j,
- org.osgi.framework,
- javax.ws.rs,
- javax.ws.rs.core,
- com.sun.jersey.api.core,
- com.sun.jersey.spi.container.servlet,
- com.sun.jersey.server.impl.container.servlet,
- com.fasterxml.jackson.databind,
- com.fasterxml.jackson.databind.node,
- com.fasterxml.jackson.core,
- org.apache.karaf.shell.commands,
- org.apache.commons.lang.math.*,
- com.google.common.*,
- org.onlab.packet.*,
- org.onlab.rest.*,
- org.onosproject.*,
- org.onlab.util.*,
- org.jboss.netty.util.*
- </Import-Package>
- <Web-ContextPath>${web.context}</Web-ContextPath>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project> \ No newline at end of file
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
deleted file mode 100644
index 3979e1e3..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultAllocationPool;
-import org.onosproject.vtnrsc.DefaultHostRoute;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.web.SubnetCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-@Path("subnets")
-public class SubnetWebResource extends AbstractWebResource {
- private final Logger log = LoggerFactory.getLogger(SubnetWebResource.class);
- public static final String SUBNET_NOT_CREATE = "Subnets is failed to create!";
- public static final String SUBNET_NOT_FOUND = "Subnets is failed to update!";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response listSubnets() {
- Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("subnets", new SubnetCodec().encode(subnets, this));
- return ok(result.toString()).build();
- }
-
- @GET
- @Path("{subnetUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getSubnet(@PathParam("subnetUUID") String id) {
-
- if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
- return ok("The subnet does not exists").build();
- }
- Subnet sub = nullIsNotFound(get(SubnetService.class)
- .getSubnet(SubnetId.subnetId(id)),
- SUBNET_NOT_FOUND);
-
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("subnet", new SubnetCodec().encode(sub, this));
- return ok(result.toString()).build();
- }
-
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response createSubnet(final InputStream input) {
-
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = mapper.readTree(input);
- Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
- Boolean result = nullIsNotFound((get(SubnetService.class)
- .createSubnets(subnets)),
- SUBNET_NOT_CREATE);
-
- if (!result) {
- return Response.status(204).entity(SUBNET_NOT_CREATE).build();
- }
- return Response.status(202).entity(result.toString()).build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{subnetUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateSubnet(@PathParam("id") String id,
- final InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = mapper.readTree(input);
- Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
- Boolean result = nullIsNotFound(get(SubnetService.class)
- .updateSubnets(subnets), SUBNET_NOT_FOUND);
- if (!result) {
- return Response.status(204).entity(SUBNET_NOT_FOUND).build();
- }
- return Response.status(203).entity(result.toString()).build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @Path("{subnetUUID}")
- @DELETE
- public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)
- throws IOException {
- try {
- SubnetId subId = SubnetId.subnetId(id);
- Set<SubnetId> subIds = new HashSet<>();
- subIds.add(subId);
- get(SubnetService.class).removeSubnets(subIds);
- return Response.status(201).entity("SUCCESS").build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- private Iterable<Subnet> createOrUpdateByInputStream(JsonNode subnode) {
- checkNotNull(subnode, JSON_NOT_NULL);
- Iterable<Subnet> subnets = null;
- JsonNode subnetNodes = subnode.get("subnets");
- if (subnetNodes == null) {
- subnetNodes = subnode.get("subnet");
- }
- log.debug("subnetNodes is {}", subnetNodes.toString());
- if (subnetNodes.isArray()) {
- subnets = changeJsonToSubs(subnetNodes);
- } else {
- subnets = changeJsonToSub(subnetNodes);
- }
- return subnets;
- }
-
- /**
- * Returns a collection of subnets from subnetNodes.
- *
- * @param subnetNodes the subnet json node
- * @return subnets a collection of subnets
- */
- public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {
- checkNotNull(subnetNodes, JSON_NOT_NULL);
- Map<SubnetId, Subnet> subMap = new HashMap<>();
- for (JsonNode subnetNode : subnetNodes) {
- if (!subnetNode.hasNonNull("id")) {
- return null;
- }
- SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());
- String subnetName = subnetNode.get("name").asText();
- TenantId tenantId = TenantId
- .tenantId(subnetNode.get("tenant_id").asText());
- TenantNetworkId networkId = TenantNetworkId
- .networkId(subnetNode.get("network_id").asText());
- Version ipVersion = Version
- .valueOf(subnetNode.get("ip_version").asText());
- IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());
- IpAddress gatewayIp = IpAddress
- .valueOf(subnetNode.get("gateway_ip").asText());
- Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();
- Boolean shared = subnetNode.get("shared").asBoolean();
- JsonNode hostRoutes = subnetNode.get("host_routes");
- Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
- JsonNode allocationPools = subnetNode.get("allocation_pools");
- Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
- Mode ipV6AddressMode = Mode
- .valueOf(subnetNode.get("ipv6_address_mode").asText());
- Mode ipV6RaMode = Mode
- .valueOf(subnetNode.get("ipv6_ra_mode").asText());
- Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
- tenantId, ipVersion, cidr,
- gatewayIp, dhcpEnabled, shared,
- Sets.newHashSet(hostRoutesIt), ipV6AddressMode,
- ipV6RaMode, Sets.newHashSet(allocationPoolsIt));
- subMap.put(id, subnet);
- }
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Returns a collection of subnets from subnetNodes.
- *
- * @param subnetNodes the subnet json node
- * @return subnets a collection of subnets
- */
- public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
- checkNotNull(subnetNodes, JSON_NOT_NULL);
- checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
- checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");
- Map<SubnetId, Subnet> subMap = new HashMap<>();
- if (!subnetNodes.hasNonNull("id")) {
- return null;
- }
- SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());
- String subnetName = subnetNodes.get("name").asText();
- TenantId tenantId = TenantId
- .tenantId(subnetNodes.get("tenant_id").asText());
- TenantNetworkId networkId = TenantNetworkId
- .networkId(subnetNodes.get("network_id").asText());
- String version = subnetNodes.get("ip_version").asText();
- Version ipVersion;
- switch (version) {
- case "4":
- ipVersion = Version.INET;
- break;
- case "6":
- ipVersion = Version.INET;
- break;
- default:
- throw new IllegalArgumentException("ipVersion should be 4 or 6.");
- }
-
- IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());
- IpAddress gatewayIp = IpAddress
- .valueOf(subnetNodes.get("gateway_ip").asText());
- Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();
- Boolean shared = subnetNodes.get("shared").asBoolean();
- JsonNode hostRoutes = subnetNodes.get("host_routes");
- Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
- JsonNode allocationPools = subnetNodes.get("allocation_pools");
- Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
-
- Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")
- .asText());
- Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());
-
- Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
- ipVersion, cidr, gatewayIp,
- dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt),
- ipV6AddressMode, ipV6RaMode,
- Sets.newHashSet(allocationPoolsIt));
- subMap.put(id, subnet);
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Gets ipv6_address_mode or ipv6_ra_mode type.
- *
- * @param mode the String value in JsonNode
- * @return ipV6Mode Mode of the ipV6Mode
- */
- private Mode getMode(String mode) {
- Mode ipV6Mode;
- if (mode == null) {
- return null;
- }
- switch (mode) {
- case "dhcpv6-stateful":
- ipV6Mode = Mode.DHCPV6_STATEFUL;
- break;
- case "dhcpv6-stateless":
- ipV6Mode = Mode.DHCPV6_STATELESS;
- break;
- case "slaac":
- ipV6Mode = Mode.SLAAC;
- break;
- default:
- ipV6Mode = null;
- }
- return ipV6Mode;
- }
-
- /**
- * Changes JsonNode alocPools to a collection of the alocPools.
- *
- * @param allocationPools the allocationPools JsonNode
- * @return a collection of allocationPools
- */
- public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {
- checkNotNull(allocationPools, JSON_NOT_NULL);
- ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps
- .newConcurrentMap();
- Integer i = 0;
- for (JsonNode node : allocationPools) {
- IpAddress startIp = IpAddress.valueOf(node.get("start").asText());
- IpAddress endIp = IpAddress.valueOf(node.get("end").asText());
- AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);
- alocplMaps.putIfAbsent(i, alocPls);
- i++;
- }
- return Collections.unmodifiableCollection(alocplMaps.values());
- }
-
- /**
- * Changes hostRoutes JsonNode to a collection of the hostRoutes.
- *
- * @param hostRoutes the hostRoutes json node
- * @return a collection of hostRoutes
- */
- public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {
- checkNotNull(hostRoutes, JSON_NOT_NULL);
- ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps
- .newConcurrentMap();
- Integer i = 0;
- for (JsonNode node : hostRoutes) {
- IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());
- IpPrefix destination = IpPrefix.valueOf(node.get("destination")
- .asText());
- HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);
- hostRouteMaps.putIfAbsent(i, hostRoute);
- i++;
- }
- return Collections.unmodifiableCollection(hostRouteMaps.values());
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-
-}
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
deleted file mode 100644
index b3888db1..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkArgument;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.OK;
-
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.TenantNetwork.State;
-import org.onosproject.vtnrsc.TenantNetwork.Type;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.web.TenantNetworkCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-
-/**
- * REST resource for interacting with the inventory of networks.
- */
-@Path("networks")
-public class TenantNetworkWebResource extends AbstractWebResource {
- public static final String NETWORK_NOT_FOUND = "Network is not found";
- public static final String NETWORK_ID_EXIST = "Network id is existed";
- public static final String NETWORK_ID_NOT_EXIST = "Network id is not existed";
- public static final String CREATE_NETWORK = "create network";
- public static final String UPDATE_NETWORK = "update network";
- public static final String DELETE_NETWORK = "delete network";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
-
- protected static final Logger log = LoggerFactory
- .getLogger(TenantNetworkWebResource.class);
- private final ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
-
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getNetworks(@QueryParam("id") String queryId,
- @QueryParam("name") String queryName,
- @QueryParam("admin_state_up") String queryadminStateUp,
- @QueryParam("status") String querystate,
- @QueryParam("shared") String queryshared,
- @QueryParam("tenant_id") String querytenantId,
- @QueryParam("router:external") String routerExternal,
- @QueryParam("provider:network_type") String type,
- @QueryParam("provider:physical_network") String physicalNetwork,
- @QueryParam("provider:segmentation_id") String segmentationId) {
- Iterable<TenantNetwork> networks = get(TenantNetworkService.class)
- .getNetworks();
- Iterator<TenantNetwork> networkors = networks.iterator();
- while (networkors.hasNext()) {
- TenantNetwork network = networkors.next();
- if ((queryId == null || queryId.equals(network.id().toString()))
- && (queryName == null || queryName.equals(network.name()))
- && (queryadminStateUp == null || queryadminStateUp
- .equals(network.adminStateUp()))
- && (querystate == null || querystate.equals(network.state()
- .toString()))
- && (queryshared == null || queryshared.equals(network
- .shared()))
- && (querytenantId == null || querytenantId.equals(network
- .tenantId().toString()))
- && (routerExternal == null || routerExternal.equals(network
- .routerExternal()))
- && (type == null || type.equals(network.type()))
- && (physicalNetwork == null || physicalNetwork
- .equals(network.physicalNetwork()))
- && (segmentationId == null || segmentationId.equals(network
- .segmentationId()))) {
- networksMap.putIfAbsent(network.id(), network);
- }
- }
- networks = Collections.unmodifiableCollection(networksMap.values());
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("networks", new TenantNetworkCodec().encode(networks, this));
-
- return ok(result.toString()).build();
- }
-
- private State isState(String state) {
- if (state.equals("ACTIVE")) {
- return TenantNetwork.State.ACTIVE;
- } else if (state.equals("BUILD")) {
- return TenantNetwork.State.BUILD;
- } else if (state.equals("DOWN")) {
- return TenantNetwork.State.DOWN;
- } else if (state.equals("ERROR")) {
- return TenantNetwork.State.ERROR;
- } else {
- return null;
- }
- }
-
- private Type isType(String type) {
- if (type.equals("LOCAL")) {
- return TenantNetwork.Type.LOCAL;
- } else {
- return null;
- }
- }
-
- @GET
- @Path("{id}")
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getNetwork(@PathParam("id") String id) {
-
- if (!get(TenantNetworkService.class).exists(TenantNetworkId
- .networkId(id))) {
- return ok("The tenantNetwork does not exists").build();
- }
- TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class)
- .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND);
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("network", new TenantNetworkCodec().encode(network, this));
-
- return ok(result.toString()).build();
-
- }
-
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response createNetworks(InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = mapper.readTree(input);
- JsonNode nodes = null;
- Iterable<TenantNetwork> networks = null;
- if (cfg.get("network") != null) {
- nodes = cfg.get("network");
- if (nodes.isArray()) {
- networks = changeJson2objs(nodes);
- } else {
- networks = changeJson2obj(CREATE_NETWORK, null, nodes);
- }
- } else if (cfg.get("networks") != null) {
- nodes = cfg.get("networks");
- networks = changeJson2objs(nodes);
- }
- Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
- .createNetworks(networks)),
- NETWORK_NOT_FOUND);
-
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Creates tenantNetwork exception {}.", e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateNetworks(@PathParam("id") String id, InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = mapper.readTree(input);
- JsonNode nodes = null;
- Iterable<TenantNetwork> networks = null;
- if (cfg.get("network") != null) {
- nodes = cfg.get("network");
- if (nodes.isArray()) {
- networks = changeJson2objs(nodes);
- } else {
- networks = changeJson2obj(UPDATE_NETWORK,
- TenantNetworkId.networkId(id),
- nodes);
- }
- } else if (cfg.get("networks") != null) {
- nodes = cfg.get("networks");
- networks = changeJson2objs(nodes);
- }
- Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
- .updateNetworks(networks)),
- NETWORK_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Updates tenantNetwork failed because of exception {}.",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @DELETE
- @Path("{id}")
- public Response deleteNetworks(@PathParam("id") String id) {
- log.debug("Deletes network by identifier {}.", id);
- Set<TenantNetworkId> networkSet = new HashSet<>();
- networkSet.add(TenantNetworkId.networkId(id));
- Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class)
- .removeNetworks(networkSet), NETWORK_NOT_FOUND);
- if (!issuccess) {
- log.debug("Network identifier {} is not existed", id);
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- }
-
- /**
- * Returns a collection of tenantNetworks.
- *
- * @param flag the flag
- * @param networkId network identifier
- * @param node the network json node
- * @return a collection of tenantNetworks
- */
- public Iterable<TenantNetwork> changeJson2obj(String flag,
- TenantNetworkId networkId,
- JsonNode node) {
- checkNotNull(node, JSON_NOT_NULL);
- TenantNetwork network = null;
- ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
- if (node != null) {
- checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
- checkArgument(node.get("shared").isBoolean(), "shared should be boolean");
- checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean");
- String name = node.get("name").asText();
- boolean adminStateUp = node.get("admin_state_up").asBoolean();
- String state = node.get("status").asText();
- boolean shared = node.get("shared").asBoolean();
- String tenantId = node.get("tenant_id").asText();
- boolean routerExternal = node.get("router:external").asBoolean();
- String type = node.get("provider:network_type").asText();
- String physicalNetwork = node.get("provider:physical_network")
- .asText();
- String segmentationId = node.get("provider:segmentation_id")
- .asText();
- TenantNetworkId id = null;
- if (flag == CREATE_NETWORK) {
- id = TenantNetworkId.networkId(node.get("id").asText());
- } else if (flag == UPDATE_NETWORK) {
- id = networkId;
- }
- network = new DefaultTenantNetwork(
- id,
- name,
- adminStateUp,
- isState(state),
- shared,
- TenantId.tenantId(tenantId),
- routerExternal,
- isType(type),
- PhysicalNetwork
- .physicalNetwork(physicalNetwork),
- SegmentationId
- .segmentationId(segmentationId));
- networksMap.putIfAbsent(id, network);
- }
- return Collections.unmodifiableCollection(networksMap.values());
- }
-
- /**
- * Returns a collection of tenantNetworks.
- *
- * @param nodes the network jsonnodes
- * @return a collection of tenantNetworks
- */
- public Iterable<TenantNetwork> changeJson2objs(JsonNode nodes) {
- checkNotNull(nodes, JSON_NOT_NULL);
- TenantNetwork network = null;
- ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
- if (nodes != null) {
- for (JsonNode node : nodes) {
- String id = node.get("id").asText();
- String name = node.get("name").asText();
- boolean adminStateUp = node.get("admin_state_up").asBoolean();
- String state = node.get("status").asText();
- boolean shared = node.get("shared").asBoolean();
- String tenantId = node.get("tenant_id").asText();
- boolean routerExternal = node.get("router:external")
- .asBoolean();
- String type = node.get("provider:network_type").asText();
- String physicalNetwork = node.get("provider:physical_network")
- .asText();
- String segmentationId = node.get("provider:segmentation_id")
- .asText();
- network = new DefaultTenantNetwork(
- TenantNetworkId
- .networkId(id),
- name,
- adminStateUp,
- isState(state),
- shared,
- TenantId.tenantId(tenantId),
- routerExternal,
- isType(type),
- PhysicalNetwork
- .physicalNetwork(physicalNetwork),
- SegmentationId
- .segmentationId(segmentationId));
- networksMap.putIfAbsent(TenantNetworkId.networkId(id), network);
- }
- }
- return Collections.unmodifiableCollection(networksMap.values());
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-}
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
deleted file mode 100644
index d0b7ed2d..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.OK;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.net.DeviceId;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPort.State;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.onosproject.vtnrsc.web.VirtualPortCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * REST resource for interacting with the inventory of infrastructure
- * virtualPort.
- */
-@Path("ports")
-public class VirtualPortWebResource extends AbstractWebResource {
- public static final String VPORT_NOT_FOUND = "VirtualPort is not found";
- public static final String VPORT_ID_EXIST = "VirtualPort id is exist";
- public static final String VPORT_ID_NOT_EXIST = "VirtualPort id is not exist";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
- protected static final Logger log = LoggerFactory
- .getLogger(VirtualPortService.class);
-
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getPorts() {
- Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class)
- .getPorts();
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("ports", new VirtualPortCodec().encode(virtualPorts, this));
- return ok(result.toString()).build();
- }
-
- @GET
- @Path("{id}")
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getportsById(@PathParam("id") String id) {
-
- if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {
- return ok("The virtualPort does not exists").build();
- }
- VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class)
- .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND);
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("port", new VirtualPortCodec().encode(virtualPort, this));
- return ok(result.toString()).build();
- }
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createPorts(InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = mapper.readTree(input);
- Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .createPorts(vPorts), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Creates VirtualPort failed because of exception {}",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @Path("{portUUID}")
- @DELETE
- public Response deletePorts(@PathParam("portUUID") String id) {
- Set<VirtualPortId> vPortIds = new HashSet<>();
- try {
- if (id != null) {
- vPortIds.add(VirtualPortId.portId(id));
- }
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .removePorts(vPortIds), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Deletes VirtualPort failed because of exception {}",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response updatePorts(@PathParam("id") String id, InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = mapper.readTree(input);
- Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .updatePorts(vPorts), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Updates failed because of exception {}", e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- /**
- * Returns a Object of the currently known infrastructure virtualPort.
- *
- * @param vPortNode the virtualPort json node
- * @return a collection of virtualPorts
- */
- public Iterable<VirtualPort> createOrUpdateByInputStream(JsonNode vPortNode) {
- checkNotNull(vPortNode, JSON_NOT_NULL);
- JsonNode vPortNodes = vPortNode.get("ports");
- if (vPortNodes == null) {
- vPortNodes = vPortNode.get("port");
- }
- if (vPortNodes.isArray()) {
- return changeJsonToPorts(vPortNodes);
- } else {
- return changeJsonToPort(vPortNodes);
- }
- }
-
- /**
- * Returns the iterable collection of virtualports from subnetNodes.
- *
- * @param vPortNodes the virtualPort json node
- * @return virtualPorts a collection of virtualPorts
- */
- public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) {
- checkNotNull(vPortNodes, JSON_NOT_NULL);
- Map<VirtualPortId, VirtualPort> portMap = new HashMap<>();
- Map<String, String> strMap = new HashMap<>();
- for (JsonNode vPortnode : vPortNodes) {
- VirtualPortId id = VirtualPortId.portId(vPortnode.get("id")
- .asText());
- String name = vPortnode.get("name").asText();
- TenantId tenantId = TenantId.tenantId(vPortnode.get("tenant_id")
- .asText());
- TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode
- .get("network_id").asText());
- checkArgument(vPortnode.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
- Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean();
- String state = vPortnode.get("status").asText();
- MacAddress macAddress = MacAddress.valueOf(vPortnode
- .get("mac_address").asText());
- DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id")
- .asText());
- String deviceOwner = vPortnode.get("device_owner").asText();
- JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
- Set<FixedIp> fixedIps = new HashSet<>();
- for (JsonNode fixedIpNode : fixedIpNodes) {
- FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
- fixedIps.add(fixedIp);
- }
-
- BindingHostId bindingHostId = BindingHostId
- .bindingHostId(vPortnode.get("binding:host_id").asText());
- String bindingVnicType = vPortnode.get("binding:vnic_type")
- .asText();
- String bindingVifType = vPortnode.get("binding:vif_type").asText();
- String bindingVifDetails = vPortnode.get("binding:vif_details")
- .asText();
- JsonNode allowedAddressPairJsonNode = vPortnode
- .get("allowed_address_pairs");
- Collection<AllowedAddressPair> allowedAddressPairs =
- jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
- JsonNode securityGroupNode = vPortnode.get("security_groups");
- Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
- strMap.put("name", name);
- strMap.put("deviceOwner", deviceOwner);
- strMap.put("bindingVnicType", bindingVnicType);
- strMap.put("bindingVifType", bindingVifType);
- strMap.put("bindingVifDetails", bindingVifDetails);
- VirtualPort vPort = new DefaultVirtualPort(id, networkId,
- adminStateUp, strMap,
- isState(state),
- macAddress, tenantId,
- deviceId, fixedIps,
- bindingHostId,
- Sets.newHashSet(allowedAddressPairs),
- Sets.newHashSet(securityGroups));
- portMap.put(id, vPort);
- }
- return Collections.unmodifiableCollection(portMap.values());
- }
-
- /**
- * Returns a collection of virtualPorts from subnetNodes.
- *
- * @param vPortNodes the virtualPort json node
- * @return virtualPorts a collection of virtualPorts
- */
- public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) {
- checkNotNull(vPortNodes, JSON_NOT_NULL);
- Map<VirtualPortId, VirtualPort> vportMap = new HashMap<>();
- Map<String, String> strMap = new HashMap<>();
- VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText());
- String name = vPortNodes.get("name").asText();
- TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id")
- .asText());
- TenantNetworkId networkId = TenantNetworkId.networkId(vPortNodes
- .get("network_id").asText());
- Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean();
- String state = vPortNodes.get("status").asText();
- MacAddress macAddress = MacAddress.valueOf(vPortNodes
- .get("mac_address").asText());
- DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id")
- .asText());
- String deviceOwner = vPortNodes.get("device_owner").asText();
- JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
- Set<FixedIp> fixedIps = new HashSet<>();
- for (JsonNode fixedIpNode : fixedIpNodes) {
- FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
- fixedIps.add(fixedIp);
- }
-
- BindingHostId bindingHostId = BindingHostId
- .bindingHostId(vPortNodes.get("binding:host_id").asText());
- String bindingVnicType = vPortNodes.get("binding:vnic_type").asText();
- String bindingVifType = vPortNodes.get("binding:vif_type").asText();
- String bindingVifDetails = vPortNodes.get("binding:vif_details")
- .asText();
- JsonNode allowedAddressPairJsonNode = vPortNodes
- .get("allowed_address_pairs");
- Collection<AllowedAddressPair> allowedAddressPairs =
- jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
- JsonNode securityGroupNode = vPortNodes.get("security_groups");
- Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
- strMap.put("name", name);
- strMap.put("deviceOwner", deviceOwner);
- strMap.put("bindingVnicType", bindingVnicType);
- strMap.put("bindingVifType", bindingVifType);
- strMap.put("bindingVifDetails", bindingVifDetails);
- VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp,
- strMap, isState(state),
- macAddress, tenantId,
- deviceId, fixedIps,
- bindingHostId,
- Sets.newHashSet(allowedAddressPairs),
- Sets.newHashSet(securityGroups));
- vportMap.put(id, vPort);
-
- return Collections.unmodifiableCollection(vportMap.values());
- }
-
- /**
- * Returns a Object of the currently known infrastructure virtualPort.
- *
- * @param allowedAddressPairs the allowedAddressPairs json node
- * @return a collection of allowedAddressPair
- */
- public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {
- checkNotNull(allowedAddressPairs, JSON_NOT_NULL);
- ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps
- .newConcurrentMap();
- int i = 0;
- for (JsonNode node : allowedAddressPairs) {
- IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());
- MacAddress mac = MacAddress.valueOf(node.get("mac_address")
- .asText());
- AllowedAddressPair allows = AllowedAddressPair
- .allowedAddressPair(ip, mac);
- allowMaps.put(i, allows);
- i++;
- }
- log.debug("The jsonNode of allowedAddressPairallow is {}"
- + allowedAddressPairs.toString());
- return Collections.unmodifiableCollection(allowMaps.values());
- }
-
- /**
- * Returns a collection of virtualPorts.
- *
- * @param securityGroups the virtualPort jsonnode
- * @return a collection of securityGroups
- */
- public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) {
- checkNotNull(securityGroups, JSON_NOT_NULL);
- ConcurrentMap<Integer, SecurityGroup> securMaps = Maps
- .newConcurrentMap();
- int i = 0;
- for (JsonNode node : securityGroups) {
- SecurityGroup securityGroup = SecurityGroup
- .securityGroup(node.asText());
- securMaps.put(i, securityGroup);
- i++;
- }
- return Collections.unmodifiableCollection(securMaps.values());
- }
-
- /**
- * Returns a collection of fixedIps.
- *
- * @param fixedIpNode the fixedIp jsonnode
- * @return a collection of SecurityGroup
- */
- public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) {
- SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id")
- .asText());
- IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address")
- .asText());
- FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress);
- return fixedIps;
- }
-
- /**
- * Returns VirtualPort State.
- *
- * @param state the virtualport state
- * @return the virtualPort state
- */
- private State isState(String state) {
- if (state.equals("ACTIVE")) {
- return VirtualPort.State.ACTIVE;
- } else {
- return VirtualPort.State.DOWN;
- }
-
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-}
diff --git a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java
deleted file mode 100644
index c81fc3d8..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN web that used rest to creat vtn resources.
- */
-package org.onosproject.vtnweb.resources;
diff --git a/framework/src/onos/apps/vtnweb/src/main/webapp/WEB-INF/web.xml b/framework/src/onos/apps/vtnweb/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 4cc12455..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- id="ONOS" version="2.5">
- <display-name>VTNRSC REST API v1.0</display-name>
-
- <servlet>
- <servlet-name>JAX-RS Service</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
- <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
- </init-param>
- <init-param>
- <param-name>com.sun.jersey.config.property.classnames</param-name>
- <param-value>
- org.onosproject.vtnweb.resources.TenantNetworkWebResource,
- org.onosproject.vtnweb.resources.SubnetWebResource,
- org.onosproject.vtnweb.resources.VirtualPortWebResource
- </param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAX-RS Service</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>
diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java
index 6d758122..49432aab 100755
--- a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java
+++ b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java
@@ -25,6 +25,21 @@ import org.onosproject.bgpio.protocol.BGPMessage;
public interface BGPController {
/**
+ * Returns list of bgp peers connected to this BGP controller.
+ *
+ * @return Iterable of BGPPeer elements
+ */
+ Iterable<BGPPeer> getPeers();
+
+ /**
+ * Returns the actual bgp peer for the given ip address.
+ *
+ * @param bgpId the id of the bgp peer to fetch
+ * @return the interface to this bgp peer
+ */
+ BGPPeer getPeer(BGPId bgpId);
+
+ /**
* Send a message to a particular bgp peer.
*
* @param bgpId the id of the peer to send message.
@@ -41,9 +56,22 @@ public interface BGPController {
void processBGPPacket(BGPId bgpId, BGPMessage msg);
/**
+ * Close all connected BGP peers.
+ *
+ */
+ void closeConnectedPeers();
+
+ /**
* Get the BGPConfig class to the caller.
*
* @return configuration object
*/
BGPCfg getConfig();
+
+ /**
+ * Get the BGP connected peers to this controller.
+ *
+ * @return the integer number
+ */
+ int getBGPConnNumber();
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeer.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeer.java
new file mode 100755
index 00000000..1b022c76
--- /dev/null
+++ b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeer.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgp.controller;
+import java.util.List;
+import org.jboss.netty.channel.Channel;
+import org.onosproject.bgpio.protocol.BGPMessage;
+import org.onosproject.bgpio.protocol.BGPVersion;
+
+/**
+ * Represents the peer side of an bgp peer.
+ *
+ */
+public interface BGPPeer {
+
+ /**
+ * Sets the BGP version for this bgp peer.
+ *
+ * @param bgpVersion the version to set.
+ */
+ void setBgpPeerVersion(BGPVersion bgpVersion);
+
+ /**
+ * Gets the BGP version for this bgp peer.
+ *
+ * @return bgp identifier.
+ */
+ int getBgpPeerIdentifier();
+
+ /**
+ * Sets the associated Netty channel for this bgp peer.
+ *
+ * @param channel the Netty channel
+ */
+ void setChannel(Channel channel);
+
+ /**
+ * Gets the associated Netty channel handler for this bgp peer.
+ *
+ * @return Channel channel connected.
+ */
+ Channel getChannel();
+
+ /**
+ * Sets the AS Number for this bgp peer.
+ *
+ * @param peerASNum the autonomous system number value to set.
+ */
+ void setBgpPeerASNum(short peerASNum);
+
+ /**
+ * Sets the hold time for this bgp peer.
+ *
+ * @param peerHoldTime the hold timer value to set.
+ */
+ void setBgpPeerHoldTime(short peerHoldTime);
+
+ /**
+ * Sets the peer identifier value.
+ *
+ * @param peerIdentifier the bgp peer identifier value.
+ */
+ void setBgpPeerIdentifier(int peerIdentifier);
+
+ /**
+ * Sets whether the bgp peer is connected.
+ *
+ * @param connected whether the bgp peer is connected
+ */
+ void setConnected(boolean connected);
+
+ /**
+ * Initialises the behaviour.
+ *
+ * @param bgpId id of bgp peer
+ * @param bgpVersion BGP version
+ * @param pktStats packet statistics
+ */
+ void init(BGPId bgpId, BGPVersion bgpVersion, BGPPacketStats pktStats);
+
+ /**
+ * Checks whether the handshake is complete.
+ *
+ * @return true is finished, false if not.
+ */
+ boolean isHandshakeComplete();
+
+ /**
+ * Writes the message to the peer.
+ *
+ * @param msg the message to write
+ */
+ void sendMessage(BGPMessage msg);
+
+ /**
+ * Writes the BGPMessage list to the peer.
+ *
+ * @param msgs the messages to be written
+ */
+ void sendMessage(List<BGPMessage> msgs);
+
+ /**
+ * Gets a string version of the ID for this bgp peer.
+ *
+ * @return string version of the ID
+ */
+ String getStringId();
+
+ /**
+ * Gets the ipAddress of the peer.
+ *
+ * @return the peer bgpId in IPAddress format
+ */
+ BGPId getBGPId();
+
+ /**
+ * Checks if the bgp peer is still connected.
+ *
+ * @return whether the bgp peer is still connected
+ */
+ boolean isConnected();
+
+ /**
+ * Disconnects the bgp peer by closing the TCP connection. Results in a call to the channel handler's
+ * channelDisconnected method for cleanup
+ */
+ void disconnectPeer();
+
+ /**
+ * Identifies the channel used to communicate with the bgp peer.
+ *
+ * @return string representation of the connection to the peer
+ */
+ String channelId();
+
+ /**
+ * Gets the negotiated hold time.
+ *
+ * @return the negotiated hold time
+ */
+ int getNegotiatedHoldTime();
+
+ /**
+ * Sets negotiated hold time for the peer.
+ *
+ * @param negotiatedHoldTime negotiated hold time
+ */
+ void setNegotiatedHoldTime(short negotiatedHoldTime);
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsg.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsg.java
index c8aef36e..ae773889 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsg.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsg.java
@@ -39,20 +39,10 @@ public interface BGPKeepaliveMsg extends BGPMessage {
* Builder interface with get and set functions to build Keepalive message.
*/
interface Builder extends BGPMessage.Builder {
-
@Override
BGPKeepaliveMsg build();
@Override
- BGPVersion getVersion();
-
- @Override
- BGPType getType();
-
- @Override
Builder setHeader(BGPHeader bgpMsgHeader);
-
- @Override
- BGPHeader getHeader();
}
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPLSNlri.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPLSNlri.java
new file mode 100644
index 00000000..572e2aeb
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPLSNlri.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.protocol;
+
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.protocol.link_state.BGPNodeLSNlriVer4.PROTOCOLTYPE;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+
+/**
+ * Abstraction of an entity providing BGP-LS NLRI.
+ */
+public interface BGPLSNlri {
+ /**
+ * Returns NlriType of BGP-LS NLRI.
+ *
+ * @return NlriType of BGP-LS NLRI
+ */
+ NlriType getNlriType();
+
+ /**
+ * Returns Identifier in Nlri.
+ *
+ * @return Identifier in Nlri
+ */
+ long getIdentifier();
+
+ /**
+ * Returns Protocol Id in Nlri.
+ *
+ * @return Protocol Id in Nlri
+ * @throws BGPParseException while getting protocol ID
+ */
+ PROTOCOLTYPE getProtocolId() throws BGPParseException;
+
+ /**
+ * Returns Route distinguisher in Nlri.
+ *
+ * @return Route distinguisher in Nlri
+ */
+ RouteDistinguisher getRouteDistinguisher();
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPMessage.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPMessage.java
index a5d8154f..309ef435 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPMessage.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPMessage.java
@@ -61,27 +61,6 @@ public interface BGPMessage extends Writeable {
BGPMessage build() throws BGPParseException;
/**
- * Returns BGP Version of BGP Message.
- *
- * @return BGP Version of BGP Message
- */
- BGPVersion getVersion();
-
- /**
- * Returns BGP Type of BGP Message.
- *
- * @return BGP Type of BGP Message
- */
- BGPType getType();
-
- /**
- * Returns BGP Header of BGP Message.
- *
- * @return BGP Header of BGP Message
- */
- BGPHeader getHeader();
-
- /**
* Sets BgpHeader and return its builder.
*
* @param bgpMsgHeader BGP Message Header
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNodeLSNlri.java
index e9aa1448..fd5b8056 100644
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNodeLSNlri.java
@@ -13,8 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.onosproject.bgpio.protocol;
+
+import org.onosproject.bgpio.protocol.link_state.BGPNodeLSIdentifier;
/**
- * ACL application implementation.
+ * Abstraction of an entity providing BGP-LS Node NLRI.
*/
-package org.onos.acl.impl;
+public interface BGPNodeLSNlri extends BGPLSNlri {
+ /**
+ * Returns local node descriptors.
+ *
+ * @return local node descriptors
+ */
+ BGPNodeLSIdentifier getLocalNodeDescriptors();
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNotificationMsg.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNotificationMsg.java
new file mode 100644
index 00000000..56540dd3
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNotificationMsg.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.protocol;
+
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPHeader;
+
+/**
+ * Abstraction of an entity providing BGP Notification Message.
+ */
+public interface BGPNotificationMsg extends BGPMessage {
+ /**
+ * Returns errorCode in Notification message.
+ *
+ * @return errorCode in Notification message
+ */
+ byte getErrorCode();
+
+ /**
+ * Returns error SubCode in Notification message.
+ *
+ * @return error SubCode in Notification message
+ */
+ byte getErrorSubCode();
+
+ /**
+ * Returns error data in Notification message.
+ *
+ * @return error data in Notification message
+ */
+ byte[] getData();
+
+ /**
+ * Builder interface with get and set functions to build Notification
+ * message.
+ */
+ public interface Builder extends BGPMessage.Builder {
+
+ @Override
+ BGPNotificationMsg build() throws BGPParseException;
+
+ /**
+ * Sets notification message header and returns its builder.
+ *
+ * @param header of notification message
+ * @return Builder by setting notification message header
+ */
+ Builder setNotificationMsgHeader(BGPHeader header);
+
+ /**
+ * Sets errorCode in notification message and return its builder.
+ *
+ * @param errorCode in notification message
+ * @return builder by setting ErrorCode in notification message
+ */
+ Builder setErrorCode(byte errorCode);
+
+ /**
+ * Sets error SubCode in notification message and return its builder.
+ *
+ * @param errorSubCode in notification Message
+ * @return builder by setting ErrorSubCode in notification Message
+ */
+ Builder setErrorSubCode(byte errorSubCode);
+
+ /**
+ * Sets error data in notification message and return its builder.
+ *
+ * @param data in notification message
+ * @return builder by setting Data in notification message
+ */
+ Builder setData(byte[] data);
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java
index c41e5eb6..a8c242b4 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onosproject.bgpio.protocol;
import java.util.LinkedList;
@@ -72,15 +71,6 @@ public interface BGPOpenMsg extends BGPMessage {
@Override
BGPOpenMsg build() throws BGPParseException;
- @Override
- BGPHeader getHeader();
-
- @Override
- BGPVersion getVersion();
-
- @Override
- BGPType getType();
-
/**
* Returns hold time of Open Message.
*
@@ -91,8 +81,7 @@ public interface BGPOpenMsg extends BGPMessage {
/**
* Sets hold time in Open Message and return its builder.
*
- * @param holdtime
- * hold timer value in open message
+ * @param holdtime hold timer value in open message
* @return builder by setting hold time
*/
Builder setHoldTime(short holdtime);
@@ -107,8 +96,7 @@ public interface BGPOpenMsg extends BGPMessage {
/**
* Sets AS number in Open Message and return its builder.
*
- * @param asNumber
- * as number in open message
+ * @param asNumber as number in open message
* @return builder by setting asNumber
*/
Builder setAsNumber(short asNumber);
@@ -123,8 +111,7 @@ public interface BGPOpenMsg extends BGPMessage {
/**
* Sets BGP Identifier in Open Message and return its builder.
*
- * @param bgpId
- * BGP Identifier in open message
+ * @param bgpId BGP Identifier in open message
* @return builder by setting BGP Identifier
*/
Builder setBgpId(int bgpId);
@@ -139,12 +126,29 @@ public interface BGPOpenMsg extends BGPMessage {
/**
* Sets capabilities in Open Message and return its builder.
*
- * @param capabilityTlv
- * capabilities in open message
+ * @param capabilityTlv capabilities in open message
* @return builder by setting capabilities
*/
Builder setCapabilityTlv(LinkedList<BGPValueType> capabilityTlv);
+ /**
+ * Sets isLargeAsCapabilityTlvSet and return its builder.
+ *
+ * @param isLargeAsCapabilitySet
+ * boolean value to know whether large AS capability is set or not
+ * @return builder by setting capabilities
+ */
+ Builder setLargeAsCapabilityTlv(boolean isLargeAsCapabilitySet);
+
+ /**
+ * Sets isLsCapabilityTlvSet and return its builder.
+ *
+ * @param isLsCapabilitySet
+ * boolean value to know whether LS capability is set or not
+ * @return builder by setting capabilities
+ */
+ Builder setLsCapabilityTlv(boolean isLsCapabilitySet);
+
@Override
Builder setHeader(BGPHeader bgpMsgHeader);
}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPPrefixLSNlri.java
index b18cb950..7e849f48 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPPrefixLSNlri.java
@@ -13,27 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.vtnrsc;
+package org.onosproject.bgpio.protocol;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
+import java.util.LinkedList;
+
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.protocol.link_state.NodeDescriptors;
/**
- * Host route dictionaries for the subnet.
+ * Abstraction of an entity providing BGP-LS Prefix NLRI.
*/
-public interface HostRoute {
-
+public interface BGPPrefixLSNlri extends BGPLSNlri {
/**
- * Returns the next hop address.
+ * Returns local node descriptors.
*
- * @return next hop address
+ * @return local node descriptors
*/
- IpAddress nexthop();
+ NodeDescriptors getLocalNodeDescriptors();
/**
- * Returns the destination address.
+ * Returns list of Prefix descriptor.
*
- * @return destination address
+ * @return list of Prefix descriptor
*/
- IpPrefix destination();
-}
+ LinkedList<BGPValueType> getPrefixdescriptor();
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java
index 377d12b7..0e531d64 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java
@@ -1,23 +1,23 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-/**
- * Provides Abstraction of IGP RouterID TLV.
- */
-public interface IGPRouterID {
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.bgpio.protocol;
+
+/**
+ * Provides Abstraction of IGP RouterID TLV.
+ */
+public interface IGPRouterID {
} \ No newline at end of file
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java
index 3d6ba8e8..535ba71d 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java
@@ -13,26 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.vtnrsc;
-import org.onlab.packet.IpAddress;
+package org.onosproject.bgpio.protocol;
/**
- * The continuous IP address range between the start address and the end address for the allocation pools.
+ * Enum to Provide the Different BGP-LS NLRI types.
*/
-public interface AllocationPool {
+public enum NlriType {
+
+ NODE(1), LINK(2), PREFIX_IPV4(3), PREFIX_IPV6(4);
+
+ int value;
/**
- * The start address for the allocation pool.
+ * Assign value with the value as the LINK-STATE NLRI type.
*
- * @return startIp
+ * @param value LINK-STATE NLRI type
*/
- IpAddress startIp();
+ NlriType(int value) {
+ this.value = value;
+ }
/**
- * The end address for the allocation pool.
+ * Returns value as LINK-STATE NLRI type.
*
- * @return endIp
+ * @return value LINK-STATE NLRI type
*/
- IpAddress endIp();
-}
+ public byte getType() {
+ return (byte) value;
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSIdentifier.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSIdentifier.java
new file mode 100644
index 00000000..cd2422a7
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSIdentifier.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.protocol.link_state;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.util.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implementation of Node Identifier which includes local node descriptor/remote node descriptors.
+ */
+public class BGPNodeLSIdentifier {
+
+ protected static final Logger log = LoggerFactory.getLogger(BGPNodeLSIdentifier.class);
+ private NodeDescriptors nodeDescriptors;
+
+ /**
+ * Resets fields.
+ */
+ public BGPNodeLSIdentifier() {
+ this.nodeDescriptors = null;
+ }
+
+ /**
+ * Constructor to initialize fields.
+ *
+ * @param nodeDescriptors local/remote node descriptor
+ */
+ public BGPNodeLSIdentifier(NodeDescriptors nodeDescriptors) {
+ this.nodeDescriptors = nodeDescriptors;
+ }
+
+ /**
+ * Parse local node descriptors.
+ *
+ * @param cb ChannelBuffer
+ * @param protocolId protocol identifier
+ * @return object of this BGPNodeLSIdentifier
+ * @throws BGPParseException while parsing local node descriptors
+ */
+ public static BGPNodeLSIdentifier parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
+ throws BGPParseException {
+ ChannelBuffer tempBuf = cb;
+ short type = cb.readShort();
+ short length = cb.readShort();
+ if (cb.readableBytes() < length) {
+ throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+ tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN));
+ }
+ NodeDescriptors nodeDescriptors = new NodeDescriptors();
+ ChannelBuffer tempCb = cb.readBytes(length);
+
+ if (type == NodeDescriptors.LOCAL_NODE_DES_TYPE) {
+ nodeDescriptors = NodeDescriptors.read(tempCb, length, type, protocolId);
+ } else {
+ throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.MALFORMED_ATTRIBUTE_LIST, null);
+ }
+ return new BGPNodeLSIdentifier(nodeDescriptors);
+ }
+
+ /**
+ * Returns node descriptors.
+ *
+ * @return node descriptors
+ */
+ public NodeDescriptors getNodedescriptors() {
+ return this.nodeDescriptors;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof BGPNodeLSIdentifier) {
+ BGPNodeLSIdentifier other = (BGPNodeLSIdentifier) obj;
+ return Objects.equals(nodeDescriptors, other.nodeDescriptors);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nodeDescriptors);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("NodeDescriptors", nodeDescriptors)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSNlriVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSNlriVer4.java
new file mode 100644
index 00000000..04780d82
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSNlriVer4.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.protocol.link_state;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.protocol.BGPNodeLSNlri;
+import org.onosproject.bgpio.protocol.NlriType;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+import org.onosproject.bgpio.util.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implementation of Node LS NLRI.
+ */
+public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
+
+ /*
+ *REFERENCE : draft-ietf-idr-ls-distribution-11
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+
+ | Protocol-ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Identifier |
+ | (64 bits) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Local Node Descriptors (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Figure : The Node NLRI format
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(BGPNodeLSNlriVer4.class);
+
+ public static final int NODE_NLRITYPE = 1;
+ public static final int IDENTIFIER_LENGTH = 16;
+ private long identifier;
+ private byte protocolId;
+ private BGPNodeLSIdentifier localNodeDescriptors;
+ private RouteDistinguisher routeDistinguisher;
+ private boolean isVpn;
+
+ /**
+ * Enum to provide PROTOCOLTYPE.
+ */
+ public enum PROTOCOLTYPE {
+ ISIS_LevelOne(1), ISIS_LevelTwo(2), OSPFv2(3), Direct(4), Static_Configuration(5), OSPFv3(6);
+ int value;
+
+ /**
+ * Assign val with the value as the protocol type.
+ *
+ * @param val protocol type
+ */
+ PROTOCOLTYPE(int val) {
+ value = val;
+ }
+
+ /**
+ * Returns value of protocol type.
+ *
+ * @return protocol type
+ */
+ public byte getType() {
+ return (byte) value;
+ }
+ }
+
+ /**
+ * Reset fields.
+ */
+ public BGPNodeLSNlriVer4() {
+ this.identifier = 0;
+ this.protocolId = 0;
+ this.localNodeDescriptors = null;
+ this.routeDistinguisher = null;
+ this.isVpn = false;
+ }
+
+ /**
+ * Constructors to initialize its parameters.
+ *
+ * @param identifier of LinkState Nlri
+ * @param protocolId of LinkState Nlri
+ * @param localNodeDescriptors local node descriptors
+ * @param isVpn true if VPN info is present
+ * @param routeDistinguisher unique for each VPN
+ */
+ BGPNodeLSNlriVer4(long identifier, byte protocolId, BGPNodeLSIdentifier localNodeDescriptors, boolean isVpn,
+ RouteDistinguisher routeDistinguisher) {
+ this.identifier = identifier;
+ this.protocolId = protocolId;
+ this.localNodeDescriptors = localNodeDescriptors;
+ this.routeDistinguisher = routeDistinguisher;
+ this.isVpn = isVpn;
+ }
+
+ /**
+ * Reads from channelBuffer and parses Node LS Nlri.
+ *
+ * @param cb ChannelBuffer
+ * @param afi Address Family Identifier
+ * @param safi Subsequent Address Family Identifier
+ * @return object of this class
+ * @throws BGPParseException while parsing node descriptors
+ */
+ public static BGPNodeLSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BGPParseException {
+ boolean isVpn = false;
+ RouteDistinguisher routeDistinguisher = null;
+ if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
+ routeDistinguisher = new RouteDistinguisher();
+ routeDistinguisher = RouteDistinguisher.read(cb);
+ isVpn = true;
+ } else {
+ isVpn = false;
+ }
+ byte protocolId = cb.readByte();
+ long identifier = cb.readLong();
+
+ // Parse Local Node Descriptors
+ BGPNodeLSIdentifier localNodeDescriptors = new BGPNodeLSIdentifier();
+ localNodeDescriptors = BGPNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
+ return new BGPNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
+ }
+
+ @Override
+ public NlriType getNlriType() {
+ return NlriType.NODE;
+ }
+
+ @Override
+ public BGPNodeLSIdentifier getLocalNodeDescriptors() {
+ return this.localNodeDescriptors;
+ }
+
+ /**
+ * Returns whether VPN is present or not.
+ *
+ * @return whether VPN is present or not
+ */
+ public boolean isVpnPresent() {
+ return this.isVpn;
+ }
+
+ @Override
+ public RouteDistinguisher getRouteDistinguisher() {
+ return this.routeDistinguisher;
+ }
+
+ @Override
+ public long getIdentifier() {
+ return this.identifier;
+ }
+
+ /**
+ * Set the node LS identifier.
+ *
+ * @param localNodeDescriptors node LS identifier to set
+ */
+ public void setNodeLSIdentifier(BGPNodeLSIdentifier localNodeDescriptors) {
+ this.localNodeDescriptors = localNodeDescriptors;
+ }
+
+ @Override
+ public PROTOCOLTYPE getProtocolId() throws BGPParseException {
+ switch (protocolId) {
+ case Constants.ISIS_LEVELONE:
+ return PROTOCOLTYPE.ISIS_LevelOne;
+ case Constants.ISIS_LEVELTWO:
+ return PROTOCOLTYPE.ISIS_LevelTwo;
+ case Constants.OSPFV2:
+ return PROTOCOLTYPE.OSPFv2;
+ case Constants.DIRECT:
+ return PROTOCOLTYPE.Direct;
+ case Constants.STATIC_CONFIGURATION:
+ return PROTOCOLTYPE.Static_Configuration;
+ case Constants.OSPFV3:
+ return PROTOCOLTYPE.OSPFv3;
+ default:
+ throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("protocolId", protocolId)
+ .add("identifier", identifier)
+ .add("RouteDistinguisher ", routeDistinguisher)
+ .add("localNodeDescriptors", localNodeDescriptors)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPPrefixIPv4LSNlriVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPPrefixIPv4LSNlriVer4.java
new file mode 100644
index 00000000..0f18c757
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPPrefixIPv4LSNlriVer4.java
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.protocol.link_state;
+
+import java.util.LinkedList;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.protocol.BGPPrefixLSNlri;
+import org.onosproject.bgpio.protocol.NlriType;
+import org.onosproject.bgpio.protocol.link_state.BGPNodeLSNlriVer4.PROTOCOLTYPE;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+import org.onosproject.bgpio.util.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implementation of Prefix IPV4 LS NLRI.
+ */
+public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
+
+ /*
+ * REFERENCE : draft-ietf-idr-ls-distribution-11
+ * 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+
+ | Protocol-ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Identifier |
+ | (64 bits) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Local Node Descriptor (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Prefix Descriptors (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Figure : The IPv4/IPv6 Topology Prefix NLRI format
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(BGPPrefixIPv4LSNlriVer4.class);
+
+ public static final int PREFIX_IPV4_NLRITYPE = 3;
+ public static final int IDENTIFIER_LENGTH = 16;
+ private long identifier;
+ private byte protocolId;
+ private RouteDistinguisher routeDistinguisher;
+ private boolean isVpn;
+ private BGPPrefixLSIdentifier bgpPrefixLSIdentifier;
+
+ /**
+ * Resets parameters.
+ */
+ public BGPPrefixIPv4LSNlriVer4() {
+ this.identifier = 0;
+ this.protocolId = 0;
+ this.bgpPrefixLSIdentifier = null;
+ this.routeDistinguisher = null;
+ this.isVpn = false;
+ }
+
+ /**
+ * Constructor to initialize parameters for BGP PrefixLSNlri.
+ *
+ * @param identifier field in BGP PrefixLSNlri
+ * @param protocolId protocol Id
+ * @param bgpPrefixLSIdentifier prefix LS Identifier
+ * @param routeDistinguisher RouteDistinguisher
+ * @param isVpn vpn availability in message
+ */
+ public BGPPrefixIPv4LSNlriVer4(long identifier, byte protocolId, BGPPrefixLSIdentifier bgpPrefixLSIdentifier,
+ RouteDistinguisher routeDistinguisher, boolean isVpn) {
+ this.identifier = identifier;
+ this.protocolId = protocolId;
+ this.bgpPrefixLSIdentifier = bgpPrefixLSIdentifier;
+ this.routeDistinguisher = routeDistinguisher;
+ this.isVpn = isVpn;
+ }
+
+ /**
+ * Reads from channelBuffer and parses Prefix LS Nlri.
+ *
+ * @param cb ChannelBuffer
+ * @param afi Address family identifier
+ * @param safi Subsequent address family identifier
+ * @return object of BGPPrefixIPv4LSNlriVer4
+ * @throws BGPParseException while parsing Prefix LS Nlri
+ */
+ public static BGPPrefixIPv4LSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BGPParseException {
+
+ boolean isVpn = false;
+ RouteDistinguisher routeDistinguisher = null;
+ if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
+ routeDistinguisher = new RouteDistinguisher();
+ routeDistinguisher = RouteDistinguisher.read(cb);
+ isVpn = true;
+ } else {
+ isVpn = false;
+ }
+ byte protocolId = cb.readByte();
+ long identifier = cb.readLong();
+
+ BGPPrefixLSIdentifier bgpPrefixLSIdentifier = new BGPPrefixLSIdentifier();
+ bgpPrefixLSIdentifier = BGPPrefixLSIdentifier.parsePrefixIdendifier(cb, protocolId);
+ return new BGPPrefixIPv4LSNlriVer4(identifier, protocolId, bgpPrefixLSIdentifier, routeDistinguisher, isVpn);
+ }
+
+ @Override
+ public NlriType getNlriType() {
+ return NlriType.PREFIX_IPV4;
+ }
+
+ @Override
+ public NodeDescriptors getLocalNodeDescriptors() {
+ return this.bgpPrefixLSIdentifier.getLocalNodeDescriptors();
+ }
+
+ @Override
+ public long getIdentifier() {
+ return this.identifier;
+ }
+
+ /**
+ * Set the prefix LS identifier.
+ *
+ * @param bgpPrefixLSIdentifier prefix identifier to set
+ */
+ public void setPrefixLSIdentifier(BGPPrefixLSIdentifier bgpPrefixLSIdentifier) {
+ this.bgpPrefixLSIdentifier = bgpPrefixLSIdentifier;
+ }
+
+ @Override
+ public PROTOCOLTYPE getProtocolId() throws BGPParseException {
+ switch (protocolId) {
+ case Constants.ISIS_LEVELONE:
+ return PROTOCOLTYPE.ISIS_LevelOne;
+ case Constants.ISIS_LEVELTWO:
+ return PROTOCOLTYPE.ISIS_LevelTwo;
+ case Constants.OSPFV2:
+ return PROTOCOLTYPE.OSPFv2;
+ case Constants.DIRECT:
+ return PROTOCOLTYPE.Direct;
+ case Constants.STATIC_CONFIGURATION:
+ return PROTOCOLTYPE.Static_Configuration;
+ case Constants.OSPFV3:
+ return PROTOCOLTYPE.OSPFv3;
+ default:
+ throw new BGPParseException("protocol id not valid");
+ }
+ }
+
+ /**
+ * Returns whether VPN is present or not.
+ *
+ * @return whether VPN is present or not
+ */
+ public boolean isVpnPresent() {
+ return this.isVpn;
+ }
+
+ /**
+ * Returns Prefix Identifier.
+ *
+ * @return Prefix Identifier
+ */
+ public BGPPrefixLSIdentifier getPrefixIdentifier() {
+ return this.bgpPrefixLSIdentifier;
+ }
+
+ @Override
+ public RouteDistinguisher getRouteDistinguisher() {
+ return this.routeDistinguisher;
+ }
+
+ @Override
+ public LinkedList<BGPValueType> getPrefixdescriptor() {
+ return this.bgpPrefixLSIdentifier.getPrefixdescriptor();
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("protocolId", protocolId)
+ .add("identifier", identifier)
+ .add("RouteDistinguisher ", routeDistinguisher)
+ .add("bgpPrefixLSIdentifier", bgpPrefixLSIdentifier)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPKeepaliveMsgVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPKeepaliveMsgVer4.java
index a6668b3a..10e6bb95 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPKeepaliveMsgVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPKeepaliveMsgVer4.java
@@ -98,21 +98,6 @@ class BGPKeepaliveMsgVer4 implements BGPKeepaliveMsg {
BGPHeader bgpMsgHeader;
@Override
- public BGPVersion getVersion() {
- return BGPVersion.BGP_4;
- }
-
- @Override
- public BGPType getType() {
- return BGPType.KEEP_ALIVE;
- }
-
- @Override
- public BGPHeader getHeader() {
- return this.bgpMsgHeader;
- }
-
- @Override
public Builder setHeader(BGPHeader bgpMsgHeader) {
this.bgpMsgHeader = bgpMsgHeader;
return this;
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java
new file mode 100644
index 00000000..064deada
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPNotificationMsgVer4.java
@@ -0,0 +1,266 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.protocol.ver4;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.protocol.BGPMessageReader;
+import org.onosproject.bgpio.protocol.BGPMessageWriter;
+import org.onosproject.bgpio.protocol.BGPNotificationMsg;
+import org.onosproject.bgpio.protocol.BGPType;
+import org.onosproject.bgpio.protocol.BGPVersion;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BGPHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * A NOTIFICATION message is sent when an error condition is detected. The BGP connection is closed immediately after it
+ * is sent.
+ */
+class BGPNotificationMsgVer4 implements BGPNotificationMsg {
+
+ /*
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Error code | Error subcode | Data (variable) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ REFERENCE : RFC 4271
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(BGPNotificationMsgVer4.class);
+
+ static final byte PACKET_VERSION = 4;
+ //BGPHeader(19) + Error code(1) + Error subcode(1)
+ static final int TOTAL_MESSAGE_MIN_LENGTH = 21;
+ static final int PACKET_MINIMUM_LENGTH = 2;
+ static final BGPType MSG_TYPE = BGPType.NOTIFICATION;
+ static final byte DEFAULT_ERRORSUBCODE = 0;
+ static final byte[] MARKER = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01};
+ static final byte MESSAGE_TYPE = 3;
+ static final BGPHeader DEFAULT_MESSAGE_HEADER = new BGPHeader(MARKER, BGPHeader.DEFAULT_HEADER_LENGTH,
+ MESSAGE_TYPE);
+
+ private byte errorCode;
+ private byte errorSubCode;
+ private byte[] data;
+ private BGPHeader bgpHeader;
+ public static final BGPNotificationMsgVer4.Reader READER = new Reader();
+
+ /**
+ * Resets fields.
+ */
+ public BGPNotificationMsgVer4() {
+ this.bgpHeader = null;
+ this.data = null;
+ this.errorCode = 0;
+ this.errorSubCode = 0;
+ }
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param bgpHeader BGP Header in notification message
+ * @param errorCode error code
+ * @param errorSubCode error subcode
+ * @param data field
+ */
+ public BGPNotificationMsgVer4(BGPHeader bgpHeader, byte errorCode, byte errorSubCode, byte[] data) {
+ this.bgpHeader = bgpHeader;
+ this.data = data;
+ this.errorCode = errorCode;
+ this.errorSubCode = errorSubCode;
+ }
+
+ /**
+ * Reader reads BGP Notification Message from the channel buffer.
+ */
+ static class Reader implements BGPMessageReader<BGPNotificationMsg> {
+ @Override
+ public BGPNotificationMsg readFrom(ChannelBuffer cb, BGPHeader bgpHeader) throws BGPParseException {
+ byte errorCode;
+ byte errorSubCode;
+ if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
+ throw new BGPParseException("Not enough readable bytes");
+ }
+ errorCode = cb.readByte();
+ errorSubCode = cb.readByte();
+ //Message Length = 21 + Data Length
+ int dataLength = bgpHeader.getLength() - TOTAL_MESSAGE_MIN_LENGTH;
+ byte[] data = new byte[dataLength];
+ cb.readBytes(data, 0, dataLength);
+ return new BGPNotificationMsgVer4(bgpHeader, errorCode, errorSubCode, data);
+ }
+ }
+
+ /**
+ * Builder class for BGP notification message.
+ */
+ static class Builder implements BGPNotificationMsg.Builder {
+ private byte errorCode;
+ private byte errorSubCode;
+ private byte[] data;
+ private BGPHeader bgpHeader;
+ private boolean isErrorCodeSet = false;
+ private boolean isErrorSubCodeSet = false;
+ private boolean isBGPHeaderSet = false;
+
+ @Override
+ public BGPNotificationMsg build() throws BGPParseException {
+ BGPHeader bgpHeader = this.isBGPHeaderSet ? this.bgpHeader : DEFAULT_MESSAGE_HEADER;
+ if (!this.isErrorCodeSet) {
+ throw new BGPParseException("Error code must be present");
+ }
+
+ byte errorSubCode = this.isErrorSubCodeSet ? this.errorSubCode : DEFAULT_ERRORSUBCODE;
+ return new BGPNotificationMsgVer4(bgpHeader, this.errorCode, errorSubCode, this.data);
+ }
+
+ @Override
+ public Builder setErrorCode(byte errorCode) {
+ this.errorCode = errorCode;
+ this.isErrorCodeSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setErrorSubCode(byte errorSubCode) {
+ this.errorSubCode = errorSubCode;
+ this.isErrorSubCodeSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+
+ @Override
+ public Builder setNotificationMsgHeader(BGPHeader header) {
+ this.bgpHeader = header;
+ this.isBGPHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setHeader(BGPHeader bgpMsgHeader) {
+ this.bgpHeader = bgpMsgHeader;
+ return this;
+ }
+ }
+
+ @Override
+ public BGPVersion getVersion() {
+ return BGPVersion.BGP_4;
+ }
+
+ @Override
+ public BGPType getType() {
+ return BGPType.NOTIFICATION;
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer cb) throws BGPParseException {
+ WRITER.write(cb, this);
+ }
+
+ static final Writer WRITER = new Writer();
+
+ /**
+ * Writer writes BGP notification message to channel buffer.
+ */
+ static class Writer implements BGPMessageWriter<BGPNotificationMsgVer4> {
+ @Override
+ public void write(ChannelBuffer cb, BGPNotificationMsgVer4 message) throws BGPParseException {
+ int msgStartIndex = cb.writerIndex();
+ int headerLenIndex = message.bgpHeader.write(cb);
+ if (headerLenIndex <= 0) {
+ throw new BGPParseException(BGPErrorType.MESSAGE_HEADER_ERROR, (byte) 0, null);
+ }
+ cb.writeByte(message.errorCode);
+ cb.writeByte(message.errorSubCode);
+ cb.writeBytes(message.data);
+
+ //Update message length field in notification message
+ int length = cb.writerIndex() - msgStartIndex;
+ cb.setShort(headerLenIndex, (short) length);
+ message.bgpHeader.setLength((short) length);
+ }
+ }
+
+ @Override
+ public byte getErrorCode() {
+ return this.errorCode;
+ }
+
+ /**
+ * Sets errorcode with specified errorcode.
+ *
+ * @param errorCode field
+ */
+ public void setErrorCode(byte errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ @Override
+ public byte getErrorSubCode() {
+ return this.errorSubCode;
+ }
+
+ /**
+ * Sets error subcode with specified errorSubCode.
+ *
+ * @param errorSubCode field
+ */
+ public void setErrorSubCode(byte errorSubCode) {
+ this.errorSubCode = errorSubCode;
+ }
+
+ @Override
+ public byte[] getData() {
+ return this.data;
+ }
+
+ /**
+ * Sets error data with specified data.
+ *
+ * @param data field
+ */
+ public void setData(byte[] data) {
+ this.data = data;
+ }
+
+ @Override
+ public BGPHeader getHeader() {
+ return this.bgpHeader;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("bgpHeader", bgpHeader)
+ .add("data", data)
+ .add("errorCode", errorCode)
+ .add("errorSubCode", errorSubCode)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java
index 1348ecfd..b50342d6 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onosproject.bgpio.protocol.ver4;
import java.util.LinkedList;
@@ -29,6 +28,8 @@ import org.onosproject.bgpio.protocol.BGPVersion;
import org.onosproject.bgpio.types.BGPErrorType;
import org.onosproject.bgpio.types.BGPHeader;
import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv;
+import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,8 +68,13 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
public static final int MSG_HEADER_LENGTH = 19;
public static final int MARKER_LENGTH = 16;
public static final int DEFAULT_HOLD_TIME = 120;
+ public static final short AS_TRANS = 23456;
public static final int OPT_PARA_TYPE_CAPABILITY = 2;
public static final BGPType MSG_TYPE = BGPType.OPEN;
+ public static final short AFI = 16388;
+ public static final byte SAFI = 71;
+ public static final byte RES = 0;
+ public static final int FOUR_OCTET_AS_NUM_CAPA_TYPE = 65;
public static final byte[] MARKER = new byte[]{(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff};
@@ -79,6 +85,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
private short asNumber;
private short holdTime;
private int bgpId;
+ private boolean isLargeAsCapabilitySet;
private LinkedList<BGPValueType> capabilityTlv;
public static final BGPOpenMsgVer4.Reader READER = new Reader();
@@ -98,18 +105,12 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
/**
* Constructor to initialize all variables of BGP Open message.
*
- * @param bgpMsgHeader
- * BGP Header in open message
- * @param version
- * BGP version in open message
- * @param holdTime
- * hold time in open message
- * @param asNumber
- * AS number in open message
- * @param bgpId
- * BGP identifier in open message
- * @param capabilityTlv
- * capabilities in open message
+ * @param bgpMsgHeader BGP Header in open message
+ * @param version BGP version in open message
+ * @param holdTime hold time in open message
+ * @param asNumber AS number in open message
+ * @param bgpId BGP identifier in open message
+ * @param capabilityTlv capabilities in open message
*/
public BGPOpenMsgVer4(BGPHeader bgpMsgHeader, byte version, short asNumber, short holdTime,
int bgpId, LinkedList<BGPValueType> capabilityTlv) {
@@ -236,7 +237,44 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
LinkedList<BGPValueType> capabilityTlv = new LinkedList<>();
- // TODO: Capability parsing
+ while (cb.readableBytes() > 0) {
+ BGPValueType tlv;
+ short type = cb.readByte();
+ short length = cb.readByte();
+
+ switch (type) {
+ case FourOctetAsNumCapabilityTlv.TYPE:
+ log.debug("FourOctetAsNumCapabilityTlv");
+ if (FourOctetAsNumCapabilityTlv.LENGTH != length) {
+ throw new BGPParseException("Invalid length received for FourOctetAsNumCapabilityTlv.");
+ }
+ if (length > cb.readableBytes()) {
+ throw new BGPParseException("Four octet as num tlv length"
+ + " is more than readableBytes.");
+ }
+ int as4Num = cb.readInt();
+ tlv = new FourOctetAsNumCapabilityTlv(as4Num);
+ break;
+ case MultiProtocolExtnCapabilityTlv.TYPE:
+ log.debug("MultiProtocolExtnCapabilityTlv");
+ if (MultiProtocolExtnCapabilityTlv.LENGTH != length) {
+ throw new BGPParseException("Invalid length received for MultiProtocolExtnCapabilityTlv.");
+ }
+ if (length > cb.readableBytes()) {
+ throw new BGPParseException("BGP LS tlv length is more than readableBytes.");
+ }
+ short afi = cb.readShort();
+ byte res = cb.readByte();
+ byte safi = cb.readByte();
+ tlv = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
+ break;
+ default:
+ log.debug("Warning: Unsupported TLV: " + type);
+ cb.skipBytes(length);
+ continue;
+ }
+ capabilityTlv.add(tlv);
+ }
return capabilityTlv;
}
@@ -248,11 +286,13 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
private boolean isHeaderSet = false;
private BGPHeader bgpMsgHeader;
private boolean isHoldTimeSet = false;
- private short holdTime;
+ private short holdTime;
private boolean isAsNumSet = false;
private short asNumber;
private boolean isBgpIdSet = false;
private int bgpId;
+ private boolean isLargeAsCapabilityTlvSet = false;
+ private boolean isLsCapabilityTlvSet = false;
LinkedList<BGPValueType> capabilityTlv = new LinkedList<>();
@@ -269,34 +309,30 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
throw new BGPParseException("BGPID is not set (mandatory)");
}
- // TODO: capabilities build
+ if (this.isLargeAsCapabilityTlvSet) {
+ BGPValueType tlv;
+ int iValue = this.getAsNumber();
+ tlv = new FourOctetAsNumCapabilityTlv(iValue);
+ this.capabilityTlv.add(tlv);
+ }
+
+ if (this.isLsCapabilityTlvSet) {
+ BGPValueType tlv;
+ tlv = new MultiProtocolExtnCapabilityTlv(AFI, RES, SAFI);
+ this.capabilityTlv.add(tlv);
+ }
return new BGPOpenMsgVer4(bgpMsgHeader, PACKET_VERSION, this.asNumber, holdTime, this.bgpId,
this.capabilityTlv);
}
@Override
- public BGPHeader getHeader() {
- return this.bgpMsgHeader;
- }
-
- @Override
public Builder setHeader(BGPHeader bgpMsgHeader) {
this.bgpMsgHeader = bgpMsgHeader;
return this;
}
@Override
- public BGPVersion getVersion() {
- return BGPVersion.BGP_4;
- }
-
- @Override
- public BGPType getType() {
- return MSG_TYPE;
- }
-
- @Override
public short getHoldTime() {
return this.holdTime;
}
@@ -342,6 +378,18 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
this.capabilityTlv = capabilityTlv;
return this;
}
+
+ @Override
+ public Builder setLargeAsCapabilityTlv(boolean isLargeAsCapabilitySet) {
+ this.isLargeAsCapabilityTlvSet = isLargeAsCapabilitySet;
+ return this;
+ }
+
+ @Override
+ public Builder setLsCapabilityTlv(boolean isLsCapabilitySet) {
+ this.isLsCapabilityTlvSet = isLsCapabilitySet;
+ return this;
+ }
}
@Override
@@ -364,6 +412,7 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
public void write(ChannelBuffer cb, BGPOpenMsgVer4 message) throws BGPParseException {
int optParaLen = 0;
+ int as4num = 0;
int startIndex = cb.writerIndex();
@@ -377,8 +426,29 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg {
// write version in 1-octet
cb.writeByte(message.version);
- // TODO : Write AS number based on capabilities
- cb.writeShort(message.asNumber);
+ // get as4num if LS Capability is set
+ if (message.isLargeAsCapabilitySet) {
+ LinkedList<BGPValueType> capabilityTlv = message
+ .getCapabilityTlv();
+ ListIterator<BGPValueType> listIterator = capabilityTlv
+ .listIterator();
+
+ while (listIterator.hasNext()) {
+ BGPValueType tlv = listIterator.next();
+ if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) {
+ as4num = ((FourOctetAsNumCapabilityTlv) tlv).getInt();
+ break;
+ }
+ }
+ }
+
+ if ((message.isLargeAsCapabilitySet) && (as4num > 65535)) {
+ // write As number as AS_TRANS
+ cb.writeShort(AS_TRANS);
+ } else {
+ // write AS number in next 2-octet
+ cb.writeShort(message.asNumber);
+ }
// write HoldTime in next 2-octet
cb.writeShort(message.holdTime);
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java
new file mode 100755
index 00000000..61570285
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides FourOctetAsNumCapabilityTlv Capability Tlv.
+ */
+public class FourOctetAsNumCapabilityTlv implements BGPValueType {
+
+ /**
+ * support to indicate its support for four-octet AS numbers -CAPABILITY TLV format.
+ */
+ protected static final Logger log = LoggerFactory
+ .getLogger(FourOctetAsNumCapabilityTlv.class);
+
+ public static final byte TYPE = 65;
+ public static final byte LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ * @param rawValue FourOctetAsNumCapabilityTlv
+ */
+ public FourOctetAsNumCapabilityTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * constructor to initialize raw.
+ * @param raw AS number
+ * @return object of FourOctetAsNumCapabilityTlv
+ */
+ public static FourOctetAsNumCapabilityTlv of(final int raw) {
+ return new FourOctetAsNumCapabilityTlv(raw);
+ }
+
+ /**
+ * Returns value of TLV.
+ * @return int value of rawValue
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof FourOctetAsNumCapabilityTlv) {
+ FourOctetAsNumCapabilityTlv other = (FourOctetAsNumCapabilityTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int iLenStartIndex = cb.writerIndex();
+ cb.writeByte(TYPE);
+ cb.writeByte(LENGTH);
+ cb.writeInt(rawValue);
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of FourOctetAsNumCapabilityTlv.
+ * @param cb type of channel buffer
+ * @return object of FourOctetAsNumCapabilityTlv
+ */
+ public static FourOctetAsNumCapabilityTlv read(ChannelBuffer cb) {
+ return FourOctetAsNumCapabilityTlv.of(cb.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue).toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java
new file mode 100755
index 00000000..9beff68c
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java
@@ -0,0 +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.bgpio.types;
+
+import java.util.Objects;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides MultiProtocolExtnCapabilityTlv.
+ */
+public class MultiProtocolExtnCapabilityTlv implements BGPValueType {
+
+ /*
+ 0 7 15 23 31
+ +-------+-------+-------+-------+
+ | AFI | Res | SAFI |
+ +-------+-------+-------+-------+
+
+ Multiprotocol Extensions CAPABILITY TLV format
+ REFERENCE : RFC 4760
+ */
+ protected static final Logger log = LoggerFactory
+ .getLogger(MultiProtocolExtnCapabilityTlv.class);
+
+ public static final byte TYPE = 1;
+ public static final byte LENGTH = 4;
+
+ private final short afi;
+ private final byte res;
+ private final byte safi;
+
+ /**
+ * Constructor to initialize variables.
+ * @param afi Address Family Identifiers
+ * @param res reserved field
+ * @param safi Subsequent Address Family Identifier
+ */
+ public MultiProtocolExtnCapabilityTlv(short afi, byte res, byte safi) {
+ this.afi = afi;
+ this.res = res;
+ this.safi = safi;
+ }
+
+ /**
+ * Returns object of MultiProtocolExtnCapabilityTlv.
+ * @param afi Address Family Identifiers
+ * @param res reserved field
+ * @param safi Subsequent Address Family Identifier
+ * @return object of MultiProtocolExtnCapabilityTlv
+ */
+ public static MultiProtocolExtnCapabilityTlv of(short afi, byte res,
+ byte safi) {
+ return new MultiProtocolExtnCapabilityTlv(afi, res, safi);
+ }
+
+ /**
+ * Returns afi Address Family Identifiers value.
+ * @return afi Address Family Identifiers value
+ */
+ public short getAFI() {
+ return afi;
+ }
+
+ /**
+ * Returns res reserved field value.
+ * @return res reserved field value
+ */
+ public byte getRes() {
+ return res;
+ }
+
+ /**
+ * Returns safi Subsequent Address Family Identifier value.
+ * @return safi Subsequent Address Family Identifier value
+ */
+ public byte getSAFI() {
+ return safi;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(afi, res, safi);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MultiProtocolExtnCapabilityTlv) {
+ MultiProtocolExtnCapabilityTlv other = (MultiProtocolExtnCapabilityTlv) obj;
+ return Objects.equals(this.afi, other.afi)
+ && Objects.equals(this.res, other.res)
+ && Objects.equals(this.safi, other.safi);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int iLenStartIndex = cb.writerIndex();
+ cb.writeByte(TYPE);
+ cb.writeByte(LENGTH);
+
+ // write afi
+ cb.writeShort(afi);
+
+ // write res
+ cb.writeByte(res);
+
+ // write safi
+ cb.writeByte(safi);
+
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of MultiprotocolCapabilityTlv.
+ * @param cb of type channel buffer
+ * @return object of MultiProtocolExtnCapabilityTlv
+ */
+ public static BGPValueType read(ChannelBuffer cb) {
+ short afi = cb.readShort();
+ byte res = cb.readByte();
+ byte safi = cb.readByte();
+ return new MultiProtocolExtnCapabilityTlv(afi, res, safi);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("AFI", afi)
+ .add("Reserved", res)
+ .add("SAFI", safi).toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
new file mode 100644
index 00000000..d0267092
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.bgpio.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ * Implementation of RouteDistinguisher.
+ */
+public class RouteDistinguisher {
+
+ private long routeDistinguisher;
+
+ /**
+ * Resets fields.
+ */
+ public RouteDistinguisher() {
+ this.routeDistinguisher = 0;
+ }
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param routeDistinguisher route distinguisher
+ */
+ public RouteDistinguisher(long routeDistinguisher) {
+ this.routeDistinguisher = routeDistinguisher;
+ }
+
+ /**
+ * Reads route distinguisher from channelBuffer.
+ *
+ * @param cb channelBuffer
+ * @return object of RouteDistinguisher
+ */
+ public static RouteDistinguisher read(ChannelBuffer cb) {
+ return new RouteDistinguisher(cb.readLong());
+ }
+
+ /**
+ * Returns route distinguisher.
+ *
+ * @return route distinguisher
+ */
+ public long getRouteDistinguisher() {
+ return this.routeDistinguisher;
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java
new file mode 100755
index 00000000..00dffb58
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.types.attr;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP attribute node router ID.
+ */
+public class BgpAttrRouterIdV4 implements BGPValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpAttrRouterIdV4.class);
+
+ public short sType;
+
+ /* IPv4 Router-ID of Node */
+ private Ip4Address ip4RouterId;
+
+ /**
+ * Constructor to initialize the value.
+ *
+ * @param ip4RouterId IPV4 address of router
+ * @param sType TLV type
+ */
+ BgpAttrRouterIdV4(Ip4Address ip4RouterId, short sType) {
+ this.ip4RouterId = ip4RouterId;
+ this.sType = sType;
+ }
+
+ /**
+ * Reads the IPv4 Router-ID.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BgpAttrRouterIdV4
+ * @throws BGPParseException while parsing BgpAttrNodeRouterId
+ */
+ public static BgpAttrRouterIdV4 read(ChannelBuffer cb, short sType)
+ throws BGPParseException {
+ byte[] ipBytes;
+ Ip4Address ip4RouterId;
+
+ short lsAttrLength = cb.readShort();
+
+ if (4 != lsAttrLength) {
+ Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
+ BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ ipBytes = new byte[lsAttrLength];
+ cb.readBytes(ipBytes);
+ ip4RouterId = Ip4Address.valueOf(ipBytes);
+ return new BgpAttrRouterIdV4(ip4RouterId, sType);
+ }
+
+ /**
+ * Returns the IPV4 router ID.
+ *
+ * @return Router ID
+ */
+ Ip4Address getAttrRouterId() {
+ return ip4RouterId;
+ }
+
+ @Override
+ public short getType() {
+ return sType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ip4RouterId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpAttrRouterIdV4) {
+ BgpAttrRouterIdV4 other = (BgpAttrRouterIdV4) obj;
+ return Objects.equals(ip4RouterId, other.ip4RouterId);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("ip4RouterId", ip4RouterId).toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java
new file mode 100755
index 00000000..561c3d4c
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.types.attr;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onlab.packet.Ip6Address;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP attribute IPv6 router ID.
+ */
+public class BgpAttrRouterIdV6 implements BGPValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpAttrRouterIdV6.class);
+
+ public short sType;
+
+ /* IPv4 Router-ID of Node */
+ private Ip6Address ip6RouterId;
+
+ /**
+ * Constructor to initialize the value.
+ *
+ * @param ip6RouterId IPV6 address of the router ID
+ * @param sType TLV type
+ */
+ BgpAttrRouterIdV6(Ip6Address ip6RouterId, short sType) {
+ this.ip6RouterId = ip6RouterId;
+ this.sType = sType;
+ }
+
+ /**
+ * Reads the IPv6 Router-ID.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BgpAttrRouterIdV6
+ * @throws BGPParseException while parsing BgpAttrRouterIdV6
+ */
+ public static BgpAttrRouterIdV6 read(ChannelBuffer cb, short sType)
+ throws BGPParseException {
+ byte[] ipBytes;
+ Ip6Address ip6RouterId;
+
+ short lsAttrLength = cb.readShort();
+
+ if (16 != lsAttrLength) {
+ Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
+ BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ ipBytes = new byte[lsAttrLength];
+ cb.readBytes(ipBytes);
+ ip6RouterId = Ip6Address.valueOf(ipBytes);
+ return new BgpAttrRouterIdV6(ip6RouterId, sType);
+ }
+
+ /**
+ * Returns IPV6 router ID.
+ *
+ * @return Router ID
+ */
+ Ip6Address getAttrRouterId() {
+ return ip6RouterId;
+ }
+
+ @Override
+ public short getType() {
+ return sType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ip6RouterId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpAttrRouterIdV6) {
+ BgpAttrRouterIdV6 other = (BgpAttrRouterIdV6) obj;
+ return Objects.equals(ip6RouterId, other.ip6RouterId);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("ip6RouterId", ip6RouterId).toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
new file mode 100755
index 00000000..50591ecf
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.types.attr;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP link name attribute.
+ */
+public class BgpLinkAttrName implements BGPValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpLinkAttrName.class);
+
+ public static final int ATTRLINK_NAME = 1098;
+
+ /* Link Name */
+ private byte[] linkName;
+
+ /**
+ * Constructor to initialize the values.
+ *
+ * @param linkName link name
+ */
+ BgpLinkAttrName(byte[] linkName) {
+ this.linkName = Arrays.copyOf(linkName, linkName.length);
+ }
+
+ /**
+ * Reads the BGP link attributes Name.
+ *
+ * @param cb Channel buffer
+ * @return object of type BgpLinkAttrName
+ * @throws BGPParseException while parsing BgpLinkAttrName
+ */
+ public static BgpLinkAttrName read(ChannelBuffer cb)
+ throws BGPParseException {
+ byte[] linkName;
+ short lsAttrLength = cb.readShort();
+
+ if (cb.readableBytes() < lsAttrLength) {
+ Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
+ BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ linkName = new byte[lsAttrLength];
+ cb.readBytes(linkName);
+ return new BgpLinkAttrName(linkName);
+ }
+
+ /**
+ * Returns the link name.
+ *
+ * @return link name
+ */
+ byte[] getAttrLinkName() {
+ return linkName;
+ }
+
+ @Override
+ public short getType() {
+ return ATTRLINK_NAME;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(linkName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpLinkAttrName) {
+ BgpLinkAttrName other = (BgpLinkAttrName) obj;
+ return Objects.equals(linkName, other.linkName);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("linkName", linkName).toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIGPFlags.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIGPFlags.java
new file mode 100755
index 00000000..035d706c
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIGPFlags.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.types.attr;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP prefix IGP Flag attribute.
+ */
+public class BgpPrefixAttrIGPFlags implements BGPValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpPrefixAttrIGPFlags.class);
+
+ public static final int ATTR_PREFIX_FLAGBIT = 1152;
+ public static final int ATTR_PREFIX_FLAG_LEN = 1;
+
+ public static final int FIRST_BIT = 0x80;
+ public static final int SECOND_BIT = 0x40;
+ public static final int THIRD_BIT = 0x20;
+ public static final int FOURTH_BIT = 0x01;
+
+ /* Prefix IGP flag bit TLV */
+ private boolean bisisUpDownBit = false;
+ private boolean bOspfNoUnicastBit = false;
+ private boolean bOspfLclAddrBit = false;
+ private boolean bOspfNSSABit = false;
+
+ /**
+ * Constructor to initialize the value.
+ *
+ * @param bisisUpDownBit IS-IS Up/Down Bit
+ * @param bOspfNoUnicastBit OSPF no unicast Bit
+ * @param bOspfLclAddrBit OSPF local address Bit
+ * @param bOspfNSSABit OSPF propagate NSSA Bit
+ */
+ BgpPrefixAttrIGPFlags(boolean bisisUpDownBit, boolean bOspfNoUnicastBit,
+ boolean bOspfLclAddrBit, boolean bOspfNSSABit) {
+ this.bisisUpDownBit = bisisUpDownBit;
+ this.bOspfNoUnicastBit = bOspfNoUnicastBit;
+ this.bOspfLclAddrBit = bOspfLclAddrBit;
+ this.bOspfNSSABit = bOspfNSSABit;
+ }
+
+ /**
+ * Reads the IGP Flags.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BgpPrefixAttrIGPFlags
+ * @throws BGPParseException while parsing BgpPrefixAttrIGPFlags
+ */
+ public static BgpPrefixAttrIGPFlags read(ChannelBuffer cb)
+ throws BGPParseException {
+ boolean bisisUpDownBit = false;
+ boolean bOspfNoUnicastBit = false;
+ boolean bOspfLclAddrBit = false;
+ boolean bOspfNSSABit = false;
+
+ short lsAttrLength = cb.readShort();
+
+ if ((lsAttrLength != ATTR_PREFIX_FLAG_LEN)
+ || (cb.readableBytes() < lsAttrLength)) {
+ Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
+ BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ byte nodeFlagBits = cb.readByte();
+
+ bisisUpDownBit = ((nodeFlagBits & (byte) FIRST_BIT) == FIRST_BIT);
+ bOspfNoUnicastBit = ((nodeFlagBits & (byte) SECOND_BIT) == SECOND_BIT);
+ bOspfLclAddrBit = ((nodeFlagBits & (byte) THIRD_BIT) == THIRD_BIT);
+ bOspfNSSABit = ((nodeFlagBits & (byte) FOURTH_BIT) == FOURTH_BIT);
+
+ return new BgpPrefixAttrIGPFlags(bisisUpDownBit, bOspfNoUnicastBit,
+ bOspfLclAddrBit, bOspfNSSABit);
+ }
+
+ /**
+ * Returns the IS-IS Up/Down Bit set or not.
+ *
+ * @return IS-IS Up/Down Bit set or not
+ */
+ boolean getisisUpDownBit() {
+ return bisisUpDownBit;
+ }
+
+ /**
+ * Returns the OSPF no unicast Bit set or not.
+ *
+ * @return OSPF no unicast Bit set or not
+ */
+ boolean getOspfNoUnicastBit() {
+ return bOspfNoUnicastBit;
+ }
+
+ /**
+ * Returns the OSPF local address Bit set or not.
+ *
+ * @return OSPF local address Bit set or not
+ */
+ boolean getOspfLclAddrBit() {
+ return bOspfLclAddrBit;
+ }
+
+ /**
+ * Returns the OSPF propagate NSSA Bit set or not.
+ *
+ * @return OSPF propagate NSSA Bit set or not
+ */
+ boolean getOspfNSSABit() {
+ return bOspfNSSABit;
+ }
+
+ @Override
+ public short getType() {
+ return ATTR_PREFIX_FLAGBIT;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit,
+ bOspfNSSABit);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpPrefixAttrIGPFlags) {
+ BgpPrefixAttrIGPFlags other = (BgpPrefixAttrIGPFlags) obj;
+ return Objects.equals(bisisUpDownBit, other.bisisUpDownBit)
+ && Objects.equals(bOspfNoUnicastBit,
+ other.bOspfNoUnicastBit)
+ && Objects.equals(bOspfLclAddrBit, other.bOspfLclAddrBit)
+ && Objects.equals(bOspfNSSABit, other.bOspfNSSABit);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("bisisUpDownBit", bisisUpDownBit)
+ .add("bOspfNoUnicastBit", bOspfNoUnicastBit)
+ .add("bOspfLclAddrBit", bOspfLclAddrBit)
+ .add("bOspfNSSABit", bOspfNSSABit).toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java
new file mode 100755
index 00000000..0cf02386
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.types.attr;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP prefix route tag attribute.
+ */
+public class BgpPrefixAttrRouteTag implements BGPValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpPrefixAttrRouteTag.class);
+
+ public static final int ATTR_PREFIX_ROUTETAG = 1153;
+
+ /* Prefix Route Tag */
+ private int[] pfxRouteTag;
+
+ /**
+ * Constructor to initialize the values.
+ *
+ * @param pfxRouteTag prefix route tag
+ */
+ BgpPrefixAttrRouteTag(int[] pfxRouteTag) {
+ this.pfxRouteTag = Arrays.copyOf(pfxRouteTag, pfxRouteTag.length);
+ }
+
+ /**
+ * Reads the Route Tag.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BgpPrefixAttrRouteTag
+ * @throws BGPParseException while parsing BgpPrefixAttrRouteTag
+ */
+ public static BgpPrefixAttrRouteTag read(ChannelBuffer cb)
+ throws BGPParseException {
+ int[] pfxRouteTag;
+
+ short lsAttrLength = cb.readShort();
+ int len = lsAttrLength / Integer.SIZE;
+
+ if (cb.readableBytes() < lsAttrLength) {
+ Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
+ BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ pfxRouteTag = new int[lsAttrLength];
+
+ for (int i = 0; i < len; i++) {
+ pfxRouteTag[i] = cb.readInt();
+ }
+
+ return new BgpPrefixAttrRouteTag(pfxRouteTag);
+ }
+
+ /**
+ * Returns the prefix route tag.
+ *
+ * @return route tag
+ */
+ int[] getPfxRouteTag() {
+ return pfxRouteTag;
+ }
+
+ @Override
+ public short getType() {
+ return ATTR_PREFIX_ROUTETAG;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pfxRouteTag);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpPrefixAttrRouteTag) {
+ BgpPrefixAttrRouteTag other = (BgpPrefixAttrRouteTag) obj;
+ return Objects.equals(pfxRouteTag, other.pfxRouteTag);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("pfxRouteTag", pfxRouteTag).toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java
new file mode 100644
index 00000000..9649bf16
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.util;
+
+/**
+ * Provides Constants usage for BGP.
+ */
+public final class Constants {
+ private Constants() {
+ }
+
+ public static final short TYPE_AND_LEN = 4;
+ public static final short TYPE_AND_LEN_AS_SHORT = 4;
+ public static final short TYPE_AND_LEN_AS_BYTE = 3;
+ public static final int ISIS_LEVELONE = 1;
+ public static final int ISIS_LEVELTWO = 2;
+ public static final int OSPFV2 = 3;
+ public static final int DIRECT = 4;
+ public static final int STATIC_CONFIGURATION = 5;
+ public static final int OSPFV3 = 6;
+ public static final short AFI_VALUE = 16388;
+ public static final byte VPN_SAFI_VALUE = (byte) 0x80;
+ public static final byte SAFI_VALUE = 71;
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPChannelHandler.java b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPChannelHandler.java
index 942d3658..c17736ed 100755
--- a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPChannelHandler.java
+++ b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPChannelHandler.java
@@ -16,19 +16,616 @@
package org.onosproject.bgp.controller.impl;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.channels.ClosedChannelException;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.ExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
+import org.jboss.netty.handler.timeout.ReadTimeoutException;
+import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
+import org.onlab.packet.IpAddress;
+import org.onosproject.bgp.controller.BGPCfg;
+import org.onosproject.bgp.controller.BGPId;
+import org.onosproject.bgp.controller.BGPPeer;
+import org.onosproject.bgp.controller.BGPPeerCfg;
+import org.onosproject.bgp.controller.impl.BGPControllerImpl.BGPPeerManager;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.protocol.BGPMessage;
+//import org.onosproject.bgpio.protocol.BGPOpenMsg;
+import org.onosproject.bgpio.protocol.BGPType;
+import org.onosproject.bgpio.protocol.BGPVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Channel handler deals with the bgp peer connection and dispatches messages from peer to the appropriate locations.
*/
class BGPChannelHandler extends IdleStateAwareChannelHandler {
- // TODO: implement FSM and session handling mechanism
+ private static final Logger log = LoggerFactory.getLogger(BGPChannelHandler.class);
+
+ static final int BGP_MAX_KEEPALIVE_INTERVAL = 3;
+ private BGPPeer bgpPeer;
+ private BGPId thisbgpId;
+ Channel channel;
+ private BGPKeepAliveTimer keepAliveTimer = null;
+ private short peerHoldTime = 0;
+ private short negotiatedHoldTime = 0;
+ private short peerAsNum;
+ private int peerIdentifier;
+ private BGPPacketStatsImpl bgpPacketStats;
+ static final int MAX_WRONG_COUNT_PACKET = 5;
+
+ // State needs to be volatile because the HandshakeTimeoutHandler
+ // needs to check if the handshake is complete
+ private volatile ChannelState state;
+
+ // When a bgp peer with a ip addresss is found (i.e we already have a
+ // connected peer with the same ip), the new peer is immediately
+ // disconnected. At that point netty callsback channelDisconnected() which
+ // proceeds to cleaup peer state - we need to ensure that it does not cleanup
+ // peer state for the older (still connected) peer
+ private volatile Boolean duplicateBGPIdFound;
+ // Indicates the bgp version used by this bgp peer
+ protected BGPVersion bgpVersion;
+ private BGPControllerImpl bgpControllerImpl;
+ private BGPPeerManager peerManager;
+ private InetSocketAddress inetAddress;
+ private IpAddress ipAddress;
+ private SocketAddress address;
+ private String peerAddr;
+ private BGPCfg bgpconfig;
+
/**
* Create a new unconnected BGPChannelHandler.
*
* @param bgpCtrlImpl bgp controller implementation object
*/
BGPChannelHandler(BGPControllerImpl bgpCtrlImpl) {
+ this.bgpControllerImpl = bgpCtrlImpl;
+ this.peerManager = bgpCtrlImpl.getPeerManager();
+ this.state = ChannelState.IDLE;
+ this.duplicateBGPIdFound = Boolean.FALSE;
+ this.bgpPacketStats = new BGPPacketStatsImpl();
+ this.bgpconfig = bgpCtrlImpl.getConfig();
+ }
+
+ // To disconnect peer session.
+ public void disconnectPeer() {
+ bgpPeer.disconnectPeer();
+ }
+
+ // *************************
+ // Channel State Machine
+ // *************************
+
+ /**
+ * The state machine for handling the peer/channel state. All state transitions should happen from within the state
+ * machine (and not from other parts of the code)
+ */
+ enum ChannelState {
+ /**
+ * Initial state before channel is connected.
+ */
+ IDLE(false) {
+
+ },
+
+ OPENSENT(false) {
+ @Override
+ void processBGPMessage(BGPChannelHandler h, BGPMessage m) throws IOException, BGPParseException {
+ log.debug("message received in OPENSENT state");
+ // check for OPEN message
+ if (m.getType() != BGPType.OPEN) {
+ // When the message type is not keep alive message increment the wrong packet statistics
+ h.processUnknownMsg();
+ log.debug("Message is not OPEN message");
+ } else {
+ log.debug("Sending keep alive message in OPENSENT state");
+ h.bgpPacketStats.addInPacket();
+
+ // TODO: initialize openmessage BGPOpenMsg pOpenmsg = (BGPOpenMsg) m;
+ // TODO: initialize identifier from open messgae h.peerIdentifier = pOpenmsg.getBgpId();
+
+ // validate capabilities and open msg
+ if (h.openMsgValidation(h)) {
+ log.debug("Sending handshake OPEN message");
+
+ /*
+ * RFC 4271, section 4.2: Upon receipt of an OPEN message, a BGP speaker MUST calculate the
+ * value of the Hold Timer by using the smaller of its configured Hold Time and the Hold Time
+ * received in the OPEN message
+ */
+ // TODO: initialize holdtime from open message h.peerHoldTime = pOpenmsg.getHoldTime();
+ if (h.peerHoldTime < h.bgpconfig.getHoldTime()) {
+ h.channel.getPipeline().replace("holdTime",
+ "holdTime",
+ new ReadTimeoutHandler(BGPPipelineFactory.TIMER,
+ h.peerHoldTime));
+ }
+
+ log.info("Hold Time : " + h.peerHoldTime);
+
+ // TODO: get AS number for open message update AS number
+ }
+
+ // Send keepalive message to peer.
+ h.sendKeepAliveMessage();
+ h.bgpPacketStats.addOutPacket();
+ h.setState(OPENCONFIRM);
+ h.bgpconfig.setPeerConnState(h.peerAddr, BGPPeerCfg.State.OPENCONFIRM);
+ }
+ }
+ },
+
+ OPENWAIT(false) {
+ @Override
+ void processBGPMessage(BGPChannelHandler h, BGPMessage m) throws IOException, BGPParseException {
+ log.debug("Message received in OPEN WAIT State");
+
+ // check for open message
+ if (m.getType() != BGPType.OPEN) {
+ // When the message type is not open message increment the wrong packet statistics
+ h.processUnknownMsg();
+ log.debug("Message is not OPEN message");
+ } else {
+ h.bgpPacketStats.addInPacket();
+
+ // TODO: initialize open message BGPOpenMsg pOpenmsg = (BGPOpenMsg) m;
+
+ // Validate open message
+ if (h.openMsgValidation(h)) {
+ log.debug("Sending handshake OPEN message");
+
+ /*
+ * RFC 4271, section 4.2: Upon receipt of an OPEN message, a BGP speaker MUST calculate the
+ * value of the Hold Timer by using the smaller of its configured Hold Time and the Hold Time
+ * received in the OPEN message
+ */
+ // TODO: get hold time from open message h.peerHoldTime = pOpenmsg.getHoldTime();
+ if (h.peerHoldTime < h.bgpconfig.getHoldTime()) {
+ h.channel.getPipeline().replace("holdTime",
+ "holdTime",
+ new ReadTimeoutHandler(BGPPipelineFactory.TIMER,
+ h.peerHoldTime));
+ }
+
+ log.debug("Hold Time : " + h.peerHoldTime);
+
+ //TODO: update AS number form open messsage update AS number
+
+ h.sendHandshakeOpenMessage();
+ h.bgpPacketStats.addOutPacket();
+ h.setState(OPENCONFIRM);
+ }
+ }
+ }
+ },
+
+ OPENCONFIRM(false) {
+ @Override
+ void processBGPMessage(BGPChannelHandler h, BGPMessage m) throws IOException, BGPParseException {
+ log.debug("Message received in OPENCONFIRM state");
+ // check for keep alive message
+ if (m.getType() != BGPType.KEEP_ALIVE) {
+ // When the message type is not keep alive message handle the wrong packet
+ h.processUnknownMsg();
+ log.debug("Message is not KEEPALIVE message");
+ } else {
+
+ // Set the peer connected status
+ h.bgpPacketStats.addInPacket();
+ log.debug("Sending keep alive message in OPENCONFIRM state");
+
+ final InetSocketAddress inetAddress = (InetSocketAddress) h.address;
+ h.thisbgpId = BGPId.bgpId(IpAddress.valueOf(inetAddress.getAddress()));
+
+ h.bgpPeer = h.peerManager.getBGPPeerInstance(h.thisbgpId, h.bgpVersion, h.bgpPacketStats);
+ // set the status fo bgp as connected
+ h.bgpPeer.setConnected(true);
+ h.bgpPeer.setChannel(h.channel);
+
+ // set specific parameters to bgp peer
+ h.bgpPeer.setBgpPeerVersion(h.bgpVersion);
+ h.bgpPeer.setBgpPeerASNum(h.peerAsNum);
+ h.bgpPeer.setBgpPeerHoldTime(h.peerHoldTime);
+ h.bgpPeer.setBgpPeerIdentifier(h.peerIdentifier);
+
+ h.negotiatedHoldTime = (h.peerHoldTime < h.bgpconfig.getHoldTime()) ? h.peerHoldTime : h.bgpconfig
+ .getHoldTime();
+ h.bgpPeer.setNegotiatedHoldTime(h.negotiatedHoldTime);
+ /*
+ * RFC 4271, When an OPEN message is received, sends a KEEPALIVE message, If the negotiated hold
+ * time value is zero, then the HoldTimer and KeepaliveTimer are not started. A reasonable maximum
+ * time between KEEPALIVE messages would be one third of the Hold Time interval.
+ */
+ h.sendKeepAliveMessage();
+
+ if (h.negotiatedHoldTime != 0) {
+ h.keepAliveTimer
+ = new BGPKeepAliveTimer(h, (h.negotiatedHoldTime / BGP_MAX_KEEPALIVE_INTERVAL));
+ }
+
+ h.bgpPacketStats.addOutPacket();
+
+ // set the state handshake completion.
+ h.setHandshakeComplete(true);
+
+ if (!h.peerManager.addConnectedPeer(h.thisbgpId, h.bgpPeer)) {
+ /*
+ * RFC 4271, Section 6.8, Based on the value of the BGP identifier, a convention is established
+ * for detecting which BGP connection is to be preserved when a collision occurs. The convention
+ * is to compare the BGP Identifiers of the peers involved in the collision and to retain only
+ * the connection initiated by the BGP speaker with the higher-valued BGP Identifier..
+ */
+ // TODO: Connection collision handling.
+ disconnectDuplicate(h);
+ } else {
+ h.setState(ESTABLISHED);
+ h.bgpconfig.setPeerConnState(h.peerAddr, BGPPeerCfg.State.ESTABLISHED);
+ }
+ }
+ }
+ },
+
+ ESTABLISHED(true) {
+ @Override
+ void processBGPMessage(BGPChannelHandler h, BGPMessage m) throws IOException, BGPParseException {
+ log.debug("Message received in established state " + m.getType());
+ // dispatch the message
+ h.dispatchMessage(m);
+ }
+ };
+
+ private boolean handshakeComplete;
+
+ ChannelState(boolean handshakeComplete) {
+ this.handshakeComplete = handshakeComplete;
+ }
+
+ /**
+ * Is this a state in which the handshake has completed?
+ *
+ * @return true if the handshake is complete
+ */
+ public boolean isHandshakeComplete() {
+ return this.handshakeComplete;
+ }
+
+ /**
+ * Disconnect duplicate peer connection.
+ *
+ * @param h channel handler
+ */
+ protected void disconnectDuplicate(BGPChannelHandler h) {
+ log.error("Duplicated BGP IP or incompleted cleanup - " + "" + "disconnecting channel {}",
+ h.getPeerInfoString());
+ h.duplicateBGPIdFound = Boolean.TRUE;
+ h.channel.disconnect();
+ }
+
+ // set handshake completion status
+ public void setHandshakeComplete(boolean handshakeComplete) {
+ this.handshakeComplete = handshakeComplete;
+ }
+
+ void processBGPMessage(BGPChannelHandler bgpChannelHandler, BGPMessage pm)
+ throws IOException, BGPParseException {
+ // TODO Auto-generated method stub
+ log.debug("BGP message stub");
+ }
+
+ }
+
+ // *************************
+ // Channel handler methods
+ // *************************
+
+ @Override
+ public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
+
+ channel = e.getChannel();
+ log.info("BGP connected from {}", channel.getRemoteAddress());
+
+ address = channel.getRemoteAddress();
+ if (!(address instanceof InetSocketAddress)) {
+ throw new IOException("Invalid peer connection.");
+ }
+
+ // Connection should establish only if local ip and Autonomous system number is configured.
+ if (bgpconfig.getState() != BGPCfg.State.IP_AS_CONFIGURED) {
+ channel.close();
+ log.info("BGP local AS and router ID not configured");
+ return;
+ }
+
+ inetAddress = (InetSocketAddress) address;
+ ipAddress = IpAddress.valueOf(inetAddress.getAddress());
+ peerAddr = ipAddress.toString();
+
+ // if peer is not configured disconnect session
+ if (!bgpconfig.isPeerConfigured(peerAddr)) {
+ log.debug("Peer is not configured {}", peerAddr);
+ channel.close();
+ return;
+ }
+
+ // if connection is already established close channel
+ if (peerManager.isPeerConnected(peerAddr)) {
+ log.debug("Duplicate connection received, peer {}", peerAddr);
+ channel.close();
+ return;
+ }
+
+ if (null != channel.getPipeline().get("PassiveHandler")) {
+ log.info("BGP handle connection request from peer");
+ // Wait for open message from bgp peer
+ setState(ChannelState.OPENWAIT);
+ } else if (null != channel.getPipeline().get("ActiveHandler")) {
+ log.info("BGP handle connection response from peer");
+
+ sendHandshakeOpenMessage();
+ bgpPacketStats.addOutPacket();
+ setState(ChannelState.OPENSENT);
+ bgpconfig.setPeerConnState(peerAddr, BGPPeerCfg.State.OPENSENT);
+ }
+ }
+
+ @Override
+ public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
+
+ channel = e.getChannel();
+ log.info("BGP disconnected callback for bgp:{}. Cleaning up ...", getPeerInfoString());
+
+ address = channel.getRemoteAddress();
+ if (!(address instanceof InetSocketAddress)) {
+ throw new IOException("Invalid peer connection.");
+ }
+
+ inetAddress = (InetSocketAddress) address;
+ ipAddress = IpAddress.valueOf(inetAddress.getAddress());
+ peerAddr = ipAddress.toString();
+
+ if (thisbgpId != null) {
+ if (!duplicateBGPIdFound) {
+ // if the disconnected peer (on this ChannelHandler)
+ // was not one with a duplicate, it is safe to remove all
+ // state for it at the controller. Notice that if the disconnected
+ // peer was a duplicate-ip, calling the method below would clear
+ // all state for the original peer (with the same ip),
+ // which we obviously don't want.
+ log.debug("{}:removal called", getPeerInfoString());
+ if (bgpPeer != null) {
+ peerManager.removeConnectedPeer(thisbgpId);
+ }
+ } else {
+ // A duplicate was disconnected on this ChannelHandler,
+ // this is the same peer reconnecting, but the original state was
+ // not cleaned up - XXX check liveness of original ChannelHandler
+ log.debug("{}:duplicate found", getPeerInfoString());
+ duplicateBGPIdFound = Boolean.FALSE;
+ }
+
+ if (null != keepAliveTimer) {
+ keepAliveTimer.getKeepAliveTimer().cancel();
+ }
+ } else {
+ log.warn("No bgp ip in channelHandler registered for " + "disconnected peer {}", getPeerInfoString());
+ }
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
+
+ log.info("[exceptionCaught]: " + e.toString());
+
+ if (e.getCause() instanceof ReadTimeoutException) {
+ if ((ChannelState.OPENWAIT == state) || (ChannelState.OPENSENT == state)) {
+
+ // When ReadTimeout timer is expired in OPENWAIT/OPENSENT state, it is considered
+ // TODO: Send notification
+ channel.close();
+ state = ChannelState.IDLE;
+ return;
+ } else if (ChannelState.OPENCONFIRM == state) {
+
+ // When ReadTimeout timer is expired in OPENCONFIRM state.
+ // TODO: Send Notification
+ channel.close();
+ state = ChannelState.IDLE;
+ return;
+ }
+ } else if (e.getCause() instanceof ClosedChannelException) {
+ log.debug("Channel for bgp {} already closed", getPeerInfoString());
+ } else if (e.getCause() instanceof IOException) {
+ log.error("Disconnecting peer {} due to IO Error: {}", getPeerInfoString(), e.getCause().getMessage());
+ if (log.isDebugEnabled()) {
+ // still print stack trace if debug is enabled
+ log.debug("StackTrace for previous Exception: ", e.getCause());
+ }
+ channel.close();
+ } else if (e.getCause() instanceof BGPParseException) {
+ // TODO: SEND NOTIFICATION
+ log.debug("BGP Parse Exception: ", e.getCause());
+ } else if (e.getCause() instanceof RejectedExecutionException) {
+ log.warn("Could not process message: queue full");
+ } else {
+ log.error("Error while processing message from peer " + getPeerInfoString() + "state " + this.state);
+ channel.close();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getPeerInfoString();
+ }
+
+ @Override
+ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
+ if (e.getMessage() instanceof List) {
+ @SuppressWarnings("Unchecked")
+ List<BGPMessage> msglist = (List<BGPMessage>) e.getMessage();
+ for (BGPMessage pm : msglist) {
+ // Do the actual packet processing
+ state.processBGPMessage(this, pm);
+ }
+ } else {
+ state.processBGPMessage(this, (BGPMessage) e.getMessage());
+ }
+ }
+
+ // *************************
+ // Channel utility methods
+ // *************************
+ /**
+ * Set handshake status.
+ *
+ * @param handshakeComplete handshake complete status
+ */
+ public void setHandshakeComplete(boolean handshakeComplete) {
+ this.state.setHandshakeComplete(handshakeComplete);
+ }
+
+ /**
+ * Is this a state in which the handshake has completed?
+ *
+ * @return true if the handshake is complete
+ */
+ public boolean isHandshakeComplete() {
+ return state.isHandshakeComplete();
+ }
+
+ /**
+ * To handle the BGP message.
+ *
+ * @param m BGP message
+ */
+ private void dispatchMessage(BGPMessage m) throws BGPParseException {
+ bgpPacketStats.addInPacket();
+ bgpControllerImpl.processBGPPacket(thisbgpId, m);
+ }
+
+ /**
+ * Return a string describing this peer based on the already available information (ip address and/or remote
+ * socket).
+ *
+ * @return display string
+ */
+ private String getPeerInfoString() {
+ if (bgpPeer != null) {
+ return bgpPeer.toString();
+ }
+ String channelString;
+ if (channel == null || channel.getRemoteAddress() == null) {
+ channelString = "?";
+ } else {
+ channelString = channel.getRemoteAddress().toString();
+ }
+ String bgpIpString;
+ // TODO: implement functionality to get bgp id string
+ bgpIpString = "?";
+ return String.format("[%s BGP-IP[%s]]", channelString, bgpIpString);
+ }
+
+ /**
+ * Update the channels state. Only called from the state machine. TODO: enforce restricted state transitions
+ *
+ * @param state
+ */
+ private void setState(ChannelState state) {
+ this.state = state;
+ }
+
+ /**
+ * get packet statistics.
+ *
+ * @return packet statistics
+ */
+ public BGPPacketStatsImpl getBgpPacketStats() {
+ return bgpPacketStats;
+ }
+
+ /**
+ * Send handshake open message to the peer.
+ *
+ * @throws IOException ,BGPParseException
+ */
+ private void sendHandshakeOpenMessage() throws IOException, BGPParseException {
+ // TODO: send open message.
+
+ }
+
+ /**
+ * Send keep alive message.
+ *
+ * @throws IOException when channel is disconnected
+ * @throws BGPParseException while building keep alive message
+ */
+ synchronized void sendKeepAliveMessage() throws IOException, BGPParseException {
+
+ // TODO: send keep alive message.
+ }
+
+ /**
+ * Send notification and close channel with peer.
+ */
+ private void sendErrNotificationAndCloseChannel() {
+ // TODO: send notification
+ channel.close();
+ }
+
+ /**
+ * Process unknown BGP message received.
+ *
+ * @throws BGPParseException when received invalid message
+ */
+ public void processUnknownMsg() throws BGPParseException {
+ log.debug("UNKNOWN message received");
+ Date now = null;
+ if (bgpPacketStats.wrongPacketCount() == 0) {
+ now = new Date();
+ bgpPacketStats.setTime(now.getTime());
+ bgpPacketStats.addWrongPacket();
+ sendErrNotificationAndCloseChannel();
+ }
+ if (bgpPacketStats.wrongPacketCount() > 1) {
+ Date lastest = new Date();
+ bgpPacketStats.addWrongPacket();
+ // converting to seconds
+ if (((lastest.getTime() - bgpPacketStats.getTime()) / 1000) > 60) {
+ now = lastest;
+ bgpPacketStats.setTime(now.getTime());
+ bgpPacketStats.resetWrongPacket();
+ bgpPacketStats.addWrongPacket();
+ } else if (((int) (lastest.getTime() - now.getTime()) / 1000) < 60) {
+ if (MAX_WRONG_COUNT_PACKET <= bgpPacketStats.wrongPacketCount()) {
+ // reset once wrong packet count reaches MAX_WRONG_COUNT_PACKET
+ bgpPacketStats.resetWrongPacket();
+ // max wrong packets received send error message and close the session
+ sendErrNotificationAndCloseChannel();
+ }
+ }
+ }
+ }
+
+ /**
+ * Open message validation.
+ *
+ * @param h channel handler
+ * @return true if validation succeed, otherwise false
+ * @throws BGPParseException when received invalid message
+ */
+ public boolean openMsgValidation(BGPChannelHandler h) throws BGPParseException {
+ // TODO: Open message validation.
+ return true;
}
-} \ No newline at end of file
+}
diff --git a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPControllerImpl.java b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPControllerImpl.java
index 95eafdbc..d8378e31 100755
--- a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPControllerImpl.java
+++ b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPControllerImpl.java
@@ -17,16 +17,24 @@
package org.onosproject.bgp.controller.impl;
import static org.onlab.util.Tools.groupedThreads;
+
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
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.onosproject.bgp.controller.BGPCfg;
import org.onosproject.bgp.controller.BGPController;
import org.onosproject.bgp.controller.BGPId;
+import org.onosproject.bgp.controller.BGPPacketStats;
+import org.onosproject.bgp.controller.BGPPeer;
import org.onosproject.bgpio.protocol.BGPMessage;
+import org.onosproject.bgpio.protocol.BGPVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,8 +50,10 @@ public class BGPControllerImpl implements BGPController {
private final ExecutorService executorBarrier = Executors.newFixedThreadPool(4,
groupedThreads("onos/bgp",
- "event-barrier-%d"));
+ "event-barrier-%d"));
+ protected ConcurrentHashMap<BGPId, BGPPeer> connectedPeers = new ConcurrentHashMap<BGPId, BGPPeer>();
+ protected BGPPeerManager peerManager = new BGPPeerManager();
final Controller ctrl = new Controller(this);
private BGPConfig bgpconfig = new BGPConfig();
@@ -57,11 +67,22 @@ public class BGPControllerImpl implements BGPController {
@Deactivate
public void deactivate() {
// Close all connected peers
+ closeConnectedPeers();
this.ctrl.stop();
log.info("Stopped");
}
@Override
+ public Iterable<BGPPeer> getPeers() {
+ return this.connectedPeers.values();
+ }
+
+ @Override
+ public BGPPeer getPeer(BGPId bgpId) {
+ return this.connectedPeers.get(bgpId);
+ }
+
+ @Override
public void writeMsg(BGPId bgpId, BGPMessage msg) {
// TODO: Send message
}
@@ -88,17 +109,167 @@ public class BGPControllerImpl implements BGPController {
}
}
+ @Override
+ public void closeConnectedPeers() {
+ BGPPeer bgpPeer;
+ for (BGPId id : this.connectedPeers.keySet()) {
+ bgpPeer = getPeer(id);
+ bgpPeer.disconnectPeer();
+ }
+ }
+
/**
- * Get controller instance.
- *
- * @return ctrl the controller.
+ * Implementation of an BGP Peer which is responsible for keeping track of connected peers and the state in which
+ * they are.
*/
+ public class BGPPeerManager {
+
+ private final Logger log = LoggerFactory.getLogger(BGPPeerManager.class);
+ private final Lock peerLock = new ReentrantLock();
+
+ /**
+ * Add a BGP peer that has just connected to the system.
+ *
+ * @param bgpId the id of bgp peer to add
+ * @param bgpPeer the actual bgp peer object.
+ * @return true if added, false otherwise.
+ */
+ public boolean addConnectedPeer(BGPId bgpId, BGPPeer bgpPeer) {
+
+ if (connectedPeers.get(bgpId) != null) {
+ this.log.error("Trying to add connectedPeer but found previous " + "value for bgp ip: {}",
+ bgpId.toString());
+ return false;
+ } else {
+ this.log.debug("Added Peer {}", bgpId.toString());
+ connectedPeers.put(bgpId, bgpPeer);
+ return true;
+ }
+ }
+
+ /**
+ * Checks if the activation for this bgp peer is valid.
+ *
+ * @param bgpId the id of bgp peer to check
+ * @return true if valid, false otherwise
+ */
+ public boolean isPeerConnected(BGPId bgpId) {
+ if (connectedPeers.get(bgpId) == null) {
+ this.log.error("Trying to activate peer but is not in " + "connected peer: bgpIp {}. Aborting ..",
+ bgpId.toString());
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if the activation for this bgp peer is valid.
+ *
+ * @param routerid the routerid of bgp peer to check
+ * @return true if valid, false otherwise
+ */
+ public boolean isPeerConnected(String routerid) {
+
+ final BGPId bgpId;
+ bgpId = BGPId.bgpId(IpAddress.valueOf(routerid));
+
+ if (connectedPeers.get(bgpId) != null) {
+ this.log.info("Peer connection exist ");
+ return true;
+ }
+ this.log.info("Initiate connect request to " + "peer: bgpIp {}", bgpId.toString());
+
+ return false;
+ }
+
+ /**
+ * Clear all state in controller peer maps for a bgp peer that has
+ * disconnected from the local controller.
+ *
+ * @param bgpId the id of bgp peer to remove.
+ */
+ public void removeConnectedPeer(BGPId bgpId) {
+ connectedPeers.remove(bgpId);
+ }
+
+ /**
+ * Clear all state in controller peer maps for a bgp peer that has
+ * disconnected from the local controller.
+ *
+ * @param routerid the router id of bgp peer to remove.
+ */
+ public void removeConnectedPeer(String routerid) {
+ final BGPId bgpId;
+
+ bgpId = BGPId.bgpId(IpAddress.valueOf(routerid));
+
+ connectedPeers.remove(bgpId);
+ }
+
+ /**
+ * Gets bgp peer for connected peer map.
+ *
+ * @param routerid router id
+ * @return peer if available, null otherwise
+ */
+ public BGPPeer getPeer(String routerid) {
+ final BGPId bgpId;
+ bgpId = BGPId.bgpId(IpAddress.valueOf(routerid));
+
+ return connectedPeers.get(bgpId);
+ }
+
+ /**
+ * Gets bgp peer instance.
+ *
+ * @param bgpId bgp identifier.
+ * @param pv bgp version.
+ * @param pktStats packet statistics.
+ * @return BGPPeer peer instance.
+ */
+ public BGPPeer getBGPPeerInstance(BGPId bgpId, BGPVersion pv, BGPPacketStats pktStats) {
+ BGPPeer bgpPeer = new BGPPeerImpl();
+ bgpPeer.init(bgpId, pv, pktStats);
+ return bgpPeer;
+ }
+
+ }
+
+ /**
+ * Gets controller instance.
+ *
+ * @return Controller instance.
+ */
public Controller getController() {
return ctrl;
}
+ /**
+ * Gets connected peers.
+ *
+ * @return connectedPeers from connected Peers Map.
+ */
+ public ConcurrentHashMap<BGPId, BGPPeer> getConnectedPeers() {
+ return connectedPeers;
+ }
+
+ /**
+ * Gets peer manager.
+ *
+ * @return peerManager.
+ */
+ public BGPPeerManager getPeerManager() {
+ return peerManager;
+ }
+
@Override
public BGPCfg getConfig() {
return this.bgpconfig;
}
+
+ @Override
+ public int getBGPConnNumber() {
+ return connectedPeers.size();
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPKeepAliveTimer.java b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPKeepAliveTimer.java
new file mode 100755
index 00000000..1c95804a
--- /dev/null
+++ b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPKeepAliveTimer.java
@@ -0,0 +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.bgp.controller.impl;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implement sending keepalive message to connected peer periodically based on negotiated holdtime.
+ */
+public class BGPKeepAliveTimer {
+
+ private Timer keepAliveTimer;
+ private BGPChannelHandler handler;
+ private static final Logger log = LoggerFactory.getLogger(BGPKeepAliveTimer.class);
+
+ /**
+ * Gets keepalive timer object.
+ *
+ * @return keepAliveTimer keepalive timer.
+ */
+ public Timer getKeepAliveTimer() {
+ return keepAliveTimer;
+ }
+
+ /**
+ * Initialize timer to send keepalive message periodically.
+ *
+ * @param h channel handler
+ * @param seconds time interval.
+ */
+ public BGPKeepAliveTimer(BGPChannelHandler h, int seconds) {
+ this.handler = h;
+ this.keepAliveTimer = new Timer();
+ this.keepAliveTimer.schedule(new SendKeepAlive(), 0, seconds * 1000);
+ }
+
+ /**
+ * Send keepalive message to connected peer on schedule.
+ */
+ class SendKeepAlive extends TimerTask {
+ @Override
+ public void run() {
+ log.debug("Sending periodic KeepAlive");
+
+ try {
+ // Send keep alive message
+ handler.sendKeepAliveMessage();
+ handler.getBgpPacketStats().addOutPacket();
+ } catch (Exception e) {
+ log.info("Exception occured while sending keepAlive message" + e.toString());
+ }
+ }
+ }
+}
diff --git a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPacketStatsImpl.java b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPacketStatsImpl.java
index 41407dc4..09f4d452 100755
--- a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPacketStatsImpl.java
+++ b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPacketStatsImpl.java
@@ -43,8 +43,7 @@ public class BGPPacketStatsImpl implements BGPPacketStats {
/**
* Get the outgoing packet count number.
*
- * @return
- * packet count
+ * @return packet count
*/
public int outPacketCount() {
return outPacketCount;
@@ -53,8 +52,7 @@ public class BGPPacketStatsImpl implements BGPPacketStats {
/**
* Get the incoming packet count number.
*
- * @return
- * packet count
+ * @return packet count
*/
public int inPacketCount() {
return inPacketCount;
@@ -63,8 +61,7 @@ public class BGPPacketStatsImpl implements BGPPacketStats {
/**
* Get the wrong packet count number.
*
- * @return
- * packet count
+ * @return packet count
*/
public int wrongPacketCount() {
return wrongPacketCount;
@@ -110,8 +107,7 @@ public class BGPPacketStatsImpl implements BGPPacketStats {
/**
* Get the time.
*
- * @return
- * time
+ * @return time
*/
public long getTime() {
return this.time;
diff --git a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPeerImpl.java b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPeerImpl.java
new file mode 100755
index 00000000..212b24d3
--- /dev/null
+++ b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPeerImpl.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.bgp.controller.impl;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.jboss.netty.channel.Channel;
+import org.onlab.packet.IpAddress;
+import org.onosproject.bgp.controller.BGPId;
+import org.onosproject.bgp.controller.BGPPacketStats;
+import org.onosproject.bgp.controller.BGPPeer;
+import org.onosproject.bgpio.protocol.BGPMessage;
+import org.onosproject.bgpio.protocol.BGPVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * BGPPeerImpl implements BGPPeer, maintains peer information and store updates in RIB .
+ */
+public class BGPPeerImpl implements BGPPeer {
+
+ protected final Logger log = LoggerFactory.getLogger(BGPPeerImpl.class);
+
+ private static final String SHUTDOWN_MSG = "Worker has already been shutdown";
+
+ private Channel channel;
+ protected String channelId;
+ private boolean connected;
+ protected boolean isHandShakeComplete = false;
+ public BGPSessionInfo sessionInfo;
+ private BGPPacketStatsImpl pktStats;
+
+ @Override
+ public void init(BGPId bgpId, BGPVersion bgpVersion, BGPPacketStats pktStats) {
+ this.sessionInfo.setRemoteBgpId(bgpId);
+ this.sessionInfo.setRemoteBgpVersion(bgpVersion);
+ this.pktStats = (BGPPacketStatsImpl) pktStats;
+ this.sessionInfo = new BGPSessionInfo();
+ }
+
+ // ************************
+ // Channel related
+ // ************************
+
+ @Override
+ public final void disconnectPeer() {
+ this.channel.close();
+ }
+
+ @Override
+ public final void sendMessage(BGPMessage m) {
+ log.debug("Sending message to {}", channel.getRemoteAddress());
+ try {
+ channel.write(Collections.singletonList(m));
+ this.pktStats.addOutPacket();
+ } catch (RejectedExecutionException e) {
+ log.warn(e.getMessage());
+ if (!e.getMessage().contains(SHUTDOWN_MSG)) {
+ throw e;
+ }
+ }
+ }
+
+ @Override
+ public final void sendMessage(List<BGPMessage> msgs) {
+ try {
+ channel.write(msgs);
+ this.pktStats.addOutPacket(msgs.size());
+ } catch (RejectedExecutionException e) {
+ log.warn(e.getMessage());
+ if (!e.getMessage().contains(SHUTDOWN_MSG)) {
+ throw e;
+ }
+ }
+ }
+
+ @Override
+ public final boolean isConnected() {
+ return this.connected;
+ }
+
+ @Override
+ public final void setConnected(boolean connected) {
+ this.connected = connected;
+ };
+
+ @Override
+ public final void setChannel(Channel channel) {
+ this.channel = channel;
+ final SocketAddress address = channel.getRemoteAddress();
+ if (address instanceof InetSocketAddress) {
+ final InetSocketAddress inetAddress = (InetSocketAddress) address;
+ final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress());
+ if (ipAddress.isIp4()) {
+ channelId = ipAddress.toString() + ':' + inetAddress.getPort();
+ } else {
+ channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort();
+ }
+ }
+ };
+
+ @Override
+ public final Channel getChannel() {
+ return this.channel;
+ };
+
+ @Override
+ public String channelId() {
+ return channelId;
+ }
+
+ // ************************
+ // BGP Peer features related
+ // ************************
+
+ @Override
+ public final BGPId getBGPId() {
+ return this.sessionInfo.getRemoteBgpId();
+ };
+
+ @Override
+ public final String getStringId() {
+ return this.sessionInfo.getRemoteBgpId().toString();
+ }
+
+ @Override
+ public final void setBgpPeerVersion(BGPVersion peerVersion) {
+ this.sessionInfo.setRemoteBgpVersion(peerVersion);
+ }
+
+ @Override
+ public void setBgpPeerASNum(short peerASNum) {
+ this.sessionInfo.setRemoteBgpASNum(peerASNum);
+ }
+
+ @Override
+ public void setBgpPeerHoldTime(short peerHoldTime) {
+ this.sessionInfo.setRemoteBgpHoldTime(peerHoldTime);
+ }
+
+ @Override
+ public void setBgpPeerIdentifier(int peerIdentifier) {
+ this.sessionInfo.setRemoteBgpIdentifier(peerIdentifier);
+ }
+
+ @Override
+ public int getBgpPeerIdentifier() {
+ return this.sessionInfo.getRemoteBgpIdentifier();
+ }
+
+ @Override
+ public int getNegotiatedHoldTime() {
+ return this.sessionInfo.getNegotiatedholdTime();
+ }
+
+ @Override
+ public void setNegotiatedHoldTime(short negotiatedHoldTime) {
+ this.sessionInfo.setNegotiatedholdTime(negotiatedHoldTime);
+ }
+
+ @Override
+ public boolean isHandshakeComplete() {
+ return isHandShakeComplete;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues().add("channel", channelId())
+ .add("bgpId", getBGPId()).toString();
+ }
+}
diff --git a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPSessionInfo.java b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPSessionInfo.java
new file mode 100755
index 00000000..207d7831
--- /dev/null
+++ b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPSessionInfo.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.bgp.controller.impl;
+
+import org.onosproject.bgp.controller.BGPId;
+import org.onosproject.bgpio.protocol.BGPVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class maintains BGP peer session info.
+ */
+public class BGPSessionInfo {
+
+ protected final Logger log = LoggerFactory.getLogger(BGPSessionInfo.class);
+ private BGPId remoteBgpId;
+ private BGPVersion remoteBgpVersion;
+ private short remoteBgpASNum;
+ private short remoteBgpholdTime;
+ private int remoteBgpIdentifier;
+ private short negotiatedholdTime;
+
+ /**
+ * Gets the negotiated hold time for the session.
+ *
+ * @return negotiated hold time.
+ */
+ public short getNegotiatedholdTime() {
+ return negotiatedholdTime;
+ }
+
+ /**
+ * Sets the negotiated hold time for the session.
+ *
+ * @param negotiatedholdTime negotiated hold time.
+ */
+ public void setNegotiatedholdTime(short negotiatedholdTime) {
+ this.negotiatedholdTime = negotiatedholdTime;
+ }
+
+ /**
+ * Gets the BGP ID of BGP peer.
+ *
+ * @return bgp ID.
+ */
+ public BGPId getRemoteBgpId() {
+ return remoteBgpId;
+ }
+
+ /**
+ * Sets the BGP ID of bgp peer.
+ *
+ * @param bgpId BGP ID to set.
+ */
+ public void setRemoteBgpId(BGPId bgpId) {
+ log.debug("Remote BGP ID {}", bgpId);
+ this.remoteBgpId = bgpId;
+ }
+
+ /**
+ * Gets the BGP version of peer.
+ *
+ * @return bgp version.
+ */
+ public BGPVersion getRemoteBgpVersion() {
+ return remoteBgpVersion;
+ }
+
+ /**
+ * Sets the BGP version for this bgp peer.
+ *
+ * @param bgpVersion bgp version to set.
+ */
+ public void setRemoteBgpVersion(BGPVersion bgpVersion) {
+ log.debug("Remote BGP version {}", bgpVersion);
+ this.remoteBgpVersion = bgpVersion;
+ }
+
+ /**
+ * Gets the BGP remote bgp AS number.
+ *
+ * @return remoteBgpASNum peer AS number.
+ */
+ public short getRemoteBgpASNum() {
+ return remoteBgpASNum;
+ }
+
+ /**
+ * Sets the AS Number for this bgp peer.
+ *
+ * @param bgpASNum the autonomous system number value to set.
+ */
+ public void setRemoteBgpASNum(short bgpASNum) {
+ log.debug("Remote BGP AS number {}", bgpASNum);
+ this.remoteBgpASNum = bgpASNum;
+ }
+
+ /**
+ * Gets the BGP peer hold time.
+ *
+ * @return bgp hold time.
+ */
+ public short getRemoteBgpHoldTime() {
+ return remoteBgpholdTime;
+ }
+
+ /**
+ * Sets the hold time for this bgp peer.
+ *
+ * @param holdTime the hold timer value to set.
+ */
+ public void setRemoteBgpHoldTime(short holdTime) {
+ log.debug("Remote BGP HoldTime {}", holdTime);
+ this.remoteBgpholdTime = holdTime;
+ }
+
+ /**
+ * Gets the BGP version for this bgp peer.
+ *
+ * @return bgp identifier.
+ */
+ public int getRemoteBgpIdentifier() {
+ return remoteBgpIdentifier;
+ }
+
+ /**
+ * Sets the peer identifier value.
+ *
+ * @param bgpIdentifier the bgp peer identifier value.
+ */
+ public void setRemoteBgpIdentifier(int bgpIdentifier) {
+ log.debug("Remote BGP Identifier {}", bgpIdentifier);
+ this.remoteBgpIdentifier = bgpIdentifier;
+ }
+}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddressBindingsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddressBindingsListCommand.java
deleted file mode 100644
index 3ce45b90..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddressBindingsListCommand.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.cli.net;
-
-import com.google.common.collect.Lists;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Lists all configured address port bindings.
- */
-@Command(scope = "onos", name = "address-bindings",
- description = "Lists all configured address port bindings.")
-public class AddressBindingsListCommand extends AbstractShellCommand {
-
- private static final String FORMAT =
- "port=%s/%s, ip(s)=%s, mac=%s, vlan=%s";
-
- @Override
- protected void execute() {
- HostService hostService = get(HostService.class);
-
- List<PortAddresses> addresses =
- Lists.newArrayList(hostService.getAddressBindings());
-
- Collections.sort(addresses, Comparators.ADDRESSES_COMPARATOR);
-
- for (PortAddresses pa : addresses) {
- print(FORMAT, pa.connectPoint().deviceId(), pa.connectPoint().port(),
- printIpAddresses(pa.ipAddresses()), pa.mac(), pa.vlan());
- }
- }
-
- private String printIpAddresses(Set<InterfaceIpAddress> addresses) {
- StringBuilder output = new StringBuilder("[");
- for (InterfaceIpAddress address : addresses) {
- output.append(address.ipAddress().toString());
- output.append("/");
- output.append(address.subnetAddress().prefixLength());
- output.append(", ");
- }
- // Remove the last comma
- output.delete(output.length() - 2 , output.length());
- output.append("]");
- return output.toString();
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/OduSignalId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/OduSignalId.java
new file mode 100644
index 00000000..e19a673d
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/OduSignalId.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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 static com.google.common.base.Preconditions.checkArgument;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+import org.onlab.util.HexString;
+
+import com.google.common.base.MoreObjects;
+/**
+ * Implementation of ODU Signal ID.
+ *
+ * <p>
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)".
+ * </p>
+ */
+public class OduSignalId {
+
+ private final int tributaryPortNumber; // Tributary Port number
+ private final int tributarySlotLength; // Number of Tributary Slots included in tsmap
+ private final byte[] tributarySlotBitmap; // Tributary slot bitmap
+
+ public static final int TRIBUTARY_SLOT_BITMAP_SIZE = 10;
+
+ /**
+ * Creates an instance with the specified arguments.
+ *
+ * @param tributaryPortNumber tributary port number
+ * @param tributarySlotLen tributary slot len
+ * @param tributarySlotBitmap tributary slot bitmap
+ */
+ public OduSignalId(int tributaryPortNumber, int tributarySlotLen,
+ byte[] tributarySlotBitmap) {
+
+ checkArgument(tributaryPortNumber <= 80 ,
+ "tributaryPortNumber %s must be <= 80 ",
+ tributaryPortNumber);
+
+ checkArgument(tributarySlotBitmap.length == TRIBUTARY_SLOT_BITMAP_SIZE,
+ "number of elements in list " + HexString.toHexString(tributarySlotBitmap)
+ + " must be equal to " + TRIBUTARY_SLOT_BITMAP_SIZE);
+
+ checkArgument(tributarySlotLen <= 80 ,
+ "tributarySlotLen %s must be <= 80 ",
+ tributarySlotLen);
+
+ this.tributaryPortNumber = tributaryPortNumber;
+ this.tributarySlotLength = tributarySlotLen;
+ this.tributarySlotBitmap = Arrays.copyOf(tributarySlotBitmap, tributarySlotBitmap.length);
+ }
+
+ /**
+ * Returns the OduSignalId representing the specified parameters.
+ *
+ * @param tributaryPortNumber tributary port number
+ * @param tributarySlotLen tributary slot len
+ * @param tributarySlotBitmap tributary slot bitmap
+ * @return OduSignalId
+ */
+ public static OduSignalId oduSignalId(int tributaryPortNumber, int tributarySlotLen,
+ byte[] tributarySlotBitmap) {
+ return new OduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap);
+ }
+
+
+ /**
+ * Returns tributary port number.
+ *
+ * @return the tributaryPortNumber
+ */
+ public int tributaryPortNumber() {
+ return tributaryPortNumber;
+ }
+
+ /**
+ * Returns tributary slot length.
+ *
+ * @return the tributarySlotLen
+ */
+ public int tributarySlotLength() {
+ return tributarySlotLength;
+ }
+
+ /**
+ * Returns tributary slot bitmap.
+ *
+ * @return the tributarySlotBitmap
+ */
+ public byte[] tributarySlotBitmap() {
+ return Arrays.copyOf(tributarySlotBitmap, tributarySlotBitmap.length);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tributaryPortNumber, tributarySlotLength, Arrays.hashCode(tributarySlotBitmap));
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof OduSignalId)) {
+ return false;
+ }
+ final OduSignalId other = (OduSignalId) obj;
+ return Objects.equals(this.tributaryPortNumber, other.tributaryPortNumber)
+ && Objects.equals(this.tributarySlotLength, other.tributarySlotLength)
+ && Arrays.equals(tributarySlotBitmap, other.tributarySlotBitmap);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .omitNullValues()
+ .add("tributaryPortNumber", tributaryPortNumber)
+ .add("tributarySlotLength", tributarySlotLength)
+ .add("tributarySlotBitmap", HexString.toHexString(tributarySlotBitmap))
+ .toString();
+ }
+
+}
+
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java
index ded3b3ae..0e509562 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ControllerInfo.java
@@ -34,6 +34,7 @@ public class ControllerInfo {
*
* @param ip the ip address
* @param port the tcp port
+ * @param type the connection type
*/
public ControllerInfo(IpAddress ip, int port, String type) {
this.ip = ip;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java
index a93dc071..965fd1f8 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java
@@ -54,6 +54,8 @@ public interface TypedStoredFlowEntry extends StoredFlowEntry {
/**
* Gets the flow live type for this entry.
+ *
+ * @return flow live type
*/
FlowLiveType flowLiveType();
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
index 7e1d43a5..ae940bdc 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
@@ -25,6 +25,8 @@ import org.onlab.packet.VlanId;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Lambda;
import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalId;
+import org.onosproject.net.OduSignalType;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.criteria.Criterion.Type;
import org.onosproject.net.OchSignalType;
@@ -486,6 +488,26 @@ public final class Criteria {
return new OchSignalTypeCriterion(signalType);
}
+ /**
+ * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value.
+ *
+ * @param oduSignalId ODU Signal Id
+ * @return match criterion
+ */
+ public static Criterion matchOduSignalId(OduSignalId oduSignalId) {
+ return new OduSignalIdCriterion(oduSignalId);
+ }
+
+ /**
+ * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value.
+ *
+ * @param signalType ODU Signal Type
+ * @return match criterion
+ */
+ public static Criterion matchOduSignalType(OduSignalType signalType) {
+ return new OduSignalTypeCriterion(signalType);
+ }
+
public static Criterion dummy() {
return new DummyCriterion();
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
index 12ab57de..10cb629f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
@@ -125,6 +125,10 @@ public interface Criterion {
OCH_SIGID,
/** Optical channel signal type (fixed or flexible). */
OCH_SIGTYPE,
+ /** ODU (Optical channel Data Unit) signal ID. */
+ ODU_SIGID,
+ /** ODU (Optical channel Data Unit) signal type. */
+ ODU_SIGTYPE,
/**
* An empty criterion.
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java
new file mode 100644
index 00000000..cb513397
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.net.OduSignalId;
+
+/**
+ * Implementation of ODU (Optical channel Data Unit) signal ID signal criterion.
+ * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGID" in
+ * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but
+ * defined in protocol agnostic way.
+ */
+public final class OduSignalIdCriterion implements Criterion {
+
+ private final OduSignalId oduSignalId;
+
+ /**
+ * Create an instance with the specified ODU signal ID.
+ *
+ * @param oduSignalId - ODU signal ID
+ */
+ OduSignalIdCriterion(OduSignalId oduSignalId) {
+ this.oduSignalId = checkNotNull(oduSignalId);
+ }
+
+ @Override
+ public Type type() {
+ return Type.ODU_SIGID;
+ }
+
+ /**
+ * Returns the ODU Signal to match.
+ *
+ * @return the ODU signal to match
+ */
+ public OduSignalId oduSignalId() {
+ return oduSignalId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type(), oduSignalId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof OduSignalIdCriterion)) {
+ return false;
+ }
+ final OduSignalIdCriterion that = (OduSignalIdCriterion) obj;
+ return Objects.equals(this.oduSignalId, that.oduSignalId);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("oduSignalId", oduSignalId)
+ .toString();
+ }
+
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java
new file mode 100644
index 00000000..d92880db
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java
@@ -0,0 +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.net.flow.criteria;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.net.OduSignalType;
+
+/**
+ * Implementation of ODU (Optical channel Data Unit) signal Type criterion.
+ * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGTYPE" in
+ * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but
+ * defined in protocol agnostic way.
+ */
+public final class OduSignalTypeCriterion implements Criterion {
+
+ private final OduSignalType signalType;
+
+ /**
+ * Create an instance with the specified ODU signal Type.
+ *
+ * @param signalType - ODU signal Type
+ */
+ OduSignalTypeCriterion(OduSignalType signalType) {
+ this.signalType = checkNotNull(signalType);
+ }
+
+ @Override
+ public Type type() {
+ return Type.ODU_SIGTYPE;
+ }
+
+ /**
+ * Returns the ODU Signal Type to match.
+ *
+ * @return the ODU signal Type to match
+ */
+ public OduSignalType signalType() {
+ return signalType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type(), signalType);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof OduSignalTypeCriterion)) {
+ return false;
+ }
+ final OduSignalTypeCriterion that = (OduSignalTypeCriterion) obj;
+ return Objects.equals(this.signalType, that.signalType);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("signalType", signalType)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OpticalSignalTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OpticalSignalTypeCriterion.java
deleted file mode 100644
index b712675b..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OpticalSignalTypeCriterion.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flow.criteria;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Implementation of optical signal type criterion (8 bits unsigned
- * integer).
- *
- * @deprecated in Cardinal Release
- */
-@Deprecated
-public final class OpticalSignalTypeCriterion implements Criterion {
- private static final short MASK = 0xff;
- private final short signalType; // Signal type value: 8 bits
- private final Type type;
-
- /**
- * Constructor.
- *
- * @param signalType the optical signal type to match (8 bits unsigned
- * integer)
- * @param type the match type. Should be Type.OCH_SIGTYPE
- */
- OpticalSignalTypeCriterion(short signalType, Type type) {
- this.signalType = (short) (signalType & MASK);
- this.type = type;
- }
-
- @Override
- public Type type() {
- return this.type;
- }
-
- /**
- * Gets the optical signal type to match.
- *
- * @return the optical signal type to match (8 bits unsigned integer)
- */
- public short signalType() {
- return signalType;
- }
-
- @Override
- public String toString() {
- return toStringHelper(type().toString())
- .add("signalType", signalType).toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type().ordinal(), signalType);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof OpticalSignalTypeCriterion) {
- OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj;
- return Objects.equals(signalType, that.signalType) &&
- Objects.equals(type, that.type);
- }
- return false;
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
index d01ea298..eddbbb71 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
@@ -59,6 +59,11 @@ public interface Instruction {
L0MODIFICATION,
/**
+ * Signifies that the traffic should be modified in L1 way.
+ */
+ L1MODIFICATION,
+
+ /**
* Signifies that the traffic should be modified in L2 way.
*/
L2MODIFICATION,
@@ -86,6 +91,7 @@ public interface Instruction {
/**
* Returns the type of instruction.
+ *
* @return type of instruction
*/
Type type();
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index c9f10685..26981e5e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
@@ -25,10 +25,12 @@ import org.onosproject.core.GroupId;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Lambda;
import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType;
import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
+import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
@@ -47,7 +49,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public final class Instructions {
-
// Ban construction
private Instructions() {}
@@ -117,6 +118,16 @@ public final class Instructions {
}
/**
+ * Creates an L1 modification with the specified ODU signal Id.
+ *
+ * @param oduSignalId ODU Signal Id
+ * @return a L1 modification
+ */
+ public static L1ModificationInstruction modL1OduSignalId(OduSignalId oduSignalId) {
+ checkNotNull(oduSignalId, "L1 ODU signal ID cannot be null");
+ return new ModOduSignalIdInstruction(oduSignalId);
+ }
+ /**
* Creates a l2 src modification.
*
* @param addr the mac address to modify to
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java
new file mode 100644
index 00000000..c6847d1c
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java
@@ -0,0 +1,88 @@
+/*
+ * 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.net.flow.instructions;
+
+import org.onosproject.net.OduSignalId;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+public abstract class L1ModificationInstruction implements Instruction {
+
+ /**
+ * Represents the type of traffic treatment.
+ */
+ public enum L1SubType {
+ /**
+ * ODU (Optical channel Data Unit) Signal Id modification.
+ */
+ ODU_SIGID
+ }
+
+ public abstract L1SubType subtype();
+
+ @Override
+ public final Type type() {
+ return Type.L1MODIFICATION;
+ }
+
+ /**
+ * Represents an L1 ODU (Optical channel Data Unit) Signal Id modification instruction.
+ */
+ public static final class ModOduSignalIdInstruction extends L1ModificationInstruction {
+
+ private final OduSignalId oduSignalId;
+
+ ModOduSignalIdInstruction(OduSignalId oduSignalId) {
+ this.oduSignalId = oduSignalId;
+ }
+
+ @Override
+ public L1SubType subtype() {
+ return L1SubType.ODU_SIGID;
+ }
+
+ public OduSignalId oduSignalId() {
+ return oduSignalId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(oduSignalId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof ModOduSignalIdInstruction)) {
+ return false;
+ }
+ final ModOduSignalIdInstruction that = (ModOduSignalIdInstruction) obj;
+ return Objects.equals(this.oduSignalId, that.oduSignalId);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("oduSignalId", oduSignalId)
+ .toString();
+ }
+ }
+
+}
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 068663bd..3403486c 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
@@ -55,9 +55,10 @@ public interface HostProviderService extends ProviderService<HostProvider> {
void hostVanished(HostId hostId);
/**
- * Notifies the core when a host is no longer detected on a network.
+ * Notifies the core when an IP is no longer associated with a host.
*
- * @param hostId id of the host that vanished
+ * @param hostId id of the host
+ * @param ipAddress ip address of host that vanished
*/
void removeIpFromHost(HostId hostId, IpAddress ipAddress);
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/PortAddresses.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/PortAddresses.java
deleted file mode 100644
index 74f22ae9..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/host/PortAddresses.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.net.host;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Represents address information bound to a port.
- */
-public final class PortAddresses {
-
- private final ConnectPoint connectPoint;
- private final Set<InterfaceIpAddress> ipAddresses;
- private final MacAddress macAddress;
- private final VlanId vlan;
-
- /**
- * Constructs a PortAddresses object for the given connection point, with a
- * set of IP addresses and a MAC address. Both address parameters are
- * optional and can be set to null.
- *
- * @param connectPoint the connection point these addresses are for
- * @param ipAddresses a set of interface IP addresses
- * @param mac a MAC address
- * @param vlan a VLAN ID
- */
- public PortAddresses(ConnectPoint connectPoint,
- Set<InterfaceIpAddress> ipAddresses, MacAddress mac, VlanId vlan) {
- this.connectPoint = connectPoint;
- this.ipAddresses = (ipAddresses == null) ?
- Collections.<InterfaceIpAddress>emptySet()
- : new HashSet<>(ipAddresses);
- this.macAddress = mac;
- this.vlan = vlan;
- }
-
- /**
- * Returns the connection point this address information is bound to.
- *
- * @return the connection point
- */
- public ConnectPoint connectPoint() {
- return connectPoint;
- }
-
- /**
- * Returns the set of interface IP addresses.
- *
- * @return the interface IP addresses
- */
- public Set<InterfaceIpAddress> ipAddresses() {
- return ipAddresses;
- }
-
- /**
- * Returns the MAC address.
- *
- * @return the MAC address
- */
- public MacAddress mac() {
- return macAddress;
- }
-
- /**
- * Returns the VLAN ID.
- *
- * @return the VLAN ID
- */
- public VlanId vlan() {
- return vlan;
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof PortAddresses)) {
- return false;
- }
-
- PortAddresses otherPa = (PortAddresses) other;
-
- return Objects.equals(this.connectPoint, otherPa.connectPoint)
- && Objects.equals(this.ipAddresses, otherPa.ipAddresses)
- && Objects.equals(this.macAddress, otherPa.macAddress)
- && Objects.equals(this.vlan, otherPa.vlan);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(connectPoint, ipAddresses, macAddress, vlan);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("connect-point", connectPoint)
- .add("ip-addresses", ipAddresses)
- .add("mac-address", macAddress)
- .add("vlan", vlan)
- .toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
deleted file mode 100644
index 5468dfb7..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.resource.device;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.net.Port;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentId;
-
-import java.util.Set;
-
-/**
- * Service for providing device resources.
- */
-@Beta
-public interface DeviceResourceService {
- /**
- * Request a set of ports needed to satisfy the intent.
- *
- * @param ports set of ports to allocate
- * @param intent the intent
- * @return true if ports were successfully allocated, false otherwise
- */
- boolean requestPorts(Set<Port> ports, Intent intent);
-
- /**
- * Returns the set of ports allocated for an intent.
- *
- * @param intentId the intent ID
- * @return set of allocated ports
- */
- Set<Port> getAllocations(IntentId intentId);
-
- /**
- * Returns the intent allocated to a port.
- *
- * @param port the port
- * @return intent ID allocated to the port
- */
- IntentId getAllocations(Port port);
-
- /**
- * Request a mapping between the given intents.
- *
- * @param keyIntentId the key intent ID
- * @param valIntentId the value intent ID
- * @return true if mapping was successful, false otherwise
- */
- boolean requestMapping(IntentId keyIntentId, IntentId valIntentId);
-
- /**
- * Returns the intents mapped to a lower intent.
- *
- * @param intentId the intent ID
- * @return the set of intent IDs
- */
- Set<IntentId> getMapping(IntentId intentId);
-
- /**
- * Release mapping of given intent.
- *
- * @param intentId intent ID
- */
- void releaseMapping(IntentId intentId);
-
- /**
- * Release ports associated with given intent ID.
- *
- * @param intentId intent ID
- */
- void releasePorts(IntentId intentId);
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
deleted file mode 100644
index a52a843f..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.resource.device;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.intent.IntentId;
-
-import java.util.Set;
-
-public interface DeviceResourceStore {
- /**
- * Returns unallocated ports on the given device.
- *
- * @param deviceId device ID
- * @return set of unallocated ports
- */
- Set<Port> getFreePorts(DeviceId deviceId);
-
- /**
- * Allocates the given ports to the given intent.
- *
- * @param ports set of ports to allocate
- * @param intentId intent ID
- * @return true if allocation was successful, false otherwise
- */
- boolean allocatePorts(Set<Port> ports, IntentId intentId);
-
- /**
- * Returns set of ports allocated for an intent.
- *
- * @param intentId the intent ID
- * @return set of allocated ports
- */
- Set<Port> getAllocations(IntentId intentId);
-
- /**
- * Returns intent allocated to a port.
- *
- * @param port the port
- * @return intent ID allocated to the port
- */
- IntentId getAllocations(Port port);
-
- /**
- * Allocates the mapping between the given intents.
- *
- * @param keyIntentId key intent ID
- * @param valIntentId value intent ID
- * @return true if mapping was successful, false otherwise
- */
- boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId);
-
- /**
- * Returns the set of intents mapped to a lower intent.
- *
- * @param intentId intent ID
- * @return set of intent IDs
- */
- Set<IntentId> getMapping(IntentId intentId);
-
- /**
- * Releases the mapping of the given intent.
- *
- * @param intentId intent ID
- */
- void releaseMapping(IntentId intentId);
-
- /**
- * Releases the ports allocated to the given intent.
- *
- * @param intentId intent ID
- * @return true if release was successful, false otherwise
- */
- boolean releasePorts(IntentId intentId);
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java
index 67c539df..f17bfb8e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/device/IntentSetMultimap.java
@@ -15,10 +15,12 @@
*/
package org.onosproject.net.resource.device;
+import com.google.common.annotations.Beta;
import org.onosproject.net.intent.IntentId;
import java.util.Set;
+@Beta
public interface IntentSetMultimap {
/**
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java
index f59670bc..5216839e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/FlowStatisticService.java
@@ -94,6 +94,7 @@ public interface FlowStatisticService {
* @param pNumber the port number of the Device to query
* @param liveType the FlowLiveType to filter, null means no filtering .
* @param instType the InstructionType to filter, null means no filtering.
+ * @param topn topn //FIXME what?
* @return list of flow entry load
*/
List<TypedFlowEntryWithLoad> loadTopnByType(Device device, PortNumber pNumber,
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java
index 60da636a..1ec427c0 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/SummaryFlowEntryWithLoad.java
@@ -94,6 +94,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns connect point.
+ *
+ * @return connect point
*/
public ConnectPoint connectPoint() {
return cp;
@@ -101,6 +103,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns total load of connect point.
+ *
+ * @return total load
*/
public Load totalLoad() {
return totalLoad;
@@ -108,6 +112,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns immediate load of connect point.
+ *
+ * @return immediate load
*/
public Load immediateLoad() {
return immediateLoad;
@@ -115,6 +121,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns short load of connect point.
+ *
+ * @return short load
*/
public Load shortLoad() {
return shortLoad;
@@ -122,6 +130,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns mid load of connect point.
+ *
+ * @return mid load
*/
public Load midLoad() {
return midLoad;
@@ -129,6 +139,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns long load of connect point.
+ *
+ * @return long load
*/
public Load longLoad() {
return longLoad;
@@ -136,6 +148,8 @@ public class SummaryFlowEntryWithLoad {
/**
* Returns unknown load of connect point.
+ *
+ * @return unknown load
*/
public Load unknownLoad() {
return unknownLoad;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java
index 3e2dbdf8..a4cbd7d0 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/statistic/TypedFlowEntryWithLoad.java
@@ -36,19 +36,37 @@ public class TypedFlowEntryWithLoad {
private static final int MID_POLL_INTERVAL = 10;
private static final int LONG_POLL_INTERVAL = 15;
-
+ /**
+ * Creates a new typed flow entry with load.
+ *
+ * @param cp connect point
+ * @param tfe typed flow entry
+ * @param load load
+ */
public TypedFlowEntryWithLoad(ConnectPoint cp, TypedStoredFlowEntry tfe, Load load) {
this.cp = cp;
this.tfe = tfe;
this.load = load;
}
+ /**
+ * Creates a new typed flow entry with load.
+ *
+ * @param cp connect point
+ * @param tfe typed flow entry
+ */
public TypedFlowEntryWithLoad(ConnectPoint cp, TypedStoredFlowEntry tfe) {
this.cp = cp;
this.tfe = tfe;
this.load = new DefaultLoad(tfe.bytes(), 0, typedPollInterval(tfe));
}
+ /**
+ * Creates a new typed flow entry with load.
+ *
+ * @param cp connect point
+ * @param fe flow entry
+ */
public TypedFlowEntryWithLoad(ConnectPoint cp, FlowEntry fe) {
this.cp = cp;
this.tfe = newTypedStoredFlowEntry(fe);
@@ -70,6 +88,8 @@ public class TypedFlowEntryWithLoad {
/**
* Returns short polling interval.
+ *
+ * @return short poll interval
*/
public static int shortPollInterval() {
return CAL_AND_POLL_INTERVAL;
@@ -77,6 +97,8 @@ public class TypedFlowEntryWithLoad {
/**
* Returns mid polling interval.
+ *
+ * @return mid poll interval
*/
public static int midPollInterval() {
return MID_POLL_INTERVAL;
@@ -84,6 +106,8 @@ public class TypedFlowEntryWithLoad {
/**
* Returns long polling interval.
+ *
+ * @return long poll interval
*/
public static int longPollInterval() {
return LONG_POLL_INTERVAL;
@@ -91,6 +115,8 @@ public class TypedFlowEntryWithLoad {
/**
* Returns average polling interval.
+ *
+ * @return average poll interval
*/
public static int avgPollInterval() {
return (CAL_AND_POLL_INTERVAL + MID_POLL_INTERVAL + LONG_POLL_INTERVAL) / 3;
@@ -100,6 +126,7 @@ public class TypedFlowEntryWithLoad {
* Returns current typed flow entry's polling interval.
*
* @param tfe typed flow entry
+ * @return typed poll interval
*/
public static long typedPollInterval(TypedStoredFlowEntry tfe) {
checkNotNull(tfe, "TypedStoredFlowEntry cannot be null");
@@ -120,6 +147,7 @@ public class TypedFlowEntryWithLoad {
* Creates a new typed flow entry with the given flow entry fe.
*
* @param fe flow entry
+ * @return new typed flow entry
*/
public static TypedStoredFlowEntry newTypedStoredFlowEntry(FlowEntry fe) {
if (fe == null) {
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java
index c0df7134..cfaf314c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounter.java
@@ -63,6 +63,7 @@ public interface AsyncAtomicCounter {
/**
* Atomically sets the given value to the current value.
*
+ * @param value new value
* @return future void
*/
CompletableFuture<Void> set(long value);
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/OduSignalIdTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/OduSignalIdTest.java
new file mode 100644
index 00000000..2ed15ff9
--- /dev/null
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/OduSignalIdTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import static org.onosproject.net.OduSignalId.oduSignalId;
+
+/**
+ * Test for OduSignalId.
+ */
+public class OduSignalIdTest {
+
+ private final OduSignalId odu1 = oduSignalId(7, 80, new byte[] {16, 16, 16, 16, 16, 16, 16, 16, 16, 16});
+ private final OduSignalId sameOdu1 = oduSignalId(7, 80, new byte[] {16, 16, 16, 16, 16, 16, 16, 16, 16, 16});
+ private final OduSignalId odu2 = oduSignalId(21, 80, new byte[] {10, 5, 10, 5, 10, 5, 10, 5, 10, 5});
+ private final OduSignalId sameOdu2 = oduSignalId(21, 80, new byte[] {10, 5, 10, 5, 10, 5, 10, 5, 10, 5});
+
+ @Test
+ public void testEquality() {
+ new EqualsTester()
+ .addEqualityGroup(odu1, sameOdu1)
+ .addEqualityGroup(odu2, sameOdu2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
index 95d605c6..d86744df 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
@@ -15,6 +15,16 @@
*/
package org.onosproject.net.flow.criteria;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
+import static org.onosproject.net.OduSignalId.oduSignalId;
+import static org.onosproject.net.PortNumber.portNumber;
+
import org.junit.Test;
import org.onlab.packet.EthType;
import org.onlab.packet.Ip6Address;
@@ -26,20 +36,12 @@ import org.onlab.packet.VlanId;
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.GridType;
import org.onosproject.net.Lambda;
+import org.onosproject.net.OchSignalType;
+import org.onosproject.net.OduSignalId;
+import org.onosproject.net.OduSignalType;
import org.onosproject.net.PortNumber;
import com.google.common.testing.EqualsTester;
-import org.onosproject.net.OchSignalType;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
-import static org.onosproject.net.PortNumber.portNumber;
-
/**
* Unit tests for the Criteria class and its subclasses.
*/
@@ -240,6 +242,18 @@ public class CriteriaTest {
Criterion matchOchSignal2 =
Criteria.matchLambda(Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 4, 8));
+ final OduSignalId odu1 = oduSignalId(1, 80, new byte [] {1, 1, 2, 2, 1, 2, 2, 1, 2, 2});
+ final OduSignalId odu2 = oduSignalId(3, 8, new byte [] {1, 0, 0, 0, 0, 0, 0, 0, 0, 0});
+ Criterion matchOduSignalId1 = Criteria.matchOduSignalId(odu1);
+ Criterion sameAsMatchOduSignalId1 = Criteria.matchOduSignalId(odu1);
+ Criterion matchOduSignalId2 = Criteria.matchOduSignalId(odu2);
+
+ final OduSignalType oduSigType1 = OduSignalType.ODU2;
+ final OduSignalType oduSigType2 = OduSignalType.ODU4;
+ Criterion matchOduSignalType1 = Criteria.matchOduSignalType(oduSigType1);
+ Criterion sameAsMatchOduSignalType1 = Criteria.matchOduSignalType(oduSigType1);
+ Criterion matchOduSignalType2 = Criteria.matchOduSignalType(oduSigType2);
+
/**
* Checks that a Criterion object has the proper type, and then converts
* it to the proper type.
@@ -294,6 +308,8 @@ public class CriteriaTest {
assertThatClassIsImmutable(MplsCriterion.class);
assertThatClassIsImmutable(IPv6ExthdrFlagsCriterion.class);
assertThatClassIsImmutable(LambdaCriterion.class);
+ assertThatClassIsImmutable(OduSignalIdCriterion.class);
+ assertThatClassIsImmutable(OduSignalTypeCriterion.class);
}
// PortCriterion class
@@ -1070,4 +1086,57 @@ public class CriteriaTest {
.addEqualityGroup(matchOchSignalType2)
.testEquals();
}
+
+ /**
+ * Test the OduSignalId method.
+ */
+ @Test
+ public void testMatchOduSignalIdMethod() {
+ OduSignalId odu = oduSignalId(1, 80, new byte[]{2, 1, 1, 3, 1, 1, 3, 1, 1, 3});
+
+ Criterion matchoduSignalId = Criteria.matchOduSignalId(odu);
+ OduSignalIdCriterion oduSignalIdCriterion =
+ checkAndConvert(matchoduSignalId,
+ Criterion.Type.ODU_SIGID,
+ OduSignalIdCriterion.class);
+ assertThat(oduSignalIdCriterion.oduSignalId(), is(equalTo(odu)));
+ }
+
+ /**
+ * Test the equals() method of the OduSignalIdCriterion class.
+ */
+ @Test
+ public void testOduSignalIdCriterionEquals() {
+ new EqualsTester()
+ .addEqualityGroup(matchOduSignalId1, sameAsMatchOduSignalId1)
+ .addEqualityGroup(matchOduSignalId2)
+ .testEquals();
+ }
+
+ // OduSignalTypeCriterion class
+
+ /**
+ * Test the OduSignalType method.
+ */
+ @Test
+ public void testMatchOduSignalTypeMethod() {
+ OduSignalType oduSigType = OduSignalType.ODU2;
+ Criterion matchoduSignalType = Criteria.matchOduSignalType(oduSigType);
+ OduSignalTypeCriterion oduSignalTypeCriterion =
+ checkAndConvert(matchoduSignalType,
+ Criterion.Type.ODU_SIGTYPE,
+ OduSignalTypeCriterion.class);
+ assertThat(oduSignalTypeCriterion.signalType(), is(equalTo(oduSigType)));
+ }
+
+ /**
+ * Test the equals() method of the OduSignalTypeCriterion class.
+ */
+ @Test
+ public void testOduSignalTypeCriterionEquals() {
+ new EqualsTester()
+ .addEqualityGroup(matchOduSignalType1, sameAsMatchOduSignalType1)
+ .addEqualityGroup(matchOduSignalType2)
+ .testEquals();
+ }
}
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
index 410349b5..a25783f9 100644
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
+++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
@@ -25,6 +25,7 @@ import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.GridType;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Lambda;
+import org.onosproject.net.OduSignalId;
import org.onosproject.net.PortNumber;
import com.google.common.testing.EqualsTester;
@@ -38,6 +39,7 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
import static org.onlab.junit.UtilityClassChecker.assertThatClassIsUtility;
import static org.onosproject.net.PortNumber.portNumber;
+import static org.onosproject.net.OduSignalId.oduSignalId;
/**
* Unit tests for the Instructions class.
@@ -96,6 +98,7 @@ public class InstructionsTest {
assertThatClassIsImmutable(Instructions.OutputInstruction.class);
assertThatClassIsImmutable(L0ModificationInstruction.ModLambdaInstruction.class);
assertThatClassIsImmutable(L0ModificationInstruction.ModOchSignalInstruction.class);
+ assertThatClassIsImmutable(L1ModificationInstruction.ModOduSignalIdInstruction.class);
assertThatClassIsImmutable(L2ModificationInstruction.ModEtherInstruction.class);
assertThatClassIsImmutable(L2ModificationInstruction.ModVlanIdInstruction.class);
assertThatClassIsImmutable(L2ModificationInstruction.ModVlanPcpInstruction.class);
@@ -259,6 +262,44 @@ public class InstructionsTest {
assertThat(ochInstruction1.hashCode(), is(not(ochInstruction2.hashCode())));
}
+ // ModOduSignalIdInstruction
+
+ private final OduSignalId odu1 = oduSignalId(1, 80, new byte[] {8, 7, 6, 5, 7, 6, 5, 7, 6, 5});
+ private final OduSignalId odu2 = oduSignalId(2, 80, new byte[] {1, 1, 2, 2, 1, 2, 2, 1, 2, 2});
+ private final Instruction oduInstruction1 = Instructions.modL1OduSignalId(odu1);
+ private final Instruction sameAsOduInstruction1 = Instructions.modL1OduSignalId(odu1);
+ private final Instruction oduInstruction2 = Instructions.modL1OduSignalId(odu2);
+
+ /**
+ * Test the modL1OduSignalId().
+ */
+ @Test
+ public void testModL1OduSignalIdMethod() {
+ Instruction instruction = Instructions.modL1OduSignalId(odu1);
+ L1ModificationInstruction.ModOduSignalIdInstruction oduInstruction =
+ checkAndConvert(instruction, Instruction.Type.L1MODIFICATION,
+ L1ModificationInstruction.ModOduSignalIdInstruction.class);
+ assertThat(oduInstruction.oduSignalId(), is(odu1));
+ }
+
+ /**
+ * Test the equals() method of the ModOduSignalInstruction class.
+ */
+ @Test
+ public void testModOduSignalIdInstructionEquals() {
+ checkEqualsAndToString(oduInstruction1, sameAsOduInstruction1, oduInstruction2);
+ }
+
+ /**
+ * Test the hashCode() method of the ModOduSignalInstruction class.
+ */
+ @Test
+ public void testModOduSignalIdInstructionHashCode() {
+ assertThat(oduInstruction1.hashCode(), is(sameAsOduInstruction1.hashCode()));
+ assertThat(oduInstruction1.hashCode(), is(not(oduInstruction2.hashCode())));
+ }
+
+
// ModEtherInstruction
private static final String MAC1 = "00:00:00:00:00:01";
diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/PortAddressesTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/PortAddressesTest.java
deleted file mode 100644
index 7c10cd15..00000000
--- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/host/PortAddressesTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.host;
-
-import java.util.Set;
-
-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.net.ConnectPoint;
-import org.onosproject.net.NetTestTools;
-
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.testing.EqualsTester;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit tests for port addresses class.
- */
-public class PortAddressesTest {
-
- PortAddresses addresses1;
- PortAddresses sameAsAddresses1;
- PortAddresses addresses2;
- PortAddresses addresses3;
-
- private static final ConnectPoint CONNECT_POINT1 =
- NetTestTools.connectPoint("cp1", 1);
- private static final IpAddress IP_ADDRESS1 = IpAddress.valueOf("1.2.3.4");
- private static final IpPrefix SUBNET_ADDRESS1 =
- IpPrefix.valueOf("1.2.0.0/16");
- private static final InterfaceIpAddress INTERFACE_ADDRESS_1 =
- new InterfaceIpAddress(IP_ADDRESS1, SUBNET_ADDRESS1);
-
- private static final ConnectPoint CONNECT_POINT2 =
- NetTestTools.connectPoint("cp2", 1);
- private static final IpAddress IP_ADDRESS2 = IpAddress.valueOf("1.2.3.5");
- private static final IpPrefix SUBNET_ADDRESS2 =
- IpPrefix.valueOf("1.3.0.0/16");
- private static final InterfaceIpAddress INTERFACE_ADDRESS_2 =
- new InterfaceIpAddress(IP_ADDRESS2, SUBNET_ADDRESS2);
-
- Set<InterfaceIpAddress> ipAddresses;
-
-
- /**
- * Initializes local data used by all test cases.
- */
- @Before
- public void setUpAddresses() {
- ipAddresses = ImmutableSet.of(INTERFACE_ADDRESS_1,
- INTERFACE_ADDRESS_2);
- addresses1 = new PortAddresses(CONNECT_POINT1, ipAddresses,
- MacAddress.BROADCAST, VlanId.NONE);
- sameAsAddresses1 = new PortAddresses(CONNECT_POINT1, ipAddresses,
- MacAddress.BROADCAST, VlanId.NONE);
- addresses2 = new PortAddresses(CONNECT_POINT2, ipAddresses,
- MacAddress.BROADCAST, VlanId.NONE);
- addresses3 = new PortAddresses(CONNECT_POINT2, ipAddresses,
- MacAddress.ZERO, VlanId.NONE);
- }
-
- /**
- * Checks that the PortAddresses class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PortAddresses.class);
- }
-
- /**
- * Checks the operation of the equals(), hash() and toString()
- * methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester()
- .addEqualityGroup(addresses1, sameAsAddresses1)
- .addEqualityGroup(addresses2)
- .addEqualityGroup(addresses3)
- .testEquals();
- }
-
- /**
- * Tests that object are created correctly.
- */
- @Test
- public void testConstruction() {
- assertThat(addresses1.mac(), is(MacAddress.BROADCAST));
- assertThat(addresses1.connectPoint(), is(CONNECT_POINT1));
- assertThat(addresses1.ipAddresses(), is(ipAddresses));
- assertThat(addresses1.vlan(), is(VlanId.NONE));
- }
-}
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java
index 76f621f2..975503bb 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/CriterionCodec.java
@@ -61,6 +61,12 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
protected static final String SLOT_GRANULARITY = "slotGranularity";
protected static final String OCH_SIGNAL_ID = "ochSignalId";
protected static final String TUNNEL_ID = "tunnelId";
+ protected static final String OCH_SIGNAL_TYPE = "ochSignalType";
+ protected static final String ODU_SIGNAL_ID = "oduSignalId";
+ protected static final String TRIBUTARY_PORT_NUMBER = "tributaryPortNumber";
+ protected static final String TRIBUTARY_SLOT_LEN = "tributarySlotLen";
+ protected static final String TRIBUTARY_SLOT_BITMAP = "tributarySlotBitmap";
+ protected static final String ODU_SIGNAL_TYPE = "oduSignalType";
@Override
public ObjectNode encode(Criterion criterion, CodecContext context) {
@@ -73,6 +79,4 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
DecodeCriterionCodecHelper decoder = new DecodeCriterionCodecHelper(json);
return decoder.decode();
}
-
-
}
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
index a962c0dd..f7af736e 100644
--- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
+++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
@@ -38,6 +38,8 @@ import org.onosproject.net.flow.criteria.MetadataCriterion;
import org.onosproject.net.flow.criteria.MplsCriterion;
import org.onosproject.net.flow.criteria.OchSignalCriterion;
import org.onosproject.net.flow.criteria.OchSignalTypeCriterion;
+import org.onosproject.net.flow.criteria.OduSignalIdCriterion;
+import org.onosproject.net.flow.criteria.OduSignalTypeCriterion;
import org.onosproject.net.flow.criteria.PortCriterion;
import org.onosproject.net.flow.criteria.SctpPortCriterion;
import org.onosproject.net.flow.criteria.TcpPortCriterion;
@@ -108,7 +110,8 @@ public final class EncodeCriterionCodecHelper {
formatMap.put(Criterion.Type.OCH_SIGTYPE, new FormatOchSigType());
formatMap.put(Criterion.Type.TUNNEL_ID, new FormatTunnelId());
formatMap.put(Criterion.Type.DUMMY, new FormatDummyType());
-
+ formatMap.put(Criterion.Type.ODU_SIGID, new FormatOduSignalId());
+ formatMap.put(Criterion.Type.ODU_SIGTYPE, new FormatOduSignalType());
// Currently unimplemented
formatMap.put(Criterion.Type.ARP_OP, new FormatUnknown());
formatMap.put(Criterion.Type.ARP_SPA, new FormatUnknown());
@@ -351,7 +354,7 @@ public final class EncodeCriterionCodecHelper {
public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
final OchSignalTypeCriterion ochSignalTypeCriterion =
(OchSignalTypeCriterion) criterion;
- return root.put("ochSignalType", ochSignalTypeCriterion.signalType().name());
+ return root.put(CriterionCodec.OCH_SIGNAL_TYPE, ochSignalTypeCriterion.signalType().name());
}
}
@@ -364,6 +367,24 @@ public final class EncodeCriterionCodecHelper {
}
}
+ private static class FormatOduSignalId implements CriterionTypeFormatter {
+ @Override
+ public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
+ final OduSignalIdCriterion oduSignalIdCriterion =
+ (OduSignalIdCriterion) criterion;
+ return root.put(CriterionCodec.ODU_SIGNAL_ID, oduSignalIdCriterion.oduSignalId().toString());
+ }
+ }
+
+ private static class FormatOduSignalType implements CriterionTypeFormatter {
+ @Override
+ public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
+ final OduSignalTypeCriterion oduSignalTypeCriterion =
+ (OduSignalTypeCriterion) criterion;
+ return root.put(CriterionCodec.ODU_SIGNAL_TYPE, oduSignalTypeCriterion.signalType().name());
+ }
+ }
+
private class FormatDummyType implements CriterionTypeFormatter {
@Override
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index e35dc0c5..9215d3a0 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -18,6 +18,7 @@ package org.onosproject.net.device.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onlab.util.Tools.nullIsNotFound;
import static org.onosproject.net.MastershipRole.MASTER;
import static org.onosproject.net.MastershipRole.NONE;
import static org.onosproject.net.MastershipRole.STANDBY;
@@ -435,7 +436,7 @@ public class DeviceManager
portDescription);
return;
}
- final Device device = getDevice(deviceId);
+ Device device = nullIsNotFound(getDevice(deviceId), "Device not found");
if ((Device.Type.ROADM.equals(device.type()))) {
Port port = getPort(deviceId, portDescription.portNumber());
portDescription = OpticalPortOperator.descriptionOf(port, portDescription.isEnabled());
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
index 8f2bda01..19377cf6 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
@@ -158,8 +158,8 @@ public final class OpticalPortOperator implements ConfigOperator {
/**
* Returns a description built from an existing port and reported status.
*
- * @param port
- * @param isEnabled
+ * @param port port
+ * @param isEnabled true if enabled
* @return a PortDescription based on the port
*/
static PortDescription descriptionOf(Port port, boolean isEnabled) {
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
index 417627ad..a387d6f4 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
@@ -235,8 +235,10 @@ public class IntentCleanup implements Runnable, IntentListener {
stuckCount++;
}
- log.debug("Intent cleanup ran and resubmitted {} corrupt, {} failed, {} stuck, and {} pending intents",
- corruptCount, failedCount, stuckCount, pendingCount);
+ if (corruptCount + failedCount + stuckCount + pendingCount > 0) {
+ log.debug("Intent cleanup ran and resubmitted {} corrupt, {} failed, {} stuck, and {} pending intents",
+ corruptCount, failedCount, stuckCount, pendingCount);
+ }
}
@Override
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java
deleted file mode 100644
index 62b4112b..00000000
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.resource.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.net.Port;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.resource.device.DeviceResourceService;
-import org.onosproject.net.resource.device.DeviceResourceStore;
-import org.slf4j.Logger;
-
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides basic implementation of device resources allocation.
- */
-@Component(immediate = true)
-@Service
-public class DeviceResourceManager implements DeviceResourceService {
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- private DeviceResourceStore store;
-
- @Activate
- public void activate() {
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean requestPorts(Set<Port> ports, Intent intent) {
- checkNotNull(intent);
-
- return store.allocatePorts(ports, intent.id());
- }
-
- @Override
- public Set<Port> getAllocations(IntentId intentId) {
- return store.getAllocations(intentId);
- }
-
- @Override
- public IntentId getAllocations(Port port) {
- return store.getAllocations(port);
- }
-
- @Override
- public void releaseMapping(IntentId intentId) {
- store.releaseMapping(intentId);
- }
-
- @Override
- public boolean requestMapping(IntentId keyIntentId, IntentId valIntentId) {
- return store.allocateMapping(keyIntentId, valIntentId);
- }
-
- @Override
- public Set<IntentId> getMapping(IntentId intentId) {
- return store.getMapping(intentId);
- }
-
- @Override
- public void releasePorts(IntentId intentId) {
- store.releasePorts(intentId);
- }
-
- private Port getTypedPort(Set<Port> ports, Port.Type type) {
- for (Port port : ports) {
- if (port.type() == type) {
- return port;
- }
- }
-
- return null;
- }
-}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
index 648119e5..10f79eb0 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
@@ -304,7 +304,7 @@ public class ConsistentResourceStore implements ResourceStore {
}
/**
- * Removes teh values from the existing values associated with the specified key.
+ * Removes the values from the existing values associated with the specified key.
* If the map doesn't contain the given values, removal will not happen.
*
* @param map map holding multiple values for a key
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 f0f3eb5e..3865a779 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
@@ -41,6 +41,7 @@ import org.onosproject.store.cluster.messaging.MessageSubject;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.serializers.KryoSerializer;
import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.ConsistentMapException;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.slf4j.Logger;
@@ -52,6 +53,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onlab.util.Tools.retryable;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -66,6 +68,8 @@ public class DistributedPacketStore
private final Logger log = getLogger(getClass());
+ private static final int MAX_BACKOFF = 10;
+
// TODO: make this configurable.
private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 4;
@@ -159,11 +163,11 @@ public class DistributedPacketStore
return tracker.requests();
}
- private class PacketRequestTracker {
+ private final class PacketRequestTracker {
private ConsistentMap<TrafficSelector, Set<PacketRequest>> requests;
- public PacketRequestTracker() {
+ private PacketRequestTracker() {
requests = storageService.<TrafficSelector, Set<PacketRequest>>consistentMapBuilder()
.withName("onos-packet-requests")
.withPartitionsDisabled()
@@ -171,7 +175,17 @@ public class DistributedPacketStore
.build();
}
- public void add(PacketRequest request) {
+ private void add(PacketRequest request) {
+ AtomicBoolean firstRequest =
+ retryable(this::addInternal, ConsistentMapException.class,
+ 3, MAX_BACKOFF).apply(request);
+ if (firstRequest.get() && delegate != null) {
+ // The instance that makes the first request will push to all devices
+ delegate.requestPackets(request);
+ }
+ }
+
+ private AtomicBoolean addInternal(PacketRequest request) {
AtomicBoolean firstRequest = new AtomicBoolean(false);
requests.compute(request.selector(), (s, existingRequests) -> {
if (existingRequests == null) {
@@ -186,14 +200,20 @@ public class DistributedPacketStore
return existingRequests;
}
});
+ return firstRequest;
+ }
- if (firstRequest.get() && delegate != null) {
- // The instance that makes the first request will push to all devices
- delegate.requestPackets(request);
+ private void remove(PacketRequest request) {
+ AtomicBoolean removedLast =
+ retryable(this::removeInternal, ConsistentMapException.class,
+ 3, MAX_BACKOFF).apply(request);
+ if (removedLast.get() && delegate != null) {
+ // The instance that removes the last request will remove from all devices
+ delegate.cancelPackets(request);
}
}
- public void remove(PacketRequest request) {
+ private AtomicBoolean removeInternal(PacketRequest request) {
AtomicBoolean removedLast = new AtomicBoolean(false);
requests.computeIfPresent(request.selector(), (s, existingRequests) -> {
if (existingRequests.contains(request)) {
@@ -209,15 +229,10 @@ public class DistributedPacketStore
return existingRequests;
}
});
-
- if (removedLast.get() && delegate != null) {
- // The instance that removes the last request will remove from all devices
- delegate.cancelPackets(request);
- }
-
+ return removedLast;
}
- public List<PacketRequest> requests() {
+ private List<PacketRequest> requests() {
List<PacketRequest> list = Lists.newArrayList();
requests.values().forEach(v -> list.addAll(v.value()));
list.sort((o1, o2) -> o1.priority().priorityValue() - o2.priority().priorityValue());
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
deleted file mode 100644
index 3266e96c..00000000
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.store.resource.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.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.resource.device.DeviceResourceStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.TransactionContext;
-import org.onosproject.store.service.TransactionalMap;
-import org.onosproject.store.service.Versioned;
-import org.slf4j.Logger;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static org.slf4j.LoggerFactory.getLogger;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Store that manages device resources using Copycat-backed TransactionalMaps.
- */
-@Component(immediate = true, enabled = true)
-@Service
-public class ConsistentDeviceResourceStore implements DeviceResourceStore {
- private final Logger log = getLogger(getClass());
-
- private static final String PORT_ALLOCATIONS = "PortAllocations";
- private static final String INTENT_MAPPING = "IntentMapping";
- private static final String INTENT_ALLOCATIONS = "PortIntentAllocations";
-
- private static final Serializer SERIALIZER = Serializer.using(KryoNamespaces.API);
-
- private ConsistentMap<Port, IntentId> portAllocMap;
- private ConsistentMap<IntentId, Set<Port>> intentAllocMap;
- private ConsistentMap<IntentId, Set<IntentId>> intentMapping;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
-
- @Activate
- public void activate() {
- portAllocMap = storageService.<Port, IntentId>consistentMapBuilder()
- .withName(PORT_ALLOCATIONS)
- .withSerializer(SERIALIZER)
- .build();
- intentAllocMap = storageService.<IntentId, Set<Port>>consistentMapBuilder()
- .withName(INTENT_ALLOCATIONS)
- .withSerializer(SERIALIZER)
- .build();
- intentMapping = storageService.<IntentId, Set<IntentId>>consistentMapBuilder()
- .withName(INTENT_MAPPING)
- .withSerializer(SERIALIZER)
- .build();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- private TransactionalMap<Port, IntentId> getPortAllocs(TransactionContext tx) {
- return tx.getTransactionalMap(PORT_ALLOCATIONS, SERIALIZER);
- }
-
- private TransactionalMap<IntentId, Set<Port>> getIntentAllocs(TransactionContext tx) {
- return tx.getTransactionalMap(INTENT_ALLOCATIONS, SERIALIZER);
- }
-
- private TransactionContext getTxContext() {
- return storageService.transactionContextBuilder().build();
- }
-
- @Override
- public Set<Port> getFreePorts(DeviceId deviceId) {
- checkNotNull(deviceId);
-
- Set<Port> freePorts = new HashSet<>();
- for (Port port : deviceService.getPorts(deviceId)) {
- if (!portAllocMap.containsKey(port)) {
- freePorts.add(port);
- }
- }
-
- return freePorts;
- }
-
- @Override
- public boolean allocatePorts(Set<Port> ports, IntentId intentId) {
- checkNotNull(ports);
- checkArgument(ports.size() > 0);
- checkNotNull(intentId);
-
- TransactionContext tx = getTxContext();
- tx.begin();
- try {
- TransactionalMap<Port, IntentId> portAllocs = getPortAllocs(tx);
- for (Port port : ports) {
- if (portAllocs.putIfAbsent(port, intentId) != null) {
- throw new Exception("Port already allocated " + port.toString());
- }
- }
-
- TransactionalMap<IntentId, Set<Port>> intentAllocs = getIntentAllocs(tx);
- intentAllocs.put(intentId, ports);
- tx.commit();
- } catch (Exception e) {
- log.error("Exception thrown, rolling back", e);
- tx.abort();
- return false;
- }
-
- return true;
- }
-
- @Override
- public Set<Port> getAllocations(IntentId intentId) {
- if (!intentAllocMap.containsKey(intentId)) {
- Collections.emptySet();
- }
-
- return intentAllocMap.get(intentId).value();
- }
-
- @Override
- public IntentId getAllocations(Port port) {
- if (!portAllocMap.containsKey(port)) {
- return null;
- }
-
- return portAllocMap.get(port).value();
- }
-
- @Override
- public Set<IntentId> getMapping(IntentId intentId) {
- Versioned<Set<IntentId>> result = intentMapping.get(intentId);
-
- if (result != null) {
- return result.value();
- }
-
- return null;
- }
-
- @Override
- public boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId) {
- Versioned<Set<IntentId>> versionedIntents = intentMapping.get(keyIntentId);
-
- if (versionedIntents == null) {
- Set<IntentId> newSet = new HashSet<>();
- newSet.add(valIntentId);
- intentMapping.put(keyIntentId, newSet);
- } else {
- versionedIntents.value().add(valIntentId);
- }
-
- return true;
- }
-
- @Override
- public void releaseMapping(IntentId intentId) {
- for (IntentId intent : intentMapping.keySet()) {
- // TODO: optimize by checking for identical src & dst
- Set<IntentId> mapping = intentMapping.get(intent).value();
- if (mapping.remove(intentId)) {
- return;
- }
- }
- }
-
- @Override
- public boolean releasePorts(IntentId intentId) {
- checkNotNull(intentId);
-
- TransactionContext tx = getTxContext();
- tx.begin();
- try {
- TransactionalMap<IntentId, Set<Port>> intentAllocs = getIntentAllocs(tx);
- Set<Port> ports = intentAllocs.get(intentId);
- intentAllocs.remove(intentId);
-
- TransactionalMap<Port, IntentId> portAllocs = getPortAllocs(tx);
- for (Port port : ports) {
- portAllocs.remove(port);
- }
- tx.commit();
- } catch (Exception e) {
- log.error("Exception thrown, rolling back", e);
- tx.abort();
- return false;
- }
-
- return true;
- }
-}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java
index 87e67215..8d5a1001 100644
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java
+++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentIntentSetMultimap.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.store.resource.impl;
+import com.google.common.annotations.Beta;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -42,6 +43,7 @@ import static org.slf4j.LoggerFactory.getLogger;
*/
@Component(immediate = true, enabled = true)
@Service
+@Beta
public class ConsistentIntentSetMultimap implements IntentSetMultimap {
private final Logger log = getLogger(getClass());
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 11137aa2..c332ada5 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
@@ -363,6 +363,15 @@ public class ConsistentLinkResourceStore extends
after.add(allocations);
linkAllocs.putIfAbsent(linkKey, after);
} else {
+ boolean overlapped = before.stream()
+ .flatMap(x -> x.getResourceAllocation(link).stream())
+ .anyMatch(x -> allocations.getResourceAllocation(link).contains(x));
+ if (overlapped) {
+ throw new ResourceAllocationException(
+ String.format("Resource allocations are overlapped between %s and %s",
+ before, allocations)
+ );
+ }
List<LinkResourceAllocations> after = new ArrayList<>(before.size() + 1);
after.addAll(before);
after.add(allocations);
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/RequestContext.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/RequestContext.java
deleted file mode 100644
index 338c8408..00000000
--- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/RequestContext.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.incubator.net.domain;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.net.Path;
-
-/**
- * Context for intent primitive requests to an intent domain provider. A context
- * must be explicitly applied before it can be used. The purpose of the request
- * context is so that an application can coordinate multiple requests across multiple
- * domains before committing. Contexts can be explicitly cancelled if they are not
- * needed (due to a better context or incomplete path across domains); they can
- * also be automatically cancelled by a provider after a short timeout.
- */
-@Beta
-public class RequestContext {
- private final IntentDomain domain;
- private final IntentResource resource;
- private final Path path;
- //TODO other common parameters:
- //String cost;
-
- public RequestContext(IntentDomain domain, IntentResource resource, Path path) {
- this.domain = domain;
- this.resource = resource;
- this.path = path;
- }
-
- public IntentDomain domain() {
- return domain;
- }
-
- public IntentResource resource() {
- return resource;
- }
-
- public Path path() {
- return path;
- }
-}
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkProvider.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkProvider.java
index 8e5b19a5..bf4a4855 100644
--- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkProvider.java
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkProvider.java
@@ -17,6 +17,7 @@ public interface VirtualNetworkProvider extends Provider {
* @param networkId virtual network identifier
* @param src source connection point
* @param dst destination connection point
+ * @return new tunnel's id
*/
TunnelId createTunnel(NetworkId networkId, ConnectPoint src, ConnectPoint dst);
diff --git a/framework/src/onos/netconf/api/pom.xml b/framework/src/onos/netconf/api/pom.xml
new file mode 100644
index 00000000..d93b3be3
--- /dev/null
+++ b/framework/src/onos/netconf/api/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-netconf</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>onos-netconf-api</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS NETCONF plugin API</description>
+ <dependencies>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport-native-epoll</artifactId>
+ <version>${netty4.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-netconf-rfc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/netconf/api/src/main/java/org/onosproject/netconf/Foo.java b/framework/src/onos/netconf/api/src/main/java/org/onosproject/netconf/Foo.java
new file mode 100644
index 00000000..ff688f45
--- /dev/null
+++ b/framework/src/onos/netconf/api/src/main/java/org/onosproject/netconf/Foo.java
@@ -0,0 +1,7 @@
+package org.onosproject.netconf;
+
+/**
+ * Created by tom on 10/19/15.
+ */
+public class Foo {
+}
diff --git a/framework/src/onos/apps/config/pom.xml b/framework/src/onos/netconf/ctl/pom.xml
index 1b95c579..56f17c90 100644
--- a/framework/src/onos/apps/config/pom.xml
+++ b/framework/src/onos/netconf/ctl/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- ~ Copyright 2014 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.
@@ -18,36 +18,30 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
<parent>
<groupId>org.onosproject</groupId>
- <artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <artifactId>onos-netconf</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>onos-app-config</artifactId>
+ <artifactId>onos-netconf-ctl</artifactId>
<packaging>bundle</packaging>
- <description>Network configuration application</description>
-
- <properties>
- <onos.app.name>org.onosproject.config</onos.app.name>
- </properties>
-
<dependencies>
<dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-netconf-api</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
- <artifactId>onlab-misc</artifactId>
+ <artifactId>onos-netconf-rfc</artifactId>
+ <version>${project.version}</version>
</dependency>
</dependencies>
-
</project>
diff --git a/framework/src/onos/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/Foo.java b/framework/src/onos/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/Foo.java
new file mode 100644
index 00000000..e0f6b3df
--- /dev/null
+++ b/framework/src/onos/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/Foo.java
@@ -0,0 +1,7 @@
+package org.onosproject.netconf.ctl;
+
+/**
+ * Created by tom on 10/19/15.
+ */
+public class Foo {
+}
diff --git a/framework/src/onos/netconf/pom.xml b/framework/src/onos/netconf/pom.xml
new file mode 100644
index 00000000..7a36c227
--- /dev/null
+++ b/framework/src/onos/netconf/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-netconf</artifactId>
+ <packaging>pom</packaging>
+
+ <description>ONOS NETCONF southbound libraries</description>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-buffer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-handler</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>api</module>
+ <module>rfc</module>
+ <module>ctl</module>
+ </modules>
+</project>
diff --git a/framework/src/onos/netconf/rfc/pom.xml b/framework/src/onos/netconf/rfc/pom.xml
new file mode 100644
index 00000000..fa1e06e2
--- /dev/null
+++ b/framework/src/onos/netconf/rfc/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-netconf</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-netconf-rfc</artifactId>
+ <packaging>bundle</packaging>
+
+</project>
diff --git a/framework/src/onos/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/Foo.java b/framework/src/onos/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/Foo.java
new file mode 100644
index 00000000..06963b0c
--- /dev/null
+++ b/framework/src/onos/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/Foo.java
@@ -0,0 +1,7 @@
+package org.onosproject.netconf.rfc;
+
+/**
+ * Created by tom on 10/19/15.
+ */
+public class Foo {
+}
diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java
index f2ff0709..e619f8e0 100644
--- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java
+++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java
@@ -28,6 +28,7 @@ import org.onosproject.ovsdb.rfc.operations.Operation;
import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -50,6 +51,17 @@ public interface OvsdbClientService extends OvsdbRPC {
void createTunnel(IpAddress srcIp, IpAddress dstIp);
/**
+ * Creates a tunnel port with given options.
+ *
+ * @param bridgeName bridge name
+ * @param portName port name
+ * @param tunnelType tunnel type
+ * @param options tunnel options
+ * @return true if tunnel creation is successful, false otherwise
+ */
+ boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options);
+
+ /**
* Drops the configuration for the tunnel.
*
* @param srcIp source IP address
@@ -72,6 +84,17 @@ public interface OvsdbClientService extends OvsdbRPC {
void createBridge(String bridgeName);
/**
+ * Creates a bridge with given name and dpid.
+ * Sets the bridge's controller with given controllers.
+ *
+ * @param bridgeName bridge name
+ * @param dpid data path id
+ * @param controllers controllers
+ * @return true if bridge creation is successful, false otherwise
+ */
+ boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers);
+
+ /**
* Drops a bridge.
*
* @param bridgeName bridge name
@@ -88,13 +111,14 @@ public interface OvsdbClientService extends OvsdbRPC {
/**
* Gets controllers of the node.
*
+ * @param openflowDeviceId target device id
* @return set of controllers; empty if no controller is find
*/
Set<ControllerInfo> getControllers(DeviceId openflowDeviceId);
/**
* Sets the Controllers for the specified bridge.
- * <p/>
+ * <p>
* This method will replace the existing controller list with the new controller
* list.
*
@@ -105,7 +129,7 @@ public interface OvsdbClientService extends OvsdbRPC {
/**
* Sets the Controllers for the specified device.
- * <p/>
+ * <p>
* This method will replace the existing controller list with the new controller
* list.
*
diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
index 3a84d000..2575a256 100644
--- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
+++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
@@ -73,6 +73,8 @@ import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -481,6 +483,52 @@ public class DefaultOvsdbClient
log.info("Create bridge success");
}
+ @Override
+ public boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers) {
+
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ String ovsUuid = getOvsUuid(OvsdbConstant.DATABASENAME);
+
+ if (dbSchema == null || ovsUuid == null) {
+ log.warn("Couldn't find database Open_vSwitch");
+ return false;
+ }
+
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid != null) {
+ log.warn("Bridge {} is already exist", bridgeName);
+ // remove existing one and re-create?
+ return false;
+ }
+
+ Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema, OvsdbTable.BRIDGE);
+ bridge.setName(bridgeName);
+
+ Set<String> failMode = new HashSet<>(Arrays.asList("secure"));
+ bridge.setFailMode(failMode);
+
+ Set<String> protocols = new HashSet<>(Arrays.asList(OvsdbConstant.OPENFLOW13));
+ bridge.setProtocols(protocols);
+
+ Map<String, String> options = new HashMap<>();
+ options.put("datapath-id", dpid);
+ bridge.setOtherConfig(options);
+
+ bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid",
+ OvsdbConstant.DATABASENAME, "bridges",
+ ovsUuid, bridge.getRow());
+
+ if (bridgeUuid != null) {
+ createPort(bridgeName, bridgeName);
+ } else {
+ log.warn("Failed to create bridge {} on {}", bridgeName, nodeId.toString());
+ return false;
+ }
+
+ setControllersWithUUID(UUID.uuid(bridgeUuid), controllers);
+ return true;
+ }
+
/**
* Sets the bridge's controller automatically.
* <p/>
@@ -648,6 +696,50 @@ public class DefaultOvsdbClient
}
@Override
+ public boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options) {
+
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid == null) {
+ log.warn("Couldn't find bridge {} in {}", bridgeName, nodeId.getIpAddress());
+ return false;
+ }
+
+ if (getPortUuid(portName, bridgeUuid) != null) {
+ log.warn("Port {} already exists", portName);
+ // remove existing one and re-create?
+ return false;
+ }
+
+ ArrayList<Operation> operations = Lists.newArrayList();
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+
+ // insert a new port to the port table
+ Port port = (Port) TableGenerator.createTable(dbSchema, OvsdbTable.PORT);
+ port.setName(portName);
+ Insert portInsert = new Insert(dbSchema.getTableSchema("Port"), "Port", port.getRow());
+ portInsert.getRow().put("interfaces", UUID.uuid("Interface"));
+ operations.add(portInsert);
+
+ // update the bridge table
+ Condition condition = ConditionUtil.equals("_uuid", UUID.uuid(bridgeUuid));
+ Mutation mutation = MutationUtil.insert("ports", UUID.uuid("Port"));
+ List<Condition> conditions = new ArrayList<>(Arrays.asList(condition));
+ List<Mutation> mutations = new ArrayList<>(Arrays.asList(mutation));
+ operations.add(new Mutate(dbSchema.getTableSchema("Bridge"), conditions, mutations));
+
+ // insert a tunnel interface
+ Interface intf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
+ intf.setName(portName);
+ intf.setType(tunnelType);
+ intf.setOptions(options);
+ Insert intfInsert = new Insert(dbSchema.getTableSchema("Interface"), "Interface", intf.getRow());
+ operations.add(intfInsert);
+
+ transactConfig(OvsdbConstant.DATABASENAME, operations);
+ return true;
+ }
+
+ @Override
public void dropTunnel(IpAddress srcIp, IpAddress dstIp) {
String bridgeName = OvsdbConstant.INTEGRATION_BRIDGE;
String portName = getTunnelName(OvsdbConstant.TYPEVXLAN, dstIp);
diff --git a/framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java b/framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java
index 71fee4fe..2c418d57 100644
--- a/framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java
+++ b/framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java
@@ -34,6 +34,7 @@ import org.onosproject.ovsdb.rfc.operations.Operation;
import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -52,6 +53,11 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService {
}
@Override
+ public boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options) {
+ return true;
+ }
+
+ @Override
public void dropTunnel(IpAddress srcIp, IpAddress dstIp) {
}
@@ -67,6 +73,11 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService {
}
@Override
+ public boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers) {
+ return true;
+ }
+
+ @Override
public void dropBridge(String bridgeName) {
}
diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java
index 00609602..09088766 100644
--- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java
+++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java
@@ -43,6 +43,7 @@ public final class Row {
* Row constructor.
*
* @param tableName table name
+ * @deprecated in Emu Release
*/
@Deprecated
private Row(String tableName) {
@@ -56,6 +57,7 @@ public final class Row {
*
* @param tableName table name
* @param columns Map of Column entity
+ * @param uuid UUID of the row
*/
public Row(String tableName, UUID uuid, Map<String, Column> columns) {
checkNotNull(tableName, "table name cannot be null");
diff --git a/framework/src/onos/pom.xml b/framework/src/onos/pom.xml
index 93ef2779..b9fdfe22 100644
--- a/framework/src/onos/pom.xml
+++ b/framework/src/onos/pom.xml
@@ -46,6 +46,7 @@
<module>openflow</module>
<module>ovsdb</module>
+ <module>netconf</module>
<module>pcep</module>
<module>providers</module>
diff --git a/framework/src/onos/providers/netconf/app/pom.xml b/framework/src/onos/providers/netconf/app/pom.xml
index dbd0a520..4a19ae8e 100644
--- a/framework/src/onos/providers/netconf/app/pom.xml
+++ b/framework/src/onos/providers/netconf/app/pom.xml
@@ -26,7 +26,7 @@
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>onos-netconf</artifactId>
+ <artifactId>onos-netconf-app</artifactId>
<packaging>pom</packaging>
<description>NetConf protocol southbound providers</description>
diff --git a/framework/src/onos/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/framework/src/onos/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index 4fa961f8..329df20b 100644
--- a/framework/src/onos/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/framework/src/onos/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -377,7 +377,6 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
public void receivedRoleReply(Dpid dpid, RoleState requested, RoleState response) {
MastershipRole request = roleOf(requested);
MastershipRole reply = roleOf(response);
-
providerService.receivedRoleReply(deviceId(uri(dpid)), request, reply);
}
diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java
index a81367cd..487cae96 100644
--- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java
+++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/NewAdaptiveFlowStatsCollector.java
@@ -492,6 +492,7 @@ public class NewAdaptiveFlowStatsCollector {
/**
* returns flowMissingXid that indicates the execution of flowMissing process or not(NO_FLOW_MISSING_XID(-1)).
*
+ * @return xid of missing flow
*/
public long getFlowMissingXid() {
return flowMissingXid;
diff --git a/framework/src/onos/tools/dev/bash_profile b/framework/src/onos/tools/dev/bash_profile
index f39c2ce1..a0f040a5 100644
--- a/framework/src/onos/tools/dev/bash_profile
+++ b/framework/src/onos/tools/dev/bash_profile
@@ -52,6 +52,7 @@ alias mis='mvn install -DskipTests -Dcheckstyle.skip -U -T 1C'
# Short-hand for ONOS build, package and test.
alias ob='onos-build'
+alias obf='ob -DskipTests -Dcheckstyle.skip'
alias obi='onos-build -Dmaven.test.failure.ignore=true'
alias obs='onos-build-selective'
alias obd='onos-build-docs'
@@ -112,6 +113,7 @@ function cell {
unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
unset OCI OCN OCT ONOS_INSTANCES ONOS_USER ONOS_GROUP ONOS_FEATURES
unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
+ export ONOS_USER=${ONOS_USER:-sdn}
export ONOS_WEB_USER=onos
export ONOS_WEB_PASS=rocks
export ONOS_CELL=$1
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css
deleted file mode 100644
index c492e203..00000000
--- a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css
+++ /dev/null
@@ -1,35 +0,0 @@
-/* css for sample app view */
-
-#ov-sample h2 {
- display: inline-block;
-}
-
-/* Panel Styling */
-#item-details-panel.floatpanel {
- position: absolute;
- top: 115px;
-}
-
-.light #item-details-panel.floatpanel {
- background-color: rgb(229, 234, 237);
-}
-.dark #item-details-panel.floatpanel {
- background-color: #3A4042;
-}
-
-#item-details-panel h3 {
- margin: 0;
- font-size: large;
-}
-
-#item-details-panel h4 {
- margin: 0;
-}
-
-#item-details-panel td {
- padding: 5px;
-}
-#item-details-panel td.label {
- font-style: italic;
- opacity: 0.8;
-} \ No newline at end of file
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html
deleted file mode 100644
index 03a7383e..00000000
--- a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!-- partial HTML -->
-<div id="ov-sample">
- <div class="tabular-header">
- <h2>Items ({{tableData.length}} total)</h2>
- <div class="ctrl-btns">
- <div class="refresh" ng-class="{active: autoRefresh}"
- icon icon-id="refresh" icon-size="36"
- tooltip tt-msg="autoRefreshTip"
- ng-click="toggleRefresh()"></div>
- </div>
- </div>
-
- <div class="summary-list" onos-table-resize>
-
- <div class="table-header" onos-sortable-header>
- <table>
- <tr>
- <td colId="id" sortable>Item ID </td>
- <td colId="label" sortable>Label </td>
- <td colId="code" sortable>Code </td>
- </tr>
- </table>
- </div>
-
- <div class="table-body">
- <table>
- <tr ng-if="!tableData.length" class="no-data">
- <td colspan="3">
- No Items found
- </td>
- </tr>
-
- <tr ng-repeat="item in tableData track by $index"
- ng-click="selectCallback($event, item)"
- ng-class="{selected: item.id === selId}">
- <td>{{item.id}}</td>
- <td>{{item.label}}</td>
- <td>{{item.code}}</td>
- </tr>
- </table>
- </div>
-
- </div>
-
- <item-details-panel></item-details-panel>
-</div>
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js
deleted file mode 100644
index 2d4aed48..00000000
--- a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js
+++ /dev/null
@@ -1,139 +0,0 @@
-// js for sample app view
-(function () {
- 'use strict';
-
- // injected refs
- var $log, $scope, fs, wss, ps;
-
- // constants
- var detailsReq = 'sampleDetailsRequest',
- detailsResp = 'sampleDetailsResponse',
- pName = 'item-details-panel',
-
- propOrder = ['id', 'label', 'code'],
- friendlyProps = ['Item ID', 'Item Label', 'Special Code'];
-
-
- function addProp(tbody, index, value) {
- var tr = tbody.append('tr');
-
- function addCell(cls, txt) {
- tr.append('td').attr('class', cls).html(txt);
- }
- addCell('label', friendlyProps[index] + ' :');
- addCell('value', value);
- }
-
- function populatePanel(panel) {
- var title = panel.append('h3'),
- tbody = panel.append('table').append('tbody');
-
- title.text('Item Details');
-
- propOrder.forEach(function (prop, i) {
- addProp(tbody, i, $scope.panelDetails[prop]);
- });
-
- panel.append('hr');
- panel.append('h4').text('Comments');
- panel.append('p').text($scope.panelDetails.comment);
- }
-
- function respDetailsCb(data) {
- $scope.panelDetails = data.details;
- $scope.$apply();
- }
-
- angular.module('ovSample', [])
- .controller('OvSampleCtrl',
- ['$log', '$scope', 'TableBuilderService',
- 'FnService', 'WebSocketService',
-
- function (_$log_, _$scope_, tbs, _fs_, _wss_) {
- $log = _$log_;
- $scope = _$scope_;
- fs = _fs_;
- wss = _wss_;
-
- var handlers = {};
- $scope.panelDetails = {};
-
- // details response handler
- handlers[detailsResp] = respDetailsCb;
- wss.bindHandlers(handlers);
-
- // custom selection callback
- function selCb($event, row) {
- if ($scope.selId) {
- wss.sendEvent(detailsReq, { id: row.id });
- } else {
- $scope.hidePanel();
- }
- $log.debug('Got a click on:', row);
- }
-
- // TableBuilderService creating a table for us
- tbs.buildTable({
- scope: $scope,
- tag: 'sample',
- selCb: selCb
- });
-
- // cleanup
- $scope.$on('$destroy', function () {
- wss.unbindHandlers(handlers);
- });
-
- $log.log('OvSampleCtrl has been created');
- }])
-
- .directive('itemDetailsPanel', ['PanelService', 'KeyService',
- function (_ps_, ks) {
- return {
- restrict: 'E',
- link: function (scope, element, attrs) {
- ps = _ps_;
- // insert details panel with PanelService
- // create the panel
- var panel = ps.createPanel(pName, {
- width: 200,
- margin: 20,
- hideMargin: 0
- });
- panel.hide();
- scope.hidePanel = function () { panel.hide(); };
-
- function closePanel() {
- if (panel.isVisible()) {
- $scope.selId = null;
- panel.hide();
- }
- }
-
- // create key bindings to handle panel
- ks.keyBindings({
- esc: [closePanel, 'Close the details panel'],
- _helpFormat: ['esc']
- });
- ks.gestureNotes([
- ['click', 'Select a row to show item details']
- ]);
-
- // update the panel's contents when the data is changed
- scope.$watch('panelDetails', function () {
- if (!fs.isEmptyObject(scope.panelDetails)) {
- panel.empty();
- populatePanel(panel);
- panel.show();
- }
- });
-
- // cleanup on destroyed scope
- scope.$on('$destroy', function () {
- ks.unbindKeys();
- ps.destroyPanel(pName);
- });
- }
- };
- }]);
-}());
diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java
index fe28186b..7c35cc53 100644
--- a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java
+++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java
@@ -49,9 +49,9 @@ import java.util.TimerTask;
*/
public class AppUiTopovMessageHandler extends UiMessageHandler {
- private static final String SAMPLE_DISPLAY_START = "sampleDisplayStart";
- private static final String SAMPLE_DISPLAY_UPDATE = "sampleDisplayUpdate";
- private static final String SAMPLE_DISPLAY_STOP = "sampleDisplayStop";
+ private static final String SAMPLE_TOPOV_DISPLAY_START = "sampleTopovDisplayStart";
+ private static final String SAMPLE_TOPOV_DISPLAY_UPDATE = "sampleTopovDisplayUpdate";
+ private static final String SAMPLE_TOPOV_DISPLAY_STOP = "sampleTopovDisplayStop";
private static final String ID = "id";
private static final String MODE = "mode";
@@ -101,7 +101,7 @@ public class AppUiTopovMessageHandler extends UiMessageHandler {
private final class DisplayStartHandler extends RequestHandler {
public DisplayStartHandler() {
- super(SAMPLE_DISPLAY_START);
+ super(SAMPLE_TOPOV_DISPLAY_START);
}
@Override
@@ -136,7 +136,7 @@ public class AppUiTopovMessageHandler extends UiMessageHandler {
private final class DisplayUpdateHandler extends RequestHandler {
public DisplayUpdateHandler() {
- super(SAMPLE_DISPLAY_UPDATE);
+ super(SAMPLE_TOPOV_DISPLAY_UPDATE);
}
@Override
@@ -153,7 +153,7 @@ public class AppUiTopovMessageHandler extends UiMessageHandler {
private final class DisplayStopHandler extends RequestHandler {
public DisplayStopHandler() {
- super(SAMPLE_DISPLAY_STOP);
+ super(SAMPLE_TOPOV_DISPLAY_STOP);
}
@Override
diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovDemo.js b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovDemo.js
index 0b82d811..328380c0 100644
--- a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovDemo.js
+++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovDemo.js
@@ -26,9 +26,9 @@
var $log, fs, flash, wss;
// constants
- var displayStart = 'sampleDisplayStart',
- displayUpdate = 'sampleDisplayUpdate',
- displayStop = 'sampleDisplayStop';
+ var displayStart = 'sampleTopovDisplayStart',
+ displayUpdate = 'sampleTopovDisplayUpdate',
+ displayStop = 'sampleTopovDisplayStop';
// internal state
var currentMode = null;
diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovOverlay.js b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovOverlay.js
index 12875e1f..7ebc030a 100644
--- a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovOverlay.js
+++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovOverlay.js
@@ -13,7 +13,7 @@
// our overlay definition
var overlay = {
- // NOTE: this must match the ID defined in AppUiTopoOverlay
+ // NOTE: this must match the ID defined in AppUiTopovOverlay
overlayId: 'meowster-overlay',
glyphId: '*star4',
tooltip: 'Sample Meowster Topo Overlay',
diff --git a/framework/src/onos/tools/package/config/samples/segmentrouting.conf b/framework/src/onos/tools/package/config/samples/segmentrouting.conf
deleted file mode 100644
index 8df6c3d2..00000000
--- a/framework/src/onos/tools/package/config/samples/segmentrouting.conf
+++ /dev/null
@@ -1,78 +0,0 @@
-{
- "comment": " Multilayer topology description and configuration",
- "restrictSwitches": true,
- "restrictLinks": true,
-
- "switchConfig":
- [
- { "nodeDpid" : "of:0000000000000001", "name": "Dallas-R1", "type": "Router_SR", "allowed": true,
- "latitude": 80.80, "longitude": 90.10,
- "params": { "routerIp": "192.168.0.1/32",
- "routerMac": "00:00:01:01:01:80",
- "nodeSid": 101,
- "isEdgeRouter" : true,
- "adjacencySids": [
- { "ports": [ 4, 5 ], "adjSid": 10234 },
- { "ports": [ 6, 7 ], "adjSid": 29019 }
- ],
- "subnets": [
- { "portNo": 1, "subnetIp": "10.0.1.128/24" }
- ]
- }
- },
-
- { "nodeDpid": "of:0000000000000002", "name": "Dallas-R2", "type": "Router_SR", "allowed": true,
- "latitude": 80.80, "longitude": 90.10,
- "params": { "routerIp": "192.168.0.2/32",
- "routerMac": "00:00:02:02:02:80",
- "nodeSid": 102,
- "isEdgeRouter" : false,
- "adjacencySids": [
- { "ports": [ 1, 2 ], "adjSid": 12453 },
- { "ports": [ 2, 3 ], "adjSid": 23333 },
- { "ports": [ 3, 1 ], "adjSid": 22233 }
- ]
- }
- },
-
- { "nodeDpid": "of:0000000000000003", "name": "Dallas-R3", "type": "Router_SR", "allowed": true,
- "latitude": 80.80, "longitude": 90.10,
- "params": { "routerIp": "192.168.0.3/32",
- "routerMac": "00:00:03:03:03:80",
- "nodeSid": 103,
- "isEdgeRouter" : false
- }
- },
-
- { "nodeDpid": "of:0000000000000004", "name": "Dallas-R4", "type": "Router_SR", "allowed": true,
- "latitude": 80.80, "longitude": 90.10,
- "params": { "routerIp": "192.168.0.4/32",
- "routerMac": "00:00:04:04:04:80",
- "nodeSid": 104,
- "isEdgeRouter" : false
- }
- },
-
- { "nodeDpid": "of:0000000000000005", "name": "Dallas-R5", "type": "Router_SR", "allowed": true,
- "latitude": 80.80, "longitude": 90.10,
- "params": { "routerIp": "192.168.0.5/32",
- "routerMac": "00:00:05:05:05:80",
- "nodeSid": 105,
- "isEdgeRouter" : false
- }
- },
-
- { "nodeDpid": "of:0000000000000006", "name": "Dallas-R6", "type": "Router_SR", "allowed": true,
- "latitude": 80.80, "longitude": 90.10,
- "params": { "routerIp": "192.168.0.6/32",
- "routerMac": "00:00:07:07:07:80",
- "nodeSid": 106,
- "isEdgeRouter" : true,
- "subnets": [
- { "portNo": 1, "subnetIp": "7.7.7.128/24" }
- ]
- }
- }
-
- ]
-}
diff --git a/framework/src/onos/tools/package/debian/onos.conf b/framework/src/onos/tools/package/debian/onos.conf
deleted file mode 100644
index 634a2636..00000000
--- a/framework/src/onos/tools/package/debian/onos.conf
+++ /dev/null
@@ -1,27 +0,0 @@
-description "Open Network Operating System"
-author "ON.Lab"
-
-start on (net-device-up
- and local-filesystems
- and runlevel [2345])
-stop on runlevel [016]
-
-console output
-kill timeout 60
-respawn
-
-env LANG=en_US.UTF-8
-#env JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
-#env NEW_JAVA_HOME=/usr/lib/jvm/java-8-oracle/
-
-pre-stop script
- /opt/onos/bin/onos halt 2>>/opt/onos/var/stderr.log
- sleep 1
-end script
-
-script
- [ -f /opt/onos/options ] && . /opt/onos/options
- start-stop-daemon --signal INT --start --chuid $ONOS_USER \
- --exec /opt/onos/bin/onos-service -- $ONOS_OPTS \
- >/opt/onos/var/stdout.log 2>/opt/onos/var/stderr.log
-end script
diff --git a/framework/src/onos/tools/test/bin/onos-secure-ssh b/framework/src/onos/tools/test/bin/onos-secure-ssh
index 3c15fa3c..a3980e17 100755
--- a/framework/src/onos/tools/test/bin/onos-secure-ssh
+++ b/framework/src/onos/tools/test/bin/onos-secure-ssh
@@ -9,9 +9,6 @@
nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
for node in $nodes; do
- # Setup passwordless login for the remote user on the local bench host
- onos-user-key $node
-
# Prune the node entry from the known hosts file since server key changes
ssh-keygen -f "$HOME/.ssh/known_hosts" -R [$node]:8101
@@ -27,5 +24,10 @@ for node in $nodes; do
sleep 1
done
"
+
+ # Setup passwordless login for the remote user on the local bench host
+ # For now, we let the local public key override the remote one
+ # TODO: fix username collision between workbench and the remote hosts
+ onos-user-key $node
done
diff --git a/framework/src/onos/tools/test/scenarios/fast.xml b/framework/src/onos/tools/test/scenarios/fast.xml
new file mode 100644
index 00000000..3cfe2c60
--- /dev/null
+++ b/framework/src/onos/tools/test/scenarios/fast.xml
@@ -0,0 +1,30 @@
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<scenario name="fast" description="ONOS fast smoke test">
+ <import file="${ONOS_SCENARIOS}/prerequisites.xml"/>
+
+ <import file="${ONOS_SCENARIOS}/setup.xml"/>
+ <dependency name="Setup" requires="Prerequisites"/>
+
+ <import file="${ONOS_SCENARIOS}/net-fast.xml"/>
+ <dependency name="Net-Fast" requires="Setup"/>
+
+ <import file="${ONOS_SCENARIOS}/archetypes.xml"/>
+ <dependency name="Archetypes" requires="Setup"/>
+
+ <import file="${ONOS_SCENARIOS}/wrapup.xml"/>
+ <dependency name="Wrapup" requires="~Archetypes,~Setup,~Net-Fast"/>
+</scenario>
diff --git a/framework/src/onos/tools/test/scenarios/net-fast.xml b/framework/src/onos/tools/test/scenarios/net-fast.xml
new file mode 100644
index 00000000..359c0082
--- /dev/null
+++ b/framework/src/onos/tools/test/scenarios/net-fast.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<scenario name="net-fast" description="Basic network functionality fast test">
+ <group name="Net-Fast">
+ <import file="${ONOS_SCENARIOS}/net-setup.xml"/>
+
+ <import file="${ONOS_SCENARIOS}/net-pingall.xml" namespace="Reactive-Forwarding"/>
+ <dependency name="Reactive-Forwarding.Net-Pingall" requires="Net-Setup"/>
+
+ <import file="${ONOS_SCENARIOS}/net-link-down-up.xml" namespace="Reactive-Forwarding"/>
+ <dependency name="Reactive-Forwarding.Net-Link-Down-Up" requires="Net-Setup,~Reactive-Forwarding.Net-Pingall"/>
+
+ <import file="${ONOS_SCENARIOS}/net-teardown.xml"/>
+ <dependency name="Net-Teardown" requires="~Reactive-Forwarding.Net-Link-Down-Up"/>
+ </group>
+</scenario>
diff --git a/framework/src/onos/tools/test/scenarios/net-pingall.xml b/framework/src/onos/tools/test/scenarios/net-pingall.xml
index 87c13227..100cebac 100644
--- a/framework/src/onos/tools/test/scenarios/net-pingall.xml
+++ b/framework/src/onos/tools/test/scenarios/net-pingall.xml
@@ -22,7 +22,7 @@
exec="onos-check-apps ${OC1} drivers,openflow,proxyarp,fwd includes"/>
<!-- TODO: take this out when initial pingall sweep is 100% -->
- <step name="Initial-Ping-All" requires="Check-Apps"
+ <step name="Initial-Ping-All" requires="Check-Apps" unless="${ONOS_RF_BUG_FIXED}"
exec="onos-mininet sendAndExpect py net.pingAll(1) --expect received"/>
<step name="Ping-All-And-Verify" requires="Check-Apps,Initial-Ping-All"
diff --git a/framework/src/onos/tools/test/scenarios/net-smoke.xml b/framework/src/onos/tools/test/scenarios/net-smoke.xml
index 91131c62..037b6f00 100644
--- a/framework/src/onos/tools/test/scenarios/net-smoke.xml
+++ b/framework/src/onos/tools/test/scenarios/net-smoke.xml
@@ -36,13 +36,13 @@
<dependency name="Net-Create-Flows" requires="Net-Setup,P2P-Intent-Connectivity,Net-REST"/>
<import file="${ONOS_SCENARIOS}/net-topo.xml"/>
- <dependency name="Net-topo" requires="Net-Setup,Net-Create-Flows"/>
+ <dependency name="Net-Topo" requires="Net-Setup,Net-Create-Flows"/>
<import file="${ONOS_SCENARIOS}/net-teardown.xml"/>
<dependency name="Net-Teardown" requires="~Host-Intent-Connectivity,
~P2P-Intent-Connectivity,
~Net-REST,
~Net-Create-Flows,
- ~Net-topo"/>
+ ~Net-Topo"/>
</group>
</scenario>
diff --git a/framework/src/onos/tools/test/scenarios/net-topo.xml b/framework/src/onos/tools/test/scenarios/net-topo.xml
index e8e23997..abcf8642 100644
--- a/framework/src/onos/tools/test/scenarios/net-topo.xml
+++ b/framework/src/onos/tools/test/scenarios/net-topo.xml
@@ -16,60 +16,60 @@
<scenario name="net-topo"
description="Network topology test">
<!-- TODO: parametrize this via recipes -->
- <group name="Net-topo">
+ <group name="Net-Topo">
<!-- Verify the overall topology using the REST API -->
- <step name="Net-topo.Query-Topo"
+ <step name="Net-Topo.Query-Topo"
exec="query-topo.py ${OC1} topo"/>
- <step name="Net-topo.Verify-Topo-Devices" requires="Net-topo.Query-Topo"
+ <step name="Net-Topo.Verify-Topo-Devices" requires="Net-Topo.Query-Topo"
exec="test ${topoDevices} == 25"/>
- <step name="Net-topo.Verify-Topo-Links" requires="Net-topo.Query-Topo"
+ <step name="Net-Topo.Verify-Topo-Links" requires="Net-Topo.Query-Topo"
exec="test ${topoLinks} == 140"/>
- <step name="Net-topo.Verify-Topo-Clusters" requires="Net-topo.Query-Topo"
+ <step name="Net-Topo.Verify-Topo-Clusters" requires="Net-Topo.Query-Topo"
exec="test ${topoClusters} == 1"/>
<!-- Verify the cluster topology using the REST API -->
- <step name="Net-topo.Query-Cluster0"
+ <step name="Net-Topo.Query-Cluster0"
exec="query-cluster.py ${OC1} clusterTopo0 0"/>
- <step name="Net-topo.Verify-Cluster0-Id" requires="Net-topo.Query-Cluster0"
+ <step name="Net-Topo.Verify-Cluster0-Id" requires="Net-Topo.Query-Cluster0"
exec="test ${clusterTopo0Id} == 0"/>
- <step name="Net-topo.Verify-Cluster0-DeviceCount" requires="Net-topo.Query-Cluster0"
+ <step name="Net-Topo.Verify-Cluster0-DeviceCount" requires="Net-Topo.Query-Cluster0"
exec="test ${clusterTopo0DeviceCount} == 25"/>
- <step name="Net-topo.Verify-Cluster0-LinkCount" requires="Net-topo.Query-Cluster0"
+ <step name="Net-Topo.Verify-Cluster0-LinkCount" requires="Net-Topo.Query-Cluster0"
exec="test ${clusterTopo0LinkCount} == 140"/>
- <step name="Net-topo.Verify-Cluster0-Root" requires="Net-topo.Query-Cluster0"
+ <step name="Net-Topo.Verify-Cluster0-Root" requires="Net-Topo.Query-Cluster0"
exec="test '${clusterTopo0Root}' == 'of:000000000000000a'"/>
<!-- Verify the list of devices for the cluster -->
- <step name="Net-topo.Verify-Cluster0-Devices"
+ <step name="Net-Topo.Verify-Cluster0-Devices"
exec="verify-topo-devices.py ${OC1} 0 0 24"/>
<!-- Spot check some known links in the topology -->
- <step name="Net-topo.Verify-Cluster0-Link1"
+ <step name="Net-Topo.Verify-Cluster0-Link1"
exec="find-link-in-cluster.py ${OC1} link1 0 140 of:000000000000000f 8 of:0000000000000015 3"/>
- <step name="Net-topo.Verify-Cluster0-Link2"
+ <step name="Net-Topo.Verify-Cluster0-Link2"
exec="find-link-in-cluster.py ${OC1} link2 0 140 of:0000000000000008 3 of:0000000000000005 4"/>
- <step name="Net-topo.Verify-Cluster0-Link3"
+ <step name="Net-Topo.Verify-Cluster0-Link3"
exec="find-link-in-cluster.py ${OC1} link3 0 140 of:0000000000000011 2 of:0000000000000002 9"/>
- <step name="Net-topo.Verify-Cluster0-Link4"
+ <step name="Net-Topo.Verify-Cluster0-Link4"
exec="find-link-in-cluster.py ${OC1} link4 0 140 of:000000000000000f 3 of:000000000000000d 10"/>
- <step name="Net-topo.Verify-Cluster0-Link5"
+ <step name="Net-Topo.Verify-Cluster0-Link5"
exec="find-link-in-cluster.py ${OC1} link5 0 140 of:000000000000000d 13 of:0000000000000010 6"/>
<!-- Verify the topology infrastructure query -->
- <step name="Net-topo.Query-Cluster0-Infra1"
+ <step name="Net-Topo.Query-Cluster0-Infra1"
exec="find-topo-infrastructure.py ${OC1} infra1 of:000000000000000f:8"/>
- <step name="Net-topo.Verify-Cluster0-Infra1" requires="Net-topo.Query-Cluster0-Infra1"
+ <step name="Net-Topo.Verify-Cluster0-Infra1" requires="Net-Topo.Query-Cluster0-Infra1"
exec="test '${infra1Infrastructure}' == 'True'"/>
- <step name="Net-topo.Query-Cluster0-Infra2"
+ <step name="Net-Topo.Query-Cluster0-Infra2"
exec="find-topo-infrastructure.py ${OC1} infra2 of:000000000000000d:8"/>
- <step name="Net-topo.Verify-Cluster0-Infra2" requires="Net-topo.Query-Cluster0-Infra2"
+ <step name="Net-Topo.Verify-Cluster0-Infra2" requires="Net-Topo.Query-Cluster0-Infra2"
exec="test '${infra2Infrastructure}' == 'True'"/>
- <step name="Net-topo.Query-Cluster0-Infra3"
+ <step name="Net-Topo.Query-Cluster0-Infra3"
exec="find-topo-infrastructure.py ${OC1} infra3 of:0000000000000012:8"/>
- <step name="Net-topo.Verify-Cluster0-Infra3" requires="Net-topo.Query-Cluster0-Infra3"
+ <step name="Net-Topo.Verify-Cluster0-Infra3" requires="Net-Topo.Query-Cluster0-Infra3"
exec="test '${infra3Infrastructure}' == 'False'"/>
</group>
diff --git a/framework/src/onos/tools/test/scenarios/prerequisites.xml b/framework/src/onos/tools/test/scenarios/prerequisites.xml
index 2c541d5b..5690fc4a 100644
--- a/framework/src/onos/tools/test/scenarios/prerequisites.xml
+++ b/framework/src/onos/tools/test/scenarios/prerequisites.xml
@@ -20,7 +20,7 @@
<parallel var="${OC#}">
<step name="Check-Passwordless-Login-${#}"
- exec="ssh -n -o ConnectTimeout=3 -o PasswordAuthentication=no sdn@${OC#} date"/>
+ exec="ssh -n -o ConnectTimeout=3 -o PasswordAuthentication=no ${ONOS_USER}@${OC#} date"/>
</parallel>
</group>
</scenario>
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IGMP.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IGMP.java
index e7abbd6a..254f1325 100644
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IGMP.java
+++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/IGMP.java
@@ -231,7 +231,7 @@ public class IGMP extends BasePacket {
IGMP igmp = new IGMP();
- ByteBuffer bb = ByteBuffer.wrap(data);
+ final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
igmp.igmpType = bb.get();
igmp.resField = bb.get();
igmp.checksum = bb.getShort();
diff --git a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java
index c2a0c812..add71eb5 100644
--- a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java
+++ b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java
@@ -42,7 +42,7 @@ import static org.onlab.stc.Scenario.loadScenario;
*/
public class Compiler {
- private static final String DEFAULT_LOG_DIR = "${env.WORKSPACE}/tmp/stc/";
+ private static final String DEFAULT_LOG_DIR = "${WORKSPACE}/tmp/stc/";
private static final String IMPORT = "import";
private static final String GROUP = "group";
diff --git a/framework/src/onos/web/gui/src/main/webapp/app/fw/widget/button.js b/framework/src/onos/web/gui/src/main/webapp/app/fw/widget/button.js
index 09cdd43a..2ef5b4b0 100644
--- a/framework/src/onos/web/gui/src/main/webapp/app/fw/widget/button.js
+++ b/framework/src/onos/web/gui/src/main/webapp/app/fw/widget/button.js
@@ -224,7 +224,9 @@
} else {
if (x >= 0 && x < rads.length) {
if (currIdx !== x) {
+ rads[currIdx].el.classed('selected', false);
currIdx = x;
+ rads[currIdx].el.classed('selected', true);
invokeCurrent();
} else {
$log.warn('current index already selected:', x);
diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js
index 42b6f4bd..0dfd6281 100644
--- a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js
+++ b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js
@@ -525,6 +525,7 @@
// temporary solution for persisting user settings
restoreConfigFromPrefs();
+ ttbs.setDefaultOverlay();
$log.debug('registered overlays...', tov.list());
$log.log('OvTopoCtrl has been created');
diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoOverlay.js b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoOverlay.js
index 7eb45ba4..74fa2f24 100644
--- a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoOverlay.js
+++ b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoOverlay.js
@@ -107,34 +107,17 @@
$log.debug(tos + 'registered overlay: ' + id, overlay);
}
- // TODO: remove this redundant code.......
- // NOTE: unregister needs to be called if an app is ever
- // deactivated/uninstalled via the applications view
-/*
- function unregister(overlay) {
- var u = 'unregister',
- over = fs.isO(overlay),
- id = over ? over.overlayId : '';
-
- if (!id) {
- return error(u, 'not a recognized overlay');
- }
- if (!overlays[id]) {
- return warn(u, 'not registered: "' + id + "'")
- }
- delete overlays[id];
- $log.debug(tos + 'unregistered overlay: ' + id);
- }
-*/
-
-
// returns the list of overlay identifiers
function list() {
return d3.map(overlays).keys();
}
// add a radio button for each registered overlay
+ // return an overlay id to index map
function augmentRbset(rset, switchFn) {
+ var map = {},
+ idx = 1;
+
angular.forEach(overlays, function (ov) {
rset.push({
gid: ov._glyphId,
@@ -143,7 +126,9 @@
tbSelection(ov.overlayId, switchFn);
}
});
+ map[ov.overlayId] = idx++;
});
+ return map;
}
// an overlay was selected via toolbar radio button press from user
@@ -394,7 +379,6 @@
return {
register: register,
- //unregister: unregister,
setApi: setApi,
list: list,
augmentRbset: augmentRbset,
diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
index 84de261b..3928cd21 100644
--- a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
+++ b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
@@ -30,13 +30,14 @@
// setUpKeys
// internal state
- var toolbar, keyData, cachedState, thirdRow;
+ var toolbar, keyData, cachedState, thirdRow, ovRset, ovIndex;
// constants
var name = 'topo-tbar',
cooktag = 'topo_prefs',
soa = 'switchOverlayActions: ',
- selOver = 'Select overlay here &#x21e7;';
+ selOver = 'Select overlay here &#x21e7;',
+ defaultOverlay = 'traffic';
// key to button mapping data
@@ -172,8 +173,8 @@
tov.tbSelection(null, switchOverlayActions);
}
}];
- tov.augmentRbset(rset, switchOverlayActions);
- toolbar.addRadioSet('topo-overlays', rset);
+ ovIndex = tov.augmentRbset(rset, switchOverlayActions);
+ ovRset = toolbar.addRadioSet('topo-overlays', rset);
}
// invoked by overlay service to switch out old buttons and switch in new
@@ -261,6 +262,11 @@
toolbar.toggle();
}
+ function setDefaultOverlay() {
+ var idx = ovIndex[defaultOverlay] || 0;
+ ovRset.selectedIndex(idx);
+ }
+
angular.module('ovTopo')
.factory('TopoToolbarService',
['$log', 'FnService', 'ToolbarService', 'PrefsService',
@@ -278,7 +284,8 @@
createToolbar: createToolbar,
destroyToolbar: destroyToolbar,
keyListener: keyListener,
- toggleToolbar: toggleToolbar
+ toggleToolbar: toggleToolbar,
+ setDefaultOverlay: setDefaultOverlay
};
}]);
}()); \ No newline at end of file