Ejemplo n.º 1
0
        public void TestBasicFunctionality()
        {
            INetworksProvider provider    = Bootstrapper.CreateNetworksProvider();
            string            networkName = UnitTestNetworkPrefix + Path.GetRandomFileName();
            string            cidr        = "192.0.2.0/24";

            CloudNetwork network;

            try
            {
                network = provider.CreateNetwork(cidr, networkName);
            }
            catch (BadServiceRequestException ex)
            {
                if (ex.Message == "Quota exceeded, too many networks.")
                {
                    Assert.Inconclusive("The required test network could not be created due to a quota.");
                }

                throw;
            }

            Assert.IsNotNull(network);

            CloudNetwork showNetwork = provider.ShowNetwork(network.Id);

            Assert.IsNotNull(showNetwork);
            Assert.AreEqual(network.Id, showNetwork.Id);
            Assert.AreEqual(network.Label, showNetwork.Label);
            Assert.AreEqual(network.Cidr, showNetwork.Cidr);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public static void Init(TestContext context)
        {
            _testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);

            var provider = new CloudServersProvider(_testIdentity);

            _initImage  = provider.ListImages(imageName: "CentOS 6.3").First();
            _initFlavor = provider.ListFlavors().OrderBy(f => f.Id).First();

            var netProvider = new CloudNetworksProvider(_testIdentity);
            var networks    = netProvider.ListNetworks();

            _testNetwork = networks.FirstOrDefault(n => !n.Label.Equals("public") && !n.Label.Equals("private"));
        }