c# - Openstack authorization -
hello reading this,
i want list images openstack following code in c#:
using system; using microsoft.visualstudio.testtools.unittesting; using net.openstack.providers.rackspace; using net.openstack.core.domain; using net.openstack.core.providers; namespace repositoriestests { [testclass] public class rackspacetests { public string username = "mbar"; public string password = "password"; public string url = "http://192.168.5.55:5001/v3"; public string project_id = "a9b2b59f093f44d881b8ebccbba00901"; public string project_name = "test-nsix"; [testmethod] public void testconnection() { try { var identity = new cloudidentitywithproject() { username = username, password = password, projectid = new projectid(project_id), projectname = project_name }; var identityprovider = new openstackidentityprovider(new uri(url)); var serverprovider = new cloudserversprovider(identity, identityprovider); var images = serverprovider.listimages(region: "regionone"); }catch(exception ex) { assert.fail(ex.message); } } } }
when run example receive following error: the request have made requires authentication. checked in browser window url: http://192.168.5.55:5001/v3 , see server exists:
{"version": {"status": "stable", "updated": "2016-04-04t00:00:00z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}], "id": "v3.6", "links": [{"href": "http://192.168.5.55:5001/v3/", "rel": "self"}]}}
i'm not sure problem lies , why can not authorize.
this stacktrace:
w net.openstack.providers.rackspace.validators.httpresponsecodevalidator.validate(response response) w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\providers\rackspace\validators\httpresponsecodevalidator.cs:wiersz 48 w net.openstack.providers.rackspace.providerbase`1.checkresponse(response response) w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\providers\rackspace\providerbase`1.cs:wiersz 861 w net.openstack.providers.rackspace.providerbase`1.executerestrequest[t](cloudidentity identity, uri absoluteuri, httpmethod method, object body, dictionary`2 querystringparameter, dictionary`2 headers, boolean isretry, boolean istokenrequest, requestsettings requestsettings, func`7 callback) w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\providers\rackspace\providerbase`1.cs:wiersz 505 w net.openstack.providers.rackspace.providerbase`1.executerestrequest[t](cloudidentity identity, uri absoluteuri, httpmethod method, object body, dictionary`2 querystringparameter, dictionary`2 headers, boolean isretry, boolean istokenrequest, requestsettings settings) w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\providers\rackspace\providerbase`1.cs:wiersz 294 w net.openstack.core.providers.openstackidentityprovider.<>c__displayclass4_0.<getuseraccess>b__0() w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\core\providers\openstackidentityprovider.cs:wiersz 108 w net.openstack.core.caching.useraccesscache.<>c__displayclass2_0.<get>b__0(string k) w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\core\caching\useraccesscache.cs:wiersz 58 w system.collections.concurrent.concurrentdictionary`2.addorupdate(tkey key, func`2 addvaluefactory, func`3 updatevaluefactory) w net.openstack.core.caching.useraccesscache.get(string key, func`1 refreshcallback, boolean forcecacherefresh) w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\core\caching\useraccesscache.cs:wiersz 58 w net.openstack.core.providers.openstackidentityprovider.getuseraccess(cloudidentity identity, boolean forcecacherefresh) w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\core\providers\openstackidentityprovider.cs:wiersz 123 w net.openstack.providers.rackspace.cloudidentityprovider.authenticate(cloudidentity identity) w c:\bamboo\xml-data\build-dir\ostk-net19-bld\src\corelib\providers\rackspace\cloudidentityprovider.cs:wiersz 948 w repositoriestests.rackspacetests.testconnection() w d:\projekty\nsix\repositoriestests\rackspacetests.cs:wiersz 35
pass identityprovider cloudidentitywithproject object:
var identityprovider = new openstackidentityprovider(new uri(url), projectcloudid);
Comments
Post a Comment