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
7a2d1912
authored
8 years ago
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add storage profile creation on first datastore save.
parent
797305ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
1 deletions
+44
-1
circle/storage/migrations/0003_datastore_azure_id.py
+19
-0
circle/storage/models.py
+21
-1
circle/storage/tasks/storage_tasks.py
+4
-0
No files found.
circle/storage/migrations/0003_datastore_azure_id.py
0 → 100644
View file @
7a2d1912
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'storage'
,
'0002_disk_bus'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'datastore'
,
name
=
'azure_id'
,
field
=
models
.
TextField
(
null
=
True
,
verbose_name
=
'azure id'
),
),
]
This diff is collapsed.
Click to expand it.
circle/storage/models.py
View file @
7a2d1912
...
...
@@ -26,13 +26,14 @@ import re
from
celery.contrib.abortable
import
AbortableAsyncResult
from
django.db.models
import
(
Model
,
BooleanField
,
CharField
,
DateTimeField
,
ForeignKey
)
ForeignKey
,
TextField
)
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.urlresolvers
import
reverse
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
model_utils.models
import
TimeStampedModel
from
sizefield.models
import
FileSizeField
from
django.db.models.signals
import
post_save
from
.tasks
import
local_tasks
,
storage_tasks
from
celery.exceptions
import
TimeoutError
...
...
@@ -51,6 +52,7 @@ class DataStore(Model):
path
=
CharField
(
max_length
=
200
,
unique
=
True
,
verbose_name
=
_
(
'path'
))
hostname
=
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
_
(
'hostname'
))
azure_id
=
TextField
(
verbose_name
=
_
(
'azure id'
),
null
=
True
)
class
Meta
:
ordering
=
[
'name'
]
...
...
@@ -543,3 +545,20 @@ class Disk(TimeStampedModel):
@property
def
is_resizable
(
self
):
return
self
.
type
in
(
'qcow2-norm'
,
'raw-rw'
,
'qcow2-snap'
,
)
def
save_datastore_sender
(
sender
,
instance
,
created
=
False
,
**
kwargs
):
if
not
instance
.
azure_id
:
logger
.
debug
(
"Send azure create_azure_storage_profile task."
)
azure_id
=
storage_tasks
.
create_azure_storage_profile
.
apply_async
(
queue
=
'localhost.storage.fast'
,
args
=
[
instance
.
name
])
.
get
(
timeout
=
60
)
if
azure_id
:
logger
.
debug
(
"created storage profile with id:
%
s"
%
azure_id
)
instance
.
azure_id
=
azure_id
instance
.
save
()
else
:
logger
.
error
(
"couldn't create storage profile"
)
#TODO: implement update
post_save
.
connect
(
save_datastore_sender
,
sender
=
DataStore
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
circle/storage/tasks/storage_tasks.py
View file @
7a2d1912
...
...
@@ -18,6 +18,10 @@
from
manager.mancelery
import
celery
@celery.task
(
name
=
'storagedriver.create_azure_storage_profile'
)
def
create_azure_storage_profile
(
name
):
pass
@celery.task
(
name
=
'storagedriver.list'
)
def
list
(
dir
):
pass
...
...
This diff is collapsed.
Click to expand it.
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