CreatePool( string resourceDisplayName, string childPoolId, string childPoolName, string parentPoolIdsString, string parentHostResourcesString) { Console.WriteLine( "Creating a resource pool:\n" + "\tPool Id: " + childPoolId + "\n\tPool Name: " + childPoolName); ResourceUtilities.DisplayResourceInformation( resourceDisplayName); ResourcePoolUtilities.DisplayPoolIdAndHostResources( parentPoolIdsString, parentHostResourcesString); string[] poolDelimter = { "[p]" }; // // Pool IDs are delimted by "[p], e.g. // "[p]Child Pool A[p][p]Child Pool B[p]" // string[] parentPoolIdArray = ResourcePoolUtilities.GetOneDimensionalArray( parentPoolIdsString, poolDelimter); string[] hostResourceDelimter = { "[h]" }; // // Parent pool host resources are specified by a 2-D array. Each pool is delimited // by a "[p]"; Each host resource is delimited by a "[h]". For example, // "[p][h]Child A, Resource 1[h][h]Child A, Resource 2[h][p][p][h]Child B, Resource 1[h][p]" // string[][] parentHostResourcesArray = ResourcePoolUtilities.GetTwoDimensionalArray( parentHostResourcesString, poolDelimter, hostResourceDelimter); ManagementScope scope = ResourcePoolUtilities.GetManagementScope(); using (ManagementObject rPConfigurationService = MsvmResourcePoolConfigurationService.GetResourcePoolConfigurationService( scope)) { CreatePoolHelper( scope, rPConfigurationService, ResourceUtilities.GetResourceType(resourceDisplayName), ResourceUtilities.GetResourceSubType(resourceDisplayName), childPoolId, childPoolName, parentPoolIdArray, parentHostResourcesArray); } }
ModifyPoolResources( string resourceDisplayName, string poolId, string parentPoolIdsString, string parentHostResourcesString) { Console.WriteLine( "Modifying a resource pool's host resources:\n" + "\tPool ID: " + poolId); ResourceUtilities.DisplayResourceInformation( resourceDisplayName); ResourcePoolUtilities.DisplayPoolIdAndHostResources( parentPoolIdsString, parentHostResourcesString); string[] poolDelimiter = { "[p]" }; string[] hostResourceDelimter = { "[h]" }; string[] parentPoolIdArray = ResourcePoolUtilities.GetOneDimensionalArray( parentPoolIdsString, poolDelimiter); string[][] parentHostResourcesArray = ResourcePoolUtilities.GetTwoDimensionalArray( parentHostResourcesString, poolDelimiter, hostResourceDelimter); ManagementScope scope = ResourcePoolUtilities.GetManagementScope(); using (ManagementObject rPConfigurationService = MsvmResourcePoolConfigurationService.GetResourcePoolConfigurationService( scope)) { ModifyPoolResourcesHelper( scope, rPConfigurationService, ResourceUtilities.GetResourceType(resourceDisplayName), ResourceUtilities.GetResourceSubType(resourceDisplayName), poolId, parentPoolIdArray, parentHostResourcesArray); } }