Permalink
Browse files

Show list of public images for Nimbus (but not EC2)

  • Loading branch information...
oldpatricka committed Mar 7, 2013
1 parent df1d261 commit 917a558976274c83dcd824c012c8cf0383d349d9
Showing with 32 additions and 4 deletions.
  1. +18 −0 phantomweb/static/js/phantom_lc.js
  2. +14 −4 phantomweb/workload.py
@@ -5,6 +5,7 @@ var g_unsaved_lcs = [];
var g_blank_name = "<new name>";
var g_selected_lc = null;
var g_selected_cloud = null;
+var MAX_PUBLIC_IMAGES_ITEMS = 200;
$(document).ready(function() {
$("#nav-launchconfig").addClass("active");
@@ -35,6 +36,16 @@ $(document).ready(function() {
},
});
+ var $phantom_lc_common_image_input = $("#phantom_lc_common_image_input").typeahead({
+ minLength: 0,
+ items: MAX_PUBLIC_IMAGES_ITEMS,
+ });
+
+ //enable showing hints on click
+ $phantom_lc_common_image_input.on('focus', $phantom_lc_common_image_input.typeahead.bind($phantom_lc_common_image_input, 'lookup'));
+ $phantom_lc_common_image_input.on('click', $phantom_lc_common_image_input.typeahead.bind($phantom_lc_common_image_input, 'lookup'));
+
+
$("#phantom_lc_add").click(function() {
phantom_lc_enable_click();
return false;
@@ -207,6 +218,10 @@ function phantom_lc_select_new_cloud_internal(cloud_name) {
if (cloud_data.status != 0) {
return;
}
+
+ var public_images_typeahead = $('#phantom_lc_common_image_input').data('typeahead');
+ public_images_typeahead.hide();
+
$("#phantom_lc_max_vm").val("");
$("#phantom_lc_instance").empty();
for (instance in cloud_data.instances) {
@@ -222,6 +237,9 @@ function phantom_lc_select_new_cloud_internal(cloud_name) {
var new_opt = $('<option>', {'name': i, value: i, text: i});
$("#phantom_lc_user_images_choices").append(new_opt);
}
+ if (public_images_typeahead) {
+ public_images_typeahead.source = cloud_data.public_images;
+ }
}
function phantom_lc_load_cloud_names() {
View
@@ -173,7 +173,7 @@ def multicloud_tags_from_de_params(phantom_con, domain_name, de_params):
monitor_sensors = de_params.get('monitor_sensors', '')
monitor_domain_sensors_key = 'monitor_domain_sensors'
monitor_domain_sensors = de_params.get('monitor_domain_sensors', '')
- sample_function_key = 'sample_function'
+ sample_function_key = 'sample_function'
sample_function = 'Average'
# TODO: this should eventually be configurable
sensor_type_key = 'sensor_type'
@@ -193,6 +193,7 @@ def multicloud_tags_from_de_params(phantom_con, domain_name, de_params):
return tags
+
def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
policy_name_key = 'PHANTOM_DEFINITION'
@@ -219,7 +220,7 @@ def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
scale_down_vms = de_params.get('sensor_scale_down_vms')
# TODO: This is hardcoded for this sync, should be exposed in the UI
- sample_function_key = 'sample_function'
+ sample_function_key = 'sample_function'
sample_function = 'Average'
sensor_type_key = 'sensor_type'
sensor_type = 'opentsdb'
@@ -250,12 +251,13 @@ def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
return tags
+
@LogEntryDecorator
def _start_domain(phantom_con, domain_name, lc_name, de_name, de_params, host_list_str, a_cloudname):
shoe_horn = "%s@%s" % (lc_name, a_cloudname)
try:
- lc = phantom_con.get_all_launch_configurations(names=[shoe_horn,])
+ lc = phantom_con.get_all_launch_configurations(names=[shoe_horn, ])
except EC2ResponseError:
lc = None
if not lc:
@@ -275,7 +277,7 @@ def _start_domain(phantom_con, domain_name, lc_name, de_name, de_params, host_li
monitor_sensors = de_params.get('monitor_sensors', '')
monitor_domain_sensors_key = 'monitor_domain_sensors'
monitor_domain_sensors = de_params.get('monitor_domain_sensors', '')
- sample_function_key = 'sample_function'
+ sample_function_key = 'sample_function'
sample_function = 'Average'
# TODO: this should eventually be configurable
sensor_type_key = 'sensor_type'
@@ -492,7 +494,15 @@ def phantom_lc_load(request_params, userobj):
l = ec2conn.get_all_images(owners=['self'])
user_images = [u.id for u in l if not u.is_public]
+ # We don't fetch EC2 public images because there are thousands
+ public_images = []
+ if cloud.driver_class != "libcloud.compute.drivers.ec2.EC2NodeDriver":
+ g_general_log.debug("Looking up public images on %s" % cloud_name)
+ l = ec2conn.get_all_images()
+ public_images = [u.id for u in l if u.is_public]
+
cloud_info['personal_images'] = user_images
+ cloud_info['public_images'] = public_images
cloud_info['instances'] = g_instance_types
cloud_info['status'] = 0
except Exception, ex:

0 comments on commit 917a558

Please sign in to comment.