OpenStack Nova ‘Reverse Engineer’
2016 May 07
Hieu LE
Vietnam OpenStack Community Organizer
Fujitsu Vietnam - PODC
Copyright 2016 Fujitsu Vietnam Limited
Starting Point (1)
1 Copyright 2016 Fujitsu Vietnam Limited
Video Tutorial: how to setup remote debugging environment for OpenStack Nova,
request from some community members.
Ref: https://youtu.be/Z0PmKyeZjjA
Starting Point (2)
 @NamNH (Fujitsu) contribute to documentation: “Debugging
OpenStack Neutron”
Ref: https://vietstack.wordpress.com/2016/04/12/how-to-remote-debugging-openstack-neutron/
Hope that he will present at next
technical meetup about Neutron ;)
2 Copyright 2016 Fujitsu Vietnam Limited
Agenda
Copyright 2016 Fujitsu Vietnam Limited
1. Architecture overview
2. Data Flows
3. Nova Code Structure Components
4. Conclusion
3
“to provide massively scalable, on demand,
self service access to compute resources”
OpenStack Nova mission
http://docs.openstack.org/developer/nova/project_scope.html
4 Copyright 2016 Fujitsu Vietnam Limited
“to provide massively scalable, on demand,
self service access to compute resources”
OpenStack Nova mission
http://docs.openstack.org/developer/nova/project_scope.html
5 Copyright 2016 Fujitsu Vietnam Limited
Virtual Servers Containers Bare Metal Servers Driver Parity
Agenda
Copyright 2016 Fujitsu Vietnam Limited
1. Architecture overview
2. Data Flows
3. Nova Code Structure Components
4. Conclusion
6
Architecture overview
 Model:
 Nova Network
 Neutron
 Cells (v1, 2)
 Core components
 DB: sql database for data storage.
 API: receive HTTP requests, converts commands and communicates with other
components via the oslo.messaging queue or HTTP
 Scheduler: decides which host gets each instance
 Compute: manages communication with hypervisor and virtual machines.
 Conductor: handles requests that need coordination(build/resize), acts as a
database proxy, or handles object conversions.
 Cells: used by some large deployments to partition compute nodes into smaller
groups, coupled with a database and queue. DEFAULT FROM MITAKA WITH
CELLS V2
7 Copyright 2016 Fujitsu Vietnam Limited
Architecture overview
 Other nova components
 Network: manages ip forwarding, bridges, and vlans
 Metadata: serves metadata for instances
 Cert: serves X509 certificates, using for euca-bundle-image and only needed for
EC2 API
 Console auth and proxies: noVNC, SPICE, XVP, RDP.. for remote console
purpose toward instances
 EC2: *DEPRECATED AND MOVE TO NEW EC2-API PROJECT FROM
MITAKA* using EC2 API with nova services.
8 Copyright 2016 Fujitsu Vietnam Limited
Architecture overview (1)
9 Copyright 2016 Fujitsu Vietnam Limited
1
2 3 45
7
6
Ref:
http://docs.openstack.org/developer/nova/architecture.html
Architecture overview (2)
10 Copyright 2016 Fujitsu Vietnam Limited
1
2 3 45
7
6
Ref:
http://docs.openstack.org/developer/nova/architecture.html
Architecture overview (2)
 Normal Workflow
11 Copyright 2016 Fujitsu Vietnam Limited
 MQ and DB is under heavy-load.
 Cells
There are Austin summit video about Nova scheduler performance.
https://www.openstack.org/videos/video/dive-into-nova-scheduler-performance-where-is-the-bottleneck
https://docs.google.com/presentation/d/1UG1HkEWyxPVMXseLwJ44ZDm-
ek_MPc4M65H8EiwZnWs/edit?ts=571fcdd5#slide=id.g12d2cf15cd_2_84
Architecture overview (3)
12 Copyright 2016 Fujitsu Vietnam Limited
Ref: OpenStack Japan User Group
Architecture overview (3)
13 Copyright 2016 Fujitsu Vietnam Limited
API DB
Compute DB
Architecture overview (3)
 Cells: aim for easily scaling and providing fault tolerance by
partition compute nodes into smaller groups with separate
database and queue, instead of legacy deployment model with
single logical database and message queue.
 Cells v1:
 Optional
 Not all features supported
 Sync instance between DBs
 Cells v2:
 Default deployment model is one v2 cell
 New API database
 Tools to migrate from cells v1 **NOT IMPLEMENTED IN MITAKA,
PLAN IS IN NEWTON**
14 Copyright 2016 Fujitsu Vietnam Limited
Agenda
Copyright 2016 Fujitsu Vietnam Limited
1. Architecture overview
2. Data Flows
3. Nova code structure
4. Conclusion
15
Façade
16 Copyright 2016 Fujitsu Vietnam Limited
WSGIService
oslo_service lib
Paste filters
Paste/Paste.Deploy lib via api-paste.ini
WebOb lib for WSGI req/res wrapper
1. RESTful req 2. WSGI Req
APIRouter
RoutesMiddleware
3. Filtered req
Routes lib
Extension
Controller:
index/show/delete/
create..
Extension
Controller:
index/show/delete/
create..
Extension
Controller:
index/show/delete/
create..
4. Req dispatching
stevedore lib for managing ext, ctrl
Expose via pbr entrypoint
oslo_conf
Façade/Decorator pattern
oslo_message
RPC
Façade design pattern
 Nova-compute API (nova/nova/compute/api.py): API, HostAPI,
InstanceActionAPI, KeypairAPI…
17 Copyright 2016 Fujitsu Vietnam Limited
Ref: Wikipedia/façade_pattern
OpenStack Oslo common lib
 oslo.cache: a library for caching based on dogpile
 oslo.concurrency: a project with helpers managing external
processes and task synchronization. E.g: check host
resources.
 oslo.config: an extensive library for parsing configuration files
and command line arguments.
 oslo.log: a logging configuration library.
 oslo.service: helper library that provides functionality for
running OpenStack services.  nova-api service
 oslo.messaging: a library that provides a messaging API which
supports RPC and notifications over a number of different
messaging transports.
 oslo.serialization
Ref: https://wiki.openstack.org/wiki/Oslo
18 Copyright 2016 Fujitsu Vietnam Limited
pbr
 Python Build Reasonableness: using setuptools to deploy your
code and expose via entry points.
 setup.cfg
 policy.json: will be checked each time an API is called
 Can be modified for reasonable purpose
19 Copyright 2016 Fujitsu Vietnam Limited
WSGI – PEP 0333
nova/wsgi.py
 WSGI Application
 Python callable passed two arg (WebOb)
• Env
• Start_response function  callback function
 WSGI Server
 Call the application
 WSGI Middleware (Paste)
 Both a server and application
 Use to wrap request
Paste Deploy will automatically find and config WSGI
applications and servers
20 Copyright 2016 Fujitsu Vietnam Limited
Ref: WSGI – Aseries of Tubes by Ian Bickings (The
Open Planning Project)
21 Copyright 2016 Fujitsu Vietnam Limited
Paste
 http://pythonpaste.org/
 Check api-paste.ini file below and see DEMO
22 Copyright 2016 Fujitsu Vietnam Limited
Middleware filter Apps
Filter flow
Stevedore (1)
 Extension manager library
 https://github.com/openstack/stevedore
 http://docs.openstack.org/developer/stevedore/
23 Copyright 2016 Fujitsu Vietnam Limited
Stevedore (2)
 Check nova/api/openstack/compute/disk_config.py
 Easier to write new API
 Easier to write new plugin
24 Copyright 2016 Fujitsu Vietnam Limited
Stevedore (3)
 Where is extension manager ?
nova/api/openstack/__init__.py – ApiRouterv21 class
nova/compute/monitors/__init.py__
and more …
25 Copyright 2016 Fujitsu Vietnam Limited
Routes
 Mapping URLs to controllers+actions. URLs are mapped to
‘action’ methods on ‘controller’ classes in
nova/api/openstack/__init__.py, class ApiRouter._init_ and
ApiRouterv21.__init__
26 Copyright 2016 Fujitsu Vietnam Limited
Stevedore ext mgr
Map URL from alias
/v2.1/​{tenant_id}​/os-aggregates
Ref: api-ref site OpenStack
Agenda
Copyright 2016 Fujitsu Vietnam Limited
1. Architecture overview
2. Data Flows
3. Nova Code Structure Components
4. Conclusion
27
Nova code structure
28 Copyright 2016 Fujitsu Vietnam Limited
documentation
For packaging, deploying and testing (using tox)
Source Codes
For setup with devstack
Configuration files
XenServer plugin for using with nova
Nova code structure
 Configuration files
29 Copyright 2016 Fujitsu Vietnam Limited
Rootwrap.d conf: allow a service-specific
unprivileged user to run a number of actions as
the root user, in the safest manner possible.
https://wiki.openstack.org/wiki/Rootwrap
Nova API config (paste + policy)
Nova Cells config sample
http://docs.openstack.org/mitaka/config-reference/compute/cells.html
Docs
Logging sample config file
Nova config generator file. Using oslo-config-generator
tool or tox –egenconfig for a sample of nova.conf file.
Nova.conf sample file will list all nova config options
and default value of each option.
Nova code structure
 Configuration files
30 Copyright 2016 Fujitsu Vietnam Limited
Rootwrap.d conf: allow a service-specific
unprivileged user to run a number of actions as
the root user, in the safest manner possible.
https://wiki.openstack.org/wiki/Rootwrap
Nova API config (paste + policy)
Nova Cells config sample
http://docs.openstack.org/mitaka/config-reference/compute/cells.html
Docs
Logging sample config file
Nova config generator file. Using oslo-config-generator
tool or tox –egenconfig for a sample of nova.conf file.
Nova.conf sample file will list all nova config options
and default value of each option. (~810 option)
Nova source code
31 Copyright 2016 Fujitsu Vietnam Limited
Executable system script, bundle and expose via pbr.
e.g.: nova-api, nova-compute..
Centralize configuration options for all nova subcomponents
(WIP  Newton version)
Nova compute virt (virtualization) driver  driver parity approach
Nova source code
32 Copyright 2016 Fujitsu Vietnam Limited
Executable system script, bundle and expose via pbr.
e.g.: nova-api, nova-compute..
Centralize configuration options for all nova subcomponents
(WIP  Newton version)
Nova compute virt (virtualization) driver  driver parity approach
HANDS-ON DEMO
Agenda
Copyright 2016 Fujitsu Vietnam Limited
1. Architecture overview
2. Nova Code Structure Components
3. Data Flows
4. Conclusion
33
Conclusion
34 Copyright 2016 Fujitsu Vietnam Limited
WSGIService
oslo_service lib
Paste filters
Paste/Paste.Deploy lib via api-paste.ini
WebOb lib for WSGI req/res wrapper
1. RESTful req 2. WSGI Req
APIRouter
RoutesMiddleware
3. Filtered req
Routes lib
Extension
Controller:
index/show/delete/
create..
Extension
Controller:
index/show/delete/
create..
Extension
Controller:
index/show/delete/
create..
4. Req dispatching
stevedore lib for managing ext, ctrl
Expose via pbr entrypoint
oslo_conf
Façade/Decorator pattern
oslo_message
RPC
THANK YOU!
Copyright 2016 Fujitsu Vietnam Limited35

Open stack nova reverse engineer

  • 1.
    OpenStack Nova ‘ReverseEngineer’ 2016 May 07 Hieu LE Vietnam OpenStack Community Organizer Fujitsu Vietnam - PODC Copyright 2016 Fujitsu Vietnam Limited
  • 2.
    Starting Point (1) 1Copyright 2016 Fujitsu Vietnam Limited Video Tutorial: how to setup remote debugging environment for OpenStack Nova, request from some community members. Ref: https://youtu.be/Z0PmKyeZjjA
  • 3.
    Starting Point (2) @NamNH (Fujitsu) contribute to documentation: “Debugging OpenStack Neutron” Ref: https://vietstack.wordpress.com/2016/04/12/how-to-remote-debugging-openstack-neutron/ Hope that he will present at next technical meetup about Neutron ;) 2 Copyright 2016 Fujitsu Vietnam Limited
  • 4.
    Agenda Copyright 2016 FujitsuVietnam Limited 1. Architecture overview 2. Data Flows 3. Nova Code Structure Components 4. Conclusion 3
  • 5.
    “to provide massivelyscalable, on demand, self service access to compute resources” OpenStack Nova mission http://docs.openstack.org/developer/nova/project_scope.html 4 Copyright 2016 Fujitsu Vietnam Limited
  • 6.
    “to provide massivelyscalable, on demand, self service access to compute resources” OpenStack Nova mission http://docs.openstack.org/developer/nova/project_scope.html 5 Copyright 2016 Fujitsu Vietnam Limited Virtual Servers Containers Bare Metal Servers Driver Parity
  • 7.
    Agenda Copyright 2016 FujitsuVietnam Limited 1. Architecture overview 2. Data Flows 3. Nova Code Structure Components 4. Conclusion 6
  • 8.
    Architecture overview  Model: Nova Network  Neutron  Cells (v1, 2)  Core components  DB: sql database for data storage.  API: receive HTTP requests, converts commands and communicates with other components via the oslo.messaging queue or HTTP  Scheduler: decides which host gets each instance  Compute: manages communication with hypervisor and virtual machines.  Conductor: handles requests that need coordination(build/resize), acts as a database proxy, or handles object conversions.  Cells: used by some large deployments to partition compute nodes into smaller groups, coupled with a database and queue. DEFAULT FROM MITAKA WITH CELLS V2 7 Copyright 2016 Fujitsu Vietnam Limited
  • 9.
    Architecture overview  Othernova components  Network: manages ip forwarding, bridges, and vlans  Metadata: serves metadata for instances  Cert: serves X509 certificates, using for euca-bundle-image and only needed for EC2 API  Console auth and proxies: noVNC, SPICE, XVP, RDP.. for remote console purpose toward instances  EC2: *DEPRECATED AND MOVE TO NEW EC2-API PROJECT FROM MITAKA* using EC2 API with nova services. 8 Copyright 2016 Fujitsu Vietnam Limited
  • 10.
    Architecture overview (1) 9Copyright 2016 Fujitsu Vietnam Limited 1 2 3 45 7 6 Ref: http://docs.openstack.org/developer/nova/architecture.html
  • 11.
    Architecture overview (2) 10Copyright 2016 Fujitsu Vietnam Limited 1 2 3 45 7 6 Ref: http://docs.openstack.org/developer/nova/architecture.html
  • 12.
    Architecture overview (2) Normal Workflow 11 Copyright 2016 Fujitsu Vietnam Limited  MQ and DB is under heavy-load.  Cells There are Austin summit video about Nova scheduler performance. https://www.openstack.org/videos/video/dive-into-nova-scheduler-performance-where-is-the-bottleneck https://docs.google.com/presentation/d/1UG1HkEWyxPVMXseLwJ44ZDm- ek_MPc4M65H8EiwZnWs/edit?ts=571fcdd5#slide=id.g12d2cf15cd_2_84
  • 13.
    Architecture overview (3) 12Copyright 2016 Fujitsu Vietnam Limited Ref: OpenStack Japan User Group
  • 14.
    Architecture overview (3) 13Copyright 2016 Fujitsu Vietnam Limited API DB Compute DB
  • 15.
    Architecture overview (3) Cells: aim for easily scaling and providing fault tolerance by partition compute nodes into smaller groups with separate database and queue, instead of legacy deployment model with single logical database and message queue.  Cells v1:  Optional  Not all features supported  Sync instance between DBs  Cells v2:  Default deployment model is one v2 cell  New API database  Tools to migrate from cells v1 **NOT IMPLEMENTED IN MITAKA, PLAN IS IN NEWTON** 14 Copyright 2016 Fujitsu Vietnam Limited
  • 16.
    Agenda Copyright 2016 FujitsuVietnam Limited 1. Architecture overview 2. Data Flows 3. Nova code structure 4. Conclusion 15
  • 17.
    Façade 16 Copyright 2016Fujitsu Vietnam Limited WSGIService oslo_service lib Paste filters Paste/Paste.Deploy lib via api-paste.ini WebOb lib for WSGI req/res wrapper 1. RESTful req 2. WSGI Req APIRouter RoutesMiddleware 3. Filtered req Routes lib Extension Controller: index/show/delete/ create.. Extension Controller: index/show/delete/ create.. Extension Controller: index/show/delete/ create.. 4. Req dispatching stevedore lib for managing ext, ctrl Expose via pbr entrypoint oslo_conf Façade/Decorator pattern oslo_message RPC
  • 18.
    Façade design pattern Nova-compute API (nova/nova/compute/api.py): API, HostAPI, InstanceActionAPI, KeypairAPI… 17 Copyright 2016 Fujitsu Vietnam Limited Ref: Wikipedia/façade_pattern
  • 19.
    OpenStack Oslo commonlib  oslo.cache: a library for caching based on dogpile  oslo.concurrency: a project with helpers managing external processes and task synchronization. E.g: check host resources.  oslo.config: an extensive library for parsing configuration files and command line arguments.  oslo.log: a logging configuration library.  oslo.service: helper library that provides functionality for running OpenStack services.  nova-api service  oslo.messaging: a library that provides a messaging API which supports RPC and notifications over a number of different messaging transports.  oslo.serialization Ref: https://wiki.openstack.org/wiki/Oslo 18 Copyright 2016 Fujitsu Vietnam Limited
  • 20.
    pbr  Python BuildReasonableness: using setuptools to deploy your code and expose via entry points.  setup.cfg  policy.json: will be checked each time an API is called  Can be modified for reasonable purpose 19 Copyright 2016 Fujitsu Vietnam Limited
  • 21.
    WSGI – PEP0333 nova/wsgi.py  WSGI Application  Python callable passed two arg (WebOb) • Env • Start_response function  callback function  WSGI Server  Call the application  WSGI Middleware (Paste)  Both a server and application  Use to wrap request Paste Deploy will automatically find and config WSGI applications and servers 20 Copyright 2016 Fujitsu Vietnam Limited Ref: WSGI – Aseries of Tubes by Ian Bickings (The Open Planning Project)
  • 22.
    21 Copyright 2016Fujitsu Vietnam Limited
  • 23.
    Paste  http://pythonpaste.org/  Checkapi-paste.ini file below and see DEMO 22 Copyright 2016 Fujitsu Vietnam Limited Middleware filter Apps Filter flow
  • 24.
    Stevedore (1)  Extensionmanager library  https://github.com/openstack/stevedore  http://docs.openstack.org/developer/stevedore/ 23 Copyright 2016 Fujitsu Vietnam Limited
  • 25.
    Stevedore (2)  Checknova/api/openstack/compute/disk_config.py  Easier to write new API  Easier to write new plugin 24 Copyright 2016 Fujitsu Vietnam Limited
  • 26.
    Stevedore (3)  Whereis extension manager ? nova/api/openstack/__init__.py – ApiRouterv21 class nova/compute/monitors/__init.py__ and more … 25 Copyright 2016 Fujitsu Vietnam Limited
  • 27.
    Routes  Mapping URLsto controllers+actions. URLs are mapped to ‘action’ methods on ‘controller’ classes in nova/api/openstack/__init__.py, class ApiRouter._init_ and ApiRouterv21.__init__ 26 Copyright 2016 Fujitsu Vietnam Limited Stevedore ext mgr Map URL from alias /v2.1/​{tenant_id}​/os-aggregates Ref: api-ref site OpenStack
  • 28.
    Agenda Copyright 2016 FujitsuVietnam Limited 1. Architecture overview 2. Data Flows 3. Nova Code Structure Components 4. Conclusion 27
  • 29.
    Nova code structure 28Copyright 2016 Fujitsu Vietnam Limited documentation For packaging, deploying and testing (using tox) Source Codes For setup with devstack Configuration files XenServer plugin for using with nova
  • 30.
    Nova code structure Configuration files 29 Copyright 2016 Fujitsu Vietnam Limited Rootwrap.d conf: allow a service-specific unprivileged user to run a number of actions as the root user, in the safest manner possible. https://wiki.openstack.org/wiki/Rootwrap Nova API config (paste + policy) Nova Cells config sample http://docs.openstack.org/mitaka/config-reference/compute/cells.html Docs Logging sample config file Nova config generator file. Using oslo-config-generator tool or tox –egenconfig for a sample of nova.conf file. Nova.conf sample file will list all nova config options and default value of each option.
  • 31.
    Nova code structure Configuration files 30 Copyright 2016 Fujitsu Vietnam Limited Rootwrap.d conf: allow a service-specific unprivileged user to run a number of actions as the root user, in the safest manner possible. https://wiki.openstack.org/wiki/Rootwrap Nova API config (paste + policy) Nova Cells config sample http://docs.openstack.org/mitaka/config-reference/compute/cells.html Docs Logging sample config file Nova config generator file. Using oslo-config-generator tool or tox –egenconfig for a sample of nova.conf file. Nova.conf sample file will list all nova config options and default value of each option. (~810 option)
  • 32.
    Nova source code 31Copyright 2016 Fujitsu Vietnam Limited Executable system script, bundle and expose via pbr. e.g.: nova-api, nova-compute.. Centralize configuration options for all nova subcomponents (WIP  Newton version) Nova compute virt (virtualization) driver  driver parity approach
  • 33.
    Nova source code 32Copyright 2016 Fujitsu Vietnam Limited Executable system script, bundle and expose via pbr. e.g.: nova-api, nova-compute.. Centralize configuration options for all nova subcomponents (WIP  Newton version) Nova compute virt (virtualization) driver  driver parity approach HANDS-ON DEMO
  • 34.
    Agenda Copyright 2016 FujitsuVietnam Limited 1. Architecture overview 2. Nova Code Structure Components 3. Data Flows 4. Conclusion 33
  • 35.
    Conclusion 34 Copyright 2016Fujitsu Vietnam Limited WSGIService oslo_service lib Paste filters Paste/Paste.Deploy lib via api-paste.ini WebOb lib for WSGI req/res wrapper 1. RESTful req 2. WSGI Req APIRouter RoutesMiddleware 3. Filtered req Routes lib Extension Controller: index/show/delete/ create.. Extension Controller: index/show/delete/ create.. Extension Controller: index/show/delete/ create.. 4. Req dispatching stevedore lib for managing ext, ctrl Expose via pbr entrypoint oslo_conf Façade/Decorator pattern oslo_message RPC
  • 36.
    THANK YOU! Copyright 2016Fujitsu Vietnam Limited35