Moving rally/doc/samples to rally/samples
Moving samples to root forlder for easy access. Change-Id: I050c8d7580282b898be77156f65cdbce75a4dbb4 Closes-Bug: 1409836
This commit is contained in:
parent
b3ea58bc55
commit
9f6838be8d
@ -1,24 +0,0 @@
|
|||||||
from rally.benchmark.scenarios import base
|
|
||||||
|
|
||||||
|
|
||||||
class ScenarioPlugin(base.Scenario):
|
|
||||||
"""Sample plugin which lists flavors."""
|
|
||||||
|
|
||||||
@base.atomic_action_timer("list_flavors")
|
|
||||||
def _list_flavors(self):
|
|
||||||
"""Sample of usage clients - list flavors
|
|
||||||
|
|
||||||
You can use self.context, self.admin_clients and self.clients which are
|
|
||||||
initialized on scenario instanse creation"""
|
|
||||||
self.clients("nova").flavors.list()
|
|
||||||
|
|
||||||
@base.atomic_action_timer("list_flavors_as_admin")
|
|
||||||
def _list_flavors_as_admin(self):
|
|
||||||
"""The same with admin clients"""
|
|
||||||
self.admin_clients("nova").flavors.list()
|
|
||||||
|
|
||||||
@base.scenario()
|
|
||||||
def list_flavors(self):
|
|
||||||
"""List flavors."""
|
|
||||||
self._list_flavors()
|
|
||||||
self._list_flavors_as_admin()
|
|
@ -1,3 +1,17 @@
|
|||||||
|
# Copyright 2013: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
from rally.benchmark.context import base
|
from rally.benchmark.context import base
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
@ -9,9 +23,10 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
@base.context(name="create_flavor", order=1000)
|
@base.context(name="create_flavor", order=1000)
|
||||||
class CreateFlavorContext(base.Context):
|
class CreateFlavorContext(base.Context):
|
||||||
"""This sample create flavor with specified options before task starts and
|
"""Create sample flavor
|
||||||
delete it after task completion.
|
|
||||||
|
|
||||||
|
This sample create flavor with specified options before task starts and
|
||||||
|
delete it after task completion.
|
||||||
To create your own context plugin, inherit it from
|
To create your own context plugin, inherit it from
|
||||||
rally.benchmark.context.base.Context
|
rally.benchmark.context.base.Context
|
||||||
"""
|
"""
|
||||||
@ -40,7 +55,7 @@ class CreateFlavorContext(base.Context):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""This method is called before task start"""
|
"""This method is called before task start."""
|
||||||
try:
|
try:
|
||||||
# use rally.osclients to get nessesary client instance
|
# use rally.osclients to get nessesary client instance
|
||||||
nova = osclients.Clients(self.context["admin"]["endpoint"]).nova()
|
nova = osclients.Clients(self.context["admin"]["endpoint"]).nova()
|
||||||
@ -60,7 +75,7 @@ class CreateFlavorContext(base.Context):
|
|||||||
LOG.warning(msg)
|
LOG.warning(msg)
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""This method is called after task finish"""
|
"""This method is called after task finish."""
|
||||||
try:
|
try:
|
||||||
nova = osclients.Clients(self.context["admin"]["endpoint"]).nova()
|
nova = osclients.Clients(self.context["admin"]["endpoint"]).nova()
|
||||||
nova.flavors.delete(self.context["flavor"]["id"])
|
nova.flavors.delete(self.context["flavor"]["id"])
|
@ -1,3 +1,18 @@
|
|||||||
|
# Copyright 2013: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from rally.benchmark.runners import base
|
from rally.benchmark.runners import base
|
40
samples/plugins/scenario/scenario_plugin.py
Normal file
40
samples/plugins/scenario/scenario_plugin.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Copyright 2013: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from rally.benchmark.scenarios import base
|
||||||
|
|
||||||
|
|
||||||
|
class ScenarioPlugin(base.Scenario):
|
||||||
|
"""Sample plugin which lists flavors."""
|
||||||
|
|
||||||
|
@base.atomic_action_timer("list_flavors")
|
||||||
|
def _list_flavors(self):
|
||||||
|
"""Sample of usage clients - list flavors
|
||||||
|
|
||||||
|
You can use self.context, self.admin_clients and self.clients which are
|
||||||
|
initialized on scenario instanse creation.
|
||||||
|
"""
|
||||||
|
self.clients("nova").flavors.list()
|
||||||
|
|
||||||
|
@base.atomic_action_timer("list_flavors_as_admin")
|
||||||
|
def _list_flavors_as_admin(self):
|
||||||
|
"""The same with admin clients."""
|
||||||
|
self.admin_clients("nova").flavors.list()
|
||||||
|
|
||||||
|
@base.scenario()
|
||||||
|
def list_flavors(self):
|
||||||
|
"""List flavors."""
|
||||||
|
self._list_flavors()
|
||||||
|
self._list_flavors_as_admin()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user