</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <excludes>org/opendaylight/yang/gen/**,**/yang/**</excludes>
+ <consoleOutput>true</consoleOutput>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.UniqueId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.IpPrefixType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.rev160427.ContextType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.GbpByNeutronMappings;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.NeutronByGbpMappings;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.BaseEndpointsByPorts;
public class NeutronGbpIidFactory {
public static InstanceIdentifier<BaseEndpointByPort> baseEndpointByPortIid(UniqueId portId) {
- return InstanceIdentifier.builder(
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+ return InstanceIdentifier.builder(Mappings.class)
.child(GbpByNeutronMappings.class)
.child(BaseEndpointsByPorts.class)
.child(BaseEndpointByPort.class, new BaseEndpointByPortKey(portId))
@Deprecated
public static InstanceIdentifier<EndpointByPort> endpointByPortIid(UniqueId portId) {
return InstanceIdentifier
- .builder(
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+ .builder(Mappings.class)
.child(GbpByNeutronMappings.class)
.child(EndpointsByPorts.class)
.child(EndpointByPort.class, new EndpointByPortKey(portId))
}
public static InstanceIdentifier<PortByBaseEndpoint> portByBaseEndpointIid(PortByBaseEndpointKey baseEpkey) {
- return InstanceIdentifier.builder(
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+ return InstanceIdentifier.builder(Mappings.class)
.child(NeutronByGbpMappings.class)
.child(PortsByBaseEndpoints.class)
.child(PortByBaseEndpoint.class, baseEpkey)
@Deprecated
public static InstanceIdentifier<PortByEndpoint> portByEndpointIid(L2BridgeDomainId l2BdId, MacAddress mac) {
return InstanceIdentifier
- .builder(
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+ .builder(Mappings.class)
.child(NeutronByGbpMappings.class)
.child(PortsByEndpoints.class)
.child(PortByEndpoint.class, new PortByEndpointKey(l2BdId, mac))
IpPrefixType.class,
contextId,
contextType);
- return InstanceIdentifier.builder(
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+ return InstanceIdentifier.builder(Mappings.class)
.child(NeutronByGbpMappings.class)
.child(ExternalGatewaysAsEndpoints.class)
.child(ExternalGatewayAsEndpoint.class, key)
public static InstanceIdentifier<ExternalGatewayAsL3Endpoint> externalGatewayAsL3Endpoint(L3ContextId l3Context,
IpAddress ipAddress) {
return InstanceIdentifier
- .builder(
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+ .builder(Mappings.class)
.child(NeutronByGbpMappings.class)
.child(ExternalGatewaysAsL3Endpoints.class)
.child(ExternalGatewayAsL3Endpoint.class, new ExternalGatewayAsL3EndpointKey(ipAddress, l3Context))
public static InstanceIdentifier<ProviderPhysicalNetworkAsL2FloodDomain> providerPhysicalNetworkAsL2FloodDomainIid(
TenantId tenantId, ContextId domainId) {
- return InstanceIdentifier.builder(
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+ return InstanceIdentifier.builder(Mappings.class)
.child(NeutronByGbpMappings.class)
.child(ProviderNetworksAsL2FloodDomains.class)
.child(ProviderPhysicalNetworkAsL2FloodDomain.class,
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomain> providerPhysicalNetworkAsL2FloodDomainIid(
TenantId tenantId, L2FloodDomainId l2FdId) {
- return InstanceIdentifier.builder(
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.Mappings.class)
+ return InstanceIdentifier.builder(Mappings.class)
.child(NeutronByGbpMappings.class)
.child(ProviderPhysicalNetworksAsL2FloodDomains.class)
.child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomain.class,
package org.opendaylight.groupbasedpolicy.neutron.mapper;
-import javax.annotation.Nullable;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
+
+import javax.annotation.Nullable;
+
import org.opendaylight.groupbasedpolicy.neutron.mapper.util.MappingUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
}
}
- public boolean unregisterEndpoint(AddressEndpointUnreg addrEpUnreg) {
- UnregisterEndpointInput input = new UnregisterEndpointInputBuilder().setAddressEndpointUnreg(
- ImmutableList.<AddressEndpointUnreg>of(new AddressEndpointUnregBuilder().setKey(addrEpUnreg.getKey())
- .build())).build();
- return unregisterEndpoint(input);
- }
-
- public boolean unregisterEndpoint(UnregisterEndpointInput input) {
+ @Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
+ public boolean registerEndpoint(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput regEndpointInput) {
try {
- RpcResult<Void> rpcResult = baseEpService.unregisterEndpoint(input).get();
+ RpcResult<Void> rpcResult = epService.registerEndpoint(regEndpointInput).get();
if (!rpcResult.isSuccessful()) {
- LOG.warn("Illegal state - unregisterEndpoint was not successful. Input of RPC: {}", input);
+ LOG.warn("Illegal state - register Endpoint was not successful. Input of RPC: {}", regEndpointInput);
return false;
}
return true;
} catch (InterruptedException | ExecutionException e) {
- LOG.error("unregisterEndpoint failed. {}", input, e);
+ LOG.error("registerEndpoint failed. {}", regEndpointInput, e);
return false;
}
}
- @Deprecated
- public boolean registerEndpoint(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput regEndpointInput) {
+ public boolean unregisterEndpoint(AddressEndpointUnreg addrEpUnreg) {
+ UnregisterEndpointInput input = new UnregisterEndpointInputBuilder().setAddressEndpointUnreg(
+ ImmutableList.<AddressEndpointUnreg>of(new AddressEndpointUnregBuilder().setKey(addrEpUnreg.getKey())
+ .build())).build();
+ return unregisterEndpoint(input);
+ }
+
+ public boolean unregisterEndpoint(UnregisterEndpointInput input) {
try {
- RpcResult<Void> rpcResult = epService.registerEndpoint(regEndpointInput).get();
+ RpcResult<Void> rpcResult = baseEpService.unregisterEndpoint(input).get();
if (!rpcResult.isSuccessful()) {
- LOG.warn("Illegal state - register Endpoint was not successful. Input of RPC: {}", regEndpointInput);
+ LOG.warn("Illegal state - unregisterEndpoint was not successful. Input of RPC: {}", input);
return false;
}
return true;
} catch (InterruptedException | ExecutionException e) {
- LOG.error("registerEndpoint failed. {}", regEndpointInput, e);
+ LOG.error("unregisterEndpoint failed. {}", input, e);
return false;
}
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public boolean unregisterEndpoint(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregEndpointInput) {
try {
RpcResult<Void> rpcResult = epService.unregisterEndpoint(unregEndpointInput).get();
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public boolean registerL3EpAsExternalGateway(TenantId tenantId, IpAddress ipAddress, L3ContextId l3Context,
NetworkDomainId networkContainment) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput registerEndpointInput =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder()
- .setL3Address(ImmutableList
- .of(new L3AddressBuilder().setL3Context(l3Context).setIpAddress(ipAddress).build()))
- .setTenant(tenantId)
- .setNetworkContainment(networkContainment)
- .setEndpointGroups(ImmutableList.of(MappingUtils.EPG_EXTERNAL_ID))
- .setTimestamp(System.currentTimeMillis())
- .build();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput
+ registerEndpointInput =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder()
+ .setL3Address(
+ ImmutableList.of(new L3AddressBuilder().setL3Context(l3Context).setIpAddress(ipAddress).build()))
+ .setTenant(tenantId)
+ .setNetworkContainment(networkContainment)
+ .setEndpointGroups(ImmutableList.of(MappingUtils.EPG_EXTERNAL_ID))
+ .setTimestamp(System.currentTimeMillis())
+ .build();
try {
RpcResult<Void> rpcResult = epService.registerEndpoint(registerEndpointInput).get();
if (!rpcResult.isSuccessful()) {
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public boolean unregisterL3EpAsExternalGateway(IpAddress ipAddress, L3ContextId l3Context) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregisterEndpointInput =
+ org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput
+ unregisterEndpointInput =
new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInputBuilder()
- .setL3(ImmutableList.of(new L3Builder().setL3Context(l3Context)
- .setIpAddress(ipAddress)
- .build()))
+ .setL3(ImmutableList.of(new L3Builder().setL3Context(l3Context).setIpAddress(ipAddress).build()))
.build();
try {
*/
package org.opendaylight.groupbasedpolicy.neutron.mapper;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.PeekingIterator;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.PeekingIterator;
-
public class NeutronMapper implements ClusteredDataTreeChangeListener<Neutron>, AutoCloseable {
- private static final String EXC_MSG_UNKNOWN_MODIFICATION_TYPE_WITHIN_DATA = "Unknown modification type within data ";
+ private static final String EXC_MSG_UNKNOWN_MODIFICATION_TYPE_IN_DATA = "Unknown modification type within data ";
- private final static SecurityRuleBuilder EIG_INGRESS_IPV4_SEC_RULE_BUILDER = new SecurityRuleBuilder()
+ private static final SecurityRuleBuilder EIG_INGRESS_IPV4_SEC_RULE_BUILDER = new SecurityRuleBuilder()
.setUuid(new Uuid("0a629f80-2408-11e6-b67b-9e71128cae77"))
.setDirection(DirectionIngress.class)
.setEthertype(EthertypeV4.class)
.setSecurityGroupId(MappingUtils.EIG_UUID);
- private final static SecurityRuleBuilder EIG_EGRESS_IPV4_SEC_RULE_BUILDER = new SecurityRuleBuilder()
+ private static final SecurityRuleBuilder EIG_EGRESS_IPV4_SEC_RULE_BUILDER = new SecurityRuleBuilder()
.setUuid(new Uuid("0f1789be-2408-11e6-b67b-9e71128cae77"))
.setDirection(DirectionEgress.class)
.setEthertype(EthertypeV4.class)
.setSecurityGroupId(MappingUtils.EIG_UUID);
- private final static SecurityRuleBuilder EIG_INGRESS_IPV6_SEC_RULE_BUILDER = new SecurityRuleBuilder()
+ private static final SecurityRuleBuilder EIG_INGRESS_IPV6_SEC_RULE_BUILDER = new SecurityRuleBuilder()
.setUuid(new Uuid("139b7f90-2408-11e6-b67b-9e71128cae77"))
.setDirection(DirectionIngress.class)
.setEthertype(EthertypeV6.class)
.setSecurityGroupId(MappingUtils.EIG_UUID);
- private final static SecurityRuleBuilder EIG_EGRESS_IPV6_SEC_RULE_BUILDER = new SecurityRuleBuilder()
+ private static final SecurityRuleBuilder EIG_EGRESS_IPV6_SEC_RULE_BUILDER = new SecurityRuleBuilder()
.setUuid(new Uuid("17517202-2408-11e6-b67b-9e71128cae77"))
.setDirection(DirectionEgress.class)
.setEthertype(EthertypeV6.class)
.setSecurityGroupId(MappingUtils.EIG_UUID);
- private final static SecurityGroupBuilder EIG_SEC_GROUP_BUILDER =
+ private static final SecurityGroupBuilder EIG_SEC_GROUP_BUILDER =
new SecurityGroupBuilder().setUuid(MappingUtils.EIG_UUID);
private final NeutronNetworkAware networkAware;
findModifiedData(NeutronSecurityRuleAware.SECURITY_RULE_WILDCARD_IID, neutronModif);
onDataObjectModification(secRuleModifs, securityRuleAware);
// subnet
- List<DataObjectModification<Subnet>> subnetModifs = findModifiedData(NeutronSubnetAware.SUBNET_WILDCARD_IID, neutronModif);
+ List<DataObjectModification<Subnet>> subnetModifs =
+ findModifiedData(NeutronSubnetAware.SUBNET_WILDCARD_IID, neutronModif);
onDataObjectModification(subnetModifs, subnetAware);
// port
- List<DataObjectModification<Port>> portModifs = findModifiedData(NeutronPortAware.PORT_WILDCARD_IID, neutronModif);
+ List<DataObjectModification<Port>> portModifs =
+ findModifiedData(NeutronPortAware.PORT_WILDCARD_IID, neutronModif);
onDataObjectModification(portModifs, portAware);
// router
- List<DataObjectModification<Router>> routerModifs = findModifiedData(NeutronRouterAware.ROUTER_WILDCARD_IID, neutronModif);
+ List<DataObjectModification<Router>> routerModifs =
+ findModifiedData(NeutronRouterAware.ROUTER_WILDCARD_IID, neutronModif);
onDataObjectModification(routerModifs, routerAware);
// floating IP
- List<DataObjectModification<Floatingip>> floatingIpModifs = findModifiedData(NeutronFloatingIpAware.FLOATING_IP_WILDCARD_IID, neutronModif);
+ List<DataObjectModification<Floatingip>> floatingIpModifs =
+ findModifiedData(NeutronFloatingIpAware.FLOATING_IP_WILDCARD_IID, neutronModif);
onDataObjectModification(floatingIpModifs, floatingIpAware);
}
}
final T dataAfter = dataModif.getDataAfter();
if (dataBefore == null && dataAfter != null) {
neutronAware.onCreated(dataAfter, neutronAfter);
- }
- else if (dataBefore != null && dataAfter != null) {
+ } else if (dataBefore != null && dataAfter != null) {
neutronAware.onUpdated(dataBefore, dataAfter, neutronBefore, neutronAfter);
- }
- else if (dataBefore != null) {
+ } else if (dataBefore != null) {
neutronAware.onDeleted(dataBefore, neutronBefore, neutronAfter);
- }
- else {
- throw new IllegalStateException(EXC_MSG_UNKNOWN_MODIFICATION_TYPE_WITHIN_DATA + dataModif);
+ } else {
+ throw new IllegalStateException(EXC_MSG_UNKNOWN_MODIFICATION_TYPE_IN_DATA + dataModif);
}
}
}
/**
* Finds all modified subnodes of given type in {@link Neutron} node.
*
- * @param <T>
+ * @param <T> dataObject type
* @param iid path to data in root node
* @param rootNode modified data of {@link Neutron} node
* @return {@link List} of modified subnodes
package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
+import com.google.common.collect.ImmutableList;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
-import com.google.common.collect.ImmutableList;
-
public class MetadataService extends ServiceUtil {
private static final ClassifierName METADATA_SERVER_TO_CLIENT_NAME =
new Description("Allow METADATA management communication between server and client.");
/**
- * Id of {@link #METADATA_CONTRACT}
+ * Id of {@link #METADATA_CONTRACT}.
*/
public static final ContractId METADATA_CONTRACT_ID = new ContractId("be0675b7-b0d6-46cc-acf1-247ed31cf572");
/**
- * Contains rules with action {@link MappingUtils#ACTION_REF_ALLOW} matching ICMP and SSH
- * communication
+ * Contains rules with action {@link MappingUtils#ACTION_REF_ALLOW} matching ICMP and SSH communication
* between Client and Server.
*/
public static final Contract METADATA_CONTRACT;
/**
- * {@link ConsumerNamedSelector} pointing to {@link #METADATA_CONTRACT}
+ * {@link ConsumerNamedSelector} pointing to {@link #METADATA_CONTRACT}.
*/
public static final ConsumerNamedSelector METADATA_CONTRACT_CONSUMER_SELECTOR;
private static final Name METADATA_SERVICE_EPG_NAME = new Name("NETWORK_SERVICE");
private static final Description METADATA_SERVICE_EPG_DESC = new Description("Represents DHCP and DNS servers.");
/**
- * ID of {@link #EPG}
+ * ID of {@link #EPG}.
*/
public static final EndpointGroupId EPG_ID = new EndpointGroupId("ffff1111-dfe5-11e4-8a00-1681e6b88ec1");
/**
- * Network-service endpoint-group providing {@link #METADATA_CONTRACT}
+ * Network-service endpoint-group providing {@link #METADATA_CONTRACT}.
*/
public static final EndpointGroup EPG;
*
* @param tenantId location of {@link #METADATA_CONTRACT}
* @param ipPrefix used in {@link L3EndpointIdentificationConstraints}
- * @param wTx transaction where entities are written
+ * @param writeTx transaction where entities are written
*/
public static void writeMetadataClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
Clause clause = createClauseWithConsProvEic(ipPrefix, METADATA_SUBJECT_NAME);
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, METADATA_CONTRACT_ID, clause.getName()),
- clause, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, METADATA_CONTRACT_ID,
+ clause.getName()), clause, true);
}
/**
* Puts network service entities (classifier-instances, {@link #METADATA_CONTRACT},
- * and {@link #EPG}) to {@link LogicalDatastoreType#CONFIGURATION}
+ * and {@link #EPG}) to {@link LogicalDatastoreType#CONFIGURATION}.
*
* @param tenantId location of network-service entities
- * @param wTx transaction where network-service entities are written
+ * @param writeTx transaction where network-service entities are written
+ * @param metadataPort port for metadata
*/
- public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction wTx, long metadataPort) {
+ public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx,
+ long metadataPort) {
+
Set<ClassifierInstance> classifierInstances = getAllClassifierInstances(metadataPort);
for (ClassifierInstance ci : classifierInstances) {
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci,
- true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()),
+ ci, true);
}
for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) {
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true);
- }
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, METADATA_CONTRACT_ID), METADATA_CONTRACT,
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai,
true);
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
+ }
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, METADATA_CONTRACT_ID),
+ METADATA_CONTRACT, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
}
/**
+ * Used to get all classifier-instances used in {@link #METADATA_CONTRACT} for specified port.
+ *
+ * @param metadataPort port for metadata
* @return All classifier-instances used in {@link #METADATA_CONTRACT}
*/
public static Set<ClassifierInstance> getAllClassifierInstances(long metadataPort) {
package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
+import com.google.common.base.Preconditions;
+
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.groupbasedpolicy.util.IidFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelector;
-import com.google.common.base.Preconditions;
-
public class NetworkClient extends ServiceUtil {
private static final Name NETWORK_CLIENT_EPG_NAME = new Name("NETWORK_CLIENT");
private static final Description NETWORK_CLIENT_EPG_DESC = new Description("Represents DHCP and DNS clients.");
/**
- * ID of {@link #EPG}
+ * ID of {@link #EPG}.
*/
public static final EndpointGroupId EPG_ID = new EndpointGroupId("ccc5e444-573c-11e5-885d-feff819cdc9f");
/**
- * Network-client endpoint-group consuming no contract
+ * Network-client endpoint-group consuming no contract.
*/
public static final EndpointGroup EPG;
}
/**
- * Puts {@link #EPG} to {@link LogicalDatastoreType#CONFIGURATION}
+ * Puts {@link #EPG} to {@link LogicalDatastoreType#CONFIGURATION}.
*
* @param tenantId location of {@link #EPG}
- * @param wTx transaction where {@link #EPG} is written
+ * @param writeTx transaction where {@link #EPG} is written
*/
- public static void writeNetworkClientEntitiesToTenant(TenantId tenantId, WriteTransaction wTx) {
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
+ public static void writeNetworkClientEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) {
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
}
/**
- * Puts consumer-named-selector to {@link #EPG} in {@link LogicalDatastoreType#CONFIGURATION}
+ * Puts consumer-named-selector to {@link #EPG} in {@link LogicalDatastoreType#CONFIGURATION}.
*
* @param tenantId tenantId location of {@link #EPG}
* @param consumerNamedSelector is added to {@link #EPG}
- * @param wTx transaction where the given consumer-named-selector is written
+ * @param writeTx transaction where the given consumer-named-selector is written
*/
public static void writeConsumerNamedSelector(TenantId tenantId, ConsumerNamedSelector consumerNamedSelector,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
Preconditions.checkNotNull(consumerNamedSelector);
- wTx.put(LogicalDatastoreType.CONFIGURATION,
+ writeTx.put(LogicalDatastoreType.CONFIGURATION,
IidFactory.consumerNamedSelectorIid(tenantId, EPG_ID, consumerNamedSelector.getName()),
consumerNamedSelector, true);
}
package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
+import com.google.common.collect.ImmutableList;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
-import com.google.common.collect.ImmutableList;
-
public class NetworkService extends ServiceUtil {
/**
- * Unit tests {@link NetworkServiceTest}
+ * Unit tests {@link NetworkServiceTest}.
*/
// ########### DHCP
private static final long DHCP_IPV4_SERVER_PORT = 67;
new Description("Allow DHCP communication between client and server.");
/**
- * Id of {@link #DHCP_CONTRACT}
+ * Id of {@link #DHCP_CONTRACT}.
*/
public static final ContractId DHCP_CONTRACT_ID = new ContractId("11118d2e-dddd-11e5-885d-feff819cdc9f");
/**
*/
public static final Contract DHCP_CONTRACT;
/**
- * {@link ConsumerNamedSelector} pointing to {@link #DHCP_CONTRACT}
+ * {@link ConsumerNamedSelector} pointing to {@link #DHCP_CONTRACT}.
*/
public static final ConsumerNamedSelector DHCP_CONTRACT_CONSUMER_SELECTOR;
private static final Description DNS_CONTRACT_DESC =
new Description("Allow DNS communication between client and server.");
/**
- * ID of {@link #DNS_CONTRACT}
+ * ID of {@link #DNS_CONTRACT}.
*/
public static final ContractId DNS_CONTRACT_ID = new ContractId("22218d2e-dddd-11e5-885d-feff819cdc9f");
/**
*/
public static final Contract DNS_CONTRACT;
/**
- * {@link ConsumerNamedSelector} pointing to {@link #DNS_CONTRACT}
+ * {@link ConsumerNamedSelector} pointing to {@link #DNS_CONTRACT}.
*/
public static final ConsumerNamedSelector DNS_CONTRACT_CONSUMER_SELECTOR;
new Description("Allow ICMP and SSH management communication between server and client.");
/**
- * Id of {@link #MGMT_CONTRACT}
+ * Id of {@link #MGMT_CONTRACT}.
*/
public static final ContractId MGMT_CONTRACT_ID = new ContractId("33318d2e-dddd-11e5-885d-feff819cdc9f");
/**
- * Contains rules with action {@link MappingUtils#ACTION_REF_ALLOW} matching ICMP and SSH
- * communication
+ * Contains rules with action {@link MappingUtils#ACTION_REF_ALLOW} matching ICMP and SSH communication
* between Client and Server.
*/
public static final Contract MGMT_CONTRACT;
/**
- * {@link ConsumerNamedSelector} pointing to {@link #MGMT_CONTRACT}
+ * {@link ConsumerNamedSelector} pointing to {@link #MGMT_CONTRACT}.
*/
public static final ConsumerNamedSelector MGMT_CONTRACT_CONSUMER_SELECTOR;
private static final Name NETWORK_SERVICE_EPG_NAME = new Name("NETWORK_SERVICE");
private static final Description NETWORK_SERVICE_EPG_DESC = new Description("Represents DHCP and DNS servers.");
/**
- * ID of {@link #EPG}
+ * ID of {@link #EPG}.
*/
public static final EndpointGroupId EPG_ID = new EndpointGroupId("ddd6cfe6-dfe5-11e4-8a00-1681e6b88ec1");
/**
- * Network-service endpoint-group providing {@link #DHCP_CONTRACT} and {@link #DNS_CONTRACT}
+ * Network-service endpoint-group providing {@link #DHCP_CONTRACT} and {@link #DNS_CONTRACT}.
*/
public static final EndpointGroup EPG;
*
* @param tenantId location of {@link #DHCP_CONTRACT}
* @param ipPrefix used in {@link L3EndpointIdentificationConstraints}
- * @param wTx transaction where entities are written
+ * @param writeTx transaction where entities are written
*/
public static void writeDhcpClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
Clause clause = createClauseWithConsProvEic(ipPrefix, DHCP_SUBJECT_NAME);
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, DHCP_CONTRACT_ID, clause.getName()),
- clause, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, DHCP_CONTRACT_ID,
+ clause.getName()), clause, true);
}
/**
*
* @param tenantId location of {@link #DNS_CONTRACT}
* @param ipPrefix used in {@link L3EndpointIdentificationConstraints}
- * @param wTx transaction where entities are written
+ * @param writeTx transaction where entities are written
*/
public static void writeDnsClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
Clause clause = createClauseWithConsProvEic(ipPrefix, DNS_SUBJECT_NAME);
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, DNS_CONTRACT_ID, clause.getName()),
- clause, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, DNS_CONTRACT_ID,
+ clause.getName()), clause, true);
}
/**
*
* @param tenantId location of {@link #MGMT_CONTRACT}
* @param ipPrefix used in {@link L3EndpointIdentificationConstraints}
- * @param wTx transaction where entities are written
+ * @param writeTx transaction where entities are written
*/
public static void writeMgmtClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
Clause clause = createClauseWithConsProvEic(ipPrefix, MGMT_SUBJECT_NAME);
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, MGMT_CONTRACT_ID, clause.getName()),
- clause, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.clauseIid(tenantId, MGMT_CONTRACT_ID,
+ clause.getName()), clause, true);
}
/**
* Puts network service entities (classifier-instances, {@link #DHCP_CONTRACT},
* {@link #DNS_CONTRACT}, {@link #MGMT_CONTRACT} and {@link #EPG}) to
- * {@link LogicalDatastoreType#CONFIGURATION}
+ * {@link LogicalDatastoreType#CONFIGURATION}.
*
* @param tenantId location of network-service entities
- * @param wTx transaction where network-service entities are written
+ * @param writeTx transaction where network-service entities are written
*/
- public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction wTx) {
+ public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) {
Set<ClassifierInstance> classifierInstances = getAllClassifierInstances();
for (ClassifierInstance ci : classifierInstances) {
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci,
- true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()),
+ ci, true);
}
for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) {
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true);
- }
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID), DHCP_CONTRACT,
- true);
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT,
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai,
true);
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID), MGMT_CONTRACT,
- true);
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
+ }
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID),
+ DHCP_CONTRACT, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT,
+ true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID),
+ MGMT_CONTRACT, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
}
/**
+ * Used to get all Classifier instances.
* @return All classifier-instances used in {@link #DHCP_CONTRACT}, {@link #DNS_CONTRACT} and
- * {@link #MGMT_CONTRACT}
+ * {@link #MGMT_CONTRACT}.
*/
public static Set<ClassifierInstance> getAllClassifierInstances() {
HashSet<ClassifierInstance> cis = new HashSet<>();
package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
+import com.google.common.collect.ImmutableList;
+
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValueBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.Contract;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ContractBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup.IntraGroupPolicy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Clause;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.ClauseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Subject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstanceBuilder;
-import com.google.common.collect.ImmutableList;
-
public class ServiceUtil {
protected static Contract createContract(ContractId cid, List<Subject> subjects, Description description) {
}
protected static ClassifierInstance createClassifInstance(ClassifierName name, ClassifierDefinitionId id,
- List<ParameterValue> pv) {
+ List<ParameterValue> pv) {
return new ClassifierInstanceBuilder().setName(name)
.setClassifierDefinitionId(id)
.setParameterValue(pv)
}
protected static List<ParameterValue> createParams(long etherType, long proto, @Nullable Long srcPort,
- @Nullable Long dstPort) {
+ @Nullable Long dstPort) {
List<ParameterValue> params = new ArrayList<>();
if (srcPort != null) {
params.add(new ParameterValueBuilder().setName(new ParameterName(L4ClassifierDefinition.SRC_PORT_PARAM))
}
protected static Clause createClauseWithConsProvEic(@Nullable IpPrefix ipPrefix, SubjectName subjectName) {
- ConsumerMatchers consumerMatchers = null;
- ProviderMatchers providerMatchers = null;
- StringBuilder clauseName = new StringBuilder();
- clauseName.append(subjectName.getValue());
- if (ipPrefix != null) {
- clauseName.append(MappingUtils.NAME_DOUBLE_DELIMETER).append(Utils.getStringIpPrefix(ipPrefix));
- consumerMatchers =
- new ConsumerMatchersBuilder()
- .setEndpointIdentificationConstraints(new EndpointIdentificationConstraintsBuilder()
- .setL3EndpointIdentificationConstraints(new L3EndpointIdentificationConstraintsBuilder()
- .setPrefixConstraint(
- ImmutableList.of(new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build()))
- .build())
- .build())
- .build();
- providerMatchers =
- new ProviderMatchersBuilder()
- .setEndpointIdentificationConstraints(new EndpointIdentificationConstraintsBuilder()
- .setL3EndpointIdentificationConstraints(new L3EndpointIdentificationConstraintsBuilder()
- .setPrefixConstraint(
- ImmutableList.of(new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build()))
- .build())
- .build())
- .build();
- }
- return new ClauseBuilder().setName(new ClauseName(clauseName.toString()))
- .setSubjectRefs(ImmutableList.of(subjectName))
- .setConsumerMatchers(consumerMatchers)
- .setProviderMatchers(providerMatchers)
- .build();
- }
+ ConsumerMatchers consumerMatchers = null;
+ ProviderMatchers providerMatchers = null;
+ StringBuilder clauseName = new StringBuilder();
+ clauseName.append(subjectName.getValue());
+ if (ipPrefix != null) {
+ clauseName.append(MappingUtils.NAME_DOUBLE_DELIMETER).append(Utils.getStringIpPrefix(ipPrefix));
+ consumerMatchers =
+ new ConsumerMatchersBuilder().setEndpointIdentificationConstraints(
+ new EndpointIdentificationConstraintsBuilder().setL3EndpointIdentificationConstraints(
+ new L3EndpointIdentificationConstraintsBuilder().setPrefixConstraint(
+ ImmutableList.of(new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build())).build())
+ .build()).build();
+ providerMatchers =
+ new ProviderMatchersBuilder().setEndpointIdentificationConstraints(
+ new EndpointIdentificationConstraintsBuilder().setL3EndpointIdentificationConstraints(
+ new L3EndpointIdentificationConstraintsBuilder().setPrefixConstraint(
+ ImmutableList.of(new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build())).build())
+ .build()).build();
+ }
+ return new ClauseBuilder().setName(new ClauseName(clauseName.toString()))
+ .setSubjectRefs(ImmutableList.of(subjectName))
+ .setConsumerMatchers(consumerMatchers)
+ .setProviderMatchers(providerMatchers)
+ .build();
+ }
protected static Rule createRuleAllow(ClassifierName classifierName, Direction direction) {
- ClassifierName name =
- new ClassifierName(direction.name() + MappingUtils.NAME_DOUBLE_DELIMETER + classifierName.getValue());
- ClassifierRef classifierRef = new ClassifierRefBuilder().setName(name)
- .setInstanceName(classifierName)
- .setDirection(direction)
- .build();
- return new RuleBuilder().setName(new RuleName(name))
- .setActionRef(ImmutableList.<ActionRef>of(MappingUtils.ACTION_REF_ALLOW))
- .setClassifierRef(ImmutableList.of(classifierRef))
- .build();
- }
+ ClassifierName name =
+ new ClassifierName(direction.name() + MappingUtils.NAME_DOUBLE_DELIMETER + classifierName.getValue());
+ ClassifierRef classifierRef =
+ new ClassifierRefBuilder().setName(name).setInstanceName(classifierName).setDirection(direction).build();
+ return new RuleBuilder().setName(new RuleName(name))
+ .setActionRef(ImmutableList.<ActionRef>of(MappingUtils.ACTION_REF_ALLOW))
+ .setClassifierRef(ImmutableList.of(classifierRef))
+ .build();
+ }
protected static ProviderNamedSelector createProviderSelector(Contract contract) {
- SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue());
- return new ProviderNamedSelectorBuilder().setName(selectorName)
- .setContract(ImmutableList.of(contract.getId()))
- .build();
- }
+ SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue());
+ return new ProviderNamedSelectorBuilder().setName(selectorName)
+ .setContract(ImmutableList.of(contract.getId()))
+ .build();
+ }
protected static ConsumerNamedSelector createConsumerSelector(Contract contract) {
- SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue());
- return new ConsumerNamedSelectorBuilder().setName(selectorName)
- .setContract(ImmutableList.of(contract.getId()))
- .build();
- }
+ SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue());
+ return new ConsumerNamedSelectorBuilder().setName(selectorName)
+ .setContract(ImmutableList.of(contract.getId()))
+ .build();
+ }
}
public interface NeutronAware<T extends DataObject> {
void onCreated(T createdItem, Neutron neutron);
+
void onUpdated(T oldItem, T newItem, Neutron oldNeutron, Neutron newNeutron);
- void onDeleted(T deletedItem, Neutron oldNeutron, Neutron newNeutron);
+ void onDeleted(T deletedItem, Neutron oldNeutron, Neutron newNeutron);
}
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Objects;
+
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
import org.opendaylight.groupbasedpolicy.util.IidFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.IpPrefixType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev170511.L3Context;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.l3endpoint.rev151217.NatAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.l3endpoint.rev151217.NatAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.floatingips.attributes.Floatingips;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Objects;
-
public class NeutronFloatingIpAware implements NeutronAware<Floatingip> {
private static final Logger LOG = LoggerFactory.getLogger(NeutronFloatingIpAware.class);
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
public class NeutronNetworkAware implements NeutronAware<Network> {
private static final Logger LOG = LoggerFactory.getLogger(NeutronNetworkAware.class);
@Override
public void onCreated(Network network, Neutron neutron) {
LOG.trace("created network - {}", network);
- ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
- TenantId tenantId = new TenantId(network.getTenantId().getValue());
Name name;
ContextId ctxId = new ContextId(network.getUuid().getValue());
ForwardingContextBuilder fwdCtxBuilder = new ForwardingContextBuilder()
- .setContextId(ctxId)
- .setContextType(MappingUtils.L3_CONTEXT);
+ .setContextId(ctxId)
+ .setContextType(MappingUtils.L3_CONTEXT);
if (!Strings.isNullOrEmpty(network.getName())) {
try {
name = new Name(network.getName());
fwdCtxBuilder.setName(name);
- } catch (Exception e) {
+ } catch (NullPointerException | IllegalArgumentException e) {
LOG.info("Name of Neutron Network '{}' is ignored.", network.getName());
LOG.debug("Name exception", e);
}
ForwardingContext l3Context = fwdCtxBuilder.build();
fwdCtxBuilder.setContextType(MappingUtils.L2_BRDIGE_DOMAIN)
-
- .setParent(MappingUtils.createParent(ctxId, MappingUtils.L3_CONTEXT));
+ .setParent(MappingUtils.createParent(ctxId, MappingUtils.L3_CONTEXT));
ForwardingContext l2Bd = fwdCtxBuilder.build();
- fwdCtxBuilder.setContextType(MappingUtils.L2_FLOOD_DOMAIN).setParent(
- MappingUtils.createParent(ctxId, MappingUtils.L2_BRDIGE_DOMAIN));
+ fwdCtxBuilder.setContextType(MappingUtils.L2_FLOOD_DOMAIN)
+ .setParent(MappingUtils.createParent(ctxId, MappingUtils.L2_BRDIGE_DOMAIN));
ForwardingContext l2Fd = fwdCtxBuilder.build();
+ ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
+ TenantId tenantId = new TenantId(network.getTenantId().getValue());
rwTx.put(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.l3ContextIid(tenantId, ctxId), l3Context, true);
rwTx.put(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.l2BridgeDomainIid(tenantId, ctxId), l2Bd, true);
rwTx.put(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.l2FloodDomainIid(tenantId, ctxId), l2Fd, true);
l3CtxBuilder.setName(name);
l2FdBuilder.setName(name);
l2BdBuilder.setName(name);
- } catch (Exception e) {
- name = null;
+ } catch (NullPointerException | IllegalArgumentException e) {
LOG.info("Name of Neutron Network '{}' is ignored.", network.getName());
LOG.debug("Name exception", e);
}
L2FloodDomainId l2FdId = new L2FloodDomainId(network.getUuid().getValue());
L3ContextId l3ContextId = new L3ContextId(l2FdId);
L3Context l3Context = l3CtxBuilder.setId(l3ContextId).build();
- rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3Context.getId()), l3Context, true);
+ rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3Context.getId()), l3Context,
+ true);
L2BridgeDomainId l2BdId = new L2BridgeDomainId(l2FdId);
L2BridgeDomain l2Bd = l2BdBuilder.setId(l2BdId).setParent(l3Context.getId()).build();
}
private void addProviderPhysicalNetworkMapping(TenantId tenantId, ContextId ctxId, String segmentationId,
- WriteTransaction wTx) {
- ProviderPhysicalNetworkAsL2FloodDomain provNetAsL2Fd = new ProviderPhysicalNetworkAsL2FloodDomainBuilder().setTenantId(
- tenantId)
+ WriteTransaction writeTx) {
+ ProviderPhysicalNetworkAsL2FloodDomain provNetAsL2Fd =
+ new ProviderPhysicalNetworkAsL2FloodDomainBuilder().setTenantId(tenantId)
.setL2FloodDomainId(ctxId)
.setSegmentationId(segmentationId)
.build();
- wTx.put(LogicalDatastoreType.OPERATIONAL,
+ writeTx.put(LogicalDatastoreType.OPERATIONAL,
NeutronGbpIidFactory.providerPhysicalNetworkAsL2FloodDomainIid(tenantId, ctxId), provNetAsL2Fd);
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private void addProviderPhysicalNetworkMapping(TenantId tenantId, L2FloodDomainId l2FdId, String segmentationId,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomain provNetAsL2Fd = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomainBuilder().setTenantId(
tenantId)
.setL2FloodDomainId(new L2FloodDomainId(l2FdId.getValue()))
.setSegmentationId(segmentationId)
.build();
- wTx.put(LogicalDatastoreType.OPERATIONAL,
+ writeTx.put(LogicalDatastoreType.OPERATIONAL,
NeutronGbpIidFactory.providerPhysicalNetworkAsL2FloodDomainIid(tenantId, l2FdId), provNetAsL2Fd);
}
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
public class NeutronPortAware implements NeutronAware<Port> {
private static final Logger LOG = LoggerFactory.getLogger(NeutronPortAware.class);
onCreated(createdItem, neutron, true);
}
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public void onCreated(Port port, Neutron neutron, boolean addBaseEpMapping) {
LOG.trace("created port - {}", port);
if (PortUtils.isRouterInterfacePort(port)) {
LOG.warn("Illegal state - router interface port does not contain fixed IPs {}", port);
return;
}
- FixedIps portIpWithSubnet = potentialPortIpWithSubnet.get();
- ContextId routerL3Context = new ContextId(port.getDeviceId());
- ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
+ final FixedIps portIpWithSubnet = potentialPortIpWithSubnet.get();
+ final ContextId routerL3Context = new ContextId(port.getDeviceId());
AddressEndpointKey addrEpKey = new AddressEndpointKey(port.getMacAddress().getValue(), MacAddressType.class,
new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN);
UniqueId portId = new UniqueId(port.getUuid().getValue());
+ ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
addBaseEndpointMappings(addrEpKey, portId, rwTx);
// Add Qrouter and VPProuter port as Endpoint
if (port.getAugmentation(PortBindingExtension.class) != null && PortUtils.DEVICE_VIF_TYPE
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private void processTenantForwarding(Subnet routerPortSubnet, ContextId routerL3Context, FixedIps portIpWithSubnet,
TenantId tenantId, ReadWriteTransaction rwTx) {
L2BridgeDomainId l2BdId = new L2BridgeDomainId(routerPortSubnet.getNetworkId().getValue());
* Creates registration input for L3 endpoint if fixedIps argument is not null.
*/
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder createEndpointRegFromPort(
Port port, FixedIps fixedIps, NetworkDomainId networkContainment, List<EndpointGroupId> endpointGroupIds,
Neutron neutron) {
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private void modifyL3ContextForEndpoints(Port port, FixedIps resolvedPortFixedIp, ContextId newContextId) {
org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder epInBuilder =
createBasicEndpointInputBuilder(port);
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private static org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder createBasicEndpointInputBuilder(
Port port) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder()
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private void registerEndpointAndStoreMapping(
org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput regEpInput,
Port port, ReadWriteTransaction rwTx) {
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private void unregisterEndpointAndRemoveMapping(
org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregEpInput,
Port port, ReadWriteTransaction rwTx) {
}
}
+ private void unregisterEndpointAndRemoveMapping(UnregisterEndpointInput baseEpUnreg, Port port,
+ ReadWriteTransaction rwTx, boolean removeBaseEpMappings) {
+ boolean isUnregisteredBaseEndpoint = epRegistrator.unregisterEndpoint(baseEpUnreg);
+ if (isUnregisteredBaseEndpoint) {
+ UniqueId portId = new UniqueId(port.getUuid().getValue());
+ PortByBaseEndpointKey portByBaseEndpointKey = new PortByBaseEndpointKey(port.getMacAddress().getValue(),
+ MacAddressType.class, new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN);
+ LOG.trace("Removing Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}",
+ port.getUuid().getValue(), port.getDeviceOwner(), portByBaseEndpointKey);
+ if (removeBaseEpMappings) {
+ removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx);
+ }
+ }
+ }
+
private void registerBaseEndpointAndStoreMapping(List<AddressEndpointReg> addrEpRegs, Port port,
- WriteTransaction wTx, boolean addBaseEpMappings) {
+ WriteTransaction writeTx, boolean addBaseEpMappings) {
RegisterEndpointInput regBaseEpInput =
new RegisterEndpointInputBuilder().setAddressEndpointReg(addrEpRegs).build();
port.getUuid());
AddressEndpointKey addrEpKey = new AddressEndpointKey(addrEpReg.getAddress(),
addrEpReg.getAddressType(), addrEpReg.getContextId(), addrEpReg.getContextType());
- addBaseEndpointMappings(addrEpKey, portId, wTx);
+ addBaseEndpointMappings(addrEpKey, portId, writeTx);
}
}
}
- private void addBaseEndpointMappings(AddressEndpointKey addrEpKey, UniqueId portId, WriteTransaction wTx) {
+ private void addBaseEndpointMappings(AddressEndpointKey addrEpKey, UniqueId portId, WriteTransaction writeTx) {
BaseEndpointByPort baseEndpointByPort = MappingFactory.createBaseEndpointByPort(addrEpKey, portId);
- wTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.baseEndpointByPortIid(portId),
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.baseEndpointByPortIid(portId),
baseEndpointByPort, true);
PortByBaseEndpoint portByBaseEndpoint = MappingFactory.createPortByBaseEndpoint(portId, addrEpKey);
- wTx.put(LogicalDatastoreType.OPERATIONAL,
+ writeTx.put(LogicalDatastoreType.OPERATIONAL,
NeutronGbpIidFactory.portByBaseEndpointIid(new PortByBaseEndpointKey(portByBaseEndpoint.getKey())),
portByBaseEndpoint, true);
}
- private void unregisterEndpointAndRemoveMapping(UnregisterEndpointInput baseEpUnreg, Port port,
- ReadWriteTransaction rwTx, boolean removeBaseEpMappings) {
- boolean isUnregisteredBaseEndpoint = epRegistrator.unregisterEndpoint(baseEpUnreg);
- if (isUnregisteredBaseEndpoint) {
- UniqueId portId = new UniqueId(port.getUuid().getValue());
- PortByBaseEndpointKey portByBaseEndpointKey = new PortByBaseEndpointKey(port.getMacAddress().getValue(),
- MacAddressType.class, new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN);
- LOG.trace("Removing Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}",
- port.getUuid().getValue(), port.getDeviceOwner(), portByBaseEndpointKey);
- if (removeBaseEpMappings) {
- removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx);
- }
- }
- }
-
private void removeBaseEndpointMappings(PortByBaseEndpointKey portByBaseEndpointKey, UniqueId portId,
ReadWriteTransaction rwTx) {
DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL,
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private void modifyForwardingOnDelete(Subnet routerPortSubnet, L3ContextId l3contextId, TenantId tenantId,
ReadWriteTransaction rwTx) {
L2BridgeDomainId l2BdId = new L2BridgeDomainId(routerPortSubnet.getNetworkId().getValue());
tenantSubnet);
}
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.UnregisterEndpointInput createUnregisterBaseEndpointInput(
Port port, Neutron neutron) {
- UnregisterEndpointInputBuilder inputBuilder = new UnregisterEndpointInputBuilder();
List<AddressEndpointUnreg> list = new ArrayList<>();
AddressEndpointUnregBuilder addrL2EpUnregBuilder = new AddressEndpointUnregBuilder();
addrL2EpUnregBuilder.setAddress(port.getMacAddress().getValue())
.setContextType(L3Context.class);
list.add(addrL3EpUnregBuilder.build());
}
+ UnregisterEndpointInputBuilder inputBuilder = new UnregisterEndpointInputBuilder();
inputBuilder.setAddressEndpointUnreg(list);
return inputBuilder.build();
}
@Deprecated
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput createUnregisterEndpointInput(
Port port, Neutron neutron) {
org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInputBuilder inputBuilder =
try {
routerName = new Name(router.getName());
fwdCtxBuilder.setName(routerName);
- } catch (Exception e) {
+ } catch (NullPointerException | IllegalArgumentException e) {
LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", router.getName(),
router.getUuid().getValue());
LOG.debug("Name exception", e);
ForwardingContext routerl3Context = fwdCtxBuilder.setContextId(routerl3ContextId)
.setContextType(MappingUtils.L3_CONTEXT)
.build();
- WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
- wTx.put(LogicalDatastoreType.CONFIGURATION, routerL3CtxIid, routerl3Context, true);
- createTenantL3Context(new L3ContextId(routerl3ContextId), tenantId, routerName, wTx);
- DataStoreHelper.submitToDs(wTx);
+ WriteTransaction writeTx = dataProvider.newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, routerL3CtxIid, routerl3Context, true);
+ createTenantL3Context(new L3ContextId(routerl3ContextId), tenantId, routerName, writeTx);
+ DataStoreHelper.submitToDs(writeTx);
}
@Deprecated
- private void createTenantL3Context(L3ContextId l3ContextId, TenantId tenantId, Name name, WriteTransaction wTx) {
+ private void createTenantL3Context(L3ContextId l3ContextId, TenantId tenantId, Name name,
+ WriteTransaction writeTx) {
L3ContextBuilder l3ContextBuilder = new L3ContextBuilder();
if (name != null) {
l3ContextBuilder.setName(name);
}
L3Context l3Context = l3ContextBuilder.setId(l3ContextId).build();
- wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3ContextId), l3Context, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3ContextId), l3Context,
+ true);
}
@Override
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public void onUpdated(Router oldRouter, Router newRouter, Neutron oldNeutron, Neutron newNeutron) {
LOG.trace("updated router - OLD: {}\nNEW: {}", oldRouter, newRouter);
L2L3IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
if (!optBd.isPresent()) {
LOG.warn(
- "Could not read L2-Bridge-Domain {}. Modification of its parent to L3-Context of router {} aborted.",
+ "Could not read L2BridgeDomain {}. Modification of its parent to L3Context of router {} aborted.",
l2BdId, newRouter.getUuid());
rwTx.cancel();
return;
return epRegistrator.unregisterEndpoint(addrEpBuilder.build());
}
-private NetworkDomain createSubnetWithVirtualRouterIp(IpPrefix gatewayIp, NetworkDomainId subnetId, List<Gateways> gateways) {
- Subnet subnet = new SubnetBuilder()
- .setVirtualRouterIp(MappingUtils.ipPrefixToIpAddress(gatewayIp.getValue()))
- .setGateways(gateways)
- .build();
+ private NetworkDomain createSubnetWithVirtualRouterIp(IpPrefix gatewayIp, NetworkDomainId subnetId,
+ List<Gateways> gateways) {
+
+ Subnet subnet =
+ new SubnetBuilder().setVirtualRouterIp(MappingUtils.ipPrefixToIpAddress(gatewayIp.getValue()))
+ .setGateways(gateways)
+ .build();
return new NetworkDomainBuilder().setKey(new NetworkDomainKey(subnetId, MappingUtils.SUBNET))
.addAugmentation(SubnetAugmentForwarding.class,
- new SubnetAugmentForwardingBuilder().setSubnet(subnet).build())
+ new SubnetAugmentForwardingBuilder().setSubnet(subnet).build())
.build();
}
@Deprecated
- private void updateTenantForwarding(Neutron newNeutron, Router oldRouter, Router newRouter, L3ContextId l3ContextId, TenantId tenantId, ReadWriteTransaction rwTx) {
- InstanceIdentifier<L3Context> l3ContextIid =
- IidFactory.l3ContextIid(tenantId, l3ContextId);
- Optional<L3Context> optL3Context = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, rwTx);
- L3Context l3Context;
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
+ private void updateTenantForwarding(Neutron newNeutron, Router oldRouter, Router newRouter, L3ContextId l3ContextId,
+ TenantId tenantId, ReadWriteTransaction rwTx) {
+
+ InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
+ Optional<L3Context> optL3Context = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid,
+ rwTx);
+ L3Context l3Context;
if (!optL3Context.isPresent()) { // add L3 context if missing
l3Context = createL3CtxFromRouter(newRouter);
rwTx.put(LogicalDatastoreType.CONFIGURATION, l3ContextIid, l3Context, true);
}
if (newRouter.getGatewayPortId() != null && oldRouter.getGatewayPortId() == null) {
- // external network is attached to router
- Uuid gatewayPortId = newRouter.getGatewayPortId();
- Optional<Port> potentialGwPort = PortUtils.findPort(gatewayPortId, newNeutron.getPorts());
- if (!potentialGwPort.isPresent()) {
- LOG.warn("Illegal state - router gateway port {} does not exist for router {}.",
- gatewayPortId.getValue(), newRouter);
- rwTx.cancel();
- return;
- }
-
- Port gwPort = potentialGwPort.get();
- List<FixedIps> fixedIpsFromGwPort = gwPort.getFixedIps();
- if (fixedIpsFromGwPort == null || fixedIpsFromGwPort.isEmpty()) {
- LOG.warn("Illegal state - router gateway port {} does not contain fixed IPs {}",
- gatewayPortId.getValue(), gwPort);
- rwTx.cancel();
- return;
- }
-
- // router can have only one external network
- FixedIps ipWithSubnetFromGwPort = fixedIpsFromGwPort.get(0);
- Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet> potentialSubnet = SubnetUtils.findSubnet(ipWithSubnetFromGwPort.getSubnetId(), newNeutron.getSubnets());
- if (!potentialSubnet.isPresent()) {
- LOG.warn("Illegal state - Subnet {} does not exist for router {}.",
- ipWithSubnetFromGwPort.getSubnetId(), newRouter);
- rwTx.cancel();
- return;
- }
- IpAddress gatewayIp = potentialSubnet.get().getGatewayIp();
- NetworkDomainId networkContainment = new NetworkDomainId(ipWithSubnetFromGwPort.getSubnetId().getValue());
- boolean registeredExternalGateway = epRegistrator.registerL3EpAsExternalGateway(tenantId, gatewayIp,
- l3ContextId, networkContainment);
- if (!registeredExternalGateway) {
- LOG.warn("Could not add L3Prefix as gateway of default route. Gateway port {}", gwPort);
- rwTx.cancel();
- return;
- }
- EndpointL3Key epL3Key = new EndpointL3Key(gatewayIp, l3ContextId);
- addNeutronExtGwMapping(epL3Key, rwTx);
-
- boolean registeredDefaultRoute = epRegistrator.registerExternalL3PrefixEndpoint(MappingUtils.DEFAULT_ROUTE,
- l3ContextId, gatewayIp, tenantId);
- if (!registeredDefaultRoute) {
- LOG.warn("Could not add EndpointL3Prefix as default route. Gateway port {}", gwPort);
- rwTx.cancel();
- return;
- }
- org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.Subnet subnetWithGw =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder().setId(new SubnetId(ipWithSubnetFromGwPort.getSubnetId().getValue()))
- .setVirtualRouterIp(gatewayIp)
- .build();
- rwTx.merge(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnetWithGw.getId()),
- subnetWithGw);
- L2BridgeDomainId l2BdId = new L2BridgeDomainId(potentialSubnet.get().getNetworkId().getValue());
- Optional<L2BridgeDomain> optBd = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
- IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
- if (!optBd.isPresent()) {
- LOG.warn(
- "Could not read L2-Bridge-Domain {}. Modification of its parent to L3-Context of router {} aborted.",
- l2BdId, newRouter.getUuid());
- rwTx.cancel();
- return;
- }
- L2BridgeDomain l2BdWithGw = new L2BridgeDomainBuilder(optBd.get())
- .setParent(new L3ContextId(l3ContextId.getValue()))
- .build();
- rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId),
- l2BdWithGw);
- }
+ // external network is attached to router
+ Uuid gatewayPortId = newRouter.getGatewayPortId();
+ Optional<Port> potentialGwPort = PortUtils.findPort(gatewayPortId, newNeutron.getPorts());
+ if (!potentialGwPort.isPresent()) {
+ LOG.warn("Illegal state - router gateway port {} does not exist for router {}.",
+ gatewayPortId.getValue(), newRouter);
+ rwTx.cancel();
+ return;
+ }
+
+ Port gwPort = potentialGwPort.get();
+ List<FixedIps> fixedIpsFromGwPort = gwPort.getFixedIps();
+ if (fixedIpsFromGwPort == null || fixedIpsFromGwPort.isEmpty()) {
+ LOG.warn("Illegal state - router gateway port {} does not contain fixed IPs {}",
+ gatewayPortId.getValue(), gwPort);
+ rwTx.cancel();
+ return;
+ }
+
+ // router can have only one external network
+ FixedIps ipWithSubnetFromGwPort = fixedIpsFromGwPort.get(0);
+ Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet>
+ potentialSubnet = SubnetUtils.findSubnet(ipWithSubnetFromGwPort.getSubnetId(), newNeutron.getSubnets());
+ if (!potentialSubnet.isPresent()) {
+ LOG.warn("Illegal state - Subnet {} does not exist for router {}.",
+ ipWithSubnetFromGwPort.getSubnetId(), newRouter);
+ rwTx.cancel();
+ return;
+ }
+ IpAddress gatewayIp = potentialSubnet.get().getGatewayIp();
+ NetworkDomainId networkContainment = new NetworkDomainId(ipWithSubnetFromGwPort.getSubnetId().getValue());
+ boolean registeredExternalGateway =
+ epRegistrator.registerL3EpAsExternalGateway(tenantId, gatewayIp, l3ContextId, networkContainment);
+ if (!registeredExternalGateway) {
+ LOG.warn("Could not add L3Prefix as gateway of default route. Gateway port {}", gwPort);
+ rwTx.cancel();
+ return;
+ }
+ EndpointL3Key epL3Key = new EndpointL3Key(gatewayIp, l3ContextId);
+ addNeutronExtGwMapping(epL3Key, rwTx);
+
+ boolean registeredDefaultRoute = epRegistrator.registerExternalL3PrefixEndpoint(MappingUtils.DEFAULT_ROUTE,
+ l3ContextId, gatewayIp, tenantId);
+ if (!registeredDefaultRoute) {
+ LOG.warn("Could not add EndpointL3Prefix as default route. Gateway port {}", gwPort);
+ rwTx.cancel();
+ return;
+ }
+ org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.Subnet
+ subnetWithGw =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder()
+ .setId(new SubnetId(ipWithSubnetFromGwPort.getSubnetId().getValue()))
+ .setVirtualRouterIp(gatewayIp)
+ .build();
+ rwTx.merge(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnetWithGw.getId()),
+ subnetWithGw);
+ L2BridgeDomainId l2BdId = new L2BridgeDomainId(potentialSubnet.get().getNetworkId().getValue());
+ Optional<L2BridgeDomain> optBd =
+ DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId,
+ l2BdId), rwTx);
+ if (!optBd.isPresent()) {
+ LOG.warn(
+ "Could not read L2BridgeDomain {}. Modification of its parent to L3Context of router {} aborted.",
+ l2BdId, newRouter.getUuid());
+ rwTx.cancel();
+ return;
+ }
+ L2BridgeDomain
+ l2BdWithGw =
+ new L2BridgeDomainBuilder(optBd.get()).setParent(new L3ContextId(l3ContextId.getValue())).build();
+ rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId), l2BdWithGw);
+ }
}
- private void deleteTenantForwarding(Neutron newNeutron, Router oldRouter, L3ContextId l3ContextId, TenantId tenantId, ReadWriteTransaction rwTx) {
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
+ private void deleteTenantForwarding(Neutron newNeutron, Router oldRouter, L3ContextId l3ContextId,
+ TenantId tenantId, ReadWriteTransaction rwTx) {
+
InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
LOG.trace("Deleting router from TenantForwarding {}", l3ContextIid);
IidFactory.subnetIid(tenantId, new SubnetId(ipWithSubnetFromGwPort.getSubnetId().getValue())), subnet);
L2BridgeDomainId l2BdId = new L2BridgeDomainId(potentialSubnet.get().getNetworkId().getValue());
- L3ContextId l3Context = new L3ContextId( potentialSubnet.get().getNetworkId().getValue());
+ L3ContextId l3Context = new L3ContextId(potentialSubnet.get().getNetworkId().getValue());
Optional<L2BridgeDomain> optBd = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
- IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
+ IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
if (optBd.isPresent()) {
L2BridgeDomain l2BdWithGw = new L2BridgeDomainBuilder(optBd.get()).setParent(l3Context).build();
LOG.trace("Setting parent for L2BridgeDomain {} back to network {}.", l2BdWithGw, l3Context);
private static void addNeutronExtGwGbpMapping(ContextId contextId, IpPrefix ipPrefix, ReadWriteTransaction rwTx) {
ExternalGatewayAsEndpoint externalGatewayL3Endpoint = MappingFactory.createEaxternalGatewayAsEndpoint(
contextId, ipPrefix);
- rwTx.put(LogicalDatastoreType.OPERATIONAL,
- NeutronGbpIidFactory.externalGatewayAsEndpoint(contextId, ipPrefix, MappingUtils.L3_CONTEXT), externalGatewayL3Endpoint, true);
+ rwTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.externalGatewayAsEndpoint(contextId,
+ ipPrefix, MappingUtils.L3_CONTEXT), externalGatewayL3Endpoint, true);
}
@Deprecated
DataStoreHelper.submitToDs(rwTx);
}
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
private void deleteExtGw(Router router, TenantId tenantId, Neutron newNeutron, ReadWriteTransaction rwTx) {
ContextId routerL3CtxId = new ContextId(router.getUuid().getValue());
if (router.getGatewayPortId() != null) {
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
public class NeutronSecurityGroupAware implements NeutronAware<SecurityGroup> {
private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityGroupAware.class);
// TODO This needs to be reworked, SecGroups shouldn't use TenantId, Neutron doesn't always configure it
return true;
}
- TenantId tId = new TenantId(secGroup.getTenantId().getValue());
+ TenantId tenantId = new TenantId(secGroup.getTenantId().getValue());
EndpointGroupId epgId = new EndpointGroupId(secGroup.getUuid().getValue());
if (epgId.getValue().equals(MappingUtils.EIG_UUID.getValue())) {
ExternalImplicitGroup eig = new ExternalImplicitGroupBuilder().setId(epgId).build();
- rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.externalImplicitGroupIid(tId, epgId), eig, true);
+ rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.externalImplicitGroupIid(tenantId, epgId), eig,
+ true);
}
EndpointGroupBuilder epgBuilder = new EndpointGroupBuilder().setId(epgId);
if (!Strings.isNullOrEmpty(secGroup.getName())) {
try {
epgBuilder.setName(new Name(secGroup.getName()));
- } catch (Exception e) {
+ } catch (NullPointerException | IllegalArgumentException e) {
LOG.info("Name '{}' of Neutron Security-group '{}' is ignored.", secGroup.getName(),
secGroup.getUuid().getValue());
LOG.debug("Name exception", e);
}
}
epgBuilder.setIntraGroupPolicy(IntraGroupPolicy.RequireContract);
- rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tId, epgId),
+ rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, epgId),
epgBuilder.build(), true);
return true;
}
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
+@SuppressWarnings("checkstyle:LineLength") // Longer lines in this class are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public class NeutronSubnetAware implements
NeutronAware<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet> {
- private final static Logger LOG = LoggerFactory.getLogger(NeutronSubnetAware.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronSubnetAware.class);
public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet> SUBNET_WILDCARD_IID =
InstanceIdentifier.builder(Neutron.class)
.child(Subnets.class)
.stream()
.filter(net -> net.getUuid().equals(port.getNetworkId()))
.filter(net -> net.getAugmentation(NetworkProviderExtension.class) != null)
- .anyMatch(net -> net.getAugmentation(NetworkProviderExtension.class).getPhysicalNetwork() != null)) {
+ .anyMatch(
+ net -> net.getAugmentation(NetworkProviderExtension.class).getPhysicalNetwork() != null)) {
// add virtual router IP only in case it is provider physical network
sb.setVirtualRouterIp(subnet.getGatewayIp());
}
if (!Strings.isNullOrEmpty(subnet.getName())) {
try {
ndb.setName(new Name(subnet.getName()));
- } catch (Exception e) {
+ } catch (NullPointerException | IllegalArgumentException e) {
LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", subnet.getName(), subnet.getUuid().getValue());
LOG.debug("Name exception", e);
}
}
ndb.setNetworkDomainId(new NetworkDomainId(subnet.getUuid().getValue()));
ndb.setNetworkDomainType(MappingUtils.SUBNET);
- ndb.setParent(MappingUtils.createParent(new NetworkDomainId(subnet.getNetworkId().getValue()), L2FloodDomain.class));
+ ndb.setParent(
+ MappingUtils.createParent(new NetworkDomainId(subnet.getNetworkId().getValue()), L2FloodDomain.class));
ndb.addAugmentation(SubnetAugmentForwarding.class, new SubnetAugmentForwardingBuilder().setSubnet(sb.build())
.build());
return ndb.build();
if (!Strings.isNullOrEmpty(subnet.getName())) {
try {
subnetBuilder.setName(new Name(subnet.getName()));
- } catch (Exception e) {
+ } catch (NullPointerException | IllegalArgumentException e) {
LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", subnet.getName(),
subnet.getUuid().getValue());
LOG.debug("Name exception", e);
ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
NetworkDomainId subnetId = new NetworkDomainId(neutronSubnet.getUuid().getValue());
TenantId tenantId = new TenantId(neutronSubnet.getTenantId().getValue());
- Optional<NetworkDomain> potentialSubnetDomain = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION,
- L2L3IidFactory.subnetIid(tenantId, subnetId), rwTx);
+ Optional<NetworkDomain> potentialSubnetDomain = DataStoreHelper.removeIfExists(
+ LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.subnetIid(tenantId, subnetId), rwTx);
if (!potentialSubnetDomain.isPresent()) {
LOG.warn("Illegal state - subnet network domain {} does not exist.", subnetId.getValue());
rwTx.cancel();
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.groupbasedpolicy.neutron.mapper.util.SecurityRuleUtils;
-import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.ChangeActionOfSecurityGroupRulesInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.NeutronGbpMapperService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.change.action.of.security.group.rules.input.SecurityGroupRule;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
-
-public class NeutronGbpMapperServiceImpl implements NeutronGbpMapperService {
-
- private static final Logger LOG = LoggerFactory.getLogger(NeutronGbpMapperServiceImpl.class);
- private NeutronSecurityRuleAware secRuleAware;
- private DataBroker dataProvider;
-
- public NeutronGbpMapperServiceImpl(DataBroker dataProvider, NeutronSecurityRuleAware secRuleAware) {
- this.dataProvider = checkNotNull(dataProvider);
- this.secRuleAware = checkNotNull(secRuleAware);
- }
-
- @Override
- public Future<RpcResult<Void>> changeActionOfSecurityGroupRules(ChangeActionOfSecurityGroupRulesInput input) {
- List<SecurityGroupRule> securityGroupRules = input.getSecurityGroupRule();
- if (securityGroupRules == null || input.getAction() == null) {
- LOG.debug("Missing params in request:\n{}", input);
- return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
- .withError(ErrorType.PROTOCOL, "Missing params. Changing to action "
- + input.getAction().getActionChoice() + " was not successful.")
- .build());
- }
-
- ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
- Optional<Neutron> potentialNeutron;
- try {
- potentialNeutron = rwTx.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(Neutron.class).build()).get();
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Exception during neutron reading.", e);
- return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
- .withError(ErrorType.PROTOCOL, "Cannot read from CONF DS.")
- .build());
- }
- if (!potentialNeutron.isPresent()) {
- return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
- .withError(ErrorType.PROTOCOL, "No neutron data in CONF DS.")
- .build());
- }
- Neutron neutron = potentialNeutron.get();
- for (SecurityGroupRule secGrpRule : securityGroupRules) {
- Uuid uuid = secGrpRule.getUuid();
- Optional<SecurityRule> potentialSecRule = SecurityRuleUtils.findSecurityRule(uuid, neutron.getSecurityRules());
- if (!potentialSecRule.isPresent()) {
- LOG.warn("Security rule {} does not exist.", uuid);
- continue;
- }
- LOG.trace("Changing action to {} in security group rule {}", input.getAction().getActionChoice(), uuid);
- boolean isSuccessful =
- secRuleAware.changeActionOfNeutronSecurityRule(potentialSecRule.get(), input.getAction().getActionChoice(), neutron, rwTx);
- if (!isSuccessful) {
- rwTx.cancel();
- LOG.warn("Changing action to {} in security group rule {} was not successful.",
- input.getAction().getActionChoice(), uuid);
- return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
- .withError(ErrorType.APPLICATION,
- "Changing to action " + input.getAction().getActionChoice() + " was not successful.")
- .build());
- }
- }
- boolean isSubmittedToDs = DataStoreHelper.submitToDs(rwTx);
- if (!isSubmittedToDs) {
- LOG.warn("Changing action to {} in security group rules {} was not successful.",
- input.getAction().getActionChoice(), input.getSecurityGroupRule());
- return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
- .withError(ErrorType.APPLICATION, "Storing to datastore was not successful. Changing to action "
- + input.getAction().getActionChoice() + " was not successful.")
- .build());
- }
- return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
- }
-
-}
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.HashMultiset;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Multiset;
+import com.google.common.collect.Sets;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.HashMultiset;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Multiset;
-import com.google.common.collect.Sets;
-
public class NeutronSecurityRuleAware implements NeutronAware<SecurityRule> {
private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityRuleAware.class);
private final Multiset<InstanceIdentifier<ActionInstance>> createdActionInstances;
private final Map<SecurityRuleKey, SecurityRule> pendingCreatedRules;
private final Map<SecurityGroupKey, SecurityGroup> pendingDeletedGroups;
- final static String PROVIDED_BY = "provided_by-";
- final static String POSSIBLE_CONSUMER = "possible_consumer-";
+ private static final String PROVIDED_BY = "provided_by-";
+ private static final String POSSIBLE_CONSUMER = "possible_consumer-";
private final EndpointRegistrator epRegistrator;
public NeutronSecurityRuleAware(DataBroker dataProvider, EndpointRegistrator epRegistrator) {
Description contractDescription = createContractDescription(secRule, neutron);
SingleRuleContract singleRuleContract = createSingleRuleContract(secRule, contractDescription, action, neutron);
Contract contract = singleRuleContract.getContract();
- rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, contract.getId()), contract, true);
+ rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, contract.getId()), contract,
+ true);
SelectorName providerSelector = getSelectorNameWithConsumer(secRule, neutron);
- writeProviderNamedSelectorToEpg(providerSelector, contract.getId(), new EpgKeyDto(providerEpgId, tenantId), rwTx);
+ writeProviderNamedSelectorToEpg(providerSelector, contract.getId(), new EpgKeyDto(providerEpgId, tenantId),
+ rwTx);
if (secRule.getRemoteGroupId() != null) {
Uuid consumerSecGroupId = secRule.getRemoteGroupId();
designContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, neutron, rwTx);
} else {
for (Uuid consumerSecGroupId : SecurityRuleUtils.findSecurityGroupsHavingSecurityRules(neutron)) {
- designContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, neutron, rwTx);
- designContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, neutron, rwTx);
+ designContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, neutron,
+ rwTx);
+ designContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, neutron,
+ rwTx);
}
}
.filter(net -> NetworkUtils.isRouterExternal(net))
.findAny();
if (publicNet.isPresent()) {
- WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
- wTx.merge(LogicalDatastoreType.CONFIGURATION,
+ WriteTransaction writeTx = dataProvider.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
IidFactory.externalImplicitGroupIid(new TenantId(secRule.getTenantId().getValue()),
MappingUtils.EPG_EXTERNAL_ID),
new ExternalImplicitGroupBuilder().setId(MappingUtils.EPG_EXTERNAL_ID).build(), true);
- wTx.merge(LogicalDatastoreType.CONFIGURATION,
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
IidFactory.endpointGroupIid(new TenantId(secRule.getTenantId().getValue()),
MappingUtils.EPG_EXTERNAL_ID),
new EndpointGroupBuilder().setId(MappingUtils.EPG_EXTERNAL_ID).build(), true);
- DataStoreHelper.submitToDs(wTx);
+ DataStoreHelper.submitToDs(writeTx);
AddressEndpointRegBuilder addrEpbuilder = new AddressEndpointRegBuilder()
.setAddress(String.valueOf(secRule.getRemoteIpPrefix().getValue()))
.setAddressType(IpPrefixType.class)
@VisibleForTesting
Set<SecurityRule> getProvidedSecRulesBetween(Uuid provSecGroup, Uuid consSecGroup, Neutron neutron) {
- return Sets.union(SecurityRuleUtils.findSecurityRulesBySecGroupAndRemoteSecGroup(provSecGroup, consSecGroup, neutron),
- SecurityRuleUtils.findSecurityRulesBySecGroupAndRemoteSecGroup(provSecGroup, null, neutron));
+ return Sets.union(
+ SecurityRuleUtils.findSecurityRulesBySecGroupAndRemoteSecGroup(provSecGroup, consSecGroup, neutron),
+ SecurityRuleUtils.findSecurityRulesBySecGroupAndRemoteSecGroup(provSecGroup, null, neutron));
}
@VisibleForTesting
return false;
}
- public boolean changeActionOfNeutronSecurityRule(SecurityRule secRule, ActionChoice action, Neutron neutron, ReadWriteTransaction rwTx) {
+ public boolean changeActionOfNeutronSecurityRule(SecurityRule secRule, ActionChoice action, Neutron neutron,
+ ReadWriteTransaction rwTx) {
+
addSfcChainActionInstance(action, new TenantId(secRule.getTenantId().getValue()), rwTx);
LOG.trace("Changing to action {} for secuirity group rule {}", action, secRule);
return addNeutronSecurityRuleWithAction(secRule, neutron, action, rwTx);
}
private void writeProviderNamedSelectorToEpg(SelectorName providerSelector, ContractId contractId, EpgKeyDto epgKey,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
ProviderNamedSelector providerNamedSelector = new ProviderNamedSelectorBuilder().setName(providerSelector)
.setContract(ImmutableList.of(contractId))
.build();
- wTx.put(LogicalDatastoreType.CONFIGURATION,
+ writeTx.put(LogicalDatastoreType.CONFIGURATION,
IidFactory.providerNamedSelectorIid(epgKey.getTenantId(), epgKey.getEpgId(),
providerNamedSelector.getName()), providerNamedSelector, true);
}
private void writeConsumerNamedSelectorToEpg(SelectorName consumerSelector, ContractId contractId, EpgKeyDto epgKey,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
ConsumerNamedSelector consumerNamedSelector = new ConsumerNamedSelectorBuilder().setName(consumerSelector)
.setContract(ImmutableList.of(contractId))
.build();
- wTx.put(LogicalDatastoreType.CONFIGURATION,
+ writeTx.put(LogicalDatastoreType.CONFIGURATION,
IidFactory.consumerNamedSelectorIid(epgKey.getTenantId(), epgKey.getEpgId(),
consumerNamedSelector.getName()), consumerNamedSelector, true);
}
@VisibleForTesting
void createClassifierInstanceIfNotExists(TenantId tenantId, ClassifierInstance classifierInstance,
- WriteTransaction wTx) {
+ WriteTransaction writeTx) {
InstanceIdentifier<ClassifierInstance> classifierInstanceIid = IidFactory.classifierInstanceIid(tenantId,
classifierInstance.getName());
if (!createdClassifierInstances.contains(classifierInstanceIid)) {
- wTx.put(LogicalDatastoreType.CONFIGURATION, classifierInstanceIid, classifierInstance, true);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, classifierInstanceIid, classifierInstance, true);
}
createdClassifierInstances.add(classifierInstanceIid);
}
if (secRule.getRemoteGroupId() != null) {
Uuid consumerSecGroupId = secRule.getRemoteGroupId();
- undesignContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, secRule, neutron, rwTx);
- undesignContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, secRule, neutron, rwTx);
+ undesignContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, secRule,
+ neutron, rwTx);
+ undesignContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, secRule,
+ neutron, rwTx);
} else {
for (Uuid consumerSecGroupId : SecurityRuleUtils.findSecurityGroupsHavingSecurityRules(neutron)) {
- undesignContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, secRule, neutron, rwTx);
- undesignContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, secRule, neutron, rwTx);
+ undesignContractsBetweenProviderAndConsumer(tenantId, providerSecGroupId, consumerSecGroupId, secRule,
+ neutron, rwTx);
+ undesignContractsBetweenProviderAndConsumer(tenantId, consumerSecGroupId, providerSecGroupId, secRule,
+ neutron, rwTx);
}
}
Set<SecurityRule> consSecRules = getProvidedSecRulesBetween(consSecGroupId, provSecGroupId, neutron);
EndpointGroupId consEpgId = new EndpointGroupId(consSecGroupId.getValue());
for (SecurityRule provSecRule : provSecRules) {
- if (isProvidersSecRuleSuitableForConsumersSecRulesAndGoodToRemove(provSecRule, consSecRules, removedSecRule)) {
+ if (isProvidersSecRuleSuitableForConsumersSecRulesAndGoodToRemove(provSecRule, consSecRules,
+ removedSecRule)) {
SelectorName consumerSelector = getSelectorNameWithProvider(provSecRule, neutron);
deleteConsumerNamedSelector(consumerSelector, new EpgKeyDto(consEpgId, tenantId), rwTx);
}
@VisibleForTesting
static boolean isOneWithinTwo(SecurityRule one, SecurityRule two) {
- if (!isOneGroupIdWithinTwoRemoteGroupId(one, two) || !isOneGroupIdWithinTwoRemoteGroupId(two, one))
+ if (!isOneGroupIdWithinTwoRemoteGroupId(one, two) || !isOneGroupIdWithinTwoRemoteGroupId(two, one)) {
return false;
- if (!SecRuleEntityDecoder.isEtherTypeOfOneWithinTwo(one, two))
+ }
+ if (!SecRuleEntityDecoder.isEtherTypeOfOneWithinTwo(one, two)) {
return false;
- if (!SecRuleEntityDecoder.isProtocolOfOneWithinTwo(one, two))
+ }
+ if (!SecRuleEntityDecoder.isProtocolOfOneWithinTwo(one, two)) {
return false;
- if (!SecRuleEntityDecoder.isPortsOfOneWithinTwo(one, two))
+ }
+ if (!SecRuleEntityDecoder.isPortsOfOneWithinTwo(one, two)) {
return false;
+ }
if (two.getRemoteIpPrefix() != null
- && one.getRemoteIpPrefix() == null)
+ && one.getRemoteIpPrefix() == null) {
return false;
+ }
return true;
}
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.collect.ImmutableList;
+
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmpV6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.SecurityRuleAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
-import com.google.common.collect.ImmutableList;
-
public class SecRuleEntityDecoder {
private SecRuleEntityDecoder() {
- throw new UnsupportedOperationException("Cannot create an instace.");
+ throw new UnsupportedOperationException("Cannot create an instance.");
}
public static ContractId getContractId(SecurityRule secRule) {
.setIntValue(portMin.longValue())
.build());
} else {
- params.add(new ParameterValueBuilder().setName(new ParameterName(L4ClassifierDefinition.DST_PORT_RANGE_PARAM))
+ params.add(new ParameterValueBuilder()
+ .setName(new ParameterName(L4ClassifierDefinition.DST_PORT_RANGE_PARAM))
.setRangeValue(
new RangeValueBuilder().setMin(portMin.longValue()).setMax(portMax.longValue()).build())
.build());
if (classifierBuilder.getClassifierDefinitionId() == null) {
classifierBuilder.setClassifierDefinitionId(IpProtoClassifierDefinition.DEFINITION.getId());
}
- params.add(new ParameterValueBuilder().setName(new ParameterName(IpProtoClassifierDefinition.PROTO_PARAM))
+ params.add(new ParameterValueBuilder()
+ .setName(new ParameterName(IpProtoClassifierDefinition.PROTO_PARAM))
.setIntValue(protocol)
.build());
}
if (classifierBuilder.getClassifierDefinitionId() == null) {
classifierBuilder.setClassifierDefinitionId(EtherTypeClassifierDefinition.DEFINITION.getId());
}
- params.add(new ParameterValueBuilder().setName(new ParameterName(EtherTypeClassifierDefinition.ETHERTYPE_PARAM))
+ params.add(new ParameterValueBuilder()
+ .setName(new ParameterName(EtherTypeClassifierDefinition.ETHERTYPE_PARAM))
.setIntValue(ethertype)
.build());
}
}
public static ActionRef createActionRefFromActionChoice(ActionChoice action) {
- if(action instanceof SfcActionCase){
+ if (action instanceof SfcActionCase) {
return MappingUtils.createSfcActionRef(((SfcActionCase) action).getSfcChainName());
} else if (action instanceof AllowActionCase) {
return MappingUtils.ACTION_REF_ALLOW;
}
/**
- * @param secRule
+ * Resolves Direction for provided secRule.
+ *
+ * @param secRule rule for which Direction is resolved.
* @return direction resolved from {@link SecurityRule#getDirection()}
* @throws IllegalArgumentException if return value of
* {@link SecurityRule#getDirection()} is other than {@link DirectionIngress} or
}
/**
+ * Resolves Clause for provided secRule.
+ *
* @param secRule {@link SecurityRule#getRemoteIpPrefix()} is used for EIC
* and subject selection
* @return clause with the subject and with a consumer matcher containing EIC
public static Clause getClause(SecurityRule secRule) {
checkNotNull(secRule);
SubjectName subjectName = SecRuleNameDecoder.getSubjectName(secRule);
- ClauseBuilder clauseBuilder =
- new ClauseBuilder().setSubjectRefs(ImmutableList.of(subjectName)).setName(SecRuleNameDecoder.getClauseName(secRule));
+ ClauseBuilder clauseBuilder = new ClauseBuilder()
+ .setSubjectRefs(ImmutableList.of(subjectName))
+ .setName(SecRuleNameDecoder
+ .getClauseName(secRule));
IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix();
if (remoteIpPrefix != null) {
clauseBuilder.setConsumerMatchers(createConsumerMatchersWithEic(remoteIpPrefix));
}
private static <T> boolean twoIsNullOrEqualsOne(T one, T two) {
- if (two == null)
+ if (two == null) {
return true;
- if (two.equals(one))
+ }
+ if (two.equals(one)) {
return true;
+ }
return false;
}
}
/**
- * @param secRule
+ * Resolves EtherType for provided secRule.
+ *
+ * @param secRule rule for which EtherType is resolved.
* @return {@code null} if {@link SecurityRule#getEthertype()} is null; Otherwise ethertype
* number
* @throws IllegalArgumentException if return value of
}
/**
- * @param secRule
+ * Resolves Protocol for provided secRule.
+ *
+ * @param secRule rule for which Protocol is resolved.
* @return {@code null} if {@link SecurityRule#getProtocol()} is null; Otherwise protocol number
* @throws IllegalArgumentException if return value of
* {@link SecurityRule#getProtocol()} is other than {@link ProtocolTcp},
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SubjectName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.HasDirection.Direction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.SecurityRuleAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
public class SecRuleNameDecoder {
- final static String MIN_PORT = "_min";
- final static String MAX_PORT = "_max";
+ static final String MIN_PORT = "_min";
+ static final String MAX_PORT = "_max";
private SecRuleNameDecoder() {
throw new UnsupportedOperationException("Cannot create an instance.");
package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
+
import java.util.List;
import javax.annotation.concurrent.Immutable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableList;
-
@Immutable
public class SingleClassifierRule {
private static boolean isRangePortParam(ParameterValue pv) {
String pvName = pv.getName().getValue();
- return pv.getRangeValue() != null
- && (pvName.equals(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM) || pvName.equals(L4ClassifierDefinition.DST_PORT_RANGE_PARAM));
+ return pv.getRangeValue() != null && (pvName.equals(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM)
+ || pvName.equals(L4ClassifierDefinition.DST_PORT_RANGE_PARAM));
}
private static boolean isSrcOrDstPortParam(ParameterValue pv) {
String pvName = pv.getName().getValue();
- return pv.getIntValue() != null
- && (pvName.equals(L4ClassifierDefinition.SRC_PORT_PARAM) || pvName.equals(L4ClassifierDefinition.DST_PORT_PARAM));
+ return pv.getIntValue() != null && (pvName.equals(L4ClassifierDefinition.SRC_PORT_PARAM)
+ || pvName.equals(L4ClassifierDefinition.DST_PORT_PARAM));
}
}
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.collect.ImmutableList;
+
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.subject.Rule;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
-import com.google.common.collect.ImmutableList;
-
@Immutable
public class SingleRuleContract {
private final Clause clause;
private final Contract contract;
- public SingleRuleContract(SecurityRule secRule, int subjectAndRuleOrder, @Nullable Description contractDescription, ActionChoice action) {
+ public SingleRuleContract(SecurityRule secRule, int subjectAndRuleOrder, @Nullable Description contractDescription,
+ ActionChoice action) {
this(secRule, new SingleClassifierRule(secRule, subjectAndRuleOrder, action), contractDescription);
}
package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension;
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
public class NetworkUtils {
public static List<Network> findRouterExternalNetworks(@Nullable Networks networks) {
package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
+import com.google.common.base.Optional;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
-import com.google.common.base.Optional;
-
public class PortUtils {
public static final String DEVICE_OWNER_DHCP = "network:dhcp";
package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
+import com.google.common.base.Optional;
+
import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
-import com.google.common.base.Optional;
-
public class RouterUtils {
public static Optional<Router> findRouter(Uuid uuid, @Nullable Routers routers) {
package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+
import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.SecurityGroups;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroup;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-
public class SecurityGroupUtils {
public static Optional<SecurityGroup> findSecurityGroup(Uuid secGrpUuid, @Nullable SecurityGroups securityGroups) {
package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.SecurityRules;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.FluentIterable;
-
public class SecurityRuleUtils {
public static Optional<SecurityRule> findSecurityRule(Uuid uuid, @Nullable SecurityRules securityRules) {
package org.opendaylight.groupbasedpolicy.neutron.mapper.util;
+import com.google.common.base.Optional;
+
import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
-import com.google.common.base.Optional;
-
public class SubnetUtils {
public static Optional<Subnet> findSubnet(Uuid uuid, @Nullable Subnets subnets) {
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.net.InetAddresses;
+
import java.net.Inet4Address;
import java.net.InetAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.net.InetAddresses;
-
public class Utils {
private static final String MASK_32 = "/32";
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.BaseEndpointsByPorts;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.EndpointsByPorts;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.base.endpoints.by.ports.BaseEndpointByPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.base.endpoints.by.ports.BaseEndpointByPortKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.gbp.by.neutron.mappings.endpoints.by.ports.EndpointByPort;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.ExternalGatewaysAsEndpoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.ExternalGatewaysAsL3Endpoints;
UniqueId portId = mock(UniqueId.class);
InstanceIdentifier<EndpointByPort> id = NeutronGbpIidFactory.endpointByPortIid(portId);
assertNotNull(id);
- Class<?>[] expectedTypes = {Mappings.class, GbpByNeutronMappings.class, EndpointsByPorts.class,
- EndpointByPort.class};
+ Class<?>[] expectedTypes =
+ {Mappings.class, GbpByNeutronMappings.class, EndpointsByPorts.class, EndpointByPort.class};
assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
assertEquals(EndpointByPort.class, id.getTargetType());
assertFalse(id.isWildcarded());
MacAddress mac = mock(MacAddress.class);
InstanceIdentifier<PortByEndpoint> id = NeutronGbpIidFactory.portByEndpointIid(l2BdId, mac);
assertNotNull(id);
- Class<?>[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, PortsByEndpoints.class,
- PortByEndpoint.class};
+ Class<?>[] expectedTypes =
+ {Mappings.class, NeutronByGbpMappings.class, PortsByEndpoints.class, PortByEndpoint.class};
assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
assertEquals(PortByEndpoint.class, id.getTargetType());
assertFalse(id.isWildcarded());
public void portByBaseEndpointIidTest() {
String address = "00:00:00:00:00:00:01";
ContextId ctxId = new ContextId("00000000-1111-2222-3333-44444555566667777");
- PortByBaseEndpointKey key = new PortByBaseEndpointKey(address, MacAddressType.class, ctxId, MappingUtils.L2_BRDIGE_DOMAIN);
+ PortByBaseEndpointKey key =
+ new PortByBaseEndpointKey(address, MacAddressType.class, ctxId, MappingUtils.L2_BRDIGE_DOMAIN);
InstanceIdentifier<PortByBaseEndpoint> id = NeutronGbpIidFactory.portByBaseEndpointIid(key);
assertNotNull(id);
- Class<?>[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, PortsByBaseEndpoints.class,
- PortByBaseEndpoint.class};
+ Class<?>[] expectedTypes =
+ {Mappings.class, NeutronByGbpMappings.class, PortsByBaseEndpoints.class, PortByBaseEndpoint.class};
assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
assertEquals(PortByBaseEndpoint.class, id.getTargetType());
assertFalse(id.isWildcarded());
InstanceIdentifier<BaseEndpointByPort> id = NeutronGbpIidFactory.baseEndpointByPortIid(portId);
assertNotNull(id);
- Class<?>[] expectedTypes = {Mappings.class, GbpByNeutronMappings.class, BaseEndpointsByPorts.class,
- BaseEndpointByPort.class};
+ Class<?>[] expectedTypes =
+ {Mappings.class, GbpByNeutronMappings.class, BaseEndpointsByPorts.class, BaseEndpointByPort.class};
assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
assertEquals(BaseEndpointByPort.class, id.getTargetType());
assertFalse(id.isWildcarded());
InstanceIdentifier<ExternalGatewayAsL3Endpoint> id = NeutronGbpIidFactory.externalGatewayAsL3Endpoint(
l3Context, ipAddress);
assertNotNull(id);
- Class<?>[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsL3Endpoints.class,
+ Class<?>[] expectedTypes =
+ {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsL3Endpoints.class,
ExternalGatewayAsL3Endpoint.class};
assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
assertEquals(ExternalGatewayAsL3Endpoint.class, id.getTargetType());
String ipAddress = "192.168.50.20/32";
IpPrefix ipPrefix = new IpPrefix(ipAddress.toCharArray());
ContextId ctxId = new ContextId("00000000-1111-2222-3333-44444555566667777");
- InstanceIdentifier<ExternalGatewayAsEndpoint> id = NeutronGbpIidFactory.externalGatewayAsEndpoint(
- ctxId, ipPrefix, MappingUtils.L3_CONTEXT);
+ InstanceIdentifier<ExternalGatewayAsEndpoint> id =
+ NeutronGbpIidFactory.externalGatewayAsEndpoint(ctxId, ipPrefix, MappingUtils.L3_CONTEXT);
assertNotNull(id);
- Class<?>[] expectedTypes = {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsEndpoints.class,
+ Class<?>[] expectedTypes =
+ {Mappings.class, NeutronByGbpMappings.class, ExternalGatewaysAsEndpoints.class,
ExternalGatewayAsEndpoint.class};
assertPathArgumentTypes(id.getPathArguments(), expectedTypes);
assertEquals(ExternalGatewayAsEndpoint.class, id.getTargetType());
assertFalse(id.isWildcarded());
- assertEquals(ctxId, id.firstKeyOf(ExternalGatewayAsEndpoint.class)
- .getContextId());
- assertEquals(MappingUtils.L3_CONTEXT, id.firstKeyOf(ExternalGatewayAsEndpoint.class)
- .getContextType());
- assertEquals(ipAddress, id.firstKeyOf(ExternalGatewayAsEndpoint.class)
- .getAddress());
- assertEquals(IpPrefixType.class, id.firstKeyOf(ExternalGatewayAsEndpoint.class)
- .getAddressType());
+ assertEquals(ctxId, id.firstKeyOf(ExternalGatewayAsEndpoint.class).getContextId());
+ assertEquals(MappingUtils.L3_CONTEXT, id.firstKeyOf(ExternalGatewayAsEndpoint.class).getContextType());
+ assertEquals(ipAddress, id.firstKeyOf(ExternalGatewayAsEndpoint.class).getAddress());
+ assertEquals(IpPrefixType.class, id.firstKeyOf(ExternalGatewayAsEndpoint.class).getAddressType());
}
private static void assertPathArgumentTypes(Iterable<PathArgument> pathArguments, Class<?>[] expectedTypes) {
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
import java.io.IOException;
import java.util.Set;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroupBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
public class NeutronMapperTest extends NeutronMapperDataBrokerTest {
private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
}
private Optional<L3Context> getL3ContextOptional(Network network) {
- ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
TenantId tenantId = new TenantId(network.getTenantId().getValue());
ContextId l3CtxId = new ContextId(network.getUuid().getValue());
L3ContextId l3ContextId = new L3ContextId(l3CtxId);
InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
- return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, rTx);
+ return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, readTx);
}
}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.common.base.Optional;
+
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import com.google.common.base.Optional;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
import org.opendaylight.groupbasedpolicy.util.IidFactory;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId;
private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
private final Uuid networkUuid = new Uuid("dddddddd-dddd-dddd-dddd-dddddddddddd");
private static final long METADATA_IPV4_SERVER_PORT = 80;
- private static final IpPrefix METADATA_IP_PREFIX = new IpPrefix(new Ipv4Prefix("169.254.169.254/32"));
private DataBroker dataBroker;
private NeutronNetworkAware networkAware;
}
private Optional<L3Context> getL3ContextOptional(Network network) {
- ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
TenantId tenantId = new TenantId(network.getTenantId().getValue());
ContextId l3CtxId = new ContextId(network.getUuid().getValue());
L3ContextId l3ContextId = new L3ContextId(l3CtxId);
InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
- return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, rTx);
+ return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, readTx);
}
}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.common.collect.ImmutableList;
+
import java.util.Collections;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetBuilder;
-import com.google.common.collect.ImmutableList;
-
public class NeutronPortAwareDataStoreTest extends NeutronMapperDataBrokerTest {
private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
private Neutron neutron;
@Before
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public void init() {
dataBroker = getDataBroker();
neutron = mock(Neutron.class);
epRegistrator = mock(EndpointRegistrator.class);
when(epRegistrator.registerEndpoint(any(RegisterEndpointInput.class))).thenReturn(true);
when(epRegistrator.registerEndpoint(
- any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput.class)))
- .thenReturn(true);
+ any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput.class)))
+ .thenReturn(true);
when(epRegistrator.unregisterEndpoint(any(UnregisterEndpointInput.class))).thenReturn(true);
when(epRegistrator.unregisterEndpoint(
- any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput.class)))
- .thenReturn(true);
+ any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput.class)))
+ .thenReturn(true);
portAware = new NeutronPortAware(dataBroker, epRegistrator, new IpPrefix(new Ipv4Prefix("192.168.192.168/32")));
}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
import org.opendaylight.groupbasedpolicy.util.IidFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.BaseEndpointService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
public class NeutronRouterAwareDataStoreTest extends NeutronMapperDataBrokerTest {
- private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
- private final Uuid routerUuid = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
- private final Uuid newRouterUuid = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbb2");
- private final Uuid subnetUuid = new Uuid("cccccccc-cccc-cccc-cccc-cccccccccccc");
- private final Uuid networkUuid = new Uuid("dddddddd-dddd-dddd-dddd-dddddddddddd");
- private final Uuid gatewayPortUuid = new Uuid("dddddddd-dddd-dddd-dddd-ddddddddddd1");
- private final IpAddress ipAddress = new IpAddress(new Ipv4Address("10.0.0.2"));
+ private static final Uuid TENANT_UUID = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
+ private static final Uuid ROUTER_UUID = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
+ private static final Uuid NEW_ROUTER_UUID = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbb2");
+ private static final Uuid SUBNET_UUID = new Uuid("cccccccc-cccc-cccc-cccc-cccccccccccc");
+ private static final Uuid NETWORK_UUID = new Uuid("dddddddd-dddd-dddd-dddd-dddddddddddd");
+ private static final Uuid GATEWAY_PORT_UUID = new Uuid("dddddddd-dddd-dddd-dddd-ddddddddddd1");
+ private static final IpAddress IP_ADDRESS = new IpAddress(new Ipv4Address("10.0.0.2"));
private static final long METADATA_IPV4_SERVER_PORT = 80;
- private static final IpPrefix METADATA_IP_PREFIX = new IpPrefix(new Ipv4Prefix("169.254.169.254/32"));
private DataBroker dataBroker;
private NeutronRouterAware routerAware;
private Network network;
@Before
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public void init() throws ExecutionException, InterruptedException {
futureRpcResult = mock(Future.class);
futureRpcFail = mock(Future.class);
epRegistrator = new EndpointRegistrator(epService, baseEpService);
networkAware = new NeutronNetworkAware(dataBroker, METADATA_IPV4_SERVER_PORT);
- network = new NetworkBuilder().setTenantId(tenantUuid).setUuid(networkUuid).setName("networkName").build();
+ network = new NetworkBuilder().setTenantId(TENANT_UUID).setUuid(NETWORK_UUID).setName("networkName").build();
routerAware = new NeutronRouterAware(dataBroker, epRegistrator);
}
@Test
public void testOnCreated() {
- Router router = new RouterBuilder().setTenantId(tenantUuid).setName("routerName").setUuid(routerUuid).build();
+ Router router = new RouterBuilder().setTenantId(TENANT_UUID).setName("routerName").setUuid(ROUTER_UUID).build();
routerAware.onCreated(router, neutron);
@Test
public void testOnCreated_incorrectName() {
- Router router = new RouterBuilder().setTenantId(tenantUuid).setName("123").setUuid(routerUuid).build();
+ Router router = new RouterBuilder().setTenantId(TENANT_UUID).setName("123").setUuid(ROUTER_UUID).build();
routerAware.onCreated(router, neutron);
when(neutron.getSubnets()).thenReturn(subnets);
when(neutron.getNetworks()).thenReturn(new NetworksBuilder().setNetwork(ImmutableList.of(network)).build());
- FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).setSubnetId(subnetUuid).build();
- Port port = new PortBuilder().setUuid(gatewayPortUuid).setFixedIps(ImmutableList.of(fixedIps)).build();
+ FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).setSubnetId(SUBNET_UUID).build();
+ Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).setFixedIps(ImmutableList.of(fixedIps)).build();
Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
when(neutron.getPorts()).thenReturn(ports);
Router oldRouter =
- new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
- Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
- .setName("newRouterName")
- .setUuid(newRouterUuid)
- .setGatewayPortId(gatewayPortUuid)
- .build();
+ new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
networkAware.onCreated(network, neutron);
routerAware.onCreated(oldRouter, neutron);
assertRouterExists(oldRouter);
+
+ Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
+ .setName("newRouterName")
+ .setUuid(NEW_ROUTER_UUID)
+ .setGatewayPortId(GATEWAY_PORT_UUID)
+ .build();
+
assertRouterNotExists(newRouter);
routerAware.onUpdated(oldRouter, newRouter, neutron, neutron);
Subnets subnets = createSubnets();
when(neutron.getSubnets()).thenReturn(subnets);
- FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).setSubnetId(subnetUuid).build();
+ FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).setSubnetId(SUBNET_UUID).build();
Port port = new PortBuilder().setUuid(new Uuid("dddddddd-dddd-dddd-dddd-000000000000"))
.setFixedIps(ImmutableList.of(fixedIps))
.build();
when(neutron.getPorts()).thenReturn(ports);
Router oldRouter =
- new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
- Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+ new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+ Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
.setName("newRouterName")
- .setUuid(newRouterUuid)
- .setGatewayPortId(gatewayPortUuid)
+ .setUuid(NEW_ROUTER_UUID)
+ .setGatewayPortId(GATEWAY_PORT_UUID)
.build();
routerAware.onCreated(oldRouter, neutron);
Subnets subnets = createSubnets();
when(neutron.getSubnets()).thenReturn(subnets);
- Port port = new PortBuilder().setUuid(gatewayPortUuid).build();
+ Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).build();
Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
when(neutron.getPorts()).thenReturn(ports);
Router oldRouter =
- new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
- Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+ new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+ Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
.setName("newRouterName")
- .setUuid(newRouterUuid)
- .setGatewayPortId(gatewayPortUuid)
+ .setUuid(NEW_ROUTER_UUID)
+ .setGatewayPortId(GATEWAY_PORT_UUID)
.build();
routerAware.onCreated(oldRouter, neutron);
Subnets subnets = createSubnets();
when(neutron.getSubnets()).thenReturn(subnets);
- FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).build();
- Port port = new PortBuilder().setUuid(gatewayPortUuid).setFixedIps(ImmutableList.of(fixedIps)).build();
+ FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).build();
+ Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).setFixedIps(ImmutableList.of(fixedIps)).build();
Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
when(neutron.getPorts()).thenReturn(ports);
Router oldRouter =
- new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
- Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+ new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+ Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
.setName("newRouterName")
- .setUuid(newRouterUuid)
- .setGatewayPortId(gatewayPortUuid)
+ .setUuid(NEW_ROUTER_UUID)
+ .setGatewayPortId(GATEWAY_PORT_UUID)
.build();
routerAware.onCreated(oldRouter, neutron);
}
@Test
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public void testOnUpdated_ExtGatewayNotRegistered() {
when(baseEpService.registerEndpoint(
any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.RegisterEndpointInput.class)))
Subnets subnets = createSubnets();
when(neutron.getSubnets()).thenReturn(subnets);
- FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).setSubnetId(subnetUuid).build();
- Port port = new PortBuilder().setUuid(gatewayPortUuid).setFixedIps(ImmutableList.of(fixedIps)).build();
+ FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).setSubnetId(SUBNET_UUID).build();
+ Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).setFixedIps(ImmutableList.of(fixedIps)).build();
Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
when(neutron.getPorts()).thenReturn(ports);
Router oldRouter =
- new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
- Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+ new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+ Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
.setName("newRouterName")
- .setUuid(newRouterUuid)
- .setGatewayPortId(gatewayPortUuid)
+ .setUuid(NEW_ROUTER_UUID)
+ .setGatewayPortId(GATEWAY_PORT_UUID)
.build();
routerAware.onCreated(oldRouter, neutron);
when(neutron.getSubnets()).thenReturn(subnets);
when(neutron.getNetworks()).thenReturn(new NetworksBuilder().setNetwork(ImmutableList.of(network)).build());
- FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(ipAddress).setSubnetId(subnetUuid).build();
- Port port = new PortBuilder().setUuid(gatewayPortUuid).setFixedIps(ImmutableList.of(fixedIps)).build();
+ FixedIps fixedIps = new FixedIpsBuilder().setIpAddress(IP_ADDRESS).setSubnetId(SUBNET_UUID).build();
+ Port port = new PortBuilder().setUuid(GATEWAY_PORT_UUID).setFixedIps(ImmutableList.of(fixedIps)).build();
Ports ports = new PortsBuilder().setPort(ImmutableList.of(port)).build();
when(neutron.getPorts()).thenReturn(ports);
Router oldRouter =
- new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
- Router newRouter = new RouterBuilder().setTenantId(tenantUuid)
+ new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
+ Router newRouter = new RouterBuilder().setTenantId(TENANT_UUID)
.setName("newRouterName")
- .setUuid(newRouterUuid)
- .setGatewayPortId(gatewayPortUuid)
+ .setUuid(NEW_ROUTER_UUID)
+ .setGatewayPortId(GATEWAY_PORT_UUID)
.build();
routerAware.onCreated(oldRouter, neutron);
@Test
public void testOnDeleted() {
Router router =
- new RouterBuilder().setTenantId(tenantUuid).setName("oldRouterName").setUuid(routerUuid).build();
+ new RouterBuilder().setTenantId(TENANT_UUID).setName("oldRouterName").setUuid(ROUTER_UUID).build();
routerAware.onCreated(router, neutron);
routerAware.onDeleted(router, neutron, neutron);
}
private Subnets createSubnets() {
- Subnet subnet = new SubnetBuilder().setTenantId(tenantUuid)
- .setUuid(subnetUuid)
+ Subnet subnet = new SubnetBuilder().setTenantId(TENANT_UUID)
+ .setUuid(SUBNET_UUID)
.setName("subnetName")
- .setNetworkId(networkUuid)
- .setGatewayIp(ipAddress)
+ .setNetworkId(NETWORK_UUID)
+ .setGatewayIp(IP_ADDRESS)
.setCidr(Utils.createIpPrefix("10.0.0.0/24"))
.build();
return new SubnetsBuilder().setSubnet(ImmutableList.of(subnet)).build();
}
private Optional<L3Context> getL3ContextOptional(Router router) {
- ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
TenantId tenantId = new TenantId(router.getTenantId().getValue());
ContextId routerL3CtxId = new ContextId(router.getUuid().getValue());
L3ContextId l3ContextId = new L3ContextId(routerL3CtxId);
InstanceIdentifier<L3Context> l3ContextIid = IidFactory.l3ContextIid(tenantId, l3ContextId);
- return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, rTx);
+ return DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l3ContextIid, readTx);
}
}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.apache.commons.lang3.StringUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
import org.opendaylight.groupbasedpolicy.neutron.mapper.EndpointRegistrator;
import org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.rule.NeutronSecurityRuleAware;
import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronEntityFactory;
+import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
import org.opendaylight.groupbasedpolicy.neutron.mapper.test.PolicyAssert;
import org.opendaylight.groupbasedpolicy.neutron.mapper.util.MappingUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
private EndpointRegistrator epRegistrator;
@Before
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public void init() {
dataBroker = getDataBroker();
@Test
public void testAddNeutronSecurityGroup_incorrectNameDescription() throws Exception {
String uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd";
- String longDescription = StringUtils.repeat("a", 4100);
SecurityGroup secGroupA = new SecurityGroupBuilder().setUuid(new Uuid(uuid))
.setTenantId(new Uuid(tenantId))
.setName("123")
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.common.collect.ImmutableList;
+
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import com.google.common.collect.ImmutableList;
-
public class NeutronSubnetAwareDataStoreTest extends NeutronMapperDataBrokerTest {
- private static final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
- private static final Uuid networkUuid = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
- private static final Uuid subnetUuid = new Uuid("cccccccc-cccc-cccc-cccc-cccccccccccc");
- private static final Uuid subnetUuid2 = new Uuid("cccccccc-cccc-cccc-cccc-ccccccccccc2");
- private static final IpAddress ipAddress = new IpAddress(new Ipv4Address("10.0.0.2"));
- private static final IpAddress ipAddress2 = new IpAddress(new Ipv4Address("10.0.2.2"));
- private static final IpPrefix ipPrefix = new IpPrefix(new Ipv4Prefix("10.0.0.0/24"));
+ private static final Uuid TENANT_UUID = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
+ private static final Uuid NETWORK_UUID = new Uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
+ private static final Uuid SUBNET_UUID = new Uuid("cccccccc-cccc-cccc-cccc-cccccccccccc");
+ private static final Uuid SUBNET_UUID_2 = new Uuid("cccccccc-cccc-cccc-cccc-ccccccccccc2");
+ private static final IpAddress IP_ADDRESS = new IpAddress(new Ipv4Address("10.0.0.2"));
+ private static final IpAddress IP_ADDRESS_2 = new IpAddress(new Ipv4Address("10.0.2.2"));
+ private static final IpPrefix IP_PREFIX = new IpPrefix(new Ipv4Prefix("10.0.0.0/24"));
private DataBroker dataBroker;
private Neutron neutron;
private RpcResult<Void> rpcResult;
private RpcResult<Void> rpcFail;
private NeutronSubnetAware subnetAware;
- private static final Subnet subnet = new SubnetBuilder().setTenantId(tenantUuid)
- .setUuid(subnetUuid)
+ private static final Subnet SUBNET = new SubnetBuilder().setTenantId(TENANT_UUID)
+ .setUuid(SUBNET_UUID)
.setName("subnetName")
- .setNetworkId(networkUuid)
- .setGatewayIp(ipAddress)
- .setCidr(ipPrefix)
+ .setNetworkId(NETWORK_UUID)
+ .setGatewayIp(IP_ADDRESS)
+ .setCidr(IP_PREFIX)
.build();
- private static final Subnet subnet2 = new SubnetBuilder().setTenantId(tenantUuid)
- .setUuid(subnetUuid2)
+ private static final Subnet SUBNET_2 = new SubnetBuilder().setTenantId(TENANT_UUID)
+ .setUuid(SUBNET_UUID_2)
.setName("subnetName2")
- .setNetworkId(networkUuid)
- .setGatewayIp(ipAddress2)
- .setCidr(ipPrefix)
+ .setNetworkId(NETWORK_UUID)
+ .setGatewayIp(IP_ADDRESS_2)
+ .setCidr(IP_PREFIX)
.build();
@Before
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
public void init() throws ExecutionException, InterruptedException {
futureRpcResult = mock(Future.class);
rpcResult = mock(RpcResult.class);
NetworkProviderExtension networkProviderExtension =
new NetworkProviderExtensionBuilder().setPhysicalNetwork("physicalNetwork").build();
- Network network = new NetworkBuilder().setUuid(networkUuid)
+ Network network = new NetworkBuilder().setUuid(NETWORK_UUID)
.addAugmentation(NetworkProviderExtension.class, networkProviderExtension)
.build();
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of(network)).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
}
@Test
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of()).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
}
@Test
public void testOnUpdated() {
- Network network = new NetworkBuilder().setUuid(networkUuid).build();
+ Network network = new NetworkBuilder().setUuid(NETWORK_UUID).build();
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of(network)).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
- NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, tenantUuid, subnet2, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, TENANT_UUID, SUBNET_2, neutron, null);
- subnetAware.onUpdated(subnet, subnet2, neutron, neutron);
+ subnetAware.onUpdated(SUBNET, SUBNET_2, neutron, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet2, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET_2, neutron, null);
}
@Test
public void testOnDeleted() {
- Network network = new NetworkBuilder().setUuid(networkUuid).build();
+ Network network = new NetworkBuilder().setUuid(NETWORK_UUID).build();
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of(network)).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
- subnetAware.onDeleted(subnet, neutron, neutron);
+ subnetAware.onDeleted(SUBNET, neutron, neutron);
- NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainNotExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
}
+
@Test
public void testOnDeleted_wrongSubnet() {
- Network network = new NetworkBuilder().setUuid(networkUuid).build();
+ Network network = new NetworkBuilder().setUuid(NETWORK_UUID).build();
Networks networks = new NetworksBuilder().setNetwork(ImmutableList.of(network)).build();
when(neutron.getNetworks()).thenReturn(networks);
- subnetAware.onCreated(subnet, neutron);
+ subnetAware.onCreated(SUBNET, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
- subnetAware.onDeleted(subnet2, neutron, neutron);
+ subnetAware.onDeleted(SUBNET_2, neutron, neutron);
- NeutronMapperAssert.assertNetworkDomainExists(dataBroker, tenantUuid, subnet, neutron, null);
+ NeutronMapperAssert.assertNetworkDomainExists(dataBroker, TENANT_UUID, SUBNET, neutron, null);
}
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRuleBuilder;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
/**
- * END 2 END TESTING - inputs are Neutron entities and expected outputs are GBP entities in
- * datastore
+ * END 2 END TESTING - inputs are Neutron entities and expected outputs are GBP entities in datastore.
*/
public class NeutronSecurityRuleAwareDataStoreTest extends NeutronMapperDataBrokerTest {
@Test
public final void testAddNeutronSecurityRule_rulesWithRemoteIpPrefix() throws Exception {
- String tenant = "ad4c6c25-2424-4ad3-97ee-f9691ce03645";
- String goldSecGrp = "fe40e28f-ad6a-4a2d-b12a-47510876344a";
- SecurityRule goldInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
- null);
- SecurityRule goldOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
- null);
- String serverSecGrp = "71cf4fe5-b146-409e-8151-cd921298ce32";
- SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class);
- SecurityRule serverIn80Tcp10_1_1_0 = new SecurityRuleBuilder().setUuid(new Uuid("9dbb533d-d9b2-4dc9-bae7-ee60c8df184d"))
- .setTenantId(new Uuid(tenant))
- .setEthertype(EthertypeV4.class)
- .setProtocol(protocolTcp)
- .setPortRangeMin(80)
- .setPortRangeMax(80)
- .setDirection(DirectionIngress.class)
- .setSecurityGroupId(new Uuid(serverSecGrp))
- .setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("10.1.1.0/24")))
- .build();
- SecurityRule serverInIp20_1_1_0 = new SecurityRuleBuilder().setUuid(new Uuid("adf7e558-de47-4f9e-a9b8-96e19db5d1ac"))
- .setTenantId(new Uuid(tenant))
- .setEthertype(EthertypeV4.class)
- .setDirection(DirectionIngress.class)
- .setSecurityGroupId(new Uuid(serverSecGrp))
- .setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("20.1.1.0/24")))
- .build();
- SecurityRule serverOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
- null);
+ final String tenant = "ad4c6c25-2424-4ad3-97ee-f9691ce03645";
+ final String goldSecGrp = "fe40e28f-ad6a-4a2d-b12a-47510876344a";
+ final SecurityRule goldInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
+ "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
+ null);
+ final SecurityRule goldOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
+ "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
+ null);
+ final String serverSecGrp = "71cf4fe5-b146-409e-8151-cd921298ce32";
+ final SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class);
+ final SecurityRule serverIn80Tcp10_1_1_0 = new SecurityRuleBuilder()
+ .setUuid(new Uuid("9dbb533d-d9b2-4dc9-bae7-ee60c8df184d"))
+ .setTenantId(new Uuid(tenant))
+ .setEthertype(EthertypeV4.class)
+ .setProtocol(protocolTcp)
+ .setPortRangeMin(80)
+ .setPortRangeMax(80)
+ .setDirection(DirectionIngress.class)
+ .setSecurityGroupId(new Uuid(serverSecGrp))
+ .setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("10.1.1.0/24")))
+ .build();
+ final SecurityRule serverInIp20_1_1_0 = new SecurityRuleBuilder()
+ .setUuid(new Uuid("adf7e558-de47-4f9e-a9b8-96e19db5d1ac"))
+ .setTenantId(new Uuid(tenant))
+ .setEthertype(EthertypeV4.class)
+ .setDirection(DirectionIngress.class)
+ .setSecurityGroupId(new Uuid(serverSecGrp))
+ .setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("20.1.1.0/24")))
+ .build();
+ final SecurityRule serverOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
+ "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
+ null);
DataBroker dataBroker = getDataBroker();
List<SecurityGroup> secGroups = new ArrayList<>();
secGroups.add(NeutronEntityFactory.securityGroup(goldSecGrp, tenant));
final String secRuleId1 = "dddddddd-dddd-dddd-dddd-dddddddddddd";
final String secRuleId2 = "eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee";
- List<SecurityGroup> secGroups = new ArrayList<>();
+ final List<SecurityGroup> secGroups = new ArrayList<>();
secGroups.add(NeutronEntityFactory.securityGroup(secGroupId1, tenantId));
secGroups.add(NeutronEntityFactory.securityGroup(secGroupId2, tenantId));
- SecurityRule secRule1 = NeutronEntityFactory.securityRuleWithEtherType(secRuleId1, tenantId,
+ final SecurityRule secRule1 = NeutronEntityFactory.securityRuleWithEtherType(secRuleId1, tenantId,
EthertypeV4.class, DirectionEgress.class, secGroupId1, secGroupId2);
- SecurityRule secRule2 = NeutronEntityFactory.securityRuleWithEtherType(secRuleId2, tenantId,
+ final SecurityRule secRule2 = NeutronEntityFactory.securityRuleWithEtherType(secRuleId2, tenantId,
EthertypeV4.class, DirectionIngress.class, secGroupId2, secGroupId1);
NeutronBuilder neutronBuilder = new NeutronBuilder()
.setSecurityGroups(new SecurityGroupsBuilder().setSecurityGroup(secGroups).build())
public final void testAddNeutronSecurityRule_rulesWithoutRemote() throws Exception {
String tenant = "ad4c6c25-2424-4ad3-97ee-f9691ce03645";
String goldSecGrp = "fe40e28f-ad6a-4a2d-b12a-47510876344a";
- SecurityRule goldInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
- null);
- SecurityRule goldOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
- null);
+ SecurityRule goldInIpv4 =
+ NeutronEntityFactory.securityRuleWithEtherType("166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant,
+ EthertypeV4.class, DirectionIngress.class, goldSecGrp, null);
+ SecurityRule goldOutIpv4 =
+ NeutronEntityFactory.securityRuleWithEtherType("dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant,
+ EthertypeV4.class, DirectionEgress.class, goldSecGrp, null);
String serverSecGrp = "71cf4fe5-b146-409e-8151-cd921298ce32";
- SecurityRule serverOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
- null);
- SecurityRule serverInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "adf7e558-de47-4f9e-a9b8-96e19db5d1ac", tenant, EthertypeV4.class, DirectionIngress.class, serverSecGrp,
- null);
+ SecurityRule serverOutIpv4 =
+ NeutronEntityFactory.securityRuleWithEtherType("8b9c48d3-44a8-46be-be35-6f3237d98071", tenant,
+ EthertypeV4.class, DirectionEgress.class, serverSecGrp, null);
+ SecurityRule serverInIpv4 =
+ NeutronEntityFactory.securityRuleWithEtherType("adf7e558-de47-4f9e-a9b8-96e19db5d1ac", tenant,
+ EthertypeV4.class, DirectionIngress.class, serverSecGrp, null);
DataBroker dataBroker = getDataBroker();
List<SecurityGroup> secGroups = new ArrayList<>();
secGroups.add(NeutronEntityFactory.securityGroup(goldSecGrp, tenant));
String tenant = "ad4c6c25-2424-4ad3-97ee-f9691ce03645";
String goldSecGrp = "fe40e28f-ad6a-4a2d-b12a-47510876344a";
SecurityRule goldInIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
- null);
+ "166aedab-fdf5-4788-9e36-2b00b5f8722f", tenant, EthertypeV4.class, DirectionIngress.class, goldSecGrp,
+ null);
SecurityRule goldOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
- null);
+ "dabfd4da-af89-45dd-85f8-181768c1b4c9", tenant, EthertypeV4.class, DirectionEgress.class, goldSecGrp,
+ null);
String serverSecGrp = "71cf4fe5-b146-409e-8151-cd921298ce32";
SecurityRule serverOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
- null);
+ "8b9c48d3-44a8-46be-be35-6f3237d98071", tenant, EthertypeV4.class, DirectionEgress.class, serverSecGrp,
+ null);
SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class);
- SecurityRule serverIn80TcpIpv4 = new SecurityRuleBuilder().setUuid(new Uuid("adf7e558-de47-4f9e-a9b8-96e19db5d1ac"))
- .setTenantId(new Uuid(tenant))
- .setEthertype(EthertypeV4.class)
- .setProtocol(protocolTcp)
- .setPortRangeMin(80)
- .setPortRangeMax(80)
- .setDirection(DirectionIngress.class)
- .setSecurityGroupId(new Uuid(serverSecGrp))
- .build();
+ SecurityRule serverIn80TcpIpv4 = new SecurityRuleBuilder()
+ .setUuid(new Uuid("adf7e558-de47-4f9e-a9b8-96e19db5d1ac"))
+ .setTenantId(new Uuid(tenant))
+ .setEthertype(EthertypeV4.class)
+ .setProtocol(protocolTcp)
+ .setPortRangeMin(80)
+ .setPortRangeMax(80)
+ .setDirection(DirectionIngress.class)
+ .setSecurityGroupId(new Uuid(serverSecGrp))
+ .build();
DataBroker dataBroker = getDataBroker();
List<SecurityGroup> secGroups = new ArrayList<>();
secGroups.add(NeutronEntityFactory.securityGroup(goldSecGrp, tenant));
@Test
public final void testAddNeutronSecurityRule_defaultSecGrp() throws Exception {
- String tenant = "111aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa";
- String defaultSecGrp = "111fffff-ffff-ffff-ffff-ffffffffffff";
- SecurityRule defaultInIpv4Default = NeutronEntityFactory.securityRuleWithEtherType(
- "111ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionIngress.class, defaultSecGrp,
- defaultSecGrp);
- SecurityRule defaultInIpv6Default = NeutronEntityFactory.securityRuleWithEtherType(
- "222ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionIngress.class, defaultSecGrp,
- defaultSecGrp);
- SecurityRule defaultOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
- "333ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionEgress.class, defaultSecGrp,
- null);
- SecurityRule defaultOutIpv6 = NeutronEntityFactory.securityRuleWithEtherType(
- "444ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionEgress.class, defaultSecGrp,
- null);
+ final String tenant = "111aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa";
+ final String defaultSecGrp = "111fffff-ffff-ffff-ffff-ffffffffffff";
+ final SecurityRule defaultInIpv4Default = NeutronEntityFactory.securityRuleWithEtherType(
+ "111ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionIngress.class, defaultSecGrp,
+ defaultSecGrp);
+ final SecurityRule defaultInIpv6Default = NeutronEntityFactory.securityRuleWithEtherType(
+ "222ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionIngress.class, defaultSecGrp,
+ defaultSecGrp);
+ final SecurityRule defaultOutIpv4 = NeutronEntityFactory.securityRuleWithEtherType(
+ "333ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionEgress.class, defaultSecGrp,
+ null);
+ final SecurityRule defaultOutIpv6 = NeutronEntityFactory.securityRuleWithEtherType(
+ "444ccccc-111c-cccc-cccc-cccccccccccc", tenant, EthertypeV4.class, DirectionEgress.class, defaultSecGrp,
+ null);
DataBroker dataBroker = getDataBroker();
List<SecurityGroup> secGroups = new ArrayList<>();
secGroups.add(NeutronEntityFactory.securityGroup(defaultSecGrp, tenant));
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.groupbasedpolicy.neutron.mapper.EndpointRegistrator;
import org.opendaylight.groupbasedpolicy.neutron.mapper.test.ConfigDataStoreReader;
-import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronEntityFactory;
+import org.opendaylight.groupbasedpolicy.neutron.mapper.test.NeutronMapperDataBrokerTest;
import org.opendaylight.groupbasedpolicy.neutron.mapper.test.PolicyAssert;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
.append(MappingUtils.NAME_VALUE_DELIMETER)
.append(EthertypeV4.class.getSimpleName())
.toString();
- System.out.println(expectedName);
- System.out.println(ci.getName().getValue());
Assert.assertEquals(expectedName, ci.getName().getValue());
List<ParameterValue> parameterValues = ci.getParameterValue();
Assert.assertNotNull(parameterValues);
Assert.assertTrue("Classifier-instance does not contain destination port parameter", containsDstPortParam);
}
- private final void assertClassifierParameterValue(ParameterValue parameter, Long expectedIntValue,
+ private void assertClassifierParameterValue(ParameterValue parameter, Long expectedIntValue,
String expectedStringValue, RangeValue expectedRangeValue) {
Assert.assertEquals(expectedIntValue, parameter.getIntValue());
Assert.assertEquals(expectedStringValue, parameter.getStringValue());
@Test
public final void testGetEtherType_ethertypeIPv4() {
secRuleBuilder.setEthertype(EthertypeV4.class);
- Assert.assertEquals(EtherTypeClassifierDefinition.IPv4_VALUE, SecRuleEntityDecoder.getEtherType(secRuleBuilder.build()));
+ Assert.assertEquals(EtherTypeClassifierDefinition.IPv4_VALUE,
+ SecRuleEntityDecoder.getEtherType(secRuleBuilder.build()));
}
@Test
public final void testGetEtherType_ethertypeIPv6() {
secRuleBuilder.setEthertype(EthertypeV6.class);
- Assert.assertEquals(EtherTypeClassifierDefinition.IPv6_VALUE, SecRuleEntityDecoder.getEtherType(secRuleBuilder.build()));
+ Assert.assertEquals(EtherTypeClassifierDefinition.IPv6_VALUE,
+ SecRuleEntityDecoder.getEtherType(secRuleBuilder.build()));
}
@Test
public final void testGetProtocol_protoTcp() {
SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class);
secRuleBuilder.setProtocol(protocolTcp);
- Assert.assertEquals(IpProtoClassifierDefinition.TCP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
+ Assert.assertEquals(IpProtoClassifierDefinition.TCP_VALUE,
+ SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
}
@Test
public final void testGetProtocol_protoUdp() {
SecurityRuleAttributes.Protocol protocolUdp = new SecurityRuleAttributes.Protocol(ProtocolUdp.class);
secRuleBuilder.setProtocol(protocolUdp);
- Assert.assertEquals(IpProtoClassifierDefinition.UDP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
+ Assert.assertEquals(IpProtoClassifierDefinition.UDP_VALUE,
+ SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
}
@Test
public final void testGetProtocol_protoIcmp() {
SecurityRuleAttributes.Protocol protocolIcmp = new SecurityRuleAttributes.Protocol(ProtocolIcmp.class);
secRuleBuilder.setProtocol(protocolIcmp);
- Assert.assertEquals(IpProtoClassifierDefinition.ICMP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
+ Assert.assertEquals(IpProtoClassifierDefinition.ICMP_VALUE,
+ SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()));
}
@Test
.append(EtherTypeClassifierDefinition.DEFINITION.getName().getValue())
.append(MappingUtils.NAME_VALUE_DELIMETER)
.append("%s");
- String frmtClsfName = String.format(frmtBuilder.toString(), 8010, 8020, secRule.getProtocol().getIdentityref().getSimpleName(),
- secRule.getEthertype().getSimpleName());
+ String frmtClsfName = String.format(frmtBuilder.toString(), 8010, 8020,
+ secRule.getProtocol().getIdentityref().getSimpleName(), secRule.getEthertype().getSimpleName());
ClassifierName expectedClsfInstanceName = new ClassifierName(frmtClsfName);
assertEquals(expectedClsfInstanceName, SecRuleNameDecoder.getClassifierInstanceName(secRule.build()));
}
@Test
public final void updateOrderBasedOnL4ClassifTest() throws Exception {
- ParameterValue sPort = createIntParameterValue(L4ClassifierDefinition.SRC_PORT_PARAM, Long.valueOf(4999));
- ParameterValue dPort = createIntParameterValue(L4ClassifierDefinition.DST_PORT_PARAM, Long.valueOf(8080));
- ParameterValue sMiniRange = createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 1000, 1000);
- ParameterValue dMiniRange = createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 2000, 2000);
- ParameterValue sPortRange = createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 3335, 3336);
- ParameterValue dPortRange = createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 9998, 9999);
- ClassifierInstance ci;
- ci = createClassifierInstance(L4ClassifierDefinition.ID, dPortRange);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 180);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, sPortRange);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 180);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, sPort);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 170);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, sMiniRange);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 170);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, dPort);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 170);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, dMiniRange);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 170);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, sPortRange, dPortRange);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 160);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, sPortRange, dPort);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 150);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, sPortRange, dMiniRange);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 150);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, dPortRange, sPort);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 150);
- ci = createClassifierInstance(L4ClassifierDefinition.ID, dPortRange, sMiniRange);
- assertEquals(SingleClassifierRule.updateOrderBasedOn(ci, allow, 0), 150);
+ final ParameterValue sourcePort = createIntParameterValue(L4ClassifierDefinition.SRC_PORT_PARAM, 4999L);
+ final ParameterValue destPort = createIntParameterValue(L4ClassifierDefinition.DST_PORT_PARAM, 8080L);
+ final ParameterValue
+ sourceMiniRange =
+ createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 1000, 1000);
+ final ParameterValue
+ destinationMiniRange =
+ createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 2000, 2000);
+ final ParameterValue
+ sourcePortRange =
+ createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 3335, 3336);
+ final ParameterValue
+ destinationPortRange =
+ createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 9998, 9999);
+
+ ClassifierInstance classifierInstance;
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 180);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 180);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePort);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourceMiniRange);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destPort);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationMiniRange);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destinationPortRange);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 160);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destPort);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destinationMiniRange);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange, sourcePort);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150);
+ classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange, sourceMiniRange);
+ assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150);
}
private ParameterValue createIntParameterValue(String paramName, Long value) {
*/
package org.opendaylight.groupbasedpolicy.neutron.mapper.test;
+import com.google.common.base.Optional;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import com.google.common.base.Optional;
-
public final class ConfigDataStoreReader {
private ConfigDataStoreReader() {
}
}
- public static Optional<ConsumerNamedSelector> readConsumerNamedSelector(DataBroker dataBroker, String tenantId, String egId,
- String selectorName) {
+ public static Optional<ConsumerNamedSelector> readConsumerNamedSelector(DataBroker dataBroker, String tenantId,
+ String egId, String selectorName) {
InstanceIdentifier<ConsumerNamedSelector> cnsIid = IidFactory.consumerNamedSelectorIid(new TenantId(tenantId),
new EndpointGroupId(egId), new SelectorName(selectorName));
try (ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction()) {
}
}
- public static Optional<Clause> readClause(DataBroker dataBroker, String tenantId, String contractId, String clauseName) {
+ public static Optional<Clause> readClause(DataBroker dataBroker, String tenantId, String contractId,
+ String clauseName) {
InstanceIdentifier<Clause> clauseIid = IidFactory.clauseIid(new TenantId(tenantId), new ContractId(contractId),
new ClauseName(clauseName));
try (ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction()) {
import static com.google.common.base.Preconditions.checkState;
-import javax.annotation.Nonnull;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
import java.io.IOException;
import java.util.Collection;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
+import javax.annotation.Nonnull;
+
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
}
/**
+ * Used to get classes from yang modules.
+ *
* @return a class from every yang module which needs to be loaded. Cannot return {@code null}
* or empty collection.
*/
*/
package org.opendaylight.groupbasedpolicy.neutron.mapper.test;
+import com.google.common.base.Strings;
+
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRuleBuilder;
-import com.google.common.base.Strings;
-
public final class NeutronEntityFactory {
private NeutronEntityFactory() {
return new SecurityGroupBuilder().setUuid(new Uuid(id)).setTenantId(new Uuid(tenantId)).setName(name).build();
}
- public static SecurityRule securityRuleWithoutGroupIds(String id, String tenant, Class<? extends EthertypeBase> etherType,
- Class<? extends DirectionBase> direction, Class<? extends ProtocolBase> protocol, int portMin, int portMax) {
+ public static SecurityRule securityRuleWithoutGroupIds(String id, String tenant,
+ Class<? extends EthertypeBase> etherType, Class<? extends DirectionBase> direction,
+ Class<? extends ProtocolBase> protocol, int portMin, int portMax) {
+
SecurityRuleAttributes.Protocol proto = new SecurityRuleAttributes.Protocol(protocol);
SecurityRuleBuilder secRule = new SecurityRuleBuilder();
secRule.setUuid(new Uuid(id));
import static org.junit.Assert.assertTrue;
import com.google.common.base.Optional;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
assertTrue(opt.isPresent());
}
+ public static void assertNetworkDomainExists(DataBroker dataBroker, Uuid tenantUuid, Subnet subnet,
+ Neutron neutron, IpAddress ipAddress) {
+ Optional<NetworkDomain> opt = getNetworkDomainOptional(dataBroker, tenantUuid, neutron, ipAddress, subnet);
+ assertTrue(opt.isPresent());
+ }
+
public static void assertNetworkDomainNotExists(DataBroker dataBroker, Port port, Subnet subnet,
Neutron neutron, IpAddress ipAddress) {
Optional<NetworkDomain> opt =
assertFalse(opt.isPresent());
}
- public static void assertNetworkDomainExists(DataBroker dataBroker, Uuid tenantUuid, Subnet subnet,
- Neutron neutron, IpAddress ipAddress) {
- Optional<NetworkDomain> opt = getNetworkDomainOptional(dataBroker, tenantUuid, neutron, ipAddress, subnet);
- assertTrue(opt.isPresent());
- }
-
public static void assertNetworkDomainNotExists(DataBroker dataBroker, Uuid tenantUuid, Subnet subnet,
Neutron neutron, IpAddress ipAddress) {
Optional<NetworkDomain> opt = getNetworkDomainOptional(dataBroker, tenantUuid, neutron, ipAddress, subnet);
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.common.collect.ImmutableList;
+
import java.util.Collection;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.Tenants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import com.google.common.collect.ImmutableList;
-
/**
* Loads only modules of GBP and it's dependencies for data broker.
* <br>
Mappings.class);
}
+ @SuppressWarnings("checkstyle:LineLength") // Longer lines in this method are caused by long package names,
+ // this will be removed when deprecated classes will be cleared.
protected EndpointRegistrator getEpRegistrator() {
EndpointRegistrator epRegistrator = mock(EndpointRegistrator.class);
when(epRegistrator.registerEndpoint(any(RegisterEndpointInput.class))).thenReturn(true);
when(epRegistrator.registerEndpoint(
- any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput.class)))
- .thenReturn(true);
+ any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput.class)))
+ .thenReturn(true);
when(epRegistrator.unregisterEndpoint(any(UnregisterEndpointInput.class))).thenReturn(true);
when(epRegistrator.unregisterEndpoint(
- any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput.class)))
- .thenReturn(true);
+ any(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput.class)))
+ .thenReturn(true);
return epRegistrator;
}
-
}
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
public final class PolicyAssert {
private PolicyAssert() {
// asserts for contract
- public static void assertContractExists(DataBroker dataBroker, String tenantId, String contractId) throws Exception {
+ public static void assertContractExists(DataBroker dataBroker, String tenantId, String contractId)
+ throws Exception {
+
Optional<Contract> contract = ConfigDataStoreReader.readContract(dataBroker, tenantId, contractId);
assertTrue(contract.isPresent());
}
assertEquals(SecRuleNameDecoder.getSubjectName(secRule), subjectRef);
}
- public static void assertClauseExists(DataBroker dataBroker, String tenantId, String contractId, String clauseName) {
+ public static void assertClauseExists(DataBroker dataBroker, String tenantId, String contractId,
+ String clauseName) {
Optional<Clause> clause = ConfigDataStoreReader.readClause(dataBroker, tenantId, contractId, clauseName);
assertTrue(clause.isPresent());
}
assertEquals(order, rule.getOrder().intValue());
}
- private static <T> T assertOneItem(Collection<T> c) {
- assertNotNull(c);
- assertTrue(c.size() == 1);
- return c.iterator().next();
+ private static <T> T assertOneItem(Collection<T> collection) {
+ assertNotNull(collection);
+ assertTrue(collection.size() == 1);
+ return collection.iterator().next();
}
// asserts for selector
-
public static void assertConsumerNamedSelectorExists(DataBroker dataBroker, String tenantId, String egId,
String selectorName) {
Optional<ConsumerNamedSelector> potentialCns = ConfigDataStoreReader.readConsumerNamedSelector(dataBroker,