当前位置: 首页>>代码示例>>C#>>正文


C# CloudServersProvider.CreateVirtualInterface方法代码示例

本文整理汇总了C#中CloudServersProvider.CreateVirtualInterface方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServersProvider.CreateVirtualInterface方法的具体用法?C# CloudServersProvider.CreateVirtualInterface怎么用?C# CloudServersProvider.CreateVirtualInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CloudServersProvider的用法示例。


在下文中一共展示了CloudServersProvider.CreateVirtualInterface方法的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);
        }
开发者ID:nick-o,项目名称:openstack.net,代码行数:29,代码来源:UserServerTests.cs


注:本文中的CloudServersProvider.CreateVirtualInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。