How to use the rally.task.validation function in rally

To help you get started, we’ve selected a few rally examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / rally-openstack / rally_openstack / scenarios / octavia / loadbalancers.py View on Github external
#    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.task import validation

from rally_openstack import consts
from rally_openstack import scenario
from rally_openstack.scenarios.octavia import utils as octavia_utils

"""Scenarios for Octavia Loadbalancer."""


@validation.add("required_services", services=[consts.Service.OCTAVIA])
@validation.add("required_platform", platform="openstack", users=True)
@validation.add("required_contexts", contexts=["network"])
@scenario.configure(context={"cleanup@openstack": ["octavia"]},
                    name="Octavia.create_and_list_loadbalancers",
                    platform="openstack")
class CreateAndListLoadbalancers(octavia_utils.OctaviaBase):

    def run(self, description=None, admin_state=True,
            listeners=None, flavor_id=None, provider=None,
            vip_qos_policy_id=None):
        """Create a loadbalancer per each subnet and then list loadbalancers.

        :param description: Human-readable description of the loadbalancer
        :param admin_state: The administrative state of the loadbalancer,
            which is up(true) or down(false)
        :param listeners: The associated listener id, if any
        :param flavor_id: The ID of the flavor
        :param provider: Provider name for the loadbalancer
github openstack / rally / rally / plugins / openstack / scenarios / nova / keypairs.py View on Github external
#    License for the specific language governing permissions and limitations
#    under the License.

from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils
from rally.task import types
from rally.task import validation


"""Scenarios for Nova keypairs."""


@validation.add("required_services", services=[consts.Service.NOVA])
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup@openstack": ["nova"]},
                    name="NovaKeypair.create_and_list_keypairs",
                    platform="openstack")
class CreateAndListKeypairs(utils.NovaScenario):

    def run(self, **kwargs):
        """Create a keypair with random name and list keypairs.

        This scenario creates a keypair and then lists all keypairs.

        :param kwargs: Optional additional arguments for keypair creation
        """

        keypair_name = self._create_keypair(**kwargs)
        self.assertTrue(keypair_name, "Keypair isn't created")
github openstack / rally / rally / plugins / openstack / scenarios / nova / hosts.py View on Github external
@scenario.configure(name="NovaHosts.list_hosts")
class ListHosts(utils.NovaScenario):

    def run(self, zone=None):
        """List all nova hosts.

        Measure the "nova host-list" command performance.

        :param zone: List nova hosts in an availability-zone.
                     None (default value) means list hosts in all
                     availability-zones
        """
        self._list_hosts(zone)


@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure(name="NovaHosts.list_and_get_hosts")
class ListAndGetHosts(utils.NovaScenario):

    def run(self, zone=None):
        """List all nova hosts,and get detailed information fot this hosts.

        Measure the "nova host-describe" command performance.

        :param zone: List nova hosts in an availability-zone.
                     None (default value) means list hosts in all
                     availability-zones
        """
        hosts = self._list_hosts(zone)
        with atomic.ActionTimer(self, "nova.get_%s_hosts" % len(hosts)):
            for host in hosts:
github openstack / rally-openstack / rally_openstack / scenarios / nova / hypervisors.py View on Github external
#    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.task import validation

from rally_openstack import consts
from rally_openstack import scenario
from rally_openstack.scenarios.nova import utils


"""Scenarios for Nova hypervisors."""


@validation.add("required_services", services=[consts.Service.NOVA])
@validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(name="NovaHypervisors.list_hypervisors",
                    platform="openstack")
class ListHypervisors(utils.NovaScenario):

    def run(self, detailed=True):
        """List hypervisors.

        Measure the "nova hypervisor-list" command performance.

        :param detailed: True if the hypervisor listing should contain
                         detailed information about all of them
        """
        self._list_hypervisors(detailed)
github openstack / rally-openstack / rally_openstack / scenarios / gnocchi / status.py View on Github external
#    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.task import validation

from rally_openstack import consts
from rally_openstack import scenario
from rally_openstack.scenarios.gnocchi import utils as gnocchiutils


"""Scenarios for Gnocchi status."""


@validation.add("required_services",
                services=[consts.Service.GNOCCHI])
@validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(name="Gnocchi.get_status")
class GetStatus(gnocchiutils.GnocchiBase):

    def run(self, detailed=False):
        """Get the status of measurements processing.

        :param detailed: get detailed output
        """
        self.admin_gnocchi.get_status(detailed)
github cloud-bulldozer / browbeat / rally / rally-plugins / netcreate-boot / netcreate_nova_boot_fip_ping.py View on Github external
#   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_openstack import consts
from rally_openstack.scenarios.neutron import utils as neutron_utils
from rally_openstack.scenarios.vm import utils as vm_utils
from rally.task import atomic
from rally.task import scenario
from rally.task import types
from rally.task import validation


@types.convert(image={"type": "glance_image"}, flavor={"type": "nova_flavor"})
@validation.add("image_valid_on_flavor", flavor_param="flavor", image_param="image")
@validation.add("required_services", services=[consts.Service.NEUTRON, consts.Service.NOVA])
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup@openstack": ["neutron", "nova"], "keypair@openstack": {},
                             "allow_ssh@openstack": None},
                    name="BrowbeatPlugin.create_network_nova_boot_ping", platform="openstack")
class CreateNetworkNovaBootPing(vm_utils.VMScenario,
                                neutron_utils.NeutronScenario):

    def run(self, image, flavor, ext_net_id, num_vms=1, router_create_args=None,
            network_create_args=None, subnet_create_args=None, **kwargs):
        ext_net_name = None
        if ext_net_id:
            ext_net_name = self.clients("neutron").show_network(
                ext_net_id)["network"]["name"]
        router_create_args["name"] = self.generate_random_name()
        router_create_args["tenant_id"] = self.context["tenant"]["id"]
        router_create_args.setdefault("external_gateway_info",
github openstack / rally / rally / plugins / openstack / scenarios / heat / stacks.py View on Github external
files value will be used instead
        :param environment: stack environment definition
        :param updated_environment: environment definition for updated stack
        """

        stack = self._create_stack(template_path, parameters,
                                   files, environment)
        self._update_stack(stack, updated_template_path,
                           updated_parameters or parameters,
                           updated_files or files,
                           updated_environment or environment)
        self._delete_stack(stack)


@types.convert(template_path={"type": "file"}, files={"type": "file_dict"})
@validation.add("required_services", services=[consts.Service.HEAT])
@validation.add("validate_heat_template", params="template_path")
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup@openstack": ["heat"]},
                    name="HeatStacks.create_stack_and_scale",
                    platform="openstack")
class CreateStackAndScale(utils.HeatScenario):

    def run(self, template_path, output_key, delta,
            parameters=None, files=None,
            environment=None):
        """Create an autoscaling stack and invoke a scaling policy.

        Measure the performance of autoscaling webhooks.

        :param template_path: path to template file that includes an
                              OS::Heat::AutoScalingGroup resource
github openstack / rally-openstack / rally_openstack / scenarios / ceilometer / queries.py View on Github external
import json

from rally.task import validation

from rally_openstack import consts
from rally_openstack import scenario
from rally_openstack.scenarios.ceilometer import utils as ceiloutils


"""Scenarios for Ceilometer Queries API."""


@validation.add("required_services",
                services=[consts.Service.CEILOMETER])
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup@openstack": ["ceilometer"]},
                    name="CeilometerQueries.create_and_query_alarms",
                    platform="openstack")
class CeilometerQueriesCreateAndQueryAlarms(ceiloutils.CeilometerScenario):

    def run(self, meter_name, threshold, filter=None, orderby=None,
            limit=None, **kwargs):
        """Create an alarm and then query it with specific parameters.

        This scenario tests POST /v2/query/alarms
        An alarm is first created and then fetched using the input query.

        :param meter_name: specifies meter name of alarm
        :param threshold: specifies alarm threshold
        :param filter: optional filter query dictionary
        :param orderby: optional param for specifying ordering of results
github cloud-bulldozer / browbeat / rally / rally-plugins / workloads / pbench-uperf.py View on Github external
import six

from rally.common import sshutils
from rally_openstack import consts
from rally_openstack.scenarios.vm import utils as vm_utils
from rally_openstack.scenarios.neutron import utils as neutron_utils
from rally.task import scenario
from rally.task import types
from rally.task import validation


LOG = logging.getLogger(__name__)


@types.convert(image={"type": "glance_image"}, flavor={"type": "nova_flavor"})
@validation.add("image_valid_on_flavor", flavor_param="flavor", image_param="image")
@validation.add("required_services", services=[consts.Service.NEUTRON, consts.Service.NOVA])
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup@openstack": ["cinder", "neutron", "nova"],
                             "keypair@openstack": {}, "allow_ssh@openstack": None},
                    name="BrowbeatPlugin.pbench_uperf", platform="openstack")
class BrowbeatPbenchUperf(neutron_utils.NeutronScenario,
                          vm_utils.VMScenario):

    def build_jump_host(self, external, image, flavor, user, password=None, **kwargs):
        keyname = self.context["user"]["keypair"]["name"]
        jump_host, jump_host_ip = self._boot_server_with_fip(image,
                                                             flavor,
                                                             use_floating_ip=True,
                                                             floating_network=external[
                                                                 'name'],
                                                             key_name=keyname,
github openstack / rally / rally / plugins / openstack / scenarios / quotas / quotas.py View on Github external
name="Quotas.nova_update_and_delete", platform="openstack")
class NovaUpdateAndDelete(utils.QuotasScenario):

    def run(self, max_quota=1024):
        """Update and delete quotas for Nova.

        :param max_quota: Max value to be updated for quota.
        """

        self._update_quotas("nova", self.context["tenant"]["id"],
                            max_quota)
        self._delete_quotas("nova", self.context["tenant"]["id"])


@validation.add("required_services", services=[consts.Service.CINDER])
@validation.add("required_platform", platform="openstack",
                admin=True, users=True)
@scenario.configure(context={"admin_cleanup@openstack": ["cinder.quotas"]},
                    name="Quotas.cinder_update", platform="openstack")
class CinderUpdate(utils.QuotasScenario):

    def run(self, max_quota=1024):
        """Update quotas for Cinder.

        :param max_quota: Max value to be updated for quota.
        """

        self._update_quotas("cinder", self.context["tenant"]["id"],
                            max_quota)


@validation.add("required_services", services=[consts.Service.CINDER])