1 / 46

Understanding Rackspace APIs

Understanding Rackspace APIs. Lesson 7. Rackspace for Developers. Rackspace APIs.

yan
Télécharger la présentation

Understanding Rackspace APIs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Understanding Rackspace APIs Lesson 7

  2. Rackspace for Developers

  3. 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.Theprocess of authentication validates the user’s credentials against some authority.” Michael Cline, Sr Software Quality Engineer, Rackspace

  4. 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.

  5. Rackspace API v2 • API v2 is defined as a RESTfulHTTP 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

  6. Rackspace SDKs • Rackspace SDKs support multiple programming languages A 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

  7. Rackspace APIs http://openstacknetsdk.org/docs/

  8. Rackspace APIs

  9. Rackspace API – First Gen Servers • Typical API Calls might do things like: • Create Server • Build Server • Change Administrator password • More

  10. 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

  11. 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

  12. 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

  13. Rackspace API – Files • System. Objectnet.openstack.Providers.Rackspace. ProviderBase< IObjectStorageProvider> net.openstack.Providers.Rackspace. CloudFilesProvider • Namespace:net.openstack.Providers.Rackspace public class CloudFilesProvider : ProviderBase<IObjectStorageProvider>, IObjectStorageProvider

  14. 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.

  15. Rackspace API – Load Balancers

  16. Rackspace API – Load Balancers • System. Objectnet.openstack.Providers.Rackspace. ProviderBase< ILoadBalancerService> net.openstack.Providers.Rackspace. CloudLoadBalancerProvider public class CloudLoadBalancerProvider : ProviderBase<ILoadBalancerService>, ILoadBalancerService

  17. 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

  18. 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.

  19. Rackspace API – DNS • System. Objectnet.openstack.Providers.Rackspace. ProviderBase< IDnsService> net.openstack.Providers.Rackspace. CloudDnsProvider • Namespace:net.openstack.Providers.Rackspace public class CloudDnsProvider : ProviderBase<IDnsService>, IDnsService

  20. 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.

  21. 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.

  22. 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

  23. Rackspace API – Identity • System. Objectnet.openstack.Providers.Rackspace. ProviderBase< IIdentityProvider> net.openstack.Providers.Rackspace. CloudIdentityProvider • Namespace:net.openstack.Providers.Rackspace public class CloudIdentityProvider : ProviderBase<IIdentityProvider>, IExtendedCloudIdentityProvider, IIdentityProvider, IIdentityService

  24. Rackspace API – Queues • System. Objectnet.openstack.Providers.Rackspace. ProviderBase< IQueueingService> net.openstack.Providers.Rackspace. CloudQueuesProvider • Namespace:net.openstack.Providers.Rackspace public class CloudQueuesProvider : ProviderBase<IQueueingService>, IQueueingService

  25. 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.

  26. Rackspace APIs – languages supported These 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

  27. 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)

  28. 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 • NuGetPackage 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:

  29. Rackspace SDKs – Installation Video http://openstacknetsdk.org/

  30. Rackspace SDK – Code Samples

  31. 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 snippet try { IIdentityProvideridentityProvider = new CloudIdentityProvider(); varuserAccess = identityProvider.Authenticate(new RackspaceCloudIdentity { Username = "MyUserName", Password = "MyPassword" }); } catch(ResponseException ex2) { // do something } https://github.com/rackspace/openstack.net/wiki/Code-Samples

  32. Rackspace SDK – Code Samples • Cloud Identity - Authenticate with username and API Key try { IIdentityProvideridentityProvider = new CloudIdentityProvider(); varuserAccess = identityProvider.Authenticate(new RackspaceCloudIdentity { Username = "MyUserName", APIKey= "MyAPIKey“ }); } catch(ResponseExceptionex2) { // do something } https://github.com/rackspace/openstack.net/wiki/Code-Samples

  33. Rackspace SDK – Code Samples • Cloud Identity – User Details and Roles – Retrieve Users Details by Name try { IIdentityProvideridentityProvider = new CloudIdentityProvider(); var identity = new RackspaceCloudIdentity{ Username = "MyUserName", APIKey = "MyPassword" }; varuserDetails = identityProvider.GetUserByName(identity, "MyUserName"); } catch(ResponseExceptionex2) { // do something } https://github.com/rackspace/openstack.net/wiki/Code-Samples

  34. Rackspace SDK – Code Samples • Cloud Identity - Retrieve user details by user id try { IIdentityProvideridentityProvider = new CloudIdentityProvider(); var identity = new RackspaceCloudIdentity{ Username = "MyUserName", APIKey = "MyPassword" }; varuserDetails = identityProvider.GetUser(identity, "UserId"); } catch(ResponseExceptionex2) { // do something } https://github.com/rackspace/openstack.net/wiki/Code-Samples

  35. Rackspace SDK – Code Samples • Cloud Identity – Administrative User Methods – List All Global Roles try { IIdentityProvideridentityProvider = new CloudIdentityProvider(); var identity = new RackspaceCloudIdentity{ Username = "MyAdminUserName", APIKey = "MyAdminPassword" }; varuserDetails = identityProvider.ListRoles(identity) } catch(ResponseException ex2) { // do something } https://github.com/rackspace/openstack.net/wiki/Code-Samples

  36. Rackspace SDK – Code Samples

  37. Rackspace SDK – Code Samples • Cloud Servers – CloudServersProviderrequries we pass in CloudIdentity. We can create CloudIdentity by passing any 2 combination Username/Password or Username/APIKey. varcloudIdentity = new CloudIdentity() { Username = "username", Password = "password" }; Or varcloudIdentity = new CloudIdentity() { APIKey = "apikey", Username = "username" };

  38. 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. • This returns IEnumerable<SimpleServerImage> with each SimpleServerImage containing values for the image name and ID. The ID is later used when creating a server. Listing Available Servers varcloudServers = new CloudServersProvider(cloudIdentity); var images = cloudServers.ListImages();

  39. Rackspace SDK – Code Samples • Listing available server flavors 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 varcloudServers = new CloudServersProvider(cloudIdentity); var flavors = cloudServers.ListFlavors(); varcloudServers = 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.

  40. Rackspace SDK – Code Samples • Creating a server in the account's default region 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 varcloudServers = new CloudServersProvider(cloudIdentity); var server = cloudServers.CreateServer("server-name", "image-id", "flavor-id"); varcloudServers = new CloudServersProvider(cloudIdentity); var server = cloudServers.GetDetails("server-id"); This will return a Server object containing all details of the cloud server.

  41. Rackspace SDK – Code Samples

  42. Rackspace SDK – Code Samples CloudBlockStorageProvider requires we pass in CloudIdentity. We can create CloudIdentity by passing any 2 combination. Username/Password or Username/ APIKey. varcloudIdentity = new CloudIdentity() { Username = "username", Password = "password" }; or varcloudIdentity = new CloudIdentity() { APIKey = "apikey", Username = "username" }; This will return a Server object containing all details of the cloud server.

  43. 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.

  44. Rackspace SDK – Code Samples Volumes Create Volumes var provider = new CloudBlockStorageProvider(); boolvolumeCreatedResponse = provider.CreateVolume(100, "Test Volume Description", "Test Volume", null, "SATA", null, cloudIdentity); List Volumes var provider = new CloudBlockStorageProvider(); IEnumerable<Volume> volumeListResponse = provider.ListVolumes(null, cloudIdentity);

  45. Rackspace SDK – Code Samples Volumes Show Volumes var provider = new CloudBlockStorageProvider(); Volume singleVolumeResponse = provider.ShowVolume({volume_id}, null, cloudIdentity); Delete Volumes var provider = new CloudBlockStorageProvider(); booldeleteVolumeResult= provider.DeleteVolume({volume_id}, null, cloudIdentity);

  46. Q&A

More Related