Skip to content

Commit

Permalink
When database is dead, disk resize can be done
Browse files Browse the repository at this point in the history
  • Loading branch information
otherpirate committed Sep 20, 2016
1 parent 43f5462 commit c9607b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dbaas/logical/admin/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
from django.contrib.admin import site
from django.db import IntegrityError
from ..models import Database
from ..validators import check_is_database_enabled, check_resize_options
from ..validators import check_is_database_enabled, check_is_database_dead, \
check_resize_options
from ..errors import DisabledDatabase, NoResizeOption

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -799,6 +800,7 @@ def generate_random_string(length, stringset=string.ascii_letters + string.digit

def database_resize_view(self, request, database_id):
try:
check_is_database_dead(database_id, 'VM resize')
database = check_is_database_enabled(database_id, 'VM resize')

from dbaas_cloudstack.models import CloudStackPack
Expand Down
13 changes: 10 additions & 3 deletions dbaas/logical/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ def check_is_database_enabled(database_id, operation):
if database.is_in_quarantine:
raise DatabaseInQuarantineError(operation, url)

if database.is_dead() or not database.database_status.is_alive:
raise DatabaseIsDeadError(operation, url)

if database.is_beeing_used_elsewhere():
raise BusyDatabaseError(url)

Expand All @@ -41,6 +38,16 @@ def check_is_database_enabled(database_id, operation):

return database

def check_is_database_dead(database_id, operation):
from logical.models import Database
database = Database.objects.get(id=database_id)

url = _get_database_error_url(database_id)
if database.is_dead() or not database.database_status.is_alive:
raise DatabaseIsDeadError(operation, url)

return database


def check_resize_options(database_id, offerings):
if not offerings:
Expand Down

0 comments on commit c9607b5

Please sign in to comment.