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
7df6dd21
authored
Mar 06, 2014
by
Bach Dániel
Committed by
Bach Dániel
Mar 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: return IP address if there is no hostname
fixes
#93
parent
5b87d860
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletions
+32
-1
circle/firewall/models.py
+2
-0
circle/firewall/tests/test_firewall.py
+30
-1
No files found.
circle/firewall/models.py
View file @
7df6dd21
...
...
@@ -631,6 +631,8 @@ class Host(models.Model):
if
self
.
shared_ip
and
public
:
res
=
Record
.
objects
.
filter
(
type
=
'A'
,
address
=
self
.
pub_ipv4
)
if
res
.
count
()
<
1
:
return
unicode
(
self
.
pub_ipv4
)
else
:
res
=
self
.
record_set
.
filter
(
type
=
'A'
,
address
=
self
.
ipv4
)
...
...
circle/firewall/tests/test_firewall.py
View file @
7df6dd21
from
django.test
import
TestCase
from
django.contrib.auth.models
import
User
from
..admin
import
HostAdmin
from
firewall.models
import
Vlan
,
Domain
,
Host
from
firewall.models
import
Vlan
,
Domain
,
Record
,
Host
from
django.forms
import
ValidationError
...
...
@@ -82,3 +82,32 @@ class GetNewAddressTestCase(TestCase):
Host
(
hostname
=
'h-6'
,
mac
=
'01:02:03:04:05:06'
,
ipv4
=
'10.0.0.6'
,
vlan
=
self
.
vlan
,
owner
=
self
.
u1
)
.
save
()
self
.
assertEqual
(
self
.
vlan
.
get_new_address
()[
'ipv4'
],
'10.0.0.2'
)
class
HostGetHostnameTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
u1
=
User
.
objects
.
create
(
username
=
'user1'
)
self
.
u1
.
save
()
self
.
d
=
Domain
(
name
=
'example.org'
,
owner
=
self
.
u1
)
self
.
d
.
save
()
Record
.
objects
.
all
()
.
delete
()
self
.
vlan
=
Vlan
(
vid
=
1
,
name
=
'test'
,
network4
=
'10.0.0.0/24'
,
network6
=
'2001:738:2001:4031::/80'
,
domain
=
self
.
d
,
owner
=
self
.
u1
,
network_type
=
'portforward'
,
snat_ip
=
'10.1.1.1'
)
self
.
vlan
.
save
()
self
.
h
=
Host
(
hostname
=
'h'
,
mac
=
'01:02:03:04:05:00'
,
ipv4
=
'10.0.0.1'
,
vlan
=
self
.
vlan
,
owner
=
self
.
u1
,
shared_ip
=
True
,
pub_ipv4
=
self
.
vlan
.
snat_ip
)
self
.
h
.
save
()
def
test_issue_93_wo_record
(
self
):
self
.
assertEqual
(
self
.
h
.
get_hostname
(
proto
=
'ipv4'
,
public
=
True
),
unicode
(
self
.
h
.
pub_ipv4
))
def
test_issue_93_w_record
(
self
):
self
.
r
=
Record
(
name
=
'vm'
,
type
=
'A'
,
domain
=
self
.
d
,
owner
=
self
.
u1
,
address
=
self
.
vlan
.
snat_ip
)
self
.
r
.
save
()
self
.
assertEqual
(
self
.
h
.
get_hostname
(
proto
=
'ipv4'
,
public
=
True
),
self
.
r
.
fqdn
)
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