Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
Hide 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 @@
{% endif %}
</dd>
{% if instance.ipv6 %}
{% if instance.ipv6
and instance.get_connect_port
%}
<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 %}
<dt>
{% trans "Username" %}
</dt>
...
...
circle/dashboard/templates/dashboard/vm-detail/network.html
View file @
f816770a
...
...
@@ -92,7 +92,7 @@
{% if l.ipv4 %}
<tr>
<td>
{% display_portforward l %}
{% display_portforward
4
l %}
</td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td>
...
...
@@ -124,7 +124,7 @@
{% if l.ipv6 %}
<tr>
<td>
{% display_portforward l %}
{% display_portforward
6
l %}
</td>
<td><i
class=
"icon-long-arrow-right"
></i></td>
<td>
...
...
circle/dashboard/templatetags/network_tags.py
View file @
f816770a
...
...
@@ -6,10 +6,18 @@ register = template.Library()
LINKABLE_PORTS
=
{
80
:
"http"
,
8080
:
"http"
,
443
:
"https"
,
21
:
"ftp"
}
@register.simple_tag
(
name
=
"display_portforward"
)
def
display_pf
(
ports
):
is_ipv6
=
"ipv6"
in
ports
data
=
ports
[
"ipv6"
if
is_ipv6
else
"ipv4"
]
@register.simple_tag
(
name
=
"display_portforward4"
)
def
display_pf4
(
ports
):
return
display_pf
(
ports
,
'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
():
href
=
"
%
s:
%
d"
%
(
data
[
'host'
],
data
[
'port'
])
...
...
circle/firewall/models.py
View file @
f816770a
...
...
@@ -696,8 +696,7 @@ class Host(models.Model):
:param private: Port number of host in subject.
"""
self
.
rules
.
filter
(
owner
=
self
.
owner
,
proto
=
proto
,
host
=
self
,
dport
=
private
)
.
delete
()
self
.
rules
.
filter
(
proto
=
proto
,
dport
=
private
)
.
delete
()
def
get_hostname
(
self
,
proto
,
public
=
True
):
"""
...
...
@@ -729,7 +728,7 @@ class Host(models.Model):
Return a list of ports with forwarding rules set.
"""
retval
=
[]
for
rule
in
self
.
rules
.
filter
(
owner
=
self
.
owner
):
for
rule
in
self
.
rules
.
all
(
):
forward
=
{
'proto'
:
rule
.
proto
,
'private'
:
rule
.
dport
,
...
...
@@ -771,9 +770,7 @@ class Host(models.Model):
if
public_port
else
None
)
# IPv6
blocked
=
self
.
incoming_rules
.
exclude
(
action
=
'accept'
)
.
filter
(
dport
=
port
,
proto
=
protocol
)
.
exists
()
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
not
blocked
else
None
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
public_port
else
None
return
endpoints
@models.permalink
...
...
circle/vm/models/instance.py
View file @
f816770a
...
...
@@ -574,11 +574,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
def
get_connect_host
(
self
,
use_ipv6
=
False
):
"""Get public hostname.
"""
if
not
self
.
interface_set
.
exclude
(
host
=
None
)
:
return
_
(
'None'
)
if
not
self
.
primary_host
:
return
None
proto
=
'ipv6'
if
use_ipv6
else
'ipv4'
return
self
.
interface_set
.
exclude
(
host
=
None
)[
0
]
.
host
.
get_hostname
(
proto
=
proto
)
return
self
.
primary_host
.
get_hostname
(
proto
=
proto
)
def
get_connect_command
(
self
,
use_ipv6
=
False
):
"""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