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
797305ce
authored
Oct 09, 2016
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Azure specific fields to instance, base template creation form.
parent
541a0e59
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
3 deletions
+88
-3
circle/dashboard/forms.py
+38
-1
circle/dashboard/templates/dashboard/_template-choose.html
+1
-1
circle/dashboard/templates/dashboard/_template-create.html
+6
-0
circle/dashboard/views/template.py
+5
-1
circle/vm/migrations/0006_auto_20161009_1702.py
+31
-0
circle/vm/models/instance.py
+7
-0
No files found.
circle/dashboard/forms.py
View file @
797305ce
...
@@ -54,7 +54,9 @@ from django.core.urlresolvers import reverse_lazy
...
@@ -54,7 +54,9 @@ 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
vm.models
import
(
from
vm.models
import
(
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
,
Instance
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
,
Instance
,
AzureVirtualMachineSize
,
AzureBuiltinPublisher
,
AzureBuiltinOffer
,
AzureBuiltinSKU
,
AzureBuiltinVersion
)
)
from
storage.models
import
DataStore
,
Disk
from
storage.models
import
DataStore
,
Disk
from
django.contrib.admin.widgets
import
FilteredSelectMultiple
from
django.contrib.admin.widgets
import
FilteredSelectMultiple
...
@@ -458,8 +460,43 @@ class NodeForm(forms.ModelForm):
...
@@ -458,8 +460,43 @@ class NodeForm(forms.ModelForm):
model
=
Node
model
=
Node
fields
=
[
'name'
,
'priority'
,
'enabled'
,
]
fields
=
[
'name'
,
'priority'
,
'enabled'
,
]
from
logging
import
getLogger
logger
=
getLogger
(
__name__
)
class
VmSizeChoiceField
(
forms
.
ModelChoiceField
):
def
label_from_instance
(
self
,
obj
):
return
"""
%
s, Cores:
%
d, Memory:
%
d MB, OS Disk:
%
d MB,
Data Disk:
%
d MB, Max disks:
%
d"""
%
(
obj
.
name
,
obj
.
number_of_cores
,
obj
.
memory_in_mb
,
obj
.
os_disk_size_in_mb
,
obj
.
resource_disk_size_in_mb
,
obj
.
max_data_disk_count
)
class
TemplateForm
(
forms
.
ModelForm
):
class
TemplateForm
(
forms
.
ModelForm
):
logger
.
debug
(
str
(
AzureVirtualMachineSize
.
objects
.
all
()))
azure_vm_size
=
VmSizeChoiceField
(
queryset
=
AzureVirtualMachineSize
.
objects
.
all
())
#TODO: this is terribly slow, should make 4 choicefields, and set choices
# with JS value changed event, and AJAX calls
# ONLY FOR TESTING PURPOSES
def
generate_azure_template_list
():
result
=
[]
for
p
in
AzureBuiltinPublisher
.
objects
.
all
():
for
o
in
p
.
azure_offer
.
all
():
for
s
in
o
.
azure_sku
.
all
():
for
v
in
s
.
azure_version
.
all
():
result
.
append
((
v
.
pk
,
"
%
s -
%
s -
%
s -
%
s"
%
(
p
.
name
,
o
.
name
,
s
.
name
,
v
.
name
),
))
return
result
azure_template
=
forms
.
ChoiceField
(
choices
=
generate_azure_template_list
)
networks
=
forms
.
ModelMultipleChoiceField
(
networks
=
forms
.
ModelMultipleChoiceField
(
queryset
=
None
,
required
=
False
,
label
=
_
(
"Networks"
))
queryset
=
None
,
required
=
False
,
label
=
_
(
"Networks"
))
...
...
circle/dashboard/templates/dashboard/_template-choose.html
View file @
797305ce
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
{% if perms.vm.create_base_template %}
{% if perms.vm.create_base_template %}
<div
class=
"panel panel-default template-choose-list-element"
>
<div
class=
"panel panel-default template-choose-list-element"
>
<input
type=
"radio"
name=
"parent"
value=
"base_vm"
/>
<input
type=
"radio"
name=
"parent"
value=
"base_vm"
/>
{% trans "Create a new base VM
without disk
" %}
{% trans "Create a new base VM
from Azure Built-In templates
" %}
</div>
</div>
{% endif %}
{% endif %}
<button
type=
"submit"
id=
"template-choose-next-button"
class=
"btn btn-success pull-right"
>
{% trans "Next" %}
</button>
<button
type=
"submit"
id=
"template-choose-next-button"
class=
"btn btn-success pull-right"
>
{% trans "Next" %}
</button>
...
...
circle/dashboard/templates/dashboard/_template-create.html
View file @
797305ce
...
@@ -11,6 +11,12 @@
...
@@ -11,6 +11,12 @@
{{ form.name|as_crispy_field }}
{{ form.name|as_crispy_field }}
<fieldset>
<legend>
{% trans "Azure settings" %}
</legend>
{{ form.azure_vm_size|as_crispy_field }}
{{ form.azure_template|as_crispy_field }}
</fieldset>
<fieldset
class=
"resources-sliders"
>
<fieldset
class=
"resources-sliders"
>
<legend>
{% trans "Resource configuration" %}
</legend>
<legend>
{% trans "Resource configuration" %}
</legend>
{% include "dashboard/_resources-sliders.html" with field_priority=form.priority field_num_cores=form.num_cores field_ram_size=form.ram_size %}
{% include "dashboard/_resources-sliders.html" with field_priority=form.priority field_num_cores=form.num_cores field_ram_size=form.ram_size %}
...
...
circle/dashboard/views/template.py
View file @
797305ce
...
@@ -36,7 +36,9 @@ from braces.views import (
...
@@ -36,7 +36,9 @@ from braces.views import (
)
)
from
django_tables2
import
SingleTableView
from
django_tables2
import
SingleTableView
from
vm.models
import
InstanceTemplate
,
InterfaceTemplate
,
Instance
,
Lease
from
vm.models
import
(
InstanceTemplate
,
InterfaceTemplate
,
Instance
,
Lease
,
AzureBuiltinVersion
)
from
storage.models
import
Disk
from
storage.models
import
Disk
from
..forms
import
(
from
..forms
import
(
...
@@ -147,6 +149,8 @@ class TemplateCreate(SuccessMessageMixin, CreateView):
...
@@ -147,6 +149,8 @@ class TemplateCreate(SuccessMessageMixin, CreateView):
tags
=
post
.
pop
(
"tags"
)
tags
=
post
.
pop
(
"tags"
)
post
[
'pw'
]
=
User
.
objects
.
make_random_password
()
post
[
'pw'
]
=
User
.
objects
.
make_random_password
()
post
[
'is_base'
]
=
True
post
[
'is_base'
]
=
True
post
[
'azure_template'
]
=
AzureBuiltinVersion
.
objects
.
get
(
pk
=
post
[
'azure_template'
])
inst
=
Instance
.
create
(
params
=
post
,
disks
=
[],
inst
=
Instance
.
create
(
params
=
post
,
disks
=
[],
networks
=
networks
,
networks
=
networks
,
tags
=
tags
,
req_traits
=
req_traits
)
tags
=
tags
,
req_traits
=
req_traits
)
...
...
circle/vm/migrations/0006_auto_20161009_1702.py
0 → 100644
View file @
797305ce
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'vm'
,
'0005_azurevirtualmachinesize'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'instance'
,
name
=
'azure_template'
,
field
=
models
.
ForeignKey
(
default
=
8000
,
verbose_name
=
'azure vm template'
,
to
=
'vm.AzureBuiltinVersion'
),
preserve_default
=
False
,
),
migrations
.
AddField
(
model_name
=
'instance'
,
name
=
'azure_vm_size'
,
field
=
models
.
ForeignKey
(
default
=
1
,
verbose_name
=
'azure vm size'
,
to
=
'vm.AzureVirtualMachineSize'
),
preserve_default
=
False
,
),
migrations
.
AlterField
(
model_name
=
'azurevirtualmachinesize'
,
name
=
'name'
,
field
=
models
.
TextField
(
unique
=
True
,
verbose_name
=
'name'
),
),
]
circle/vm/models/instance.py
View file @
797305ce
...
@@ -50,6 +50,8 @@ from .activity import (ActivityInProgressError, InstanceActivity)
...
@@ -50,6 +50,8 @@ from .activity import (ActivityInProgressError, InstanceActivity)
from
.common
import
BaseResourceConfigModel
,
Lease
from
.common
import
BaseResourceConfigModel
,
Lease
from
.network
import
Interface
from
.network
import
Interface
from
.node
import
Node
,
Trait
from
.node
import
Node
,
Trait
from
.azure_virtual_machine_size
import
AzureVirtualMachineSize
from
.azure_builtin_template
import
AzureBuiltinVersion
logger
=
getLogger
(
__name__
)
logger
=
getLogger
(
__name__
)
pre_state_changed
=
Signal
(
providing_args
=
[
"new_state"
])
pre_state_changed
=
Signal
(
providing_args
=
[
"new_state"
])
...
@@ -259,6 +261,11 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -259,6 +261,11 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
objects
=
Manager
()
objects
=
Manager
()
active
=
QueryManager
(
destroyed_at
=
None
)
active
=
QueryManager
(
destroyed_at
=
None
)
azure_vm_size
=
ForeignKey
(
AzureVirtualMachineSize
,
verbose_name
=
_
(
'azure vm size'
))
azure_template
=
ForeignKey
(
AzureBuiltinVersion
,
verbose_name
=
_
(
'azure vm template'
))
class
Meta
:
class
Meta
:
app_label
=
'vm'
app_label
=
'vm'
db_table
=
'vm_instance'
db_table
=
'vm_instance'
...
...
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