Using our own hardware, we've installed vanilla openstack with all components however I am having problems accessing services other than the Identity due to a region issue. The code used is as follows called with the admin account and admin tennant we created...
public static void TestAccess(string userName, string password, string projectName, string projectId)
{
try
{
Uri baseUrl = new Uri(URL_IDENTITY);
CloudIdentityWithProject projectCloudId = new CloudIdentityWithProject();
projectCloudId.Username = userName;
projectCloudId.Password = password;
projectCloudId.ProjectName = projectName;
projectCloudId.ProjectId = new ProjectId(projectId);
OpenStackIdentityProvider idProvider = new OpenStackIdentityProvider(baseUrl, projectCloudId);
UserAccess userAccess = idProvider.Authenticate(projectCloudId);
IEnumerable<ExtendedEndpoint> eps = idProvider.ListEndpoints(userAccess.Token.Id);
string reg = idProvider.DefaultRegion; // This is null
ServiceCatalog[] scs = userAccess.ServiceCatalog;
// Get the list of regions
regionList = new List<string>();
foreach (ServiceCatalog sc in scs)
{
foreach (Endpoint ep in sc.Endpoints)
{
regionList.Add(ep.Region); // This is 'regionOne' in every case
}
}
// Try stuff...
foreach(string region in regionList.Distinct())
{
// Get a list of containers
CloudFilesProvider cfp = new CloudFilesProvider(projectCloudId, idProvider);
// THIS LINE FAILS
IEnumerable<Container> listOfContainers = cfp.ListContainers(region: region);
foreach (Container ctnr in listOfContainers)
{
Console.WriteLine("Container: {0}", ctnr.Name);
}
CloudNetworksProvider cnp = new CloudNetworksProvider(identity: null, identityProvider: idProvider);
IEnumerable<CloudNetwork> networks = cnp.ListNetworks(identity: null, region: region);
foreach (CloudNetwork network in networks)
{
Console.WriteLine("Network[{0}] name: {1}", networkCount, network.Label);
Console.WriteLine("Network[{0}] Id: {1}", networkCount, network.Id);
++networkCount;
}
Console.WriteLine("{0} networks listed.", networkCount);
}
}
catch(Exception ex)
{
throw;
}
}
The code fails at the call to ListContainers(region: region) with the error... 'The user does not have access to the requested service or region' where as if I don't specify a region the error is simply 'No region was provided, the service does not provide a region-independent endpoint, and there is no default region set for the user's account'
We are only accessing our internal network at the moment so regions aren't important to us yet...
Also of note is that when making a call to...
CloudNetwork detail = cnp.ShowNetwork(networkGuid, "regionOne");
of a network I can see returns the error 'The item was not found or does not exist.'
Help and advice much appreciated.
I managed to extend the functionality of the Openstack.Net SDK fairly simply. The code below extends it to include various functions for Tenant/Project manipulations...
Firstly, create a NewTenant container that will be used to pass data to and from the webservices, I've put it in the same namespace as the others...
Now we can create any new Request classes for posting the data...
Now create the Response objects for the requests to help retrieve the data
Now we can create a class that inherits from OpenStackIdentityProvider with the additional functionality for Tenant/Project manipulation that we want...
I imagine that this functionality will appear in the GitHub version soon, but if not I hope it's useful.