Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add Sensor DE UI to webpage

  • Loading branch information...
commit f0b44153db220901abc2c348d6938e92bc0632b0 1 parent c0e0579
Patrick Armstrong authored November 19, 2012
68  phantomweb/static/css/phantom_domain.css
... ...
@@ -1,3 +1,9 @@
  1
+
  2
+#loading
  3
+{
  4
+    height: 23px;
  5
+}
  6
+
1 7
 #phantom_domain_content
2 8
 {
3 9
     display: table;
@@ -10,10 +16,50 @@
10 16
     height: 25px;
11 17
 }
12 18
 
  19
+#phantom_domain_list_pane
  20
+{
  21
+    float: left;
  22
+    position: relative;
  23
+    overflow: hidden;
  24
+    width: 12%%;
  25
+    height: 410px;
  26
+    margin: 4px;
  27
+    margin-left: 0px;
  28
+    margin-right: 1px;
  29
+    padding-left: 0px;
  30
+    padding-right: 0px;
  31
+    padding-top: 0px;
  32
+}
  33
+
  34
+#phantom_domain_list_domains
  35
+{
  36
+    height: 400px;
  37
+    overflow: hidden;
  38
+    padding: 4px;
  39
+    margin: -5px -20px -5px -5px;
  40
+}
  41
+
  42
+#phantom_domain_button_add_div
  43
+{
  44
+    padding-top: 0;
  45
+}
  46
+
  47
+#phantom_domain_button_add
  48
+{
  49
+    width: 100%;
  50
+    margin-left: auto;
  51
+    margin-right: auto;
  52
+}
  53
+
13 54
 #phantom_domain_main_combined_pane
14 55
 {
15 56
     float: left;
16 57
     position: relative;
  58
+    width: 38%;
  59
+}
  60
+
  61
+.phantom_domain_de_pref {
  62
+    display: none;
17 63
 }
18 64
 
19 65
 .phantom_domain_section_div
@@ -34,7 +80,7 @@
34 80
 .phantom_domain_label
35 81
 {
36 82
     display: inline-block;
37  
-    width: 40%;
  83
+    width: 45%;
38 84
 }
39 85
 
40 86
 .phantom_domain_value
@@ -67,7 +113,8 @@
67 113
 #phantom_domain_details_pane
68 114
 {
69 115
     position: relative;
70  
-    float: right;
  116
+    float: left;
  117
+    width: 41%;
71 118
 }
72 119
 
73 120
 #phantom_domain_details_filter_div
@@ -84,26 +131,21 @@
84 131
 .phantom_domain_form_pane
85 132
 {
86 133
     border: solid;
87  
-    border-color: black;
  134
+    border-color: #AAA;
88 135
     border-width: 1px;
89 136
     padding: 10px;
90  
-    margin: 4px;
91 137
     height: 400px;
92  
-    width: 45%;
93  
-    margin-left: 5px;
94  
-    margin-right: 5px;
  138
+    margin: 4px;
  139
+    margin-left: 0px;
  140
+    margin-right: 1px;
95 141
 }
96 142
 
97 143
 .phantom_domain_control_buttons
98 144
 {
99  
-    margin-left: 75px;
  145
+    margin-left: auto;
  146
+    margin-right: auto;
100 147
 }
101 148
 
102  
-#phantom_domain_list_domains
103  
-{
104  
-    width: 400px;
105  
-    height: 200px;
106  
-}
107 149
 
108 150
 .phantom_domain_combo
109 151
 {
354  phantomweb/static/js/phantom_domain.js
... ...
@@ -1,39 +1,78 @@
1 1
 var g_domain_data = {};
2 2
 var g_launch_config_names = {};
3 3
 var g_domain_details = {};
  4
+var g_decision_engines_by_name = {'Sensor': 'sensor', 'Multi Cloud': 'multicloud'};
  5
+var g_decision_engines_by_type = {'sensor': 'Sensor', 'multicloud': 'Multi Cloud'};
  6
+var DEFAULT_DECISION_ENGINE = 'Multi Cloud';
4 7
 
5  
-function phantom_domain_buttons(enabled) {
  8
+$(document).ready(function() {
  9
+
  10
+    $("#phantom_domain_main_combined_pane_inner").hide();
  11
+
  12
+    $("#phantom_domain_de_choice").val(DEFAULT_DECISION_ENGINE)
  13
+    phantom_select_de(DEFAULT_DECISION_ENGINE);
  14
+
  15
+    phantom_domain_load();
  16
+
  17
+    $("body").click(function() {
  18
+        phantom_domain_noncontext_mouse_down();
  19
+    })
  20
+
  21
+    $("#phantom_domain_update_button").click(function() {
  22
+        phantom_domain_update_click();
  23
+    })
  24
+
  25
+    $("#phantom_domain_de_choice").change(function() {
  26
+        phantom_select_de($("#phantom_domain_de_choice").val());
  27
+    });
6 28
 
7  
-    var component_array = [
8  
-        "#phantom_domain_name_input",
9  
-        "#phantom_domain_size_input",
10  
-        "#phantom_domain_lc_choice",
11  
-        "#phantom_domain_button_start",
12  
-        "#phantom_domain_button_resize",
13  
-        "#phantom_domain_button_terminate",
14  
-        "#phantom_domain_button_list_choices",
15  
-        "#phantom_domain_filter_list",
16  
-        "#phantom_domain_update_button",
17  
-        "#phantom_domain_instance_details",
18  
-        "#phantom_domain_list_domains"
19  
-    ];
  29
+    $("#phantom_domain_button_add").click(function() {
  30
+        phantom_add_domain_click();
  31
+    });
  32
+
  33
+    $("#phantom_domain_list_domains").change(function() {
  34
+        phantom_domain_select_domain();
  35
+    });
  36
+
  37
+    $("#phantom_domain_list_domains option").click(function() {
  38
+        phantom_domain_select_domain();
  39
+    });
  40
+
  41
+    $("#phantom_domain_button_start").click(function() {
  42
+        phantom_domain_start_click();
  43
+    });
  44
+
  45
+    $("#phantom_domain_button_resize").click(function() {
  46
+        phantom_domain_resize_click();
  47
+    });
  48
+
  49
+    $("#phantom_domain_button_terminate").click(function() {
  50
+        phantom_domain_terminate_click();
  51
+    });
  52
+});
  53
+
  54
+
  55
+function phantom_domain_buttons(enabled) {
20 56
 
21 57
     if (enabled) {
22  
-        for (var comp in component_array) {
23  
-            comp = component_array[comp];
24  
-            $(comp).removeAttr("disabled", "disabled");
25  
-        }
  58
+        $("input, select").removeAttr("disabled");
26 59
         $('#phantom_domain_loading_image').hide();
27 60
     }
28 61
     else {
29  
-        for (var comp in component_array) {
30  
-            comp = component_array[comp];
31  
-            $(comp).attr("disabled", "disabled");
32  
-        }
  62
+        $("input, select").attr("disabled", true);
33 63
         $('#phantom_domain_loading_image').show();
34 64
     }
35 65
 }
36 66
 
  67
+function phantom_add_domain_click() {
  68
+    var new_domain_name = prompt("Enter a new domain name:");
  69
+    g_domain_data[new_domain_name] = {};
  70
+    phantom_domain_load_domain_names();
  71
+
  72
+    $("#phantom_domain_list_domains").val(new_domain_name);
  73
+    phantom_domain_select_domain();
  74
+}
  75
+
37 76
 function phantom_domain_load_lc_names() {
38 77
     $("#phantom_domain_lc_choice").empty();
39 78
 
@@ -45,12 +84,41 @@ function phantom_domain_load_lc_names() {
45 84
 }
46 85
 
47 86
 function phantom_domain_load_domain_names() {
  87
+    var previously_selected_domain = $("#phantom_domain_list_domains").val();
48 88
     $("#phantom_domain_list_domains").empty();
49 89
 
50 90
     for(var domain_name in g_domain_data) {
51 91
         var new_opt = $('<option>', {'name': domain_name, value: domain_name, text: domain_name});
52 92
         $("#phantom_domain_list_domains").append(new_opt);
53 93
     }
  94
+
  95
+    $("#phantom_domain_list_domains").val(previously_selected_domain);
  96
+}
  97
+
  98
+function phantom_domain_load_de_names() {
  99
+    $("#phantom_domain_de_choice").empty();
  100
+
  101
+    for(var decision_engine in g_decision_engines_by_name) {
  102
+        var new_opt = $('<option>', {'name': decision_engine, value: decision_engine, text: decision_engine});
  103
+        $("#phantom_domain_de_choice").append(new_opt);
  104
+    }
  105
+}
  106
+
  107
+function phantom_select_de(decision_engine) {
  108
+    var current_de = $("#phantom_domain_de_choice").val();
  109
+
  110
+    if (decision_engine === "Sensor") {
  111
+        $("#phantom_domain_de_choice").val("Sensor");
  112
+        $(".phantom_domain_de_pref").hide().filter("#phantom_domain_sensor_preferences").show();
  113
+        $("#phantom_domain_sensor_preferences").show();
  114
+    }
  115
+    else if (decision_engine === "Multi Cloud") {
  116
+        $("#phantom_domain_de_choice").val("Multi Cloud");
  117
+        $(".phantom_domain_de_pref").hide().filter("#phantom_domain_multicloud_preferences").show();
  118
+    }
  119
+    else {
  120
+        console.log("Don't know de type: " + decision_engine);
  121
+    }
54 122
 }
55 123
 
56 124
 function phantom_domain_load_internal() {
@@ -63,6 +131,7 @@ function phantom_domain_load_internal() {
63 131
 
64 132
         phantom_domain_load_lc_names();
65 133
         phantom_domain_load_domain_names();
  134
+        phantom_domain_load_de_names();
66 135
         phantom_domain_buttons(true);
67 136
     };
68 137
 
@@ -85,23 +154,78 @@ function phantom_domain_load() {
85 154
     }
86 155
 }
87 156
 
88  
-
  157
+// TODO: refactor for DRY with resize
89 158
 function phantom_domain_start_click_internal() {
90 159
     var url = make_url('api/domain/start');
91 160
     var lc_name = $("#phantom_domain_lc_choice").val();
92  
-    var domain_name = $("#phantom_domain_name_input").val();
  161
+    var domain_name = $("#phantom_domain_name_label").text();
  162
+    var de_name = g_decision_engines_by_name[$("#phantom_domain_de_choice").val()];
  163
+
  164
+    // Multicloud attrs
93 165
     var vm_count = $("#phantom_domain_size_input").val();
94 166
 
  167
+    // Sensor attrs
  168
+    var metric = $("#phantom_domain_metric_input").val();
  169
+    var cooldown = $("#phantom_domain_cooldown_input").val();
  170
+    var minimum_vms = $("#phantom_domain_minimum_input").val();
  171
+    var maximum_vms = $("#phantom_domain_maximum_input").val();
  172
+    var scale_up_threshold = $("#phantom_domain_scale_up_threshold_input").val();
  173
+    var scale_up_vms = $("#phantom_domain_scale_up_n_vms_input").val();
  174
+    var scale_down_threshold = $("#phantom_domain_scale_down_threshold_input").val();
  175
+    var scale_down_vms = $("#phantom_domain_scale_down_n_vms_input").val();
  176
+
95 177
     var error_msg = undefined;
96 178
 
97  
-    if(lc_name == undefined || lc_name == "" || lc_name == null) {
  179
+    if (lc_name == undefined || lc_name == "" || lc_name == null) {
98 180
         error_msg = "You must select a launch configuration name";
99 181
     }
100  
-    if(domain_name == undefined || domain_name == "" || domain_name == null) {
  182
+    if (domain_name == undefined || domain_name == "" || domain_name == null) {
101 183
         error_msg = "You must specify a domain name";
102 184
     }
103  
-    if(vm_count == undefined || vm_count == "" || vm_count == null) {
104  
-        error_msg = "You must specify a total number of vms";
  185
+
  186
+    var data = {"name": domain_name, "lc_name": lc_name, "de_name": de_name};
  187
+
  188
+    if (de_name == "multicloud") {
  189
+        if (! vm_count) {
  190
+            error_msg = "You must specify a total number of vms";
  191
+        }
  192
+
  193
+        data["vm_count"] = vm_count;
  194
+    }
  195
+    else if (de_name == "sensor") {
  196
+        if (! metric) {
  197
+            error_msg = "You must specify a metric";
  198
+        }
  199
+        if (! cooldown) {
  200
+            error_msg = "You must specify a cooldown";
  201
+        }
  202
+        if (! minimum_vms) {
  203
+            error_msg = "You must specify a minimum number of vms";
  204
+        }
  205
+        if (! maximum_vms) {
  206
+            error_msg = "You must specify a maximum number of vms";
  207
+        }
  208
+        if (! scale_up_threshold) {
  209
+            error_msg = "You must specify a scale up threshold";
  210
+        }
  211
+        if (! scale_up_vms) {
  212
+            error_msg = "You must specify a number of vms to scale up by";
  213
+        }
  214
+        if (! scale_down_threshold) {
  215
+            error_msg = "You must specify a scale down threshold";
  216
+        }
  217
+        if (! scale_down_vms) {
  218
+            error_msg = "You must specify a number of vms to scale down by";
  219
+        }
  220
+
  221
+        data["sensor_metric"] = metric;
  222
+        data["sensor_cooldown"] = cooldown;
  223
+        data["sensor_minimum_vms"] = minimum_vms;
  224
+        data["sensor_maximum_vms"] = maximum_vms;
  225
+        data["sensor_scale_up_threshold"] = scale_up_threshold;
  226
+        data["sensor_scale_up_vms"] = scale_up_vms;
  227
+        data["sensor_scale_down_threshold"] = scale_down_threshold;
  228
+        data["sensor_scale_down_vms"] = scale_down_vms;
105 229
     }
106 230
 
107 231
     if (error_msg != undefined) {
@@ -109,10 +233,12 @@ function phantom_domain_start_click_internal() {
109 233
         return;
110 234
     }
111 235
 
112  
-    var data = {'name': domain_name, "lc_name": lc_name, "vm_count": vm_count}
113  
-
114 236
     var success_func = function(obj) {
115 237
         phantom_domain_load_internal();
  238
+        $("#phantom_domain_start_buttons").hide();
  239
+        $("#phantom_domain_running_buttons").show();
  240
+        $("#phantom_domain_list_domains").val(domain_name);
  241
+        phantom_domain_details_internal();
116 242
     }
117 243
 
118 244
     var error_func = function(obj, message) {
@@ -134,38 +260,92 @@ function phantom_domain_start_click() {
134 260
 }
135 261
 
136 262
 function phantom_domain_resize_click_internal() {
137  
-     var url = make_url('api/domain/resize');
138  
-     var domain_name = $("#phantom_domain_name_input").val();
139  
-     var new_size = $("#phantom_domain_size_input").val();
  263
+    var url = make_url('api/domain/resize');
  264
+    var lc_name = $("#phantom_domain_lc_choice").val();
  265
+    var domain_name = $("#phantom_domain_name_label").text();
  266
+    var de_name = g_decision_engines_by_name[$("#phantom_domain_de_choice").val()];
140 267
 
141  
-     var error_msg = undefined;
  268
+    // Multicloud attrs
  269
+    var vm_count = $("#phantom_domain_size_input").val();
  270
+
  271
+    // Sensor attrs
  272
+    var metric = $("#phantom_domain_metric_input").val();
  273
+    var cooldown = $("#phantom_domain_cooldown_input").val();
  274
+    var minimum_vms = $("#phantom_domain_minimum_input").val();
  275
+    var maximum_vms = $("#phantom_domain_maximum_input").val();
  276
+    var scale_up_threshold = $("#phantom_domain_scale_up_threshold_input").val();
  277
+    var scale_up_vms = $("#phantom_domain_scale_up_n_vms_input").val();
  278
+    var scale_down_threshold = $("#phantom_domain_scale_down_threshold_input").val();
  279
+    var scale_down_vms = $("#phantom_domain_scale_down_n_vms_input").val();
  280
+
  281
+    var error_msg = undefined;
142 282
 
143  
-     if(domain_name == undefined || domain_name == "" || domain_name == null) {
  283
+    if (! lc_name) {
  284
+        error_msg = "You must select a launch configuration name";
  285
+    }
  286
+    if (! domain_name) {
144 287
         error_msg = "You must specify a domain name";
145  
-     }
146  
-     if(new_size == undefined || new_size == "" || new_size == null) {
147  
-        error_msg = "You must specify a new size";
148  
-     }
149  
-     if (error_msg != undefined) {
150  
-         alert(error_msg);
151  
-         return;
152  
-     }
153  
-
154  
-     var data = {'name': domain_name, 'vm_count': new_size}
155  
-
156  
-     var success_func = function(obj) {
157  
-         $("#phantom_domain_size_input").val("");
158  
-         phantom_domain_load_internal();
159  
-     }
160  
-
161  
-     var error_func = function(obj, message) {
162  
-         alert(message);
163  
-         phantom_domain_buttons(true);
164  
-     }
165  
-
166  
-     phantom_domain_buttons(false);
167  
-     phantomAjaxPost(url, data, success_func, error_func);
  288
+    }
168 289
 
  290
+    var data = {"name": domain_name, "lc_name": lc_name, "de_name": de_name};
  291
+
  292
+    if (de_name == "multicloud") {
  293
+        if (! vm_count) {
  294
+            error_msg = "You must specify a total number of vms";
  295
+        }
  296
+
  297
+        data["vm_count"] = vm_count;
  298
+    }
  299
+    else if (de_name == "sensor") {
  300
+        if (! metric) {
  301
+            error_msg = "You must specify a metric";
  302
+        }
  303
+        if (! cooldown) {
  304
+            error_msg = "You must specify a cooldown";
  305
+        }
  306
+        if (! minimum_vms) {
  307
+            error_msg = "You must specify a minimum number of vms";
  308
+        }
  309
+        if (! maximum_vms) {
  310
+            error_msg = "You must specify a maximum number of vms";
  311
+        }
  312
+        if (! scale_up_threshold) {
  313
+            error_msg = "You must specify a scale up threshold";
  314
+        }
  315
+        if (! scale_up_vms) {
  316
+            error_msg = "You must specify a number of vms to scale up by";
  317
+        }
  318
+        if (! scale_down_threshold) {
  319
+            error_msg = "You must specify a scale down threshold";
  320
+        }
  321
+        if (! scale_down_vms) {
  322
+            error_msg = "You must specify a number of vms to scale down by";
  323
+        }
  324
+
  325
+        data["sensor_metric"] = metric;
  326
+        data["sensor_cooldown"] = cooldown;
  327
+        data["sensor_minimum_vms"] = minimum_vms;
  328
+        data["sensor_maximum_vms"] = maximum_vms;
  329
+        data["sensor_scale_up_threshold"] = scale_up_threshold;
  330
+        data["sensor_scale_up_vms"] = scale_up_vms;
  331
+        data["sensor_scale_down_threshold"] = scale_down_threshold;
  332
+        data["sensor_scale_down_vms"] = scale_down_vms;
  333
+    }
  334
+
  335
+    var success_func = function(obj) {
  336
+        //("#phantom_domain_size_input").val("");
  337
+        //$("#phantom_domain_list_domains").val(domain_name);
  338
+        phantom_domain_load_internal();
  339
+        //phantom_domain_select_domain();
  340
+    }
  341
+
  342
+    var error_func = function(obj, message) {
  343
+        alert(message);
  344
+        phantom_domain_buttons(true);
  345
+    }
  346
+
  347
+    phantom_domain_buttons(false);
  348
+    phantomAjaxPost(url, data, success_func, error_func);
169 349
 }
170 350
 
171 351
 function phantom_domain_resize_click() {
@@ -179,13 +359,13 @@ function phantom_domain_resize_click() {
179 359
 
180 360
 function phantom_domain_terminate_click_internal() {
181 361
     var url = make_url('api/domain/terminate');
182  
-    var domain_name = $("#phantom_domain_name_input").val();
  362
+    var domain_name = $("#phantom_domain_name_label").text();
183 363
 
184 364
     var error_msg = undefined;
185 365
 
186 366
     if(domain_name == undefined || domain_name == "" || domain_name == null) {
187 367
         error_msg = "You must specify a domain name";
188  
-    }   
  368
+    }
189 369
     if (error_msg != undefined) {
190 370
         alert(error_msg);
191 371
         return;
@@ -194,10 +374,13 @@ function phantom_domain_terminate_click_internal() {
194 374
     var data = {'name': domain_name}
195 375
 
196 376
     var success_func = function(obj) {
197  
-        $("#phantom_domain_name_input").val("");
  377
+        delete g_domain_data[domain_name];
  378
+        $("#phantom_domain_name_label").text("");
198 379
         $("#phantom_domain_lc_choice").val("");
199 380
         $("#phantom_domain_size_input").val("");
200  
-        phantom_domain_load_internal();
  381
+        $("#phantom_domain_list_domains option[name*=" + domain_name + "]").remove();
  382
+        phantom_domain_deselect_domain();
  383
+        phantom_domain_buttons(true);
201 384
     }
202 385
 
203 386
     var error_func = function(obj, message) {
@@ -220,14 +403,45 @@ function phantom_domain_terminate_click() {
220 403
 }
221 404
 
222 405
 function phantom_domain_select_domain_internal() {
  406
+
223 407
     var domain_name = $("#phantom_domain_list_domains").val();
  408
+    if (!domain_name) {
  409
+        return;
  410
+    }
  411
+
  412
+    $("#phantom_domain_main_combined_pane_inner").show();
  413
+    $("#phantom_domain_instance_details").empty();
224 414
 
225 415
     var domain_data = g_domain_data[domain_name];
226  
-    $("#phantom_domain_name_input").val(domain_name);
227  
-    $("#phantom_domain_size_input").val(domain_data.vm_size);
228  
-    $("#phantom_domain_lc_choice").val(domain_data.lc_name);
  416
+    $("#phantom_domain_name_label").text(domain_name);
  417
+
  418
+    if (Object.keys(domain_data).length == 0) {
  419
+        phantom_select_de(DEFAULT_DECISION_ENGINE);
  420
+        $("#phantom_domain_start_buttons").show();
  421
+        $("#phantom_domain_running_buttons").hide();
  422
+    }
  423
+    else {
229 424
 
230  
-    phantom_domain_details_internal();
  425
+        $("#phantom_domain_lc_choice").val(domain_data.lc_name);
  426
+        $("#phantom_domain_start_buttons").hide();
  427
+        $("#phantom_domain_running_buttons").show();
  428
+        phantom_select_de(g_decision_engines_by_type[domain_data.de_name]);
  429
+
  430
+        if (domain_data.de_name == "multicloud") {
  431
+            $("#phantom_domain_size_input").val(domain_data.vm_size);
  432
+        }
  433
+        else if (domain_data.de_name == "sensor") {
  434
+            $("#phantom_domain_metric_input").val(domain_data.metric);
  435
+            $("#phantom_domain_cooldown_input").val(domain_data.sensor_cooldown);
  436
+            $("#phantom_domain_minimum_input").val(domain_data.sensor_minimum_vms);
  437
+            $("#phantom_domain_maximum_input").val(domain_data.sensor_maximum_vms);
  438
+            $("#phantom_domain_scale_up_threshold_input").val(domain_data.sensor_scale_up_threshold);
  439
+            $("#phantom_domain_scale_up_n_vms_input").val(domain_data.sensor_scale_up_vms);
  440
+            $("#phantom_domain_scale_down_threshold_input").val(domain_data.sensor_scale_down_threshold);
  441
+            $("#phantom_domain_scale_down_n_vms_input").val(domain_data.sensor_scale_down_vms);
  442
+        }
  443
+        phantom_domain_details_internal();
  444
+    }
231 445
 }
232 446
 
233 447
 
@@ -240,6 +454,12 @@ function phantom_domain_select_domain() {
240 454
     }
241 455
 }
242 456
 
  457
+function phantom_domain_deselect_domain() {
  458
+    $("#phantom_domain_main_combined_pane_inner").show();
  459
+    $("#phantom_domain_instance_details").empty();
  460
+    $("#phantom_domain_main_combined_pane_inner").hide();
  461
+}
  462
+
243 463
 function phantom_domain_update_click() {
244 464
     try {
245 465
         phantom_domain_details_internal();
@@ -312,7 +532,7 @@ function sensor_data_to_string(sensor_data) {
312 532
 
313 533
 function phantom_domain_details_internal() {
314 534
 
315  
-    var domain_name = $("#phantom_domain_list_domains").val();
  535
+    var domain_name = $("#phantom_domain_name_label").text();
316 536
 
317 537
     var url = make_url("api/domain/details");
318 538
     var data = {'name': domain_name};
112  phantomweb/templates/phantom_domain.html
@@ -14,7 +14,7 @@
14 14
     <script src="/static/js/phantom_common.js"></script>
15 15
     <script src="/static/js/phantom_domain.js"></script>
16 16
 {% endblock %}
17  
-{% block bodytag %}onload="phantom_domain_load();" onclick="phantom_domain_noncontext_mouse_down();"{% endblock %}
  17
+{% block bodytag %}{% endblock %}
18 18
 {% block nimbus_body  %}
19 19
 
20 20
 <div id="phantom_instance_context_menu_div">
@@ -28,53 +28,91 @@
28 28
     <div class="phantom_headings">
29 29
         <label id="phantom_domain_heading_label" >Domains</label>
30 30
     </div>
31  
-    <div>
  31
+    <div id="loading">
32 32
         <img src="/static/images/loading4.gif" id="phantom_domain_loading_image"/>
33 33
     </div>
34 34
 
35  
-    <div id="phantom_domain_main_combined_pane" class="phantom_domain_form_pane">
36  
-        <label class="phantom_area_header">Domain Options</label>
37  
-        <div class="phantom_domain_section_div phantom_domain_row">
38  
-            <label for="phantom_domain_name_input" class="phantom_domain_label">Domain Name:</label>
39  
-            <input type='text' id="phantom_domain_name_input" class="phantom_domain_value"/>
  35
+    <div id="phantom_domain_list_pane" class="phantom_domain_form_pane">
  36
+        <div class="phantom_domain_section_div phantom_domain_row" id="phantom_domain_button_add_div"  >
  37
+            <input type="button" id="phantom_domain_button_add" class="phantom_domain_button" value="Add Domain" />
40 38
         </div>
41 39
 
42  
-        <div class="phantom_domain_section_div phantom_domain_row">
43  
-            <label for="phantom_domain_size_input" class="phantom_domain_label">Size:</label>
44  
-            <input type='text' id="phantom_domain_size_input" class="phantom_domain_value"/>
45  
-        </div>
  40
+        <select id="phantom_domain_list_domains" class="phantom_domain_value phantom_domain_combo" size="20" >
  41
+        </select>
  42
+    </div>
46 43
 
47  
-        <div class="phantom_domain_section_div phantom_domain_row" >
48  
-            <label class="phantom_domain_label" id="phantom_domain_lc_div">Launch Configuration</label>
49  
-            <select id="phantom_domain_lc_choice" class="phantom_domain_value phantom_domain_combo">
50  
-            </select>
51  
-        </div>
  44
+    <div id="phantom_domain_main_combined_pane" class="phantom_domain_form_pane">
  45
+        <div id="phantom_domain_main_combined_pane_inner">
  46
+            <label class="phantom_area_header">Configuration for <span id="phantom_domain_name_label"></span></label>
52 47
 
53  
-        <div id="phantom_domain_button_div" class="phantom_domain_row phantom_domain_section_div">
54  
-            <table class="phantom_domain_control_buttons">
55  
-                <tr>
56  
-                    <td>
57  
-                        <input type="button" id="phantom_domain_button_start" class="phantom_domain_button" value="Start" onclick="phantom_domain_start_click()"/>
58  
-                    </td>
59  
-                    <td>
60  
-                        <input type="button" id="phantom_domain_button_resize" class="phantom_domain_button" value="Resize" onclick="phantom_domain_resize_click()"/>
61  
-                    </td>
62  
-                    <td>
63  
-                        <input type="button" id="phantom_domain_button_terminate" class="phantom_domain_button" value="Terminate" onclick="phantom_domain_terminate_click()"/>
64  
-                    </td>
65  
-                </tr>
66  
-            </table>
67  
-        </div>
  48
+            <div class="phantom_domain_section_div phantom_domain_row" >
  49
+                <label class="phantom_domain_label" id="phantom_domain_lc_div">Launch Configuration</label>
  50
+                <select id="phantom_domain_lc_choice" class="phantom_domain_value phantom_domain_combo">
  51
+                </select>
  52
+            </div>
68 53
 
69  
-        <div class="phantom_domain_section_div">
70  
-            <select size="5" id="phantom_domain_list_domains" class="phantom_domain_row" onchange="phantom_domain_select_domain()">
71  
-            </select>
72  
-        </div>
  54
+            <div class="phantom_domain_section_div phantom_domain_row" >
  55
+                <label class="phantom_domain_label" id="phantom_domain_de_div">Decision Engine:</label>
  56
+                <select id="phantom_domain_de_choice" class="phantom_domain_value phantom_domain_combo">
  57
+                </select>
  58
+            </div>
  59
+
  60
+            <div class="phantom_domain_de_pref phantom_domain_section_div phantom_domain_row" id="phantom_domain_multicloud_preferences">
  61
+                <label for="phantom_domain_size_input" class="phantom_domain_label">Size:</label>
  62
+                <input type='text' id="phantom_domain_size_input" class="phantom_domain_value"/>
  63
+            </div>
73 64
 
  65
+            <div class="phantom_domain_de_pref phantom_domain_section_div phantom_domain_row" id="phantom_domain_sensor_preferences">
  66
+                <label for="phantom_domain_metric_input" class="phantom_domain_label">Metric:</label>
  67
+                <input type='text' id="phantom_domain_metric_input" class="phantom_domain_value"/>
  68
+
  69
+                <label for="phantom_domain_cooldown_input" class="phantom_domain_label">Cooldown (s):</label>
  70
+                <input type='text' id="phantom_domain_cooldown_input" class="phantom_domain_value"/>
  71
+
  72
+                <label for="phantom_domain_minimum_input" class="phantom_domain_label">Minimum:</label>
  73
+                <input type='text' id="phantom_domain_minimum_input" class="phantom_domain_value"/>
  74
+
  75
+                <label for="phantom_domain_maximum_input" class="phantom_domain_label">Maximum:</label>
  76
+                <input type='text' id="phantom_domain_maximum_input" class="phantom_domain_value"/>
  77
+
  78
+                <label for="phantom_domain_scale_up_threshold_input" class="phantom_domain_label">Scale Up Threshold:</label>
  79
+                <input type='text' id="phantom_domain_scale_up_threshold_input" class="phantom_domain_value"/>
  80
+
  81
+                <label for="phantom_domain_scale_up_n_vms_input" class="phantom_domain_label">Scale Up By:</label>
  82
+                <input type='text' id="phantom_domain_scale_up_n_vms_input" class="phantom_domain_value"/>
  83
+
  84
+                <label for="phantom_domain_scale_down_threshold_input" class="phantom_domain_label">Scale Down Threshold:</label>
  85
+                <input type='text' id="phantom_domain_scale_down_threshold_input" class="phantom_domain_value"/>
  86
+
  87
+                <label for="phantom_domain_scale_down_n_vms_input" class="phantom_domain_label">Scale Down By:</label>
  88
+                <input type='text' id="phantom_domain_scale_down_n_vms_input" class="phantom_domain_value"/>
  89
+            </div>
  90
+
  91
+
  92
+            <div id="phantom_domain_button_div" class="phantom_domain_row phantom_domain_section_div">
  93
+                <table class="phantom_domain_control_buttons" id="phantom_domain_start_buttons">
  94
+                    <tr>
  95
+                        <td>
  96
+                            <input type="button" id="phantom_domain_button_start" class="phantom_domain_button" value="Start"/>
  97
+                        </td>
  98
+                    </tr>
  99
+                </table>
  100
+                <table class="phantom_domain_control_buttons" id="phantom_domain_running_buttons">
  101
+                    <tr>
  102
+                        <td>
  103
+                            <input type="button" id="phantom_domain_button_resize" class="phantom_domain_button" value="Update"/>
  104
+                        </td>
  105
+                        <td>
  106
+                            <input type="button" id="phantom_domain_button_terminate" class="phantom_domain_button" value="Terminate"/>
  107
+                        </td>
  108
+                    </tr>
  109
+                </table>
  110
+            </div>
  111
+        </div>
74 112
     </div>
75 113
 
76 114
     <div id="phantom_domain_details_pane" class="phantom_domain_form_pane">
77  
-        <label id="phantom_domain_details_name" class="phantom_area_header">Domain details.</label>
  115
+        <label id="phantom_domain_details_name" class="phantom_area_header">Details</label>
78 116
         <div id="phantom_domain_details_filter_div">
79 117
             <label id="phantom_domain_filter_list_label">Show:</label>
80 118
             <select name="phantom_domain_filter_list" id="phantom_domain_filter_list">
@@ -86,7 +124,7 @@
86 124
                 <option>TERMINATING</option>
87 125
                 <option>FAILED</option>
88 126
             </select>
89  
-            <input type="button" id="phantom_domain_update_button" class="phantom_domain_button" value="Update" onclick="phantom_domain_update_click()"/>
  127
+            <input type="button" id="phantom_domain_update_button" class="phantom_domain_button" value="Refresh"/>
90 128
         </div>
91 129
         <div id="phantom_domain_details_list_div">
92 130
             <ul id="phantom_domain_instance_details">
25  phantomweb/util.py
@@ -114,6 +114,7 @@ class UserObjectMySQL(UserObject):
114 114
 
115 115
     def __init__(self, username):
116 116
 
  117
+        self.username = username
117 118
         phantom_info_objects = PhantomInfoDB.objects.all()
118 119
         if not phantom_info_objects:
119 120
             raise PhantomWebException('The service is mis-configured.  Please contact your sysadmin')
@@ -128,9 +129,12 @@ def __init__(self, username):
128 129
         self._user_dbobject = self._authz.get_user_object_by_display_name(username)
129 130
         if not self._user_dbobject:
130 131
             raise PhantomWebException('The user %s is not associated with cloud user database.  Please contact your sysadmin' % (username))
  132
+        self.access_key = self._user_dbobject.access_key
131 133
 
132 134
         ssl = self.rabbit_info.rabbitssl
133 135
         self._dashi_conn = DashiCeiConnection(self.rabbit_info.rabbithost, self.rabbit_info.rabbituser, self.rabbit_info.rabbitpassword, exchange=self.rabbit_info.rabbitexchange, timeout=60, port=self.rabbit_info.rabbitport, ssl=ssl)
  136
+        self.epum = EPUMClient(self._dashi_conn)
  137
+        self.dtrs = DTRSClient(self._dashi_conn)
134 138
 
135 139
         self._load_clouds()
136 140
 
@@ -139,14 +143,29 @@ def close(self):
139 143
         self._authz.close()
140 144
 
141 145
     def has_phantom_data(self):
142  
-       return True
  146
+        return True
143 147
 
144 148
     def describe_domain(self, username, domain):
145 149
         # TODO: this should eventually be part of the REST API
146  
-        epum_client = EPUMClient(self._dashi_conn)
147  
-        describe = epum_client.describe_domain(domain, caller=username)
  150
+        describe = self.epum.describe_domain(domain, caller=username)
148 151
         return describe
149 152
 
  153
+    def get_all_groups(self):
  154
+        domain_names = self.epum.list_domains(caller=self.access_key)
  155
+        domains = []
  156
+        for domain in domain_names:
  157
+            domain_description = self.epum.describe_domain(domain, caller=self.access_key)
  158
+            domains.append(domain_description)
  159
+        return domains
  160
+
  161
+    def get_all_lcs(self):
  162
+        dt_names = self.dtrs.list_dts(self.access_key)
  163
+        dts = []
  164
+        for dt_name in dt_names:
  165
+            dt = self.dtrs.describe_dt(self.access_key, dt_name)
  166
+            dts.append(dt)
  167
+        return dts
  168
+
150 169
     def load_clouds(self):
151 170
         self._load_clouds()
152 171
 
234  phantomweb/workload.py
@@ -18,6 +18,11 @@
18 18
 # at some point this should come from some sort of DB
19 19
 g_instance_types = ["m1.small", "m1.large", "m1.xlarge"]
20 20
 
  21
+g_engine_to_phantom_de_map = {
  22
+        "epu.decisionengine.impls.phantom_multi_site_overflow.PhantomMultiSiteOverflowEngine": "multicloud",
  23
+        "epu.decisionengine.impls.sensor.SensorEngine": "sensor",
  24
+        }
  25
+
21 26
 PHANTOM_REGION = 'phantom'
22 27
 
23 28
 #
@@ -74,6 +79,35 @@ def _get_all_domains(phantom_con):
74 79
 
75 80
     return return_asgs
76 81
 
  82
+def _get_all_domains_dashi(userobj):
  83
+
  84
+    asgs = userobj.get_all_groups()
  85
+
  86
+    return_asgs = {}
  87
+    for a in asgs:
  88
+        engine_conf = a.get('config', {}).get('engine_conf', {})
  89
+        engine_class = a.get('config', {}).get('general', {}).get('engine_class')
  90
+
  91
+        ent = {}
  92
+        ent['name'] = a['name']
  93
+        ent['de_name'] = g_engine_to_phantom_de_map.get(engine_class)
  94
+        ent['vm_size'] = engine_conf.get('domain_desired_size')
  95
+
  96
+        ent['lc_name'] = engine_conf.get('dtname')
  97
+        ent['metric'] = engine_conf.get('metric')
  98
+        ent['sensor_cooldown'] = engine_conf.get('cooldown_period')
  99
+        ent['sensor_minimum_vms'] = engine_conf.get('minimum_vms')
  100
+        ent['sensor_maximum_vms'] = engine_conf.get('maximum_vms')
  101
+        ent['sensor_scale_up_threshold'] = engine_conf.get('scale_up_threshold')
  102
+        ent['sensor_scale_up_vms'] = engine_conf.get('scale_up_n_vms')
  103
+        ent['sensor_scale_down_threshold'] = engine_conf.get('scale_down_threshold')
  104
+        ent['sensor_scale_down_vms'] = engine_conf.get('scale_down_n_vms')
  105
+
  106
+        return_asgs[a['name']] = ent
  107
+
  108
+    return return_asgs
  109
+        
  110
+
77 111
 @LogEntryDecorator
78 112
 def _get_phantom_con(userobj):
79 113
     url = userobj.phantom_info.phantom_url
@@ -85,8 +119,57 @@ def _get_phantom_con(userobj):
85 119
     con.host = uparts.hostname
86 120
     return con
87 121
 
  122
+def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
  123
+
  124
+    policy_name_key = 'PHANTOM_DEFINITION'
  125
+    policy_name = 'sensor_engine'
  126
+    policy_tag = Tag(connection=phantom_con, key=policy_name_key, value=policy_name, resource_id=domain_name)
  127
+
  128
+    metric_key = 'metric'
  129
+    metric = de_params.get('sensor_metric')
  130
+
  131
+    cooldown_key = 'cooldown_period'
  132
+    cooldown = de_params.get('sensor_cooldown')
  133
+    scale_up_threshold_key = 'scale_up_threshold'
  134
+    scale_up_threshold = de_params.get('sensor_scale_up_threshold')
  135
+    scale_up_vms_key = 'scale_up_n_vms'
  136
+    scale_up_vms = de_params.get('sensor_scale_up_vms')
  137
+    scale_down_threshold_key = 'scale_down_threshold'
  138
+    scale_down_threshold = de_params.get('sensor_scale_down_threshold')
  139
+    scale_down_vms_key = 'scale_down_n_vms'
  140
+    scale_down_vms = de_params.get('sensor_scale_down_vms')
  141
+
  142
+    # TODO: This is hardcoded for this sync, should be exposed in the UI
  143
+    sample_function_key =  'sample_function'
  144
+    sample_function = 'Average'
  145
+    sensor_type_key = 'sensor_type'
  146
+    sensor_type = 'cloudwatch'
  147
+
  148
+    metric_tag = Tag(connection=phantom_con, key=metric_key, value=metric, resource_id=domain_name)
  149
+    sample_function_tag = Tag(connection=phantom_con, key=sample_function_key, value=sample_function, resource_id=domain_name)
  150
+    sensor_type_tag = Tag(connection=phantom_con, key=sensor_type_key, value=sensor_type, resource_id=domain_name)
  151
+    cooldown_tag = Tag(connection=phantom_con, key=cooldown_key, value=cooldown, resource_id=domain_name)
  152
+    scale_up_threshold_tag = Tag(connection=phantom_con, key=scale_up_threshold_key, value=scale_up_threshold, resource_id=domain_name)
  153
+    scale_up_vms_tag = Tag(connection=phantom_con, key=scale_up_vms_key, value=scale_up_vms, resource_id=domain_name)
  154
+    scale_down_threshold_tag = Tag(connection=phantom_con, key=scale_down_threshold_key, value=scale_down_threshold, resource_id=domain_name)
  155
+    scale_down_vms_tag = Tag(connection=phantom_con, key=scale_down_vms_key, value=scale_down_vms, resource_id=domain_name)
  156
+
  157
+    tags = []
  158
+    tags.append(policy_tag)
  159
+    tags.append(metric_tag)
  160
+    tags.append(sample_function_tag)
  161
+    tags.append(sensor_type_tag)
  162
+    tags.append(cooldown_tag)
  163
+    tags.append(scale_up_threshold_tag)
  164
+    tags.append(scale_up_vms_tag)
  165
+    tags.append(scale_down_threshold_tag)
  166
+    tags.append(scale_down_vms_tag)
  167
+
  168
+    return tags
  169
+
  170
+
88 171
 @LogEntryDecorator
89  
-def _start_domain(phantom_con, domain_name, lc_name, vm_count, host_list_str, a_cloudname):
  172
+def _start_domain(phantom_con, domain_name, lc_name, de_name, de_params, host_list_str, a_cloudname):
90 173
 
91 174
     shoe_horn = "%s@%s" % (lc_name, a_cloudname)
92 175
     try:
@@ -98,31 +181,50 @@ def _start_domain(phantom_con, domain_name, lc_name, vm_count, host_list_str, a_
98 181
 
99 182
     lc = lc[0]
100 183
 
101  
-    policy_name_key = 'PHANTOM_DEFINITION'
102  
-    policy_name = 'error_overflow_n_preserving'
103  
-    ordered_clouds_key = 'clouds'
104  
-    n_preserve_key = 'n_preserve'
105  
-    n_preserve = vm_count
  184
+    tags = []
106 185
 
107  
-    policy_tag = Tag(connection=phantom_con, key=policy_name_key, value=policy_name, resource_id=domain_name)
108  
-    clouds_tag = Tag(connection=phantom_con, key=ordered_clouds_key, value=host_list_str, resource_id=domain_name)
109  
-    npreserve_tag = Tag(connection=phantom_con, key=n_preserve_key, value=n_preserve, resource_id=domain_name)
  186
+    if de_name == 'multicloud':
  187
+        policy_name_key = 'PHANTOM_DEFINITION'
  188
+        policy_name = 'error_overflow_n_preserving'
  189
+        ordered_clouds_key = 'clouds'
  190
+        n_preserve_key = 'n_preserve'
  191
+        n_preserve = de_params.get('vm_count')
110 192
 
111  
-    # TODO: This is hardcoded for this sync, should be exposed in the UI
112  
-    metric_key = 'metric'
113  
-    metric = 'CPUUtilization'
114  
-    sample_function_key =  'sample_function'
115  
-    sample_function = 'Average'
116  
-    sensor_type_key = 'sensor_type'
117  
-    sensor_type = 'cloudwatch'
  193
+        policy_tag = Tag(connection=phantom_con, key=policy_name_key, value=policy_name, resource_id=domain_name)
  194
+        clouds_tag = Tag(connection=phantom_con, key=ordered_clouds_key, value=host_list_str, resource_id=domain_name)
  195
+        npreserve_tag = Tag(connection=phantom_con, key=n_preserve_key, value=n_preserve, resource_id=domain_name)
118 196
 
119  
-    metric_tag = Tag(connection=phantom_con, key=metric_key, value=metric, resource_id=domain_name)
120  
-    sample_function_tag = Tag(connection=phantom_con, key=sample_function_key, value=sample_function, resource_id=domain_name)
121  
-    sensor_type_tag = Tag(connection=phantom_con, key=sensor_type_key, value=sensor_type, resource_id=domain_name)
  197
+        tags.append(policy_tag)
  198
+        tags.append(clouds_tag)
  199
+        tags.append(npreserve_tag)
  200
+
  201
+        min_size = de_params.get('vm_count')
  202
+        max_size = de_params.get('vm_count')
  203
+
  204
+        # TODO: This is hardcoded for this sync, should be exposed in the UI
  205
+        metric_key = 'metric'
  206
+        metric = 'CPUUtilization'
  207
+        sample_function_key =  'sample_function'
  208
+        sample_function = 'Average'
  209
+        sensor_type_key = 'sensor_type'
  210
+        sensor_type = 'cloudwatch'
  211
+
  212
+        metric_tag = Tag(connection=phantom_con, key=metric_key, value=metric, resource_id=domain_name)
  213
+        sample_function_tag = Tag(connection=phantom_con, key=sample_function_key, value=sample_function, resource_id=domain_name)
  214
+        sensor_type_tag = Tag(connection=phantom_con, key=sensor_type_key, value=sensor_type, resource_id=domain_name)
122 215
 
123  
-    tags = [policy_tag, clouds_tag, npreserve_tag, metric_tag, sample_function_tag, sensor_type_tag]
  216
+        tags.append(metric_tag)
  217
+        tags.append(sample_function_tag)
  218
+        tags.append(sensor_type_tag)
124 219
 
125  
-    asg = boto.ec2.autoscale.group.AutoScalingGroup(launch_config=lc, connection=phantom_con, group_name=domain_name, availability_zones=["us-east-1"], min_size=vm_count, max_size=vm_count, tags=tags)
  220
+    elif de_name == 'sensor':
  221
+
  222
+        min_size = de_params.get('sensor_minimum_vms')
  223
+        max_size = de_params.get('sensor_maximum_vms')
  224
+
  225
+        tags = tags + sensor_tags_from_de_params(phantom_con, domain_name, de_params)
  226
+
  227
+    asg = boto.ec2.autoscale.group.AutoScalingGroup(launch_config=lc, connection=phantom_con, group_name=domain_name, availability_zones=["us-east-1"], min_size=min_size, max_size=max_size, tags=tags)
126 228
     phantom_con.create_auto_scaling_group(asg)
127 229
 
128 230
 @PhantomWebDecorator
@@ -439,9 +541,9 @@ def phantom_lc_delete(request_params, userobj):
439 541
 @PhantomWebDecorator
440 542
 @LogEntryDecorator
441 543
 def phantom_domain_load(request_params, userobj):
442  
-    phantom_con = _get_phantom_con(userobj)
443 544
 
444  
-    domains = _get_all_domains(phantom_con)
  545
+    phantom_con = _get_phantom_con(userobj)
  546
+    domains = _get_all_domains_dashi(userobj)
445 547
     all_lc_dict = _get_all_launch_configurations(phantom_con, userobj._user_dbobject.access_key)
446 548
 
447 549
     lc_names = []
@@ -458,14 +560,40 @@ def phantom_domain_load(request_params, userobj):
458 560
 @PhantomWebDecorator
459 561
 @LogEntryDecorator
460 562
 def phantom_domain_start(request_params, userobj):
461  
-    params = ['name', "lc_name", "vm_count", ]
462  
-    for p in params:
  563
+    sensor_params = ["sensor_metric", "sensor_cooldown", "sensor_minimum_vms", 
  564
+            "sensor_maximum_vms", "sensor_scale_up_threshold", "sensor_scale_up_vms", 
  565
+            "sensor_scale_down_threshold", "sensor_scale_down_vms"]
  566
+    multicloud_params = ["vm_count",]
  567
+    mandatory_params = ['name', "lc_name", "de_name"]
  568
+    for p in mandatory_params:
463 569
         if p not in request_params:
464 570
             raise PhantomWebException('Missing parameter %s' % (p))
465 571
     domain_name = request_params["name"]
466 572
     lc_name = request_params["lc_name"]
467  
-    vm_count = request_params["vm_count"]
468  
-
  573
+    de_name = request_params["de_name"]
  574
+
  575
+    de_params = {}
  576
+    if de_name == "sensor":
  577
+        for p in sensor_params:
  578
+            if p not in request_params:
  579
+                raise PhantomWebException('Missing parameter %s' % (p))
  580
+
  581
+        de_params["sensor_metric"] = request_params["sensor_metric"]
  582
+        de_params["sensor_cooldown"] = request_params["sensor_cooldown"]
  583
+        de_params["sensor_minimum_vms"] = request_params["sensor_minimum_vms"]
  584
+        de_params["sensor_maximum_vms"] = request_params["sensor_maximum_vms"]
  585
+        de_params["sensor_scale_up_threshold"] = request_params["sensor_scale_up_threshold"]
  586
+        de_params["sensor_scale_up_vms"] = request_params["sensor_scale_up_vms"]
  587
+        de_params["sensor_scale_down_threshold"] = request_params["sensor_scale_down_threshold"]
  588
+        de_params["sensor_scale_down_vms"] = request_params["sensor_scale_down_vms"]
  589
+
  590
+    elif de_name == "multicloud":
  591
+        for p in multicloud_params:
  592
+            if p not in request_params:
  593
+                g_general_log.debug("%s not in %s" % (p, request_params))
  594
+                raise PhantomWebException('Missing parameter %s' % (p))
  595
+
  596
+        de_params["vm_count"] = request_params["vm_count"]
469 597
 
470 598
     lc_db_object = LaunchConfigurationDB.objects.filter(name=lc_name, username=userobj._user_dbobject.access_key)
471 599
     if not lc_db_object or len(lc_db_object) < 1:
@@ -487,7 +615,7 @@ def phantom_domain_start(request_params, userobj):
487 615
 
488 616
 
489 617
     phantom_con = _get_phantom_con(userobj)
490  
-    _start_domain(phantom_con, domain_name, lc_name, vm_count, ordered_hosts, a_cloudname)
  618
+    _start_domain(phantom_con, domain_name, lc_name, de_name, de_params, ordered_hosts, a_cloudname)
491 619
 
492 620
     response_dict = {}
493 621
     return response_dict
@@ -495,24 +623,64 @@ def phantom_domain_start(request_params, userobj):
495 623
 @PhantomWebDecorator
496 624
 @LogEntryDecorator
497 625
 def phantom_domain_resize(request_params, userobj):
498  
-    params = ['name', "vm_count"]
499  
-    for p in params:
  626
+    sensor_params = ["sensor_metric", "sensor_cooldown", "sensor_minimum_vms", 
  627
+            "sensor_maximum_vms", "sensor_scale_up_threshold", "sensor_scale_up_vms", 
  628
+            "sensor_scale_down_threshold", "sensor_scale_down_vms"]
  629
+    multicloud_params = ["vm_count",]
  630
+    mandatory_params = ['name', "de_name"]
  631
+    for p in mandatory_params:
500 632
         if p not in request_params:
501 633
             raise PhantomWebException('Missing parameter %s' % (p))
  634
+    domain_name = request_params["name"]
  635
+    de_name = request_params["de_name"]
  636
+
  637
+    de_params = {}
  638
+    if de_name == "sensor":
  639
+        g_general_log.debug("PDA: updating sensor")
  640
+        for p in sensor_params:
  641
+            if p not in request_params:
  642
+                raise PhantomWebException('Missing parameter %s' % (p))
  643
+
  644
+        de_params["sensor_metric"] = request_params["sensor_metric"]
  645
+        de_params["sensor_cooldown"] = request_params["sensor_cooldown"]
  646
+        de_params["sensor_minimum_vms"] = request_params["sensor_minimum_vms"]
  647
+        de_params["sensor_maximum_vms"] = request_params["sensor_maximum_vms"]
  648
+        de_params["sensor_scale_up_threshold"] = request_params["sensor_scale_up_threshold"]
  649
+        de_params["sensor_scale_up_vms"] = request_params["sensor_scale_up_vms"]
  650
+        de_params["sensor_scale_down_threshold"] = request_params["sensor_scale_down_threshold"]
  651
+        de_params["sensor_scale_down_vms"] = request_params["sensor_scale_down_vms"]
  652
+
  653
+    elif de_name == "multicloud":
  654
+        g_general_log.debug("PDA: updating multicloud")
  655
+        for p in multicloud_params:
  656
+            if p not in request_params:
  657
+                g_general_log.debug("%s not in %s" % (p, request_params))
  658
+                raise PhantomWebException('Missing parameter %s' % (p))
  659
+
  660
+        de_params["vm_count"] = request_params["vm_count"]
  661
+
502 662
 
503 663
     domain_name = request_params["name"]
504  
-    new_size = request_params["vm_count"]
  664
+    new_size = request_params.get("vm_count")
505 665
 
506 666
     try:
507 667
         phantom_con = _get_phantom_con(userobj)
  668
+
  669
+        tags = sensor_tags_from_de_params(phantom_con, domain_name, de_params)
  670
+        phantom_con.create_or_update_tags(tags)
  671
+
508 672
         asg = phantom_con.get_all_groups(names=[domain_name,])
509 673
         if not asg:
510 674
             raise PhantomWebException("domain %s not found" % (domain_name))
511 675
         asg = asg[0]
512  
-        asg.set_capacity(new_size)
  676
+
  677
+        if new_size is not None:
  678
+            asg.set_capacity(new_size)
  679
+
513 680
     except PhantomWebException:
514 681
         raise
515 682
     except Exception, ex:
  683
+        g_general_log.exception("Error in resize")
516