CloudIdentity on openstacksdknet (Could not find u

2019-07-14 17:33发布

问题:

I am working on a Cloud Backup client by using OpenStack SDK .NET and I'm trying to identify with user credentials, sent to me from the server administrator. For the test everything seems to work perfect on the python openstack client. I use Advanced Rest Client Chrome Extension to get the token:

http://xx.xx.xx.xx:5000/v3/auth/tokens
POST METHOD

Header:
Content-Type: application/json

Body:

{
    "auth": {
        "identity": {
            "methods": [
                "password"
            ],
            "password": {
                "user": {
                    "id": "e5f4ec652c5e4d97b8fe6266113ac9f3",
                    "password": "PasswordFromAdministrator"
                }
            }
        },
        "scope": {
            "project": {
                "id": "9b594b7c51484702b6b4d1a91c6aa2ed"
            }
        }
    }
}

The response is with status Created (201):

Date: Tue, 20 Oct 2015 10:28:26 GMT 
Server: Apache/2.4.7 (Ubuntu) 
X-Subject-Token: d3b8133fea7846abbe2f023f410e3294
Vary: X-Auth-Token 
x-openstack-request-id: req-a517ee76-9353-4c7c-b646-47f566c84838
Content-Length: 1756 
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json 

With the X-Subject-Token I log into a openstack server with python client with the command:

openstack --os-url http://xx.xx.xx.xx:5000/v3 --os-identity-api-version 3 --os-token=d3b8133fea7846abbe2f023f410e3294

And the authorization is OK. Projects, Users, Containers, everything is listed perfect. The problem comes, when I try to use OpenStack APIs for .NET. I use OpenStack SDK .NET and CloudIdentity Class in all forms (CloudIdentity, CloudIdentityWithProject) and the response allays is "Could not find user XXXX (Disable debug mode to suppress these details.)":

    static void Main(string[] args)
    {
        var username = "myuser";
        var password = "PasswordFromAdministrator";
        var project_name = "backup";
        var project_id = "9b594b7c51484702b6b4d1a91c6aa2ed";
        var auth_url = "http://xx.xx.xx.xx:5000/v3";
        var region = "RegionOne";

        var identity = new CloudIdentityWithProject()
        {
            Username = username,
            Password = password,
            ProjectId = new ProjectId(project_id),
            ProjectName = project_name
        };

        //var identity = new CloudIdentity()
        //{
            //Username = username,
            //Password = password,
        //};

        var identityProvider = new OpenStackIdentityProvider(new Uri(auth_url));

        var conn = new CloudFilesProvider(identity, identityProvider);

        // step-2
        var containers = conn.ListContainers();
        foreach (var container in containers)
        {
            Console.WriteLine(string.Format("Container Name: {1}", container.Name));
        }
    }

The user exists in the server and have administrative role for the project. So the questions are: 1. Is this the right way to identity in openstack server? 2. If not, is there better API for backup files in openstack?

回答1:

Unfortunately, at this time, OpenStack.NET only supports OpenStack Identity v2.0, not v3. Perhaps you can ask your administrator if there is a v2 identity endpoint available for you to use?

The roadmap has scheduled support for identity v3 in OpenStack.NET v1.5.2 (we are currently on v1.5.0.1). But that won't happen for a few months.