Movatterモバイル変換


[0]ホーム

URL:


PPT, PDF13,601 views

Intro to CloudStack API

The document introduces the CloudStack API, outlining its documentation, client libraries, and methods for making authenticated and unauthenticated HTTP API calls. It describes the architectural principles of REST and provides examples of API requests along with code snippets for building a REST interface using Flask. Additionally, it invites contributions and engagement from the community regarding the development and use of CloudStack.

Embed presentation

Downloaded 141 times
Introduction to the CloudStackAPISebastien Goasguen@sebgoa
Outline• Documentation• Clients• Exploration• Integration port• Signing requests• REST or not REST
Documentationhttp://cloudstack.apache.org/docs/api/apidocs-4.0.0/TOC_Root_Admin.htmlhttp://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.0.1-incubating/html/API_Developers_Guide/index.html
Clients• 15 clients andcounting… on Github• Java, Python, Perl,Ruby, C#, php, Clojure
Exploration• Use a debugger console• E.g Firebug• As you navigate the UI,check the http calls thatare being made• Identify the methods• Identify the parameterspassed to each call
HTTPbased• API calls made via HTTP(s)• Pass name of the call as command• Pass list of key/value pairs as arguments tothe call• GET method• Response can be XML or JSON• Query API that is RESTlikehttp://gehrcke.de/2009/06/aws-about-api/
Integration Port• Unauthenticated call– Dangerous– Don’t open it all– Certainly don’t open it to the public internet• Set the port on the UI
Using theintegration porthttp://localhost:8096/client/api?command=listUsers&response=jsoncurl 'http://localhost:8096/client/api?command=listUsers&response=json'{ "listusersresponse" : { "count":3 ,"user" : [ {"id":"7ed6d5da-93b2-4545-a502-23d20b48ef2a","username":"admin","firstname":"admin","lastname":"cloud","created":"2012-07-05T12:18:27-0700","state":"enabled","account":"admin","accounttype":1,"domainid":"8a111e58-e155-4482-93ce-84efff3c7c77","domain":"ROOT","apikey":"plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg”…http://localhost:8096/client/api?command=listUserscurl http://localhost:8096/client/api?command=listUsers<?xml version="1.0" encoding="ISO-8859-1"?><listusersresponse cloud-stack-version="3.0.3.2012-07-04T06:31:57Z"><count>3</count><user><id>7ed6d5da-93b2-4545-a502-23d20b48ef2a</id><username>admin</username><firstname>admin</firstname><lastname>cloud</lastname><created>2012-07-05T12:18:27-0700</created><state>enabled</state><account>admin</account><accounttype>1</accounttype><domainid>8a111e58-e155-4482-93ce-84efff3c7c77</domainid><domain>ROOT</domain><apikey>plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg…http://www.shapeblue.com/2012/05/10/using-the-api-for-advanced-network-management/
Authenticated calls• Using http(s)• API endpoint for the cloud– http://localhost:8080/client/api?• Command key to pass the name of the call• Key/value pairs for the arguments• API key of the user making the call• Signature for authorization
API Keys• Generate API keys for the user that will accessthe cloud
Creating the signature• Form the request url: list of key=valuepairs joined by & and encoded for httptransport• Compute the signature:– lower case values, replace + with %20– generate the hmac using sha1 hash function– Base64 encode the digest– Encode for http transport• Form the entire request adding the signature:&signature=
Example>>> request{'apikey': 'plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg', 'command': 'listUsers','response': 'json'}>>>request_url="&".join(["=".join([r,urllib.quote_plus(request[r])]) for r in request.keys()])>>>sig_url="&".join(["=".join([r.lower(),urllib.quote_plus(request[r]).lower()]) for r in sorted(request.iterkeys())])>>>sig=urllib.quote_plus(base64.encodestring(hmac.new(secretkey,sig_url,hashlib.sha1).digest()).strip())>>> req=url+request_url+'&signature='+sig>>> res=urllib2.urlopen(req)>>> res.read()
REST• REST stands for Representational StateTransfer• Architectural style to design web servicesintroduced by Roy Fielding (former ASF chair)• Premise:– HTTP protocol is enough to create web servicesand change the state of web resources– HTTP methods can be used to change the state– Eases web services design compared to SOAPhttp://en.wikipedia.org/wiki/Roy_Fieldinghttp://en.wikipedia.org/wiki/Representational_State_Transfer
REST• REST style web services couple beimplemented with other protocol than http• But http provides all that is neededhttp://en.wikipedia.org/wiki/Representational_State_Transfer
REST API• The CloudStack API is a query API• It is RESTlike but not RESTfull• Example:listUsers() a GET vs GETupdateUser() a GET vs PATCHcreateUser() a GET vs POSTdeleteUser() a GET vs DELETEhttp://gehrcke.de/2009/06/aws-about-api/http://publish.luisrei.com/articles/flaskrest.html
Exercise• Build a REST interface to CloudStack• Use Flask a Lightweight Python webframeworkhttp://flask.pocoo.orghttp://publish.luisrei.com/articles/flaskrest.html
Exercisefrom flask import Flaskapp = Flask(__name__)@app.route("/")def hello():return "Hello World!"if __name__ == "__main__":app.run(debug=True)Flask allows you to define web routes andfunctions that get executed when these routesare called.
Exercise@app.route('/login', methods=['GET', 'POST'])def login():if request.method == 'POST':do_the_login()else:show_the_login_form()curl -X DELETEhttp://localhost:5000/user/b3b60a8dfdf6f-4ce6-a6f9-6194907457a5{ "deleteuserresponse" : { "success" : "true"} }https://github.com/runseb/cloudstack-flaskhttp://buildacloud.org/blog/253-to-rest-or-not-to-rest.html
Info• Apache Top Level Project (TLP)• http://cloudstack.apache.org• #cloudstack and #cloudstack-dev on irc.freenode.net• @CloudStack on Twitter• http://www.slideshare.net/cloudstack• dev-subscribe@cloudstack.apache.org• users-subscribe@cloudstack.apache.orgWelcoming contributions and feedback, Join the fun !

Recommended

PPT
CloudMonkey
PDF
iOS Application Security
PPTX
WebdriverIO: the Swiss Army Knife of testing
PPTX
Kubernetes and container security
PPTX
Introducing Swagger
PPT
Docker and CloudStack
PPT
Masakari project onboarding
PPTX
44CON 2014 - Meterpreter Internals, OJ Reeves
 
PDF
Kubernetes security
PDF
Hacking and Defending APIs - Red and Blue make Purple.pdf
PDF
Demystifying OAuth 2.0
PPTX
Express JS Rest API Tutorial
PDF
Spring boot introduction
PDF
Ansible 101
PDF
Neat tricks to bypass CSRF-protection
PDF
Introduction to Hibernate Framework
PDF
How to write a Dockerfile
PDF
Docker compose
PDF
Java 8 Lambda Built-in Functional Interfaces
PDF
Serving ML easily with FastAPI - meme version
PDF
Introduction to ASP.NET Core
PDF
Monitoring in CloudStack
PDF
A Introduction of Packer
PPT
Java
PDF
Packer by HashiCorp
PDF
Kubernetes Webinar - Using ConfigMaps & Secrets
PPTX
Constructors in java
PDF
Angular Observables & RxJS Introduction
PPTX
PPT
CloudStack and BigData

More Related Content

PPT
CloudMonkey
PDF
iOS Application Security
PPTX
WebdriverIO: the Swiss Army Knife of testing
PPTX
Kubernetes and container security
PPTX
Introducing Swagger
PPT
Docker and CloudStack
PPT
Masakari project onboarding
PPTX
44CON 2014 - Meterpreter Internals, OJ Reeves
 
CloudMonkey
iOS Application Security
WebdriverIO: the Swiss Army Knife of testing
Kubernetes and container security
Introducing Swagger
Docker and CloudStack
Masakari project onboarding
44CON 2014 - Meterpreter Internals, OJ Reeves
 

What's hot

PDF
Kubernetes security
PDF
Hacking and Defending APIs - Red and Blue make Purple.pdf
PDF
Demystifying OAuth 2.0
PPTX
Express JS Rest API Tutorial
PDF
Spring boot introduction
PDF
Ansible 101
PDF
Neat tricks to bypass CSRF-protection
PDF
Introduction to Hibernate Framework
PDF
How to write a Dockerfile
PDF
Docker compose
PDF
Java 8 Lambda Built-in Functional Interfaces
PDF
Serving ML easily with FastAPI - meme version
PDF
Introduction to ASP.NET Core
PDF
Monitoring in CloudStack
PDF
A Introduction of Packer
PPT
Java
PDF
Packer by HashiCorp
PDF
Kubernetes Webinar - Using ConfigMaps & Secrets
PPTX
Constructors in java
PDF
Angular Observables & RxJS Introduction
Kubernetes security
Hacking and Defending APIs - Red and Blue make Purple.pdf
Demystifying OAuth 2.0
Express JS Rest API Tutorial
Spring boot introduction
Ansible 101
Neat tricks to bypass CSRF-protection
Introduction to Hibernate Framework
How to write a Dockerfile
Docker compose
Java 8 Lambda Built-in Functional Interfaces
Serving ML easily with FastAPI - meme version
Introduction to ASP.NET Core
Monitoring in CloudStack
A Introduction of Packer
Java
Packer by HashiCorp
Kubernetes Webinar - Using ConfigMaps & Secrets
Constructors in java
Angular Observables & RxJS Introduction

Viewers also liked

PPTX
PPT
CloudStack and BigData
PPTX
Apalia/Amysta Cloud Usage Metering and Billing
PPTX
성공하는 애자일을 위한 짧은 이야기
ODP
BtrCloud CloudStack Plugin
PPT
DevCloud and CloudMonkey
PDF
Collaboration for Dummies
PPTX
Sk planet 이야기
PDF
[AUG] 칸반을 활용한 업무 프로세스 혁신 실천법
PDF
Analytics Roles: Part 1
PDF
Network Automation with Salt and NAPALM: a self-resilient network
PPT
Apache CloudStack Google Summer of Code
PPT
Build a Cloud Day Paris
PDF
Cloud stack for_beginners
PDF
Git 101 for CloudStack
PDF
UShareSoft Image Management for CloudStack
PDF
4 Prerequisites for DevOps Success
PPTX
Cloud Automation with ProActive
PDF
스크럼, 이걸 왜 하나요
PPTX
Vivienda romana
CloudStack and BigData
Apalia/Amysta Cloud Usage Metering and Billing
성공하는 애자일을 위한 짧은 이야기
BtrCloud CloudStack Plugin
DevCloud and CloudMonkey
Collaboration for Dummies
Sk planet 이야기
[AUG] 칸반을 활용한 업무 프로세스 혁신 실천법
Analytics Roles: Part 1
Network Automation with Salt and NAPALM: a self-resilient network
Apache CloudStack Google Summer of Code
Build a Cloud Day Paris
Cloud stack for_beginners
Git 101 for CloudStack
UShareSoft Image Management for CloudStack
4 Prerequisites for DevOps Success
Cloud Automation with ProActive
스크럼, 이걸 왜 하나요
Vivienda romana

Similar to Intro to CloudStack API

PPTX
Restful api
PDF
Pentesting RESTful webservices
PDF
REST API Basics
PPTX
PDF
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
PDF
Api fundamentals
PDF
REST APIs
PDF
API Basics
PDF
Designing RESTful APIs
PDF
Introduction to REST - REST Basics - JSON
PDF
Building RESTful APIs
PDF
Api FUNdamentals #MHA2017
PPTX
Understanding APIs.pptx
PPTX
rest-api-basics.pptx
PPTX
Rest Webservice
ODP
Attacking REST API
PPTX
Restful webservice
PPTX
Understanding APIs.pptx introduction chk
PDF
Creating Restful Web Services with restish
PPTX
Real world RESTful service development problems and solutions
Restful api
Pentesting RESTful webservices
REST API Basics
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Api fundamentals
REST APIs
API Basics
Designing RESTful APIs
Introduction to REST - REST Basics - JSON
Building RESTful APIs
Api FUNdamentals #MHA2017
Understanding APIs.pptx
rest-api-basics.pptx
Rest Webservice
Attacking REST API
Restful webservice
Understanding APIs.pptx introduction chk
Creating Restful Web Services with restish
Real world RESTful service development problems and solutions

More from Sebastien Goasguen

PPTX
Apache Libcloud
PPT
CloudStack / Saltstack lightning talk at DevOps Amsterdam
PPT
Kubernetes on CloudStack with coreOS
PPTX
On Docker and its use for LHC at CERN
PPTX
Moving from Publican to Read The Docs
PPT
Avoiding cloud lock-in
PPT
Building FOSS clouds
PPT
CloudStack Clients and Tools
PPTX
Serverless on Kubernetes
PPT
Cloud Standards and CloudStack
PPTX
Kubernetes kubecon-roundup
PPTX
SDN: Network Agility in the Cloud
PPT
MyCloud for $100k
PPTX
CloudStack Conference Public Clouds Use Cases
PPTX
Cloud and Big Data trends
PDF
Kubernetes Native Serverless solution: Kubeless
PDF
Kubernetes Sealed secrets
PPT
Apache CloudStack AlpesJUG
PPT
CloudStack for Java User Group
PPT
Intro to CloudStack Build a Cloud Day
Apache Libcloud
CloudStack / Saltstack lightning talk at DevOps Amsterdam
Kubernetes on CloudStack with coreOS
On Docker and its use for LHC at CERN
Moving from Publican to Read The Docs
Avoiding cloud lock-in
Building FOSS clouds
CloudStack Clients and Tools
Serverless on Kubernetes
Cloud Standards and CloudStack
Kubernetes kubecon-roundup
SDN: Network Agility in the Cloud
MyCloud for $100k
CloudStack Conference Public Clouds Use Cases
Cloud and Big Data trends
Kubernetes Native Serverless solution: Kubeless
Kubernetes Sealed secrets
Apache CloudStack AlpesJUG
CloudStack for Java User Group
Intro to CloudStack Build a Cloud Day

Recently uploaded

PDF
Security Technologys: Access Control, Firewall, VPN
PDF
Unlocking the Power of Salesforce Architecture: Frameworks for Effective Solu...
PDF
Session 1 - Solving Semi-Structured Documents with Document Understanding
PDF
Security Forum Sessions from Houston 2025 Event
PDF
GPUS and How to Program Them by Manya Bansal
PDF
Day 1 - Cloud Security Strategy and Planning ~ 2nd Sight Lab ~ Cloud Security...
PPTX
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
PDF
ElyriaSoftware — Powering the Future with Blockchain Innovation
PDF
Day 2 - Network Security ~ 2nd Sight Lab ~ Cloud Security Class ~ 2020
PPTX
wob-report.pptxwob-report.pptxwob-report.pptx
PDF
Our Digital Tribe_ Cultivating Connection and Growth in Our Slack Community 🌿...
DOCX
Introduction to the World of Computers (Hardware & Software)
PDF
Is It Possible to Have Wi-Fi Without an Internet Provider
PDF
Energy Storage Landscape Clean Energy Ministerial
PDF
December Patch Tuesday
 
PPTX
Chapter 3 Introduction to number system.pptx
PDF
Making Sense of Raster: From Bit Depth to Better Workflows
PDF
The major tech developments for 2026 by Pluralsight, a research and training ...
PPTX
Cybersecurity Best Practices - Step by Step guidelines
PPTX
cybercrime in Information security .pptx
Security Technologys: Access Control, Firewall, VPN
Unlocking the Power of Salesforce Architecture: Frameworks for Effective Solu...
Session 1 - Solving Semi-Structured Documents with Document Understanding
Security Forum Sessions from Houston 2025 Event
GPUS and How to Program Them by Manya Bansal
Day 1 - Cloud Security Strategy and Planning ~ 2nd Sight Lab ~ Cloud Security...
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
ElyriaSoftware — Powering the Future with Blockchain Innovation
Day 2 - Network Security ~ 2nd Sight Lab ~ Cloud Security Class ~ 2020
wob-report.pptxwob-report.pptxwob-report.pptx
Our Digital Tribe_ Cultivating Connection and Growth in Our Slack Community 🌿...
Introduction to the World of Computers (Hardware & Software)
Is It Possible to Have Wi-Fi Without an Internet Provider
Energy Storage Landscape Clean Energy Ministerial
December Patch Tuesday
 
Chapter 3 Introduction to number system.pptx
Making Sense of Raster: From Bit Depth to Better Workflows
The major tech developments for 2026 by Pluralsight, a research and training ...
Cybersecurity Best Practices - Step by Step guidelines
cybercrime in Information security .pptx

Intro to CloudStack API

  • 1.
    Introduction to theCloudStackAPISebastien Goasguen@sebgoa
  • 2.
    Outline• Documentation• Clients•Exploration• Integration port• Signing requests• REST or not REST
  • 3.
  • 4.
    Clients• 15 clientsandcounting… on Github• Java, Python, Perl,Ruby, C#, php, Clojure
  • 5.
    Exploration• Use adebugger console• E.g Firebug• As you navigate the UI,check the http calls thatare being made• Identify the methods• Identify the parameterspassed to each call
  • 6.
    HTTPbased• API callsmade via HTTP(s)• Pass name of the call as command• Pass list of key/value pairs as arguments tothe call• GET method• Response can be XML or JSON• Query API that is RESTlikehttp://gehrcke.de/2009/06/aws-about-api/
  • 7.
    Integration Port• Unauthenticatedcall– Dangerous– Don’t open it all– Certainly don’t open it to the public internet• Set the port on the UI
  • 8.
    Using theintegration porthttp://localhost:8096/client/api?command=listUsers&response=jsoncurl'http://localhost:8096/client/api?command=listUsers&response=json'{ "listusersresponse" : { "count":3 ,"user" : [ {"id":"7ed6d5da-93b2-4545-a502-23d20b48ef2a","username":"admin","firstname":"admin","lastname":"cloud","created":"2012-07-05T12:18:27-0700","state":"enabled","account":"admin","accounttype":1,"domainid":"8a111e58-e155-4482-93ce-84efff3c7c77","domain":"ROOT","apikey":"plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg”…http://localhost:8096/client/api?command=listUserscurl http://localhost:8096/client/api?command=listUsers<?xml version="1.0" encoding="ISO-8859-1"?><listusersresponse cloud-stack-version="3.0.3.2012-07-04T06:31:57Z"><count>3</count><user><id>7ed6d5da-93b2-4545-a502-23d20b48ef2a</id><username>admin</username><firstname>admin</firstname><lastname>cloud</lastname><created>2012-07-05T12:18:27-0700</created><state>enabled</state><account>admin</account><accounttype>1</accounttype><domainid>8a111e58-e155-4482-93ce-84efff3c7c77</domainid><domain>ROOT</domain><apikey>plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg…http://www.shapeblue.com/2012/05/10/using-the-api-for-advanced-network-management/
  • 9.
    Authenticated calls• Usinghttp(s)• API endpoint for the cloud– http://localhost:8080/client/api?• Command key to pass the name of the call• Key/value pairs for the arguments• API key of the user making the call• Signature for authorization
  • 10.
    API Keys• GenerateAPI keys for the user that will accessthe cloud
  • 11.
    Creating the signature•Form the request url: list of key=valuepairs joined by & and encoded for httptransport• Compute the signature:– lower case values, replace + with %20– generate the hmac using sha1 hash function– Base64 encode the digest– Encode for http transport• Form the entire request adding the signature:&signature=
  • 12.
    Example>>> request{'apikey': 'plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg','command': 'listUsers','response': 'json'}>>>request_url="&".join(["=".join([r,urllib.quote_plus(request[r])]) for r in request.keys()])>>>sig_url="&".join(["=".join([r.lower(),urllib.quote_plus(request[r]).lower()]) for r in sorted(request.iterkeys())])>>>sig=urllib.quote_plus(base64.encodestring(hmac.new(secretkey,sig_url,hashlib.sha1).digest()).strip())>>> req=url+request_url+'&signature='+sig>>> res=urllib2.urlopen(req)>>> res.read()
  • 13.
    REST• REST standsfor Representational StateTransfer• Architectural style to design web servicesintroduced by Roy Fielding (former ASF chair)• Premise:– HTTP protocol is enough to create web servicesand change the state of web resources– HTTP methods can be used to change the state– Eases web services design compared to SOAPhttp://en.wikipedia.org/wiki/Roy_Fieldinghttp://en.wikipedia.org/wiki/Representational_State_Transfer
  • 14.
    REST• REST styleweb services couple beimplemented with other protocol than http• But http provides all that is neededhttp://en.wikipedia.org/wiki/Representational_State_Transfer
  • 15.
    REST API• TheCloudStack API is a query API• It is RESTlike but not RESTfull• Example:listUsers() a GET vs GETupdateUser() a GET vs PATCHcreateUser() a GET vs POSTdeleteUser() a GET vs DELETEhttp://gehrcke.de/2009/06/aws-about-api/http://publish.luisrei.com/articles/flaskrest.html
  • 16.
    Exercise• Build aREST interface to CloudStack• Use Flask a Lightweight Python webframeworkhttp://flask.pocoo.orghttp://publish.luisrei.com/articles/flaskrest.html
  • 17.
    Exercisefrom flask importFlaskapp = Flask(__name__)@app.route("/")def hello():return "Hello World!"if __name__ == "__main__":app.run(debug=True)Flask allows you to define web routes andfunctions that get executed when these routesare called.
  • 18.
    Exercise@app.route('/login', methods=['GET', 'POST'])deflogin():if request.method == 'POST':do_the_login()else:show_the_login_form()curl -X DELETEhttp://localhost:5000/user/b3b60a8dfdf6f-4ce6-a6f9-6194907457a5{ "deleteuserresponse" : { "success" : "true"} }https://github.com/runseb/cloudstack-flaskhttp://buildacloud.org/blog/253-to-rest-or-not-to-rest.html
  • 19.
    Info• Apache TopLevel Project (TLP)• http://cloudstack.apache.org• #cloudstack and #cloudstack-dev on irc.freenode.net• @CloudStack on Twitter• http://www.slideshare.net/cloudstack• dev-subscribe@cloudstack.apache.org• users-subscribe@cloudstack.apache.orgWelcoming contributions and feedback, Join the fun !

[8]ページ先頭

©2009-2025 Movatter.jp