Skip to content

Commit

Permalink
F #1454: Changed form to create new host from sunstone
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmont committed Feb 12, 2018
1 parent 478f668 commit 9c2f665
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/sunstone/models/OpenNebulaJSON/HostJSON.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create(template_json)
host_hash['cluster_id'].to_i)
delete_values = ['name', 'im_mad', 'vm_mad', 'cluster_id']

template_str = hash_to_str(host_hash, delete_values)
template_str = template_to_str(host_hash, delete_values)
if !template_str.nil?
params=Hash.new
params['template_raw'] = template_str
Expand Down
16 changes: 5 additions & 11 deletions src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,24 +293,18 @@ define(function(require) {
}

if(vmm_mad == "one"){
var capacity = {};
var key = "";
var value = "";
var user = $('input[name="ONE_USER"]').val();
var pass = $('input[name="ONE_PASSWORD"]').val();
var endpoint = $('input[name="ONE_ENDPOINT"]').val();
$('tr.row_capacity_one',context).each(function() {
key = $("input[name='key']", this).val();
value = $("input[name='value']", this).val();
capacity[key] = value;
});
var cpu = $('input[name="ONE_CAPACITY_CPU"]').val();
var memory = $('input[name="ONE_CAPACITY_MEMORY"]').val();

host_json["host"]["ONE_USER"] = user;
host_json["host"]["ONE_PASSWORD"] = pass;
host_json["host"]["ONE_ENDPOINT"] = endpoint;
if (capacity["CPU"] && capacity["MEMORY"]){
host_json["host"]["ONE_CAPACITY"] = capacity;
}
host_json["host"]["ONE_CAPACITY"] = {};
host_json["host"]["ONE_CAPACITY"]["CPU"] = cpu;
host_json["host"]["ONE_CAPACITY"]["MEMORY"] = memory;
}
//Create the OpenNebula.Host.
//If it is successfull we refresh the list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,70 +140,37 @@
<fieldset>
<legend>{{tr "OpenNebula"}}</legend>
<div class="row">
<div class="large-12 columns">
<div class="large-6 columns">
<label for="ONE_USER">{{tr "Remote username"}}</label>
<input type="text" name="ONE_USER" />
</div>
</div>
<div class="row">
<div class="large-6 columns">
<label for="ONE_PASSWORD">{{tr "Remote password"}}</label>
<input type="text" name="ONE_PASSWORD" />
</div>
<div class="large-6 columns">
</div>
<div class="row">
<div class="large-12 columns">
<label for="ONE_ENDPOINT">{{tr "Remote endpoint"}}</label>
<input type="text" name="ONE_ENDPOINT" />
</div>
</div>
<div class="row">
<div class="medium-12 columns">
<label>{{tr "Remote capacity"}}</label>
<div class="row">
<div class="large-12 columns">
<table class="dataTable capacity_table">
<thead>
<tr>
<th>{{tr "Key"}}</th>
<th>{{tr "Value"}}</th>
<th></th>
</tr>
</thead>
<tbody class="capacity_one">
<tr class='row_capacity_one'>
<td style='display: flex; justify-content: flex-start'>
<input class='capacity_key' type='text' name='key' value="CPU">
</td>
<td>
<input class='capacity_value' type='number' min='0' name='value'>
</td>
<td style='width: 150%; display: flex; justify-content: flex-end'>
<a href='#'><i class='fa fa-times-circle remove-capacity'></i></a>
</td>
</tr>
<tr class='row_capacity_one'>
<td style='display: flex; justify-content: flex-start'>
<input class='capacity_key' type='text' name='key' value="MEMORY">
</td>
<td>
<input class='capacity_value' type='number' min='0' name='value'>
</td>
<td style='width: 150%; display: flex; justify-content: flex-end'>
<a href='#'><i class='fa fa-times-circle remove-capacity'></i></a>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">
<a type="button" class="add_custom_tag button small small-12 secondary radius">
<i class="fa fa-lg fa-plus-circle"></i>
</a>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="row">
<div class="large-1 columns"></div>
<div class="large-11 columns">
<label for="ONE_CAPACITY_CPU">{{tr "CPU"}}</label>
<input type="number" name="ONE_CAPACITY_CPU" />
</div>
</div>
<div class="row">
<div class="large-1 columns"></div>
<div class="large-11 columns">
<label for="ONE_CAPACITY_MEMORY">{{tr "Memory"}}</label>
<input type="number" name="ONE_CAPACITY_MEMORY" />
</div>
</div>
</fieldset>
Expand Down

0 comments on commit 9c2f665

Please sign in to comment.