简体   繁体   中英

How to create a new server using OpenStack.NET

I am new to OpenStack, just a few hours experience. I want to create a new machine using OpenStack.NET and this is the code that I come up with.

var identityUrl = "http://server:5000/v2.0";
var imageUrl = "http://server:9292";
var username = "username";
var password = "password";

var cloudId = new CloudIdentity() { Username = username, Password = password };
var cloudIdProvider = new CloudIdentityProvider(new Uri(identityUrl));

cloudIdProvider.Authenticate(cloudId);

var cloudServersProvider = new CloudServersProvider(cloudId, cloudIdProvider);

var newServer = cloudServersProvider.CreateServer("cloudServerName", "Windows Server 2012", "m1.medium");

identityUrl is the url for identity service imageUrl is the url for image service

I can authenticate on cloudIdProvider.Authenticate(cloudId); line so I think the identity service and username/password are correct.

When I debug on cloudServersProvider.CreateServer("cloudServerName", "Windows Server 2012", "m1.medium"); , it throws 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. exception which I don't know how to fix it.

The Identity Service is likely failing to include information about the Compute Service endpoint, because you did not specify the tenantName and/or tenantId during authentication. The next release of the SDK will include support for specifying these as described in the preview build of the OpenStack Authentication documentation. However, since the described classes do not exist in the 1.3.1.0 release, you'll need to include a copy of them in your project until 1.3.2.0 is released.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM