mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
Feature #3532: Add Sunstone support for import EC2 VMs
This commit is contained in:
parent
5404ad5c36
commit
1833a204d0
@ -18,6 +18,9 @@
|
||||
/* HOST_HISTORY_LENGTH is ignored by server */
|
||||
var HOST_HISTORY_LENGTH = 40;
|
||||
|
||||
/* Hypervisors from where you can import VMs*/
|
||||
var HYPERVISORS_CAN_IMPORT_VM = ["vcenter", "ec2"]
|
||||
|
||||
var create_host_tmpl =
|
||||
'<div class="row">\
|
||||
<div class="large-12 columns">\
|
||||
@ -778,7 +781,10 @@ function updateHostInfo(request,host){
|
||||
var stripped_host_template = {};
|
||||
var unshown_values = {};
|
||||
|
||||
if (host_info.TEMPLATE.HYPERVISOR && host_info.TEMPLATE.HYPERVISOR.toLowerCase() != "vcenter")
|
||||
var hypervisor_name = host_info.TEMPLATE.HYPERVISOR ? host_info.TEMPLATE.HYPERVISOR.toLowerCase() : "-" ;
|
||||
|
||||
|
||||
if (!$.inArray(hypervisor_name, HYPERVISORS_CAN_IMPORT_VM))
|
||||
{
|
||||
stripped_host_template = host_info.TEMPLATE;
|
||||
}
|
||||
@ -969,7 +975,7 @@ function updateHostInfo(request,host){
|
||||
<tr>\
|
||||
<th></th>\
|
||||
<th>' + tr("VM name") + '</th>\
|
||||
<th>' + tr("UUID") + '</th>\
|
||||
<th>' + tr("Remote ID") + '</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbody_host_wilds">\
|
||||
@ -1030,8 +1036,13 @@ function updateHostInfo(request,host){
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_monitoring_tab",monitor_tab);
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_vms_tab",vms_info_tab);
|
||||
|
||||
if (host_info.TEMPLATE.HYPERVISOR == "vcenter") {
|
||||
hypervisor_name = host_info.TEMPLATE.HYPERVISOR ? host_info.TEMPLATE.HYPERVISOR.toLowerCase() : "-";
|
||||
|
||||
if (hypervisor_name == "vcenter") {
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_esx_tab",esx_info_tab);
|
||||
}
|
||||
|
||||
if ($.inArray(hypervisor_name, HYPERVISORS_CAN_IMPORT_VM)) {
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_wilds_tab",wilds_info_tab);
|
||||
}
|
||||
|
||||
@ -1068,7 +1079,9 @@ function updateHostInfo(request,host){
|
||||
dataTable_esx_hosts.fnAddData(host_list_array);
|
||||
delete host_info.TEMPLATE.HOST;
|
||||
}
|
||||
}
|
||||
|
||||
if ($.inArray(hypervisor_name, HYPERVISORS_CAN_IMPORT_VM)) {
|
||||
// WILDS datatable
|
||||
var dataTable_wilds_hosts = $("#datatable_host_wilds",main_tabs_context).dataTable({
|
||||
"bSortClasses" : false,
|
||||
@ -1082,13 +1095,13 @@ function updateHostInfo(request,host){
|
||||
|
||||
$.each(wilds, function(){
|
||||
name = this.VM_NAME;
|
||||
safe_name = name.replace(/ /g,"_").replace(/./g,"_");
|
||||
uuid = this.DEPLOY_ID;
|
||||
safe_name = name.replace(/ /g,"_").replace(/\./g,"_");
|
||||
deploy_id = this.DEPLOY_ID;
|
||||
|
||||
wilds_list_array.push([
|
||||
'<input type="checkbox" id="import_wild_checker" class="import_'+safe_name+'" unchecked/>',
|
||||
name,
|
||||
uuid
|
||||
deploy_id
|
||||
]);
|
||||
|
||||
dataTable_wilds_hosts.fnAddData(wilds_list_array);
|
||||
|
@ -121,6 +121,9 @@ instance_types:
|
||||
t1.micro:
|
||||
cpu: 1
|
||||
memory: 0.615
|
||||
t2.micro:
|
||||
cpu: 1
|
||||
memory: 1
|
||||
cg1.4xlarge:
|
||||
cpu: 16
|
||||
memory: 22.5
|
||||
|
@ -340,11 +340,16 @@ class EC2Driver
|
||||
|
||||
poll_data=parse_poll(i)
|
||||
|
||||
vm_template_to_one = vm_to_one(i)
|
||||
vm_template_to_one = Base64.encode64(vm_template_to_one).gsub("\n","")
|
||||
|
||||
one_id = i.tags['ONE_ID']
|
||||
|
||||
vms_info << "VM=[\n"
|
||||
vms_info << " ID=#{one_id || -1},\n"
|
||||
vms_info << " DEPLOY_ID=#{i.instance_id},\n"
|
||||
vms_info << " VM_NAME=#{i.instance_id},\n"
|
||||
vms_info << " IMPORT_TEMPLATE=\"#{vm_template_to_one}\",\n"
|
||||
vms_info << " POLL=\"#{poll_data}\" ]\n"
|
||||
|
||||
if one_id
|
||||
@ -458,10 +463,6 @@ private
|
||||
end
|
||||
}
|
||||
|
||||
vm_template_to_one = vm_to_one(instance)
|
||||
vm_template_to_one = Base64.encode64(vm_template_to_one).gsub("\n","")
|
||||
info << "IMPORT_TEMPLATE=#{vm_template_to_one}"
|
||||
|
||||
info
|
||||
rescue
|
||||
# Unkown state if exception occurs retrieving information from
|
||||
@ -576,7 +577,7 @@ private
|
||||
def vm_to_one(instance)
|
||||
cpu, mem = instance_type_capacity(instance.instance_type)
|
||||
|
||||
str = "NAME = \"Instance from #{instance.image_id}\"\n"\
|
||||
str = "NAME = \"Instance from #{instance.id}\"\n"\
|
||||
"CPU = \"#{cpu}\"\n"\
|
||||
"vCPU = \"#{cpu}\"\n"\
|
||||
"MEMORY = \"#{mem}\"\n"\
|
||||
@ -585,9 +586,10 @@ private
|
||||
" TYPE =\"ec2\",\n"\
|
||||
" AMI =\"#{instance.image_id}\"\n"\
|
||||
"]\n"\
|
||||
"IMPORT_VM_ID = \"#{instance.image_id}\"\n"\
|
||||
"IMPORT_VM_ID = \"#{instance.id}\"\n"\
|
||||
"SCHED_REQUIREMENTS=\"NAME=\\\"#{@host}\\\"\"\n"\
|
||||
"DESCRIPTION = \"Instance imported from EC2\"\n"
|
||||
"DESCRIPTION = \"Instance imported from EC2, from instance"\
|
||||
" #{instance.id}, AMI #{instance.image_id}\"\n"
|
||||
|
||||
str
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user