SlideShare a Scribd company logo
1 of 16
How to create a
libcloud driver from scratch
the NephoScale case
Libcloud
one library to rule them all
Supports many providers
What if your provider is not
supported?
● Clone
● Branch
● Write
● Test
● Merge back
Time to contribute
Tasklist
Backend actions
● list_nodes: list all nodes, including ip addresses, node state, metadata, etc
● list_images: list all the images the provider supports
● list_sizes: list different plans, providing data such as CPU, ram and disk size
● list_locations: List all available provider zones when applicable
Tasklist
Node actions
● create_node: create a node specifying it’s size, image, name and location
● deploy_node: create a node and deploy a public ssh key and optionally run a
deploy script
● reboot_node/shut down_node
● start_node/stop_node: start a stopped node, or stop a started one
● destroy_node: Delete the node
Getting ready
APIs and drivers
● Familiarize yourself with the provider API
● Choose a recent libcloud driver to base your code on
● Don’t break conventions. Do it the libcloud way
libcloud repo
Clone and extend
● Clone libcloud from https://github.com/apache/libcloud
● Libcloud drivers live in libcloud/compute/drivers
● They all inherit from the base driver at libcloud/compute/base.py
● Create your git branch
● Add your driver on libcloud/compute/providers.py
Create driver file
Create libcloud/compute/drivers/nephoscale.py
Specify the cloud provider API endpoint
API_HOST = 'api.nephoscale.com'
and the possible node states
NODE_STATE_MAP = {
'on': NodeState.RUNNING,
'off': NodeState.UNKNOWN,
'unknown': NodeState.UNKNOWN,
}
Writing the driver
We need to create a NodeDriver based driver
class NephoscaleNodeDriver(NodeDriver):
"""Nephoscale node driver class"""
type = Provider.NEPHOSCALE
api_name = 'nephoscale'
name = 'NephoScale'
website = 'http://www.nephoscale.com'
connectionCls = NephoscaleConnection
features = {'create_node': ['ssh_key']}
def list_locations(self):
...
Writing the Connection class
and write a Connection class
class NephoscaleConnection(ConnectionUserAndKey):
host = API_HOST
responseCls = NephoscaleResponse
def add_default_headers(self, headers):
user_b64 = base64.b64encode(b('%s:%s' % (self.user_id,
self.key)))
headers['Authorization'] = 'Basic %s' %
(user_b64.decode('utf-8'))
return headers
Writing the Response class
Response classes derive from JsonResponse or XMLRPCResponse
class NephoscaleResponse(JsonResponse):
"""Nephoscale API Response"""
def parse_error(self):
if self.status == httplib.UNAUTHORIZED:
raise InvalidCredsError('Authorization Failed')
if self.status == httplib.NOT_FOUND:
raise Exception("The resource you are looking for is not
found.")
return self.body
Keep consistency
Keep consistency, hardcode things when necessary
● Most of the times you don’t need to override deploy_node
● Libcloud standardizes things for providers (nodes/sizes/images/locations)
● When a provider does non-standard stuff, override
● Some providers don’t return enough details
● Hardcode only when necessary
Testing the driver
Test your driver often to make sure it works
user@user:~/dev/libcloud$ python
>>> from libcloud.compute.types import Provider
>>> from libcloud.compute.providers import get_driver
>>> driver = get_driver(Provider.NEPHOSCALE)
>>> conn = driver('user','correct_password')
>>> conn.list_nodes()
[<Node: uuid=e20bdbf7ef6890645f5b217e0bd2b5912b969cc1,
name=nepho-7, state=0, public_ips=['198.89.109.116'],
provider=NephoScale ...>]
Contributing to libcloud
Some ground rules and contribution workflow:
● Open a ticket on the tracker to notify any interested parties
● Write unit tests
● Follow code style (follow PEP8, use spaces for tabs, etc)
● Commit and open a pull request
● Wait for a review and make any changes pointed
● Create a patch with your changes and add it to your ticket
Thank you!
To check the driver in action, visit https://mist.io
More resources:
● https://libcloud.readthedocs.org/en/latest/development.html
● https://github.com/apache/libcloud
● https://libcloud.readthedocs.org/en/latest/developer_information.html
Special thanks to Tomaz, maintainer of libcloud and a very helpful guy :)

More Related Content

What's hot

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102APNIC
 
Development of Ansible modules
Development of Ansible modulesDevelopment of Ansible modules
Development of Ansible modulesjtyr
 
Node js presentation
Node js presentationNode js presentation
Node js presentationmartincabrera
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & ExpressChristian Joudrey
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017Jumping Bean
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node jsfakedarren
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with AnsibleAhmed AbouZaid
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with ExpressAaron Stannard
 

What's hot (20)

Express node js
Express node jsExpress node js
Express node js
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Node.js - Best practices
Node.js  - Best practicesNode.js  - Best practices
Node.js - Best practices
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102
 
Express js
Express jsExpress js
Express js
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Development of Ansible modules
Development of Ansible modulesDevelopment of Ansible modules
Development of Ansible modules
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Nodejs intro
Nodejs introNodejs intro
Nodejs intro
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 

Viewers also liked

Improving notes addressing experience with recent contacts
Improving notes addressing experience with recent contactsImproving notes addressing experience with recent contacts
Improving notes addressing experience with recent contactsVinayak Tavargeri
 
αίσιο τέλος, διήγημα
αίσιο τέλος, διήγημααίσιο τέλος, διήγημα
αίσιο τέλος, διήγημαartedinou
 
Learning activity progress- Sarah
Learning activity progress- SarahLearning activity progress- Sarah
Learning activity progress- Sarahsarahmobilelearning
 
Area and perimeter (1)
Area and perimeter (1)Area and perimeter (1)
Area and perimeter (1)Mari QZ
 
Measuring What Really Matters: Search Engine Metrics & Tracking Tips - David ...
Measuring What Really Matters: Search Engine Metrics & Tracking Tips - David ...Measuring What Really Matters: Search Engine Metrics & Tracking Tips - David ...
Measuring What Really Matters: Search Engine Metrics & Tracking Tips - David ...Energy Digital Summit
 
Ingi_El-Azizi 2014 - Copy
Ingi_El-Azizi  2014 - CopyIngi_El-Azizi  2014 - Copy
Ingi_El-Azizi 2014 - CopyIngi Elazizi
 
Educational Transformation with Media
Educational Transformation with MediaEducational Transformation with Media
Educational Transformation with MediaTerryKH2006
 
Avoiding conflict and litigation with hmrc
Avoiding conflict and litigation with hmrcAvoiding conflict and litigation with hmrc
Avoiding conflict and litigation with hmrcIndia inc
 
Golden ages of Florence
Golden ages of FlorenceGolden ages of Florence
Golden ages of Florenceskate99
 
Dung si Monti - Ep 03
Dung si Monti - Ep 03Dung si Monti - Ep 03
Dung si Monti - Ep 03Dung si Monti
 
Curriculum Vitae_Sudhan R with 2Yr`s Experience
Curriculum Vitae_Sudhan R with 2Yr`s ExperienceCurriculum Vitae_Sudhan R with 2Yr`s Experience
Curriculum Vitae_Sudhan R with 2Yr`s ExperienceSUDHAN R
 
Wee cig presentation
Wee cig presentationWee cig presentation
Wee cig presentationdennislzf
 

Viewers also liked (20)

Improving notes addressing experience with recent contacts
Improving notes addressing experience with recent contactsImproving notes addressing experience with recent contacts
Improving notes addressing experience with recent contacts
 
αίσιο τέλος, διήγημα
αίσιο τέλος, διήγημααίσιο τέλος, διήγημα
αίσιο τέλος, διήγημα
 
Learning activity progress- Sarah
Learning activity progress- SarahLearning activity progress- Sarah
Learning activity progress- Sarah
 
Area and perimeter (1)
Area and perimeter (1)Area and perimeter (1)
Area and perimeter (1)
 
0026 resistencia
0026 resistencia0026 resistencia
0026 resistencia
 
Measuring What Really Matters: Search Engine Metrics & Tracking Tips - David ...
Measuring What Really Matters: Search Engine Metrics & Tracking Tips - David ...Measuring What Really Matters: Search Engine Metrics & Tracking Tips - David ...
Measuring What Really Matters: Search Engine Metrics & Tracking Tips - David ...
 
Gta 5
Gta 5Gta 5
Gta 5
 
Ingi_El-Azizi 2014 - Copy
Ingi_El-Azizi  2014 - CopyIngi_El-Azizi  2014 - Copy
Ingi_El-Azizi 2014 - Copy
 
Photography
Photography Photography
Photography
 
Educational Transformation with Media
Educational Transformation with MediaEducational Transformation with Media
Educational Transformation with Media
 
Dung si Monti_Ep 01
Dung si Monti_Ep 01Dung si Monti_Ep 01
Dung si Monti_Ep 01
 
Avoiding conflict and litigation with hmrc
Avoiding conflict and litigation with hmrcAvoiding conflict and litigation with hmrc
Avoiding conflict and litigation with hmrc
 
Epis
EpisEpis
Epis
 
Golden ages of Florence
Golden ages of FlorenceGolden ages of Florence
Golden ages of Florence
 
Декада
ДекадаДекада
Декада
 
Dung si Monti - Ep 03
Dung si Monti - Ep 03Dung si Monti - Ep 03
Dung si Monti - Ep 03
 
Curriculum Vitae_Sudhan R with 2Yr`s Experience
Curriculum Vitae_Sudhan R with 2Yr`s ExperienceCurriculum Vitae_Sudhan R with 2Yr`s Experience
Curriculum Vitae_Sudhan R with 2Yr`s Experience
 
Tujuan
TujuanTujuan
Tujuan
 
Hi-Lok Installation
Hi-Lok InstallationHi-Lok Installation
Hi-Lok Installation
 
Wee cig presentation
Wee cig presentationWee cig presentation
Wee cig presentation
 

Similar to How to create a libcloud driver from scratch

Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发shaokun
 
Working in the multi-cloud with libcloud
Working in the multi-cloud with libcloudWorking in the multi-cloud with libcloud
Working in the multi-cloud with libcloudGrig Gheorghiu
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 
Chef or how to make computers do the work for us
Chef or how to make computers do the work for usChef or how to make computers do the work for us
Chef or how to make computers do the work for ussickill
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbJuan Maiz
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comVan-Duyet Le
 
"ClojureScript journey: from little script, to CLI program, to AWS Lambda fun...
"ClojureScript journey: from little script, to CLI program, to AWS Lambda fun..."ClojureScript journey: from little script, to CLI program, to AWS Lambda fun...
"ClojureScript journey: from little script, to CLI program, to AWS Lambda fun...Julia Cherniak
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developerscacois
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with PuppetKris Buytaert
 
PofEAA and SQLAlchemy
PofEAA and SQLAlchemyPofEAA and SQLAlchemy
PofEAA and SQLAlchemyInada Naoki
 

Similar to How to create a libcloud driver from scratch (20)

Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
 
Working in the multi-cloud with libcloud
Working in the multi-cloud with libcloudWorking in the multi-cloud with libcloud
Working in the multi-cloud with libcloud
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Chef or how to make computers do the work for us
Chef or how to make computers do the work for usChef or how to make computers do the work for us
Chef or how to make computers do the work for us
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
 
Catalyst MVC
Catalyst MVCCatalyst MVC
Catalyst MVC
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
"ClojureScript journey: from little script, to CLI program, to AWS Lambda fun...
"ClojureScript journey: from little script, to CLI program, to AWS Lambda fun..."ClojureScript journey: from little script, to CLI program, to AWS Lambda fun...
"ClojureScript journey: from little script, to CLI program, to AWS Lambda fun...
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
Chef solo the beginning
Chef solo the beginning Chef solo the beginning
Chef solo the beginning
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
PofEAA and SQLAlchemy
PofEAA and SQLAlchemyPofEAA and SQLAlchemy
PofEAA and SQLAlchemy
 

Recently uploaded

VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 

Recently uploaded (20)

VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 

How to create a libcloud driver from scratch

  • 1. How to create a libcloud driver from scratch the NephoScale case
  • 2. Libcloud one library to rule them all
  • 4. What if your provider is not supported? ● Clone ● Branch ● Write ● Test ● Merge back Time to contribute
  • 5. Tasklist Backend actions ● list_nodes: list all nodes, including ip addresses, node state, metadata, etc ● list_images: list all the images the provider supports ● list_sizes: list different plans, providing data such as CPU, ram and disk size ● list_locations: List all available provider zones when applicable
  • 6. Tasklist Node actions ● create_node: create a node specifying it’s size, image, name and location ● deploy_node: create a node and deploy a public ssh key and optionally run a deploy script ● reboot_node/shut down_node ● start_node/stop_node: start a stopped node, or stop a started one ● destroy_node: Delete the node
  • 7. Getting ready APIs and drivers ● Familiarize yourself with the provider API ● Choose a recent libcloud driver to base your code on ● Don’t break conventions. Do it the libcloud way
  • 8. libcloud repo Clone and extend ● Clone libcloud from https://github.com/apache/libcloud ● Libcloud drivers live in libcloud/compute/drivers ● They all inherit from the base driver at libcloud/compute/base.py ● Create your git branch ● Add your driver on libcloud/compute/providers.py
  • 9. Create driver file Create libcloud/compute/drivers/nephoscale.py Specify the cloud provider API endpoint API_HOST = 'api.nephoscale.com' and the possible node states NODE_STATE_MAP = { 'on': NodeState.RUNNING, 'off': NodeState.UNKNOWN, 'unknown': NodeState.UNKNOWN, }
  • 10. Writing the driver We need to create a NodeDriver based driver class NephoscaleNodeDriver(NodeDriver): """Nephoscale node driver class""" type = Provider.NEPHOSCALE api_name = 'nephoscale' name = 'NephoScale' website = 'http://www.nephoscale.com' connectionCls = NephoscaleConnection features = {'create_node': ['ssh_key']} def list_locations(self): ...
  • 11. Writing the Connection class and write a Connection class class NephoscaleConnection(ConnectionUserAndKey): host = API_HOST responseCls = NephoscaleResponse def add_default_headers(self, headers): user_b64 = base64.b64encode(b('%s:%s' % (self.user_id, self.key))) headers['Authorization'] = 'Basic %s' % (user_b64.decode('utf-8')) return headers
  • 12. Writing the Response class Response classes derive from JsonResponse or XMLRPCResponse class NephoscaleResponse(JsonResponse): """Nephoscale API Response""" def parse_error(self): if self.status == httplib.UNAUTHORIZED: raise InvalidCredsError('Authorization Failed') if self.status == httplib.NOT_FOUND: raise Exception("The resource you are looking for is not found.") return self.body
  • 13. Keep consistency Keep consistency, hardcode things when necessary ● Most of the times you don’t need to override deploy_node ● Libcloud standardizes things for providers (nodes/sizes/images/locations) ● When a provider does non-standard stuff, override ● Some providers don’t return enough details ● Hardcode only when necessary
  • 14. Testing the driver Test your driver often to make sure it works user@user:~/dev/libcloud$ python >>> from libcloud.compute.types import Provider >>> from libcloud.compute.providers import get_driver >>> driver = get_driver(Provider.NEPHOSCALE) >>> conn = driver('user','correct_password') >>> conn.list_nodes() [<Node: uuid=e20bdbf7ef6890645f5b217e0bd2b5912b969cc1, name=nepho-7, state=0, public_ips=['198.89.109.116'], provider=NephoScale ...>]
  • 15. Contributing to libcloud Some ground rules and contribution workflow: ● Open a ticket on the tracker to notify any interested parties ● Write unit tests ● Follow code style (follow PEP8, use spaces for tabs, etc) ● Commit and open a pull request ● Wait for a review and make any changes pointed ● Create a patch with your changes and add it to your ticket
  • 16. Thank you! To check the driver in action, visit https://mist.io More resources: ● https://libcloud.readthedocs.org/en/latest/development.html ● https://github.com/apache/libcloud ● https://libcloud.readthedocs.org/en/latest/developer_information.html Special thanks to Tomaz, maintainer of libcloud and a very helpful guy :)

Editor's Notes

  1. Libcloud allows users to manage four different cloud resources: Cloud Servers, Cloud Storage, Load Balancers as a Service and DNS as a Service. Cloud Servers is the oldest and more mature part of the library and currently supports more than 40 providers.
  2. Many cloud providers eg Amazon, Rackspace, Openstack etc, are already supported by libcloud. But what if your favorite provider isn’t?
  3. We’ll just create one ourselves. Libcloud is an open-source project with solid documentation and lots of code examples.
  4. The are two main sets of actions we need to support. Backend actions that are provider/account specific.
  5. and node actions that refer to a specific node (Virtual Machine). Most of them our self-explanatory. deploy_node runs create node and supplies a public ssh key for server access. It can optionally wait for the server to come online and deploy a script.
  6. We’ll need access to our provider API. In this scenario, the Nephoscale API. We will use the Digital Ocean driver as a template as it is one of the most recent, well written and up-to-date drivers. There is an effort by libcloud to standardize the basic functionality for all the compute drivers, and update the oldest ones.
  7. We’ll start by cloning the libcloud repo. All our drivers are in /libcloud/compute/drivers Every driver inherits from the main base driver at libcloud/compute/base.py We’ll create a git branch and add our driver on the DRIVERS dict on libcloud/compute/providers.py And our Provider class on libcloud/compute/types.py We will use the Digital Ocean driver as a template as it is one of the most recent, well written and up-to-date drivers. There is an effort by libcloud to standardize the basic functionality for all the compute drivers, and update the oldest ones.
  8. On libcloud/compute/drivers/ we create a file with the name of our provider: nephoscale.py in our case. After the initial imports that we copy from the Digital Ocean driver, we specify the API endpoint of our cloud provider and a dict with the states that the nodes can have. This differs from provider to provider, with some providers having just a few states -running, stopped - and others having intermediates ones -e.g. rebooting, shutting down etc.
  9. Here we specify the type (same as on libcloud/compute/types.py), the connection class (NephoscaleConnection) and a features dict with the way deploy_node will try to authenticate to the created node after create_node has run . Inside the NephoscaleNodeDriver is where all our functions will live. We’ll write all functions we want to implement there, list_images, list_nodes, reboot_node etc. To keep consistency, we make sure that list_nodes returns a list of Node objects, list_images a list of NodeImage objects, list_sizes a list of NodeSize objects and list_locations a list of NodeLocation objects.
  10. NephoscaleConnection is the Connection class that will handle connection, authentication and send the request to the NephoScale API endpoint. All drivers implement a Connection class that is responsible for sending the request data, adding HTTP headers or params and also encoding the request body.The API host endpoint is specified there, along with the HTTP headers or params that are used to authenticate for each provider. NephoScale API calls require HTTP Basic Authentication with the user/password base64 encoded on every request, so we’ll add it to add_default_params. Other providers handle authentication with requiring the params on each request -API key, password, secret etc.
  11. All drivers also need a response class that handles responses of the API endpoint, parses body and returns Exceptions or the actual return content. Response classes for the libcloud drivers derive from JsonResponse or XMLRPCResponse, depending on the response type of the cloud provider -Json or XML. Both derive from Response class that lives in libcloud/common/base.py. We want to make sure here that in the case of errors we throw the correct exceptions - e.g. InvalidCredsError for failed authentication
  12. Most of the drivers of libcloud implement create_node to return a Node object, of the newly created host. Function deploy_node is not overridden , but instead gets called from the NodeDriver, since it does a lot of things that need not be rewritten, such as checks that the node public ip is up, that the machine can be accessible, that it can authenticate via password or ssh key, and optionally runs a deploy script. One of the cool things with libcloud is that it standardizes things. It enforces the use of basic entities -nodes, sizes, images, locations- for all cloud providers it supports. SoftLayer for example does not provide a size entity through it’s API, but rather expects that we specify CPU, RAM and disk size when we create a node. The way libcloud driver is implemented, one can either pass these manually, or simply select one of the sizes provided by list_sizes. Ideally all size/image/location related data should be fetched by asking the provider. When this is not possible, for example when the provider does not implement a request, we need to hard code these settings. For example the pricing info for some of the providers isn’t returned while asking for the sizes (list_sizes) and thus is hard coded on libcloud/data/pricing.json
  13. Having created the compute driver for our cloud provider and having tested it’s functionality, it is time to commit it to libcloud. In this case we need to write tests -ideally for all functionality, add some fixtures and make sure the tests pass. Libcloud contains unit tests for nearly everything and enforces testing for new functionality. Use the codestyle proposed by libcloud, follow the workflow and your patch will be accepted to trunk.
  14. Have fun developing your driver! To check this driver in action log in to mist.io Special thanks to Tomaz, maintainer of liblcoud and it’s bigger laborer of love, for proof reading this text.