Search in sources :

Example 1 with com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding

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());
    }
}
Also used : com.citrix.netscaler.nitro.resource.config.gslb.gslbservice_lbmonitor_binding(com.citrix.netscaler.nitro.resource.config.gslb.gslbservice_lbmonitor_binding) com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding(com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding) ExecutionException(com.cloud.utils.exception.ExecutionException) IOException(java.io.IOException) ConfigurationException(javax.naming.ConfigurationException) com.citrix.netscaler.nitro.exception.nitro_exception(com.citrix.netscaler.nitro.exception.nitro_exception) com.citrix.netscaler.nitro.service.nitro_service(com.citrix.netscaler.nitro.service.nitro_service) com.citrix.netscaler.nitro.resource.config.gslb.gslbservice(com.citrix.netscaler.nitro.resource.config.gslb.gslbservice) ExecutionException(com.cloud.utils.exception.ExecutionException) com.citrix.netscaler.nitro.resource.config.ns.nsconfig(com.citrix.netscaler.nitro.resource.config.ns.nsconfig) com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding(com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding)

Example 2 with com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding

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());
    }
}
Also used : com.citrix.netscaler.nitro.resource.config.gslb.gslbservice_lbmonitor_binding(com.citrix.netscaler.nitro.resource.config.gslb.gslbservice_lbmonitor_binding) com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding(com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding) ExecutionException(com.cloud.utils.exception.ExecutionException) IOException(java.io.IOException) ConfigurationException(javax.naming.ConfigurationException) com.citrix.netscaler.nitro.exception.nitro_exception(com.citrix.netscaler.nitro.exception.nitro_exception) com.citrix.netscaler.nitro.service.nitro_service(com.citrix.netscaler.nitro.service.nitro_service) com.citrix.netscaler.nitro.resource.config.gslb.gslbservice(com.citrix.netscaler.nitro.resource.config.gslb.gslbservice) ExecutionException(com.cloud.utils.exception.ExecutionException) com.citrix.netscaler.nitro.resource.config.ns.nsconfig(com.citrix.netscaler.nitro.resource.config.ns.nsconfig) com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding(com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding)

Aggregations

com.citrix.netscaler.nitro.exception.nitro_exception (com.citrix.netscaler.nitro.exception.nitro_exception)2 com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding (com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_binding)2 com.citrix.netscaler.nitro.resource.config.gslb.gslbservice (com.citrix.netscaler.nitro.resource.config.gslb.gslbservice)2 com.citrix.netscaler.nitro.resource.config.gslb.gslbservice_lbmonitor_binding (com.citrix.netscaler.nitro.resource.config.gslb.gslbservice_lbmonitor_binding)2 com.citrix.netscaler.nitro.resource.config.ns.nsconfig (com.citrix.netscaler.nitro.resource.config.ns.nsconfig)2 com.citrix.netscaler.nitro.service.nitro_service (com.citrix.netscaler.nitro.service.nitro_service)2 ExecutionException (com.cloud.utils.exception.ExecutionException)2 IOException (java.io.IOException)2 ConfigurationException (javax.naming.ConfigurationException)2