Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f816770a
authored
Jul 03, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: fix Host.list_ports()
parent
dc5425b3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
18 deletions
+22
-18
circle/dashboard/templates/dashboard/vm-detail.html
+2
-2
circle/dashboard/templates/dashboard/vm-detail/network.html
+2
-2
circle/dashboard/templatetags/network_tags.py
+12
-4
circle/firewall/models.py
+3
-6
circle/vm/models/instance.py
+3
-4
No files found.
circle/dashboard/templates/dashboard/vm-detail.html
View file @
f816770a
...
@@ -80,9 +80,9 @@
...
@@ -80,9 +80,9 @@
{% endif %}
{% endif %}
</dd>
</dd>
{% if instance.ipv6 %}
{% if instance.ipv6
and instance.get_connect_port
%}
<dt>
{% trans "Host (IPv6)" %}
</dt>
<dt>
{% trans "Host (IPv6)" %}
</dt>
<dd>
{{ ipv6_host }}:
<strong>
{{ i
nstance.i
pv6_port }}
</strong></dd>
<dd>
{{ ipv6_host }}:
<strong>
{{ ipv6_port }}
</strong></dd>
{% endif %}
{% endif %}
<dt>
{% trans "Username" %}
</dt>
<dt>
{% trans "Username" %}
</dt>
...
...
circle/dashboard/templates/dashboard/vm-detail/network.html
View file @
f816770a
...
@@ -92,7 +92,7 @@
...
@@ -92,7 +92,7 @@
{% if l.ipv4 %}
{% if l.ipv4 %}
<tr>
<tr>
<td>
<td>
{% display_portforward l %}
{% display_portforward
4
l %}
</td>
</td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td>
<td>
...
@@ -124,7 +124,7 @@
...
@@ -124,7 +124,7 @@
{% if l.ipv6 %}
{% if l.ipv6 %}
<tr>
<tr>
<td>
<td>
{% display_portforward l %}
{% display_portforward
6
l %}
</td>
</td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td>
<td>
...
...
circle/dashboard/templatetags/network_tags.py
View file @
f816770a
...
@@ -6,10 +6,18 @@ register = template.Library()
...
@@ -6,10 +6,18 @@ register = template.Library()
LINKABLE_PORTS
=
{
80
:
"http"
,
8080
:
"http"
,
443
:
"https"
,
21
:
"ftp"
}
LINKABLE_PORTS
=
{
80
:
"http"
,
8080
:
"http"
,
443
:
"https"
,
21
:
"ftp"
}
@register.simple_tag
(
name
=
"display_portforward"
)
@register.simple_tag
(
name
=
"display_portforward4"
)
def
display_pf
(
ports
):
def
display_pf4
(
ports
):
is_ipv6
=
"ipv6"
in
ports
return
display_pf
(
ports
,
'ipv4'
)
data
=
ports
[
"ipv6"
if
is_ipv6
else
"ipv4"
]
@register.simple_tag
(
name
=
"display_portforward6"
)
def
display_pf6
(
ports
):
return
display_pf
(
ports
,
'ipv6'
)
def
display_pf
(
ports
,
proto
):
data
=
ports
[
proto
]
if
ports
[
'private'
]
in
LINKABLE_PORTS
.
keys
():
if
ports
[
'private'
]
in
LINKABLE_PORTS
.
keys
():
href
=
"
%
s:
%
d"
%
(
data
[
'host'
],
data
[
'port'
])
href
=
"
%
s:
%
d"
%
(
data
[
'host'
],
data
[
'port'
])
...
...
circle/firewall/models.py
View file @
f816770a
...
@@ -696,8 +696,7 @@ class Host(models.Model):
...
@@ -696,8 +696,7 @@ class Host(models.Model):
:param private: Port number of host in subject.
:param private: Port number of host in subject.
"""
"""
self
.
rules
.
filter
(
owner
=
self
.
owner
,
proto
=
proto
,
host
=
self
,
self
.
rules
.
filter
(
proto
=
proto
,
dport
=
private
)
.
delete
()
dport
=
private
)
.
delete
()
def
get_hostname
(
self
,
proto
,
public
=
True
):
def
get_hostname
(
self
,
proto
,
public
=
True
):
"""
"""
...
@@ -729,7 +728,7 @@ class Host(models.Model):
...
@@ -729,7 +728,7 @@ class Host(models.Model):
Return a list of ports with forwarding rules set.
Return a list of ports with forwarding rules set.
"""
"""
retval
=
[]
retval
=
[]
for
rule
in
self
.
rules
.
filter
(
owner
=
self
.
owner
):
for
rule
in
self
.
rules
.
all
(
):
forward
=
{
forward
=
{
'proto'
:
rule
.
proto
,
'proto'
:
rule
.
proto
,
'private'
:
rule
.
dport
,
'private'
:
rule
.
dport
,
...
@@ -771,9 +770,7 @@ class Host(models.Model):
...
@@ -771,9 +770,7 @@ class Host(models.Model):
if
public_port
else
if
public_port
else
None
)
None
)
# IPv6
# IPv6
blocked
=
self
.
incoming_rules
.
exclude
(
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
public_port
else
None
action
=
'accept'
)
.
filter
(
dport
=
port
,
proto
=
protocol
)
.
exists
()
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
not
blocked
else
None
return
endpoints
return
endpoints
@models.permalink
@models.permalink
...
...
circle/vm/models/instance.py
View file @
f816770a
...
@@ -574,11 +574,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -574,11 +574,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
def
get_connect_host
(
self
,
use_ipv6
=
False
):
def
get_connect_host
(
self
,
use_ipv6
=
False
):
"""Get public hostname.
"""Get public hostname.
"""
"""
if
not
self
.
interface_set
.
exclude
(
host
=
None
)
:
if
not
self
.
primary_host
:
return
_
(
'None'
)
return
None
proto
=
'ipv6'
if
use_ipv6
else
'ipv4'
proto
=
'ipv6'
if
use_ipv6
else
'ipv4'
return
self
.
interface_set
.
exclude
(
host
=
None
)[
0
]
.
host
.
get_hostname
(
return
self
.
primary_host
.
get_hostname
(
proto
=
proto
)
proto
=
proto
)
def
get_connect_command
(
self
,
use_ipv6
=
False
):
def
get_connect_command
(
self
,
use_ipv6
=
False
):
"""Returns a formatted connect string.
"""Returns a formatted connect string.
...
...
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