Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
1698b3d4
authored
Nov 11, 2015
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard, vm, storage, settings: fix DataStore queries
parent
9c20e518
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
5 deletions
+20
-5
circle/circle/settings/base.py
+2
-0
circle/dashboard/management/commands/init.py
+3
-1
circle/dashboard/views/storage.py
+2
-2
circle/storage/models.py
+12
-1
circle/vm/models/instance.py
+1
-1
No files found.
circle/circle/settings/base.py
View file @
1698b3d4
...
...
@@ -84,6 +84,8 @@ ADMINS = (
EMAIL_SUBJECT_PREFIX
=
get_env_variable
(
'DJANGO_SUBJECT_PREFIX'
,
'[CIRCLE] '
)
DEFAULT_DATASTORE
=
get_env_variable
(
'DEFAULT_DATASTORE'
,
'default'
)
########## END MANAGER CONFIGURATION
...
...
circle/dashboard/management/commands/init.py
View file @
1698b3d4
...
...
@@ -22,6 +22,7 @@ from optparse import make_option
from
django.contrib.auth.models
import
User
from
django.core.management.base
import
BaseCommand
from
django.conf
import
settings
from
firewall.models
import
Vlan
,
VlanGroup
,
Domain
,
Firewall
,
Rule
from
storage.models
import
DataStore
...
...
@@ -73,7 +74,8 @@ class Command(BaseCommand):
admin
.
set_password
(
options
[
'admin_pass'
])
admin
.
save
()
self
.
create
(
DataStore
,
'path'
,
path
=
'/datastore'
,
name
=
'default'
,
self
.
create
(
DataStore
,
'path'
,
path
=
'/datastore'
,
name
=
settings
.
DEFAULT_DATASTORE
,
hostname
=
options
[
'datastore_queue'
])
# leases
...
...
circle/dashboard/views/storage.py
View file @
1698b3d4
...
...
@@ -37,13 +37,13 @@ class StorageDetail(SuperuserRequiredMixin, UpdateView):
template_name
=
"dashboard/storage/detail.html"
def
get_object
(
self
):
return
DataStore
.
objects
.
get
()
return
DataStore
.
get_default_datastore
()
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
StorageDetail
,
self
)
.
get_context_data
(
**
kwargs
)
ds
=
self
.
get_object
()
try
:
ds
=
self
.
get_object
()
context
[
'stats'
]
=
self
.
_get_stats
()
context
[
'missing_disks'
]
=
ds
.
get_missing_disks
()
context
[
'orphan_disks'
]
=
ds
.
get_orphan_disks
()
...
...
circle/storage/models.py
View file @
1698b3d4
...
...
@@ -24,6 +24,7 @@ from os.path import join
import
uuid
import
re
from
django.conf
import
settings
from
celery.contrib.abortable
import
AbortableAsyncResult
from
django.db.models
import
(
Model
,
BooleanField
,
CharField
,
DateTimeField
,
ForeignKey
)
...
...
@@ -109,6 +110,16 @@ class DataStore(Model):
disks
=
Disk
.
objects
.
filter
(
destroyed__isnull
=
True
,
is_ready
=
True
)
return
disks
.
exclude
(
filename__in
=
files
)
@classmethod
def
get_default_datastore
(
cls
):
try
:
datastore_name
=
settings
.
DEFAULT_DATASTORE
if
datastore_name
:
return
cls
.
objects
.
get
(
name
=
datastore_name
)
except
cls
.
DoesNotExist
:
pass
return
cls
.
objects
.
all
()[
0
]
# TODO
class
Disk
(
TimeStampedModel
):
...
...
@@ -413,7 +424,7 @@ class Disk(TimeStampedModel):
@classmethod
def
__create
(
cls
,
user
,
params
):
datastore
=
params
.
pop
(
'datastore'
,
DataStore
.
objects
.
get
())
datastore
=
params
.
pop
(
'datastore'
,
DataStore
.
get_default_datastore
())
filename
=
params
.
pop
(
'filename'
,
str
(
uuid
.
uuid4
()))
disk
=
cls
(
filename
=
filename
,
datastore
=
datastore
,
**
params
)
return
disk
...
...
circle/vm/models/instance.py
View file @
1698b3d4
...
...
@@ -488,7 +488,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
datastore
=
self
.
disks
.
all
()[
0
]
.
datastore
except
IndexError
:
from
storage.models
import
DataStore
datastore
=
DataStore
.
objects
.
get
()
datastore
=
DataStore
.
get_default_datastore
()
path
=
datastore
.
path
+
'/'
+
self
.
vm_name
+
'.dump'
return
{
'datastore'
:
datastore
,
'path'
:
path
}
...
...
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