- if self.traffic_profile["cpus"] % len(self.traffic_profile["urls"]):
- logger.error("The number of CPUs must be a multiplication of the "
- "number of URLs.")
- self.traffic_profile = None
+ if self.traffic_profile[u"cpus"] % len(self.traffic_profile[u"urls"]):
+ logger.error(
+ u"The number of CPUs must be a multiple of the number of URLs."
+ )
+ return False
+ return True
+
+ def _validate_int_param(self, param, minimum):
+ """Validate that an int parameter is set acceptably
+ If it is not an int already but a string, convert and store it as int.
+
+ :param param: Name of a traffic profile parameter
+ :param minimum: The minimum value for the named parameter
+ :type param: str
+ :type minimum: int
+ :returns: whether param is set to an int of at least minimum value
+ :rtype: bool
+ """
+ value = self._traffic_profile[param]
+ if isinstance(value, str):
+ if value.isdigit():
+ value = int(value)
+ else:
+ value = minimum - 1
+ if isinstance(value, int) and value >= minimum:
+ self.traffic_profile[param] = value
+ return True
+ logger.error(
+ f"The parameter '{param}' must be an integer and at least {minimum}"
+ )
+ return False