mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Bug #4108: Add option to create persistent images in onevm save-as-template
(cherry picked from commit 45b33cabc5440e73051db06056388a7f732a7cdb)
This commit is contained in:
parent
b5d254b989
commit
6bbe71a386
@ -127,6 +127,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
:description => "ID of the Snapshot to save."
|
||||
}
|
||||
|
||||
PERSISTENT={
|
||||
:name => "persistent",
|
||||
:large => "--persistent",
|
||||
:description => "Make the new images persistent"
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# Global Options
|
||||
########################################################################
|
||||
@ -916,9 +922,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
States: POWEROFF
|
||||
EOT
|
||||
|
||||
command :save, save_desc, :vmid, :name do
|
||||
command :save, save_desc, :vmid, :name, :options=>[PERSISTENT] do
|
||||
helper.perform_action(args[0],options,"Saving VM") do |vm|
|
||||
res = vm.save_as_template(args[1])
|
||||
res = vm.save_as_template(args[1], options[:persistent] )
|
||||
|
||||
if !OpenNebula.is_error?(res)
|
||||
puts "Template ID: #{res}"
|
||||
|
@ -712,10 +712,12 @@ module OpenNebula
|
||||
# of the current disks. The VM capacity and NICs are also preserved
|
||||
#
|
||||
# @param name [String] Name for the new Template
|
||||
# @param name [true,false,nil] Optional, true to make the saved images
|
||||
# persistent, false make them non-persistent
|
||||
#
|
||||
# @return [Integer, OpenNebula::Error] the new Template ID in case of
|
||||
# success, error otherwise
|
||||
def save_as_template(name)
|
||||
def save_as_template(name, persistent=nil)
|
||||
img_ids = []
|
||||
new_tid = nil
|
||||
|
||||
@ -797,6 +799,10 @@ module OpenNebula
|
||||
|
||||
raise if OpenNebula.is_error?(rc)
|
||||
|
||||
if persistent == true
|
||||
OpenNebula::Image.new_with_id(rc.to_i, @client).persistent()
|
||||
end
|
||||
|
||||
img_ids << rc.to_i
|
||||
|
||||
replace << "DISK = [ IMAGE_ID = #{rc} ]\n"
|
||||
|
@ -187,7 +187,7 @@ module OpenNebulaJSON
|
||||
def save_as_template(params=Hash.new)
|
||||
vm_new = VirtualMachine.new(VirtualMachine.build_xml(@pe_id),
|
||||
@client)
|
||||
vm_new.save_as_template(params['name'])
|
||||
vm_new.save_as_template(params['name'], params['persistent'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -503,7 +503,7 @@ define(function(require) {
|
||||
'<div class="row">'+
|
||||
'<div class="large-12 columns">'+
|
||||
'<span style="font-size: 14px; line-height: 20px">'+
|
||||
Locale.tr("This Virtual Machine will be saved in a new Template. Only the main disk will be preserved!")+
|
||||
Locale.tr("This Virtual Machine will be saved in a new Template.")+
|
||||
'<br>'+
|
||||
Locale.tr("You can then create a new Virtual Machine using this Template.")+
|
||||
'</span>'+
|
||||
@ -516,6 +516,27 @@ define(function(require) {
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<br>'+
|
||||
'<div class="row">'+
|
||||
'<div class="large-12 columns">'+
|
||||
'<span style="font-size: 14px; line-height: 20px">'+
|
||||
Locale.tr("The new Virtual Machine's disks can be made persistent. In a persistent Virtual Machine the changes made survive after it is destroyed. On the other hand, you cannot create more than one simultaneous Virtual Machine from a Template with persistent disks.")+
|
||||
'</span>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<br>'+
|
||||
'<div class="row">'+
|
||||
'<div class="large-12 columns">'+
|
||||
'<label class="left" style="margin-left: 25px">'+
|
||||
'<input type="radio" name="provision_snapshot_radio" value="persistent" class="provision_snapshot_persistent_radio">'+
|
||||
' <i class="fa fa-fw fa-save"/> '+Locale.tr("Persistent")+
|
||||
'</label>'+
|
||||
'<label class="left" style="margin-left: 25px">'+
|
||||
'<input type="radio" name="provision_snapshot_radio" value="nonpersistent" class="provision_snapshot_nonpersisten_radio" checked>'+
|
||||
' <i class="fa fa-fw fa-trash-o"/> '+Locale.tr("Non-persistent")+
|
||||
'</label>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<br>'+
|
||||
'<div class="row">'+
|
||||
'<div class="large-11 large-centered columns">'+
|
||||
'<a href"#" class="provision_snapshot_create_button success button large-12 radius right">'+Locale.tr("Save Virtual Machine to Template")+'</a>'+
|
||||
@ -532,12 +553,15 @@ define(function(require) {
|
||||
|
||||
var vm_id = context.attr("vm_id");
|
||||
var template_name = $('.provision_snapshot_name', context).val();
|
||||
var persistent =
|
||||
($('input[name=provision_snapshot_radio]:checked').val() == "persistent");
|
||||
|
||||
OpenNebula.VM.save_as_template({
|
||||
data : {
|
||||
id: vm_id,
|
||||
extra_param: {
|
||||
name : template_name
|
||||
name : template_name,
|
||||
persistent : persistent
|
||||
}
|
||||
},
|
||||
timeout: false,
|
||||
|
@ -70,13 +70,15 @@ define(function(require) {
|
||||
|
||||
$('#' + DIALOG_ID + 'Form', context).submit(function() {
|
||||
var template_name = $('#template_name', this).val();
|
||||
var persistent = $('#saveas_persistency', this).is(":checked") ? true : false;
|
||||
var vm_id = $("#vm_id", context).val();
|
||||
|
||||
OpenNebula.VM.save_as_template({
|
||||
data : {
|
||||
id: vm_id,
|
||||
extra_param: {
|
||||
name : template_name
|
||||
name : template_name,
|
||||
persistent : persistent
|
||||
}
|
||||
},
|
||||
success: function(request, response){
|
||||
|
@ -34,6 +34,12 @@
|
||||
<input type="text" name="template_name" id="template_name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<input type="checkbox" name="saveas_persistency" id="saveas_persistency" />
|
||||
<label for="saveas_persistency">{{tr "Make the new images persistent"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_buttons">
|
||||
<button class="button radius right success" type="submit">{{tr "Save As Template"}}</button>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user