use of com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding in project cloudstack by apache.
the class NetscalerResource method bindServiceToMonitor.
private void bindServiceToMonitor(final String nsServiceName, final String nsMonitorName) throws ExecutionException {
try {
com.citrix.netscaler.nitro.resource.config.basic.service serviceObject = new com.citrix.netscaler.nitro.resource.config.basic.service();
serviceObject = com.citrix.netscaler.nitro.resource.config.basic.service.get(_netscalerService, nsServiceName);
if (serviceObject != null) {
final com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding serviceMonitor = new com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding();
serviceMonitor.set_monitor_name(nsMonitorName);
serviceMonitor.set_name(nsServiceName);
serviceMonitor.set_monstate("ENABLED");
s_logger.debug("Trying to bind the monitor :" + nsMonitorName + " to the service :" + nsServiceName);
com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding.add(_netscalerService, serviceMonitor);
s_logger.debug("Successfully binded the monitor :" + nsMonitorName + " to the service :" + nsServiceName);
}
} catch (final nitro_exception e) {
throw new ExecutionException("Failed to create new monitor :" + nsMonitorName + " due to " + e.getMessage());
} catch (final Exception e) {
throw new ExecutionException("Failed to create new monitor :" + nsMonitorName + " due to " + e.getMessage());
}
}
use of com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding in project cloudstack by apache.
the class NetscalerResource method unBindServiceToMonitor.
private void unBindServiceToMonitor(final String nsServiceName, final String nsMonitorName) throws ExecutionException {
try {
com.citrix.netscaler.nitro.resource.config.basic.service serviceObject = new com.citrix.netscaler.nitro.resource.config.basic.service();
serviceObject = com.citrix.netscaler.nitro.resource.config.basic.service.get(_netscalerService, nsServiceName);
if (serviceObject != null) {
final com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding serviceMonitor = new com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding();
serviceMonitor.set_monitor_name(nsMonitorName);
serviceMonitor.set_name(nsServiceName);
s_logger.debug("Trying to unbind the monitor :" + nsMonitorName + " from the service :" + nsServiceName);
service_lbmonitor_binding.delete(_netscalerService, serviceMonitor);
s_logger.debug("Successfully unbinded the monitor :" + nsMonitorName + " from the service :" + nsServiceName);
}
} catch (final nitro_exception e) {
if (e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS) {
return;
} else {
throw new ExecutionException("Failed to unbind monitor :" + nsMonitorName + "from the service :" + nsServiceName + "due to " + e.getMessage());
}
} catch (final Exception e) {
throw new ExecutionException("Failed to unbind monitor :" + nsMonitorName + "from the service :" + nsServiceName + "due to " + e.getMessage());
}
}
Aggregations