SlideShare una empresa de Scribd logo
1 de 34
BEST REST in OpenStack
Vikram Hosakote
Sr. Software Engineer, Cisco Systems
vhosakot@cisco.com
DEVNET-2004
• What is a RESTful service?
• REST methods
• REST in OpenStack
• Hands-on exercises
• Troubleshooting / debugging REST APIs
• Q & A
Agenda
What is a RESTful service?
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 5DEVNET-2055
What is a RESTful service?
• Representational State Transfer (REST) is a stateless, client-server based,
cacheable web service
• Uses HTTP protocol for communication
• Data is considered as a “resource” and accessed using Uniform Resource
Identifiers (URIs) that typically look like a web link
• URI is RFC RFC3986 (example:
http://www.ciscolive.com/us/learn/sessions/session-catalog)
• Uses HTTP clients like curl, browsers (Google Chrome Postman) and wget
REST in OpenStack
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 7DEVNET-2055
REST in OpenStack
Hands-on exercises
Hands-on exercises
• Run OpenStack Neutron CLIs and analyze REST packets in WireShark
• REST for big data use cases – REST pagination in Neutron
• Implementing a RESTful server using Python Flask
Hands-on exercises
• Run OpenStack Neutron CLIs and analyze REST packets in WireShark
• REST for big data use cases – REST pagination in Neutron
• Implementing a RESTful server using Python Flask
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 11DEVNET-2055
• start-capture <your first name>-<GET|POST|PUT|DELETE>.pcap
• Run an OpenStack Neutron CLI
• stop-capture
Hands-on exercises
• Run OpenStack Neutron CLIs and analyze REST packets in WireShark
• REST for big data use cases – REST pagination in Neutron
• Implementing a RESTful server using Python Flask
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 13DEVNET-2055
• Enable neutron pagination and restart neutorn-server
• cd Cisco-Live-Workshop/scripts
• ./big_data_create_networks.py
• Run commands in Cisco-Live-
Workshop/scripts/big_data_neutron_curl.txt on
GitHub(https://github.com/vhosakot/Cisco-Live-Workshop)
Hands-on exercises
• Run OpenStack Neutron CLIs and analyze REST packets in WireShark
• REST for big data use cases – REST pagination in Neutron
• Implementing a RESTful server using Python Flask
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 15DEVNET-2055
• cd Cisco-Live-Workshop/scripts
• ./rest_server.py
• Run commands in Cisco-Live-
Workshop/scripts/rest_client_steps.txt on
GitHub(https://github.com/vhosakot/Cisco-Live-Workshop)
Troubleshooting / debugging REST APIs
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 17DEVNET-2055
Troubleshooting / debugging REST APIs
• curl -v (verbose mode)
• wget -v (verbose mode)
• wget -d or wget --debug (debug mode)
• neutron -v or neutron -d or neutron --debug (neutron debug mode)
• http://www.httpdebugger.com
• https://www.wireshark.org
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 18DEVNET-2055
Troubleshooting / debugging REST APIs using
Python
import httplib
import logging
import requests
httplib.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
result = requests.get('http://www.cisco.com/')
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 19DEVNET-2055
Troubleshooting / debugging REST APIs using
Python
>>> result = requests.get('http://www.cisco.com/')
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): www.cisco.com
send: 'GET / HTTP/1.1rnHost: www.cisco.comrnConnection: keep-alivernAccept-Encoding: gzip,
deflaternAccept: */*rnUser-Agent: python-requests/2.10.0rnrn'
reply: 'HTTP/1.1 200 OKrn'
header: Server: Apache
header: ETag: "10839-53789488e5b33"
header: Accept-Ranges: bytes
header: Content-Encoding: gzip
header: CDCHOST: wemxweb-publish-prod1-01
header: Content-Length: 14215
header: Content-Type: text/html
header: Expires: Wed, 13 Jul 2016 20:25:27 GMT
header: Cache-Control: max-age=0, no-cache, no-store
header: Pragma: no-cache
header: Date: Wed, 13 Jul 2016 20:25:27 GMT
header: Connection: keep-alive
header: access-control-allow-origin: *
DEBUG:requests.packages.urllib3.connectionpool:"GET / HTTP/1.1" 200 14215
>>> print result
<Response [200]>
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Complete Your Online Session Evaluation
Don’t forget: Cisco Live sessions will be available
for viewing on-demand after the event at
CiscoLive.com/Online
• Give us your feedback to be
entered into a Daily Survey
Drawing. A daily winner will
receive a $750 Amazon gift card.
• Complete your session surveys
through the Cisco Live mobile
app or from the Session Catalog
on CiscoLive.com/us.
20Presentation ID
Thank you
Q & A
Additional slides
Mocking a REST server to unit-test REST APIs
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 26DEVNET-2055
Mocking a REST server to unit-test REST APIs
• https://github.com/openstack/requests-mock
>>> import requests
>>> import requests_mock
>>> session = requests.Session()
>>> adapter = requests_mock.Adapter()
>>> session.mount('mock', adapter)
>>> adapter.register_uri('GET', 'mock://test.com', text='data')
>>> resp = session.get('mock://test.com')
>>> resp.status_code, resp.text
(200, 'data')
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 27DEVNET-2055
Mocking a REST server to unit-test REST APIs
• https://pypi.python.org/pypi/mock-server/0.3.7
• https://github.com/gabrielfalcao/HTTPretty
• http://python-mock-tutorial.readthedocs.io/en/latest/mock.html
REST API caching and cache-aware REST clients
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 29DEVNET-2055
REST API caching and cache-aware REST clients
• RFC 7234 - https://tools.ietf.org/html/rfc7234#section-5
• REST supports HTTP cache-control headers:
max-age
max-stale
min-fresh
no-cache
no-store
no-transform
only-if-cached
must-revalidate
Public
private
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 30DEVNET-2055
REST API caching and cache-aware REST clients
• Keystone caching
• http://docs.openstack.org/admin-guide/keystone_caching_layer.html
• http://docs.openstack.org/developer/keystone/configuration.html#caching-layer
• Glance image caching
• http://docs.openstack.org/developer/glance/cache.html
• OSLO caching
• http://docs.openstack.org/developer/oslo.cache/api.html
• https://specs.openstack.org/openstack/api-wg/guidelines/http.html#http-caching-and-
proxy-behavior
• Memcached
• http://docs.openstack.org/ha-guide/controller-ha-memcached.html
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 31DEVNET-2055
REST API caching and cache-aware REST clients
Bulk REST operations and REST API batching
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 33DEVNET-2055
Bulk REST operations and REST API batching
• http://developer.openstack.org/api-ref-networking-v2.html#bulkCreateNetwork
• https://wiki.openstack.org/wiki/Neutron/APIv2-specification#Bulk_version
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 34DEVNET-2055
Bulk REST operations and REST API batching
• Bulk REST API JSON request format:
POST v2.0/networks.json
Content-Type: application/json
Accept: application/json
{
"networks": [
{
"name": "sample_network_1",
"admin_state_up": false
},
{
"name": "sample_network_2",
"admin_state_up": false
}]
}

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

How logging makes a private cloud a better cloud - OpenStack最新情報セミナー(2016年12月)
How logging makes a private cloud a better cloud - OpenStack最新情報セミナー(2016年12月)How logging makes a private cloud a better cloud - OpenStack最新情報セミナー(2016年12月)
How logging makes a private cloud a better cloud - OpenStack最新情報セミナー(2016年12月)
 
NTTドコモ様 導入事例 OpenStack Summit 2016 Barcelona 講演「Expanding and Deepening NTT D...
NTTドコモ様 導入事例 OpenStack Summit 2016 Barcelona 講演「Expanding and Deepening NTT D...NTTドコモ様 導入事例 OpenStack Summit 2016 Barcelona 講演「Expanding and Deepening NTT D...
NTTドコモ様 導入事例 OpenStack Summit 2016 Barcelona 講演「Expanding and Deepening NTT D...
 
[2015-11월 정기 세미나]K8s on openstack
[2015-11월 정기 세미나]K8s on openstack[2015-11월 정기 세미나]K8s on openstack
[2015-11월 정기 세미나]K8s on openstack
 
[OpenStack 하반기 스터디] HA using DVR
[OpenStack 하반기 스터디] HA using DVR[OpenStack 하반기 스터디] HA using DVR
[OpenStack 하반기 스터디] HA using DVR
 
See what happened with real time kvm when building real time cloud pezhang@re...
See what happened with real time kvm when building real time cloud pezhang@re...See what happened with real time kvm when building real time cloud pezhang@re...
See what happened with real time kvm when building real time cloud pezhang@re...
 
HA in OpenStack service - meetup #9
HA in OpenStack service - meetup #9HA in OpenStack service - meetup #9
HA in OpenStack service - meetup #9
 
Control Your Network ASICs, What Benefits switchdev Can Bring Us
Control Your Network ASICs, What Benefits switchdev Can Bring UsControl Your Network ASICs, What Benefits switchdev Can Bring Us
Control Your Network ASICs, What Benefits switchdev Can Bring Us
 
OVS v OVS-DPDK
OVS v OVS-DPDKOVS v OVS-DPDK
OVS v OVS-DPDK
 
Approaching hyperconvergedopenstack
Approaching hyperconvergedopenstackApproaching hyperconvergedopenstack
Approaching hyperconvergedopenstack
 
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!![OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!
 
Is OpenStack Neutron production ready for large scale deployments?
Is OpenStack Neutron production ready for large scale deployments?Is OpenStack Neutron production ready for large scale deployments?
Is OpenStack Neutron production ready for large scale deployments?
 
OpenStack KOREA 정기 세미나_OpenStack meet iNaaS SDN Controller
OpenStack KOREA 정기 세미나_OpenStack meet iNaaS SDN ControllerOpenStack KOREA 정기 세미나_OpenStack meet iNaaS SDN Controller
OpenStack KOREA 정기 세미나_OpenStack meet iNaaS SDN Controller
 
How Networking works with Data Science
How Networking works with Data Science How Networking works with Data Science
How Networking works with Data Science
 
SecurityPI - Hardening your IoT endpoints in Home.
SecurityPI - Hardening your IoT endpoints in Home. SecurityPI - Hardening your IoT endpoints in Home.
SecurityPI - Hardening your IoT endpoints in Home.
 
Docker infiniband
Docker infinibandDocker infiniband
Docker infiniband
 
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...
Unrevealed Story Behind Viettel Network Cloud Hotpot | Đặng Văn Đại, Hà Mạnh ...
 
Vandyke SecureCRT tips and tricks
Vandyke SecureCRT tips and tricksVandyke SecureCRT tips and tricks
Vandyke SecureCRT tips and tricks
 
Unlock Your Cloud Potential with Mirantis OpenStack & Cumulus Linux
Unlock Your Cloud Potential with Mirantis OpenStack & Cumulus LinuxUnlock Your Cloud Potential with Mirantis OpenStack & Cumulus Linux
Unlock Your Cloud Potential with Mirantis OpenStack & Cumulus Linux
 
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
OpenStack Korea 2015 상반기스터디(devops) 스크립트로 오픈스택 설치하기 20150728
 
Testing, CI Gating & Community Fast Feedback: The Challenge of Integration Pr...
Testing, CI Gating & Community Fast Feedback: The Challenge of Integration Pr...Testing, CI Gating & Community Fast Feedback: The Challenge of Integration Pr...
Testing, CI Gating & Community Fast Feedback: The Challenge of Integration Pr...
 

Similar a BEST REST in OpenStack

Similar a BEST REST in OpenStack (20)

Autoscaling OpenStack Natively with Heat, Ceilometer and LBaaS
Autoscaling OpenStack Natively with Heat, Ceilometer and LBaaSAutoscaling OpenStack Natively with Heat, Ceilometer and LBaaS
Autoscaling OpenStack Natively with Heat, Ceilometer and LBaaS
 
Apic dc api deep dive
Apic dc api deep dive Apic dc api deep dive
Apic dc api deep dive
 
Open Device Programmability: Hands-on Intro to RESTCONF (and a bit of NETCONF)
Open Device Programmability: Hands-on Intro to RESTCONF (and a bit of NETCONF)Open Device Programmability: Hands-on Intro to RESTCONF (and a bit of NETCONF)
Open Device Programmability: Hands-on Intro to RESTCONF (and a bit of NETCONF)
 
PLNOG16: Automatyzacja kreaowania usług operatorskich w separacji od rodzaju ...
PLNOG16: Automatyzacja kreaowania usług operatorskich w separacji od rodzaju ...PLNOG16: Automatyzacja kreaowania usług operatorskich w separacji od rodzaju ...
PLNOG16: Automatyzacja kreaowania usług operatorskich w separacji od rodzaju ...
 
Using Databases and Containers From Development to Deployment
Using Databases and Containers  From Development to DeploymentUsing Databases and Containers  From Development to Deployment
Using Databases and Containers From Development to Deployment
 
SD Times - Docker v2
SD Times - Docker v2SD Times - Docker v2
SD Times - Docker v2
 
Applying Hyper-scale Design Patterns to Routing
Applying Hyper-scale Design Patterns to RoutingApplying Hyper-scale Design Patterns to Routing
Applying Hyper-scale Design Patterns to Routing
 
DEVNET-1128 Cisco Intercloud Fabric NB Api's for Business & Providers
DEVNET-1128	Cisco Intercloud Fabric NB Api's for Business & ProvidersDEVNET-1128	Cisco Intercloud Fabric NB Api's for Business & Providers
DEVNET-1128 Cisco Intercloud Fabric NB Api's for Business & Providers
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on Mobicents
 
OpenStack Enabling DevOps
OpenStack Enabling DevOpsOpenStack Enabling DevOps
OpenStack Enabling DevOps
 
MySQL The State of the Dolphin - jun15
MySQL The State of the Dolphin - jun15MySQL The State of the Dolphin - jun15
MySQL The State of the Dolphin - jun15
 
Zure Azure PaaS Zero to Hero - DevOps training day
Zure Azure PaaS Zero to Hero - DevOps training dayZure Azure PaaS Zero to Hero - DevOps training day
Zure Azure PaaS Zero to Hero - DevOps training day
 
Webex APIs for Administrators - DEVNET_2610 - Cisco Live 2019
Webex APIs for Administrators - DEVNET_2610 - Cisco Live 2019Webex APIs for Administrators - DEVNET_2610 - Cisco Live 2019
Webex APIs for Administrators - DEVNET_2610 - Cisco Live 2019
 
Coding 102 REST API Basics Using Spark
Coding 102 REST API Basics Using SparkCoding 102 REST API Basics Using Spark
Coding 102 REST API Basics Using Spark
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
WAN Automation Engine API Deep Dive
WAN Automation Engine API Deep DiveWAN Automation Engine API Deep Dive
WAN Automation Engine API Deep Dive
 
App fabric introduction
App fabric introductionApp fabric introduction
App fabric introduction
 
What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)
 
20171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v0120171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v01
 
Cisco ONE Enterprise Cloud (UCSD) Hands-on Lab
Cisco ONE Enterprise Cloud (UCSD) Hands-on LabCisco ONE Enterprise Cloud (UCSD) Hands-on Lab
Cisco ONE Enterprise Cloud (UCSD) Hands-on Lab
 

Más de Vikram G Hosakote (6)

Kolla talk at OpenStack Summit 2017 in Sydney
Kolla talk at OpenStack Summit 2017 in SydneyKolla talk at OpenStack Summit 2017 in Sydney
Kolla talk at OpenStack Summit 2017 in Sydney
 
Cisco UCS loves Kubernetes, Docker and OpenStack Kolla
Cisco UCS loves Kubernetes, Docker and OpenStack KollaCisco UCS loves Kubernetes, Docker and OpenStack Kolla
Cisco UCS loves Kubernetes, Docker and OpenStack Kolla
 
OpenStack with OpenDaylight
OpenStack with OpenDaylightOpenStack with OpenDaylight
OpenStack with OpenDaylight
 
Jumbo Mumbo in OpenStack
Jumbo Mumbo in OpenStackJumbo Mumbo in OpenStack
Jumbo Mumbo in OpenStack
 
Multicast in OpenStack
Multicast in OpenStackMulticast in OpenStack
Multicast in OpenStack
 
Multi-node ZUUL OpenStack gate for bare metal and Docker
Multi-node ZUUL OpenStack gate for bare metal and DockerMulti-node ZUUL OpenStack gate for bare metal and Docker
Multi-node ZUUL OpenStack gate for bare metal and Docker
 

Último

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 

BEST REST in OpenStack

  • 1.
  • 2. BEST REST in OpenStack Vikram Hosakote Sr. Software Engineer, Cisco Systems vhosakot@cisco.com DEVNET-2004
  • 3. • What is a RESTful service? • REST methods • REST in OpenStack • Hands-on exercises • Troubleshooting / debugging REST APIs • Q & A Agenda
  • 4. What is a RESTful service?
  • 5. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 5DEVNET-2055 What is a RESTful service? • Representational State Transfer (REST) is a stateless, client-server based, cacheable web service • Uses HTTP protocol for communication • Data is considered as a “resource” and accessed using Uniform Resource Identifiers (URIs) that typically look like a web link • URI is RFC RFC3986 (example: http://www.ciscolive.com/us/learn/sessions/session-catalog) • Uses HTTP clients like curl, browsers (Google Chrome Postman) and wget
  • 7. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 7DEVNET-2055 REST in OpenStack
  • 9. Hands-on exercises • Run OpenStack Neutron CLIs and analyze REST packets in WireShark • REST for big data use cases – REST pagination in Neutron • Implementing a RESTful server using Python Flask
  • 10. Hands-on exercises • Run OpenStack Neutron CLIs and analyze REST packets in WireShark • REST for big data use cases – REST pagination in Neutron • Implementing a RESTful server using Python Flask
  • 11. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 11DEVNET-2055 • start-capture <your first name>-<GET|POST|PUT|DELETE>.pcap • Run an OpenStack Neutron CLI • stop-capture
  • 12. Hands-on exercises • Run OpenStack Neutron CLIs and analyze REST packets in WireShark • REST for big data use cases – REST pagination in Neutron • Implementing a RESTful server using Python Flask
  • 13. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 13DEVNET-2055 • Enable neutron pagination and restart neutorn-server • cd Cisco-Live-Workshop/scripts • ./big_data_create_networks.py • Run commands in Cisco-Live- Workshop/scripts/big_data_neutron_curl.txt on GitHub(https://github.com/vhosakot/Cisco-Live-Workshop)
  • 14. Hands-on exercises • Run OpenStack Neutron CLIs and analyze REST packets in WireShark • REST for big data use cases – REST pagination in Neutron • Implementing a RESTful server using Python Flask
  • 15. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 15DEVNET-2055 • cd Cisco-Live-Workshop/scripts • ./rest_server.py • Run commands in Cisco-Live- Workshop/scripts/rest_client_steps.txt on GitHub(https://github.com/vhosakot/Cisco-Live-Workshop)
  • 17. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 17DEVNET-2055 Troubleshooting / debugging REST APIs • curl -v (verbose mode) • wget -v (verbose mode) • wget -d or wget --debug (debug mode) • neutron -v or neutron -d or neutron --debug (neutron debug mode) • http://www.httpdebugger.com • https://www.wireshark.org
  • 18. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 18DEVNET-2055 Troubleshooting / debugging REST APIs using Python import httplib import logging import requests httplib.HTTPConnection.debuglevel = 1 logging.basicConfig() logging.getLogger().setLevel(logging.DEBUG) requests_log = logging.getLogger("requests.packages.urllib3") requests_log.setLevel(logging.DEBUG) requests_log.propagate = True result = requests.get('http://www.cisco.com/')
  • 19. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 19DEVNET-2055 Troubleshooting / debugging REST APIs using Python >>> result = requests.get('http://www.cisco.com/') INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): www.cisco.com send: 'GET / HTTP/1.1rnHost: www.cisco.comrnConnection: keep-alivernAccept-Encoding: gzip, deflaternAccept: */*rnUser-Agent: python-requests/2.10.0rnrn' reply: 'HTTP/1.1 200 OKrn' header: Server: Apache header: ETag: "10839-53789488e5b33" header: Accept-Ranges: bytes header: Content-Encoding: gzip header: CDCHOST: wemxweb-publish-prod1-01 header: Content-Length: 14215 header: Content-Type: text/html header: Expires: Wed, 13 Jul 2016 20:25:27 GMT header: Cache-Control: max-age=0, no-cache, no-store header: Pragma: no-cache header: Date: Wed, 13 Jul 2016 20:25:27 GMT header: Connection: keep-alive header: access-control-allow-origin: * DEBUG:requests.packages.urllib3.connectionpool:"GET / HTTP/1.1" 200 14215 >>> print result <Response [200]>
  • 20. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Complete Your Online Session Evaluation Don’t forget: Cisco Live sessions will be available for viewing on-demand after the event at CiscoLive.com/Online • Give us your feedback to be entered into a Daily Survey Drawing. A daily winner will receive a $750 Amazon gift card. • Complete your session surveys through the Cisco Live mobile app or from the Session Catalog on CiscoLive.com/us. 20Presentation ID
  • 22. Q & A
  • 23.
  • 25. Mocking a REST server to unit-test REST APIs
  • 26. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 26DEVNET-2055 Mocking a REST server to unit-test REST APIs • https://github.com/openstack/requests-mock >>> import requests >>> import requests_mock >>> session = requests.Session() >>> adapter = requests_mock.Adapter() >>> session.mount('mock', adapter) >>> adapter.register_uri('GET', 'mock://test.com', text='data') >>> resp = session.get('mock://test.com') >>> resp.status_code, resp.text (200, 'data')
  • 27. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 27DEVNET-2055 Mocking a REST server to unit-test REST APIs • https://pypi.python.org/pypi/mock-server/0.3.7 • https://github.com/gabrielfalcao/HTTPretty • http://python-mock-tutorial.readthedocs.io/en/latest/mock.html
  • 28. REST API caching and cache-aware REST clients
  • 29. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 29DEVNET-2055 REST API caching and cache-aware REST clients • RFC 7234 - https://tools.ietf.org/html/rfc7234#section-5 • REST supports HTTP cache-control headers: max-age max-stale min-fresh no-cache no-store no-transform only-if-cached must-revalidate Public private
  • 30. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 30DEVNET-2055 REST API caching and cache-aware REST clients • Keystone caching • http://docs.openstack.org/admin-guide/keystone_caching_layer.html • http://docs.openstack.org/developer/keystone/configuration.html#caching-layer • Glance image caching • http://docs.openstack.org/developer/glance/cache.html • OSLO caching • http://docs.openstack.org/developer/oslo.cache/api.html • https://specs.openstack.org/openstack/api-wg/guidelines/http.html#http-caching-and- proxy-behavior • Memcached • http://docs.openstack.org/ha-guide/controller-ha-memcached.html
  • 31. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 31DEVNET-2055 REST API caching and cache-aware REST clients
  • 32. Bulk REST operations and REST API batching
  • 33. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 33DEVNET-2055 Bulk REST operations and REST API batching • http://developer.openstack.org/api-ref-networking-v2.html#bulkCreateNetwork • https://wiki.openstack.org/wiki/Neutron/APIv2-specification#Bulk_version
  • 34. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 34DEVNET-2055 Bulk REST operations and REST API batching • Bulk REST API JSON request format: POST v2.0/networks.json Content-Type: application/json Accept: application/json { "networks": [ { "name": "sample_network_1", "admin_state_up": false }, { "name": "sample_network_2", "admin_state_up": false }] }