本文整理汇总了C#中CloudServersProvider.AttachServerVolume方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServersProvider.AttachServerVolume方法的具体用法?C# CloudServersProvider.AttachServerVolume怎么用?C# CloudServersProvider.AttachServerVolume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CloudServersProvider
的用法示例。
在下文中一共展示了CloudServersProvider.AttachServerVolume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Attach_Server_Volume
public void Should_Attach_Server_Volume()
{
var provider = new CloudServersProvider(_testIdentity);
_testVolume = provider.AttachServerVolume(_testServer.Id, "2da9ce90-076e-450a-be3e-c822c9aa73f5");
Assert.IsNotNull(_testVolume);
}
示例2: TestAttachServerVolume
public void TestAttachServerVolume()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
IBlockStorageProvider blockStorageProvider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity);
VolumeType volumeType = UserBlockStorageTests.GetSsdVolumeTypeOrDefault(blockStorageProvider);
string volumeName = UserBlockStorageTests.UnitTestVolumePrefix + Path.GetRandomFileName();
Volume volume = blockStorageProvider.CreateVolume(UserBlockStorageTests.MinimumVolumeSize, displayName: volumeName, volumeType: volumeType != null ? volumeType.Id : null);
Assert.AreEqual(VolumeState.Available, blockStorageProvider.WaitForVolumeAvailable(volume.Id).Status);
/* AttachServerVolume
*/
ServerVolume serverVolume = provider.AttachServerVolume(_server.Id, volume.Id);
Assert.IsNotNull(serverVolume);
Assert.IsFalse(string.IsNullOrEmpty(serverVolume.Id));
Assert.AreEqual(_server.Id, serverVolume.ServerId);
Assert.AreEqual(volume.Id, serverVolume.VolumeId);
Assert.AreEqual(VolumeState.InUse, blockStorageProvider.WaitForVolumeState(volume.Id, VolumeState.InUse, new[] { VolumeState.Available, VolumeState.Error }).Status);
/* ListServerVolumes
*/
ServerVolume[] serverVolumes = provider.ListServerVolumes(_server.Id).ToArray();
Assert.IsNotNull(serverVolumes);
Assert.AreEqual(1, serverVolumes.Length);
Assert.AreEqual(serverVolume.Id, serverVolumes[0].Id);
Assert.AreEqual(serverVolume.ServerId, serverVolumes[0].ServerId);
Assert.AreEqual(serverVolume.VolumeId, serverVolumes[0].VolumeId);
/* GetServerVolumeDetails
*/
ServerVolume volumeDetails = provider.GetServerVolumeDetails(_server.Id, volume.Id);
Assert.IsNotNull(volumeDetails);
Assert.AreEqual(serverVolume.Id, volumeDetails.Id);
Assert.AreEqual(serverVolume.ServerId, volumeDetails.ServerId);
Assert.AreEqual(serverVolume.VolumeId, volumeDetails.VolumeId);
bool detach = provider.DetachServerVolume(_server.Id, volume.Id);
Assert.IsTrue(detach);
ServerVolume[] remainingVolumes = provider.ListServerVolumes(_server.Id).ToArray();
Assert.AreEqual(0, remainingVolumes.Length);
Assert.AreEqual(VolumeState.Available, blockStorageProvider.WaitForVolumeAvailable(volume.Id).Status);
bool deleted = blockStorageProvider.DeleteVolume(volume.Id);
Assert.IsTrue(blockStorageProvider.WaitForVolumeDeleted(volume.Id));
}