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();
            }
        }
        protected void CFProvidersDeleteContainerObject(string cfcontainername, string cfdeletecontainerobject, string dcregion, bool dcsnet = true)
        {
            var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

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

            var Cfdeletecontainerobject = CloudFilesProvider.DeleteObject(cfcontainername, cfdeletecontainerobject, null, dcregion, dcsnet);
        }
        protected void CFProvidersCreateObjectFromFile(string cfcontainername, string cfcreateobjfilepath, string cfcreateobjfilename, int cfcreateobjchunksize, string dcregion, bool dcsnet = true)
        {
            var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

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

            CloudFilesProvider.CreateObjectFromFile(cfcontainername, cfcreateobjfilepath, cfcreateobjfilename, cfcreateobjchunksize, null, dcregion, null, dcsnet);
        }
        protected void CFProvidersCreateContainer(string cfcreatecontainername, string dcregion, bool dcsnet = true)
        {
            var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

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

            var CfCreateContainer = CloudFilesProvider.CreateContainer(cfcreatecontainername, dcregion, dcsnet);
        }
        protected void CFProviderListContainers(string dcregion, bool dcsnet = true)
        {
            var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

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

            var CfContainers = CloudFilesProvider.ListContainers(null, null, null, dcregion, dcsnet);

            CFContainerDDL.DataSource = CfContainers;
            CFContainerDDL.DataTextField = "Name";
            CFContainerDDL.DataBind();
        }
Пример #7
0
        public ComputeTests()
        {
            CloudInstance cloudInstance;
            CloudInstance.TryParse(ConfigurationManager.AppSettings["TestIdentityGeo"], true, out cloudInstance);

            _testIdentity = new RackspaceCloudIdentity
            {
                APIKey = ConfigurationManager.AppSettings["TestIdentityAPIKey"],
                Password = ConfigurationManager.AppSettings["TestIdentityPassword"],
                CloudInstance = cloudInstance,
                Username = ConfigurationManager.AppSettings["TestIdentityUserName"],
            };
        }
        public static void Init(TestContext context)
        {
            _testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);
            _testAdminIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestAdminIdentity);

            _newAPIKey = Guid.NewGuid().ToString();
            _adminNewAPIKey = Guid.NewGuid().ToString();

            var provider = BuildProvider();

            _userDetails = provider.GetUserByName(_testIdentity.Username, _testIdentity);
            _adminUserDetails = provider.GetUserByName(_testAdminIdentity.Username, _testAdminIdentity);
        }
Пример #9
0
        public void Should_Throw_Error_When_Authenticating_With_Invalid_Password()
        {
            var identity = new RackspaceCloudIdentity()
                               {
                                   Username = _testIdentity.Username,
                                   Password = "******"
                               };
            IIdentityProvider serviceProvider = new CloudIdentityProvider(identity);

            try
            {
                var userAccess = serviceProvider.Authenticate();

                throw new Exception("This code path is invalid, exception was expected.");
            }
            catch (net.openstack.Core.Exceptions.Response.ResponseException)
            {
                Assert.IsTrue(true);
            }
        }
Пример #10
0
        static bool Login()
        {
            auth = new RackspaceCloudIdentity();
            auth.Username = Username;
            auth.Password = Password;
            auth.APIKey = APIKey;
            auth.CloudInstance = AccountRegion == "LON" ? CloudInstance.UK : CloudInstance.Default;

            try
            {
                CloudIdentityProvider identityProvider = new CloudIdentityProvider();
                var userAccess = identityProvider.Authenticate(auth);
            }
            catch (Exception ex)
            {
                PrintException(ex);
                return false;
            }

            return true;
        }
 public static void Init(TestContext context)
 {
     _testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);
 }
Пример #12
0
        public static void Main(string[] args)
        {
            Boolean containerExists = false;
            if (args.Length < 4 || args.Length > 5)
            {
                Console.WriteLine("Usage: {0} username api_key target_container path_to_file [region (US|UK)]", Environment.CommandLine);
                Environment.Exit(1);
            }
            RackspaceCloudIdentity auth = new RackspaceCloudIdentity();
            IEnumerable<Container> containerList = null;
            auth.Username = args[0];
            auth.APIKey = args[1];
            targetContainer = args[2];
            filePath = args[3];
            if (args.Length == 5)
            {
                if (args[4] != "UK" && args[4] != "US")
                {
                    Console.WriteLine("region must be either US or UK", Environment.CommandLine);
                    Environment.Exit(1);
                }
                switch (args[4])
                {
                    case "UK": {auth.CloudInstance = CloudInstance.UK;};break;
                    case "US": { auth.CloudInstance = CloudInstance.Default;}; break;
                }
            }

            try
            {
                IIdentityProvider identityProvider = new CloudIdentityProvider();
                var userAccess = identityProvider.Authenticate(auth);
            }
            catch (ResponseException ex2)
            {
                Console.WriteLine("Authentication failed with the following message: {0}",ex2.Message);
                Environment.Exit(1);
            }

            try
            {
                var cloudFilesProvider = new CloudFilesProvider(auth);
                containerList = cloudFilesProvider.ListContainers();

                foreach (Container container in containerList)
                {
                    if (container.Name == targetContainer)
                    {
                        containerExists = true;
                        break;
                    }
                }

                if (!containerExists)
                {
                    Console.WriteLine("Container \"{0}\" does not exist on the provided CloudFiles account.", targetContainer);
                    Environment.Exit(1);
                }
                if (!File.Exists(filePath))
                {
                    Console.WriteLine("The file specified ({0}) does not exist", filePath);
                    Environment.Exit(1);
                }
                cloudFilesProvider.CreateObjectFromFile(targetContainer, @filePath, Path.GetFileName(filePath));
            }
            catch (Exception ex2)
            {
                Console.WriteLine(ex2.Message);
                Environment.Exit(1);
            }
            Console.WriteLine("*SUCCESS* File: \"{0}\" uploaded to \"{1}\"", filePath, targetContainer);
        }
Пример #13
0
        public void Should_Throw_Error_When_Authenticating_With_Invalid_Username()
        {
            var identity = new RackspaceCloudIdentity()
            {
                Username = "******",
                APIKey = "bad api key"
            };
            IIdentityProvider serviceProvider = new IdentityProvider();

            try
            {
                var userAccess = serviceProvider.Authenticate(identity);

                throw new Exception("This code path is invalid, exception was expected.");
            }
            catch (net.openstack.Core.Exceptions.Response.ResponseException)
            {
                Assert.IsTrue(true);
            }
        }
        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();
            }
        }