CloudStack provides a variety of settings you can use to set values, limits, configure features, and enable or disable features in the cloud.
Once your Management Server is running, you might need to set some of these global configuration parameters, depending on configuration you want at the global level, which will be in effect throughout the cloud and we need to restart the Management server after changing the values to get effected.
Our new framework allows us to define some configuration parameters at lower level (account, zone, cluster, or primary storage), which will override the global configuration parameter values.
We provide some methods in ConfigurationServer interface using which we can get the value of configuration parameter from the DB based on the scope.
New methods are introduced (marked in green)
public interface ConfigurationServer { public static final String Name = "configuration-server"; /** * Persists default values for the configuration table, pods/zones, and VLANs * * @return */ public void persistDefaultValues() throws InternalErrorException; public void updateKeyPairs(); /** * get the value of configuration parameter at the scope given for the corresponding resource level (account, zone, cluster, or primary storage) * If either scope or resourceId is not specified then get the global value * @param name * configuration parameter name * @param scope * Scope at which parameter value is defined (account, zone, cluster, or primary storage) * @param resourceId * id of the resource (account, zone, cluster, or primary storage) * @return value of the configuration parameter */ public String getConfigValue(String name, String scope, Long resourceId); /** * get the list of configuration parameters and values at the scope given for the corresponding resource level (account, zone, cluster, or primary storage) * If either scope or resourceId is not specified then get the global value * @param scope * Scope at which parameter value is defined (account, zone, cluster, or primary storage) * @param resourceId * id of the resource (account, zone, cluster, or primary storage) * @return list of the configuration parameters and values */ public List<ConfigurationVO> getConfigListByScope(String scope, Long resourceId); }
To get the value of a parameter at particular scope
@Inject ConfigurationServer _configServer;
1) Get the value of "mem.overprovisioning.factor" defined at cluster (id=3)
overProvisioinigFactor = Float.parseFloat(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), clusterId));
2) Get the value of "mem.overprovisioning.factor" defined at global level
overProvisioinigFactor = Float.parseFloat(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), null, null));
We have defined an enum to mention the scope in Config.java
public static enum ConfigurationParameterScope { global, zone, cluster, storagepool, account }
Just add the corresponding scope at the end of the configuration parameter enum value.
Example: MemOverprovisioningFactor("Advanced", ManagementServer.class, String.class, "mem.overprovisioning.factor", "1", "Used for memory overprovisioning calculation", null, ConfigurationParameterScope.cluster.toString()),
To update a configuration parameter at particular scope
API name |
Existing API Parameters |
New optional API Parameters |
API Response |
---|---|---|---|
updateConfiguration |
name: the name of the configuration |
zoneid: ID of the zone |
updateconfigurationresponse with scope and updated value |
Example: localhost:8096/client/api?command=updateConfiguration&name=mem.overprovisioning.factor&value=2&clusterid=a69d292a-c1e7-4630-8acf-58e955859ab6
To list configuration parameter at particular scope
API name |
Existing API Parameters |
New optional API Parameters |
API Response |
---|---|---|---|
listConfiguration |
category: lists configurations by category |
zoneid: ID of the zone |
listconfigurationsresponse with scope and value at the corresponding scope of the parameters. |
Example: To list the parameter values defined at zone id b7aa7e8c-78b1-49f2-9876-aa25a728276d
1) Improve the framework to support defining a parameter at multiple scopes (account, zone, cluster, or primary storage)
2) To maintain a local cache of configuration parameter values. All consumers of config parameters should access config values from this cache. Cache should get updated whenever the value in DB is gets updated.