Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion dbaas/logical/admin/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def name_html(self, database):
return show_info_popup(
database.name, "Show Endpoint", ed_point,
"icon-info-sign", "show-endpoint"
) + self.quarantine_html(database) + self.attention_html(database)
) + self.quarantine_html(database) + self.attention_html(database) + self.manually_stopped_html(database)

name_html.short_description = _("name")
name_html.admin_order_field = "name"
Expand All @@ -241,6 +241,14 @@ def quarantine_html(self, database):

return format_html(quarantine)

def manually_stopped_html(self, database):
html_default = '<span class="label label-{}">{}</span>'
manually_stopped = ""
if database.was_manually_stopped:
manually_stopped = html_default.format("important", "Manually Stopped")

return format_html(manually_stopped)

def attention_html(self, database):
html_default = '<span id="att-btn" title="Click Me!" onclick="showAttentionDetails(\''+database.attention_description+'\', this)" ' \
'class="label label-{}" style="cursor:pointer;">{}</span>'
Expand Down

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dbaas/logical/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ class Database(BaseModel):
is_monitoring = models.BooleanField(
verbose_name=_("Is database being monitored?"), default=True
)
was_manually_stopped = models.BooleanField(
verbose_name=_("The database was manually stoppped?"), default=False
)
attention = models.BooleanField(
verbose_name=_("The database has GCP divergences?"), default=False, blank=True
)
Expand Down
3 changes: 3 additions & 0 deletions dbaas/logical/templates/logical/database/details/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ <h1>
{% if database.attention %}
<span class="label label-warning title_tag" id="att_tag">Attention!</span>
{% endif %}
{% if database.was_manually_stopped %}
<span class="label label-important" style="vertical-align: middle;">Manually Stopped</span>
{% endif %}
<a target="_blank" id="task_running"></a>
<div id="running_label"></div>
</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,12 @@
value = $("#id_start_stop_database").val();
if(value.includes('Stop')){
url = "/logical/stop_database/"+ database_id;
att_manually_stopped = true;
}else{
url = "/logical/start_database/"+ database_id;
att_manually_stopped = false
}

jQuery.ajax({
"dataType": "json",
"url": url,
Expand Down
6 changes: 5 additions & 1 deletion dbaas/logical/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.conf.urls import patterns, url
from .views import refresh_status, toggle_monitoring, start_database_vm, stop_database_vm, set_attention, funct_send_all_chg
from .views import (refresh_status, toggle_monitoring, start_database_vm, stop_database_vm, set_attention,
funct_send_all_chg, set_manually_stopped)
from .views import (CredentialView, CredentialSSLView,
credential_parameter_by_name, check_offering_sizes)

Expand All @@ -21,6 +22,9 @@
url(r"^toggle_monitoring/(?P<database_id>\d*)$",
toggle_monitoring,
name="toggle_monitoring"),
url(r"^set_manually_stopped/(?P<database_id>\d*)$",
set_manually_stopped,
name="set_manually_stopped"),
url(r"^send_all_chg/(?P<database_id>\d*)$",
funct_send_all_chg,
name="marked_to_send_all_changes_to_service_now"),
Expand Down
13 changes: 13 additions & 0 deletions dbaas/logical/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,19 @@ def toggle_monitoring(request, database_id):
return HttpResponse(output, content_type="application/json")


def set_manually_stopped(request, database_id):
try:
database = Database.objects.get(id=database_id)
except (Database.DoesNotExist, ValueError):
return
database.was_manually_stopped = request.GET.get('manually_stopped') == 'true'
database.save()
instances_status = []
output = json.dumps({'database_status': database.status_html,
'instances_status': instances_status})
return HttpResponse(output, content_type="application/json")


def funct_send_all_chg(request, database_id):
try:
database = Database.objects.get(id=database_id)
Expand Down
3 changes: 3 additions & 0 deletions dbaas/maintenance/task_start_database_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def task_start_database_vm(database, task, retry_from=None):
if steps_for_instances(
steps, instances_to_start_database_vm, task, start_database_vm.update_step, since_step=since_step
):
database.was_manually_stopped = False
database.save()

database.update_status()
start_database_vm.set_success()
task.set_status_success('Starting Database is done')
Expand Down
4 changes: 4 additions & 0 deletions dbaas/maintenance/task_stop_database_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def task_stop_database_vm(database, task, retry_from=None):
if steps_for_instances(
steps, instances_to_stop_database_vm, task, stop_database_vm.update_step, since_step=since_step
):

database.was_manually_stopped = True
database.save()

database.update_status()
stop_database_vm.set_success()
task.set_status_success('Stopping Database is done')
Expand Down