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

More Related Content

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

What's hot

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

Viewers also liked

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

Similar to Intro to CloudStack API

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

More from Sebastien Goasguen

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

Recently uploaded

PDF
Session 1 - Solving Semi-Structured Documents with Document Understanding
PPTX
cybercrime in Information security .pptx
PDF
Day 3 - Data and Application Security - 2nd Sight Lab Cloud Security Class
PDF
Security Technologys: Access Control, Firewall, VPN
DOCX
Introduction to the World of Computers (Hardware & Software)
PPTX
THIS IS CYBER SECURITY NOTES USED IN CLASS ON VARIOUS TOPICS USED IN CYBERSEC...
PDF
Day 2 - Network Security ~ 2nd Sight Lab ~ Cloud Security Class ~ 2020
PDF
Unser Jahresrückblick – MarvelClient in 2025
PDF
December Patch Tuesday
 
PPTX
Cybercrime in the Digital Age: Risks, Impact & Protection
PDF
Eredità digitale sugli smartphone: cosa resta di noi nei dispositivi mobili
PPTX
Building Cyber Resilience for 2026: Best Practices for a Secure, AI-Driven Bu...
PPTX
Software Analysis &Design ethiopia chap-2.pptx
PDF
Our Digital Tribe_ Cultivating Connection and Growth in Our Slack Community 🌿...
PDF
The year in review - MarvelClient in 2025
PPTX
Data Privacy and Protection: Safeguarding Information in a Connected World
PPTX
wob-report.pptxwob-report.pptxwob-report.pptx
PPT
software-security-intro in information security.ppt
PPTX
AI's Impact on Cybersecurity - Challenges and Opportunities
PDF
ElyriaSoftware — Powering the Future with Blockchain Innovation
Session 1 - Solving Semi-Structured Documents with Document Understanding
cybercrime in Information security .pptx
Day 3 - Data and Application Security - 2nd Sight Lab Cloud Security Class
Security Technologys: Access Control, Firewall, VPN
Introduction to the World of Computers (Hardware & Software)
THIS IS CYBER SECURITY NOTES USED IN CLASS ON VARIOUS TOPICS USED IN CYBERSEC...
Day 2 - Network Security ~ 2nd Sight Lab ~ Cloud Security Class ~ 2020
Unser Jahresrückblick – MarvelClient in 2025
December Patch Tuesday
 
Cybercrime in the Digital Age: Risks, Impact & Protection
Eredità digitale sugli smartphone: cosa resta di noi nei dispositivi mobili
Building Cyber Resilience for 2026: Best Practices for a Secure, AI-Driven Bu...
Software Analysis &Design ethiopia chap-2.pptx
Our Digital Tribe_ Cultivating Connection and Growth in Our Slack Community 🌿...
The year in review - MarvelClient in 2025
Data Privacy and Protection: Safeguarding Information in a Connected World
wob-report.pptxwob-report.pptxwob-report.pptx
software-security-intro in information security.ppt
AI's Impact on Cybersecurity - Challenges and Opportunities
ElyriaSoftware — Powering the Future with Blockchain Innovation

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