Difference between revisions of "Rally/HowToExtendRally"
m (→Add Deploy engines) |
m (→Add Server providers) |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
==Add Deploy engines== | ==Add Deploy engines== | ||
− | Implementing your own deploy engines allows you to employ custom OpenStack platforms. | + | 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]]. |
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: | 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: | ||
Line 34: | Line 34: | ||
''# Cleanup the deployment here, e.g.'' | ''# Cleanup the deployment here, e.g.'' | ||
self._vm_provider.destroy_vms() | self._vm_provider.destroy_vms() | ||
+ | |||
+ | |||
==Add Server providers== | ==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]]. | |
+ | 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()'': | ||
+ | |||
+ | <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> | ||
==Add Benchmark scenarios== | ==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]]. | |
+ | |||
+ | 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'' |
Latest revision as of 12:58, 14 January 2014
Contents
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