Skip to content

Commit 20f0fd0

Browse files
IAGO HENRIQUEIAGO HENRIQUE
authored andcommitted
Merge remote-tracking branch 'refs/remotes/origin/dev' into dev
2 parents 6310ae1 + 680abe3 commit 20f0fd0

File tree

12 files changed

+233
-85
lines changed

12 files changed

+233
-85
lines changed

dbaas/drivers/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ def get_slave_instances(self, ):
307307

308308
return instances
309309

310+
def get_temporary_instances(self):
311+
instances = [instance if instance.temporary is True else None
312+
for instance in self.databaseinfra.instances.all()]
313+
return filter(None, instances)
314+
310315
def start_slave(self, instance):
311316
pass
312317

dbaas/drivers/replication_topologies/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_resize_steps(self):
6161
'workflow.steps.util.infra.Offering',
6262
'workflow.steps.util.vm.InstanceIsSlave',
6363
'workflow.steps.util.zabbix.EnableAlarms',
64-
)}]
64+
)}] + self.get_configure_db_params_steps()
6565

6666
def get_upgrade_disk_type_steps(self):
6767
return [{
@@ -268,7 +268,8 @@ def get_add_database_instances_steps(self):
268268
self.get_add_database_instances_steps_description():
269269
self.get_add_database_instances_first_steps() +
270270
self.get_add_database_instances_middle_steps() +
271-
self.get_add_database_instances_last_steps()
271+
self.get_add_database_instances_last_steps() +
272+
self.get_configure_db_params_steps()
272273
}]
273274

274275
def get_remove_readonly_instance_steps(self):
@@ -384,7 +385,7 @@ def get_reinstallvm_steps(self):
384385
'workflow.steps.util.database.CheckIsUp',
385386
'workflow.steps.util.metric_collector.RestartTelegraf',
386387
),
387-
}] + self.get_reinstallvm_steps_final()
388+
}] + self.get_reinstallvm_steps_final() + self.get_configure_db_params_steps()
388389

389390
def get_reinstallvm_ssl_steps(self):
390391
return ()

dbaas/drivers/replication_topologies/mongodb.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ def get_configure_ssl_dns_steps(self):
179179
'workflow.steps.util.ssl.SetSSLFilesAccessMongoDBIfConfigured',
180180
'workflow.steps.util.ssl.UpdateExpireAtDate',
181181
)
182+
183+
def get_configure_db_params_steps(self):
184+
return []
182185

183186

184187
class MongoDBSingle(BaseMongoDB):
@@ -285,7 +288,7 @@ def get_deploy_steps(self):
285288
'Save Snapshot': (
286289
'workflow.steps.util.database.MakeSnapshot',
287290
)}
288-
]
291+
] + self.get_configure_db_params_steps()
289292

290293
def get_host_migrate_steps(self):
291294
return [{
@@ -748,7 +751,7 @@ def get_deploy_steps(self):
748751
'Save Snapshot': (
749752
'workflow.steps.util.database.MakeSnapshot',
750753
)
751-
}]
754+
}] + self.get_configure_db_params_steps()
752755

753756
def get_clone_steps(self):
754757
return [{
@@ -915,10 +918,13 @@ def get_recreate_slave_steps(self):
915918
'workflow.steps.util.zabbix.EnableAlarms',
916919
'workflow.steps.util.database.ConfigurePrometheusMonitoring'
917920
)
918-
}]
921+
}] + self.get_configure_db_params_steps()
919922

920923
def get_auto_upgrade_database_vm_offering(self):
921924
return [{
925+
'Take new Snapshot': (
926+
'workflow.steps.util.volume_provider.TakeSnapshotForSecondaryOrReadOnly',
927+
)}, {
922928
'Create new VM': (
923929
'workflow.steps.util.infra.OfferingAutoUpgrade',
924930
'workflow.steps.util.host_provider.AllocateIPTemporaryInstance',
@@ -1010,7 +1016,7 @@ def get_auto_upgrade_database_vm_offering(self):
10101016
'workflow.steps.util.host_provider.DestroyVirtualMachineTemporaryInstance',
10111017
'workflow.steps.util.host_provider.DestroyIPTemporaryInstance',
10121018
)}
1013-
]
1019+
] + self.get_configure_db_params_steps()
10141020

10151021
def get_host_migrate_steps(self):
10161022
return [{
@@ -1565,7 +1571,7 @@ def get_resize_steps(self):
15651571
'workflow.steps.util.infra.Offering',
15661572
'workflow.steps.util.vm.InstanceIsSlave',
15671573
# 'workflow.steps.util.zabbix.EnableAlarms',
1568-
)}]
1574+
)}] + self.get_configure_db_params_steps()
15691575

15701576
def get_deploy_steps(self):
15711577
return [{
@@ -1629,7 +1635,7 @@ def get_deploy_steps(self):
16291635
'Save Snapshot': (
16301636
'workflow.steps.util.database.MakeSnapshot',
16311637
)
1632-
}]
1638+
}] + self.get_configure_db_params_steps()
16331639

16341640

16351641
class MongoGenericGCE(object):
@@ -1663,7 +1669,10 @@ def get_recreate_slave_steps(self):
16631669
'workflow.steps.util.zabbix.EnableAlarms',
16641670
'workflow.steps.util.database.ConfigurePrometheusMonitoring'
16651671
)
1666-
}]
1672+
}] + self.get_configure_db_params_steps()
1673+
1674+
def get_configure_db_params_steps(self):
1675+
return []
16671676

16681677
def get_replica_migration_steps(self):
16691678
return [{

dbaas/drivers/replication_topologies/mysql.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def get_deploy_steps(self):
209209
'Save Snapshot': (
210210
'workflow.steps.util.database.MakeSnapshot',
211211
)
212-
}]
212+
}] + self.get_configure_db_params_steps()
213213

214214
def get_configure_db_params_steps(self):
215215
return [{
@@ -608,7 +608,7 @@ def get_deploy_steps(self):
608608
'Save Snapshot': (
609609
'workflow.steps.util.database.MakeSnapshot',
610610
)
611-
}]
611+
}] + self.get_configure_db_params_steps()
612612

613613
def get_clone_steps(self):
614614
return [{
@@ -894,7 +894,7 @@ def get_reinstallvm_steps(self):
894894
'workflow.steps.util.database.CheckIsUp',
895895
'workflow.steps.util.metric_collector.RestartTelegraf',
896896
),
897-
}] + self.get_reinstallvm_steps_final()
897+
}] + self.get_reinstallvm_steps_final() + self.get_configure_db_params_steps()
898898

899899
def get_upgrade_steps(self):
900900
return [{
@@ -1175,7 +1175,7 @@ def get_recreate_slave_steps(self):
11751175
'workflow.steps.util.zabbix.EnableAlarms',
11761176
'workflow.steps.util.database.ConfigurePrometheusMonitoring'
11771177
)
1178-
}]
1178+
}] + self.get_configure_db_params_steps()
11791179

11801180
def get_base_host_migrate_steps(self):
11811181
return (
@@ -2490,7 +2490,7 @@ def get_recreate_slave_steps(self):
24902490
'workflow.steps.util.zabbix.EnableAlarms',
24912491
'workflow.steps.util.database.ConfigurePrometheusMonitoring'
24922492
)
2493-
}]
2493+
}] + self.get_configure_db_params_steps()
24942494

24952495
def get_reinstallvm_steps(self):
24962496
return [{
@@ -2528,4 +2528,4 @@ def get_reinstallvm_steps(self):
25282528
'workflow.steps.util.database.CheckIsUp',
25292529
'workflow.steps.util.metric_collector.RestartTelegraf',
25302530
),
2531-
}] + self.get_reinstallvm_steps_final()
2531+
}] + self.get_reinstallvm_steps_final() + self.get_configure_db_params_steps()

dbaas/drivers/replication_topologies/redis.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# -*- coding: utf-8 -*-
23
from base import BaseTopology, InstanceDeploy
34
from physical.models import Instance
@@ -56,6 +57,9 @@ def get_database_change_persistence_steps(self):
5657
'workflow.steps.util.zabbix.EnableAlarms',
5758
)
5859
}]
60+
61+
def get_configure_db_params_steps(self):
62+
return []
5963

6064

6165
class RedisSingle(BaseRedis):
@@ -123,7 +127,7 @@ def get_deploy_steps(self):
123127
'Save Snapshot': (
124128
'workflow.steps.util.database.MakeSnapshot',
125129
)
126-
}]
130+
}] + self.get_configure_db_params_steps()
127131

128132
def get_clone_steps(self):
129133
return [{
@@ -494,7 +498,7 @@ def get_deploy_steps(self):
494498
'Save Snapshot': (
495499
'workflow.steps.util.database.MakeSnapshot',
496500
)
497-
}]
501+
}] + self.get_configure_db_params_steps()
498502

499503
def get_clone_steps(self):
500504
return [{
@@ -824,7 +828,7 @@ def get_deploy_steps(self):
824828
'Save Snapshot': (
825829
'workflow.steps.util.database.MakeSnapshot',
826830
)
827-
}]
831+
}] + self.get_configure_db_params_steps()
828832

829833
def get_filer_migrate_steps(self):
830834
return [{

dbaas/logical/templates/logical/database/details/parameters_tab.html

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="panel-heading">
77
<h3 class="panel-title">Custom Parameters</h3>
88
{% if show_auto_configure_btn %}
9-
<a href="{% url 'auto_configure_db_params_btn' database.id %}" target="_blank" class="btn btn-primary">AutoConfigure DB Params</a>
9+
<a href="#" data-toggle="modal" id="autoconfig_btn" data-target="#autoconfig_params" target="_blank" class="btn btn-primary">AutoConfigure DB Params</a>
1010
<em>* Atualiza somente o max_connections (MySQL) e não gera downtime!</em>
1111
{% endif %}
1212
</div>
@@ -166,6 +166,8 @@ <h3 class="panel-title">Custom Parameters</h3>
166166
</div>
167167
</div>
168168
{% endif %}
169+
{% include "admin/confirmation_modal.html" with modal_id="autoconfig_params" confirmation_message="Are you sure you want to AutoConfigure database parameters now?" box_title="AutoConfigure Params" button_type="button" button_value="Auto Configure Parameters" button_name="autoconfig_params_confirm" id_optional="id=id_autoconfig_params" %}
170+
169171
{% endblock %}
170172

171173
{% block js_footer %}
@@ -174,6 +176,7 @@ <h3 class="panel-title">Custom Parameters</h3>
174176
<script src="{% static "assets/js/bignumber.min.js" %}"></script>
175177
<script src="{% static "js/parameters_validator.js" %}"></script>
176178
<script type="text/javascript">
179+
var database_id = '{{ database.id }}';
177180

178181
function resetDefault(checkbox_control, id)
179182
{
@@ -241,8 +244,31 @@ <h3 class="panel-title">Custom Parameters</h3>
241244
});
242245
$("#id_change_parameter_yes").keyup();
243246

247+
running_update = false
248+
244249
})
245250

251+
$("#id_autoconfig_params").on("click", function() {
252+
if (running_update){
253+
return;
254+
}
255+
running_update = true;
256+
$("#id_autoconfig_params").attr('disabled','disabled');
257+
url = "/logical/autoconfigure_db_params/"+ database_id;
258+
259+
jQuery.ajax({
260+
"dataType": "json",
261+
"url": url,
262+
"type": "GET"
263+
}).success(function() {
264+
running_update = false;
265+
window.location.reload();
266+
267+
}).error(function() {
268+
alert("invalid server response")
269+
});
270+
});
271+
246272
function check_static_parameter_changed()
247273
{
248274
var inputs = $("input, select");

dbaas/logical/templates/logical/database/details/resizes_tab.html

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,14 @@
4545
<div class="control-group">
4646
<div class="control-label"><label>AutoResize:</label></div>
4747
<div class="controls">
48-
<a href="{% url 'resize_vm_from_btn' database.id 'cpu_ram' %}" target="_blank" class="btn btn-success">Resize CPU & RAM</a>
49-
<a href="{% url 'resize_vm_from_btn' database.id 'cpu' %}" target="_blank" class="btn btn-primary">Resize CPU</a>
50-
<a href="{% url 'resize_vm_from_btn' database.id 'ram' %}" target="_blank" class="btn btn-info">Resize RAM</a>
48+
<a href="#" target="_blank" class="btn btn-success autoupgrade_database_btn" data-toggle="modal" id="cpu_ram" data-target="#autoupgrade_vm">Resize CPU & RAM</a>
49+
<a href="#" target="_blank" class="btn btn-primary autoupgrade_database_btn" data-toggle="modal" id="cpu" data-target="#autoupgrade_vm">Resize CPU</a>
50+
<a href="#" target="_blank" class="btn btn-info autoupgrade_database_btn" data-toggle="modal" id="ram" data-target="#autoupgrade_vm">Resize RAM</a>
5151
</div>
5252
</div>
5353
{% endif %}
5454
{% endif %}
55-
<!-- <div class="control-group">-->
56-
<!-- <div class="control-label"><label>Disk offering:</label></div>-->
57-
<!-- <div class="controls">-->
58-
<!-- <select id="id_disk_offering" name="disk_offering">-->
59-
<!-- {% for disk_offering in disk_offerings %}-->
60-
<!-- <option value="{{disk_offering.id}}"-->
61-
<!-- {% if disk_offering == database.infra.disk_offering %}-->
62-
<!-- selected="selected">*-->
63-
<!-- {% else %}-->
64-
<!-- >-->
65-
<!-- {% endif %}-->
66-
<!-- {{disk_offering}}-->
67-
<!-- </option>-->
68-
<!-- {% endfor %}-->
69-
<!-- </select>-->
70-
<!-- <button data-toggle="modal" id="disk_resize_btn" data-target="#resize_disk">Resize</button>-->
71-
<!-- </div>-->
72-
<!-- </div>-->
73-
<!-- <div class="control-group">-->
74-
<!-- <div class="controls">-->
75-
<!-- <label class="checkbox">-->
76-
<!-- <input {% if database.disk_auto_resize %} checked="checked" {% endif %} id="id_disk_auto_resize" name="disk_auto_resize" type="checkbox"/>-->
77-
<!-- <span><label class="vCheckboxLabel" for="id_disk_auto_resize">Disk auto resize</label></span>-->
78-
<!-- </label>-->
79-
<!-- <p class="help-block">When marked, the disk will be resized automatically.</p>-->
80-
<!-- </div>-->
81-
<!-- </div>-->
55+
8256
{% if available_patches %}
8357
<div class="control-group">
8458
<div class="control-label"><label>Patch upgrade:</label></div>
@@ -114,6 +88,7 @@
11488

11589
{% include "admin/confirmation_modal_input.html" with modal_id="resize_vm" title="Resize VM" body_text="logical/modal/vm_offering_body.html" input_name="resize_vm_yes" submit_button_value="Resize" submit_button_name="vm_resize" submit_button_id="id_resize_vm_btn_modal" %}
11690

91+
{% include "admin/confirmation_modal.html" with modal_id="autoupgrade_vm" confirmation_message="Are you sure you want AutoUpgrade database offer now?" box_title="AutoUpgrade Offer" button_type="button" button_value="AutoUpgrade Database" button_name="autoupgrade_db_confirm" id_optional="id=id_autoupgrade_db" %}
11792

11893
{% endblock %}
11994

@@ -122,6 +97,9 @@
12297
{{ block.super }}
12398

12499
<script>
100+
var database_id = '{{ database.id }}';
101+
var running_update = false;
102+
125103
function status_resize(btn_id, current_value, selected_value) {
126104
btn = document.getElementById(btn_id)
127105
btn.disabled = current_value == selected_value
@@ -146,6 +124,32 @@
146124
}
147125
});
148126
}
127+
128+
$(".autoupgrade_database_btn").click(function() {
129+
$("#id_autoupgrade_db").val($(this).attr('id'));
130+
});
131+
132+
$("#id_autoupgrade_db").on("click", function() {
133+
if (running_update){
134+
return;
135+
}
136+
running_update = true;
137+
$("#id_autoupgrade_db").attr('disabled','disabled');
138+
value = $("#id_autoupgrade_db").val();
139+
url = "/logical/resize_vm/"+ database_id + "/" + value;
140+
141+
jQuery.ajax({
142+
"dataType": "json",
143+
"url": url,
144+
"type": "GET"
145+
}).success(function(){
146+
running_update = false;
147+
window.location.reload();
148+
}).error(function() {
149+
alert("invalid server response");
150+
});
151+
});
152+
149153
jQuery(document).ready(function($) {
150154
document.onkeydown = function () {
151155
switch (event.keyCode) {
@@ -157,6 +161,7 @@
157161
}
158162
}
159163
}
164+
160165
var currentForm;
161166

162167
$("#id_disk_offering").on("change", function() {

dbaas/logical/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,8 +2761,7 @@ def resize_vm_from_btn(request, database_id, resize_target):
27612761
database=database, user=user, resize_target=resize_target
27622762
)
27632763

2764-
future_offering = database.get_future_offering(resize_target)
2765-
return HttpResponse(json.dumps({'future_offering': future_offering.name}), content_type="application/json")
2764+
return HttpResponse(json.dumps({}), content_type="application/json")
27662765

27672766

27682767
@login_required()
@@ -2779,4 +2778,4 @@ def auto_configure_db_params_btn(request, database_id):
27792778
database=database, user=user
27802779
)
27812780

2782-
return HttpResponse(({'success'}), content_type="application/json")
2781+
return HttpResponse(json.dumps({}), content_type="application/json")

0 commit comments

Comments
 (0)