From 7994f88a3594e35d5fc3af252556d71d6a75d08e Mon Sep 17 00:00:00 2001
From: Slawek Kaplonski <skaplons@redhat.com>
Date: Mon, 2 Sep 2024 11:28:05 +0200
Subject: [PATCH] Add "trusted" attribute to "port" resource

Related-bug: #2060916
Change-Id: Id065db33d7a71f0b4aac8ee95d4d3947736a7bda
---
 openstack/network/v2/port.py                                | 3 +++
 openstack/tests/unit/network/v2/test_port.py                | 2 ++
 .../notes/Add-trusted-vif-to-the-port-e306789f92e181b2.yaml | 6 ++++++
 3 files changed, 11 insertions(+)
 create mode 100644 releasenotes/notes/Add-trusted-vif-to-the-port-e306789f92e181b2.yaml

diff --git a/openstack/network/v2/port.py b/openstack/network/v2/port.py
index d85427576..03d6b0970 100644
--- a/openstack/network/v2/port.py
+++ b/openstack/network/v2/port.py
@@ -161,5 +161,8 @@ class Port(_base.NetworkResource, tag.TagMixin):
     #: sub_ports is a list of dicts with keys:
     #: port_id, segmentation_type, segmentation_id, mac_address*
     trunk_details = resource.Body('trunk_details', type=dict)
+    #: Status of the trusted VIF setting, this value is added to the
+    #: binding:profile field and passed to services which needs, it, like Nova
+    trusted = resource.Body('trusted', type=bool)
     #: Timestamp when the port was last updated.
     updated_at = resource.Body('updated_at')
diff --git a/openstack/tests/unit/network/v2/test_port.py b/openstack/tests/unit/network/v2/test_port.py
index 4fe890ee4..9fb34dcd1 100644
--- a/openstack/tests/unit/network/v2/test_port.py
+++ b/openstack/tests/unit/network/v2/test_port.py
@@ -67,6 +67,7 @@ EXAMPLE = {
             }
         ],
     },
+    'trusted': True,
     'updated_at': '2016-07-09T12:14:57.233772',
 }
 
@@ -165,4 +166,5 @@ class TestPort(base.TestCase):
         self.assertEqual(EXAMPLE['status'], sot.status)
         self.assertEqual(EXAMPLE['project_id'], sot.project_id)
         self.assertEqual(EXAMPLE['trunk_details'], sot.trunk_details)
+        self.assertEqual(EXAMPLE['trusted'], sot.trusted)
         self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
diff --git a/releasenotes/notes/Add-trusted-vif-to-the-port-e306789f92e181b2.yaml b/releasenotes/notes/Add-trusted-vif-to-the-port-e306789f92e181b2.yaml
new file mode 100644
index 000000000..e4cfe953f
--- /dev/null
+++ b/releasenotes/notes/Add-trusted-vif-to-the-port-e306789f92e181b2.yaml
@@ -0,0 +1,6 @@
+---
+features:
+  - |
+    Add ``trusted`` attribute to ``port`` resourse. Users can use this
+    attribute to set port to be trusted what will be then populated into
+    the ``binding:profile`` dictionary.