static void Main(string[] args) { const string region = "RegionOne"; // Configure OpenStack.NET OpenStackNet.Configure(options => options.DefaultTimeout = TimeSpan.FromSeconds(5)); // Authenticate var identityUrl = new Uri("http://example.com"); var user = new CloudIdentityWithProject(); var identity = new OpenStackIdentityProvider(identityUrl, user); identity.Authenticate(); // Use legacy and new providers var legacyNetworking = new CloudNetworksProvider(null, identity); legacyNetworking.ListNetworks(); var networks = new NetworkingService(identity, region); networks.ListNetworks(); var legacyCompute = new CloudServersProvider(null, identity); legacyCompute.ListServers(); var compute = new ComputeService(identity, region); compute.ListServers(); }
public void AuthenticateTest() { var userAccess = _identityService.Authenticate(); Assert.NotNull(userAccess); Assert.NotNull(userAccess.Token); Assert.NotNull(userAccess.Token.Id); Assert.NotNull(userAccess.ServiceCatalog); Assert.NotEmpty(userAccess.ServiceCatalog); }
private static void CopyToOvh() { Console.WriteLine("Copy to OVH"); var username = GetSetting("username"); var password = GetSetting("password"); var projectname = GetSetting("projectname"); var containerName = GetSetting("containername"); var uri = GetSetting("uri"); var zipFolder = GetSetting("zipfolder"); var zipFs = zipFolder.Split(';'); foreach (var zipF in zipFs) { var identityEndpoint = new Uri(uri); var identity = new CloudIdentityWithProject { Username = username, Password = password, ProjectName = projectname }; var identityProvider = new OpenStackIdentityProvider(identityEndpoint, identity); // Verify that we can connect and our credentials are correct identityProvider.Authenticate(); var provider = new CloudFilesProvider(identity, identityProvider); var filelist = Directory.GetFiles(zipF, "*.zip"); if (filelist.Any()) { foreach (var filePath in filelist) { Console.WriteLine("Copy OpenStack: " + DateTime.UtcNow + " " + filePath); var objectName = Path.GetFileName(filePath); // Method 2: Set metadata in a separate call after the object is created provider.CreateObjectFromFile(containerName, filePath, objectName, null, 4096, null, "GRA1"); var metadata = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase) { { "Key", "Value" } }; provider.UpdateObjectMetadata(containerName, objectName, metadata, "GRA1"); } } } }