From f89f4cd3af26cada4dd3b5c326e4e0c4cf082318 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Fri, 29 Mar 2024 22:17:09 +0000 Subject: [PATCH] Add vnic_type to the member object The member object now has an optional vnic_type that specifies if the member network port should use an SR-IOV VF or not. Change-Id: Ia2a3d396de2b09c5e9e55e6cec826423dce5aff8 --- octavia_lib/api/drivers/data_models.py | 7 +++++-- octavia_lib/common/constants.py | 3 +++ octavia_lib/tests/unit/api/drivers/test_data_models.py | 9 ++++++--- .../notes/Add-member-vnic_type-c42bed41588b6f02.yaml | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/Add-member-vnic_type-c42bed41588b6f02.yaml diff --git a/octavia_lib/api/drivers/data_models.py b/octavia_lib/api/drivers/data_models.py index 5386664..6a1bc7e 100644 --- a/octavia_lib/api/drivers/data_models.py +++ b/octavia_lib/api/drivers/data_models.py @@ -233,7 +233,8 @@ class Member(BaseDataModel): def __init__(self, address=Unset, admin_state_up=Unset, member_id=Unset, monitor_address=Unset, monitor_port=Unset, name=Unset, pool_id=Unset, protocol_port=Unset, subnet_id=Unset, - weight=Unset, backup=Unset, project_id=Unset): + weight=Unset, backup=Unset, project_id=Unset, + vnic_type=Unset): self.address = address self.admin_state_up = admin_state_up @@ -247,12 +248,14 @@ class Member(BaseDataModel): self.weight = weight self.backup = backup self.project_id = project_id + self.vnic_type = vnic_type def __str__(self): return (f"Member(address={self.address!r}, " f"member_id={self.member_id!r}, name={self.name!r}, " f"pool_id={self.pool_id!r}, project_id={self.project_id!r}, " - f"subnet_id={self.subnet_id!r}, weight={self.weight!r})") + f"subnet_id={self.subnet_id!r}, weight={self.weight!r}, " + f"vnic_type={self.vnic_type!r})") class HealthMonitor(BaseDataModel): diff --git a/octavia_lib/common/constants.py b/octavia_lib/common/constants.py index 5afabb6..df0abfa 100644 --- a/octavia_lib/common/constants.py +++ b/octavia_lib/common/constants.py @@ -298,4 +298,7 @@ VIP_NETWORK_ID = 'vip_network_id' VIP_PORT_ID = 'vip_port_id' VIP_SUBNET_ID = 'vip_subnet_id' VIP_QOS_POLICY_ID = 'vip_qos_policy_id' +VNIC_TYPE = 'vnic_type' +VNIC_TYPE_DIRECT = 'direct' +VNIC_TYPE_NORMAL = 'normal' WEIGHT = 'weight' diff --git a/octavia_lib/tests/unit/api/drivers/test_data_models.py b/octavia_lib/tests/unit/api/drivers/test_data_models.py index 1727663..8a84cea 100644 --- a/octavia_lib/tests/unit/api/drivers/test_data_models.py +++ b/octavia_lib/tests/unit/api/drivers/test_data_models.py @@ -150,7 +150,8 @@ class TestProviderDataModels(base.TestCase): protocol_port=80, subnet_id=self.mem_subnet_id, weight=1, - backup=False) + backup=False, + vnic_type=constants.VNIC_TYPE_NORMAL) self.ref_healthmonitor = data_models.HealthMonitor( admin_state_up=False, @@ -307,7 +308,8 @@ class TestProviderDataModels(base.TestCase): 'protocol_port': 80, 'subnet_id': self.mem_subnet_id, 'weight': 1, - 'backup': False} + 'backup': False, + 'vnic_type': constants.VNIC_TYPE_NORMAL} self.ref_healthmonitor_dict = { 'admin_state_up': False, @@ -518,7 +520,8 @@ class TestProviderDataModels(base.TestCase): f"Member(address='192.0.2.10', member_id={self.member_id!r}, " f"name='member', pool_id={self.pool_id!r}, " f"project_id={self.project_id!r}, " - f"subnet_id={self.ref_member.subnet_id!r}, weight=1)", + f"subnet_id={self.ref_member.subnet_id!r}, weight=1, " + f"vnic_type='{constants.VNIC_TYPE_NORMAL}')", str(self.ref_member)) self.assertEqual( f"Pool(loadbalancer_id={self.loadbalancer_id!r}, " diff --git a/releasenotes/notes/Add-member-vnic_type-c42bed41588b6f02.yaml b/releasenotes/notes/Add-member-vnic_type-c42bed41588b6f02.yaml new file mode 100644 index 0000000..2f32042 --- /dev/null +++ b/releasenotes/notes/Add-member-vnic_type-c42bed41588b6f02.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Added the "vnic_type" field to the member object.