Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
5
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
5069b23e
authored
Feb 23, 2023
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
datastore update
parent
8380e20d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
11 deletions
+39
-11
circle/dashboard/forms.py
+5
-2
circle/storage/migrations/0007_disk_cache_size.py
+18
-0
circle/storage/models.py
+12
-5
circle/vm/operations.py
+4
-4
No files found.
circle/dashboard/forms.py
View file @
5069b23e
...
@@ -90,11 +90,14 @@ class OperationForm(NoFormTagMixin, forms.Form):
...
@@ -90,11 +90,14 @@ class OperationForm(NoFormTagMixin, forms.Form):
class
VmSaveForm
(
OperationForm
):
class
VmSaveForm
(
OperationForm
):
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
'Name'
),
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
'Name'
),
help_text
=
_
(
'Human readable name of template.'
))
help_text
=
_
(
'Human readable name of template.'
))
datastore
=
forms
.
ModelChoiceField
(
queryset
=
None
,
initial
=
0
,
empty_label
=
None
,
help_text
=
_
(
'Backing file location'
))
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
default
=
kwargs
.
pop
(
'default'
,
None
)
default
=
kwargs
.
pop
(
'default'
,
None
)
clone
=
kwargs
.
pop
(
'clone'
,
False
)
clone
=
kwargs
.
pop
(
'clone'
,
False
)
super
(
VmSaveForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
VmSaveForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'datastore'
]
.
queryset
=
DataStore
.
objects
.
all
()
if
default
:
if
default
:
self
.
fields
[
'name'
]
.
initial
=
default
self
.
fields
[
'name'
]
.
initial
=
default
if
clone
:
if
clone
:
...
@@ -851,7 +854,7 @@ class VmCreateDiskForm(OperationForm):
...
@@ -851,7 +854,7 @@ class VmCreateDiskForm(OperationForm):
widget
=
FileSizeWidget
,
initial
=
(
10
<<
30
),
label
=
_
(
'Size'
),
widget
=
FileSizeWidget
,
initial
=
(
10
<<
30
),
label
=
_
(
'Size'
),
help_text
=
_
(
'Size of disk to create in bytes or with units '
help_text
=
_
(
'Size of disk to create in bytes or with units '
'like MB or GB.'
))
'like MB or GB.'
))
datastore
=
forms
.
ModelChoiceField
(
queryset
=
None
)
datastore
=
forms
.
ModelChoiceField
(
queryset
=
None
,
initial
=
0
,
empty_label
=
None
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
default
=
kwargs
.
pop
(
'default'
,
None
)
default
=
kwargs
.
pop
(
'default'
,
None
)
...
@@ -991,7 +994,7 @@ class VmImportDiskForm(OperationForm):
...
@@ -991,7 +994,7 @@ class VmImportDiskForm(OperationForm):
class
VmDownloadDiskForm
(
OperationForm
):
class
VmDownloadDiskForm
(
OperationForm
):
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
"Name"
),
required
=
False
)
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
"Name"
),
required
=
False
)
url
=
forms
.
CharField
(
label
=
_
(
'URL'
),
validators
=
[
URLValidator
(),
])
url
=
forms
.
CharField
(
label
=
_
(
'URL'
),
validators
=
[
URLValidator
(),
])
datastore
=
forms
.
ModelChoiceField
(
queryset
=
None
)
datastore
=
forms
.
ModelChoiceField
(
queryset
=
None
,
initial
=
0
,
empty_label
=
None
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
VmDownloadDiskForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
VmDownloadDiskForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
...
circle/storage/migrations/0007_disk_cache_size.py
0 → 100644
View file @
5069b23e
# Generated by Django 3.2.3 on 2023-01-13 16:40
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'storage'
,
'0006_auto_20221231_1011'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'disk'
,
name
=
'cache_size'
,
field
=
models
.
IntegerField
(
default
=
1024
,
help_text
=
'Disk metadata cache max size (Kbyte)'
,
verbose_name
=
'cache size'
),
),
]
circle/storage/models.py
View file @
5069b23e
...
@@ -29,7 +29,7 @@ from celery.result import allow_join_result
...
@@ -29,7 +29,7 @@ from celery.result import allow_join_result
from
celery.exceptions
import
TimeoutError
from
celery.exceptions
import
TimeoutError
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.db.models
import
(
Model
,
BooleanField
,
CharField
,
DateTimeField
,
from
django.db.models
import
(
Model
,
BooleanField
,
CharField
,
DateTimeField
,
IntegerField
,
ForeignKey
)
ForeignKey
)
from
django.db
import
models
from
django.db
import
models
from
django.utils
import
timezone
from
django.utils
import
timezone
...
@@ -147,6 +147,9 @@ class Disk(TimeStampedModel):
...
@@ -147,6 +147,9 @@ class Disk(TimeStampedModel):
destroyed
=
DateTimeField
(
blank
=
True
,
default
=
None
,
null
=
True
)
destroyed
=
DateTimeField
(
blank
=
True
,
default
=
None
,
null
=
True
)
ci_disk
=
BooleanField
(
default
=
False
)
ci_disk
=
BooleanField
(
default
=
False
)
is_ready
=
BooleanField
(
default
=
False
)
is_ready
=
BooleanField
(
default
=
False
)
cache_size
=
IntegerField
(
default
=
1024
,
help_text
=
_
(
"Disk metadata cache max size (Kbyte)"
),
verbose_name
=
_
(
'cache size'
))
class
Meta
:
class
Meta
:
ordering
=
[
'name'
]
ordering
=
[
'name'
]
...
@@ -346,7 +349,8 @@ class Disk(TimeStampedModel):
...
@@ -346,7 +349,8 @@ class Disk(TimeStampedModel):
'driver_cache'
:
self
.
datastore
.
driver_cache
,
'driver_cache'
:
self
.
datastore
.
driver_cache
,
'target_device'
:
self
.
device_type
+
self
.
dev_num
,
'target_device'
:
self
.
device_type
+
self
.
dev_num
,
'target_bus'
:
self
.
device_bus
,
'target_bus'
:
self
.
device_bus
,
'disk_device'
:
'cdrom'
if
self
.
type
==
'iso'
else
'disk'
'disk_device'
:
'cdrom'
if
self
.
type
==
'iso'
else
'disk'
,
'cache_size'
:
self
.
cache_size
}
}
def
get_disk_desc
(
self
):
def
get_disk_desc
(
self
):
...
@@ -358,7 +362,8 @@ class Disk(TimeStampedModel):
...
@@ -358,7 +362,8 @@ class Disk(TimeStampedModel):
'format'
:
self
.
format
,
'format'
:
self
.
format
,
'size'
:
self
.
size
,
'size'
:
self
.
size
,
'base_name'
:
self
.
base
.
filename
if
self
.
base
else
None
,
'base_name'
:
self
.
base
.
filename
if
self
.
base
else
None
,
'type'
:
'snapshot'
if
self
.
base
else
'normal'
'type'
:
'snapshot'
if
self
.
base
else
'normal'
,
'cache_size'
:
self
.
cache_size
}
}
def
get_remote_queue_name
(
self
,
queue_id
=
'storage'
,
priority
=
None
,
def
get_remote_queue_name
(
self
,
queue_id
=
'storage'
,
priority
=
None
,
...
@@ -559,7 +564,7 @@ class Disk(TimeStampedModel):
...
@@ -559,7 +564,7 @@ class Disk(TimeStampedModel):
args
=
[
self
.
datastore
.
path
,
self
.
filename
],
args
=
[
self
.
datastore
.
path
,
self
.
filename
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
def
save_as
(
self
,
task
=
None
,
user
=
None
,
task_uuid
=
None
,
timeout
=
300
):
def
save_as
(
self
,
task
=
None
,
user
=
None
,
task_uuid
=
None
,
datastore
=
None
,
timeout
=
300
):
"""Save VM as template.
"""Save VM as template.
Based on disk type:
Based on disk type:
...
@@ -588,7 +593,9 @@ class Disk(TimeStampedModel):
...
@@ -588,7 +593,9 @@ class Disk(TimeStampedModel):
new_type
,
new_base
=
mapping
[
self
.
type
]
new_type
,
new_base
=
mapping
[
self
.
type
]
disk
=
Disk
.
create
(
datastore
=
self
.
datastore
,
if
not
datastore
:
datastore
=
self
.
datastore
disk
=
Disk
.
create
(
datastore
=
datastore
,
base
=
new_base
,
base
=
new_base
,
name
=
self
.
name
,
size
=
self
.
size
,
name
=
self
.
name
,
size
=
self
.
size
,
type
=
new_type
,
dev_num
=
self
.
dev_num
)
type
=
new_type
,
dev_num
=
self
.
dev_num
)
...
...
circle/vm/operations.py
View file @
5069b23e
...
@@ -857,7 +857,7 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -857,7 +857,7 @@ class SaveAsTemplateOperation(InstanceOperation):
disk
.
destroy
()
disk
.
destroy
()
def
_operation
(
self
,
activity
,
user
,
system
,
name
=
None
,
def
_operation
(
self
,
activity
,
user
,
system
,
name
=
None
,
with_shutdown
=
True
,
clone
=
False
,
task
=
None
,
**
kwargs
):
with_shutdown
=
True
,
clone
=
False
,
task
=
None
,
datastore
=
'default'
,
**
kwargs
):
try
:
try
:
self
.
instance
.
_cleanup
(
parent_activity
=
activity
,
user
=
user
)
self
.
instance
.
_cleanup
(
parent_activity
=
activity
,
user
=
user
)
except
:
except
:
...
@@ -898,9 +898,9 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -898,9 +898,9 @@ class SaveAsTemplateOperation(InstanceOperation):
from
storage.models
import
Disk
from
storage.models
import
Disk
def
__try_save_disk
(
disk
):
def
__try_save_disk
(
disk
,
datastore
):
try
:
try
:
return
disk
.
save_as
(
task
)
return
disk
.
save_as
(
task
,
datastore
=
datastore
)
except
Disk
.
WrongDiskTypeError
:
except
Disk
.
WrongDiskTypeError
:
return
disk
return
disk
...
@@ -913,7 +913,7 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -913,7 +913,7 @@ class SaveAsTemplateOperation(InstanceOperation):
ugettext_noop
(
"saving disk
%(name)
s"
),
ugettext_noop
(
"saving disk
%(name)
s"
),
name
=
disk
.
name
)
name
=
disk
.
name
)
):
):
self
.
disks
.
append
(
__try_save_disk
(
disk
))
self
.
disks
.
append
(
__try_save_disk
(
disk
,
datastore
=
datastore
))
# create template and do additional setup
# create template and do additional setup
tmpl
=
InstanceTemplate
(
**
params
)
tmpl
=
InstanceTemplate
(
**
params
)
...
...
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