public void DeleteServerTest_Delete_Server_Not_Exist()
        {
            var os = new OpenStackMember(UserName, Password, TenantName);

            // expect ItemNotFoundException
            bool b = os.DeleteServer(InvalidId);
        }
        public void GetServerTest()
        {
            var          osm    = new OpenStackMember(UserName, Password, TenantName); // with tenant
            SimpleServer ss     = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.Active);
            Server       server = osm.GetServer(ss.Id);

            Assert.IsTrue(server.Id == ss.Id);
            Assert.IsTrue(osm.DeleteServer(ss.Id));
        }
        public void DeleteServerTest()
        {
            var          osm = new OpenStackMember(UserName, Password, TenantName, TenantId);
            SimpleServer ss  = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.ShutOff);

            if (ss != null)
            {
                bool b = osm.DeleteServer(ss.Id);
                Assert.IsTrue(b);
                Trace.WriteLine(String.Format("server deleted : {0}", DateTime.Now));
            }
        }
        public void CreateServerTest_5times()
        {
            OpenStackMember os        = null;
            NewServer       server    = null;
            var             serverIds = new List <string>();

            try
            {
                os = new OpenStackMember(UserName, Password, TenantName, TenantId);
                var image = os.ListImages().First();
                for (int cnt = 1; cnt <= 15; cnt++)
                {
                    IEnumerable <SimpleServer> servers = os.ListServers();
                    var      names      = servers.GroupBy(s => s.Name, (key, g) => key);
                    string[] data       = Enumerable.Range(1, 100).Select(i => string.Format("{0}_{1}", TesterName, i)).ToArray <string>();
                    string   serverName = (from b in data where !names.Contains <string>(b) select b).First();
                    server = os.CreateServer(serverName, image.Id, GetFlavorByName("g-1gb").Id, "D$fjhg5422mnM-");
                    serverIds.Add(server.Id);
                    Trace.WriteLine(String.Format("server creation transferred : {0}", DateTime.Now));
                    Assert.IsNotNull(server);
                    Assert.IsNotNull(server.AdminPassword);
                    Trace.WriteLine(string.Format("ServerName : {0}", serverName));
                    Trace.WriteLine(string.Format("AdminPassword : {0}", server.AdminPassword));
                }
            }
            finally
            {
                foreach (var serverId in serverIds)
                {
                    bool bDelete = os.DeleteServer(serverId);
                    Assert.IsTrue(bDelete);
                    Trace.WriteLine(String.Format("server deletion transferred : {0}", DateTime.Now));
                    os.ServersProvider.WaitForServerDeleted(serverId);
                    Trace.WriteLine(String.Format("server deleted : {0}", DateTime.Now));
                }
            }
        }
        public void CreateServerTest()
        {
            var os = new OpenStackMember(UserName, Password, TenantName, TenantId);

            var image = os.ListImages().First();

            // decide server name which is not duplicated.
            IEnumerable <SimpleServer> servers = os.ListServers();
            var names = servers.GroupBy(s => s.Name, (key, g) => key);

            string[] data       = Enumerable.Range(1, 100).Select(i => string.Format("{0}_{1}", TesterName, i)).ToArray <string>();
            string   serverName = (from b in data where !names.Contains <string>(b) select b).First();

            // create server
            // the name tag must not contain space
            NewServer server = os.CreateServer(serverName, image.Id, GetFlavorByName("g-1gb").Id, "S5df!Afdas%'Zt", keyname: null, nametag: "test_nametag", networks: null);

            Trace.WriteLine(String.Format("server creation transferred : {0}", DateTime.Now));
            Assert.IsNotNull(server);
            Assert.IsNotNull(server.AdminPassword);
            Trace.WriteLine(string.Format("ServerName : {0}", serverName));
            Trace.WriteLine(string.Format("AdminPassword : {0}", server.AdminPassword));

            // wait for activate
            os.ServersProvider.WaitForServerActive(server.Id);
            Trace.WriteLine(String.Format("server activated : {0}", DateTime.Now));

            bool bDelete = os.DeleteServer(server.Id);

            Assert.IsTrue(bDelete);
            Trace.WriteLine(String.Format("server deletion transferred : {0}", DateTime.Now));

            // wait for delete
            os.ServersProvider.WaitForServerDeleted(server.Id);
            Trace.WriteLine(String.Format("server deleted : {0}", DateTime.Now));
        }