From 83f89dd34ec981be5fbc643422182ceb00594737 Mon Sep 17 00:00:00 2001 From: maxinjian Date: Thu, 13 Apr 2017 09:33:29 -0400 Subject: [PATCH] Extend required_paramaters validator Extend required_paramaters validator to be able to search sub-dict of "config". Subdict is something like "create_image_args" to be passed to required_paramaters function. Change-Id: I62df108842a1680cbe79bf52d151d96af3a9b790 --- .../openstack/scenarios/cinder/volumes.py | 1 - .../openstack/scenarios/mistral/executions.py | 1 - .../openstack/scenarios/mistral/workbooks.py | 1 - .../openstack/scenarios/murano/packages.py | 4 --- .../openstack/scenarios/neutron/network.py | 25 +++++++++---------- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/rally/plugins/openstack/scenarios/cinder/volumes.py b/rally/plugins/openstack/scenarios/cinder/volumes.py index dccb6833..ab6d211c 100644 --- a/rally/plugins/openstack/scenarios/cinder/volumes.py +++ b/rally/plugins/openstack/scenarios/cinder/volumes.py @@ -569,7 +569,6 @@ class CreateAndListSnapshots(cinder_utils.CinderBasic, @validation.restricted_parameters(["name", "display_name"]) @validation.required_services(consts.Service.CINDER, consts.Service.GLANCE) @validation.add("required_platform", platform="openstack", users=True) -@validation.required_parameters("size") @scenario.configure(context={"cleanup": ["cinder", "glance"]}, name="CinderVolumes.create_and_upload_volume_to_image") class CreateAndUploadVolumeToImage(cinder_utils.CinderBasic, diff --git a/rally/plugins/openstack/scenarios/mistral/executions.py b/rally/plugins/openstack/scenarios/mistral/executions.py index 65cf3298..ef7093dc 100644 --- a/rally/plugins/openstack/scenarios/mistral/executions.py +++ b/rally/plugins/openstack/scenarios/mistral/executions.py @@ -51,7 +51,6 @@ class ListExecutions(utils.MistralScenario): sort_keys=sort_keys, sort_dirs=sort_dirs) -@validation.required_parameters("definition") @validation.file_exists("definition") @types.convert(definition={"type": "file"}) @types.convert(params={"type": "file"}) diff --git a/rally/plugins/openstack/scenarios/mistral/workbooks.py b/rally/plugins/openstack/scenarios/mistral/workbooks.py index ce9c29c0..488aa08d 100644 --- a/rally/plugins/openstack/scenarios/mistral/workbooks.py +++ b/rally/plugins/openstack/scenarios/mistral/workbooks.py @@ -38,7 +38,6 @@ class ListWorkbooks(utils.MistralScenario): self._list_workbooks() -@validation.required_parameters("definition") @validation.file_exists("definition") @types.convert(definition={"type": "file"}) @validation.required_clients("mistral") diff --git a/rally/plugins/openstack/scenarios/murano/packages.py b/rally/plugins/openstack/scenarios/murano/packages.py index 38aa8978..69032efa 100644 --- a/rally/plugins/openstack/scenarios/murano/packages.py +++ b/rally/plugins/openstack/scenarios/murano/packages.py @@ -25,7 +25,6 @@ from rally.task import validation """Scenarios for Murano packages.""" -@validation.required_parameters("package") @validation.file_exists(param_name="package", mode=os.F_OK) @validation.required_clients("murano") @validation.required_services(consts.Service.MURANO) @@ -57,7 +56,6 @@ class ImportAndListPackages(utils.MuranoScenario): os.remove(package_path) -@validation.required_parameters("package") @validation.file_exists(param_name="package", mode=os.F_OK) @validation.required_clients("murano") @validation.required_services(consts.Service.MURANO) @@ -86,7 +84,6 @@ class ImportAndDeletePackage(utils.MuranoScenario): os.remove(package_path) -@validation.required_parameters("package", "body") @validation.file_exists(param_name="package", mode=os.F_OK) @validation.required_clients("murano") @validation.required_services(consts.Service.MURANO) @@ -124,7 +121,6 @@ class PackageLifecycle(utils.MuranoScenario): os.remove(package_path) -@validation.required_parameters("package", "filter_query") @validation.file_exists(param_name="package", mode=os.F_OK) @validation.required_clients("murano") @validation.required_services(consts.Service.MURANO) diff --git a/rally/plugins/openstack/scenarios/neutron/network.py b/rally/plugins/openstack/scenarios/neutron/network.py index 94363ff8..68f1c594 100644 --- a/rally/plugins/openstack/scenarios/neutron/network.py +++ b/rally/plugins/openstack/scenarios/neutron/network.py @@ -105,7 +105,7 @@ class CreateAndDeleteNetworks(utils.NeutronScenario): class CreateAndListSubnets(utils.NeutronScenario): def run(self, network_create_args=None, subnet_create_args=None, - subnet_cidr_start=None, subnets_per_network=None): + subnet_cidr_start=None, subnets_per_network=1): """Create and a given number of subnets and list all subnets. The scenario creates a network, a given number of subnets and then @@ -132,7 +132,7 @@ class CreateAndUpdateSubnets(utils.NeutronScenario): def run(self, subnet_update_args, network_create_args=None, subnet_create_args=None, subnet_cidr_start=None, - subnets_per_network=None): + subnets_per_network=1): """Create and update a subnet. The scenario creates a network, a given number of subnets @@ -186,14 +186,14 @@ class CreateAndShowSubnets(utils.NeutronScenario): self._show_subnet(subnet, atomic_action=False) -@validation.required_parameters("subnets_per_network") +@validation.number("subnets_per_network", minval=1, integer_only=True) @validation.required_services(consts.Service.NEUTRON) @scenario.configure(context={"cleanup": ["neutron"]}, name="NeutronNetworks.create_and_delete_subnets") class CreateAndDeleteSubnets(utils.NeutronScenario): def run(self, network_create_args=None, subnet_create_args=None, - subnet_cidr_start=None, subnets_per_network=None): + subnet_cidr_start=None, subnets_per_network=1): """Create and delete a given number of subnets. The scenario creates a network, a given number of subnets and then @@ -221,7 +221,7 @@ class CreateAndDeleteSubnets(utils.NeutronScenario): class CreateAndListRouters(utils.NeutronScenario): def run(self, network_create_args=None, subnet_create_args=None, - subnet_cidr_start=None, subnets_per_network=None, + subnet_cidr_start=None, subnets_per_network=1, router_create_args=None): """Create and a given number of routers and list all routers. @@ -242,7 +242,6 @@ class CreateAndListRouters(utils.NeutronScenario): @validation.number("subnets_per_network", minval=1, integer_only=True) -@validation.required_parameters("subnets_per_network") @validation.required_services(consts.Service.NEUTRON) @scenario.configure(context={"cleanup": ["neutron"]}, name="NeutronNetworks.create_and_update_routers") @@ -250,7 +249,7 @@ class CreateAndUpdateRouters(utils.NeutronScenario): def run(self, router_update_args, network_create_args=None, subnet_create_args=None, subnet_cidr_start=None, - subnets_per_network=None, router_create_args=None): + subnets_per_network=1, router_create_args=None): """Create and update a given number of routers. Create a network, a given number of subnets and routers @@ -272,14 +271,14 @@ class CreateAndUpdateRouters(utils.NeutronScenario): self._update_router(router, router_update_args) -@validation.required_parameters("subnets_per_network") +@validation.number("subnets_per_network", minval=1, integer_only=True) @validation.required_services(consts.Service.NEUTRON) @scenario.configure(context={"cleanup": ["neutron"]}, name="NeutronNetworks.create_and_delete_routers") class CreateAndDeleteRouters(utils.NeutronScenario): def run(self, network_create_args=None, subnet_create_args=None, - subnet_cidr_start=None, subnets_per_network=None, + subnet_cidr_start=None, subnets_per_network=1, router_create_args=None): """Create and delete a given number of routers. @@ -339,7 +338,7 @@ class SetAndClearRouterGateway(utils.NeutronScenario): class CreateAndListPorts(utils.NeutronScenario): def run(self, network_create_args=None, - port_create_args=None, ports_per_network=None): + port_create_args=None, ports_per_network=1): """Create and a given number of ports and list all ports. :param network_create_args: dict, POST /v2.0/networks request @@ -362,7 +361,7 @@ class CreateAndListPorts(utils.NeutronScenario): class CreateAndUpdatePorts(utils.NeutronScenario): def run(self, port_update_args, network_create_args=None, - port_create_args=None, ports_per_network=None): + port_create_args=None, ports_per_network=1): """Create and update a given number of ports. Measure the "neutron port-create" and "neutron port-update" commands @@ -416,14 +415,14 @@ class CreateAndShowPorts(utils.NeutronScenario): err_msg=msg) -@validation.required_parameters("ports_per_network") +@validation.number("ports_per_network", minval=1, integer_only=True) @validation.required_services(consts.Service.NEUTRON) @scenario.configure(context={"cleanup": ["neutron"]}, name="NeutronNetworks.create_and_delete_ports") class CreateAndDeletePorts(utils.NeutronScenario): def run(self, network_create_args=None, - port_create_args=None, ports_per_network=None): + port_create_args=None, ports_per_network=1): """Create and delete a port. Measure the "neutron port-create" and "neutron port-delete"