Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> providers =
_networkService.listNetworkServiceProviders(_znet.getId(), Provider.JuniperContrailRouter.getName(),
null, null, null);
if (providers.second() == 0) {
s_logger.debug("Add " + Provider.JuniperContrailRouter.getName() + " to network " + _znet.getName());
PhysicalNetworkServiceProvider provider =
_networkService.addProviderToPhysicalNetwork(_znet.getId(), Provider.JuniperContrailRouter.getName(),
null, null);
_networkService.updateNetworkServiceProvider(provider.getId(),
PhysicalNetworkServiceProvider.State.Enabled.toString(), null);
} else {
PhysicalNetworkServiceProvider provider = providers.first().get(0);
if (provider.getState() != PhysicalNetworkServiceProvider.State.Enabled) {
_networkService.updateNetworkServiceProvider(provider.getId(),
PhysicalNetworkServiceProvider.State.Enabled.toString(), null);
}
}
providers = _networkService.listNetworkServiceProviders(_znet.getId(), null,
PhysicalNetworkServiceProvider.State.Enabled.toString(), null, null);
s_logger.debug(_znet.getName() + " has " + providers.second().toString() + " Enabled providers");
for (PhysicalNetworkServiceProvider provider: providers.first()) {
if (provider.getProviderName().equals(Provider.JuniperContrailRouter.getName())) {
continue;
}
s_logger.debug("Disabling " + provider.getProviderName());
_networkService.updateNetworkServiceProvider(provider.getId(),
PhysicalNetworkServiceProvider.State.Disabled.toString(), null);
}
}