Skip to content

Commit

Permalink
test: add NetIfaceConfig.network property
Browse files Browse the repository at this point in the history
This is to be able to get access to `ipaddress` helper functions to deal
with IPs.

Signed-off-by: Pablo Barbáchano <[email protected]>
  • Loading branch information
pb8o committed Jan 8, 2024
1 parent d9a4839 commit d564999
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/host_tools/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
"""Utilities for test host microVM network setup."""

import ipaddress
import random
import string
from dataclasses import dataclass, field
Expand Down Expand Up @@ -200,6 +201,11 @@ def guest_mac(self):
"""Return the guest MAC address."""
return mac_from_ip(self.guest_ip)

@property
def network(self):
"""Return the guest network"""
return ipaddress.IPv4Interface(f"{self.host_ip}/{self.netmask_len}").network

@staticmethod
def with_id(i, netmask_len=30):
"""Define network iface with id `i`."""
Expand Down

0 comments on commit d564999

Please sign in to comment.