protected void ListCloudServerIpAddresses_Click(object sender, EventArgs e)
        {
            try
            {
                CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider();
                CloudServersProvider CloudServersProvider = new net.openstack.Providers.Rackspace.CloudServersProvider();

                var identity = new RackspaceCloudIdentity { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

                if (RegionDFW.Checked)
                {
                    var serveripaddressdetails = CloudServersProvider.ListAddresses(CSImageListDDL.SelectedValue, "dfw", identity);
                }
                else if (RegionORD.Checked)
                {
                    var serveripaddressdetails = CloudServersProvider.ListAddresses(CSImageListDDL.SelectedValue, "dfw", identity);

                    CFResultsGrid.DataSource = serveripaddressdetails;
                    CFResultsGrid.DataBind();
                }
                else
                {
                    LblInfo.Text = "Please select DFW or ORD not both.";
                }
            }
            catch (Exception ex)
            {
                Error.Text = "Something went terribly wrong! See below for more info. <br /> <br />" + ex.ToString();
            }
        }
        protected void CreateServer_Click(object sender, EventArgs e)
        {
            try
            {
                CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider();
                CloudServersProvider CloudServersProvider = new net.openstack.Providers.Rackspace.CloudServersProvider();

                var identity = new RackspaceCloudIdentity { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

                if (RegionDFW.Checked)
                {
                    CloudServersProvider.CreateServer(CSName.Text, null, CSFlavorsDDL.Text, null, null, "dfw", identity);
                }
                else if (RegionORD.Checked)
                {
                    CloudServersProvider.CreateServer(CSName.Text, null, CSFlavorsDDL.Text, null, null, "ord", identity);
                }
                else
                {
                    LblInfo.Text = "Please select DFW or ORD not both.";
                }
            }
            catch (Exception ex)
            {
                Error.Text = "Something went terribly wrong! See below for more info. <br /> <br />" + ex.ToString();
            }
        }
Esempio n. 3
0
        public static CloudServersProvider serversProvider()
        {
            string CloudIdentityUserName = (string)(HttpContext.Current.Session["CloudIdentityUserName"]);
            string CloudIdentityApiKey   = (string)(HttpContext.Current.Session["CloudIdentityApiKey"]);

            RackspaceCloudIdentity identity = new RackspaceCloudIdentity()
            {
                Username = CloudIdentityUserName, APIKey = CloudIdentityApiKey
            };

            CloudServersProvider CloudServersProvider = new net.openstack.Providers.Rackspace.CloudServersProvider(identity);

            return(CloudServersProvider);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Stopwatch TimeClock = new Stopwatch();

            TimeClock.Start();

            HttpContext.Current.Session["CSListServersName"]   = HttpUtility.HtmlEncode(CS_ddl_ListServers.SelectedItem);
            HttpContext.Current.Session["CSListServersID"]     = HttpUtility.HtmlEncode(CS_ddl_ListServers.SelectedValue);
            HttpContext.Current.Session["CSListServersRegion"] = CS_ddl_Region.Text;

            string region                  = CS_ddl_Region.SelectedItem.ToString();
            string cslistserverid          = CS_ddl_ListServers.SelectedValue.ToString();
            string cslistserveridsession   = (string)(HttpContext.Current.Session["CSListServersID"]);
            string cslistservernamesession = (string)(HttpContext.Current.Session["CSListServersName"]);
            string CloudIdentityUserName   = (string)(HttpContext.Current.Session["CloudIdentityUserName"]);
            string CloudIdentityApiKey     = (string)(HttpContext.Current.Session["CloudIdentityApiKey"]);

            var identity = new RackspaceImpersonationIdentity()
            {
                Username = CloudIdentityUserName, APIKey = CloudIdentityApiKey
            };

            CloudIdentityProvider identityProvider     = new net.openstack.Providers.Rackspace.CloudIdentityProvider(identity);
            CloudServersProvider  CloudServersProvider = new net.openstack.Providers.Rackspace.CloudServersProvider();

            Page.GetPostBackEventReference(CS_btn_RebootCloudServer);

            try
            {
                if (IsPostBack)
                {
                    HttpContext.Current.Session["PostBackListServerIdDDL"]   = HttpUtility.HtmlEncode(CS_ddl_ListServers.SelectedValue);
                    HttpContext.Current.Session["PostBackListServerNameDDL"] = HttpUtility.HtmlEncode(CS_ddl_ListServers.SelectedItem);
                }
                else
                {
                    if (string.IsNullOrEmpty((string)(Session["CloudIdentityUserName"])) & string.IsNullOrEmpty((string)(Session["CloudIdentityApiKey"])))
                    {
                        CS_lbl_Error.Text = "Before continuing please login and enter Cloud Username and API Key.";
                    }
                    else if (string.IsNullOrEmpty((string)(Session["CloudIdentityUserName"])))
                    {
                        CS_lbl_Error.Text = "Before continuing please login and please enter Cloud Username.";
                    }
                    else if (string.IsNullOrEmpty((string)(Session["CloudIdentityApiKey"])))
                    {
                        CS_lbl_Error.Text = "Before continuing please login and please enter API Key.";
                    }
                    else
                    {
                        var listimages = Servers.CS_m_ListImages();
                        bindListImagesNoIndexInDDL(listimages, "Name", "Id");

                        var listflavors = Servers.CS_m_ListFlavors();
                        bindListFlavorsNoIndexInDDL(listflavors, "Name", "Id");

                        var serverdetails = Servers.CS_m_ListServerInfo(region);
                        var firstserver   = serverdetails.First();
                        bindListServersNoIndexInDDL(serverdetails, "Name", "Id");

                        CS_m_GetCloudServerDetails(firstserver.Id, region);

                        TimeClock.Stop();
                        CS_lbl_TimeClock.Text = TimeClock.Elapsed.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                CS_m_MsgCatchException(ex.ToString());
            }
        }
        protected void OneClick_Click(object sender, EventArgs e)
        {
            try
            {
                CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider();
                CloudServersProvider CloudServersProvider = new net.openstack.Providers.Rackspace.CloudServersProvider();

                var identity = new RackspaceCloudIdentity { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

                if (RegionDFW.Checked)
                {
                    var serverdetails = CloudServersProvider.ListServersWithDetails(null, null, null, null, null, null, null, "dfw", identity);

                    CSListDDL.DataSource = serverdetails;
                    CSListDDL.DataTextField = "Name";
                    CSListDDL.DataValueField = "Id";
                    CSListDDL.DataBind();

                    var flavordetails = CloudServersProvider.ListFlavors(0, 0, null, 0, "dfw", identity);

                    CSFlavorsDDL.DataSource = flavordetails;
                    CSFlavorsDDL.DataTextField = "Name";
                    CSFlavorsDDL.DataValueField = "Id";
                    CSFlavorsDDL.DataBind();

                    var serverimagedetails = CloudServersProvider.ListImages(null, null, "ACTIVE", DateTime.UtcNow, null, 100, null, "dfw", identity);

                    CSImageListDDL.DataSource = serverimagedetails;
                    CSImageListDDL.DataBind();
                    CSImageListDDL.DataTextField = "Name";
                    CSImageListDDL.DataValueField = "Id";
                    CSImageListDDL.DataSource = serverimagedetails;

                    CSImageListDDL.DataBind();
                }
                else if (RegionORD.Checked)
                {
                    var serverdetails = CloudServersProvider.ListServersWithDetails(null, null, null, null, null, null, null, "ord", identity);

                    CSListDDL.DataSource = serverdetails;
                    CSListDDL.DataTextField = "Name";
                    CSListDDL.DataValueField = "Id";
                    CSListDDL.DataBind();

                    var flavordetails = CloudServersProvider.ListFlavors(0, 0, null, 0, "ord", identity);

                    CSFlavorsDDL.DataSource = flavordetails;
                    CSFlavorsDDL.DataTextField = "Name";
                    CSFlavorsDDL.DataValueField = "Id";
                    CSFlavorsDDL.DataBind();

                    var serverimagedetails = CloudServersProvider.ListImages(null, null, null, DateTime.Now, null, 0, null, "ord", identity);

                    CFResultsGrid.DataSource = serverimagedetails;
                    CFResultsGrid.DataBind();
                }
                else
                {
                    LblInfo.Text = "Please select DFW or ORD not both.";
                }
            }
            catch (Exception ex)
            {
                Error.Text = "Something went terribly wrong! See below for more info. <br /> <br />" + ex.ToString();
            }
        }