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
This commit is contained in:
maxinjian 2017-04-13 09:33:29 -04:00
parent 7aaad2f963
commit 83f89dd34e
5 changed files with 12 additions and 20 deletions

View File

@ -569,7 +569,6 @@ class CreateAndListSnapshots(cinder_utils.CinderBasic,
@validation.restricted_parameters(["name", "display_name"]) @validation.restricted_parameters(["name", "display_name"])
@validation.required_services(consts.Service.CINDER, consts.Service.GLANCE) @validation.required_services(consts.Service.CINDER, consts.Service.GLANCE)
@validation.add("required_platform", platform="openstack", users=True) @validation.add("required_platform", platform="openstack", users=True)
@validation.required_parameters("size")
@scenario.configure(context={"cleanup": ["cinder", "glance"]}, @scenario.configure(context={"cleanup": ["cinder", "glance"]},
name="CinderVolumes.create_and_upload_volume_to_image") name="CinderVolumes.create_and_upload_volume_to_image")
class CreateAndUploadVolumeToImage(cinder_utils.CinderBasic, class CreateAndUploadVolumeToImage(cinder_utils.CinderBasic,

View File

@ -51,7 +51,6 @@ class ListExecutions(utils.MistralScenario):
sort_keys=sort_keys, sort_dirs=sort_dirs) sort_keys=sort_keys, sort_dirs=sort_dirs)
@validation.required_parameters("definition")
@validation.file_exists("definition") @validation.file_exists("definition")
@types.convert(definition={"type": "file"}) @types.convert(definition={"type": "file"})
@types.convert(params={"type": "file"}) @types.convert(params={"type": "file"})

View File

@ -38,7 +38,6 @@ class ListWorkbooks(utils.MistralScenario):
self._list_workbooks() self._list_workbooks()
@validation.required_parameters("definition")
@validation.file_exists("definition") @validation.file_exists("definition")
@types.convert(definition={"type": "file"}) @types.convert(definition={"type": "file"})
@validation.required_clients("mistral") @validation.required_clients("mistral")

View File

@ -25,7 +25,6 @@ from rally.task import validation
"""Scenarios for Murano packages.""" """Scenarios for Murano packages."""
@validation.required_parameters("package")
@validation.file_exists(param_name="package", mode=os.F_OK) @validation.file_exists(param_name="package", mode=os.F_OK)
@validation.required_clients("murano") @validation.required_clients("murano")
@validation.required_services(consts.Service.MURANO) @validation.required_services(consts.Service.MURANO)
@ -57,7 +56,6 @@ class ImportAndListPackages(utils.MuranoScenario):
os.remove(package_path) os.remove(package_path)
@validation.required_parameters("package")
@validation.file_exists(param_name="package", mode=os.F_OK) @validation.file_exists(param_name="package", mode=os.F_OK)
@validation.required_clients("murano") @validation.required_clients("murano")
@validation.required_services(consts.Service.MURANO) @validation.required_services(consts.Service.MURANO)
@ -86,7 +84,6 @@ class ImportAndDeletePackage(utils.MuranoScenario):
os.remove(package_path) os.remove(package_path)
@validation.required_parameters("package", "body")
@validation.file_exists(param_name="package", mode=os.F_OK) @validation.file_exists(param_name="package", mode=os.F_OK)
@validation.required_clients("murano") @validation.required_clients("murano")
@validation.required_services(consts.Service.MURANO) @validation.required_services(consts.Service.MURANO)
@ -124,7 +121,6 @@ class PackageLifecycle(utils.MuranoScenario):
os.remove(package_path) os.remove(package_path)
@validation.required_parameters("package", "filter_query")
@validation.file_exists(param_name="package", mode=os.F_OK) @validation.file_exists(param_name="package", mode=os.F_OK)
@validation.required_clients("murano") @validation.required_clients("murano")
@validation.required_services(consts.Service.MURANO) @validation.required_services(consts.Service.MURANO)

View File

@ -105,7 +105,7 @@ class CreateAndDeleteNetworks(utils.NeutronScenario):
class CreateAndListSubnets(utils.NeutronScenario): class CreateAndListSubnets(utils.NeutronScenario):
def run(self, network_create_args=None, subnet_create_args=None, 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. """Create and a given number of subnets and list all subnets.
The scenario creates a network, a given number of subnets and then 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, def run(self, subnet_update_args, network_create_args=None,
subnet_create_args=None, subnet_cidr_start=None, subnet_create_args=None, subnet_cidr_start=None,
subnets_per_network=None): subnets_per_network=1):
"""Create and update a subnet. """Create and update a subnet.
The scenario creates a network, a given number of subnets 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) 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) @validation.required_services(consts.Service.NEUTRON)
@scenario.configure(context={"cleanup": ["neutron"]}, @scenario.configure(context={"cleanup": ["neutron"]},
name="NeutronNetworks.create_and_delete_subnets") name="NeutronNetworks.create_and_delete_subnets")
class CreateAndDeleteSubnets(utils.NeutronScenario): class CreateAndDeleteSubnets(utils.NeutronScenario):
def run(self, network_create_args=None, subnet_create_args=None, 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. """Create and delete a given number of subnets.
The scenario creates a network, a given number of subnets and then The scenario creates a network, a given number of subnets and then
@ -221,7 +221,7 @@ class CreateAndDeleteSubnets(utils.NeutronScenario):
class CreateAndListRouters(utils.NeutronScenario): class CreateAndListRouters(utils.NeutronScenario):
def run(self, network_create_args=None, subnet_create_args=None, 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): router_create_args=None):
"""Create and a given number of routers and list all routers. """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.number("subnets_per_network", minval=1, integer_only=True)
@validation.required_parameters("subnets_per_network")
@validation.required_services(consts.Service.NEUTRON) @validation.required_services(consts.Service.NEUTRON)
@scenario.configure(context={"cleanup": ["neutron"]}, @scenario.configure(context={"cleanup": ["neutron"]},
name="NeutronNetworks.create_and_update_routers") name="NeutronNetworks.create_and_update_routers")
@ -250,7 +249,7 @@ class CreateAndUpdateRouters(utils.NeutronScenario):
def run(self, router_update_args, network_create_args=None, def run(self, router_update_args, network_create_args=None,
subnet_create_args=None, subnet_cidr_start=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 and update a given number of routers.
Create a network, a given number of subnets and 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) 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) @validation.required_services(consts.Service.NEUTRON)
@scenario.configure(context={"cleanup": ["neutron"]}, @scenario.configure(context={"cleanup": ["neutron"]},
name="NeutronNetworks.create_and_delete_routers") name="NeutronNetworks.create_and_delete_routers")
class CreateAndDeleteRouters(utils.NeutronScenario): class CreateAndDeleteRouters(utils.NeutronScenario):
def run(self, network_create_args=None, subnet_create_args=None, 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): router_create_args=None):
"""Create and delete a given number of routers. """Create and delete a given number of routers.
@ -339,7 +338,7 @@ class SetAndClearRouterGateway(utils.NeutronScenario):
class CreateAndListPorts(utils.NeutronScenario): class CreateAndListPorts(utils.NeutronScenario):
def run(self, network_create_args=None, 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. """Create and a given number of ports and list all ports.
:param network_create_args: dict, POST /v2.0/networks request :param network_create_args: dict, POST /v2.0/networks request
@ -362,7 +361,7 @@ class CreateAndListPorts(utils.NeutronScenario):
class CreateAndUpdatePorts(utils.NeutronScenario): class CreateAndUpdatePorts(utils.NeutronScenario):
def run(self, port_update_args, network_create_args=None, 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. """Create and update a given number of ports.
Measure the "neutron port-create" and "neutron port-update" commands Measure the "neutron port-create" and "neutron port-update" commands
@ -416,14 +415,14 @@ class CreateAndShowPorts(utils.NeutronScenario):
err_msg=msg) 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) @validation.required_services(consts.Service.NEUTRON)
@scenario.configure(context={"cleanup": ["neutron"]}, @scenario.configure(context={"cleanup": ["neutron"]},
name="NeutronNetworks.create_and_delete_ports") name="NeutronNetworks.create_and_delete_ports")
class CreateAndDeletePorts(utils.NeutronScenario): class CreateAndDeletePorts(utils.NeutronScenario):
def run(self, network_create_args=None, 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. """Create and delete a port.
Measure the "neutron port-create" and "neutron port-delete" Measure the "neutron port-create" and "neutron port-delete"