1 Developing WBEM Clients Using Python Tim Potter Hewlett-Packard Company

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

Web forms and CGI scripts Dr. Andrew C.R. Martin
More about Ruby Maciej Mensfeld Presented by: Maciej Mensfeld More about Ruby dev.mensfeld.pl github.com/mensfeld.
Introduction to WSDL presented by Xiang Fu. Source WSDL 1.1 specification WSDL 1.1 specification – WSDL 1.2 working draft WSDL.
RPC Robert Grimm New York University Remote Procedure Calls.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Snejina Lazarova Senior QA Engineer, Team Lead CRMTeam Dimo Mitev Senior QA Engineer, Team Lead SystemIntegrationTeam Telerik QA Academy SOAP-based Web.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Python Web Applications A KISS Introduction. Web Applications with Python Fetching, parsing, text processing Database client – mySQL, etc., for building.
PHP Scripting Language. Introduction “PHP” is an acronym for “PHP: Hypertext Preprocessor.” It is an interpreted, server-side scripting language. Originally.
The PHP Story. PHP Story PHP is a programming language. Incorporate(join) sophisticated business logic. Widely used general purpose scripting language.
UNIT-V The MVC architecture and Struts Framework.
Python for Oracle Geeks or, “Just a wafer-thin slice of Python” or, “Python as a Second Language (PSL)” Catherine Devlin IntelliTech Systems.
1 Spidering the Web in Python CSC 161: The Art of Programming Prof. Henry Kautz 11/23/2009.
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 24 – Web Servers (PWS, IIS, Apache, Jigsaw) Outline 24.1Introduction 24.2Microsoft Personal.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
NETWORK CENTRIC COMPUTING (With included EMBEDDED SYSTEMS)
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
JavaScript & jQuery the missing manual Chapter 11
Software Engineering 2003 Jyrki Nummenmaa 1 CASE Tools CASE = Computer-Aided Software Engineering A set of tools to (optimally) assist in each.
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Putting What We Learned Into Context – WSGI and Web Frameworks A290/A590, Fall /16/2014.
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Python CGI programming
1 Python CIS*2450 Advanced Programming Concepts Material for this lecture was developed by Dr. D. Calvert.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
1 Apache. 2 Module - Apache ♦ Overview This module focuses on configuring and customizing Apache web server. Apache is a commonly used Hypertext Transfer.
Web Server Administration Web Services XML SOAP. Overview What are web services and what do they do? What is XML? What is SOAP? How are they all connected?
Introduction to Applets CS 3505 Client Side Scripting with applets.
Ruby! Ronald L. Ramos. What is Ruby? Ruby is a scripting language designed by Yukihiro Matsumoto, also known as Matz. It runs on a variety of platforms,
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Dyalog’09. Overview of MildServer Morten Kromberg Dyalog’09 – Princeton, NJ.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
2/26/021 Pegasus Security Architecture Author: Nag Boranna Hewlett-Packard Company.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
The Software Development Process
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Google Application Engine Introduction Jim Eng with thanks to Charles Severance
Overview The Basics – Python classes and objects Procedural vs OO Programming Entity modelling Operations / methods Program flow OOP Concepts and user-defined.
CS105 Computer Programming PYTHON (based on CS 11 Python track: lecture 1, CALTECH)
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Comanche A GUI management tool for Apache Daniel López Ridruejo
Web Services using PHP. web services (recap) Web services today are frequently just Application Programming Interfaces (API) or web APIs that can be accessed.
Lemon Tutorial Sensor How-To Miroslav Siket, Dennis Waldron CERN-IT/FIO-FD.
Web Service Definition Language. Web Services: WSDL2 Web Service Definition Language ( WSDL ) What is a web service? [ F. Leymann 2003 ] A piece of code.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
PyWBEM Python WBEM Client: Overview Karl Schopmeyer Andreas Maier February 2016 SNIA SMI plugfest #2 Version:
Pyragen A PYTHON WRAPPER GENERATOR TO APPLICATION CORE LIBRARIES Fernando PEREIRA, Christian THEIS - HSE/RP EDMS tech note:
Presented By P.SRIVIDYA 085D1A0552 Programming Language.
© 2006 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Testing Providers with PyWBEM Tim.
© 2005 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice LCA2006 Systems Administration Miniconf:
Lesson 10: Dictionaries Topic: Introduction to Programming, Zybook Ch 9, P4E Ch 9. Slides on website.
PyWBEM Python WBEM CIM/XML client Rapid Overview
Perl Modules.
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
Automate Database Deployment with Python
PyWBEM Python WBEM Client: Overview #2
Presentation transcript:

1 Developing WBEM Clients Using Python Tim Potter Hewlett-Packard Company

2 Quotes “The best way to learn about something is to teach it.” - Unknown

3 Quotes (2) “The best way to learn about something is to write a program to do it.” - Me

4 About PyWBEM PyWBEM was written to answer the following questions: 1. What is this WBEM thing anyway? 2. How can I do useful things with it?

5 About PyWBEM (2) PyWBEM is a pure-Python CIM client Runs on Unix/Linux and WIN32 ~100 downloads since first release

6 About PyWBEM (2) PyWBEM != PiWBEM PiWBEM is another open-source client framework written in Python Written by Chris Hobbs from Nortel

7 About Python Python is a popular, open source, object- oriented scripting language Clear and elegant syntax Good free tutorial on Python at

8 PyWBEM Audience Developers Testers End-users “Hackers”

9 Installing PyWBEM For Unix, use standard Python module install process: $ python setup.py build # python setup.py install For WIN32, run the executable installer

10 Example code Lots of example code and applications available at the PyWBEM home page

11 Connections Call WBEMConnection() function to make a connection import pywbem conn = pywbem.WBEMConnection( ' ('username', 'password'))

12 Instance API Enumeration methods on connection object return a list of CIM objects result = conn.EnumerateInstances( 'CIM_OperatingSystem') result = conn.EnumerateInstanceNames( 'CIM_OperatingSystem')

13 Instance API (2) All other instance provider methods available –conn.GetInstance(...) –conn.DeleteInstance(...) –conn.ModifyInstance(...) –conn.CreateInstance(...)

14 Instance API (3) Parameter passing done using Python keyword arguments conn.EnumerateInstanceNames( 'CIM_Foo', LocalNamespacePath = 'root/PG_InterOp')

15 Object Model Usability extremely important PyWBEM uses built-in Python data types whenever possible Most common use cases should only involve CIMInstanceName and CIMInstance objects

16 Object Model (2) CIMInstanceName object Access property names through dictionary interface >>> print obj['CreationClassName'] 'PG_OperatingSystem'

17 Object Model (3) CIMInstance object Same idea as instance name, except for assigning integer property values obj['Status'] = pywbem.Uint16(2)

18 Object Model (4) All objects have a __str__ method >>> print str(obj) >>> PG_OperatingSystem.CreationClassName=”CIM_ OperatingSystem”,Name=”Red Hat Enterprise Linux AS”,CSCreationClassName=”CIM_UnitaryComput erSystem”,CSName=”deckchair”

19 Errors and Exceptions CIM errors are translated into Python exceptions try: conn.DeleteInstance(...) except pywbem.CIMError, arg: print 'CIM error %d: %s' % (arg[0], arg[1])

20 Method API InvokeMethod() function returns a tuple of return value, and output parameters result, output_params = conn.InvokeMethod ('Foo', object, param = value,...)

21 Associations API Slightly trickier due to complexity of CIM association API Return a list of class names associated with the CIM_ComputerSystem class names = conn.AssociatorNames( 'CIM_ComputerSystem')

22 Associations API (2) Return a list of instance names associated with a CIM_ComputerSystem instance cs = conn.EnumerateInstanceNames( 'CIM_ComputerSystem')[0] names = conn.AssociatorNames(cs)

23 Associations API (3) All association provider methods available –conn.AssociatorNames(...) –conn.ReferenceNames(...) –conn.Associators(...) –conn.References(...)

24 Class API Enumerations return lists of class names and class objects result = conn.EnumerateClassNames() result = conn.EnumerateClasses()

25 Class API (2) Other class functions available but not well supported in version 0.4 –conn.GetClass(...) –conn.DeleteClass(...) –conn.CreateClass(...) –conn.ModifyClass(...)

26 Qualifiers API Not well supported in PyWBEM 0.4

27 Indications API Nothing implemented yet in PyWBEM 0.4 Useful tasks would be –Framework for receipt of indications –Subscription management –Parsing of received indications

28 XML Generation WBEM requests requires generation of small bits of XML PyWBEM has a library to generate all XML elements in CIM DTD API is simple mapping of DTD structure to Python

29 XML Generation (2) from pywbem import * mc = METHODCALL('Foo', CLASSNAME('CIM_Foo'))

30 XML Generation (3) CIM( MESSAGE( SIMPLEREQ(mc), 1001, '1.0'), '2.0', '2.0') <CIM CIMVERSION=”2.0” DTDVERSION=”2.0”>...

31 XML Parsing WBEM replies require parsing of large bits of XML PyWBEM has library to parse all XML elements in CIM DTD API is simple mapping of DTD structure to Python

32 TODO More simplification of APIs Indications, classes and qualifiers work More documentation

33 Demo Application #1 Instance consistency checker Checks instances of a class against class definition instance-checker.py

34 Demo Application #1 (2) #!/usr/bin/python import pywbem # Make connection conn = pywbem.WBEMConnection( ' % server, (username, password))

35 Demo Application #1 (3) # Get class definition and # instances klass = conn.GetClass(classname) instances = conn.EnumerateInstances(classname) for i in instances: # Check instances against definition

36 Demo Application #1 (4) # Check for extra properties extra = set(klass.properties.keys()) - set(i.properties.keys()) if len(extra) > 0: print 'Extra properties in %s instance: %s' % (classname, extra)

37 Demo Application #1 (5) # Check for missing properties missing = set(i.properties.keys()) - set(klass.properties.keys()) if len(missing) > 0: print 'Missing properties in %s instance: %s' % (classname, missing)

38 Demo Application #1 (6) # Check property types against # definition for prop, value in i.properties.items(): if value.type != klass.properties[prop].type: print 'Property %s has bad type' % klass.properties[key].name

39 Demo Application #2 Web-based schema browser Simple CGI script to browse class definitions schema-browser.py

40 Demo Application #2 (2) #!/usr/bin/python import cgi, pywbem print 'Content-Type: text/html\n' print ' ' print ' CIM Browser ' print ' '

41 Demo Application #2 (3) form = cgi.FormContentDict() if not form.has_key('classname'): classnames = conn.EnumerateClassNames(DeepInherit ance = True) classnames.sort() print ' Classes '

42 Demo Application #2 (4) print ' ' [print_html_link(cl) for cl in classname] print '

43 Demo Application #2 (5) if form.has_key('classname'): print ' %s ' % classname try: cl = conn.GetClass(classname, LocalOnly = False) except pywbem.CIMError, arg: print arg[1] sys.exit(1)

44 Demo Application #2 (6) # Display qualifiers [print_qualifier(q.name, q.value) for q in cl.qualifiers.values()] # Display properties [print_property(key, value.qualifiers['Description'].value) for key, value in cl.properties.items()]

45 Demo Application #3 A simple CIMOM leveraging the Twisted Python framework for HTTP transport Unfinished with no provider support mini-cimom.py

46 Questions? Presentation and examples available at: