Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hostinfo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
hostinfo
Commits
7cf2c93a
Commit
7cf2c93a
authored
Nov 4, 2021
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Make device matching work for unknown device kinds
parent
0325467f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hostinfo/networkmanager.py
+15
-8
15 additions, 8 deletions
src/hostinfo/networkmanager.py
with
15 additions
and
8 deletions
src/hostinfo/networkmanager.py
+
15
−
8
View file @
7cf2c93a
...
@@ -28,25 +28,32 @@ class Network(object):
...
@@ -28,25 +28,32 @@ class Network(object):
self
.
_tun
=
{}
self
.
_tun
=
{}
self
.
_connection
=
{}
self
.
_connection
=
{}
# Get devices from network manager
# Get devices from network manager
def
is_kind
(
device
,
kind
):
device_class
=
getattr
(
NetworkManager
,
kind
,
None
)
if
device_class
==
None
:
print
(
'
%s not defined in this version of NetworkManager
'
%
kind
)
return
False
return
isinstance
(
device
,
device_class
)
for
d
in
NetworkManager
.
NetworkManager
.
AllDevices
:
for
d
in
NetworkManager
.
NetworkManager
.
AllDevices
:
if
is
instance
(
d
,
NetworkManager
.
Generic
):
if
is
_kind
(
d
,
'
Generic
'
):
pass
pass
elif
is
instance
(
d
,
NetworkManager
.
Dummy
):
elif
is
_kind
(
d
,
'
Dummy
'
):
pass
pass
elif
is
instance
(
d
,
NetworkManager
.
Wireless
):
elif
is
_kind
(
d
,
'
Wireless
'
):
pass
pass
elif
is
instance
(
d
,
NetworkManager
.
WireGuard
):
elif
is
_kind
(
d
,
'
WireGuard
'
):
pass
pass
elif
is
instance
(
d
,
NetworkManager
.
Wired
):
elif
is
_kind
(
d
,
'
Wired
'
):
self
.
_wired
[
d
.
HwAddress
.
lower
()]
=
d
self
.
_wired
[
d
.
HwAddress
.
lower
()]
=
d
pass
pass
elif
is
instance
(
d
,
NetworkManager
.
Bridge
):
elif
is
_kind
(
d
,
'
Bridge
'
):
self
.
_bridge
[
d
.
HwAddress
.
lower
()]
=
d
self
.
_bridge
[
d
.
HwAddress
.
lower
()]
=
d
pass
pass
elif
is
instance
(
d
,
NetworkManager
.
IPTunnel
):
elif
is
_kind
(
d
,
'
IPTunnel
'
):
self
.
_ip_tunnel
[
d
.
Interface
]
=
d
self
.
_ip_tunnel
[
d
.
Interface
]
=
d
pass
pass
elif
is
instance
(
d
,
NetworkManager
.
Tun
):
elif
is
_kind
(
d
,
'
Tun
'
):
self
.
_tun
[
d
.
Interface
]
=
d
self
.
_tun
[
d
.
Interface
]
=
d
pass
pass
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment