// create a 'gslbvserver' object representing a globally load balanced service
private static void
createVirtualServer(nitro_service client, String vserverName, String lbMethod, String persistenceType, long persistenceId, String serviceType)
throws ExecutionException {
try {
gslbvserver vserver;
vserver = getVserverObject(client, vserverName);
boolean isUpdateSite = false;
if (vserver == null) {
vserver = new gslbvserver();
} else {
isUpdateSite = true;
}
vserver.set_name(vserverName);
if ("RoundRobin".equalsIgnoreCase(lbMethod)) {
vserver.set_lbmethod("ROUNDROBIN");
} else if ("LeastConn".equalsIgnoreCase(lbMethod)) {
vserver.set_lbmethod("LEASTCONNECTION");
} else if ("Proximity".equalsIgnoreCase(lbMethod)) {
vserver.set_lbmethod("RTT");
} else {
throw new ExecutionException("Unsupported LB method");
}
vserver.set_persistencetype(persistenceType);
if ("SOURCEIP".equalsIgnoreCase(persistenceType)) {
vserver.set_persistenceid(persistenceId);
}
vserver.set_servicetype(serviceType);
vserver.set_state("ENABLED");
vserver.set_cookietimeout(null);
vserver.set_domainname(null);
if (isUpdateSite) {
// both netmask and LB method can not be specified while update so set to null
vserver.set_netmask(null);
vserver.set_v6netmasklen(null);
gslbvserver.update(client, vserver);
} else {
gslbvserver.add(client, vserver);
}