From ead2bfc713322102a8a9f1ea6efc7d80ba610d8c Mon Sep 17 00:00:00 2001 From: Amy Ge Date: Tue, 20 Jun 2017 16:12:20 -0700 Subject: [PATCH] Improve plugin sample and corresponding 'creating a plugin' tutorial The scenario_plugin.py was updated, however, the documentation still has the old instruction for creating a plugin. Let's update that in- struction. Let's also add 'required_services' and 'required_platform' in the sample to make it more complete. Change-Id: I6d36ea51a3ee32b94ab296c77195ee22652f40ec --- .../plugins/implementation/scenario_plugin.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/source/plugins/implementation/scenario_plugin.rst b/doc/source/plugins/implementation/scenario_plugin.rst index e7cb17a8..f4a7c657 100644 --- a/doc/source/plugins/implementation/scenario_plugin.rst +++ b/doc/source/plugins/implementation/scenario_plugin.rst @@ -24,18 +24,23 @@ Let's create a simple scenario plugin that list flavors. Creation ^^^^^^^^ -Inherit a class for your plugin from the base *Scenario* class and +Inherit a class for your plugin from the base *OpenStackScenario* class and implement a scenario method inside it. In our scenario, we'll first list flavors as an ordinary user, and then repeat the same using admin clients: .. code-block:: python + from rally import consts + from rally.plugins.openstack import scenario from rally.task import atomic - from rally.task import scenario + from rally.task import validation - class ScenarioPlugin(scenario.Scenario): + @validation.add("required_services", services=[consts.Service.NOVA]) + @validation.add("required_platform", platform="openstack", users=True) + @scenario.configure(name="ScenarioPlugin.list_flavors_useless") + class ListFlavors(scenario.OpenStackScenario): """Sample plugin which lists flavors.""" @atomic.action_timer("list_flavors") @@ -51,8 +56,7 @@ clients: """The same with admin clients""" self.admin_clients("nova").flavors.list() - @scenario.configure() - def list_flavors(self): + def run(self): """List flavors.""" self._list_flavors() self._list_flavors_as_admin()