Skip to content

Commit

Permalink
Merge "Add cidr prefix parameter in dynamic workloads"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Jun 22, 2022
2 parents ac2edfd + 7e45cad commit 38a589e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions browbeat-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ workloads:
shift_on_stack_workload: poddensity
shift_on_stack_kubeconfig_paths:
- /home/stack/.kube/config
# External networks with /23 ranges will be created by dynamic workloads.
# All these external networks will share the first 16 bits.
cidr_prefix: "172.31"
# num_external_networks are the number of the external networks to be
# created as part of rally context for dynamic workloads. These external
# networks will be used in a round robin fashion by the iterations.
Expand Down
2 changes: 2 additions & 0 deletions rally/rally-plugins/dynamic-workloads/dynamic_workload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
{% set shift_on_stack_burst = shift_on_stack_burst or 20 %}
{% set shift_on_stack_workload = shift_on_stack_workload or 'poddensity' %}
{% set shift_on_stack_kubeconfig_paths = shift_on_stack_kubeconfig_paths or ['/home/stack/.kube/config'] %}
{% set cidr_prefix = cidr_prefix or '172.31' %}
{% set num_external_networks = num_external_networks or 16 %}
{% set router_external = router_external or True %}
{% set sla_max_avg_duration = sla_max_avg_duration or 60 %}
Expand Down Expand Up @@ -114,6 +115,7 @@ BrowbeatPlugin.dynamic_workload:
num_external_networks: {{ num_external_networks }}
interface_name: '{{ iface_name }}'
provider_phys_net: '{{ provider_phys_net }}'
cidr_prefix: '{{ cidr_prefix }}'
sla:
max_avg_duration: {{sla_max_avg_duration}}
max_seconds_per_iteration: {{sla_max_seconds}}
Expand Down
17 changes: 11 additions & 6 deletions rally/rally-plugins/dynamic-workloads/rally_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class CreateExternalNetworksContext(context.Context):
"$schema": consts.JSON_SCHEMA,
"additionalProperties": False,
"properties": {
"cidr_prefix": {
"type": "string",
},
"num_external_networks": {
"type": "integer",
"minimum": 0
Expand Down Expand Up @@ -58,11 +61,12 @@ def _create_subnet(self, tenant_id, network_id, network_number):
"network_id": network_id,
"name": self.net_wrapper.owner.generate_random_name(),
"ip_version": 4,
"cidr": "172.31.{}.0/23".format(network_number),
"cidr": "{}.{}.0/23".format(self.cidr_prefix, network_number),
"enable_dhcp": False,
"gateway_ip": "172.31.{}.1".format(network_number),
"allocation_pools": [{"start": "172.31.{}.2".format(network_number),
"end": "172.31.{}.254".format(network_number+1)}]
"gateway_ip": "{}.{}.1".format(self.cidr_prefix, network_number),
"allocation_pools": [{"start": "{}.{}.2".format(self.cidr_prefix, network_number),
"end": "{}.{}.254".format(
self.cidr_prefix, network_number+1)}]
}
}
return self.net_wrapper.client.create_subnet(subnet_args)["subnet"]
Expand All @@ -78,6 +82,7 @@ def setup(self):
self.context["external_subnets"] = {}
self.num_external_networks = self.config.get("num_external_networks", 16)
self.interface_name = self.config.get("interface_name", "ens7f1")
self.cidr_prefix = self.config.get("cidr_prefix", "172.31")

num_external_networks_created = 0

Expand Down Expand Up @@ -114,8 +119,8 @@ def setup(self):
has_error_occured = True
break

cmd = ["sudo", "ip", "a", "a", "172.31.{}.1/23".format(
num_external_networks_created*2), "dev",
cmd = ["sudo", "ip", "a", "a", "{}.{}.1/23".format(
self.cidr_prefix, num_external_networks_created*2), "dev",
"{}.{}".format(self.interface_name, num_external_networks_created + 1)]
proc = subprocess.Popen(cmd)
proc.wait()
Expand Down

0 comments on commit 38a589e

Please sign in to comment.