CreateSan( string poolId, string notes, string[] hostResources) { Console.WriteLine("Creating Virtual SAN - {0} ...", poolId); ManagementScope scope = FibreChannelUtilities.GetFcScope(); string resourcePoolSettingData = FibreChannelUtilities.GetSettingsForPool(scope, poolId, notes); // // Fibre Channel Connection Resource Pools have only 1 parent, the primordial pool. // string[] parentPoolPathArray = new string[1]; parentPoolPathArray[0] = FibreChannelUtilities.GetResourcePoolPath(scope, null); string[] resourceAllocationSettingDataArray = new string[1]; resourceAllocationSettingDataArray[0] = FibreChannelUtilities.GetNewPoolAllocationSettings(scope, poolId, hostResources); using (ManagementObject rpConfigurationService = FibreChannelUtilities.GetResourcePoolConfigurationService(scope)) using (ManagementBaseObject inParams = rpConfigurationService.GetMethodParameters("CreatePool")) { inParams["PoolSettings"] = resourcePoolSettingData; inParams["ParentPools"] = parentPoolPathArray; inParams["AllocationSettings"] = resourceAllocationSettingDataArray; using (ManagementBaseObject outParams = rpConfigurationService.InvokeMethod( "CreatePool", inParams, null)) { WmiUtilities.ValidateOutput(outParams, scope, true, true); } } Console.WriteLine("Successfully Created Virtual SAN: {0}", poolId); }
ModifySanSettings( string poolId, string newPoolId ) { Console.WriteLine("Modifying a Virtual SAN's settings:"); Console.WriteLine("\tSAN Name: {0} (change to {1})", poolId, newPoolId); ManagementScope scope = FibreChannelUtilities.GetFcScope(); using (ManagementObject rpConfigurationService = FibreChannelUtilities.GetResourcePoolConfigurationService(scope)) { string resourcePoolSettingData = FibreChannelUtilities.GetSettingsForPool(scope, newPoolId, null); string poolPath = FibreChannelUtilities.GetResourcePoolPath(scope, poolId); using (ManagementBaseObject inParams = rpConfigurationService.GetMethodParameters("ModifyPoolSettings")) { inParams["ChildPool"] = poolPath; inParams["PoolSettings"] = resourcePoolSettingData; using (ManagementBaseObject outParams = rpConfigurationService.InvokeMethod( "ModifyPoolSettings", inParams, null)) { WmiUtilities.ValidateOutput(outParams, scope, true, true); } } } Console.WriteLine("Successfully renamed Virtual SAN: from {0} to {1}", poolId, newPoolId); }