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
a118c3e8
authored
Jul 01, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: change traits and raw data of vms
parent
d0ad840c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
1 deletions
+90
-1
circle/dashboard/forms.py
+37
-1
circle/dashboard/templates/dashboard/vm-detail/resources.html
+26
-0
circle/dashboard/urls.py
+5
-0
circle/dashboard/views.py
+22
-0
No files found.
circle/dashboard/forms.py
View file @
a118c3e8
...
@@ -39,12 +39,13 @@ from django.template import Context
...
@@ -39,12 +39,13 @@ from django.template import Context
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
sizefield.widgets
import
FileSizeWidget
from
sizefield.widgets
import
FileSizeWidget
from
django.core.urlresolvers
import
reverse_lazy
from
django_sshkey.models
import
UserKey
from
django_sshkey.models
import
UserKey
from
firewall.models
import
Vlan
,
Host
from
firewall.models
import
Vlan
,
Host
from
storage.models
import
Disk
from
storage.models
import
Disk
from
vm.models
import
(
from
vm.models
import
(
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
,
Instance
)
)
from
.models
import
Profile
,
GroupProfile
from
.models
import
Profile
,
GroupProfile
from
circle.settings.base
import
LANGUAGES
from
circle.settings.base
import
LANGUAGES
...
@@ -1145,3 +1146,38 @@ class UserKeyForm(forms.ModelForm):
...
@@ -1145,3 +1146,38 @@ class UserKeyForm(forms.ModelForm):
if
self
.
user
:
if
self
.
user
:
self
.
instance
.
user
=
self
.
user
self
.
instance
.
user
=
self
.
user
return
super
(
UserKeyForm
,
self
)
.
clean
()
return
super
(
UserKeyForm
,
self
)
.
clean
()
class
TraitsForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Instance
fields
=
(
'req_traits'
,
)
@property
def
helper
(
self
):
helper
=
FormHelper
()
helper
.
form_show_labels
=
False
helper
.
form_action
=
reverse_lazy
(
"dashboard.views.vm-traits"
,
kwargs
=
{
'pk'
:
self
.
instance
.
pk
})
helper
.
add_input
(
Submit
(
"submit"
,
_
(
"Save"
),
css_class
=
"btn btn-success"
,
))
return
helper
class
RawDataForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Instance
fields
=
(
'raw_data'
,
)
@property
def
helper
(
self
):
helper
=
FormHelper
()
helper
.
form_show_labels
=
False
helper
.
form_action
=
reverse_lazy
(
"dashboard.views.vm-raw-data"
,
kwargs
=
{
'pk'
:
self
.
instance
.
pk
})
helper
.
add_input
(
Submit
(
"submit"
,
_
(
"Save"
),
css_class
=
"btn btn-success"
,
css_id
=
"submit-password-button"
))
return
helper
circle/dashboard/templates/dashboard/vm-detail/resources.html
View file @
a118c3e8
...
@@ -68,6 +68,32 @@
...
@@ -68,6 +68,32 @@
</div>
</div>
</div>
</div>
{% if user.is_superuser %}
<hr/>
<div
class=
"row"
id=
""
>
<div
class=
"col-sm-12"
>
<h3>
{% trans "Required traits" %}
</h3>
{% crispy traits_form %}
</div>
</div>
<hr/>
<div
class=
"row"
id=
""
>
<div
class=
"col-sm-12"
>
<h3>
{% trans "Raw data" %}
</h3>
{% crispy raw_data_form %}
</div>
</div>
{% endif %}
{% block extra_js %}
{% block extra_js %}
<style>
<style>
...
...
circle/dashboard/urls.py
View file @
a118c3e8
...
@@ -37,6 +37,7 @@ from .views import (
...
@@ -37,6 +37,7 @@ from .views import (
get_vm_screenshot
,
get_vm_screenshot
,
ProfileView
,
toggle_use_gravatar
,
UnsubscribeFormView
,
ProfileView
,
toggle_use_gravatar
,
UnsubscribeFormView
,
UserKeyDelete
,
UserKeyDetail
,
UserKeyCreate
,
UserKeyDelete
,
UserKeyDetail
,
UserKeyCreate
,
VmTraitsUpdate
,
VmRawDataUpdate
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -89,6 +90,10 @@ urlpatterns = patterns(
...
@@ -89,6 +90,10 @@ urlpatterns = patterns(
name
=
'dashboard.views.vm-activity'
),
name
=
'dashboard.views.vm-activity'
),
url
(
r'^vm/(?P<pk>\d+)/screenshot/$'
,
get_vm_screenshot
,
url
(
r'^vm/(?P<pk>\d+)/screenshot/$'
,
get_vm_screenshot
,
name
=
'dashboard.views.vm-get-screenshot'
),
name
=
'dashboard.views.vm-get-screenshot'
),
url
(
r'^vm/(?P<pk>\d+)/traits/$'
,
VmTraitsUpdate
.
as_view
(),
name
=
'dashboard.views.vm-traits'
),
url
(
r'^vm/(?P<pk>\d+)/raw_data/$'
,
VmRawDataUpdate
.
as_view
(),
name
=
'dashboard.views.vm-raw-data'
),
url
(
r'^node/list/$'
,
NodeList
.
as_view
(),
name
=
'dashboard.views.node-list'
),
url
(
r'^node/list/$'
,
NodeList
.
as_view
(),
name
=
'dashboard.views.node-list'
),
url
(
r'^node/(?P<pk>\d+)/$'
,
NodeDetailView
.
as_view
(),
url
(
r'^node/(?P<pk>\d+)/$'
,
NodeDetailView
.
as_view
(),
...
...
circle/dashboard/views.py
View file @
a118c3e8
...
@@ -61,6 +61,7 @@ from .forms import (
...
@@ -61,6 +61,7 @@ from .forms import (
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
VmSaveForm
,
UserKeyForm
,
VmSaveForm
,
UserKeyForm
,
CirclePasswordChangeForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
CirclePasswordChangeForm
,
VmCreateDiskForm
,
VmDownloadDiskForm
,
TraitsForm
,
RawDataForm
)
)
from
.tables
import
(
from
.tables
import
(
...
@@ -287,6 +288,11 @@ class VmDetailView(CheckedDetailView):
...
@@ -287,6 +288,11 @@ class VmDetailView(CheckedDetailView):
# ipv6 infos
# ipv6 infos
context
[
'ipv6_host'
]
=
instance
.
get_connect_host
(
use_ipv6
=
True
)
context
[
'ipv6_host'
]
=
instance
.
get_connect_host
(
use_ipv6
=
True
)
context
[
'ipv6_port'
]
=
instance
.
get_connect_port
(
use_ipv6
=
True
)
context
[
'ipv6_port'
]
=
instance
.
get_connect_port
(
use_ipv6
=
True
)
# resources forms
if
self
.
request
.
user
.
is_superuser
:
context
[
'traits_form'
]
=
TraitsForm
(
instance
=
instance
)
context
[
'raw_data_form'
]
=
RawDataForm
(
instance
=
instance
)
return
context
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
...
@@ -499,6 +505,22 @@ class VmDetailView(CheckedDetailView):
...
@@ -499,6 +505,22 @@ class VmDetailView(CheckedDetailView):
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
class
VmTraitsUpdate
(
UpdateView
):
form_class
=
TraitsForm
model
=
Instance
def
get_success_url
(
self
):
return
self
.
get_object
()
.
get_absolute_url
()
+
"#resources"
class
VmRawDataUpdate
(
UpdateView
):
form_class
=
RawDataForm
model
=
Instance
def
get_success_url
(
self
):
return
self
.
get_object
()
.
get_absolute_url
()
+
"#resources"
class
OperationView
(
DetailView
):
class
OperationView
(
DetailView
):
template_name
=
'dashboard/operate.html'
template_name
=
'dashboard/operate.html'
...
...
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