Hi,
Our users have the ability to swap resources at run time via a script that we created. The script is launched from a node in the NodeEdge component. In the script the user can select the profile instance they want to use and the resource and we retrieve the function from the node from where the script starts. Currently, I'm using an elaborate function to retrieve all available resources with that function definition and profile instance to filter out the resources that I need.
Would there be a more efficient call to get those available resources for a specific node to use then in the AssignResourceRequest?
Hi Timothy,
You can use the following method from the SrmUtilities class:
// Summary:
// Gets the available resources for a node of a service definition when no booking
// exists yet.
// Parameters:
// serviceDefinition:
// Service definition where the node belongs to.
// nodeId:
// Node to get the available resources.
// bookingInfo:
// Booking information.
// bookingManager:
// Booking manager that will create the booking.
// srmCache:
// Reference to a SrmCache.
// profileInstance:
// Optional Profile Instance.
// Returns:
// A System.Collections.Generic.IEnumerable`1 containing all available resources.
public static IEnumerable<ResourcePriority> GetAvailableResourcesForNode(Net.ServiceManager.Objects.ServiceDefinition serviceDefinition, int nodeId, MainBookingInfo bookingInfo, BookingManager bookingManager, SrmCache srmCache, Net.Profiles.ProfileInstance profileInstance = null);
You can get the 'MainBookingInfo' by doing reservation.GetBookingData() on the original reservation object.
E.g.:
var resources = SrmUtilities.GetAvailableResourcesForNode(serviceDefinition, 4, reservation.GetBookingData(), this.bookingManager, new SrmCache(), profileInstance);
Works perfectly thanks!