// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved
namespace Microsoft.Samples.HyperV.FibreChannel
{
using System;
using System.Management;
using System.Globalization;
using Microsoft.Samples.HyperV.Common;
static class DeleteSanSample
{
///
/// Deletes a Virtual SAN by its Name.
///
/// Name of the Virtual SAN to be deleted.
private static void
DeleteSan(
string poolId)
{
Console.WriteLine("Deleting Virtual SAN - {0} ...", poolId);
ManagementScope scope = FibreChannelUtilities.GetFcScope();
using (ManagementObject rpConfigurationService =
FibreChannelUtilities.GetResourcePoolConfigurationService(scope))
using (ManagementBaseObject inParams =
rpConfigurationService.GetMethodParameters("DeletePool"))
{
inParams["Pool"] = FibreChannelUtilities.GetResourcePoolPath(scope, poolId);
using (ManagementBaseObject outParams =
rpConfigurationService.InvokeMethod(
"DeletePool",
inParams,
null))
{
WmiUtilities.ValidateOutput(outParams, scope, true, true);
}
}
Console.WriteLine("Successfully deleted Virtual SAN - {0}", poolId);
}
///
/// Entry point for the DeleteSan sample.
///
/// The command line arguments.
internal static void
ExecuteSample(
string[] args)
{
if (args.Length != 1 || (args.Length > 0 && args[0] == "/?"))
{
Console.WriteLine("Usage: DeleteSan \n");
return;
}
try
{
DeleteSan(args[0]);
}
catch (Exception ex)
{
Console.WriteLine("Failed to delete the san. Error message details:\n");
Console.WriteLine(ex.Message);
}
}
}
}