use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class DhcpAllocationPoolManager method createIdAllocationPool.
protected void createIdAllocationPool(String networkId, AllocationPool pool) {
String poolName = getPoolKeyIdByAllocationPool(networkId, pool);
long low = DhcpServiceUtils.convertIpToLong(pool.getAllocateFrom());
long high = DhcpServiceUtils.convertIpToLong(pool.getAllocateTo());
CreateIdPoolInput createPool = new CreateIdPoolInputBuilder().setPoolName(poolName).setLow(low).setHigh(high).build();
try {
Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
if (result != null && result.get().isSuccessful()) {
LOG.info("DHCP Allocation Pool Service : Created IdPool name {}", poolName);
} else {
LOG.error("DHCP Allocation Pool Service : Unable to create IdPool name {}", poolName);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to create Pool for DHCP Allocation Pool Service", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class DhcpAllocationPoolManager method releaseIdAllocationPool.
protected void releaseIdAllocationPool(String networkId, AllocationPool pool) {
String poolName = getPoolKeyIdByAllocationPool(networkId, pool);
DeleteIdPoolInput deletePool = new DeleteIdPoolInputBuilder().setPoolName(poolName).build();
try {
Future<RpcResult<Void>> result = idManager.deleteIdPool(deletePool);
if (result != null && result.get().isSuccessful()) {
LOG.info("DHCP Allocation Pool Service : Deleted IdPool name {}", poolName);
} else {
LOG.error("DHCP Allocation Pool Service : Unable to delete IdPool name {}", poolName);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to delete Pool for DHCP Allocation Pool Service", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class DhcpAllocationPoolManager method createIdAllocation.
private long createIdAllocation(String groupIdKey, String idKey) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(groupIdKey).setIdKey(idKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
return rpcResult.getResult().getIdValue();
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.trace("Failed to allocate id for DHCP Allocation Pool Service", e);
}
return 0;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class DhcpInterfaceConfigListener method add.
@Override
protected void add(InstanceIdentifier<Interface> identifier, Interface add) {
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(add.getName()), () -> {
String interfaceName = add.getName();
IfL2vlan vlanInterface = add.getAugmentation(IfL2vlan.class);
if (vlanInterface == null) {
return Collections.emptyList();
}
Port port = dhcpManager.getNeutronPort(interfaceName);
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null != subnet && subnet.isEnableDhcp()) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
LOG.debug("Binding DHCP service for interface {}", interfaceName);
DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
}));
}
return Collections.emptyList();
}, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class ElanServiceChainUtils method getElanServiceChainState.
/**
* Read from ElanToLportTagMap the PsuedoLogicalPort related with a given elan.
*
* @param broker dataBroker service reference
* @param elanInstanceName the name of the Elan
* @return the ElanToPseudoPortData object or Optional.absent() if it
* cannot be found
*/
public static Optional<ElanServiceChainState> getElanServiceChainState(final DataBroker broker, final String elanInstanceName) {
InstanceIdentifier<ElanServiceChainState> path = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).augmentation(ElanServiceChainState.class).build();
Optional<ElanServiceChainState> elanServiceChainStateOpc = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, path);
return elanServiceChainStateOpc;
}
Aggregations