Pass custom args to create_port through create_server

Allow consumers of create_server to pass custom arguments to
create_port method which is called from create_server one.

Fix namestart var usage in create_port - as the name of the var
suggests, it should be used to generate a name from. Therefore
the patch also adds rand_name call which we accidentaly removed
recently.

Implements: blueprint tempest-scenario-manager-stable
Change-Id: I724e0f37d4381a493217a077492046f7a4b0a2a2
This commit is contained in:
Martin Kopec 2020-12-17 20:43:26 +00:00
parent 0e0264636f
commit 9c87441724
1 changed files with 16 additions and 3 deletions

View File

@ -143,10 +143,20 @@ class ScenarioTest(tempest.test.BaseTestCase):
# resp part which is not used in scenario tests
def create_port(self, network_id, client=None, **kwargs):
"""Creates port for the respective network_id"""
"""Creates port for the respective network_id
:param network_id: the id of the network
:param client: the client to use, defaults to self.ports_client
:param kwargs: additional arguments such as:
- namestart - a string to generate a name for the port from
- default is self.__class__.__name__
- 'binding:vnic_type' - defaults to CONF.network.port_vnic_type
- 'binding:profile' - defaults to CONF.network.port_profile
"""
if not client:
client = self.ports_client
name = kwargs.pop('namestart', self.__class__.__name__)
name = data_utils.rand_name(
kwargs.pop('namestart', self.__class__.__name__))
if CONF.network.port_vnic_type and 'binding:vnic_type' not in kwargs:
kwargs['binding:vnic_type'] = CONF.network.port_vnic_type
if CONF.network.port_profile and 'binding:profile' not in kwargs:
@ -216,6 +226,9 @@ class ScenarioTest(tempest.test.BaseTestCase):
the port.
example: port_profile = "capabilities:[switchdev]"
Defaults to ``CONF.network.port_profile``.
* *create_port_body* (``dict``) --
This attribute is a dictionary of additional arguments to be
passed to create_port method.
"""
# NOTE(jlanoux): As a first step, ssh checks in the scenario
@ -241,7 +254,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
# every network
if vnic_type or profile:
ports = []
create_port_body = {}
create_port_body = kwargs.pop('create_port_body', {})
if vnic_type:
create_port_body['binding:vnic_type'] = vnic_type