import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
import org.opendaylight.neutron.northbound.api.BadRequestException;
import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD;
import org.opendaylight.neutron.spi.NeutronSecurityRule;
String> ETHERTYPE_MAP = new ImmutableBiMap.Builder<Class<? extends EthertypeBase>, String>()
.put(EthertypeV4.class, "IPv4").put(EthertypeV6.class, "IPv6").build();
+ private final NeutronSecurityGroupInterface securityGroupInterface;
+
@Inject
- public NeutronSecurityRuleInterface(DataBroker db) {
+ public NeutronSecurityRuleInterface(DataBroker db, NeutronSecurityGroupInterface securityGroupInterface) {
super(SecurityRuleBuilder.class, db);
+ this.securityGroupInterface = securityGroupInterface;
}
@Override
}
return securityRuleBuilder.build();
}
+
+ @Override
+ protected boolean areAllDependenciesAvailable(ReadTransaction tx, NeutronSecurityRule securityRule) {
+ return securityGroupInterface.exists(securityRule.getSecurityRuleGroupID(), tx)
+ && ifNonNull(securityRule.getSecurityRemoteGroupID(),
+ remoteGroupID -> securityGroupInterface.exists(remoteGroupID, tx));
+ }
}