-
Notifications
You must be signed in to change notification settings - Fork 101
Rackspace Cloud Servers Code Samples
Here we will provide samples for basic operations on CloudServersProvider
.
CloudServersProvider
requries we pass in CloudIdentity
. We can create CloudIdentity
by passing any 2 combination Username/Password or Username/APIKey.
var cloudIdentity = new CloudIdentity() { Username = "username", Password = "password" };
or
var cloudIdentity = new CloudIdentity() { APIKey = "apikey", Username = "username" };
For more information on IdentityProvider
There are 2 ways to pass in the identity credentials to CloudBlockStorageProvider:
- In the constructor.
- Into each method individually.
Our samples below will assume the identity has been passed into the constructor.
var cloudServers = new CloudServersProvider(cloudIdentity);
var images = cloudServers.ListImages();
This returns IEnumerable<SimpleServerImage>
with each SimpleServerImage
containing values for the image name and ID. The ID is later used when creating a server.
var cloudServers = new CloudServersProvider(cloudIdentity);
var flavors = cloudServers.ListFlavors();
This returns IEnumerable<Flavor>
with each Flavor
containing the values for the flavor name and ID. The ID is later used when creating a server.
var cloudServers = new CloudServersProvider(cloudIdentity);
var flavors = cloudServers.ListFlavorsWithDetails();
This returns IEnumerable<FlavorDetails>
with each FlavorDetails
containing the values for the flavor name and ID. The ID is later used when creating a server. It also contains RAM, disk and vCPU values.
var cloudServers = new CloudServersProvider(cloudIdentity);
var server = cloudServers.CreateServer("server-name", "image-id", "flavor-id");
This will return a NewServer
object which will contain the default admin password. This is the only time the password can be retrieved from the server without resetting it
var cloudServers = new CloudServersProvider(cloudIdentity);
var server = cloudServers.GetDetails("server-id");
This will return a Server
object containing all details of the cloud server.
var cloudServers = new CloudServersProvider(cloudIdentity);
var server = cloudServers.DeleteServer("server-id");
Returns a bool
indicating if the action was successful