Search in sources :

Example 1 with DhcpConfig

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;
}
Also used : DhcpConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfig)

Example 2 with DhcpConfig

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 ""
    }
}
Also used : Configs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs)

Example 3 with DhcpConfig

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;
}
Also used : ConfigsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.ConfigsBuilder) DhcpConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfig) Configs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs) DhcpConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfigBuilder)

Aggregations

DhcpConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfig)2 Configs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.Configs)2 DhcpConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DhcpConfigBuilder)1 ConfigsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dhcp.config.ConfigsBuilder)1