GUACAMOLE-317: Expose "failover-only" attribute for connections.

This commit is contained in:
Michael Jumper
2017-06-06 13:31:29 -07:00
parent 3c553b965c
commit 31519061dc
2 changed files with 17 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ import org.apache.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.jdbc.JDBCEnvironment;
import org.apache.guacamole.auth.jdbc.base.ModeledChildDirectoryObject;
import org.apache.guacamole.form.BooleanField;
import org.apache.guacamole.form.EnumField;
import org.apache.guacamole.form.Field;
import org.apache.guacamole.form.Form;
@@ -121,6 +122,13 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
*/
public static final String CONNECTION_WEIGHT = "weight";
/**
* The name of the attribute which controls whether the connection should
* be used as a spare only (all other non-spare connections within the same
* balancing group should be preferred).
*/
public static final String FAILOVER_ONLY_NAME = "failover-only";
/**
* All attributes related to restricting user accounts, within a logical
* form.
@@ -134,7 +142,8 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
* All attributes related to load balancing in a logical form.
*/
public static final Form LOAD_BALANCING = new Form("load-balancing", Arrays.<Field>asList(
new NumericField(CONNECTION_WEIGHT)
new NumericField(CONNECTION_WEIGHT),
new BooleanField(FAILOVER_ONLY_NAME, "true")
));
/**
@@ -281,6 +290,9 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
// Set connection weight
attributes.put(CONNECTION_WEIGHT, NumericField.format(getModel().getConnectionWeight()));
// Set whether connection is failover-only
attributes.put(FAILOVER_ONLY_NAME, getModel().isFailoverOnly() ? "true" : null);
return attributes;
}
@@ -333,6 +345,9 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
logger.debug("Unable to parse numeric attribute.", e);
}
// Translate failover-only attribute
getModel().setFailoverOnly("true".equals(attributes.get(FAILOVER_ONLY_NAME)));
}
/**

View File

@@ -20,6 +20,7 @@
"FIELD_HEADER_MAX_CONNECTIONS" : "Maximum number of connections:",
"FIELD_HEADER_MAX_CONNECTIONS_PER_USER" : "Maximum number of connections per user:",
"FIELD_HEADER_FAILOVER_ONLY" : "Use for failover only:",
"FIELD_HEADER_WEIGHT" : "Connection weight:",
"FIELD_HEADER_GUACD_HOSTNAME" : "Hostname:",