Jump to: navigation, search

Difference between revisions of "Rally/HowToExtendRally"

(Description: Link added)
m (Add Server providers)
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=Available Deploy Engines=
+
=Extend Rally functionality=
  
==DummyEngine==
 
  
===Description===
+
==Add Deploy engines==
This engine does not deploy anything, but uses an existing OpenStack deployment. It may be useful in case you have a preconfigured OpenStack deployment ready for benchmark scenarios launching.
+
Implementing your own deploy engines allows you to employ custom OpenStack platforms. Before starting to implement your own deploy engine, take a look at  [[Rally/DeployEngines|the already available deploy engines]].
===Configuration Example===
+
 
    {
+
To implement a custom deploy engine, you need to create a subclass of ''rally.deploy.engine.EngineFactory'' and implement the ''__init__()'', ''deploy()'' and ''cleanup()'' methods:
         "name": "DummyEngine",
+
 
        "cloud_config": {
+
    from rally.deploy import engine
             ''(specify here the cloud endpoints)''
+
    from rally.serverprovider import provider
             "identity": {
+
    class MyEngine(engine.EngineFactory):
                "url": "http://192.168.122.22/",
+
        def __init__(self, task, config):
                "uri": "http://192.168.122.22:5000/v2.0/",
+
            self.task = task
                "admin_username": "admin",
+
            self._config = config
                "admin_password": "password",
+
            self._vms = []
                "admin_tenant_name": "demo"
+
            provider_config = config['provider']
 +
            self._vm_provider = provider.ProviderFactory.get_provider(provider_config)
 +
            ''# Perform further initialization here''
 +
         def deploy(self):
 +
            self._vms = self._vm_provider.create_vms()
 +
            for vm in self._vms:
 +
                ''# Deploy OpenStack on each VM here''
 +
             ''# Return the endpoints''
 +
             return {
 +
                'identity': {
 +
                    'url': 'http://$IDENTITY_HOST/',
 +
                    'uri': 'http://$IDENTITY_HOST:5000/v2.0/',
 +
                    'admin_username': '$ADMIN',
 +
                    'admin_password': '$PASSWORD',
 +
                    'admin_tenant_name': '$TENANT',
 +
                }
 
             }
 
             }
         }
+
         def cleanup(self):
    }
+
            ''# Cleanup the deployment here, e.g.''
 +
            self._vm_provider.destroy_vms()
  
  
  
==DevstackEngine==
+
==Add Server providers==
 +
Implementing your own server providers allows you to use custom hardware/software configurations as well as virtualization strategies. Before starting to implement your own server provider, take a look at  [[Rally/ServerProviders|the already available server providers]].
  
===Description===
+
To implement a custom server provider, you need to create a subclass of ''rally.serverprovider.provider.ProviderFactory'' and implement 5 methods, namely ''__init__()'', ''upload_image()'', ''destroy_image()'', ''create_servers()'' and ''destroy_servers()'':
This engine deploys a DevStack cloud using the given devstack repository. As this deploy engine is not a dummy one, it also needs a concrete [[ServerProviders|Server Provider]] to be specified in the config.
+
 
 +
<pre>
 +
    from rally.serverprovider import provider
 +
      
 +
    class MyProvider(provider.ProviderFactory):
 +
 
 +
      def create_servers(self):
 +
            """Create VMs with chosen image.
 +
            :param image_uuid: Indetificator of image
 +
            :param type_id: VM type identificator
 +
            :param amount: amount of required VMs
 +
            :returns: list of provider.Server instances.
 +
            """
 +
            # Provide working servers with access via ssh
 +
 
 +
      def destroy_servers(self):
 +
            """Destroy already created VMs."""
 +
            # Destroy/Free allocated servers
 +
</pre>
  
===Configuration Example===
+
==Add Benchmark scenarios==
    {
+
Implementing your own benchmark scenarios allows you to benchmark your cloud against custom loading procedures. Before starting to implement your own benchmark scenarios, take a look at  [[Rally/BenchmarkScenarios|the already available benchmark scenarios]].
        "name": "DevstackEngine",
 
        "localrc": {
 
            "ADMIN_PASSWORD": "secret",
 
            ...
 
        },
 
        "devstack_repo": "git://example.com/devstack/",
 
        "provider": {
 
            "name": "''%PROVIDER_NAME''",
 
          ...
 
        }
 
    }
 
  
=Note=
+
To implement a custom benchmark scenario(s), you need to create a subclass of ''rally.benchmark.base.Scenario'' and implement each of the desired benchmarks in a separate method. The benchmark methods may be arbitrary named, but should be decorated by ''@classmethod'' (so they all take ''cls'' as their first parameter) and also take the ''context'' dictionary as the second parameter. In addition to the benchmark methods, overriding the ''class_init()'', ''init()'' and ''cleanup()'' methods allows you to implement your own benchmark setup and cleanup strategies. ''init()'' differs from ''class_init()'' in that it should return a context dictionary (possibly with some objects predefined) which can then be used in the benchmark methods:
Stay tuned.
+
   
 +
    from rally.benchmark import base
 +
    class MyScenario(base.Scenario):
 +
        @classmethod
 +
        def init(cls, config):
 +
            context = {}
 +
            ''# Prepare the environment for benchmarking''
 +
            return context
 +
        @classmethod
 +
        def cleanup(cls, context):
 +
            ''# Perform cleanup''
 +
        @classmethod
 +
        def my_scenario_1(cls, context, my_arg):
 +
            ''# Launch the benchmarking procedure''
 +
        @classmethod
 +
        def my_scenario_2(cls, context, my_arg):
 +
            ''# Launch the benchmarking procedure''

Latest revision as of 12:58, 14 January 2014

Extend Rally functionality

Add Deploy engines

Implementing your own deploy engines allows you to employ custom OpenStack platforms. Before starting to implement your own deploy engine, take a look at the already available deploy engines.

To implement a custom deploy engine, you need to create a subclass of rally.deploy.engine.EngineFactory and implement the __init__(), deploy() and cleanup() methods:

   from rally.deploy import engine
   from rally.serverprovider import provider
   class MyEngine(engine.EngineFactory):
       def __init__(self, task, config):
           self.task = task
           self._config = config
           self._vms = []
           provider_config = config['provider']
           self._vm_provider = provider.ProviderFactory.get_provider(provider_config)
           # Perform further initialization here
       def deploy(self):
           self._vms = self._vm_provider.create_vms()
           for vm in self._vms:
               # Deploy OpenStack on each VM here
           # Return the endpoints
           return {
               'identity': {
                   'url': 'http://$IDENTITY_HOST/',
                   'uri': 'http://$IDENTITY_HOST:5000/v2.0/',
                   'admin_username': '$ADMIN',
                   'admin_password': '$PASSWORD',
                   'admin_tenant_name': '$TENANT',
               }
           }
       def cleanup(self):
           # Cleanup the deployment here, e.g.
           self._vm_provider.destroy_vms()


Add Server providers

Implementing your own server providers allows you to use custom hardware/software configurations as well as virtualization strategies. Before starting to implement your own server provider, take a look at the already available server providers.

To implement a custom server provider, you need to create a subclass of rally.serverprovider.provider.ProviderFactory and implement 5 methods, namely __init__(), upload_image(), destroy_image(), create_servers() and destroy_servers():

    from rally.serverprovider import provider
      
    class MyProvider(provider.ProviderFactory):
 
       def create_servers(self):
            """Create VMs with chosen image.
            :param image_uuid: Indetificator of image
            :param type_id: VM type identificator
            :param amount: amount of required VMs
            :returns: list of provider.Server instances.
            """
            # Provide working servers with access via ssh
  
       def destroy_servers(self):
            """Destroy already created VMs."""
            # Destroy/Free allocated servers

Add Benchmark scenarios

Implementing your own benchmark scenarios allows you to benchmark your cloud against custom loading procedures. Before starting to implement your own benchmark scenarios, take a look at the already available benchmark scenarios.

To implement a custom benchmark scenario(s), you need to create a subclass of rally.benchmark.base.Scenario and implement each of the desired benchmarks in a separate method. The benchmark methods may be arbitrary named, but should be decorated by @classmethod (so they all take cls as their first parameter) and also take the context dictionary as the second parameter. In addition to the benchmark methods, overriding the class_init(), init() and cleanup() methods allows you to implement your own benchmark setup and cleanup strategies. init() differs from class_init() in that it should return a context dictionary (possibly with some objects predefined) which can then be used in the benchmark methods:

   from rally.benchmark import base
   class MyScenario(base.Scenario):
       @classmethod
       def init(cls, config):
           context = {}
           # Prepare the environment for benchmarking
           return context
       @classmethod
       def cleanup(cls, context):
           # Perform cleanup
       @classmethod
       def my_scenario_1(cls, context, my_arg):
           # Launch the benchmarking procedure
       @classmethod
       def my_scenario_2(cls, context, my_arg):
           # Launch the benchmarking procedure