I have an ad hoc query that gathers the max concurrency, concurrency left and capacity left of all our resources in SRM. I would like to get the Max capacity of each of the resources in this same query. Is this possible? I've not found anything in the libraries that would do this. I'm interested in the Capacity: Bandwidth value in the resource as shown below.
My query is based around the example in Interacting with Resource Manager | DataMiner Docs
Hi Sion,
Resources store capacities as a combination of the ID of the capacity profile parameter, and the configured max value. So in order to retrieve the configured max bandwidth on each resource, you first need to know the ID of the bandwidth parameter. The easiest way to do this is to retrieve the bandwidth profile parameter by name. See the code below:
var profileHelper = new ProfileHelper(gqiDms.SendMessages);
var rmHelper = new ResourceManagerHelper(gqiDms.SendMessage);
// You need to import the 'Skyline.DataMiner.Net.Messages.SLDataGateway' namespace for the filter.
var parameterFilter = ParameterExposers.Name.Equal("Bandwidth");var parameter = profileHelper.ProfileParameters.Read(parameterFilter).FirstOrDefault();
if (parameter == null)
{
// There is no parameter with name 'Bandwidth'
...
}// Retrieve the resources, see the docs page you linked for examples on how to construct filters or on how to use paging.
var resources = rmHelper.GetResources(...);foreach (var oneResource in resources)
{
var bandWidthCapacity = oneResource.Capacities.FirstOrDefault(c => c.CapacityProfileID == parameter.ID);
if (bandWidthCapacity != null)
{
var maxBandwidthOnResource = bandWidthCapacity.Value.MaxDecimalQuantity;
}
}
Note that if you want to know the amount of bandwidth that is left instead of the configured max bandwidth, you can do so with a 'GetEligibleResources' call instead, of which there is also an example in the docs.
Perfect, thank you Seppe. I had the other data based on the other examples. ProfileHelper looks useful indeed