use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfig in project netvirt by opendaylight.
the class DhcpShowCommand method doExecute.
@Override
protected Object doExecute() throws Exception {
InstanceIdentifier<DhcpConfig> iid = InstanceIdentifier.create(DhcpConfig.class);
DhcpConfig dhcpConfig = SingleTransactionDataBroker.syncRead(dataBroker, CONFIGURATION, iid);
if (isDhcpConfigAvailable(dhcpConfig)) {
leaseDuration = dhcpConfig.getConfigs().get(0).getLeaseDuration();
defDomain = dhcpConfig.getConfigs().get(0).getDefaultDomain();
}
session.getConsole().println("Lease Duration: " + (leaseDuration != null ? leaseDuration : DhcpMConstants.DEFAULT_LEASE_TIME));
session.getConsole().println("Default Domain: " + (defDomain != null ? defDomain : DhcpMConstants.DEFAULT_DOMAIN_NAME));
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfig in project netvirt by opendaylight.
the class DhcpConfigListener method updateConfig.
private void updateConfig(DhcpConfig update) {
// TODO: Update operational with actual values
if (update == null || update.getConfigs() == null || update.getConfigs().isEmpty()) {
dhcpManager.setLeaseDuration(DhcpMConstants.DEFAULT_LEASE_TIME);
dhcpManager.setDefaultDomain(DhcpMConstants.DEFAULT_DOMAIN_NAME);
return;
}
Configs config = update.getConfigs().get(0);
if (config.getLeaseDuration() != null) {
dhcpManager.setLeaseDuration(config.getLeaseDuration());
}
if (config.getDefaultDomain() != null) {
dhcpManager.setDefaultDomain(config.getDefaultDomain());
// TODO: What to do if string is ""
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfig 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