autotest/virt-test — pull request #748 by yangdongsheng (2013-08-20 07:20:24+00:00)
Title: virttest.staging.service: Introduce a class named ServiceManagerFactory.

Introduce a class named ServiceManagerFactory to create kinds of service manager.
* Class ServiceManagerFactory provides two staticmethod to create generate service manager
and to create specific service manager.
* Internal class named FactoryHelper to provide some help method for ServiceManagerFactory.

Relationship of the classes in service module.

service
|
-------------------------------------
| |
_GenericServiceManager _SpecificServiceManager
|
-----------------------------
| |
_SystemdServiceManager _SystemdServiceManager

* ServiceManagerFactory provides two interfaces to create service.
* create_specific_service_manager() to create _SpecificServiceManager.
* create_generic_service_manager() to create _GenericServiceManager.
* FactoryHelper provides a method get_service_manager_type() to
auto detect the system type and return constructor of
_SystemdServiceManager or _SystemdServiceManager.
So, user do not have to know about the system type when they use
create_generic_service_manager() to create _GenericServiceManager.

Outline of ServiceManagerFactory class:
ServiceManagerFactory
|
---------------------------------------------------------------------------------------
| | |
create_specific_service_manager() create_generic_service_manager() FactoryHelper
| | |
| | ----------------------------------------------
| | | | |
| | |----------------------| |---------------------| get_name_of_init()
| | |*get_specific_service_| |*get_generic_service_|
| |------------>|command_generator() | |command_generator() |
| |*get_specific_service_| |*get_generic_service_|
| |result_parser() | |result_parser() |
| |----------------------| |*get_generic_service_|
|------------------------------------------------------------------------------>|manager_type() |
-----------------------

Signed-off-by: yangdongsheng