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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
893d31b6
authored
Feb 27, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://giccero.cloud.ik.bme.hu/cloud
parents
46cdd740
7137b4f6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
14 deletions
+33
-14
firewall/models.py
+1
-1
miscellaneous/devenv/nextinit.sh
+2
-0
one/models.py
+22
-11
one/templates/vm-credentials.html
+2
-2
one/views.py
+6
-0
No files found.
firewall/models.py
View file @
893d31b6
...
...
@@ -304,7 +304,7 @@ class Record(models.Model):
else
:
return
self
.
name
else
:
# if self.host is None
if
self
.
name
is
Non
e
:
if
not
self
.
nam
e
:
return
unicode
(
self
.
domain
)
else
:
return
self
.
name
+
'.'
+
unicode
(
self
.
domain
)
...
...
miscellaneous/devenv/nextinit.sh
View file @
893d31b6
...
...
@@ -13,6 +13,8 @@ sudo rabbitmqctl add_vhost django || true
sudo
rabbitmqctl set_permissions
-p
django nyuszi
'.*'
'.*'
'.*'
||
true
sudo
cp /opt/webadmin/cloud/miscellaneous/devenv/boot_url.py /opt/
#Set up store server
rm
-rf
/var/www/
*
mkdir
-p
/var/www
...
...
one/models.py
View file @
893d31b6
...
...
@@ -14,7 +14,7 @@ from django.db.models.signals import post_save
from
django
import
forms
from
django.utils.translation
import
ugettext_lazy
as
_
from
firewall.models
import
Host
,
Rule
,
Vlan
from
firewall.models
import
Host
,
Rule
,
Vlan
,
Record
from
school.models
import
Person
,
Group
from
store.api
import
StoreApi
from
.util
import
keygen
...
...
@@ -403,30 +403,41 @@ class Instance(models.Model):
def
get_absolute_url
(
self
):
return
(
'vm_show'
,
None
,
{
'iid'
:
self
.
id
})
def
get_port
(
self
):
def
get_port
(
self
,
use_ipv6
=
False
):
"""Get public port number for default access method."""
proto
=
self
.
template
.
access_type
if
self
.
template
.
network
.
nat
:
if
self
.
template
.
network
.
nat
and
not
use_ipv6
:
return
{
"rdp"
:
23000
,
"nx"
:
22000
,
"ssh"
:
22000
}[
proto
]
+
int
(
self
.
ip
.
split
(
'.'
)[
2
])
*
256
+
int
(
self
.
ip
.
split
(
'.'
)[
3
])
else
:
return
{
"rdp"
:
3389
,
"nx"
:
22
,
"ssh"
:
22
}[
proto
]
def
get_connect_host
(
self
):
def
get_connect_host
(
self
,
use_ipv6
=
False
):
"""Get public hostname."""
if
self
.
firewall_host
is
None
:
return
_
(
'None'
)
if
self
.
template
.
network
.
nat
:
return
self
.
firewall_host
.
pub_ipv4
else
:
return
self
.
firewall_host
.
ipv4
try
:
if
use_ipv6
:
return
self
.
firewall_host
.
record_set
.
filter
(
type
=
'AAAA'
)[
0
]
.
get_data
()[
'name'
]
else
:
if
self
.
template
.
network
.
nat
:
ip
=
self
.
firewall_host
.
pub_ipv4
return
Record
.
objects
.
get
(
type
=
'A'
,
address
=
ip
)
.
get_data
()[
'name'
]
else
:
return
self
.
firewall_host
.
record_set
.
filter
(
type
=
'A'
)[
0
]
.
get_data
()[
'name'
]
except
:
raise
if
self
.
template
.
network
.
nat
:
return
self
.
firewall_host
.
pub_ipv4
else
:
return
self
.
firewall_host
.
ipv4
def
get_connect_uri
(
self
):
def
get_connect_uri
(
self
,
use_ipv6
=
False
):
"""Get access parameters in URI format."""
try
:
proto
=
self
.
template
.
access_type
if
proto
==
'ssh'
:
proto
=
'sshterm'
port
=
self
.
get_port
()
host
=
self
.
get_connect_host
()
port
=
self
.
get_port
(
use_ipv6
=
use_ipv6
)
host
=
self
.
get_connect_host
(
use_ipv6
=
use_ipv6
)
pw
=
self
.
pw
return
(
"
%(proto)
s:cloud:
%(pw)
s:
%(host)
s:
%(port)
d"
%
{
"port"
:
port
,
"proto"
:
proto
,
"pw"
:
pw
,
...
...
one/templates/vm-credentials.html
View file @
893d31b6
...
...
@@ -35,11 +35,11 @@
</tr>
<tr>
<th>
{% trans "IP" %}:
</th>
<td>
{{ i.
get_connect_host
}}
</td>
<td>
{{ i.
hostname
}}
</td>
</tr>
<tr>
<th>
{% trans "Port" %}:
</th>
<td>
{{ i.
get_
port}}
</td>
<td>
{{ i.port}}
</td>
</tr>
<tr>
<th>
{% trans "Username" %}:
</th>
...
...
one/views.py
View file @
893d31b6
...
...
@@ -94,6 +94,9 @@ def ajax_template_name_unique(request, name):
def
vm_credentials
(
request
,
iid
):
try
:
vm
=
get_object_or_404
(
Instance
,
pk
=
iid
,
owner
=
request
.
user
)
proto
=
len
(
request
.
META
[
"REMOTE_ADDR"
]
.
split
(
'.'
))
==
1
vm
.
hostname
=
vm
.
get_connect_host
(
use_ipv6
=
proto
)
vm
.
port
=
vm
.
get_port
(
use_ipv6
=
proto
)
return
render_to_response
(
'vm-credentials.html'
,
RequestContext
(
request
,
{
'i'
:
vm
}))
except
:
return
HttpResponse
(
_
(
"Could not get Virtual Machine credentials."
),
status
=
404
)
...
...
@@ -296,6 +299,9 @@ def vm_show(request, iid):
except
UserCloudDetails
.
DoesNotExist
:
details
=
UserCloudDetails
(
user
=
request
.
user
)
details
.
save
()
proto
=
len
(
request
.
META
[
"REMOTE_ADDR"
]
.
split
(
'.'
))
==
1
inst
.
hostname
=
inst
.
get_connect_host
(
use_ipv6
=
proto
)
inst
.
port
=
inst
.
get_port
(
use_ipv6
=
proto
)
return
render_to_response
(
"show.html"
,
RequestContext
(
request
,{
'uri'
:
inst
.
get_connect_uri
(),
'state'
:
inst
.
state
,
...
...
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