diff --git a/common/vrnetlab.py b/common/vrnetlab.py index f6767004..87977a4c 100644 --- a/common/vrnetlab.py +++ b/common/vrnetlab.py @@ -90,7 +90,9 @@ def __init__( self.nic_type = "e1000" self.num_nics = 0 # number of nics that are actually *provisioned* (as in nics that will be added to container) - self.num_provisioned_nics = int(os.environ.get("CLAB_INTFS", 0)) + # since hellt/vrnetlab 0.15.0 the CLAB_INTFS_WITH_MGMT env var is used (instead of CLAB_INTFS) + # that counts management interface as well as data plane interfaces defined in the topology + self.num_provisioned_nics = int(os.environ.get("CLAB_INTFS_WITH_MGMT", 0)) # "highest" provisioned nic num -- used for making sure we can allocate nics without needing # to have them allocated sequential from eth1 self.highest_provisioned_nic_num = 0 @@ -425,7 +427,7 @@ def gen_mgmt(self): def nic_provision_delay(self) -> None: self.logger.debug( - f"number of provisioned data plane interfaces is {self.num_provisioned_nics}" + f"number of provisioned data and control plane interfaces is {self.num_provisioned_nics}" ) if self.num_provisioned_nics == 0: @@ -442,8 +444,10 @@ def nic_provision_delay(self) -> None: inf_path = Path("/sys/class/net/") while True: provisioned_nics = list(inf_path.glob("eth*")) - # if we see num provisioned +1 (for mgmt) we have all nics ready to roll! - if len(provisioned_nics) >= self.num_provisioned_nics + 1: + # if we see num provisioned interfaces we have all nics ready to roll! + # the management interface is counted as well and is included in CLAB_INTFS env var + # since containerlab v0.51.0 + if len(provisioned_nics) >= self.num_provisioned_nics: nics = [ int(re.search(pattern=r"\d+", string=nic.name).group()) for nic in provisioned_nics @@ -456,9 +460,11 @@ def nic_provision_delay(self) -> None: self.highest_provisioned_nic_num = max(nics) self.logger.debug( - f"highest allocated interface id determined to be: {self.highest_provisioned_nic_num}..." + f"highest allocated interface id determined to be: {self.highest_provisioned_nic_num}" + ) + self.logger.debug( + "control and datap plane interfaces detected, continuing..." ) - self.logger.debug("interfaces provisioned, continuing...") return time.sleep(5)