+ All Categories
Home > Documents > Understanding Rackspace APIs

Understanding Rackspace APIs

Date post: 24-Feb-2016
Category:
Upload: yan
View: 40 times
Download: 0 times
Share this document with a friend
Description:
Understanding Rackspace APIs. Lesson 7. Rackspace for Developers. Rackspace APIs. - PowerPoint PPT Presentation
Popular Tags:
46
Understanding Rackspace APIs Lesson 7
Transcript
Page 1: Understanding Rackspace APIs

Understanding Rackspace APIsLesson 7

Page 2: Understanding Rackspace APIs

Rackspace for Developers

Page 3: Understanding Rackspace APIs

Rackspace APIs

“The Rackspace OpenStack API is a very powerful REST based api when orchestrating their Rackspace cloud environment. It gives customers the ability to spin up/spin down/ image/load balance/ DNS linking/ autoscale/etc via webservice calls.”

“In my opinion its the single most powerful api that a customer can use to manage their Rackspacce cloud environment without using the UI.The process of authentication validates the user’s credentials against some authority.”

Michael Cline, Sr Software Quality Engineer, Rackspace

Page 4: Understanding Rackspace APIs

Why Rackspace APIs?

• Automation / Management – Automate customers Cloud based environments- leveraging .NET IIS 8.0 based frameworks to orchestrate Rack Openstack environments.

• Cloud Servers provides the core features of the OpenStack Compute API v2 and also deploys certain Rackspace extensions. The OpenStack Compute API and the Rackspace extensions are known collectively as API v2.

Page 5: Understanding Rackspace APIs

Rackspace API v2

• API v2 is defined as a RESTful HTTP service that uses all aspects of the HTTP protocol, including methods, URIs, media types, and response codes. • To request next generation Cloud Servers services, you must first

issue an authentication request to the Rackspace Cloud Identity Service, which is an implementation of the OpenStack Keystone Identity Service v2.0. • API v2 supports both the JSON and XML data serialization request

and response formats

Page 6: Understanding Rackspace APIs

Rackspace SDKs

• Rackspace SDKs support multiple programming languagesA software development kit (SDK) is a set of tools and documentation to make it easier for software developers to use the open cloud. • Set of language bindings that provide a language-level API

for accessing cloud services (as opposed to forcing developers to use the REST/HTTP APIs directly) in a manner consistent with language standards

Page 7: Understanding Rackspace APIs

Rackspace APIs

http://openstacknetsdk.org/docs/

Page 8: Understanding Rackspace APIs

Rackspace APIs

Page 9: Understanding Rackspace APIs

Rackspace API – First Gen Servers

• Typical API Calls might do things like:• Create Server• Build Server• Change Administrator password• More

Page 10: Understanding Rackspace APIs

Rackspace API – Next Gen Servers

• Cloud Servers provides the core features of the OpenStack Compute API v2 and also deploys certain Rackspace extensions. The OpenStack Compute API and the Rackspace extensions are known collectively as API v2.

• Typical API Calls might do things like:• Create Server• Build Server• Change Administrator password• More

Page 11: Understanding Rackspace APIs

Rackspace API v1 & v2 - Differences

• If you have applications or scripts that use first generation Cloud Servers API v1.0, you must revise them to use the next generation Cloud Servers API v2. Though many API v1.0 operations have the same names as API v2 operations, the following elements have changed in several API operations:

• Normal and error response codes• URI parameters• State transitions• Request body attributes• Response body fields• API v2 Developer Guide: http://

docs.rackspace.com/servers/api/v2/cs-devguide/content/ch_preface.html

Page 12: Understanding Rackspace APIs

Rackspace API – Files

• Cloud Files allows users to store/retrieve files via a simple Web Service (REST: Representational State Transfer) interface. • New Cloud Files storage applications such as the tools

described in the previous sections can be designed and developed by using the REST API. • For more details on developing Cloud Files applications,

please refer to the Rackspace Cloud Files API Developer Guide at http://docs.rackspacecloud.com/files/api/cf-devguide-latest.pdf.• Included in .Net SDK

Page 14: Understanding Rackspace APIs

Rackspace API – Databases

• Rackspace Cloud Databases is an OpenStack-based MySQL relational database service

• Rackspace Cloud Databases allows Rackspace customers to easily provision database instances of varying virtual resource sizes without the need to maintain and/or update MySQL.

• Interactions with Cloud Databases occur programmatically via the Cloud Databases API as described in this developer guide.

Page 15: Understanding Rackspace APIs

Rackspace API – Load Balancers

Page 16: Understanding Rackspace APIs

Rackspace API – Load Balancers

• System. Object net.openstack.Providers.Rackspace. ProviderBase< ILoadBalancerService> net.openstack.Providers.Rackspace. CloudLoadBalancerProvider

public class CloudLoadBalancerProvider : ProviderBase<ILoadBalancerService>, ILoadBalancerService

Page 17: Understanding Rackspace APIs

Rackspace API – Block Storage

• Rackspace Cloud Block Storage is a block level storage solution that allows customers to mount drives or volumes to their Rackspace Next Generation Cloud Servers™.

net.openstack.Providers.Rackspace. ProviderBase< IObjectStorageProvider> net.openstack.Providers.Rackspace. CloudFilesProvider

• Namespace: net.openstack.Providers.Rackspace

public class CloudFilesProvider : ProviderBase<IObjectStorageProvider>, IObjectStorageProvider

Page 18: Understanding Rackspace APIs

Rackspace API – DNS • Rackspace Cloud DNS is a Domain Name System (DNS) available to

Rackspace Cloud customers. Interactions with Rackspace Cloud DNS occur programmatically via the Rackspace Cloud DNS API.

Page 20: Understanding Rackspace APIs

Rackspace API – Backups

• Rackspace Cloud Backup - file-based backup application that lets you choose which files and folders to backup from your Cloud Server.

• Interactions with Rackspace Cloud Backup occur programmatically via the Rackspace Cloud Backup API as described in this Developer Guide.

• The Rackspace Cloud Backup API is implemented using a RESTful web service interface.

Page 21: Understanding Rackspace APIs

Rackspace API – Monitoring

• Rackspace Cloud monitoring includes:• Current system health• Alerts on failure conditions• Collection of historical data• Trending and capacity planning

• To keep track of your cloud resources and receive instant notification when a resource needs your attention, use the Cloud Monitoring API. This RESTful API enables you to quickly create multiple monitors with predefined checks, such as PING, HTTPS, SMTP, and many others.

Page 22: Understanding Rackspace APIs

Rackspace API – Networking

• The Cloud Networks Provider enable simple access to the Rackspace Cloud Network Services. Cloud Networks lets you create a virtual Layer 2 network, known as an isolated network, which gives you greater control and security when you deploy web applications.• Documentation URL: http://docs.rackspace.com/servers/api/v2/cn-

gettingstarted/content/ch_overview.html

public class CloudNetworksProvider : ProviderBase<INetworksProvider>, INetworksProvider

Page 23: Understanding Rackspace APIs

Rackspace API – Identity

• System. Object net.openstack.Providers.Rackspace. ProviderBase< IIdentityProvider> net.openstack.Providers.Rackspace. CloudIdentityProvider

• Namespace: net.openstack.Providers.Rackspace

public class CloudIdentityProvider : ProviderBase<IIdentityProvider>, IExtendedCloudIdentityProvider, IIdentityProvider, IIdentityService

Page 25: Understanding Rackspace APIs

Rackspace API – Autoscale

• Rackspace Auto Scale is an API-based tool that automatically scales resources in response to an increase or decrease in overall workload based on user-defined thresholds.

Page 26: Understanding Rackspace APIs

Rackspace APIs – languages supportedThese are the SDKs that are currently available:

• Rackspace Cloud SDK for Java• Rackspace Cloud SDK for PHP• Rackspace Cloud SDK for Python• Rackspace Cloud SDK for Ruby• Rackspace Cloud SDK for Microsoft .NET• Rackspace Cloud SDK for node.js

Page 27: Understanding Rackspace APIs

Rackspace SDKs – sign up information• Before you can use these SDKs, you need to have access to a Rackspace

cloud account and have enabled API access. That is, you must have signed up for the Rackspace Cloud at http://www.rackspace.com/cloud and you must have an API key.

• To find your API key:• Sign in to the Cloud Control Panel. • Click on your user name in the upper-right side of the top navigation

pane.• Select API Keys from the menu.• Follow the instructions on the page.• http://50.56.176.226/OCA/activities/CloudAPI (additional information)

Page 28: Understanding Rackspace APIs

Rackspace SDKs – Installation• To install the SDK into your project, you will need:

• Visual Studio 2010 or higher (any version will work)• .NET 4.0 or higher• NuGet Package Manager

• Once you have created your .NET project created, you can install the SDK using the NuGet Package Manager Console (Found by click on View->Other Windows->Package Manager Console).

• To install openstack.net, run the following command in the Nuget Package Manager Console:

Page 29: Understanding Rackspace APIs

Rackspace SDKs – Installation Video

http://openstacknetsdk.org/

Page 30: Understanding Rackspace APIs

Rackspace SDK – Code Samples

Page 31: Understanding Rackspace APIs

Rackspace SDK – Code Samples • Cloud Identity - Authenticate with username and

password//Required namespaces using net.openstack.Providers.Rackspace; using net.openstack.Core.Providers; using net.openstack.Core.Exceptions.Response;

//Code snippettry { IIdentityProvider identityProvider = new CloudIdentityProvider(); var userAccess = identityProvider.Authenticate(new RackspaceCloudIdentity{ Username = "MyUserName", Password = "MyPassword" }); } catch(ResponseException ex2) { // do something }

https://github.com/rackspace/openstack.net/wiki/Code-Samples

Page 32: Understanding Rackspace APIs

Rackspace SDK – Code Samples • Cloud Identity - Authenticate with username and API

Keytry { IIdentityProvider identityProvider = new CloudIdentityProvider();var userAccess = identityProvider.Authenticate(new RackspaceCloudIdentity{Username = "MyUserName",APIKey = "MyAPIKey“}); }catch(ResponseException ex2) {// do something }

https://github.com/rackspace/openstack.net/wiki/Code-Samples

Page 33: Understanding Rackspace APIs

Rackspace SDK – Code Samples • Cloud Identity – User Details and Roles – Retrieve

Users Details by Nametry { IIdentityProvider identityProvider = new CloudIdentityProvider(); var identity = new RackspaceCloudIdentity{ Username = "MyUserName", APIKey = "MyPassword" }; var userDetails = identityProvider.GetUserByName(identity, "MyUserName"); }catch(ResponseException ex2){ // do something}

https://github.com/rackspace/openstack.net/wiki/Code-Samples

Page 34: Understanding Rackspace APIs

Rackspace SDK – Code Samples • Cloud Identity - Retrieve user details by user id

try {IIdentityProvider identityProvider = new CloudIdentityProvider(); var identity = new RackspaceCloudIdentity{ Username = "MyUserName", APIKey = "MyPassword" }; var userDetails = identityProvider.GetUser(identity, "UserId"); } catch(ResponseException ex2){// do something}

https://github.com/rackspace/openstack.net/wiki/Code-Samples

Page 35: Understanding Rackspace APIs

Rackspace SDK – Code Samples • Cloud Identity – Administrative User Methods – List

All Global Rolestry {IIdentityProvider identityProvider = new CloudIdentityProvider(); var identity = new RackspaceCloudIdentity{ Username = "MyAdminUserName", APIKey = "MyAdminPassword" }; var userDetails = identityProvider.ListRoles(identity) } catch(ResponseException ex2) {// do something}

https://github.com/rackspace/openstack.net/wiki/Code-Samples

Page 36: Understanding Rackspace APIs

Rackspace SDK – Code Samples

Page 37: Understanding Rackspace APIs

Rackspace SDK – Code Samples • Cloud Servers – 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" };

Page 38: Understanding Rackspace APIs

Rackspace SDK – Code Samples

• This returns IEnumerable<SimpleServerImage> with each SimpleServerImage containing values for the image name and ID. The ID is later used when creating a server.

• There are 2 ways to pass in the identity credentials to CloudBlockStorageProvider:

1.In the constructor.2.Into each method individually.

• Our samples below will assume the identity has been passed into the constructor.

Listing Available Servers

var cloudServers = new CloudServersProvider(cloudIdentity); var images = cloudServers.ListImages();

Page 39: Understanding Rackspace APIs

Rackspace SDK – Code Samples

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.

• Listing available server flavors - with details

• Listing available server flavorsvar cloudServers = new CloudServersProvider(cloudIdentity); var flavors = cloudServers.ListFlavors();

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 flavors = cloudServers.ListFlavorsWithDetails();

Page 40: Understanding Rackspace APIs

Rackspace SDK – Code Samples

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

• Retrieve server details

• Creating a server in the account's default regionvar cloudServers = new CloudServersProvider(cloudIdentity); var server = cloudServers.CreateServer("server-name", "image-id", "flavor-id");

This will return a Server object containing all details of the cloud server.

var cloudServers = new CloudServersProvider(cloudIdentity); var server = cloudServers.GetDetails("server-id");

Page 41: Understanding Rackspace APIs

Rackspace SDK – Code Samples

Page 42: Understanding Rackspace APIs

Rackspace SDK – Code Samples CloudBlockStorageProvider requires 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" };

This will return a Server object containing all details of the cloud server.

var cloudIdentity = new CloudIdentity() { APIKey = "apikey", Username = "username" };

or

Page 43: Understanding Rackspace APIs

Rackspace SDK – Code Samples There are 2 ways to pass in the identity credentials to CloudBlockStorageProvider:

1. In the constructor.2. Into each method individually.

Our samples below will assume the identity has been passed into the constructor.

Page 44: Understanding Rackspace APIs

Rackspace SDK – Code Samples

Create Volumes

Volumes

var provider = new CloudBlockStorageProvider(); bool volumeCreatedResponse = provider.CreateVolume(100, "Test Volume Description", "Test Volume", null, "SATA", null, cloudIdentity);

var provider = new CloudBlockStorageProvider(); IEnumerable<Volume> volumeListResponse = provider.ListVolumes(null, cloudIdentity);

List Volumes

Page 45: Understanding Rackspace APIs

Rackspace SDK – Code Samples

Show Volumes

Volumes

var provider = new CloudBlockStorageProvider(); Volume singleVolumeResponse = provider.ShowVolume({volume_id}, null, cloudIdentity);

var provider = new CloudBlockStorageProvider(); bool deleteVolumeResult= provider.DeleteVolume({volume_id}, null, cloudIdentity);

Delete Volumes

Page 46: Understanding Rackspace APIs

Q&A


Recommended