Browse files

Add user data field

  • Loading branch information...
1 parent 8f3e9c1 commit 45d5dcc55312358f48f3adcb3c34026fbd5adbbd @oldpatricka oldpatricka committed Oct 1, 2012
View
4 phantomweb/static/css/phantom.css
@@ -130,7 +130,7 @@
#domain_list_choices
{
width: 400px;
- height: 200px;
+ height: 110px;
}
.phantom_section_div
@@ -345,4 +345,4 @@
#testblock
{
-}
+}
View
2 phantomweb/static/js/phantom.js
@@ -143,6 +143,7 @@ function listAllDomains() {
function startDomain() {
var asgNameOpt = document.getElementById('domain_name_input');
var asgSizeOpt = document.getElementById('domain_size_input');
+ var userData = document.getElementById('user_data');
var allocOpt = document.getElementById('allocation_choices');
var locationOpt = document.getElementById('location_choices');
var userImageOpt = document.getElementById('user_images_choices');
@@ -165,6 +166,7 @@ function startDomain() {
u = u.concat('&cloud=').concat(locationOpt.value);
u = u.concat('&common=').concat(common_check);
u = u.concat('&desired_size=').concat(asgSizeOpt.value);
+ u = u.concat('&user_data=').concat(encodeURIComponent(userData.value));
var func = function(obj){
listAllDomains();
View
25 phantomweb/templates/phantom.html
@@ -102,6 +102,31 @@
</div>
</div>
+ <div class="phantom_section_div">
+ <div class="phantom_domain_row">
+ <div class="combo_label">
+ <label id="allocation_choice_label" class="combo_label">Instance Size</label>
+ </div>
+ <div class="combo_value">
+ <select name="allocation" id="allocation_choices" class="imagechoice" label="allocation_choice_label">
+ {% for i in instance_types %}
+ <option>{{i}}</option>
+ {% endfor %}
+ </select>
+ </div>
+ </div>
+ </div>
+
+ <div class="phantom_section_div">
+ <div id="domain_name_div" class="phantom_domain_row" >
+ <div class="combo_label">
+ <label id="user_data_lbl" >User Data:</label>
+ </div>
+ <div class="combo_value">
+ <textarea id="user_data" name='user_data_text' label="user_data_lbl"></textarea>
+ </div>
+ </div>
+ </div>
<div id="lc_button_div" class="phantom_domain_row">
<table>
View
9 phantomweb/workload.py
@@ -121,10 +121,10 @@ def list_domains(request_params, userobj):
@LogEntryDecorator
-def _find_or_create_config(con, size, image, keyname, common, lc_name):
+def _find_or_create_config(con, size, image, keyname, common, lc_name, user_data):
lcs = con.get_all_launch_configurations(names=[lc_name,])
if not lcs:
- lc = boto.ec2.autoscale.launchconfig.LaunchConfiguration(con, name=lc_name, image_id=image, key_name=keyname, security_groups='default', instance_type=size)
+ lc = boto.ec2.autoscale.launchconfig.LaunchConfiguration(con, name=lc_name, image_id=image, key_name=keyname, security_groups='default', instance_type=size, user_data=user_data)
con.create_launch_configuration(lc)
return lc
return lcs[0]
@@ -135,7 +135,7 @@ def _find_or_create_config(con, size, image, keyname, common, lc_name):
def start_domain(request_params, userobj):
con = _get_phantom_con(userobj)
- params = ['size', 'name', 'image', 'cloud', 'common', 'desired_size']
+ params = ['size', 'name', 'image', 'cloud', 'common', 'desired_size', 'user_data']
for p in params:
if p not in request_params:
raise PhantomWebDecorator('Missing parameter %s' % (p))
@@ -145,6 +145,7 @@ def start_domain(request_params, userobj):
asg_name = request_params['name']
cloud = request_params['cloud']
common = request_params['common']
+ user_data = request_params['user_data']
try:
desired_size = int(request_params['desired_size'])
@@ -167,7 +168,7 @@ def start_domain(request_params, userobj):
raise PhantomWebException(e_msg)
lc_name = "%s@%s" % (lc_name, cloud)
- lc = _find_or_create_config(con, size, image_name, key_name, common, lc_name)
+ lc = _find_or_create_config(con, size, image_name, key_name, common, lc_name, user_data)
asg = boto.ec2.autoscale.group.AutoScalingGroup(launch_config=lc, connection=con, group_name=asg_name, availability_zones=[cloud], min_size=desired_size, max_size=desired_size)
con.create_auto_scaling_group(asg)
response_dict = {

0 comments on commit 45d5dcc

Please sign in to comment.