示例#1
0
        public static List <ListItem> CS_m_ListServerVolumeList(string dcregion)
        {
            var volumedetails = Servers.blockStorageProvider().ListVolumes(dcregion);

            var             GetVolumeID = volumedetails.ToList();
            List <ListItem> volumelist  = new List <ListItem>();

            foreach (var i in GetVolumeID)
            {
                var attachments_var = i.Attachments;
                if (attachments_var.Count() <= 0)
                {
                    ListItem ListItemDisplayName = new ListItem(i.DisplayName, i.Id);
                    volumelist.Add(ListItemDisplayName);
                }
                else
                {
                    foreach (var item in attachments_var)
                    {
                        ListItem ListItemDisplayName = new ListItem(i.DisplayName, i.Id);
                        volumelist.Add(ListItemDisplayName);
                    }
                }
            }
            return(volumelist);
        }
        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.";
            }
        }