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
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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
10 deletions
+29
-10
firewall/models.py
+1
-1
miscellaneous/devenv/nextinit.sh
+2
-0
one/models.py
+18
-7
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):
...
@@ -304,7 +304,7 @@ class Record(models.Model):
else
:
else
:
return
self
.
name
return
self
.
name
else
:
# if self.host is None
else
:
# if self.host is None
if
self
.
name
is
Non
e
:
if
not
self
.
nam
e
:
return
unicode
(
self
.
domain
)
return
unicode
(
self
.
domain
)
else
:
else
:
return
self
.
name
+
'.'
+
unicode
(
self
.
domain
)
return
self
.
name
+
'.'
+
unicode
(
self
.
domain
)
...
...
miscellaneous/devenv/nextinit.sh
View file @
893d31b6
...
@@ -13,6 +13,8 @@ sudo rabbitmqctl add_vhost django || true
...
@@ -13,6 +13,8 @@ sudo rabbitmqctl add_vhost django || true
sudo
rabbitmqctl set_permissions
-p
django nyuszi
'.*'
'.*'
'.*'
||
true
sudo
rabbitmqctl set_permissions
-p
django nyuszi
'.*'
'.*'
'.*'
||
true
sudo
cp /opt/webadmin/cloud/miscellaneous/devenv/boot_url.py /opt/
#Set up store server
#Set up store server
rm
-rf
/var/www/
*
rm
-rf
/var/www/
*
mkdir
-p
/var/www
mkdir
-p
/var/www
...
...
one/models.py
View file @
893d31b6
...
@@ -14,7 +14,7 @@ from django.db.models.signals import post_save
...
@@ -14,7 +14,7 @@ from django.db.models.signals import post_save
from
django
import
forms
from
django
import
forms
from
django.utils.translation
import
ugettext_lazy
as
_
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
school.models
import
Person
,
Group
from
store.api
import
StoreApi
from
store.api
import
StoreApi
from
.util
import
keygen
from
.util
import
keygen
...
@@ -403,30 +403,41 @@ class Instance(models.Model):
...
@@ -403,30 +403,41 @@ class Instance(models.Model):
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'vm_show'
,
None
,
{
'iid'
:
self
.
id
})
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."""
"""Get public port number for default access method."""
proto
=
self
.
template
.
access_type
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
])
return
{
"rdp"
:
23000
,
"nx"
:
22000
,
"ssh"
:
22000
}[
proto
]
+
int
(
self
.
ip
.
split
(
'.'
)[
2
])
*
256
+
int
(
self
.
ip
.
split
(
'.'
)[
3
])
else
:
else
:
return
{
"rdp"
:
3389
,
"nx"
:
22
,
"ssh"
:
22
}[
proto
]
return
{
"rdp"
:
3389
,
"nx"
:
22
,
"ssh"
:
22
}[
proto
]
def
get_connect_host
(
self
):
def
get_connect_host
(
self
,
use_ipv6
=
False
):
"""Get public hostname."""
"""Get public hostname."""
if
self
.
firewall_host
is
None
:
if
self
.
firewall_host
is
None
:
return
_
(
'None'
)
return
_
(
'None'
)
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
:
if
self
.
template
.
network
.
nat
:
return
self
.
firewall_host
.
pub_ipv4
return
self
.
firewall_host
.
pub_ipv4
else
:
else
:
return
self
.
firewall_host
.
ipv4
return
self
.
firewall_host
.
ipv4
def
get_connect_uri
(
self
):
def
get_connect_uri
(
self
,
use_ipv6
=
False
):
"""Get access parameters in URI format."""
"""Get access parameters in URI format."""
try
:
try
:
proto
=
self
.
template
.
access_type
proto
=
self
.
template
.
access_type
if
proto
==
'ssh'
:
if
proto
==
'ssh'
:
proto
=
'sshterm'
proto
=
'sshterm'
port
=
self
.
get_port
()
port
=
self
.
get_port
(
use_ipv6
=
use_ipv6
)
host
=
self
.
get_connect_host
()
host
=
self
.
get_connect_host
(
use_ipv6
=
use_ipv6
)
pw
=
self
.
pw
pw
=
self
.
pw
return
(
"
%(proto)
s:cloud:
%(pw)
s:
%(host)
s:
%(port)
d"
%
return
(
"
%(proto)
s:cloud:
%(pw)
s:
%(host)
s:
%(port)
d"
%
{
"port"
:
port
,
"proto"
:
proto
,
"pw"
:
pw
,
{
"port"
:
port
,
"proto"
:
proto
,
"pw"
:
pw
,
...
...
one/templates/vm-credentials.html
View file @
893d31b6
...
@@ -35,11 +35,11 @@
...
@@ -35,11 +35,11 @@
</tr>
</tr>
<tr>
<tr>
<th>
{% trans "IP" %}:
</th>
<th>
{% trans "IP" %}:
</th>
<td>
{{ i.
get_connect_host
}}
</td>
<td>
{{ i.
hostname
}}
</td>
</tr>
</tr>
<tr>
<tr>
<th>
{% trans "Port" %}:
</th>
<th>
{% trans "Port" %}:
</th>
<td>
{{ i.
get_
port}}
</td>
<td>
{{ i.port}}
</td>
</tr>
</tr>
<tr>
<tr>
<th>
{% trans "Username" %}:
</th>
<th>
{% trans "Username" %}:
</th>
...
...
one/views.py
View file @
893d31b6
...
@@ -94,6 +94,9 @@ def ajax_template_name_unique(request, name):
...
@@ -94,6 +94,9 @@ def ajax_template_name_unique(request, name):
def
vm_credentials
(
request
,
iid
):
def
vm_credentials
(
request
,
iid
):
try
:
try
:
vm
=
get_object_or_404
(
Instance
,
pk
=
iid
,
owner
=
request
.
user
)
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
}))
return
render_to_response
(
'vm-credentials.html'
,
RequestContext
(
request
,
{
'i'
:
vm
}))
except
:
except
:
return
HttpResponse
(
_
(
"Could not get Virtual Machine credentials."
),
status
=
404
)
return
HttpResponse
(
_
(
"Could not get Virtual Machine credentials."
),
status
=
404
)
...
@@ -296,6 +299,9 @@ def vm_show(request, iid):
...
@@ -296,6 +299,9 @@ def vm_show(request, iid):
except
UserCloudDetails
.
DoesNotExist
:
except
UserCloudDetails
.
DoesNotExist
:
details
=
UserCloudDetails
(
user
=
request
.
user
)
details
=
UserCloudDetails
(
user
=
request
.
user
)
details
.
save
()
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
,{
return
render_to_response
(
"show.html"
,
RequestContext
(
request
,{
'uri'
:
inst
.
get_connect_uri
(),
'uri'
:
inst
.
get_connect_uri
(),
'state'
:
inst
.
state
,
'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