1 {% extends 'admin/change_form.html' %}
6 {% for dn in deployment_nodes %}
7 [{{ dn.0 }}, {{ dn.1 }} , "{{ dn.2 }}"],
11 deployment_flavors = [
12 {% for dn in deployment_flavors %}
13 [{{ dn.0 }}, {{ dn.1 }} , "{{ dn.2 }}"],
18 {% for dn in deployment_images %}
19 [{{ dn.0 }}, {{ dn.1 }} , "{{ dn.2 }}"],
24 {% for s in site_login_bases %}
25 [{{ s.0 }}, "{{ s.1 }}"],
29 function option_html(val, text, selected) {
31 return '<option value="' + val + '" selected>' + text + '</option>\n';
33 return '<option value="' + val + '">' + text + '</option>\n';
37 function update_nodes(deployment_select, flavor_select, node_select) {
38 deployment_id = $(deployment_select).val();
39 node_id = $(node_select).val();
40 flavor_name = $(flavor_select).children(":selected").text()
42 for (i in deployment_nodes) {
43 // this is for EC2, where the node hostnames imply the flavor.
44 dn = deployment_nodes[i];
45 if ((dn[0] == deployment_id) && (dn[2].lastIndexOf(flavor_name,0) === 0)) {
46 html = html + option_html(dn[1], dn[2], dn[1]==node_id);
50 // now try it without the flavor hostname prefix matching
51 for (i in deployment_nodes) {
52 dn = deployment_nodes[i];
53 if (dn[0] == deployment_id) {
54 html = html + option_html(dn[1], dn[2], dn[1]==node_id);
58 html = "<option value=''>---------</option>\n" + html;
59 node_select.empty().append(html);
62 function update_flavors(deployment_select, flavor_select) {
63 deployment_id = $(deployment_select).val();
64 flavor_id = $(flavor_select).val();
65 html = "<option value=''>---------</option>\n";
66 for (i in deployment_flavors) {
67 dn = deployment_flavors[i];
68 if (dn[0] == deployment_id) {
69 html = html + option_html(dn[1], dn[2], dn[1] == flavor_id);
72 flavor_select.empty().append(html);
75 function update_images(deployment_select, image_select) {
76 deployment_id = $(deployment_select).val();
77 image_id = $(image_select).val();
78 html = "<option value=''>---------</option>\n";
79 for (i in deployment_images) {
80 dn = deployment_images[i];
81 if (dn[0] == deployment_id) {
82 html = html + option_html(dn[1], dn[2], dn[1] == image_id);
85 image_select.empty().append(html);
88 function sliver_deployment_changed(any_control) {
89 /* This function handles someone changing the deployment control
90 in the add-sliver line. It updats the flavors and nodes dialogs
94 /* the inscrutable jquery selector below says:
95 find the closest parent "tr" to the current element
96 then find the child with class "field-deployment"
97 then find the child with that is a select
99 then turn it into a jquery object
101 deployment_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-deployment select')[0].id);
102 node_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-node select')[0].id);
103 flavor_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-flavor select')[0].id);
104 image_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-image select')[0].id);
105 update_nodes(deployment_select, flavor_select, node_select);
106 update_flavors(deployment_select, flavor_select);
107 update_images(deployment_select, image_select);
110 function sliver_flavor_changed(any_control) {
111 /* this is like sliver_flavor changed, but does not update the flavors
114 deployment_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-deployment select')[0].id);
115 node_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-node select')[0].id);
116 flavor_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-flavor select')[0].id);
117 update_nodes(deployment_select, flavor_select, node_select);
120 function update_slice_prefix(site_select, slice_name_id) {
121 site_id = $(site_select).val();
123 for (i in site_login_bases) {
124 if (site_login_bases[i][0] == site_id) {
125 slice_prefix=site_login_bases[i][1]+"_";
128 $("#"+slice_name_id).val(slice_prefix);