def _vm_resize(request, database): try: check_is_database_dead(database.id, 'VM resize') check_is_database_enabled(database.id, 'VM resize') except DisabledDatabase as err: messages.add_message(request, messages.ERROR, err.message) else: offering = Offering.objects.get(id=request.POST.get('vm_offering')) Database.resize( database=database, offering=offering, user=request.user, )
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 offerings = CloudStackPack.objects.filter( offering__region__environment=database.environment, engine_type__name=database.engine_type).exclude( offering__serviceofferingid=database.offering_id) check_resize_options(database_id, offerings) except (DisabledDatabase, NoResizeOption) as err: self.message_user(request, err.message, messages.ERROR) return HttpResponseRedirect(err.url) form = None if request.method == 'POST': # If the form has been submitted... form = ResizeDatabaseForm( request.POST, initial={ "database_id": database_id, "original_offering_id": database.offering_id }, ) # A form bound to the POST data if form.is_valid(): # All validation rules pass cloudstackpack = CloudStackPack.objects.get( id=request.POST.get('target_offer')) Database.resize( database=database, cloudstackpack=cloudstackpack, user=request.user, ) url = reverse('admin:notification_taskhistory_changelist') # Redirect after POST return HttpResponseRedirect(url + "?user=%s" % request.user.username) else: form = ResizeDatabaseForm(initial={ "database_id": database_id, "original_offering_id": database.offering_id }, ) # An unbound form return render_to_response("logical/database/resize.html", locals(), context_instance=RequestContext(request))
def _vm_resize(request, database): try: check_is_database_dead(database.id, 'VM resize') check_is_database_enabled(database.id, 'VM resize') except DisabledDatabase as err: messages.add_message(request, messages.ERROR, err.message) else: cloudstack_pack = CloudStackPack.objects.get( id=request.POST.get('vm_offering')) Database.resize( database=database, cloudstackpack=cloudstack_pack, user=request.user, )
def _vm_resize(request, database): try: check_is_database_dead(database.id, 'VM resize') check_is_database_enabled(database.id, 'VM resize') except DisabledDatabase as err: messages.add_message(request, messages.ERROR, err.message) else: offering = Offering.objects.get( id=request.POST.get('vm_offering') ) Database.resize( database=database, offering=offering, user=request.user, )