Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
agent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
7
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
43614758
authored
Jan 15, 2015
by
Oliver Pinter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added basic networking
parent
cfd7f36c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
freebsd/network.py
+11
-10
No files found.
freebsd/network.py
View file @
43614758
...
@@ -42,27 +42,28 @@ def change_ip_freebsd(interfaces, dns):
...
@@ -42,27 +42,28 @@ def change_ip_freebsd(interfaces, dns):
remove_interfaces_freebsd
(
dict
(
data
)
.
keys
())
remove_interfaces_freebsd
(
dict
(
data
)
.
keys
())
for
device
,
conf
in
data
:
for
device
,
conf
in
data
:
if_file
=
rcconf_dir
+
device
if_file
=
rcconf_dir
+
"ifconfig_"
+
device
with
open
(
if_file
,
'w'
)
as
f
:
with
open
(
if_file
,
'w'
)
as
f
:
f
.
write
(
'ifconfig_'
+
device
+
'="SYNCDHCP"'
)
#XXXOP - hardcoded
'''
with open(interfaces_file, 'a') as f:
for ifname, conf in data:
ipv4_alias_counter
=
ipv6_alias_counter
=
0
ipv4_alias_counter
=
ipv6_alias_counter
=
0
f.write('auto
%
s
\n
'
%
ifname)
for
i
in
conf
[
'addresses'
]:
for
i
in
conf
[
'addresses'
]:
alias
=
""
ip_with_prefix
=
IPNetwork
(
i
)
ip_with_prefix
=
IPNetwork
(
i
)
prefixlen = ip_with_prefix.prefixlen
ip
=
ip_with_prefix
.
ip
ip
=
ip_with_prefix
.
ip
alias = ifname
prefixlen
=
ip_with_prefix
.
prefixlen
if
ip
.
version
==
6
:
if
ip
.
version
==
6
:
alias
=
"_ipv6"
if
ipv6_alias_counter
>
0
:
if
ipv6_alias_counter
>
0
:
alias = '
%
s:
%
d'
%
(ifname, ipv6_alias_counter
)
alias
=
'
_alias
%
d'
%
(
ipv6_alias_counter
-
1
)
ipv6_alias_counter
+=
1
ipv6_alias_counter
+=
1
f
.
write
(
"ifconfig_"
+
device
+
alias
+
"="
+
"
\"
inet6
%(ip)
s prefix
%(pref)
s
\"\n
"
%
{
'ip'
:
ip
,
'pref'
:
prefixlen
})
else
:
else
:
if
ipv4_alias_counter
>
0
:
if
ipv4_alias_counter
>
0
:
alias = '
%
s:
%
d'
%
(ifname, ipv4_alias_counter
)
alias
=
'
_alias
%
d'
%
(
ipv4_alias_counter
-
1
)
ipv4_alias_counter
+=
1
ipv4_alias_counter
+=
1
f
.
write
(
"ifconfig_"
+
device
+
alias
+
"="
+
"
\"
inet
%(ip)
s/
%(pref)
s
\"\n
"
%
{
'ip'
:
ip
,
'pref'
:
prefixlen
})
'''
f.write(
f.write(
'iface
%(ifname)
s
%(proto)
s static
\n
'
'iface
%(ifname)
s
%(proto)
s static
\n
'
...
...
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