mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
71449e75b5
@ -87,11 +87,11 @@ var create_vn_tmpl =
|
||||
<input type="text" name="net_address" id="net_address" /><br />\
|
||||
<label for="net_mask">Network Mask:</label>\
|
||||
<input type="text" name="net_mask" id="net_mask" /><br />\
|
||||
<label for="custom_pool" style="height:2em;">Enable pool boundaries:</label>\
|
||||
<label for="custom_pool" style="height:2em;">Define a subnet by IP range:</label>\
|
||||
<input type="checkbox" name="custom_pool" id="custom_pool" style="margin-bottom:2em;" value="yes" /><br />\
|
||||
<label for="ip_start">Pool start:</label>\
|
||||
<label for="ip_start">IP start:</label>\
|
||||
<input type="text" name="ip_start" id="ip_start" disabled="disabled" /><br />\
|
||||
<label for="ip_end">Pool end:</label>\
|
||||
<label for="ip_end">IP end:</label>\
|
||||
<input type="text" name="ip_end" id="ip_end" disabled="disabled" />\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
@ -280,27 +280,7 @@ var vnet_actions = {
|
||||
error: onError,
|
||||
notify: false,
|
||||
},
|
||||
/*
|
||||
"Network.modifyleases" : {
|
||||
type: "custom",
|
||||
call: function(action,obj){
|
||||
nodes = getSelectedNodes(dataTable_vNetworks);
|
||||
$.each(nodes,function(){
|
||||
Sunstone.runAction(action,this,obj);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
"Network.addleases_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpAddLeaseDialog
|
||||
},
|
||||
|
||||
"Network.rmleases_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpRemoveLeaseDialog
|
||||
},
|
||||
*/
|
||||
"Network.chown" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.Network.chown,
|
||||
@ -390,21 +370,7 @@ var vnet_buttons = {
|
||||
tip: "Select the new group:",
|
||||
condition: mustBeAdmin,
|
||||
},
|
||||
/*
|
||||
"action_list" : {
|
||||
type: "select",
|
||||
actions: {
|
||||
"Network.addleases_dialog" : {
|
||||
type: "action",
|
||||
text: "Add lease"
|
||||
},
|
||||
"Network.rmleases_dialog" : {
|
||||
type: "action",
|
||||
text: "Remove lease"
|
||||
}
|
||||
}
|
||||
},
|
||||
*/
|
||||
|
||||
"Network.delete" : {
|
||||
type: "action",
|
||||
text: "Delete"
|
||||
@ -416,10 +382,10 @@ var vnet_info_panel = {
|
||||
title: "Virtual network information",
|
||||
content: ""
|
||||
},
|
||||
"vnet_template_tab" : {
|
||||
title: "Virtual network template",
|
||||
"vnet_leases_tab" : {
|
||||
title: "Lease management",
|
||||
content: ""
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var vnets_tab = {
|
||||
@ -547,31 +513,34 @@ function updateVNetworkInfo(request,vn){
|
||||
</tr>\
|
||||
</table>';
|
||||
|
||||
info_tab_content += printLeases(vn_info);
|
||||
info_tab_content += '\
|
||||
<table id="vn_template_table" class="info_table">\
|
||||
<thead><tr><th colspan="2">Virtual Network template (attributes)</th></tr></thead>'+
|
||||
prettyPrintJSON(vn_info.TEMPLATE)+
|
||||
'</table>'
|
||||
|
||||
|
||||
var leases_tab_content = printLeases(vn_info);
|
||||
|
||||
var info_tab = {
|
||||
title: "Virtual Network information",
|
||||
content: info_tab_content
|
||||
}
|
||||
};
|
||||
|
||||
var template_tab = {
|
||||
title: "Virtual Network template",
|
||||
content:
|
||||
'<table id="vn_template_table" class="info_table" style="width:80%">\
|
||||
<thead><tr><th colspan="2">Virtual Network template</th></tr></thead>'+
|
||||
prettyPrintJSON(vn_info.TEMPLATE)+
|
||||
'</table>'
|
||||
}
|
||||
var leases_tab = {
|
||||
title: "Lease management",
|
||||
content: leases_tab_content
|
||||
};
|
||||
|
||||
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_info_tab",info_tab);
|
||||
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_template_tab",template_tab);
|
||||
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_leases_tab",leases_tab);
|
||||
|
||||
Sunstone.popUpInfoPanel("vnet_info_panel");
|
||||
|
||||
}
|
||||
|
||||
function printLeases(vn_info){
|
||||
var html ='<form style="display:inline-block;" id="leases_form" vnid="'+vn_info.ID+'"><table id="vn_leases_info_table" class="info_table" style="width:100%;">\
|
||||
var html ='<form style="display:inline-block;width:80%" id="leases_form" vnid="'+vn_info.ID+'"><table id="vn_leases_info_table" class="info_table" style="width:100%;">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">Leases information</th></tr>\
|
||||
</thead><tbody>';
|
||||
@ -1013,77 +982,6 @@ function setupLeasesOps(){
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function setupAddRemoveLeaseDialog() {
|
||||
dialogs_context.append('<div title="Lease management" id="lease_vn_dialog"></div>');
|
||||
$lease_vn_dialog = $('#lease_vn_dialog',dialogs_context)
|
||||
|
||||
var dialog = $lease_vn_dialog;
|
||||
|
||||
dialog.html(
|
||||
'<form id="lease_vn_form" action="javascript:alert(\'js error!\');">\
|
||||
<fieldset>\
|
||||
<div>Please specify:</div>\
|
||||
<label for="add_lease_ip">Lease IP:</label>\
|
||||
<input type="text" name="add_lease_ip" id="add_lease_ip" /><br />\
|
||||
<label id="add_lease_mac_label" for="add_lease_mac">Lease MAC:</label>\
|
||||
<input type="text" name="add_lease_mac" id="add_lease_mac" />\
|
||||
</select>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button id="lease_vn_proceed" class="" value="">OK</button>\
|
||||
<button class="confirm_cancel" value="">Cancel</button>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form>'
|
||||
);
|
||||
|
||||
//Prepare the jquery-ui dialog. Set style options here.
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
width: 410,
|
||||
height: 220
|
||||
});
|
||||
|
||||
$('button',dialog).button();
|
||||
|
||||
$('#lease_vn_form',dialog).submit(function(){
|
||||
var ip = $('#add_lease_ip',this).val();
|
||||
var mac = $('#add_lease_mac',this).val();
|
||||
|
||||
var obj = {ip: ip, mac: mac};
|
||||
|
||||
if (!mac.length) { delete obj.mac; };
|
||||
|
||||
Sunstone.runAction("Network.modifyleases",
|
||||
$('#lease_vn_proceed',this).val(),
|
||||
obj);
|
||||
$lease_vn_dialog.dialog('close');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function popUpAddLeaseDialog() {
|
||||
$lease_vn_dialog.dialog("option","title","Add lease");
|
||||
$('#add_lease_mac',$lease_vn_dialog).show();
|
||||
$('#add_lease_mac_label',$lease_vn_dialog).show();
|
||||
$('#lease_vn_proceed',$lease_vn_dialog).val("Network.addleases");
|
||||
$lease_vn_dialog.dialog("open");
|
||||
}
|
||||
|
||||
function popUpRemoveLeaseDialog() {
|
||||
$lease_vn_dialog.dialog("option","title","Remove lease");
|
||||
$('#add_lease_mac',$lease_vn_dialog).hide();
|
||||
$('#add_lease_mac_label',$lease_vn_dialog).hide();
|
||||
$('#lease_vn_proceed',$lease_vn_dialog).val("Network.rmleases");
|
||||
$lease_vn_dialog.dialog("open");
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
function setVNetAutorefresh() {
|
||||
setInterval(function(){
|
||||
var checked = $('input.check_item:checked',dataTable_vNetworks);
|
||||
@ -1097,7 +995,7 @@ function setVNetAutorefresh() {
|
||||
|
||||
function is_public_vnet(id) {
|
||||
var data = getElementData(id,"#vnetwork",dataTable_vNetworks)[7];
|
||||
return $(data).attr("checked");
|
||||
return $(data).is(":checked");
|
||||
};
|
||||
|
||||
function setupVNetActionCheckboxes(){
|
||||
|
@ -72,14 +72,16 @@ class VmmAction
|
||||
@vnm_src = VirtualNetworkDriver.new(@data[:net_drv],
|
||||
:local_actions => @vmm.options[:local_actions],
|
||||
:message => @xml_data,
|
||||
:ssh_stream => @ssh_src)
|
||||
:ssh_stream => @ssh_src,
|
||||
:extra_data => @data)
|
||||
|
||||
if @data[:dest_host] and !@data[:dest_host].empty?
|
||||
@ssh_dst = @vmm.get_ssh_stream(@data[:dest_host], @id)
|
||||
@vnm_dst = VirtualNetworkDriver.new(@data[:dest_driver],
|
||||
:local_actions => @vmm.options[:local_actions],
|
||||
:message => @xml_data,
|
||||
:ssh_stream => @ssh_dst)
|
||||
:ssh_stream => @ssh_dst,
|
||||
:extra_data => @data)
|
||||
end
|
||||
end
|
||||
|
||||
@ -115,7 +117,7 @@ class VmmAction
|
||||
# Executes a set of steps. If one step fails any recover action is performed
|
||||
# and the step execution breaks.
|
||||
# @param [Array] array of steps to be executed
|
||||
# @return [String, Hash] "SUCCESS/FAILURE" for the step set, and
|
||||
# @return [String, Hash] "SUCCESS/FAILURE" for the step set, and
|
||||
# information associated to each step (by :<action>_info). In case of
|
||||
# failure information is also in [:failed_info]
|
||||
def execute_steps(steps)
|
||||
@ -124,7 +126,7 @@ class VmmAction
|
||||
steps.each do |step|
|
||||
# Execute Step
|
||||
case step[:driver]
|
||||
when :vmm
|
||||
when :vmm
|
||||
if step[:destination]
|
||||
host = @data[:dest_host]
|
||||
ssh = @ssh_dst
|
||||
@ -134,7 +136,7 @@ class VmmAction
|
||||
end
|
||||
|
||||
result, info = @vmm.do_action(get_parameters(step[:parameters]),
|
||||
@id,
|
||||
@id,
|
||||
host,
|
||||
step[:action],
|
||||
:ssh_stream => ssh,
|
||||
@ -153,20 +155,21 @@ class VmmAction
|
||||
info = "No driver in #{step[:action]}"
|
||||
end
|
||||
|
||||
# Save the step info
|
||||
# Save the step info
|
||||
@data["#{step[:action]}_info".to_sym] = info
|
||||
@data[step[:save_info_as]] = info if step[:save_info_as]
|
||||
|
||||
# Roll back steps, store failed info and break steps
|
||||
if DriverExecHelper.failed?(result)
|
||||
if DriverExecHelper.failed?(result)
|
||||
execute_steps(@data[:fail_actions]) if @data[:fail_actions]
|
||||
@data[:failed_info] = info
|
||||
|
||||
@vmm.log(@id,
|
||||
@vmm.log(@id,
|
||||
"Failed to execute #{DRIVER_NAMES[step[:driver]]} " \
|
||||
"operation: #{step[:action]}.")
|
||||
break
|
||||
else
|
||||
@vmm.log(@id,
|
||||
@vmm.log(@id,
|
||||
"Sussecfully execute #{DRIVER_NAMES[step[:driver]]} " \
|
||||
"operation: #{step[:action]}.")
|
||||
end
|
||||
@ -217,7 +220,7 @@ class ExecDriver < VirtualMachineDriver
|
||||
@options={
|
||||
:threaded => true
|
||||
}.merge!(options)
|
||||
|
||||
|
||||
super("vmm/#{hypervisor}", @options)
|
||||
|
||||
@hypervisor = hypervisor
|
||||
@ -273,11 +276,12 @@ class ExecDriver < VirtualMachineDriver
|
||||
},
|
||||
# Boot the Virtual Machine
|
||||
{
|
||||
:driver => :vmm,
|
||||
:action => :deploy,
|
||||
:parameters => [dfile, :host],
|
||||
:stdin => domain
|
||||
},
|
||||
:driver => :vmm,
|
||||
:action => :deploy,
|
||||
:parameters => [dfile, :host],
|
||||
:stdin => domain,
|
||||
:save_info_as => :deploy_id
|
||||
},
|
||||
# Execute post-boot networking setup
|
||||
{
|
||||
:driver => :vnm,
|
||||
|
@ -31,6 +31,7 @@ class VirtualNetworkDriver
|
||||
@options = options
|
||||
@ssh_stream = options[:ssh_stream]
|
||||
@message = options[:message]
|
||||
@extra_data = options[:extra_data]
|
||||
|
||||
@vm_encoded = Base64.encode64(@message.elements['VM'].to_s).delete("\n")
|
||||
|
||||
@ -49,7 +50,9 @@ class VirtualNetworkDriver
|
||||
:stdin => nil,
|
||||
}.merge(ops)
|
||||
|
||||
cmd = action_command_line(aname, @vm_encoded)
|
||||
deploy_id=@extra_data[:deploy_id] || '-'
|
||||
|
||||
cmd = action_command_line(aname, "#{@vm_encoded} #{deploy_id}")
|
||||
|
||||
if action_is_local?(aname)
|
||||
execution = LocalCommand.run(cmd, log_method(id))
|
||||
@ -67,4 +70,4 @@ class VirtualNetworkDriver
|
||||
|
||||
result, info = get_info_from_execution(execution)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -18,8 +18,9 @@ require 'OpenNebulaNetwork'
|
||||
|
||||
class OpenNebulaHM < OpenNebulaNetwork
|
||||
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
|
||||
def initialize(vm, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,hypervisor)
|
||||
|
||||
def initialize(vm, deploy_id = nil, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,deploy_id,hypervisor)
|
||||
@bridges = get_interfaces
|
||||
end
|
||||
|
||||
|
@ -22,6 +22,9 @@ $: << File.join(File.dirname(__FILE__), "..")
|
||||
require 'OpenNebulaNetwork'
|
||||
require 'Firewall'
|
||||
|
||||
fw = OpenNebulaFirewall.from_base64(ARGV[0])
|
||||
template64 = ARGV[0]
|
||||
deploy_id = ARGV[1]
|
||||
|
||||
fw = OpenNebulaFirewall.from_base64(template64, deploy_id)
|
||||
|
||||
fw.activate
|
||||
|
@ -17,9 +17,11 @@
|
||||
class OpenNebulaFirewall < OpenNebulaNetwork
|
||||
XPATH_FILTER = "TEMPLATE/NIC[ICMP|WHITE_PORTS_TCP|WHITE_PORTS_UDP|" <<
|
||||
"BLACK_PORTS_TCP|BLACK_PORTS_UDP]"
|
||||
def initialize(vm, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,hypervisor)
|
||||
|
||||
def initialize(vm, deploy_id = nil, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,deploy_id,hypervisor)
|
||||
end
|
||||
|
||||
def activate
|
||||
vm_id = @vm['ID']
|
||||
process do |nic|
|
||||
|
@ -43,14 +43,17 @@ COMMANDS = {
|
||||
}
|
||||
|
||||
class VM
|
||||
attr_accessor :nics, :vm_info
|
||||
attr_accessor :nics, :vm_info, :deploy_id
|
||||
|
||||
def initialize(vm_root, xpath_filter, hypervisor)
|
||||
def initialize(vm_root, xpath_filter, deploy_id, hypervisor)
|
||||
@vm_root = vm_root
|
||||
@xpath_filter = xpath_filter
|
||||
@deploy_id = deploy_id
|
||||
@hypervisor = hypervisor
|
||||
@vm_info = Hash.new
|
||||
|
||||
@deploy_id = nil if deploy_id == "-"
|
||||
|
||||
nics = Nics.new(@hypervisor)
|
||||
|
||||
@vm_root.elements.each(@xpath_filter) do |nic_element|
|
||||
@ -92,19 +95,19 @@ end
|
||||
class OpenNebulaNetwork
|
||||
attr_reader :hypervisor, :vm
|
||||
|
||||
def self.from_base64(vm_64, hypervisor=nil)
|
||||
def self.from_base64(vm_64, deploy_id = nil, hypervisor = nil)
|
||||
vm_xml = Base64::decode64(vm_64)
|
||||
self.new(vm_xml, hypervisor)
|
||||
self.new(vm_xml, deploy_id, hypervisor)
|
||||
end
|
||||
|
||||
def initialize(vm_tpl, xpath_filter, hypervisor=nil)
|
||||
def initialize(vm_tpl, xpath_filter, deploy_id = nil, hypervisor = nil)
|
||||
if !hypervisor
|
||||
@hypervisor = detect_hypervisor
|
||||
else
|
||||
@hypervisor = hypervisor
|
||||
end
|
||||
|
||||
@vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, @hypervisor)
|
||||
|
||||
@vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, deploy_id, @hypervisor)
|
||||
end
|
||||
|
||||
def process(&block)
|
||||
|
@ -39,7 +39,11 @@ class NicKVM < Hash
|
||||
end
|
||||
|
||||
def get_info(vm)
|
||||
deploy_id = vm['DEPLOY_ID']
|
||||
if vm.deploy_id
|
||||
deploy_id = vm.deploy_id
|
||||
else
|
||||
deploy_id = vm['DEPLOY_ID']
|
||||
end
|
||||
|
||||
if deploy_id and vm.vm_info[:dumpxml].nil?
|
||||
vm.vm_info[:dumpxml] = `#{COMMANDS[:virsh]} dumpxml #{deploy_id} \
|
||||
|
@ -18,8 +18,9 @@ require 'OpenNebulaNetwork'
|
||||
|
||||
class EbtablesVLAN < OpenNebulaNetwork
|
||||
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
|
||||
def initialize(vm, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,hypervisor)
|
||||
|
||||
def initialize(vm, deploy_id = nil, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,deploy_id,hypervisor)
|
||||
end
|
||||
|
||||
def ebtables(rule)
|
||||
|
@ -22,10 +22,13 @@ $: << File.join(File.dirname(__FILE__), "..")
|
||||
require 'Ebtables'
|
||||
require 'Firewall'
|
||||
|
||||
onevlan = EbtablesVLAN.from_base64(ARGV[0])
|
||||
template64 = ARGV[0]
|
||||
deploy_id = ARGV[1]
|
||||
|
||||
onevlan = EbtablesVLAN.from_base64(template64, deploy_id)
|
||||
|
||||
onevlan.activate
|
||||
|
||||
fw = OpenNebulaFirewall.from_base64(ARGV[0])
|
||||
fw = OpenNebulaFirewall.from_base64(template64, deploy_id)
|
||||
|
||||
fw.activate
|
||||
|
@ -22,6 +22,9 @@ $: << File.join(File.dirname(__FILE__), "..")
|
||||
require 'OpenNebulaNetwork'
|
||||
require 'Firewall'
|
||||
|
||||
fw = OpenNebulaFirewall.from_base64(ARGV[0])
|
||||
template64 = ARGV[0]
|
||||
deploy_id = ARGV[1]
|
||||
|
||||
fw = OpenNebulaFirewall.from_base64(template64, deploy_id)
|
||||
|
||||
fw.activate
|
||||
|
@ -18,8 +18,9 @@ require 'OpenNebulaNetwork'
|
||||
|
||||
class OpenvSwitchVLAN < OpenNebulaNetwork
|
||||
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
|
||||
def initialize(vm, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,hypervisor)
|
||||
|
||||
def initialize(vm, deploy_id = nil, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,deploy_id,hypervisor)
|
||||
end
|
||||
|
||||
def activate
|
||||
|
@ -22,11 +22,13 @@ $: << File.join(File.dirname(__FILE__), "..")
|
||||
require 'OpenvSwitch'
|
||||
require 'Firewall'
|
||||
|
||||
template64 = ARGV[0]
|
||||
deploy_id = ARGV[1]
|
||||
|
||||
onevlan = OpenvSwitchVLAN.from_base64(ARGV[0])
|
||||
onevlan = OpenvSwitchVLAN.from_base64(template64, deploy_id)
|
||||
|
||||
onevlan.activate
|
||||
|
||||
fw = OpenNebulaFirewall.from_base64(ARGV[0])
|
||||
fw = OpenNebulaFirewall.from_base64(template64, deploy_id)
|
||||
|
||||
fw.activate
|
||||
|
Loading…
x
Reference in New Issue
Block a user