Patchwork [bitbake-devel,0/1] Webhob: helper based on webservice

login
register
mail settings
Submitter Xiaotong lv
Date June 7, 2012, 1:51 a.m.
Message ID <cover.1339033548.git.xiaotongx.lv@intel.com>
Download mbox
Permalink /patch/29255/
State New
Headers show

Pull-request

git://git.yoctoproject.org/poky-contrib xtlv/webhob-webservice

Comments

Xiaotong lv - June 7, 2012, 1:51 a.m.
This helper is a bitbake ui, based on soaplib 1.0 lib to implement a webservice interface.
Using 'bitbake -u webhob_webserivce ip:port' to startup this help.
I defined 2 webservice methods, they are runCommand(param) and getEvent().
Different languages can remotely call the 2 methods to communicate with bitbake. such as php, java, js, python and so on.
1. runCommand(param) method is responsible for sending commands to bitbake server.
   the param format is:
    {
        'function'  : string            (required, function name)
        'param_type': array(string)     (optional, params types, values only are 'string', 'list' or 'bool')
        'params'    : array(string)     (optional, string param corresponds to itself,
                                                   list type corresponds to 'str1 str2 str3 ....',
                                                   bool type corresponds to  'true' or 'false'
                                         )
    }

    some examples:
    1). to call bitbake server.runCommand(["initCooker"])
        param style is:
        {
           'function': 'initCokker'
        }
    2). to call bitbake server.runCommand(["getVariable", "BBLAYERS"])
        param style is:
        {
          'function'   : 'getVariable'
          'param_type' : ['string']
          'params'     : ['BBLASYERS']
        }
    3). to call bitbake server.runCommand(["buildTargets", list(recipe_queue), 'build'])
        param style is:
        {
          'function'   : 'buildTargets'
          'param_type' : ['list','string']
          'params'     : ['recipe1 recipe2 recipe2 recipe4 ....', 'build']
        }

2. getEvent() is respinsible for getting the event results generated by bitbake event objects, it returns a standard json format data.
   some examples:
   1)  to get some async configurations:
      [{'event': 'ConfigFilesFound',
       'values': 'poky-bleeding poky-lsb poky poky-tiny defaultsetup',
       'variable': 'distro'},
       {'event': 'CommandCompleted'}
      ]
      [{'event': 'ConfigFilesFound',
        'values': 'atom-pc routerstationpro mpc8315e-rdb beagleboard qemumips qemuarm qemux86-64 qemux86 qemuppc',
        'variable': 'machine'},
       {'event': 'CommandCompleted'}
        'values': 'i586 x86_64 i686',
        'variable': 'machine-sdk'},
       {'event': 'CommandCompleted'}
      ]
      [{'event': 'FilesMatchingFound',
        'matches': 'rootfs_rpm.bbclass rootfs_deb.bbclass rootfs_ipk.bbclass',
        'pattern': 'rootfs_'},
       {'event': 'CommandCompleted'}
      ]

    2) some recipe progress values
         [{'current': 24,
          'event': 'TreeDataPreparationProgress',
          'msg': 'Preparing tree data: 24/1105',
          'total': 1105},
         {'current': 25,
          'event': 'TreeDataPreparationProgress',
          'msg': 'Preparing tree data: 25/1105',
          'total': 1105},
         {'current': 26,
          'event': 'TreeDataPreparationProgress',
          'msg': 'Preparing tree data: 26/1105',
          'total': 1105},
         {'current': 27,
          'event': 'TreeDataPreparationProgress',
          'msg': 'Preparing tree data: 27/1105',
          'total': 1105},
         {'current': 28,
          'event': 'TreeDataPreparationProgress',
          'msg': 'Preparing tree data: 28/1105',
          'total': 1105},
         {'current': 29,
          'event': 'TreeDataPreparationProgress',
          'msg': 'Preparing tree data: 29/1105',
          'total': 1105}]

    3) some task building values
         [{'event': 'TaskSucceeded',
          'message': 'package libpcre-native-8.21-r1: task do_populate_sysroot: Succeeded',
          'package': 'libpcre-native-8.21-r1',
          'pid': 30382,
          'task': 'do_populate_sysroot'},
         {'event': 'runQueueTaskCompleted',
          'pid': 0,
          'taskid': 753,
          'taskstring': 'virtual:native:/home/xiaotong/workspace/python/poky-contrib/meta/recipes-support/libpcre/libpcre_8.21.bb, do_populate_sysroot'},
         {'event': 'runQueueTaskStarted',
          'noexec': False,
          'pid': 0,
          'stats': {'active': 0, 'completed': 324, 'failed': 0},
          'taskid': 709,
          'taskstring': 'virtual:native:/home/xiaotong/workspace/python/poky-contrib/meta/recipes-support/db/db_5.1.19.bb, do_populate_sysroot'},
         {'event': 'TaskStarted',
          'message': 'package db-native-5.1.19-r4: task do_populate_sysroot: Started',
          'package': 'db-native-5.1.19-r4',
          'pid': 30447,

The following changes since commit 3bf8069100e54153d13319dc32ca089327b6a139:

  documentation/yocto-project-qs/yocto-project-qs.xml: added quotes (2012-05-01 21:00:36 +0100)

are available in the git repository at:
  git://git.yoctoproject.org/poky-contrib xtlv/webhob-webservice
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=xtlv/webhob-webservice

Xiaotong lv (1):
  Webhob: a general helper interface based on webservice

 bitbake/lib/bb/ui/crumbs/webserviceeventhandler.py |  190 ++++++++++++++++++++
 bitbake/lib/bb/ui/webhob_webservice.py             |  141 +++++++++++++++
 2 files changed, 331 insertions(+), 0 deletions(-)
 create mode 100644 bitbake/lib/bb/ui/crumbs/webserviceeventhandler.py
 create mode 100755 bitbake/lib/bb/ui/webhob_webservice.py
Shane Wang - June 13, 2012, 5:56 a.m.
Is there any feedback for this piece of helper code?

--
Shane

Xiaotong lv wrote onĀ 2012-06-07:

> This helper is a bitbake ui, based on soaplib 1.0 lib to implement a
> webservice interface. Using 'bitbake -u webhob_webserivce ip:port' to
> startup this help. I defined 2 webservice methods, they are
> runCommand(param) and getEvent(). Different languages can remotely call
> the 2 methods to communicate with bitbake. such as php, java, js, python
> and so on. 1. runCommand(param) method is responsible for sending
> commands to bitbake server.
>    the param format is:
>     {
>         'function'  : string            (required, function name)
>         'param_type': array(string)     (optional, params types, values
>         only are 'string', 'list' or 'bool') 'params'    : array(string)
>             (optional, string param
> corresponds to itself,
>                                                    list type corresponds
>                                                    to 'str1 str2 str3
>                                                    ....', bool type
> corresponds to  'true' or 'false'
>                                          )
>     }
>     
>     some examples:
>     1). to call bitbake server.runCommand(["initCooker"])
>         param style is:
>         {
>            'function': 'initCokker'
>         } 2). to call bitbake server.runCommand(["getVariable",
>         "BBLAYERS"]) param style is: {
>           'function'   : 'getVariable'
>           'param_type' : ['string']
>           'params'     : ['BBLASYERS']
>         }
>     3). to call bitbake server.runCommand(["buildTargets",
> list(recipe_queue), 'build'])
>         param style is:
>         {
>           'function'   : 'buildTargets'
>           'param_type' : ['list','string']
>           'params'     : ['recipe1 recipe2 recipe2 recipe4 ....', 'build']
>         }
> 2. getEvent() is respinsible for getting the event results generated by bitbake
> event objects, it returns a standard json format data.
>    some examples:
>    1)  to get some async configurations:
>       [{'event': 'ConfigFilesFound',
>        'values': 'poky-bleeding poky-lsb poky poky-tiny defaultsetup',
>        'variable': 'distro'},
>        {'event': 'CommandCompleted'}
>       ]
>       [{'event': 'ConfigFilesFound',
>         'values': 'atom-pc routerstationpro mpc8315e-rdb beagleboard
>         qemumips qemuarm qemux86-64 qemux86 qemuppc', 'variable':
>         'machine'}, {'event': 'CommandCompleted'} 'values': 'i586 x86_64
>         i686', 'variable': 'machine-sdk'},
>        {'event': 'CommandCompleted'}
>       ]
>       [{'event': 'FilesMatchingFound',
>         'matches': 'rootfs_rpm.bbclass rootfs_deb.bbclass
>         rootfs_ipk.bbclass', 'pattern': 'rootfs_'},
>        {'event': 'CommandCompleted'}
>       ]
>     2) some recipe progress values
>          [{'current': 24,
>           'event': 'TreeDataPreparationProgress', 'msg': 'Preparing tree
>           data: 24/1105', 'total': 1105}, {'current': 25, 'event':
>           'TreeDataPreparationProgress', 'msg': 'Preparing tree data:
>           25/1105', 'total': 1105}, {'current': 26, 'event':
>           'TreeDataPreparationProgress', 'msg': 'Preparing tree data:
>           26/1105', 'total': 1105}, {'current': 27, 'event':
>           'TreeDataPreparationProgress', 'msg': 'Preparing tree data:
>           27/1105', 'total': 1105}, {'current': 28, 'event':
>           'TreeDataPreparationProgress', 'msg': 'Preparing tree data:
>           28/1105', 'total': 1105}, {'current': 29, 'event':
>           'TreeDataPreparationProgress', 'msg': 'Preparing tree data:
>           29/1105', 'total': 1105}]
>     3) some task building values
>          [{'event': 'TaskSucceeded',
>           'message': 'package libpcre-native-8.21-r1: task
>           do_populate_sysroot: Succeeded', 'package':
>           'libpcre-native-8.21-r1', 'pid': 30382, 'task':
>           'do_populate_sysroot'}, {'event': 'runQueueTaskCompleted',
>           'pid': 0, 'taskid': 753, 'taskstring':
> 'virtual:native:/home/xiaotong/workspace/python/poky-contrib/meta/recipes
> -support/libpcre/libpcre_8.21.bb, do_populate_sysroot'},
>          {'event': 'runQueueTaskStarted',
>           'noexec': False,
>           'pid': 0,
>           'stats': {'active': 0, 'completed': 324, 'failed': 0},
>           'taskid': 709,
>           'taskstring':
> 'virtual:native:/home/xiaotong/workspace/python/poky-contrib/meta/recipes
> -support/db/db_5.1.19.bb, do_populate_sysroot'},
>          {'event': 'TaskStarted',
>           'message': 'package db-native-5.1.19-r4: task
>           do_populate_sysroot: Started', 'package':
>           'db-native-5.1.19-r4', 'pid': 30447,
> The following changes since commit
> 3bf8069100e54153d13319dc32ca089327b6a139:
> 
>   documentation/yocto-project-qs/yocto-project-qs.xml: added quotes
> (2012-05-01 21:00:36 +0100)
> 
> are available in the git repository at:
>   git://git.yoctoproject.org/poky-contrib xtlv/webhob-webservice
> http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=xtlv/webhob-webs
> erv ice
> 
> Xiaotong lv (1):
>   Webhob: a general helper interface based on webservice
>  bitbake/lib/bb/ui/crumbs/webserviceeventhandler.py |  190
>  ++++++++++++++++++++ bitbake/lib/bb/ui/webhob_webservice.py            
>  |  141 +++++++++++++++ 2 files changed, 331 insertions(+), 0
>  deletions(-) create mode 100644
>  bitbake/lib/bb/ui/crumbs/webserviceeventhandler.py create mode 100755
>  bitbake/lib/bb/ui/webhob_webservice.py