Skip to content

Commit

Permalink
Add new validator and completion script for thunderbolt pci-address
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelgaspar committed Dec 24, 2024
1 parent 8785eeb commit 2c23f8d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions interface-definitions/interfaces_thunderbolt.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
<properties>
<help>PCI device address of the Thunderbolt controller port</help>
<completionHelp>
<list>00:0d.2 00:0d.3</list>
<script>${vyos_completion_dir}/list_thunderbolt_pci_addresses.sh --no-running</script>
</completionHelp>
<valueHelp>
<format>&lt;hh:hh.h&gt;</format>
<description>PCI device address of the Thunderbolt controller port</description>
</valueHelp>
<constraint>
<regex>[0-9a-fA-F]{2}:[0-9a-fA-F]{2}.[0-9]+</regex>
<validator name="thunderbolt-pci-address" />
</constraint>
</properties>
</leafNode>
Expand Down
19 changes: 19 additions & 0 deletions src/completion/list_thunderbolt_pci_addresses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#
# Copyright (C) 2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This script is a completion helper to list all Thunderbolt ports PCI Addresses

lspci | grep Thunderbolt | grep NHI | cut -d" " -f1
23 changes: 23 additions & 0 deletions src/validators/thunderbolt-pci-address
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
#
# Copyright (C) 2021 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

for address in $(lspci | grep Thunderbolt | grep NHI | cut -d" " -f1); do
if [ "$address" == "$1" ]; then
exit 0
fi
done

exit 1

0 comments on commit 2c23f8d

Please sign in to comment.