Exemplo n.º 1
0
 public static void CS_m_RebootServer(string dcregion, string listserverid, string reboottype)
 {
     if (reboottype.ToString() == "soft")
     {
         Servers.serversProvider().RebootServer(listserverid, RebootType.Soft, dcregion);
     }
     else if (reboottype.ToString() == "hard")
     {
         Servers.serversProvider().RebootServer(listserverid, RebootType.Hard, dcregion);
     }
 }
Exemplo n.º 2
0
        public static void CS_m_DetachVolume(string listserverid, string availablevolumeid, string dcregion)
        {
            var volumedetails = Servers.serversProvider().DetachServerVolume(listserverid, availablevolumeid, dcregion);

            var volumeIsInList = false;
            var count          = 0;

            do
            {
                var serverdetails = Servers.serversProvider().GetDetails(listserverid, dcregion);
                var volumes       = serverdetails.GetVolumes();

                if (volumes != null)
                {
                    volumeIsInList = volumes.Any(v => v.Id == availablevolumeid);
                }

                count += 1;
            } while (volumeIsInList && count < 600);
        }
Exemplo n.º 3
0
        public static string CS_m_CreateServer(string servername, string listimageid, string listflavorsid, string howmanyserverstocreate, string dcregion)
        {
            StringBuilder CS_sb_CloudServerPasswd = new StringBuilder();

            int InputHowMany = int.Parse(howmanyserverstocreate);

            bool attachtoservicenetwork = bool.Parse("true");
            bool attachtopublicnetwork  = bool.Parse("true");

            Servers.serversProvider();

            if (InputHowMany <= 10)
            {
                if (InputHowMany >= 1)
                {
                    int count   = 1;
                    int countid = 1;
                    while (count <= InputHowMany)
                    {
                        count   = count + 1;
                        countid = count - 1;
                        var server       = Servers.serversProvider().CreateServer(servername + "_" + countid, listimageid, listflavorsid, null, null, null, attachtoservicenetwork, attachtopublicnetwork, null, dcregion);
                        var serverpasswd = server.AdminPassword.ToString();
                        CS_sb_CloudServerPasswd.Append(servername + "_" + countid + " " + serverpasswd.ToString() + "\r\n");
                    }

                    return("Servers have been created successfully.  Your admin password is: \r\n" + CS_sb_CloudServerPasswd);
                }
                else
                {
                    var server       = Servers.serversProvider().CreateServer(servername, listimageid, listflavorsid, null, null, null, attachtoservicenetwork, attachtopublicnetwork, null, dcregion);
                    var serverpasswd = server.AdminPassword.ToString();

                    return(servername + " created successfully.  Your admin password is: " + serverpasswd);
                }
            }
            else
            {
                return("You can only create 10 servers at a time.");
            }
        }
Exemplo n.º 4
0
        public static string CS_m_ListAddresses(string listServersSelectedValue, string dcregion)
        {
            ServerAddresses serverAddresses = Servers.serversProvider().ListAddresses(listServersSelectedValue, dcregion);

            var IpAddresses_SB = new StringBuilder();

            bool foundAddress = false;

            foreach (KeyValuePair <string, IPAddressList> addresses in serverAddresses)
            {
                IpAddresses_SB.Append("Network: " + addresses.Key + "<br />");

                foreach (IPAddress address in addresses.Value)
                {
                    foundAddress = true;
                    IpAddresses_SB.Append(address + "<br />");
                }
            }

            return(IpAddresses_SB.ToString());
        }
Exemplo n.º 5
0
        public static void CS_m_AttachVolume(string listserverid, string availablevolumeid, string dcregion)
        {
            var attachServerVolume = Servers.serversProvider().AttachServerVolume(listserverid, availablevolumeid, null, dcregion);

            var volumeIsInList = false;
            var count          = 0;

            do
            {
                var serverdetails      = Servers.serversProvider().GetDetails(listserverid, dcregion);
                var GetAttachedVolumes = serverdetails.GetVolumes().ToList();

                if (GetAttachedVolumes != null)
                {
                    volumeIsInList = GetAttachedVolumes.Any(v => v.Id == attachServerVolume.Id);
                }

                count += 1;

                Thread.Sleep(2400);
            } while (!volumeIsInList && count < 600);
        }
Exemplo n.º 6
0
        public static IEnumerable <SimpleServer> CS_m_ListServerInfo(string dcregion)
        {
            IEnumerable <SimpleServer> serverdetails = Servers.serversProvider().ListServers(null, null, null, null, null, null, null, dcregion);

            return(serverdetails);
        }
Exemplo n.º 7
0
 public static void CS_m_PasswdReset(string listserverid, string newpassword, string dcregion)
 {
     Servers.serversProvider().ChangeAdministratorPassword(listserverid, newpassword, dcregion);
 }
Exemplo n.º 8
0
        public static IEnumerable <SimpleServerImage> CS_m_ListImages()
        {
            IEnumerable <SimpleServerImage> images = Servers.serversProvider().ListImages();

            return(images);
        }
Exemplo n.º 9
0
        public static IEnumerable <Flavor> CS_m_ListFlavors()
        {
            IEnumerable <Flavor> flavordetails = Servers.serversProvider().ListFlavors();

            return(flavordetails);
        }
Exemplo n.º 10
0
 public static void CS_m_DeleteServer(string listserversid, string dcregion)
 {
     Servers.serversProvider().DeleteServer(listserversid, dcregion);
 }
        protected void CS_m_GetCloudServerDetails(string cslistserverid, string dcregion)
        {
            string value = "";

            try
            {
                if (string.IsNullOrEmpty((string)(Session["CSListServersID"])))
                {
                    if (string.IsNullOrEmpty(cslistserverid))
                    {
                        CS_m_ClearDdls();
                        CS_lbl_CSInfo.Text = "You currently have no servers built in the " + dcregion.ToString() + " datacenter.  Please create one to see more information about it.";
                    }
                    else
                    {
                        var serverdetails = Servers.serversProvider().GetDetails(cslistserverid, dcregion);
                        var volumedetails = Servers.blockStorageProvider().ListVolumes(dcregion);

                        var Status             = serverdetails.GetDetails().Status;
                        var TaskState          = serverdetails.GetDetails().TaskState;
                        var VMState            = serverdetails.GetDetails().VMState;
                        var UserID             = serverdetails.GetDetails().UserId;
                        var HostId             = serverdetails.GetDetails().HostId;
                        var ServerId           = serverdetails.GetDetails().Id;
                        var TenantId           = serverdetails.GetDetails().TenantId;
                        var Created            = serverdetails.GetDetails().Created;
                        var LastUpdated        = serverdetails.GetDetails().Updated;
                        var DiskConfig         = serverdetails.GetDetails().DiskConfig;
                        var FlavorID           = serverdetails.GetDetails().Flavor.Id;
                        var FlavorName         = serverdetails.GetDetails().Flavor.Name;
                        var ImageID            = serverdetails.GetDetails().Image.Id;
                        var ImageName          = serverdetails.GetDetails().Image.Name;
                        var PowerState         = serverdetails.GetDetails().PowerState;
                        var GetAttachedVolumes = serverdetails.GetVolumes().ToList();
                        var GetVolumeID        = volumedetails.ToList();

                        var listServerVolumeList = Servers.CS_m_ListServerVolumeList(dcregion);
                        foreach (var i in listServerVolumeList)
                        {
                            addItemToDdl(i);
                        }

                        bindlblCSInfo2(Servers.CS_m_ListAddresses(CS_ddl_ListServers.SelectedValue, dcregion));

                        foreach (var i in GetAttachedVolumes)
                        {
                            ListItem ListItemDisplayName = new ListItem(i.Device, i.Id);
                            CS_ddl_CBSAttachedVolume.Items.Add(ListItemDisplayName);
                        }

                        CS_lbl_CSInfo.Text = "Status : " + Status + "<br />" +
                                             "Task State : " + TaskState + "<br />" +
                                             "VM State : " + VMState + "<br />" +
                                             "User ID : " + UserID + "<br />" +
                                             "Host ID : " + HostId + "<br />" +
                                             "Server ID : " + ServerId + "<br />" +
                                             "Tenant ID : " + TenantId + "<br />" +
                                             "Created: " + Created + "<br />" +
                                             "Last Updated : " + LastUpdated + "<br />" +
                                             "Disk Config : " + DiskConfig + "<br />" +
                                             "Flavor Name : " + FlavorName + "<br />" +
                                             "Flavor ID : " + FlavorID + "<br />" +
                                             "Image Name : " + ImageName + "<br />" +
                                             "Image ID : " + ImageID + "<br />" +
                                             "Power :" + PowerState + "<br />";
                    }
                }
                else
                {
                    CS_m_ClearDdls();

                    var serverdetails = Servers.serversProvider().GetDetails(cslistserverid, dcregion);
                    var volumedetails = Servers.blockStorageProvider().ListVolumes(dcregion);

                    var Status             = serverdetails.GetDetails().Status;
                    var TaskState          = serverdetails.GetDetails().TaskState;
                    var VMState            = serverdetails.GetDetails().VMState;
                    var UserID             = serverdetails.GetDetails().UserId;
                    var HostId             = serverdetails.GetDetails().HostId;
                    var ServerId           = serverdetails.GetDetails().Id;
                    var TenantId           = serverdetails.GetDetails().TenantId;
                    var Created            = serverdetails.GetDetails().Created;
                    var LastUpdated        = serverdetails.GetDetails().Updated;
                    var DiskConfig         = serverdetails.GetDetails().DiskConfig;
                    var FlavorID           = serverdetails.GetDetails().Flavor.Id;
                    var FlavorName         = serverdetails.GetDetails().Flavor.Name;
                    var ImageID            = serverdetails.GetDetails().Image.Id;
                    var ImageName          = serverdetails.GetDetails().Image.Name;
                    var PowerState         = serverdetails.GetDetails().PowerState;
                    var PublicAddresses    = serverdetails.Addresses.Public.ToList();
                    var PrivateAddresses   = serverdetails.Addresses.Private.ToList();
                    var GetAttachedVolumes = serverdetails.GetVolumes().ToList();
                    var GetVolumeID        = volumedetails.ToList();

                    var listServerVolumeList = Servers.CS_m_ListServerVolumeList(dcregion);
                    foreach (var i in listServerVolumeList)
                    {
                        addItemToDdl(i);
                    }

                    bindlblCSInfo2(Servers.CS_m_ListAddresses(CS_ddl_ListServers.SelectedValue, dcregion));


                    foreach (var i in GetAttachedVolumes)
                    {
                        ListItem ListItemDisplayName = new ListItem(i.Device, i.Id);
                        CS_ddl_CBSAttachedVolume.Items.Add(ListItemDisplayName);
                    }

                    CS_lbl_CSInfo.Text = "Status : " + Status + "<br />" +
                                         "Task State : " + TaskState + "<br />" +
                                         "VM State : " + VMState + "<br />" +
                                         "User ID : " + UserID + "<br />" +
                                         "Host ID : " + HostId + "<br />" +
                                         "Server ID : " + ServerId + "<br />" +
                                         "Tenant ID : " + TenantId + "<br />" +
                                         "Created: " + Created + "<br />" +
                                         "Last Updated : " + LastUpdated + "<br />" +
                                         "Disk Config : " + DiskConfig + "<br />" +
                                         "Flavor Name : " + FlavorName + "<br />" +
                                         "Flavor ID : " + FlavorID + "<br />" +
                                         "Image Name : " + ImageName + "<br />" +
                                         "Image ID : " + ImageID + "<br />" +
                                         "Power :" + PowerState + "<br />";
                }
            }
            catch (Exception ex)
            {
                CS_lbl_Error.Text = " Server details are not available yet.";
            }
        }