Selective resource creation in dynamic workloads

This patch introduces the following changes.
1. The router created at the beginning of every iteration in
dynamic workloads is used only by VM and trunk dynamic
workloads. This patch changes the code to make sure that the
router is created only when VM and trunk dynamic workloads are
enabled.
2. The code has been modified to support passing num_external_networks: '0'
in browbeat-config.yaml.
3. This patch will fix https://bugs.launchpad.net/openstack-browbeat/+bug/1955722.

Change-Id: Idcca472a4d95d10b0fb80017b49d18787ef5c2bf
This commit is contained in:
Sanjay Chari 2021-12-29 11:36:37 +05:30
parent 993700480f
commit 3602f0dc4a
2 changed files with 24 additions and 17 deletions

View File

@ -61,10 +61,13 @@ class DynamicWorkload(vm.VMDynamicScenario, trunk.TrunkDynamicScenario,
router_create_args=None, network_create_args=None,
subnet_create_args=None, **kwargs):
context_ext_net_id = self.context["external_networks"][((self.context["iteration"]-1)
% num_external_networks)]["id"]
self.log_info("Using external network {} from context for iteration {}".format(
context_ext_net_id, self.context["iteration"]))
if num_external_networks > 0:
context_ext_net_id = self.context["external_networks"][((self.context["iteration"]-1)
% num_external_networks)]["id"]
self.log_info("Using external network {} from context for iteration {}".format(
context_ext_net_id, self.context["iteration"]))
self.ext_net_name = self.clients("neutron").show_network(context_ext_net_id)["network"][
"name"]
workloads_list = workloads.split(",")
self.trunk_vm_user = "centos"
@ -76,21 +79,25 @@ class DynamicWorkload(vm.VMDynamicScenario, trunk.TrunkDynamicScenario,
self.security_group = self.create_sec_group_with_icmp_ssh()
self.log_info("security group {} created for this iteration".format(self.security_group))
# Let this router be used by resources created by VM dynamic workloads in this iteration,
# if the iteration is not divisible by 5.
router_create_args["name"] = self.generate_random_name()
router_create_args["tenant_id"] = self.context["tenant"]["id"]
router_create_args.setdefault(
"external_gateway_info", {"network_id": context_ext_net_id, "enable_snat": True}
)
self.router = self._create_router(router_create_args)
self.log_info("router {} created for this iteration".format(self.router))
if(workloads == "all" or "migrate_servers" in workloads_list or
"swap_floating_ips_between_servers" in workloads_list or
"stop_start_servers" in workloads_list or
"pod_fip_simulation" in workloads_list or
"add_subports_to_random_trunks" in workloads_list or
"delete_subports_from_random_trunks" in workloads_list or
"swap_floating_ips_between_random_subports" in workloads_list):
# Let this router be used by resources created by VM and trunk dynamic workloads
# in this iteration.
router_create_args["name"] = self.generate_random_name()
router_create_args["tenant_id"] = self.context["tenant"]["id"]
router_create_args.setdefault(
"external_gateway_info", {"network_id": context_ext_net_id, "enable_snat": True}
)
self.router = self._create_router(router_create_args)
self.log_info("router {} created for this iteration".format(self.router))
self.keypair = self.context["user"]["keypair"]
self.ext_net_name = self.clients("neutron").show_network(context_ext_net_id)["network"][
"name"]
try:
self.browbeat_dir = DynamicWorkload.browbeat_dir
except AttributeError:

View File

@ -33,7 +33,7 @@ class CreateExternalNetworksContext(context.Context):
"properties": {
"num_external_networks": {
"type": "integer",
"minimum": 1
"minimum": 0
},
"interface_name": {
"type": "string"