use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfigBuilder in project netvirt by opendaylight.
the class DhcpConfigureCommand method doExecute.
@Override
protected Object doExecute() throws Exception {
if (defaultDomain == null && leaseDuration == null) {
session.getConsole().println(getHelp());
return null;
}
Integer currLeaseDuration = DhcpMConstants.DEFAULT_LEASE_TIME;
String currDefDomain = DhcpMConstants.DEFAULT_DOMAIN_NAME;
ConfigsBuilder dccBuilder = new ConfigsBuilder();
InstanceIdentifier<DhcpConfig> iid = InstanceIdentifier.create(DhcpConfig.class);
DhcpConfig currentConfig = SingleTransactionDataBroker.syncRead(dataBroker, CONFIGURATION, iid);
if (currentConfig != null && currentConfig.getConfigs() != null && !currentConfig.getConfigs().isEmpty()) {
Configs dhcpConfig = currentConfig.getConfigs().get(0);
if (dhcpConfig.getLeaseDuration() != null) {
currLeaseDuration = dhcpConfig.getLeaseDuration();
}
if (dhcpConfig.getDefaultDomain() != null) {
currDefDomain = dhcpConfig.getDefaultDomain();
}
}
dccBuilder.setLeaseDuration(leaseDuration == null ? currLeaseDuration : leaseDuration);
dccBuilder.setDefaultDomain(defaultDomain == null ? currDefDomain : defaultDomain);
List<Configs> configList = Collections.singletonList(dccBuilder.build());
DhcpConfigBuilder dcBuilder = new DhcpConfigBuilder();
dcBuilder.setConfigs(configList);
SingleTransactionDataBroker.syncWrite(dataBroker, CONFIGURATION, iid, dcBuilder.build());
return null;
}
Aggregations