本文整理汇总了C#中CloudServersProvider.ListVirtualInterfaces方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServersProvider.ListVirtualInterfaces方法的具体用法?C# CloudServersProvider.ListVirtualInterfaces怎么用?C# CloudServersProvider.ListVirtualInterfaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CloudServersProvider
的用法示例。
在下文中一共展示了CloudServersProvider.ListVirtualInterfaces方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestVirtualInterfaces
public void TestVirtualInterfaces()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
INetworksProvider networksProvider = new CloudNetworksProvider(Bootstrapper.Settings.TestIdentity);
CloudNetwork publicNetwork = networksProvider.ListNetworks().Single(i => i.Label.Equals("public", StringComparison.OrdinalIgnoreCase));
CloudNetwork privateNetwork = networksProvider.ListNetworks().Single(i => i.Label.Equals("private", StringComparison.OrdinalIgnoreCase));
VirtualInterface publicVirtualInterface = provider.CreateVirtualInterface(_server.Id, publicNetwork.Id);
Assert.IsNotNull(publicVirtualInterface);
Assert.IsFalse(string.IsNullOrEmpty(publicVirtualInterface.Id));
Assert.IsNotNull(publicVirtualInterface.MACAddress);
VirtualInterface privateVirtualInterface = provider.CreateVirtualInterface(_server.Id, privateNetwork.Id);
Assert.IsNotNull(privateVirtualInterface);
Assert.IsFalse(string.IsNullOrEmpty(privateVirtualInterface.Id));
Assert.IsNotNull(privateVirtualInterface.MACAddress);
IEnumerable<VirtualInterface> virtualInterfaces = provider.ListVirtualInterfaces(_server.Id);
Assert.IsNotNull(virtualInterfaces);
Assert.IsTrue(virtualInterfaces.Where(i => i.Id.Equals(publicVirtualInterface.Id, StringComparison.OrdinalIgnoreCase)).Any());
Assert.IsTrue(virtualInterfaces.Where(i => i.Id.Equals(privateVirtualInterface.Id, StringComparison.OrdinalIgnoreCase)).Any());
bool deleted;
deleted = provider.DeleteVirtualInterface(_server.Id, publicVirtualInterface.Id);
Assert.IsTrue(deleted);
deleted = provider.DeleteVirtualInterface(_server.Id, privateVirtualInterface.Id);
Assert.IsTrue(deleted);
}