-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jiazhang <[email protected]> rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED
- Loading branch information
1 parent
1d8b213
commit d43de4d
Showing
6 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Custom datasources for ``nmcli`` command | ||
""" | ||
from insights.core.plugins import datasource | ||
from insights.parsers.nmcli import NmcliConnShow | ||
|
||
|
||
@datasource(NmcliConnShow) | ||
def nmcli_conn_show_uuids(broker): | ||
""" Return a list of connection uuids """ | ||
nmcli_conn_show = broker[NmcliConnShow] | ||
return [item["UUID"] for item in nmcli_conn_show.data] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from insights.parsers.nmcli import NmcliConnShow | ||
from insights.specs.datasources.nmcli import nmcli_conn_show_uuids | ||
from insights.tests import context_wrap | ||
|
||
|
||
NMCLI_CONN_SHOW = ''' | ||
NAME UUID TYPE DEVICE | ||
Wired connection 2 5fb06bd0-b09a-4573-b393-b54e832ddce9 ethernet enp0s20f0u5c2 | ||
lo 10f69a0f-0bb0-409f-831f-b5b729ba81af loopback lo | ||
Wired connection 1 9dc5d4c5-71ae-44fb-804a-d6edd65f3e03 ethernet -- | ||
enp0s29f2 bb30e099-8220-3eba-45f1-47fb09a4ec80 ethernet -- | ||
'''.strip() | ||
|
||
|
||
def test_nmcli_conn_show_uuids(): | ||
nmcli_conn_show = NmcliConnShow(context_wrap(NMCLI_CONN_SHOW)) | ||
broker = {NmcliConnShow: nmcli_conn_show} | ||
result = nmcli_conn_show_uuids(broker) | ||
assert result == ['5fb06bd0-b09a-4573-b393-b54e832ddce9', '10f69a0f-0bb0-409f-831f-b5b729ba81af', '9dc5d4c5-71ae-44fb-804a-d6edd65f3e03', 'bb30e099-8220-3eba-45f1-47fb09a4ec80'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters