Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
settingsd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
settingsd
Commits
46cdc52c
Commit
46cdc52c
authored
Apr 02, 2019
by
Дмитрий Никулин
Committed by
Никита Ефремов
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Network: support for changing ip addresses per-interface
parent
df840443
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
fmod_network.py
plugins/functions/fmod_network.py
+22
-1
No files found.
plugins/functions/fmod_network.py
View file @
46cdc52c
...
...
@@ -4,7 +4,7 @@ import socket
import
os
from
pyroute2
import
IPDB
from
pyroute2.netlink.rtnl.ifinfmsg
import
IFF_UP
from
ipaddress
import
IPv4Address
from
ipaddress
import
IPv4Address
,
IPv4Network
from
yaml
import
dump
,
safe_load
from
settingsd
import
const
...
...
@@ -101,6 +101,27 @@ class Network(service.FunctionObject) :
def
_apply_interface_settings
(
self
,
interface_settings
):
with
IPDB
()
as
ipdb
:
for
interface
in
ipdb
.
interfaces
.
values
():
if
not
interface
.
ifname
in
interface_settings
:
continue
if
'address'
in
interface_settings
[
interface
.
ifname
]:
with
interface
as
interface
:
already_set
=
False
for
addr
,
mask
in
interface
.
ipaddr
:
prefixlen
=
IPv4Network
(
'0.0.0.0/'
+
interface_settings
[
interface
.
ifname
][
'mask'
])
.
prefixlen
if
interface_settings
[
interface
.
ifname
][
'address'
]
==
addr
and
prefixlen
==
mask
:
already_set
=
True
break
if
not
already_set
:
interface
.
add_ip
(
interface_settings
[
interface
.
ifname
][
'address'
],
IPv4Network
(
'0.0.0.0/'
+
interface_settings
[
interface
.
ifname
][
'mask'
])
.
prefixlen
)
for
addr
,
mask
in
interface
.
ipaddr
:
interface
.
del_ip
(
addr
,
mask
)
interfaces
=
[
i
.
ifname
for
i
in
ipdb
.
interfaces
.
values
()]
port_settings
=
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment