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
0dbe809a
authored
Jul 12, 2016
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard, vm, storage, settings: fix DataStore queries with get_default_datastore()
parent
b02d4a32
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
6 deletions
+21
-6
circle/circle/settings/base.py
+2
-0
circle/dashboard/management/commands/init.py
+3
-1
circle/dashboard/views/storage.py
+2
-2
circle/fabfile.py
+1
-1
circle/storage/models.py
+12
-1
circle/vm/models/instance.py
+1
-1
No files found.
circle/circle/settings/base.py
View file @
0dbe809a
...
...
@@ -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 @
0dbe809a
...
...
@@ -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 @
0dbe809a
...
...
@@ -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/fabfile.py
View file @
0dbe809a
...
...
@@ -37,7 +37,7 @@ except Exception as e:
else
:
env
.
roledefs
[
'node'
]
=
[
unicode
(
n
.
host
.
ipv4
)
for
n
in
_Node
.
objects
.
filter
(
enabled
=
True
)]
env
.
roledefs
[
'storage'
]
=
[
_DataStore
.
objects
.
get
()
.
hostname
]
env
.
roledefs
[
'storage'
]
=
[
_DataStore
.
get_default_datastore
()
.
hostname
]
def
update_all
():
...
...
circle/storage/models.py
View file @
0dbe809a
...
...
@@ -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
)
...
...
@@ -110,6 +111,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
):
...
...
@@ -414,7 +425,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 @
0dbe809a
...
...
@@ -493,7 +493,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