Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ab7f458e
authored
Sep 02, 2014
by
Bach Dániel
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: simplify Host.get_network_config()
parent
1767d22c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
circle/firewall/models.py
+22
-6
No files found.
circle/firewall/models.py
View file @
ab7f458e
...
@@ -530,6 +530,26 @@ class Host(models.Model):
...
@@ -530,6 +530,26 @@ class Host(models.Model):
def
incoming_rules
(
self
):
def
incoming_rules
(
self
):
return
self
.
rules
.
filter
(
direction
=
'in'
)
return
self
.
rules
.
filter
(
direction
=
'in'
)
@staticmethod
def
create_ipnetwork
(
ip
,
prefixlen
):
try
:
net
=
IPNetwork
(
ip
)
net
.
prefixlen
=
prefixlen
except
TypeError
:
return
None
else
:
return
net
@property
def
ipv4_with_vlan_prefixlen
(
self
):
return
Host
.
create_ipnetwork
(
self
.
ipv4
,
self
.
vlan
.
network4
.
prefixlen
)
@property
def
ipv6_with_vlan_prefixlen
(
self
):
return
Host
.
create_ipnetwork
(
self
.
ipv6
,
self
.
vlan
.
network6
.
prefixlen
)
@property
@property
def
ipv6_with_prefixlen
(
self
):
def
ipv6_with_prefixlen
(
self
):
try
:
try
:
...
@@ -604,15 +624,11 @@ class Host(models.Model):
...
@@ -604,15 +624,11 @@ class Host(models.Model):
interface
=
{
'addresses'
:
[]}
interface
=
{
'addresses'
:
[]}
if
self
.
ipv4
and
self
.
vlan
.
network4
:
if
self
.
ipv4
and
self
.
vlan
.
network4
:
ipv4
=
IPNetwork
(
self
.
ipv4
)
interface
[
'addresses'
]
.
append
(
str
(
self
.
ipv4_with_vlan_prefixlen
))
ipv4
.
prefixlen
=
self
.
vlan
.
network4
.
prefixlen
interface
[
'addresses'
]
.
append
(
str
(
ipv4
))
interface
[
'gw4'
]
=
str
(
self
.
vlan
.
network4
.
ip
)
interface
[
'gw4'
]
=
str
(
self
.
vlan
.
network4
.
ip
)
if
self
.
ipv6
and
self
.
vlan
.
network6
:
if
self
.
ipv6
and
self
.
vlan
.
network6
:
ipv6
=
IPNetwork
(
self
.
ipv6
)
interface
[
'addresses'
]
.
append
(
str
(
self
.
ipv4_with_vlan_prefixlen
))
ipv6
.
prefixlen
=
self
.
vlan
.
network6
.
prefixlen
interface
[
'addresses'
]
.
append
(
str
(
ipv6
))
interface
[
'gw6'
]
=
str
(
self
.
vlan
.
network6
.
ip
)
interface
[
'gw6'
]
=
str
(
self
.
vlan
.
network6
.
ip
)
return
interface
return
interface
...
...
Bach Dániel
@bachdaniel
mentioned in merge request
!176 (merged)
Sep 02, 2014
mentioned in merge request
!176 (merged)
mentioned in merge request !176
Toggle commit list
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