Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ee6f3995
authored
Jan 27, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: fix get_connect_uri()
parent
3eb0db45
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletions
+45
-1
circle/dashboard/templates/dashboard/vm-detail.html
+1
-1
circle/firewall/models.py
+26
-0
circle/vm/models/instance.py
+18
-0
No files found.
circle/dashboard/templates/dashboard/vm-detail.html
View file @
ee6f3995
...
...
@@ -34,7 +34,7 @@
</div>
<h3>
{% trans "Connection" %}
</h3>
<!-- TODO RDP -->
<input
type=
"text"
value=
"
ssh cloud@vm.ik.bme.hu -p22312
"
class=
"form-control"
readonly
/>
<input
type=
"text"
value=
"
{{ instance.get_connect_command }}
"
class=
"form-control"
readonly
/>
<dl
class=
"dl-horizontal vm-details-pw"
>
<dt>
Password:
</dt>
<dd>
...
...
circle/firewall/models.py
View file @
ee6f3995
...
...
@@ -650,6 +650,32 @@ class Host(models.Model):
"""
return
self
.
get_hostname
(
'ipv4'
,
public
=
False
)
def
get_public_endpoints
(
self
,
port
,
protocol
=
'tcp'
):
"""Get public IPv4 and IPv6 endpoints for local port.
Optionally the required protocol (e.g. TCP, UDP) can be specified.
"""
endpoints
=
{}
# IPv4
public_ipv4
=
self
.
pub_ipv4
if
self
.
pub_ipv4
else
self
.
ipv4
# try get matching port(s) without NAT
ports
=
self
.
incoming_rules
.
filter
(
accept
=
True
,
dport
=
port
,
nat
=
False
,
proto
=
protocol
)
if
ports
.
exists
():
public_port
=
ports
[
0
]
.
dport
else
:
# try get matching port(s) with NAT
ports
=
self
.
incoming_rules
.
filter
(
accept
=
True
,
nat_dport
=
port
,
nat
=
True
,
proto
=
protocol
)
public_port
=
ports
[
0
]
.
dport
if
ports
.
exists
()
else
None
endpoints
[
'ipv4'
]
=
((
public_ipv4
,
public_port
)
if
public_port
else
None
)
# IPv6
blocked
=
self
.
incoming_rules
.
filter
(
accept
=
False
,
dport
=
port
,
proto
=
protocol
)
.
exists
()
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
not
blocked
else
None
return
endpoints
@models.permalink
def
get_absolute_url
(
self
):
return
(
'network.host'
,
None
,
{
'pk'
:
self
.
pk
})
...
...
circle/vm/models/instance.py
View file @
ee6f3995
...
...
@@ -405,6 +405,24 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
return
self
.
interface_set
.
exclude
(
host
=
None
)[
0
]
.
host
.
get_hostname
(
proto
=
proto
)
def
get_connect_command
(
self
,
use_ipv6
=
False
):
try
:
port
=
self
.
get_connect_port
(
use_ipv6
=
use_ipv6
)
host
=
self
.
get_connect_host
(
use_ipv6
=
use_ipv6
)
proto
=
self
.
access_method
print
proto
if
proto
==
'rdp'
:
return
'rdesktop
%(host)
s:
%(port)
d -u cloud -p
%(pw)
s'
%
{
'port'
:
port
,
'proto'
:
proto
,
'pw'
:
self
.
pw
,
'host'
:
host
}
elif
proto
==
'ssh'
:
return
(
'sshpass -p
%(pw)
s ssh -o StrictHostKeyChecking=n '
'cloud@
%(host)
s -p
%(port)
d'
)
%
{
'port'
:
port
,
'proto'
:
proto
,
'pw'
:
self
.
pw
,
'host'
:
host
}
except
:
return
def
get_connect_uri
(
self
,
use_ipv6
=
False
):
"""Get access parameters in URI format.
"""
...
...
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