SlideShare a Scribd company logo
1 of 24
Download to read offline
Python Bindings for SA Forum AIS APIs

                        Hans Feldt
                         Ericsson

                        Currie Reid
                   Linux Product Division
                        Wind River
Outline of Presentation

•   Objectives
•   What is Python?
•   Mapping Python to Objectives
•   How Python bindings are implemented
•   (Demonstration)
•   Future Works
Objectives

• Enable testing in all phases of the software
  lifecycle.
• Simplify development across different
  architectures.
• Simplify presentation to developers and
  engineers.
• Quickly create tools that make it easy to
  investigate and monitor the system.
• Make it easy to create and modify prototypes.
What is Python?

• General purpose, high-level, interpreted
  language.
• Design philosophy emphasizes code readability.
• Designed to be extensible
• Large, comprehensive standard library.
• Supports object-oriented, imperative, and (lesser
  degree) functional programming paradigms.
• Dynamic type system, automatic memory
  management.
• Free, open-source, many 3rd party packages.
Popularity and Usage

• Twice awarded as “Programming language of the
  Year” by TIOBE (2007 & 2010)
• Ranked number 8 in the TIOBE popularity index
• Used as a scripting language for web applications
  (Django, Pylons, …)
• Used as an embedded scripting language in other
  programs (GIMP, GDB, ..)
• OpenSAF related: Mercurial, Buildbot, Trac, Yum
• Standard component in Linux distributions
Enable testing in all phases of software
lifecycle
• Test coverage more complete if easy to write
  tests; test-driven development encouraged!
• Tests are portable across architectures.
• Built-in modules for testing include unittest and
  doctest.
• Modules available for unit testing, mock testing,
  fuzz testing, web testing, gui testing, etc.
• i.e.: nose, py.test, zope.testing.
Simplify development across different
architectures
• Python scripts are portable across different
  architectures.
• Edit-compile-run cycle is greatly reduced.
• Python code can be edited/patched on the target
  system if required.
• Huge collection of native and 3rd-party bindings
  available to aid/speed development.
Simplify presentation to developers and
engineers
• Python syntax reads like pseudo-code.
• Most Python programs much smaller than lower-
  level implementations.
• Easier to examine the problem domain when
  you abstract-away programming details and
  challenges associated with the machine.
• Do more with less
Make it easy to create and modify
prototypes
• Components and applications can be rapidly
  prototyped in Python.
• Designs can then be hardened in another
  implementation language.
• Ideal glue language.
• Working code can be developed much faster
  than lower-level languages.
• Identify “hot spots” in application and possibly
  optimize by extending with C/C++
Ctypes module: Wrap Libraries in Python

• Advanced FFI (Foreign Function Interface) for
  Python 2.3 and higher.
• Included in Python 2.5
• Provides C compatible data types
• Call functions in shared libraries (DLLs).
• Create, access and manipulate simple and
  complicated C data types in Python.
• Enables C callbacks to be implemented in
  Python.
Python Bindings Implementation

•   Conversion of SAF types to ctypes
•   Definition of Const
•   Definition of Enumeration
•   Definition of Struct
•   Definition of Union
•   Dynamic Loading of Libraries and CDLL
•   Definition of Functions
•   Definition of callbacks and CFUNCTYPE
Conversion of SAF types to ctypes

SaInt8T     =   c_char
SaInt16T    =   c_short
SaInt32T    =   c_int
SaInt64T    =   c_longlong
SaUint8T    =   c_ubyte
SaUint16T   =   c_ushort
SaUint32T   =   c_uint
SaUint64T   =   c_ulonglong
...

myuint = SaUint64T(12)
Definition of Const

saAis = Const()

saAis.SA_TIME_END = 0x7FFFFFFFFFFFFFFF
saAis.SA_TIME_BEGIN = 0x0
saAis.SA_TIME_UNKNOWN = 0x8000000000000000




time_start = saAis.SA_TIME_BEGIN
saAis.SA_TIME_BEGIN = 5 #ERROR: EXCEPTION
Definition of Enumeration

SaDispatchFlagsT = SaEnumT
eSaDispatchFlagsT = Enumeration((
  ('SA_DISPATCH_ONE', 1),
  ('SA_DISPATCH_ALL', 2),
  ('SA_DISPATCH_BLOCKING', 3),
))




flag = eSaDispatchFlagsT.SA_DISPATCH_ALL
flag_str = eSaDispatchFlagsT.whatis(flag)
Definition of Structs
class SaNameT(Structure):
   _fields_ = [('length', SaUint16T),
      ('value',(SaInt8T*saAis.SA_MAX_NAME_LENGTH))]

  def __init__(self, name=''):
      super(SaNameT, self).__init__(len(name), name)




dn = SaNameT(‘safApp=OpenSAF’)
Definition of Unions

class SaLimitValueT(Union):
   _fields_ = [('int64Value', SaInt64T),
      ('uint64Value', SaUint64T),
      ('timeValue', SaTimeT),
      ('floatValue', SaFloatT),
      ('doubleValue', SaDoubleT)]




un = SaLimitValueT()
un.timeValue = 5000000000
Dynamic Loading of Libraries using CDLL

amfdll = CDLL('libSaAmf.so.0')




  Functions in the library accessible as
  attributes of the amfdll object.
Definition of Functions

def saAmfInitialize(amfHandle,
   amfCallbacks, version):




  return amfdll.saAmfInitialize(
    BYREF(amfHandle),
    BYREF(amfCallbacks),
    BYREF(version))
Example usage

amfHandle = SaAmfHandleT()
amfCallbacks = None
version = SaVersionT(‘B’, 1, 1)

rc = saAmfInitialize(amfHandle,
   amfCallbacks, version)
Definition of callbacks and CFUNCTYPE

SaAmfCSISetCallbackT = CFUNCTYPE(None,
   SaInvocationT, POINTER(SaNameT),
   SaAmfHAStateT, SaAmfCSIDescriptorT)

def myCSISetCallback(invoc,
   comp, hastate, descr):
   …
callbacks = SaAmfCallbacksT()
callbacks.saAmfCSISetCallbackT(
   SaAmfCSISetCallbackT(myCSISetCallback))
Bindings in 4.2

• A 1:1 mapping primarily aimed for OpenSAF
  services testing
• Samples using the bindings
Future Work

• Pythonic interfaces (inspired by Java bindings?)
• OpenSAF test framework using Python bindings
• Simple GUI for management
• Bindings for IMM A.02.11 – OpenSAF
  extensions
• Complete SMF bindings
Example of Pythonic Interface
def foo(parent, values, mods, dn1, dn2):
  owner = SaImmOmOwner(‘Hans’)
  owner.set(parent)
  ccb = SaImmOmCcb(owner)
  ccb.objectCreate(‘TestClass’, parent, values)
  ccb.objectModify(dn1, mods)
  ccb.objectDelete(dn2)
  ccb.apply()
Questions?

More Related Content

What's hot

Linaro Connect 2016 (BKK16) - Introduction to LISA
Linaro Connect 2016 (BKK16) - Introduction to LISALinaro Connect 2016 (BKK16) - Introduction to LISA
Linaro Connect 2016 (BKK16) - Introduction to LISAPatrick Bellasi
 
CICC 2001 - Reducing Multiple Design Flow Support Requirements with OLA
CICC 2001 - Reducing Multiple Design Flow Support Requirements with OLACICC 2001 - Reducing Multiple Design Flow Support Requirements with OLA
CICC 2001 - Reducing Multiple Design Flow Support Requirements with OLATim55Ehrler
 
SWIM MasterClass - Building SWIM B2B web services using Open Standards
SWIM MasterClass - Building SWIM B2B web services using Open StandardsSWIM MasterClass - Building SWIM B2B web services using Open Standards
SWIM MasterClass - Building SWIM B2B web services using Open StandardsDebbie Wilson
 
Irati goals and achievements - 3rd RINA Workshop
Irati goals and achievements - 3rd RINA WorkshopIrati goals and achievements - 3rd RINA Workshop
Irati goals and achievements - 3rd RINA WorkshopEleni Trouva
 
Jython for embedded software validation
Jython for embedded software validationJython for embedded software validation
Jython for embedded software validationPyCon Italia
 
Simulating metal coil handling
Simulating metal coil handlingSimulating metal coil handling
Simulating metal coil handlingjhjsmits
 
Barak Perlman, ConteXtream - SFC (Service Function Chaining) Using Openstack ...
Barak Perlman, ConteXtream - SFC (Service Function Chaining) Using Openstack ...Barak Perlman, ConteXtream - SFC (Service Function Chaining) Using Openstack ...
Barak Perlman, ConteXtream - SFC (Service Function Chaining) Using Openstack ...Cloud Native Day Tel Aviv
 
OpenSPARC T1 Processor
OpenSPARC T1 ProcessorOpenSPARC T1 Processor
OpenSPARC T1 ProcessorDVClub
 
Next Generation MPICH: What to Expect - Lightweight Communication and More
Next Generation MPICH: What to Expect - Lightweight Communication and MoreNext Generation MPICH: What to Expect - Lightweight Communication and More
Next Generation MPICH: What to Expect - Lightweight Communication and MoreIntel® Software
 
OpenPOWER Application Optimization
OpenPOWER Application Optimization OpenPOWER Application Optimization
OpenPOWER Application Optimization Ganesan Narayanasamy
 
Dynamic Service Chaining
Dynamic Service Chaining Dynamic Service Chaining
Dynamic Service Chaining Tail-f Systems
 
Yang in OpenDaylight
Yang in OpenDaylightYang in OpenDaylight
Yang in OpenDaylightGunjan Patel
 

What's hot (19)

Linaro Connect 2016 (BKK16) - Introduction to LISA
Linaro Connect 2016 (BKK16) - Introduction to LISALinaro Connect 2016 (BKK16) - Introduction to LISA
Linaro Connect 2016 (BKK16) - Introduction to LISA
 
CICC 2001 - Reducing Multiple Design Flow Support Requirements with OLA
CICC 2001 - Reducing Multiple Design Flow Support Requirements with OLACICC 2001 - Reducing Multiple Design Flow Support Requirements with OLA
CICC 2001 - Reducing Multiple Design Flow Support Requirements with OLA
 
SWIM MasterClass - Building SWIM B2B web services using Open Standards
SWIM MasterClass - Building SWIM B2B web services using Open StandardsSWIM MasterClass - Building SWIM B2B web services using Open Standards
SWIM MasterClass - Building SWIM B2B web services using Open Standards
 
8 ert
8 ert8 ert
8 ert
 
OpenFlow
OpenFlowOpenFlow
OpenFlow
 
Sharam salamian
Sharam salamianSharam salamian
Sharam salamian
 
Irati goals and achievements - 3rd RINA Workshop
Irati goals and achievements - 3rd RINA WorkshopIrati goals and achievements - 3rd RINA Workshop
Irati goals and achievements - 3rd RINA Workshop
 
Real Time Support For Xen
Real Time Support For XenReal Time Support For Xen
Real Time Support For Xen
 
Right Availability in RAC environment. Playing with Oracle clusterware infras...
Right Availability in RAC environment. Playing with Oracle clusterware infras...Right Availability in RAC environment. Playing with Oracle clusterware infras...
Right Availability in RAC environment. Playing with Oracle clusterware infras...
 
Jython for embedded software validation
Jython for embedded software validationJython for embedded software validation
Jython for embedded software validation
 
Implement Checkpointing for Android
Implement Checkpointing for AndroidImplement Checkpointing for Android
Implement Checkpointing for Android
 
Simulating metal coil handling
Simulating metal coil handlingSimulating metal coil handling
Simulating metal coil handling
 
Barak Perlman, ConteXtream - SFC (Service Function Chaining) Using Openstack ...
Barak Perlman, ConteXtream - SFC (Service Function Chaining) Using Openstack ...Barak Perlman, ConteXtream - SFC (Service Function Chaining) Using Openstack ...
Barak Perlman, ConteXtream - SFC (Service Function Chaining) Using Openstack ...
 
OpenSPARC T1 Processor
OpenSPARC T1 ProcessorOpenSPARC T1 Processor
OpenSPARC T1 Processor
 
Next Generation MPICH: What to Expect - Lightweight Communication and More
Next Generation MPICH: What to Expect - Lightweight Communication and MoreNext Generation MPICH: What to Expect - Lightweight Communication and More
Next Generation MPICH: What to Expect - Lightweight Communication and More
 
OpenPOWER Application Optimization
OpenPOWER Application Optimization OpenPOWER Application Optimization
OpenPOWER Application Optimization
 
Dynamic Service Chaining
Dynamic Service Chaining Dynamic Service Chaining
Dynamic Service Chaining
 
Yang in OpenDaylight
Yang in OpenDaylightYang in OpenDaylight
Yang in OpenDaylight
 
Shalini xs10
Shalini xs10Shalini xs10
Shalini xs10
 

Similar to OpenSAF Symposium_Python Bindings_9.21.11

Python-Yesterday Today Tomorrow(What's new?)
Python-Yesterday Today Tomorrow(What's new?)Python-Yesterday Today Tomorrow(What's new?)
Python-Yesterday Today Tomorrow(What's new?)Mohan Arumugam
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Fwdays
 
Open Source Swift Under the Hood
Open Source Swift Under the HoodOpen Source Swift Under the Hood
Open Source Swift Under the HoodC4Media
 
Code Clash Python vs Java — Which Language Wins.pdf
Code Clash Python vs Java — Which Language Wins.pdfCode Clash Python vs Java — Which Language Wins.pdf
Code Clash Python vs Java — Which Language Wins.pdfSudhanshiBakre1
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingAkhil Kaushik
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1Kanchilug
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinalProf. Wim Van Criekinge
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3aminmesbahi
 
Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?GetInData
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
Machine learning from software developers point of view
Machine learning from software developers point of viewMachine learning from software developers point of view
Machine learning from software developers point of viewPierre Paci
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Wei Sun
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet IntroductionWei Sun
 
Building cloud-enabled genomics workflows with Luigi and Docker
Building cloud-enabled genomics workflows with Luigi and DockerBuilding cloud-enabled genomics workflows with Luigi and Docker
Building cloud-enabled genomics workflows with Luigi and DockerJacob Feala
 
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoTInria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoTStéphanie Roger
 
Python_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfPython_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfVisionAcademyProfSac
 

Similar to OpenSAF Symposium_Python Bindings_9.21.11 (20)

Python-Yesterday Today Tomorrow(What's new?)
Python-Yesterday Today Tomorrow(What's new?)Python-Yesterday Today Tomorrow(What's new?)
Python-Yesterday Today Tomorrow(What's new?)
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
 
Open Source Swift Under the Hood
Open Source Swift Under the HoodOpen Source Swift Under the Hood
Open Source Swift Under the Hood
 
Code Clash Python vs Java — Which Language Wins.pdf
Code Clash Python vs Java — Which Language Wins.pdfCode Clash Python vs Java — Which Language Wins.pdf
Code Clash Python vs Java — Which Language Wins.pdf
 
Python PPT 50.pptx
Python PPT 50.pptxPython PPT 50.pptx
Python PPT 50.pptx
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
 
Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
PyData Boston 2013
PyData Boston 2013PyData Boston 2013
PyData Boston 2013
 
Machine learning from software developers point of view
Machine learning from software developers point of viewMachine learning from software developers point of view
Machine learning from software developers point of view
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02
 
Mannu_Kumar_CV
Mannu_Kumar_CVMannu_Kumar_CV
Mannu_Kumar_CV
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
 
Building cloud-enabled genomics workflows with Luigi and Docker
Building cloud-enabled genomics workflows with Luigi and DockerBuilding cloud-enabled genomics workflows with Luigi and Docker
Building cloud-enabled genomics workflows with Luigi and Docker
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoTInria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
 
Python_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfPython_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdf
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

OpenSAF Symposium_Python Bindings_9.21.11

  • 1. Python Bindings for SA Forum AIS APIs Hans Feldt Ericsson Currie Reid Linux Product Division Wind River
  • 2. Outline of Presentation • Objectives • What is Python? • Mapping Python to Objectives • How Python bindings are implemented • (Demonstration) • Future Works
  • 3. Objectives • Enable testing in all phases of the software lifecycle. • Simplify development across different architectures. • Simplify presentation to developers and engineers. • Quickly create tools that make it easy to investigate and monitor the system. • Make it easy to create and modify prototypes.
  • 4. What is Python? • General purpose, high-level, interpreted language. • Design philosophy emphasizes code readability. • Designed to be extensible • Large, comprehensive standard library. • Supports object-oriented, imperative, and (lesser degree) functional programming paradigms. • Dynamic type system, automatic memory management. • Free, open-source, many 3rd party packages.
  • 5. Popularity and Usage • Twice awarded as “Programming language of the Year” by TIOBE (2007 & 2010) • Ranked number 8 in the TIOBE popularity index • Used as a scripting language for web applications (Django, Pylons, …) • Used as an embedded scripting language in other programs (GIMP, GDB, ..) • OpenSAF related: Mercurial, Buildbot, Trac, Yum • Standard component in Linux distributions
  • 6. Enable testing in all phases of software lifecycle • Test coverage more complete if easy to write tests; test-driven development encouraged! • Tests are portable across architectures. • Built-in modules for testing include unittest and doctest. • Modules available for unit testing, mock testing, fuzz testing, web testing, gui testing, etc. • i.e.: nose, py.test, zope.testing.
  • 7. Simplify development across different architectures • Python scripts are portable across different architectures. • Edit-compile-run cycle is greatly reduced. • Python code can be edited/patched on the target system if required. • Huge collection of native and 3rd-party bindings available to aid/speed development.
  • 8. Simplify presentation to developers and engineers • Python syntax reads like pseudo-code. • Most Python programs much smaller than lower- level implementations. • Easier to examine the problem domain when you abstract-away programming details and challenges associated with the machine. • Do more with less
  • 9. Make it easy to create and modify prototypes • Components and applications can be rapidly prototyped in Python. • Designs can then be hardened in another implementation language. • Ideal glue language. • Working code can be developed much faster than lower-level languages. • Identify “hot spots” in application and possibly optimize by extending with C/C++
  • 10. Ctypes module: Wrap Libraries in Python • Advanced FFI (Foreign Function Interface) for Python 2.3 and higher. • Included in Python 2.5 • Provides C compatible data types • Call functions in shared libraries (DLLs). • Create, access and manipulate simple and complicated C data types in Python. • Enables C callbacks to be implemented in Python.
  • 11. Python Bindings Implementation • Conversion of SAF types to ctypes • Definition of Const • Definition of Enumeration • Definition of Struct • Definition of Union • Dynamic Loading of Libraries and CDLL • Definition of Functions • Definition of callbacks and CFUNCTYPE
  • 12. Conversion of SAF types to ctypes SaInt8T = c_char SaInt16T = c_short SaInt32T = c_int SaInt64T = c_longlong SaUint8T = c_ubyte SaUint16T = c_ushort SaUint32T = c_uint SaUint64T = c_ulonglong ... myuint = SaUint64T(12)
  • 13. Definition of Const saAis = Const() saAis.SA_TIME_END = 0x7FFFFFFFFFFFFFFF saAis.SA_TIME_BEGIN = 0x0 saAis.SA_TIME_UNKNOWN = 0x8000000000000000 time_start = saAis.SA_TIME_BEGIN saAis.SA_TIME_BEGIN = 5 #ERROR: EXCEPTION
  • 14. Definition of Enumeration SaDispatchFlagsT = SaEnumT eSaDispatchFlagsT = Enumeration(( ('SA_DISPATCH_ONE', 1), ('SA_DISPATCH_ALL', 2), ('SA_DISPATCH_BLOCKING', 3), )) flag = eSaDispatchFlagsT.SA_DISPATCH_ALL flag_str = eSaDispatchFlagsT.whatis(flag)
  • 15. Definition of Structs class SaNameT(Structure): _fields_ = [('length', SaUint16T), ('value',(SaInt8T*saAis.SA_MAX_NAME_LENGTH))] def __init__(self, name=''): super(SaNameT, self).__init__(len(name), name) dn = SaNameT(‘safApp=OpenSAF’)
  • 16. Definition of Unions class SaLimitValueT(Union): _fields_ = [('int64Value', SaInt64T), ('uint64Value', SaUint64T), ('timeValue', SaTimeT), ('floatValue', SaFloatT), ('doubleValue', SaDoubleT)] un = SaLimitValueT() un.timeValue = 5000000000
  • 17. Dynamic Loading of Libraries using CDLL amfdll = CDLL('libSaAmf.so.0') Functions in the library accessible as attributes of the amfdll object.
  • 18. Definition of Functions def saAmfInitialize(amfHandle, amfCallbacks, version): return amfdll.saAmfInitialize( BYREF(amfHandle), BYREF(amfCallbacks), BYREF(version))
  • 19. Example usage amfHandle = SaAmfHandleT() amfCallbacks = None version = SaVersionT(‘B’, 1, 1) rc = saAmfInitialize(amfHandle, amfCallbacks, version)
  • 20. Definition of callbacks and CFUNCTYPE SaAmfCSISetCallbackT = CFUNCTYPE(None, SaInvocationT, POINTER(SaNameT), SaAmfHAStateT, SaAmfCSIDescriptorT) def myCSISetCallback(invoc, comp, hastate, descr): … callbacks = SaAmfCallbacksT() callbacks.saAmfCSISetCallbackT( SaAmfCSISetCallbackT(myCSISetCallback))
  • 21. Bindings in 4.2 • A 1:1 mapping primarily aimed for OpenSAF services testing • Samples using the bindings
  • 22. Future Work • Pythonic interfaces (inspired by Java bindings?) • OpenSAF test framework using Python bindings • Simple GUI for management • Bindings for IMM A.02.11 – OpenSAF extensions • Complete SMF bindings
  • 23. Example of Pythonic Interface def foo(parent, values, mods, dn1, dn2): owner = SaImmOmOwner(‘Hans’) owner.set(parent) ccb = SaImmOmCcb(owner) ccb.objectCreate(‘TestClass’, parent, values) ccb.objectModify(dn1, mods) ccb.objectDelete(dn2) ccb.apply()