diff --git a/src/sunstone/models/OpenNebulaJSON/GroupJSON.rb b/src/sunstone/models/OpenNebulaJSON/GroupJSON.rb
index f269131c07..1d9c0c4528 100644
--- a/src/sunstone/models/OpenNebulaJSON/GroupJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON/GroupJSON.rb
@@ -45,7 +45,7 @@ module OpenNebulaJSON
end
def chown(params=Hash.new)
- super(params['owner_id'].to_i,-1)
+ super(params['owner_id'].to_i)
end
end
end
diff --git a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb
index ae67302f6a..c88dd6dae3 100644
--- a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb
@@ -59,7 +59,7 @@ module OpenNebulaJSON
end
def update(params=Hash.new)
- super(params['name'], params['value'])
+ super(params['template_raw'])
end
def remove_attr(params=Hash.new)
diff --git a/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb b/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb
index 18b97bc6d9..a5783979af 100644
--- a/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb
@@ -43,23 +43,18 @@ module OpenNebulaJSON
rc = case action_hash['perform']
when "publish" then self.publish
- when "rm_attr" then self.remove_attr(action_hash['params'])
when "unpublish" then self.unpublish
when "update" then self.update(action_hash['params'])
- when "chown" then self.chown(action_hash['params'])
+ when "chown" then self.chown(action_hash['params'])
else
error_msg = "#{action_hash['perform']} action not " <<
" available for this resource"
OpenNebula::Error.new(error_msg)
end
end
-
- def update(params=Hash.new)
- super(params['name'], params['value'])
- end
- def remove_attr(params=Hash.new)
- super(params['name'])
+ def update(params=Hash.new)
+ super(params['template_raw'])
end
def chown(params=Hash.new)
diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb
index 32c777bf3e..d654f50649 100644
--- a/src/sunstone/models/SunstoneServer.rb
+++ b/src/sunstone/models/SunstoneServer.rb
@@ -87,6 +87,19 @@ class SunstoneServer
end
end
+ ############################################################################
+ #
+ ############################################################################
+ def get_template(kind,id)
+ resource = retrieve_resource(kind,id)
+ if OpenNebula.is_error?(resource)
+ return [404, resource.to_json]
+ else
+ template_str = resource.template_str(true)
+ return [200, {:template => template_str}.to_json]
+ end
+ end
+
############################################################################
#
############################################################################
diff --git a/src/sunstone/public/css/application.css b/src/sunstone/public/css/application.css
index 6840aefa7c..badc5de365 100644
--- a/src/sunstone/public/css/application.css
+++ b/src/sunstone/public/css/application.css
@@ -235,19 +235,19 @@ div.tip span.man_icon {
display:inline-block!important;
}
-span.tipspan {
- position: fixed;
- display:block;
- padding:4px;
- -webkit-border-radius: 3px;
- -moz-border-radius: 3px;
- border-radius: 3px;
- border: 1px solid #353735;
- margin-left:2px;
- margin-right:5px;
- background-color: white;
+span.tipspan,div.full_info {
+ position: fixed;
+ display:block;
+ padding:4px;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ border: 1px solid #353735;
+ margin-left:2px;
+ margin-right:5px;
+ background-color: white;
color: #353735;
- font-size:10px;
+ font-size:10px;
}
.vm_section input {
float:none;
diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js
index 00095a56f4..299ca9809a 100644
--- a/src/sunstone/public/js/opennebula.js
+++ b/src/sunstone/public/js/opennebula.js
@@ -1783,7 +1783,71 @@ var OpenNebula = {
}
});
},
+ "fetch_template" : function(params)
+ {
+ var callback = params.success;
+ var callback_error = params.error;
+ var id = params.data.id;
+ var method = "fetch_template";
+ var resource = OpenNebula.Image.resource;
+ var request = OpenNebula.Helper.request(resource,method, id);
+
+ $.ajax({
+ url: "/image/" + id + "/template",
+ type: "GET",
+ dataType:"json",
+ success: function(response)
+ {
+ if (callback)
+ {
+ callback(request,response);
+ }
+ },
+ error: function(response)
+ {
+ if(callback_error)
+ {
+ callback_error(request, OpenNebula.Error(response));
+ }
+ }
+ });
+ },
+
+ "update": function(params)
+ {
+ var callback = params.success;
+ var callback_error = params.error;
+ var id = params.data.id;
+ var template_raw = params.data.extra_param;
+ var template_obj = {"template_raw": template_raw}
+
+ var method = "update";
+ var action = OpenNebula.Helper.action(method, template_obj);
+
+ var resource = OpenNebula.Image.resource;
+ var request = OpenNebula.Helper.request(resource,method, [id, template_obj]);
+
+ $.ajax({
+ url: "/image/" + id + "/action",
+ type: "POST",
+ data: JSON.stringify(action),
+ success: function(response)
+ {
+ if (callback)
+ {
+ callback(request, response);
+ }
+ },
+ error: function(response)
+ {
+ if (callback_error)
+ {
+ callback_error(request, OpenNebula.Error(response));
+ }
+ }
+ });
+ },
"delete": function(params)
{
var callback = params.success;
@@ -1874,82 +1938,6 @@ var OpenNebula = {
}
});
},
-
- "addattr": function(params)
- {
- var callback = params.success;
- var callback_error = params.error;
- var id = params.data.id;
- var name = params.data.name;
- var value = params.data.value;
-
- var method = "update";
- var action = OpenNebula.Helper.action(method, {
- "name" : name,
- "value" : value
- });
-
- var resource = OpenNebula.Image.resource;
- var request = OpenNebula.Helper.request(resource,method, [id, name, value]);
-
- $.ajax({
- url: "/image/" + id + "/action",
- type: "POST",
- data: JSON.stringify(action),
- success: function(response)
- {
- if (callback)
- {
- callback(request, response);
- }
- },
- error: function(response)
- {
- if (callback_error)
- {
- callback_error(request, OpenNebula.Error(response));
- }
- }
- });
- },
-
- "rmattr": function(params)
- {
- var callback = params.success;
- var callback_error = params.error;
- var id = params.data.id;
- var name = params.data.name;
- var value = params.data.value;
-
- var method = "rm_attr";
- var action = OpenNebula.Helper.action(method, {
- "name" : name
- });
-
- var resource = OpenNebula.Image.resource;
- var request = OpenNebula.Helper.request(resource,method, [id, name]);
-
- $.ajax({
- url: "/image/" + id + "/action",
- type: "POST",
- data: JSON.stringify(action),
- success: function(response)
- {
- if (callback)
- {
- callback(request, response);
- }
- },
- error: function(response)
- {
- if (callback_error)
- {
- callback_error(request, OpenNebula.Error(response));
- }
- }
- });
- },
-
"enable": function(params)
{
var callback = params.success;
@@ -2188,95 +2176,49 @@ var OpenNebula = {
});
},
- "addattr" : function(params)
+ "fetch_template" : function(params)
{
var callback = params.success;
var callback_error = params.error;
var id = params.data.id;
- var name = params.data.name;
- var value = params.data.value;
- var method = "update";
- var action = OpenNebula.Helper.action(method, {
- "name" : name,
- "value" : value
- });
-
- var resource = OpenNebula.Template.resource;
- var request = OpenNebula.Helper.request(resource,method, [id, name, value]);
+ var method = "fetch_template";
+ var resource = OpenNebula.Template.resource;
+ var request = OpenNebula.Helper.request(resource,method, id);
$.ajax({
- url: "/template/" + id + "/action",
- type: "POST",
- data: JSON.stringify(action),
+ url: "/template/" + id + "/template",
+ type: "GET",
+ dataType:"json",
success: function(response)
{
if (callback)
{
- callback(request, response);
+ callback(request,response);
}
},
error: function(response)
{
- if (callback_error)
+ if(callback_error)
{
callback_error(request, OpenNebula.Error(response));
}
}
- });
+ });
},
"update" : function(params)
{
var callback = params.success;
var callback_error = params.error;
var id = params.data.id;
- var name = params.data.name;
- var value = params.data.value;
+ var template_raw = params.data.extra_param;
+ var template_obj = {"template_raw": template_raw}
var method = "update";
- var action = OpenNebula.Helper.action(method, {
- "name" : name,
- "value" : value
- });
-
+ var action = OpenNebula.Helper.action(method, template_obj);
+
var resource = OpenNebula.Template.resource;
- var request = OpenNebula.Helper.request(resource,method, [id, name, value]);
-
- $.ajax({
- url: "/template/" + id + "/action",
- type: "POST",
- data: JSON.stringify(action),
- success: function(response)
- {
- if (callback)
- {
- callback(request, response);
- }
- },
- error: function(response)
- {
- if (callback_error)
- {
- callback_error(request, OpenNebula.Error(response));
- }
- }
- });
- },
- "rmattr" : function(params)
- {
- var callback = params.success;
- var callback_error = params.error;
- var id = params.data.id;
- var name = params.data.name;
- var value = params.data.value;
-
- var method = "rm_attr";
- var action = OpenNebula.Helper.action(method, {
- "name" : name
- });
-
- var resource = OpenNebula.Template.resource;
- var request = OpenNebula.Helper.request(resource,method, [id, name]);
+ var request = OpenNebula.Helper.request(resource,method, [id, template_obj]);
$.ajax({
url: "/template/" + id + "/action",
@@ -2298,6 +2240,7 @@ var OpenNebula = {
}
});
},
+
"publish" : function(params)
{
var callback = params.success;
diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js
index b568803c50..8d1d65e550 100644
--- a/src/sunstone/public/js/plugins/hosts-tab.js
+++ b/src/sunstone/public/js/plugins/hosts-tab.js
@@ -44,7 +44,6 @@ var hosts_tab_content =
All \
ID \
Name \
- Group \
Running VMs \
CPU Use \
Memory use \
@@ -318,7 +317,6 @@ function hostElementArray(host_json){
return [ ' ',
host.ID,
host.NAME,
- getGroupName(host.GID),
host.HOST_SHARE.RUNNING_VMS, //rvm
pb_cpu,
pb_mem,
@@ -385,79 +383,79 @@ function updateHostsView (request,host_list){
//Updates the host info panel tab's content and pops it up
function updateHostInfo(request,host){
var host_info = host.HOST;
-
+
//Information tab
var info_tab = {
title : "Host information",
content :
'\
- \
- Host information - '+host_info.NAME+' \
- \
- \
- ID \
- '+host_info.ID+' \
- \
- \
- State \
- '+OpenNebula.Helper.resource_state("host",host_info.STATE)+' \
- \
- \
- Group \
- '+host_info.GID+' \
- \
- \
- IM MAD \
- '+host_info.IM_MAD+' \
- \
- \
- VM MAD \
- '+host_info.VM_MAD+' \
- \
- \
- TM MAD \
- '+host_info.TM_MAD+' \
- \
-
\
- \
- \
- Host shares \
- \
- \
- Max Mem \
- '+humanize_size(host_info.HOST_SHARE.MAX_MEM)+' \
- \
- \
- Used Mem (real) \
- '+humanize_size(host_info.HOST_SHARE.USED_MEM)+' \
- \
- \
- Used Mem (allocated) \
- '+humanize_size(host_info.HOST_SHARE.MAX_USAGE)+' \
- \
- \
- Used CPU (real) \
- '+host_info.HOST_SHARE.USED_CPU+' \
- \
- \
- Used CPU (allocated) \
- '+host_info.HOST_SHARE.CPU_USAGE+' \
- \
- \
- Running VMs \
- '+host_info.HOST_SHARE.RUNNING_VMS+' \
- \
-
'
+ \
+ Host information - '+host_info.NAME+' \
+ \
+ \
+ \
+ ID \
+ '+host_info.ID+' \
+ \
+ \
+ State \
+ '+OpenNebula.Helper.resource_state("host",host_info.STATE)+' \
+ \
+ \
+ IM MAD \
+ '+host_info.IM_MAD+' \
+ \
+ \
+ VM MAD \
+ '+host_info.VM_MAD+' \
+ \
+ \
+ TM MAD \
+ '+host_info.TM_MAD+' \
+ \
+ \
+ \
+ \
+ \
+ Host shares \
+ \
+ \
+ \
+ Max Mem \
+ '+humanize_size(host_info.HOST_SHARE.MAX_MEM)+' \
+ \
+ \
+ Used Mem (real) \
+ '+humanize_size(host_info.HOST_SHARE.USED_MEM)+' \
+ \
+ \
+ Used Mem (allocated) \
+ '+humanize_size(host_info.HOST_SHARE.MAX_USAGE)+' \
+ \
+ \
+ Used CPU (real) \
+ '+host_info.HOST_SHARE.USED_CPU+' \
+ \
+ \
+ Used CPU (allocated) \
+ '+host_info.HOST_SHARE.CPU_USAGE+' \
+ \
+ \
+ Running VMs \
+ '+host_info.HOST_SHARE.RUNNING_VMS+' \
+ \
+ \
+
'
}
-
+
//Template tab
var template_tab = {
title : "Host template",
- content :
- '\
- Host template '+
- prettyPrintJSON(host_info.TEMPLATE)+
- '
'
+ content :
+ '\
+ Host template '+
+ prettyPrintJSON(host_info.TEMPLATE)+
+ '
'
}
var monitor_tab = {
@@ -551,7 +549,7 @@ $(document).ready(function(){
dataTable_hosts.fnClearTable();
addElement([
spinner,
- '','','','','','',''],dataTable_hosts);
+ '','','','','',''],dataTable_hosts);
Sunstone.runAction("Host.list");
setupCreateHostDialog();
diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js
index c0cfcf95b2..b78289cd7f 100644
--- a/src/sunstone/public/js/plugins/images-tab.js
+++ b/src/sunstone/public/js/plugins/images-tab.js
@@ -16,7 +16,7 @@
/*Images tab plugin*/
-var images_tab_content =
+var images_tab_content =
'\
\
\
@@ -25,7 +25,8 @@ var templates_tab_content =
\
All \
ID \
- User \
+ Owner \
+ Group \
Name \
Registration time \
Public \
@@ -37,114 +38,114 @@ var templates_tab_content =
';
var create_template_tmpl = '\
-
\
-
\
-
\
- \
+ \
+ \
+
\
+ \
\
- \
- \
-
\
-
Capacity options \
- \
-
Capacity \
- \
-
Name: \
-
\
-
Name that the VM will get for description purposes. If NAME is not supplied a name generated by one will be in the form of one-<VID>.
\
-
\
- \
-
Memory: \
-
\
-
Amount of RAM required for the VM, in Megabytes.
\
-
\
- \
-
CPU: \
-
\
-
Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.
\
-
\
- \
-
VCPU: \
-
\
-
Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.
\
-
\
- \
-
\
- \
- \
-
\
-
OS and Boot options \
- \
-
Architecture: \
-
\
- i686 \
- x86_64 \
- \
-
CPU architecture to virtualization
\
-
\
- \
- \
-
Boot method: \
-
\
- \
- Kernel \
- Bootloader \
- \
-
Select boot method
\
-
\
- \
-
Kernel: \
-
\
-
Path to the OS kernel to boot the image
\
-
\
- \
-
Initrd: \
-
\
-
Path to the initrd image
\
-
\
- \
-
Root: \
-
\
-
Device to be mounted as root
\
-
\
- \
-
Kernel commands: \
-
\
-
Arguments for the booting kernel
\
-
\
- \
-
Bootloader: \
-
\
-
Path to the bootloader executable
\
-
\
- \
-
Boot: \
-
\
- \
-
Boot device type
\
-
\
- \
-
\
+ \
+ \
+
\
+
Capacity options \
+ \
+
Capacity \
+ \
+
Name: \
+
\
+
Name that the VM will get for description purposes. If NAME is not supplied a name generated by one will be in the form of one-<VID>.
\
+
\
+ \
+
Memory: \
+
\
+
Amount of RAM required for the VM, in Megabytes.
\
+
\
+ \
+
CPU: \
+
\
+
Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.
\
+
\
+ \
+
VCPU: \
+
\
+
Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.
\
+
\
+ \
+
\
+ \
+ \
+
\
+
OS and Boot options \
+ \
+
Architecture: \
+
\
+ i686 \
+ x86_64 \
+ \
+
CPU architecture to virtualization
\
+
\
+ \
+ \
+
Boot method: \
+
\
+ \
+ Kernel \
+ Bootloader \
+ \
+
Select boot method
\
+
\
+ \
+
Kernel: \
+
\
+
Path to the OS kernel to boot the image
\
+
\
+ \
+
Initrd: \
+
\
+
Path to the initrd image
\
+
\
+ \
+
Root: \
+
\
+
Device to be mounted as root
\
+
\
+ \
+
Kernel commands: \
+
\
+
Arguments for the booting kernel
\
+
\
+ \
+
Bootloader: \
+
\
+
Path to the bootloader executable
\
+
\
+ \
+
Boot: \
+
\
+ \
+
Boot device type
\
+
\
+ \
+
\
\
\
\
@@ -175,248 +176,248 @@ var create_template_tmpl = '\
\
\
\
- \
- \
-
\
-
Disks \
- \
- Add disk/image \
- Disk\
- \
- Image\
- \
-
\
-
\
- \
-
Image: \
-
\
- \
-
Name of the image to use
\
-
\
- \
-
Bus: \
-
\
- \
-
Type of disk device to emulate: ide, scsi
\
-
\
- \
-
Target: \
-
\
-
Device to map image disk. If set, it will overwrite the default device mapping
\
-
\
- \
-
Driver: \
-
\
-
Specific image mapping driver. KVM: raw, qcow2. Xen:tap:aio:, file:. VMware unsupported
\
-
\
- \
-
Type: \
-
\
- \
-
Disk type
\
-
\
- \
-
Source: \
-
\
-
Disk file location path or URL
\
-
\
- \
- \
-
Size: \
-
\
-
Size in MB
\
-
\
- \
- \
-
Format: \
-
\
-
Filesystem type for the fs images
\
-
\
- \
-
Clone: \
-
\
- Yes \
- No \
- \
-
Clone this image
\
-
\
- \
-
Save: \
-
\
- No \
- Yes \
- \
-
Save this image after shutting down the VM
\
-
\
- \
-
Read only: \
-
\
- No \
- Yes \
- \
-
Mount image as read-only
\
-
\
- \
-
Add \
-
Remove selected \
-
\
-
Current disks: \
-
\
- \
-
\
-
\
- \
-
\
+ \
+ \
+
\
+
Disks \
+ \
+ Add disk/image \
+ Disk\
+ \
+ Image\
+ \
+
\
+
\
+ \
+
Image: \
+
\
+ \
+
Name of the image to use
\
+
\
+ \
+
Bus: \
+
\
+ \
+
Type of disk device to emulate: ide, scsi
\
+
\
+ \
+
Target: \
+
\
+
Device to map image disk. If set, it will overwrite the default device mapping
\
+
\
+ \
+
Driver: \
+
\
+
Specific image mapping driver. KVM: raw, qcow2. Xen:tap:aio:, file:. VMware unsupported
\
+
\
+ \
+
Type: \
+
\
+ \
+
Disk type
\
+
\
+ \
+
Source: \
+
\
+
Disk file location path or URL
\
+
\
+ \
+ \
+
Size: \
+
\
+
Size in MB
\
+
\
+ \
+ \
+
Format: \
+
\
+
Filesystem type for the fs images
\
+
\
+ \
+
Clone: \
+
\
+ Yes \
+ No \
+ \
+
Clone this image
\
+
\
+ \
+
Save: \
+
\
+ No \
+ Yes \
+ \
+
Save this image after shutting down the VM
\
+
\
+ \
+
Read only: \
+
\
+ No \
+ Yes \
+ \
+
Mount image as read-only
\
+
\
+ \
+
Add \
+
Remove selected \
+
\
+
Current disks: \
+
\
+ \
+
\
+
\
+ \
+
\
\
- \
- \
-
\
-
Network \
- \
- Add network \
- Predefined\
- \
- Manual\
- \
- \
-
\
-
\
- \
-
Network: \
-
\
- \
-
Name of the network to attach this device
\
-
\
- \
-
IP: \
-
\
-
Request an specific IP from the Network
\
-
\
- \
-
MAC: \
-
\
-
HW address associated with the network interface
\
-
\
- \
-
Bridge \
-
\
-
Name of the bridge the network device is going to be attached to
\
-
\
- \
-
Target: \
-
\
-
Name for the tun device created for the VM
\
-
\
- \
-
Script: \
-
\
-
Name of a shell script to be executed after creating the tun device for the VM
\
-
\
- \
-
Model: \
-
\
-
Hardware that will emulate this network interface. With Xen this is the type attribute of the vif.
\
-
\
- \
-
Add \
-
Remove selected \
-
\
-
Current NICs: \
-
\
- \
-
\
- \
-
\
+ \
+ \
+
\
+
Network \
+ \
+ Add network \
+ Predefined\
+ \
+ Manual\
+ \
+ \
+
\
+
\
+ \
+
Network: \
+
\
+ \
+
Name of the network to attach this device
\
+
\
+ \
+
IP: \
+
\
+
Request an specific IP from the Network
\
+
\
+ \
+
MAC: \
+
\
+
HW address associated with the network interface
\
+
\
+ \
+
Bridge \
+
\
+
Name of the bridge the network device is going to be attached to
\
+
\
+ \
+
Target: \
+
\
+
Name for the tun device created for the VM
\
+
\
+ \
+
Script: \
+
\
+
Name of a shell script to be executed after creating the tun device for the VM
\
+
\
+ \
+
Model: \
+
\
+
Hardware that will emulate this network interface. With Xen this is the type attribute of the vif.
\
+
\
+ \
+
Add \
+
Remove selected \
+
\
+
Current NICs: \
+
\
+ \
+
\
+ \
+
\
\
\
- \
- \
+ \
+ \
\
\
- \
- \
-
\
-
Graphics \
- \
-
Graphics type: \
-
\
+ \
+ \
+
\
+
Graphics \
+ \
+
Graphics type: \
+
\
Please select \
- VNC \
- SDL \
- \
-
\
-
\
- \
-
Listen IP: \
-
\
-
IP to listen on
\
-
\
- \
-
Port: \
-
\
-
Port for the VNC server
\
-
\
- \
-
Password: \
-
\
-
Password for the VNC server
\
-
\
- \
-
Keymap \
-
\
-
Keyboard configuration locale to use in the VNC display
\
-
\
- \
-
\
+ VNC \
+ SDL \
+ \
+
\
+
\
+ \
+
Listen IP: \
+
\
+
IP to listen on
\
+
\
+ \
+
Port: \
+
\
+
Port for the VNC server
\
+
\
+ \
+
Password: \
+
\
+
Password for the VNC server
\
+
\
+ \
+
Keymap \
+
\
+
Keyboard configuration locale to use in the VNC display
\
+
\
+ \
+
\
\
\
- \
- \
-
\
-
Add context variables \
-
\
-
Context \
+ \
+ \
+
\
+
Add context variables \
+
\
+
Context \
\
Name: \
\
@@ -439,49 +440,49 @@ var create_template_tmpl = '
\
\
\
\
- \
-
\
-
\
-
Add placement options \
-
\
-
Placement \
- \
-
Requirements: \
-
\
-
Boolean expression that rules out provisioning hosts from list of machines suitable to run this VM
\
-
\
- \
-
Rank: \
-
\
-
This field sets which attribute will be used to sort the suitable hosts for this VM. Basically, it defines which hosts are more suitable than others
\
-
\
- \
-
\
+ \
+
\
+
\
+
Add placement options \
+
\
+
Placement \
+ \
+
Requirements: \
+
\
+
Boolean expression that rules out provisioning hosts from list of machines suitable to run this VM
\
+
\
+ \
+
Rank: \
+
\
+
This field sets which attribute will be used to sort the suitable hosts for this VM. Basically, it defines which hosts are more suitable than others
\
+
\
+ \
+
\
\
\
- \
-
\
-
\
-
Add Hypervisor raw options \
-
\
-
Raw \
- \
- \
-
Data: \
-
\
-
\
-
Raw data to be passed directly to the hypervisor
\
-
\
- \
-
\
+ \
+
\
+
\
+
Add Hypervisor raw options \
+
\
+
Raw \
+ \
+ \
+
Data: \
+
\
+
\
+
Raw data to be passed directly to the hypervisor
\
+
\
+ \
+
\
\
\
\
-
\
-
\
-
Add custom variables \
-
\
-
Custom variables \
+ \
+
\
+
Add custom variables \
+
\
+
Custom variables \
\
Name: \
\
@@ -502,34 +503,34 @@ var create_template_tmpl = '
\
\
\
\
- \
- \
- \
- \
- Create\
- \
- Reset \
-
\
- \
- \
- \
- \
-
\
- Write the Virtual Machine template here \
- \
- \
-
\
- \
- \
- \
- \
- Create\
- \
- Reset \
-
\
- \
- \
-
\
+ \
+ \
+ \
+ \
+ Create\
+ \
+ Reset \
+
\
+ \
+ \
+ \
+
\
+
\
+ Write the Virtual Machine template here \
+ \
+ \
+
\
+ \
+ \
+ \
+ \
+ Create\
+ \
+ Reset \
+
\
+ \
+ \
+
\
';
var templates_select = "";
@@ -537,7 +538,7 @@ var template_list_json = {};
var dataTable_templates;
var template_actions = {
-
+
"Template.create" : {
type: "create",
call: OpenNebula.Template.create,
@@ -545,33 +546,33 @@ var template_actions = {
error: onError,
notify:true
},
-
+
"Template.create_dialog" : {
type: "custom",
call: popUpCreateTemplateDialog
},
-
+
"Template.list" : {
type: "list",
call: OpenNebula.Template.list,
callback: updateTemplatesView,
error: onError
},
-
+
"Template.show" : {
type : "single",
call: OpenNebula.Template.show,
callback: updateTemplateElement,
error: onError
},
-
+
"Template.showinfo" : {
type: "single",
call: OpenNebula.Template.show,
callback: updateTemplateInfo,
error: onError
},
-
+
"Template.refresh" : {
type: "custom",
call: function () {
@@ -579,75 +580,39 @@ var template_actions = {
Sunstone.runAction("Template.list");
},
},
-
+
"Template.autorefresh" : {
type: "custom",
call: function() {
OpenNebula.Template.list({timeout: true, success: updateTemplatesView, error: onError});
}
},
-
- "Template.addattr" : {
- type: "multiple",
- call: function(obj){
- var id_attr = obj.data.id;
- var name = $('#template_attr_name').val();
- var value = $('#template_attr_value').val();
- OpenNebula.Template.addattr(
- {data: {
- id: id_attr,
- name: name,
- value: value
- },
- success: obj.success,
- error: obj.error
- });
+
+ "Template.update_dialog" : {
+ type: "custom",
+ call: popUpTemplateTemplateUpdateDialog
+ },
+
+ "Template.update" : {
+ type: "single",
+ call: OpenNebula.Template.update,
+ callback: function() {
+ notifyMessage("Template updated correctly");
},
- callback : function (req) {
- Sunstone.runAction("Template.show",req.request.data[0]);
- },
- elements: function() { return getSelectedNodes(dataTable_templates); },
error: onError,
- notify: true
+ notify: false
},
-
- "Template.addattr_dialog" : {
- type: "custom",
- call: popUpTemplateAddattrDialog
- },
-
- "Template.updateattr_dialog" : {
- type: "custom",
- call: popUpTemplateAddattrDialog
- },
-
- "Template.rmattr" : {
- type: "multiple",
- call: function(obj){
- var id_attr = obj.data.id;
- var name = $('#template_attr_name').val();
- OpenNebula.Template.rmattr(
- {data: {
- id: id_attr,
- name: name
- },
- success: obj.success,
- error: obj.error
- });
+
+ "Template.fetch_template" : {
+ type: "single",
+ call: OpenNebula.Template.fetch_template,
+ callback: function (request,response) {
+ $('#template_update_dialog #template_update_textarea').val(response.template);
},
- callback: function (req) {
- Sunstone.runAction("Template.show",req.request.data[0]);
- },
- elements: function() { return getSelectedNodes(dataTable_templates); },
error: onError,
- notify: true
+ notify: false
},
-
- "Template.rmattr_dialog" : {
- type: "custom",
- call: popUpTemplateRmattrDialog,
- },
-
+
"Template.publish" : {
type: "multiple",
call: OpenNebula.Template.publish,
@@ -658,7 +623,7 @@ var template_actions = {
error: onError,
notify: true
},
-
+
"Template.unpublish" : {
type: "multiple",
call: OpenNebula.Template.unpublish,
@@ -669,7 +634,7 @@ var template_actions = {
error: onError,
notify: true
},
-
+
"Template.delete" : {
type: "multiple",
call: OpenNebula.Template.delete,
@@ -692,7 +657,27 @@ var template_actions = {
});
},
notify: false
- }
+ },
+ "Template.chown" : {
+ type: "multiple",
+ call: OpenNebula.Template.chown,
+ callback: function (req) {
+ Sunstone.runAction("Template.show",req.request.data[0]);
+ },
+ elements: function() { return getSelectedNodes(dataTable_templates); },
+ error:onError,
+ notify: true
+ },
+ "Template.chgrp" : {
+ type: "multiple",
+ call: OpenNebula.Template.chgrp,
+ callback: function (req) {
+ Sunstone.runAction("Template.show",req.request.data[0]);
+ },
+ elements: function() { return getSelectedNodes(dataTable_templates); },
+ error:onError,
+ notify: true
+ }
}
@@ -708,24 +693,29 @@ var template_buttons = {
text: "+ New",
condition: True
},
+ "Template.update_dialog" : {
+ type: "action",
+ text: "Update a template",
+ condition: True,
+ alwaysActive: true
+ },
"Template.instantiate" : {
type: "action",
text: "Instantiate",
condition: True
},
- "Template.addattr_dialog" : {
- type: "action",
- text: "Add attribute",
+ "Template.chown" : {
+ type: "confirm_with_select",
+ text: "Change owner",
+ select: function() {return users_select;},
+ tip: "Select the new owner:",
condition: True
},
- "Template.updateattr_dialog" : {
- type: "action",
- text: "Update attribute",
- condition: True
- },
- "Template.rmattr_dialog" : {
- type: "action",
- text: "Remove attribute",
+ "Template.chgrp" : {
+ type: "confirm_with_select",
+ text: "Change group",
+ select: function() {return groups_select;},
+ tip: "Select the new group:",
condition: True
},
"action_list" : {
@@ -735,12 +725,12 @@ var template_buttons = {
"Template.publish" : {
type: "action",
text: "Publish",
- condition: True
+ condition: True
},
"Template.unpublish" : {
type: "action",
text: "Unpublish",
- condition: True
+ condition: True
},
}
},
@@ -755,7 +745,7 @@ var template_info_panel = {
"template_info_tab" : {
title: "Template information",
content: ""
- }
+ }
}
var templates_tab = {
@@ -776,7 +766,8 @@ function templateElementArray(template_json){
return [
' ',
template.ID,
- template.USERNAME ? template.USERNAME : getUserName(template.UID),
+ getUserName(template.UID),
+ getGroupName(template.GID),
template.NAME,
pretty_time(template.REGTIME),
parseInt(template.PUBLIC) ? "yes" : "no"
@@ -798,9 +789,9 @@ function templateInfoListener(){
//Updates the select input field with an option for each template
function updateTemplateSelect(){
- templates_select =
- makeSelectOptions(dataTable_templates,1,3,5,"no",2);
-
+ templates_select =
+ makeSelectOptions(dataTable_templates,1,4,7,"no",2);
+
//update static selectors:
$('#create_vm_dialog #template_id').html(templates_select);
$('#speed_virt').html(templates_select);
@@ -841,83 +832,12 @@ function updateTemplatesView(request, templates_list){
}
-// Prepare the dialog to add/remove/update template attributes
-function setupTemplateAttributesDialogs(){
-
- //Append to DOM
- $('div#dialogs').append('
');
-
- //Put HTML in place
- $('#template_attributes_dialog').html(
- '\
- \
- \
-
\
- \
- Name: \
- \
-
\
- \
- Value: \
- \
-
\
- \
- OK \
- Cancel \
-
\
- \
- ');
-
- $('#template_attributes_dialog').dialog({
- autoOpen:false,
- width:400,
- modal:true,
- height:220,
- resizable:false,
- });
-
- $('#template_attributes_dialog button').button();
-
- //Upcase variable names
- $('#template_attr_name').keyup(function(){
- $(this).val($(this).val().toUpperCase());
- });
-
- $('#template_attributes_dialog #template_attr_proceed').click(function(){
- $('#template_attributes_dialog').dialog('close');
- });
-
- $('#template_attributes_dialog #template_attr_cancel').click(function(){
- $('#template_attributes_dialog').dialog('close');
- return false;
- });
-
-}
-
// Popup a dialog to add/update an attribute
-function popUpTemplateAddattrDialog(){
-
- //Show value field and label
- $('#template_attr_value').show();
- $('#template_attr_value').prev().show();
- var desc = "Please write the name and value of the attribute. It will be added or updated in all selected templates:";
- $('#template_attr_proceed').val("Template.addattr");
- $('#template_attr_action_desc').html(desc);
- $('#template_attributes_dialog').dialog('open');
- return false;
-}
-
-// Popup a dialog to remove an attribute
-function popUpTemplateRmattrDialog(){
-
- //Hide value field and label
- $('#template_attr_value').hide();
- $('#template_attr_value').prev().hide();
- var desc = "Please type the attribute you want to remove:";
- $('#template_attr_proceed').val("Template.rmattr");
- $('#template_attr_action_desc').html(desc);
- $('#template_attributes_dialog').dialog('open');
- return false;
+function popUpTemplateTemplateUpdateDialog(){
+ $('#template_update_dialog #template_update_button').val("Template");
+ $('#template_update_dialog #template_update_select').html(templates_select);
+ $('#template_update_dialog').dialog('open');
+ return false;
}
// Callback to update the information panel tabs and pop it up
@@ -926,26 +846,26 @@ function updateTemplateInfo(request,template){
var info_tab = {
title: "Information",
content: '\
- \
- Template "'+template_info.NAME+'" information \
- \
- \
- ID \
- '+template_info.ID+' \
- \
- \
- Name \
- '+template_info.NAME+' \
- \
- \
- Register time \
- '+pretty_time(template_info.REGTIME)+' \
- \
- \
- Public \
- '+(parseInt(template_info.PUBLIC) ? "yes" : "no")+' \
- \
-
'
+ \
+ Template "'+template_info.NAME+'" information \
+ \
+ \
+ ID \
+ '+template_info.ID+' \
+ \
+ \
+ Name \
+ '+template_info.NAME+' \
+ \
+ \
+ Register time \
+ '+pretty_time(template_info.REGTIME)+' \
+ \
+ \
+ Public \
+ '+(parseInt(template_info.PUBLIC) ? "yes" : "no")+' \
+ \
+ '
};
var template_tab = {
title: "Template",
@@ -970,9 +890,9 @@ function setupCreateTemplateDialog(){
// Called when changing tabs. Since we use the same form for both
// KVM, XEN and others we need to do some operation to update it
var vmTabChange = function(event,ui){
- // ui.tab // anchor element of the selected (clicked) tab
- // ui.panel // element, that contains the selected/clicked tab contents
- // ui.index // zero-based index of the selected (clicked) tab
+ // ui.tab // anchor element of the selected (clicked) tab
+ // ui.panel // element, that contains the selected/clicked tab contents
+ // ui.index // zero-based index of the selected (clicked) tab
switch(ui.index){
case 0:
enable_kvm();
@@ -988,7 +908,7 @@ function setupCreateTemplateDialog(){
//hide_disabled();
//show_enabled();
}
-
+
//~ var hide_disabled = function(context) {
//~ var $disabled;
//~ if (!context) {
@@ -996,12 +916,12 @@ function setupCreateTemplateDialog(){
//~ } else {
//~ $disabled = $('.vm_param input:disabled,.vm_param select:disabled',context);
//~ }
- //~
+ //~
//~ $disabled.each(function(){
//~ $(this).parent('.vm_param').hide();
//~ });
//~ }
- //~
+ //~
//~ var show_enabled = function(context){
//~ var $enabled;
//~ if (!context) {
@@ -1009,55 +929,55 @@ function setupCreateTemplateDialog(){
//~ } else {
//~ $enabled = $('.vm_param input:enabled,.vm_param select:enabled',context);
//~ }
- //~
+ //~
//~ $enabled.parent('.vm_param').show();
//~ }
//Using kvm wizard. Updates mandatory tag, optional tags, disable
//XEN-only (and others) items, enables KVM items
- var enable_kvm = function(){
- man_class="kvm";
- opt_class="kvm_opt";
- $(xen_items).attr("disabled","disabled");
+ var enable_kvm = function(){
+ man_class="kvm";
+ opt_class="kvm_opt";
+ $(xen_items).attr("disabled","disabled");
$(vmware_items).attr("disabled","disabled");
- $(kvm_items).removeAttr("disabled");
+ $(kvm_items).removeAttr("disabled");
$('.vm_param .man_icon').css("display","none");
$('.kvm .man_icon').css("display","inline-block");
- //KVM particularities:
+ //KVM particularities:
// * Add no_type option for disks
// * Add driver default option for boot and select it - hide some fields
// * Set the raw type to kvm
// * Show the inputs section
-
- var type_opts =
+
+ var type_opts =
'None \
Disk \
- Floppy \
- CD-ROM \
- Swap \
- FS \
- Block ';
-
- $('div#disks select#TYPE').html(type_opts);
-
- var boot_opts =
+ Floppy \
+ CD-ROM \
+ Swap \
+ FS \
+ Block ';
+
+ $('div#disks select#TYPE').html(type_opts);
+
+ var boot_opts =
'hd \
- fd \
- cdrom \
- network ';
-
+ fd \
+ cdrom \
+ network ';
+
$('div#os_boot_opts select#BOOT').html(boot_opts);
$('div#kernel_bootloader',section_os_boot).show();
$('select#boot_method option').removeAttr("selected");
- $('select#boot_method option#no_boot').html("Driver default");
+ $('select#boot_method option#no_boot').html("Driver default");
$('select#boot_method option').removeAttr("selected");
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
- var bus_opts =
+ var bus_opts =
'IDE \
SCSI \
Virtio ';
@@ -1065,201 +985,201 @@ function setupCreateTemplateDialog(){
$('div#disks select#BUS').html(bus_opts);
- $('input#TYPE', section_raw).val("kvm");
+ $('input#TYPE', section_raw).val("kvm");
- $(section_inputs).show();
+ $(section_inputs).show();
$(section_graphics).show();
-
-
- };
+
+
+ };
// Using XEN wizard. Update mandatory and optional classes, disable
// KVM-only (and other) items, enable XEN fields...
- var enable_xen = function(){
- man_class="xen";
- opt_class="xen_opt";
- $(kvm_items).attr("disabled","disabled");
+ var enable_xen = function(){
+ man_class="xen";
+ opt_class="xen_opt";
+ $(kvm_items).attr("disabled","disabled");
$(vmware_items).attr("disabled","disabled");
- $(xen_items).removeAttr("disabled");
+ $(xen_items).removeAttr("disabled");
$('.vm_param .man_icon').css("display","none");
$('.xen .man_icon').css("display","inline-block");
- // XEN particularities:
+ // XEN particularities:
// * Remove no_type option from disks
// * Remove driver default boot method
// * Set the raw section to XEN
// * Hide the inputs section
-
- var type_opts =
+
+ var type_opts =
'Disk \
- Floppy \
- CD-ROM \
- Swap \
- FS \
- Block ';
-
+ Floppy \
+ CD-ROM \
+ Swap \
+ FS \
+ Block ';
+
$('div#disks select#TYPE').html(type_opts);
$('div#os_boot_opts select#BOOT').empty();
$('div#kernel_bootloader',section_os_boot).show();
- $('select#boot_method option:selected').removeAttr("selected");
+ $('select#boot_method option:selected').removeAttr("selected");
$('select#boot_method option#no_boot').html("Please choose");
- $('.kernel, .bootloader', $('div#os_boot_opts')).hide();
+ $('.kernel, .bootloader', $('div#os_boot_opts')).hide();
- var bus_opts =
+ var bus_opts =
'IDE \
SCSI ';
$('div#disks select#BUS').html(bus_opts);
- $('input#TYPE', section_raw).val("xen");
- $(section_inputs).hide(); //not present for xen
+ $('input#TYPE', section_raw).val("xen");
+ $(section_inputs).hide(); //not present for xen
$(section_graphics).show();
-
-
-
- };
+
+
+
+ };
var enable_vmware = function() {
man_class="vmware";
- opt_class="vmware_opt";
- $(xen_items).attr("disabled","disabled");
+ opt_class="vmware_opt";
+ $(xen_items).attr("disabled","disabled");
$(kvm_items).attr("disabled","disabled");
- $(vmware_items).removeAttr("disabled");
+ $(vmware_items).removeAttr("disabled");
$('.vm_param .man_icon').css("display","none");
$('.vmware .man_icon').css("display","inline-block");
- //VMWARE particularities
+ //VMWARE particularities
// * Add no_type option for disks
// * Set the raw type to kvm
// * Hide the inputs and graphics section
// * Hide boot method
- var type_opts =
+ var type_opts =
'File \
- CD-ROM \
- Block ';
-
+ CD-ROM \
+ Block ';
+
$('div#os_boot_opts select#BOOT').empty();
-
+
$('div#disks select#BOOT').empty();
$('select#boot_method option').removeAttr("selected");
- $('select#boot_method option#no_boot').html("Driver default");
+ $('select#boot_method option#no_boot').html("Driver default");
$('select#boot_method option').removeAttr("selected");
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
- var bus_opts =
+ var bus_opts =
'IDE \
SCSI ';
$('div#disks select#BUS').html(bus_opts);
- $('input#TYPE', section_raw).val("vmware");
+ $('input#TYPE', section_raw).val("vmware");
- $(section_inputs).hide();
+ $(section_inputs).hide();
$(section_graphics).hide();
-
+
$('div#kernel_bootloader',section_os_boot).hide();
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
}
//This function checks that all mandatory items within a section
//have some value. Returns true if so, false if not.
- var mandatory_filter = function(context){
- var man_items = "."+man_class;
+ var mandatory_filter = function(context){
+ var man_items = "."+man_class;
+
+ //find enabled mandatory items in this context
+ man_items = $(man_items+' input:visible, '+man_items+' select:visible',context);
+ var r = true;
- //find enabled mandatory items in this context
- man_items = $(man_items+' input:visible, '+man_items+' select:visible',context);
- var r = true;
-
//we fail it the item is enabled and has no value
- $.each(man_items,function(){
- if ($(this).parents(".vm_param").attr("disabled") ||
- !($(this).val().length)) {
- r = false;
- return false;
- };
- });
- return r;
+ $.each(man_items,function(){
+ if ($(this).parents(".vm_param").attr("disabled") ||
+ !($(this).val().length)) {
+ r = false;
+ return false;
+ };
+ });
+ return r;
- };
+ };
//Adds an option element to a multiple select box. Before doing so,
//it checks that the desired filter is passed
- var box_add_element = function(context,box_tag,filter){
- var value="";
- var params= $('.vm_param',context);
- var inputs= $('input:enabled',params);
- var selects = $('select:enabled',params);
- var fields = $.merge(inputs,selects);
+ var box_add_element = function(context,box_tag,filter){
+ var value="";
+ var params= $('.vm_param',context);
+ var inputs= $('input:enabled',params);
+ var selects = $('select:enabled',params);
+ var fields = $.merge(inputs,selects);
- //are fields passing the filter?
- var result = filter();
- if (!result) {
- notifyError("There are mandatory parameters missing in this section");
- return false;
- }
+ //are fields passing the filter?
+ var result = filter();
+ if (!result) {
+ notifyError("There are mandatory parameters missing in this section");
+ return false;
+ }
+
+ value={};
- value={};
-
//With each enabled field we form a JSON object
var id = null;
- $.each(fields,function(){
- if (!($(this).parents(".vm_param").attr("disabled")) &&
- $(this).val().length){
- //Pick up parent's ID if we do not have one
- id = $(this).attr('id').length ? $(this).attr('id') : $(this).parent().attr('id');
- value[id] = $(this).val();
- }
- });
- var value_string = JSON.stringify(value);
- var option= ''+
- stringJSON(value)+
- ' ';
- $('select'+box_tag,context).append(option);
- return false;
- };
+ $.each(fields,function(){
+ if (!($(this).parents(".vm_param").attr("disabled")) &&
+ $(this).val().length){
+ //Pick up parent's ID if we do not have one
+ id = $(this).attr('id').length ? $(this).attr('id') : $(this).parent().attr('id');
+ value[id] = $(this).val();
+ }
+ });
+ var value_string = JSON.stringify(value);
+ var option= ''+
+ stringJSON(value)+
+ ' ';
+ $('select'+box_tag,context).append(option);
+ return false;
+ };
//Removes selected elements from a multiple select box
- var box_remove_element = function(section_tag,box_tag){
- var context = $(section_tag);
- $('select'+box_tag+' :selected',context).remove();
- return false;
- };
+ var box_remove_element = function(section_tag,box_tag){
+ var context = $(section_tag);
+ $('select'+box_tag+' :selected',context).remove();
+ return false;
+ };
//Given the JSON of a VM template (or of a section of it), it crawls
- //the fields of certain section (context) and add their name and
+ //the fields of certain section (context) and add their name and
//values to the template JSON.
- var addSectionJSON = function(template_json,context){
- var params= $('.vm_param',context);
- var inputs= $('input:enabled',params);
- var selects = $('select:enabled',params);
- var fields = $.merge(inputs,selects);
+ var addSectionJSON = function(template_json,context){
+ var params= $('.vm_param',context);
+ var inputs= $('input:enabled',params);
+ var selects = $('select:enabled',params);
+ var fields = $.merge(inputs,selects);
- fields.each(function(){
- if (!($(this).parents(".vm_param").attr("disabled"))){ //if ! disabled
- if ($(this).val().length){ //if has a length
- template_json[$(this).attr('id')]=$(this).val();
- }
- }
- });
- }
+ fields.each(function(){
+ if (!($(this).parents(".vm_param").attr("disabled"))){ //if ! disabled
+ if ($(this).val().length){ //if has a length
+ template_json[$(this).attr('id')]=$(this).val();
+ }
+ }
+ });
+ }
// Given an array (usually empty), a section (context) and a tag for
- // a multiple select in that section, it adds the contents of the
+ // a multiple select in that section, it adds the contents of the
// box as objects in the array.
// TODO: Make it return a new array?
- var addBoxJSON = function(array,context,box_tag){
- $('select'+box_tag+' option',context).each(function(){
- array.push( JSON.parse($(this).val()) );
- });
- }
+ var addBoxJSON = function(array,context,box_tag){
+ $('select'+box_tag+' option',context).each(function(){
+ array.push( JSON.parse($(this).val()) );
+ });
+ }
//Given an object, removes those elements which are empty
- //Used to clean up a template JSON before submitting
+ //Used to clean up a template JSON before submitting
//it to opennebula.js
var removeEmptyObjects = function(obj){
for (elem in obj){
@@ -1291,40 +1211,40 @@ function setupCreateTemplateDialog(){
}
//Toggles the icon when a section is folded/unfolded
- var iconToggle = function(){
- $('.icon_right').toggle(
- function(e){
- $('span',e.currentTarget).removeClass("ui-icon-plusthick");
- $('span',e.currentTarget).addClass("ui-icon-minusthick");
- },function(e){
- $('span',e.currentTarget).removeClass("ui-icon-minusthick");
- $('span',e.currentTarget).addClass("ui-icon-plusthick");
- });
- }
+ var iconToggle = function(){
+ $('.icon_right').toggle(
+ function(e){
+ $('span',e.currentTarget).removeClass("ui-icon-plusthick");
+ $('span',e.currentTarget).addClass("ui-icon-minusthick");
+ },function(e){
+ $('span',e.currentTarget).removeClass("ui-icon-minusthick");
+ $('span',e.currentTarget).addClass("ui-icon-plusthick");
+ });
+ }
// Set ups the capacity section
- var capacity_setup = function(){
+ var capacity_setup = function(){
//Actually there is nothing to set up, but it used to be
//possible to hide it like others
/*
- $('fieldset',section_capacity).hide();
- $('#add_capacity',section_capacity).click(function(){
- $('fieldset',section_capacity).toggle();
- return false;
- });
+ $('fieldset',section_capacity).hide();
+ $('#add_capacity',section_capacity).click(function(){
+ $('fieldset',section_capacity).toggle();
+ return false;
+ });
*/
- }
-
- //Sets up the OS_BOOT section
- var os_boot_setup = function(){
- $('fieldset',section_os_boot).hide();
- $('.bootloader, .kernel',section_os_boot).hide();
+ }
- $('#add_os_boot_opts',section_os_boot).click(function(){
- $('fieldset',section_os_boot).toggle();
+ //Sets up the OS_BOOT section
+ var os_boot_setup = function(){
+ $('fieldset',section_os_boot).hide();
+ $('.bootloader, .kernel',section_os_boot).hide();
+
+ $('#add_os_boot_opts',section_os_boot).click(function(){
+ $('fieldset',section_os_boot).toggle();
return false;
- });
+ });
//Chrome workaround
@@ -1334,28 +1254,28 @@ function setupCreateTemplateDialog(){
//Depending on the boot method we enable/disable some options
$('#boot_method',section_os_boot).click(function(){
- select = $(this).val();
- switch (select)
- {
- case "kernel":
- $('.bootloader',section_os_boot).hide();
- $('.bootloader',section_os_boot).attr("disabled","disabled");
- $('.kernel',section_os_boot).show();
- $('.kernel',section_os_boot).removeAttr("disabled");
- break;
- case "bootloader":
- $('.kernel',section_os_boot).hide();
- $('.kernel',section_os_boot).attr("disabled","disabled");
- $('.bootloader',section_os_boot).show();
- $('.bootloader',section_os_boot).removeAttr("disabled");
- break;
- default:
- $('.kernel, .bootloader',section_os_boot).hide();
- $('.kernel, .bootloader',section_os_boot).attr("disabled","disabled");
- $('.kernel input, .bootloader input',section_os_boot).val("");
- };
- });
- };
+ select = $(this).val();
+ switch (select)
+ {
+ case "kernel":
+ $('.bootloader',section_os_boot).hide();
+ $('.bootloader',section_os_boot).attr("disabled","disabled");
+ $('.kernel',section_os_boot).show();
+ $('.kernel',section_os_boot).removeAttr("disabled");
+ break;
+ case "bootloader":
+ $('.kernel',section_os_boot).hide();
+ $('.kernel',section_os_boot).attr("disabled","disabled");
+ $('.bootloader',section_os_boot).show();
+ $('.bootloader',section_os_boot).removeAttr("disabled");
+ break;
+ default:
+ $('.kernel, .bootloader',section_os_boot).hide();
+ $('.kernel, .bootloader',section_os_boot).attr("disabled","disabled");
+ $('.kernel input, .bootloader input',section_os_boot).val("");
+ };
+ });
+ };
// Sets up the features section
var features_setup = function(){
@@ -1368,49 +1288,49 @@ function setupCreateTemplateDialog(){
};
// Sets up the disk section
- var disks_setup = function(){
+ var disks_setup = function(){
- $('fieldset',section_disks).hide();
- $('.vm_param', section_disks).hide();
- //$('#image_vs_disk',section_disks).show();
+ $('fieldset',section_disks).hide();
+ $('.vm_param', section_disks).hide();
+ //$('#image_vs_disk',section_disks).show();
- $('#add_disks', section_disks).click(function(){
- $('fieldset',section_disks).toggle();
+ $('#add_disks', section_disks).click(function(){
+ $('fieldset',section_disks).toggle();
return false;
- });
+ });
//Depending on adding a disk or a image we need to show/hide
//different options and make then mandatory or not
- $('#image_vs_disk input',section_disks).click(function(){
- //$('fieldset',section_disks).show();
+ $('#image_vs_disk input',section_disks).click(function(){
+ //$('fieldset',section_disks).show();
$('.vm_param', section_disks).show();
- var select = $('#image_vs_disk :checked',section_disks).val();
- switch (select)
- {
- case "disk":
- $('.add_image',section_disks).hide();
- $('.add_image',section_disks).attr("disabled","disabled");
- $('.add_disk',section_disks).show();
- $('.add_disk',section_disks).removeAttr("disabled");
- $('#TARGET',section_disks).parent().removeClass(opt_class);
- $('#TARGET',section_disks).parent().addClass(man_class);
- break;
- case "image":
- $('.add_disk',section_disks).hide();
- $('.add_disk',section_disks).attr("disabled","disabled");
- $('.add_image',section_disks).show();
- $('.add_image',section_disks).removeAttr("disabled");
- $('#TARGET',section_disks).parent().removeClass(man_class);
- $('#TARGET',section_disks).parent().addClass(opt_class);
- break;
- }
- $('#SIZE',section_disks).parent().hide();
- $('#SIZE',section_disks).parent().attr("disabled","disabled");
- $('#FORMAT',section_disks).parent().hide();
- $('#SIZE',section_disks).parent().attr("disabled","disabled");
- $('#TYPE :selected',section_disks).removeAttr("selected");
+ var select = $('#image_vs_disk :checked',section_disks).val();
+ switch (select)
+ {
+ case "disk":
+ $('.add_image',section_disks).hide();
+ $('.add_image',section_disks).attr("disabled","disabled");
+ $('.add_disk',section_disks).show();
+ $('.add_disk',section_disks).removeAttr("disabled");
+ $('#TARGET',section_disks).parent().removeClass(opt_class);
+ $('#TARGET',section_disks).parent().addClass(man_class);
+ break;
+ case "image":
+ $('.add_disk',section_disks).hide();
+ $('.add_disk',section_disks).attr("disabled","disabled");
+ $('.add_image',section_disks).show();
+ $('.add_image',section_disks).removeAttr("disabled");
+ $('#TARGET',section_disks).parent().removeClass(man_class);
+ $('#TARGET',section_disks).parent().addClass(opt_class);
+ break;
+ }
+ $('#SIZE',section_disks).parent().hide();
+ $('#SIZE',section_disks).parent().attr("disabled","disabled");
+ $('#FORMAT',section_disks).parent().hide();
+ $('#SIZE',section_disks).parent().attr("disabled","disabled");
+ $('#TYPE :selected',section_disks).removeAttr("selected");
//hide_disabled(section_disks);
- });
+ });
//Chrome workaround
$('select#TYPE',section_disks).change(function(){
@@ -1419,239 +1339,239 @@ function setupCreateTemplateDialog(){
//Depending on the type of disk we need to show/hide
//different options and make then mandatory or not
- $('select#TYPE',section_disks).click(function(){
- var select = $(this).val();
- switch (select) {
- //size,format,target
- case "swap":
- //size mandatory
- $('#SIZE',section_disks).parent().show();
- $('#SIZE',section_disks).parent().removeAttr("disabled");
- $('#SIZE',section_disks).parent().removeClass(opt_class);
- $('#SIZE',section_disks).parent().addClass(man_class);
+ $('select#TYPE',section_disks).click(function(){
+ var select = $(this).val();
+ switch (select) {
+ //size,format,target
+ case "swap":
+ //size mandatory
+ $('#SIZE',section_disks).parent().show();
+ $('#SIZE',section_disks).parent().removeAttr("disabled");
+ $('#SIZE',section_disks).parent().removeClass(opt_class);
+ $('#SIZE',section_disks).parent().addClass(man_class);
- //target optional
- $('#TARGET',section_disks).parent().removeClass(man_class);
- $('#TARGET',section_disks).parent().addClass(opt_class);
+ //target optional
+ $('#TARGET',section_disks).parent().removeClass(man_class);
+ $('#TARGET',section_disks).parent().addClass(opt_class);
- //format hidden
- $('#FORMAT',section_disks).parent().hide();
- $('#FORMAT',section_disks).parent().attr("disabled","disabled");
+ //format hidden
+ $('#FORMAT',section_disks).parent().hide();
+ $('#FORMAT',section_disks).parent().attr("disabled","disabled");
//source hidden
$('#SOURCE',section_disks).parent().hide();
$('#SOURCE',section_disks).parent().
attr("disabled","disabled");
- break;
- case "fs":
- //size mandatory
- $('#SIZE',section_disks).parent().show();
- $('#SIZE',section_disks).parent().removeAttr("disabled");
- $('#SIZE',section_disks).parent().removeClass(opt_class);
- $('#SIZE',section_disks).parent().addClass(man_class);
+ break;
+ case "fs":
+ //size mandatory
+ $('#SIZE',section_disks).parent().show();
+ $('#SIZE',section_disks).parent().removeAttr("disabled");
+ $('#SIZE',section_disks).parent().removeClass(opt_class);
+ $('#SIZE',section_disks).parent().addClass(man_class);
- //target mandatory
- $('#TARGET',section_disks).parent().removeClass(opt_class);
- $('#TARGET',section_disks).parent().addClass(man_class);
+ //target mandatory
+ $('#TARGET',section_disks).parent().removeClass(opt_class);
+ $('#TARGET',section_disks).parent().addClass(man_class);
- //format mandatory
- $('#FORMAT',section_disks).parent().show();
- $('#FORMAT',section_disks).parent().removeAttr("disabled");
- $('#FORMAT',section_disks).parent().removeClass(opt_class);
- $('#FORMAT',section_disks).parent().addClass(man_class);
+ //format mandatory
+ $('#FORMAT',section_disks).parent().show();
+ $('#FORMAT',section_disks).parent().removeAttr("disabled");
+ $('#FORMAT',section_disks).parent().removeClass(opt_class);
+ $('#FORMAT',section_disks).parent().addClass(man_class);
//source hidden
$('#SOURCE',section_disks).parent().hide();
$('#SOURCE',section_disks).parent().
attr("disabled","disabled");
- break;
- case "block":
- //size shown and optional
- $('#SIZE',section_disks).parent().show();
- $('#SIZE',section_disks).parent().removeAttr("disabled");
- $('#SIZE',section_disks).parent().removeClass(man_class);
- $('#SIZE',section_disks).parent().addClass(opt_class);
+ break;
+ case "block":
+ //size shown and optional
+ $('#SIZE',section_disks).parent().show();
+ $('#SIZE',section_disks).parent().removeAttr("disabled");
+ $('#SIZE',section_disks).parent().removeClass(man_class);
+ $('#SIZE',section_disks).parent().addClass(opt_class);
- //target mandatory
- $('#TARGET',section_disks).parent().removeClass(opt_class);
- $('#TARGET',section_disks).parent().addClass(man_class);
+ //target mandatory
+ $('#TARGET',section_disks).parent().removeClass(opt_class);
+ $('#TARGET',section_disks).parent().addClass(man_class);
+
+ //format hidden
+ $('#FORMAT',section_disks).parent().hide();
+ $('#FORMAT',section_disks).parent().attr("disabled","disabled");
- //format hidden
- $('#FORMAT',section_disks).parent().hide();
- $('#FORMAT',section_disks).parent().attr("disabled","disabled");
-
//source hidden
$('#SOURCE',section_disks).parent().hide();
$('#SOURCE',section_disks).parent().
attr("disabled","disabled");
- break;
- case "floppy":
- case "disk":
- case "cdrom":
+ break;
+ case "floppy":
+ case "disk":
+ case "cdrom":
default:
- //size hidden
- $('#SIZE',section_disks).parent().hide();
- $('#SIZE',section_disks).parent().attr("disabled","disabled");
+ //size hidden
+ $('#SIZE',section_disks).parent().hide();
+ $('#SIZE',section_disks).parent().attr("disabled","disabled");
- //target mandatory
- $('#TARGET',section_disks).parent().removeClass(opt_class);
- $('#TARGET',section_disks).parent().addClass(man_class);
+ //target mandatory
+ $('#TARGET',section_disks).parent().removeClass(opt_class);
+ $('#TARGET',section_disks).parent().addClass(man_class);
- //format optional
- $('#FORMAT',section_disks).parent().hide();
- $('#FORMAT',section_disks).parent().attr("disabled","disabled");
+ //format optional
+ $('#FORMAT',section_disks).parent().hide();
+ $('#FORMAT',section_disks).parent().attr("disabled","disabled");
//source shown
$('#SOURCE',section_disks).parent().show();
$('#SOURCE',section_disks).parent().
removeAttr("disabled");
- }
+ }
//hide_disabled(section_disks);
- });
+ });
//Our filter for the disks section fields is the mandatory
//filter for this section
- var diskFilter = function(){
- return mandatory_filter(section_disks);
- };
+ var diskFilter = function(){
+ return mandatory_filter(section_disks);
+ };
- $('#add_disk_button',section_disks).click(function(){
- box_add_element(section_disks,'#disks_box',diskFilter);
- return false;
- });
- $('#remove_disk_button',section_disks).click(function(){
- box_remove_element(section_disks,'#disks_box');
- return false;
- });
- };
+ $('#add_disk_button',section_disks).click(function(){
+ box_add_element(section_disks,'#disks_box',diskFilter);
+ return false;
+ });
+ $('#remove_disk_button',section_disks).click(function(){
+ box_remove_element(section_disks,'#disks_box');
+ return false;
+ });
+ };
// Sets up the network section
- var networks_setup = function(){
+ var networks_setup = function(){
- $('.vm_param',section_networks).hide();
- $('fieldset',section_networks).hide();
+ $('.vm_param',section_networks).hide();
+ $('fieldset',section_networks).hide();
- $('#add_networks',section_networks).click(function(){
- $('fieldset',section_networks).toggle();
+ $('#add_networks',section_networks).click(function(){
+ $('fieldset',section_networks).toggle();
return false;
- });
+ });
//Depending on adding predefined network or not we show/hide
//some fields
- $('#network_vs_niccfg input',section_networks).click(function(){
+ $('#network_vs_niccfg input',section_networks).click(function(){
- select = $('#network_vs_niccfg :checked',section_networks).val();
- switch (select) {
- case "network":
- $('.niccfg',section_networks).hide();
- $('.niccfg',section_networks).attr("disabled","disabled");
- $('.network',section_networks).show();
- $('.network',section_networks).removeAttr("disabled");
- break;
- case "niccfg":
- $('.network',section_networks).hide();
- $('.network',section_networks).attr("disabled","disabled");
- $('.niccfg',section_networks).show();
- $('.niccfg',section_networks).removeAttr("disabled");
- break;
- }
+ select = $('#network_vs_niccfg :checked',section_networks).val();
+ switch (select) {
+ case "network":
+ $('.niccfg',section_networks).hide();
+ $('.niccfg',section_networks).attr("disabled","disabled");
+ $('.network',section_networks).show();
+ $('.network',section_networks).removeAttr("disabled");
+ break;
+ case "niccfg":
+ $('.network',section_networks).hide();
+ $('.network',section_networks).attr("disabled","disabled");
+ $('.niccfg',section_networks).show();
+ $('.niccfg',section_networks).removeAttr("disabled");
+ break;
+ }
//hide_disabled(section_networks);
- });
+ });
- //The filter to add a new network checks that we have selected a
+ //The filter to add a new network checks that we have selected a
//network, or that the ip or mac are set
//TODO: Improve this check
var nicFilter = function(){
return mandatory_filter(section_networks);
};
- $('#add_nic_button',section_networks).click(function(){
- box_add_element(section_networks,'#nics_box',nicFilter);
- return false;
- });
- $('#remove_nic_button',section_networks).click(function(){
- box_remove_element(section_networks,'#nics_box');
- return false;
- });
+ $('#add_nic_button',section_networks).click(function(){
+ box_add_element(section_networks,'#nics_box',nicFilter);
+ return false;
+ });
+ $('#remove_nic_button',section_networks).click(function(){
+ box_remove_element(section_networks,'#nics_box');
+ return false;
+ });
- };
+ };
//Sets up the input section - basicly enabling adding and removing from box
- var inputs_setup = function() {
- $('fieldset',section_inputs).hide();
+ var inputs_setup = function() {
+ $('fieldset',section_inputs).hide();
- $('#add_inputs',section_inputs).click(function(){
- $('fieldset',section_inputs).toggle();
+ $('#add_inputs',section_inputs).click(function(){
+ $('fieldset',section_inputs).toggle();
return false;
- });
+ });
+
+ $('#add_input_button',section_inputs).click(function(){
+ //no filter
+ box_add_element(section_inputs,'#inputs_box',True);
+ return false;
+ });
+ $('#remove_input_button',section_inputs).click(function(){
+ box_remove_element(section_inputs,'#inputs_box');
+ return false;
+ });
+ };
- $('#add_input_button',section_inputs).click(function(){
- //no filter
- box_add_element(section_inputs,'#inputs_box',True);
- return false;
- });
- $('#remove_input_button',section_inputs).click(function(){
- box_remove_element(section_inputs,'#inputs_box');
- return false;
- });
- };
-
//Set up the graphics section
- var graphics_setup = function(){
- $('fieldset',section_graphics).hide();
+ var graphics_setup = function(){
+ $('fieldset',section_graphics).hide();
$('.vm_param',section_graphics).hide();
$('select#TYPE',section_graphics).parent().show();
- $('#add_graphics',section_graphics).click(function(){
- $('fieldset',section_graphics).toggle();
+ $('#add_graphics',section_graphics).click(function(){
+ $('fieldset',section_graphics).toggle();
return false;
- });
+ });
//Chrome workaround
$('select#TYPE',section_graphics).change(function(){
$(this).trigger("click");
});
- $('select#TYPE',section_graphics).click(function(){
- g_type = $(this).val();
- switch (g_type) {
- case "vnc":
+ $('select#TYPE',section_graphics).click(function(){
+ g_type = $(this).val();
+ switch (g_type) {
+ case "vnc":
$('#LISTEN',section_graphics).parent().show();
- $('#PORT',section_graphics).parent().show();
- $('#PASSWD',section_graphics).parent().show();
- $('#KEYMAP',section_graphics).parent().show();
- $('#PORT',section_graphics).parent().removeAttr("disabled");
- $('#PASSWD',section_graphics).parent().removeAttr("disabled");
- $('#KEYMAP',section_graphics).parent().removeAttr("disabled");
- break;
- case "sdl":
+ $('#PORT',section_graphics).parent().show();
+ $('#PASSWD',section_graphics).parent().show();
+ $('#KEYMAP',section_graphics).parent().show();
+ $('#PORT',section_graphics).parent().removeAttr("disabled");
+ $('#PASSWD',section_graphics).parent().removeAttr("disabled");
+ $('#KEYMAP',section_graphics).parent().removeAttr("disabled");
+ break;
+ case "sdl":
$('#LISTEN',section_graphics).parent().show();
- $('#PORT',section_graphics).parent().hide();
- $('#PASSWD',section_graphics).parent().hide();
- $('#KEYMAP',section_graphics).parent().hide();
- $('#PORT',section_graphics).parent().attr("disabled","disabled");
- $('#PASSWD',section_graphics).parent().attr("disabled","disabled");
- $('#KEYMAP',section_graphics).parent().attr("disabled","disabled");
- break;
+ $('#PORT',section_graphics).parent().hide();
+ $('#PASSWD',section_graphics).parent().hide();
+ $('#KEYMAP',section_graphics).parent().hide();
+ $('#PORT',section_graphics).parent().attr("disabled","disabled");
+ $('#PASSWD',section_graphics).parent().attr("disabled","disabled");
+ $('#KEYMAP',section_graphics).parent().attr("disabled","disabled");
+ break;
default:
$('#LISTEN',section_graphics).parent().hide();
- $('#PORT',section_graphics).parent().hide();
- $('#PASSWD',section_graphics).parent().hide();
- $('#KEYMAP',section_graphics).parent().hide();
+ $('#PORT',section_graphics).parent().hide();
+ $('#PASSWD',section_graphics).parent().hide();
+ $('#KEYMAP',section_graphics).parent().hide();
- }
- });
+ }
+ });
- }
+ }
//Set up the context section - TODO: Apply improvements here...
- var context_setup = function(){
- $('fieldset',section_context).hide();
+ var context_setup = function(){
+ $('fieldset',section_context).hide();
- $('#add_context',section_context).click(function(){
+ $('#add_context',section_context).click(function(){
$('fieldset',section_context).toggle();
return false;
- });
-
+ });
+
$('#add_context_button', section_context).click(function(){
var name = $('#var_name',section_context).val();
var value = $('#var_value',section_context).val();
@@ -1663,38 +1583,38 @@ function setupCreateTemplateDialog(){
name+'='+value+
'';
$('select#context_box',section_context).append(option);
- return false;
+ return false;
});
-
+
$('#remove_context_button', section_context).click(function(){
box_remove_element(section_context,'#context_box');
- return false;
+ return false;
});
- };
+ };
// Set up the placement section
- var placement_setup = function(){
- $('fieldset',section_placement).hide();
+ var placement_setup = function(){
+ $('fieldset',section_placement).hide();
- $('#add_placement',section_placement).click(function(){
- $('fieldset',section_placement).toggle();
+ $('#add_placement',section_placement).click(function(){
+ $('fieldset',section_placement).toggle();
return false;
- });
+ });
- };
+ };
// Set up the raw section
- var raw_setup = function(){
- $('fieldset',section_raw).hide();
+ var raw_setup = function(){
+ $('fieldset',section_raw).hide();
- $('#add_raw',section_raw).click(function(){
- $('fieldset',section_raw).toggle();
+ $('#add_raw',section_raw).click(function(){
+ $('fieldset',section_raw).toggle();
return false;
- });
- };
-
+ });
+ };
+
//set up the custom variables section
var custom_variables_setup = function(){
$('fieldset',section_custom_var).hide();
@@ -1717,74 +1637,74 @@ function setupCreateTemplateDialog(){
name+'='+value+
'';
$('select#custom_var_box',section_custom_var).append(option);
- return false;
+ return false;
});
$('#remove_custom_var_button', section_custom_var).click(
function(){
box_remove_element(section_custom_var,'#custom_var_box');
- return false;
+ return false;
});
}
//***CREATE VM DIALOG MAIN BODY***
-
+
$('div#dialogs').append('
');
- //Insert HTML in place
- $('#create_template_dialog').html(create_template_tmpl);
+ //Insert HTML in place
+ $('#create_template_dialog').html(create_template_tmpl);
//Enable tabs
- $('#template_create_tabs').tabs({
+ $('#template_create_tabs').tabs({
select:vmTabChange
});
- //Prepare jquery dialog
+ //Prepare jquery dialog
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
- $('#create_template_dialog').dialog({
- autoOpen: false,
- modal: true,
- width: 700,
+ $('#create_template_dialog').dialog({
+ autoOpen: false,
+ modal: true,
+ width: 700,
height: height
- });
-
+ });
+
// Enhace buttons
$('#create_template_dialog button').button();
// Setup tips200
setupTips($('#create_template_dialog'));
-
+
//Enable different icon for folded/unfolded categories
iconToggle(); //toogle +/- buttons
- //Sections, used to stay within their scope
- var section_capacity = $('#capacity');
- var section_os_boot = $('#os_boot_opts');
+ //Sections, used to stay within their scope
+ var section_capacity = $('#capacity');
+ var section_os_boot = $('#os_boot_opts');
var section_features = $('#features');
- var section_disks = $('#disks');
- var section_networks = $('#networks');
- var section_inputs = $('#inputs');
- var section_graphics = $('#graphics');
- var section_context = $('#context');
- var section_placement = $('#placement');
- var section_raw = $('#raw');
+ var section_disks = $('#disks');
+ var section_networks = $('#networks');
+ var section_inputs = $('#inputs');
+ var section_graphics = $('#graphics');
+ var section_context = $('#context');
+ var section_placement = $('#placement');
+ var section_raw = $('#raw');
var section_custom_var = $('#custom_var');
- //Different selector for items of kvm and xen (mandatory and optional)
- var items = '.vm_param input,.vm_param select';
- var kvm_man_items = '.kvm input,.kvm select';
- var kvm_opt_items = '.kvm_opt input, .kvm_opt select';
- var kvm_items = kvm_man_items +','+kvm_opt_items;
- var xen_man_items = '.xen input,.xen select';
- var xen_opt_items = '.xen_opt input, .xen_opt select';
- var xen_items = xen_man_items +','+ xen_opt_items;
+ //Different selector for items of kvm and xen (mandatory and optional)
+ var items = '.vm_param input,.vm_param select';
+ var kvm_man_items = '.kvm input,.kvm select';
+ var kvm_opt_items = '.kvm_opt input, .kvm_opt select';
+ var kvm_items = kvm_man_items +','+kvm_opt_items;
+ var xen_man_items = '.xen input,.xen select';
+ var xen_opt_items = '.xen_opt input, .xen_opt select';
+ var xen_items = xen_man_items +','+ xen_opt_items;
var vmware_man_items = '.vmware input,.vmware select';
- var vmware_opt_items = '.vmware_opt input, .vmware_opt select';
- var vmware_items = vmware_man_items +','+ vmware_opt_items;
+ var vmware_opt_items = '.vmware_opt input, .vmware_opt select';
+ var vmware_items = vmware_man_items +','+ vmware_opt_items;
- //Starting template type, optional items class and mandatory items class
- var templ_type = "kvm";
- var opt_class=".kvm_opt";
- var man_class=".kvm";
+ //Starting template type, optional items class and mandatory items class
+ var templ_type = "kvm";
+ var opt_class=".kvm_opt";
+ var man_class=".kvm";
- enable_kvm(); //enable all kvm options
+ enable_kvm(); //enable all kvm options
//Fold/unfold all sections button
$('#fold_unfold_vm_params').toggle(
@@ -1799,75 +1719,75 @@ function setupCreateTemplateDialog(){
});
//initialise all sections
- capacity_setup();
- os_boot_setup();
+ capacity_setup();
+ os_boot_setup();
features_setup();
- disks_setup();
- networks_setup();
- inputs_setup();
- graphics_setup();
- context_setup();
- placement_setup();
- raw_setup();
+ disks_setup();
+ networks_setup();
+ inputs_setup();
+ graphics_setup();
+ context_setup();
+ placement_setup();
+ raw_setup();
custom_variables_setup();
//Process form
- $('button#create_template_form_easy').click(function(){
- //validate form
+ $('button#create_template_form_easy').click(function(){
+ //validate form
- var vm_json = {};
+ var vm_json = {};
var name,value,boot_method;
- //process capacity options
- var scope = section_capacity;
+ //process capacity options
+ var scope = section_capacity;
- if (!mandatory_filter(scope)){
- notifyError("There are mandatory fields missing in the capacity section");
- return false;
- };
- addSectionJSON(vm_json,scope);
+ if (!mandatory_filter(scope)){
+ notifyError("There are mandatory fields missing in the capacity section");
+ return false;
+ };
+ addSectionJSON(vm_json,scope);
- //process os_boot_opts
- scope= section_os_boot;
- switch (templ_type){
- case "xen":
+ //process os_boot_opts
+ scope= section_os_boot;
+ switch (templ_type){
+ case "xen":
boot_method = $('#boot_method option:selected',scope).val();
- if (!boot_method.length){
- notifyError("Xen templates must specify a boot method");
- return false;}
- };
+ if (!boot_method.length){
+ notifyError("Xen templates must specify a boot method");
+ return false;}
+ };
- if (!mandatory_filter(scope)){
- notifyError("There are mandatory fields missing in the OS Boot options section");
- return false;
- };
+ if (!mandatory_filter(scope)){
+ notifyError("There are mandatory fields missing in the OS Boot options section");
+ return false;
+ };
vm_json["OS"] = {};
- addSectionJSON(vm_json["OS"],scope);
+ addSectionJSON(vm_json["OS"],scope);
//Fetch pae and acpi options
scope = section_features;
vm_json["FEATURES"] = {};
addSectionJSON(vm_json["FEATURES"],scope);
- //process disks -> fetch from box
- scope = section_disks;
- vm_json["DISK"] = [];
- addBoxJSON(vm_json["DISK"],scope,'#disks_box');
+ //process disks -> fetch from box
+ scope = section_disks;
+ vm_json["DISK"] = [];
+ addBoxJSON(vm_json["DISK"],scope,'#disks_box');
- //process nics -> fetch from box
- scope = section_networks;
- vm_json["NIC"] = [];
- addBoxJSON(vm_json["NIC"],scope,'#nics_box');
+ //process nics -> fetch from box
+ scope = section_networks;
+ vm_json["NIC"] = [];
+ addBoxJSON(vm_json["NIC"],scope,'#nics_box');
- //process inputs -> fetch from box
- scope = section_inputs;
- vm_json["INPUT"] = [];
- addBoxJSON(vm_json["INPUT"],scope,'#inputs_box');
+ //process inputs -> fetch from box
+ scope = section_inputs;
+ vm_json["INPUT"] = [];
+ addBoxJSON(vm_json["INPUT"],scope,'#inputs_box');
- //process graphics -> fetch fields with value
- scope = section_graphics;
- vm_json["GRAPHICS"] = {};
- addSectionJSON(vm_json["GRAPHICS"],scope);
+ //process graphics -> fetch fields with value
+ scope = section_graphics;
+ vm_json["GRAPHICS"] = {};
+ addSectionJSON(vm_json["GRAPHICS"],scope);
//context
scope = section_context;
@@ -1888,10 +1808,10 @@ function setupCreateTemplateDialog(){
$('input#RANK',scope).val(rank);
addSectionJSON(vm_json,scope);
- //raw -> if value set type to driver and fetch
- scope = section_raw;
- vm_json["RAW"] = {};
- addSectionJSON(vm_json["RAW"],scope);
+ //raw -> if value set type to driver and fetch
+ scope = section_raw;
+ vm_json["RAW"] = {};
+ addSectionJSON(vm_json["RAW"],scope);
//custom vars
scope = section_custom_var;
@@ -1906,33 +1826,33 @@ function setupCreateTemplateDialog(){
//wrap it in the "vmtemplate" object
vm_json = {vmtemplate: vm_json};
-
-
+
+
Sunstone.runAction("Template.create",vm_json);
-
+
$('#create_template_dialog').dialog('close');
- return false;
- });
+ return false;
+ });
//Handle manual forms
- $('button#create_template_form_manual').click(function(){
- var template = $('#textarea_vm_template').val();
+ $('button#create_template_form_manual').click(function(){
+ var template = $('#textarea_vm_template').val();
//wrap it in the "vm" object
template = {"vmtemplate": {"template_raw": template}};
Sunstone.runAction("Template.create",template);
- $('#create_template_dialog').dialog('close');
- return false;
- });
+ $('#create_template_dialog').dialog('close');
+ return false;
+ });
//Reset form - empty boxes
- $('button#reset_vm_form').click(function(){
- $('select#disks_box option',section_disks).remove();
- $('select#nics_box option',section_networks).remove();
- $('select#inputs_box option',section_inputs).remove();
- return true;
- });
+ $('button#reset_vm_form').click(function(){
+ $('select#disks_box option',section_disks).remove();
+ $('select#nics_box option',section_networks).remove();
+ $('select#inputs_box option',section_inputs).remove();
+ return true;
+ });
@@ -1945,42 +1865,41 @@ function popUpCreateTemplateDialog(){
// Set the autorefresh interval for the datatable
function setTemplateAutorefresh() {
setInterval(function(){
- var checked = $('input:checked',dataTable_templates.fnGetNodes());
+ var checked = $('input:checked',dataTable_templates.fnGetNodes());
var filter = $("#datatable_templates_filter input").attr("value");
- if (!checked.length && !filter.length){
+ if (!checked.length && !filter.length){
Sunstone.runAction("Template.autorefresh");
- }
- },INTERVAL+someTime());
+ }
+ },INTERVAL+someTime());
}
//The DOM is ready at this point
$(document).ready(function(){
-
- dataTable_templates = $("#datatable_templates").dataTable({
+
+ dataTable_templates = $("#datatable_templates").dataTable({
"bJQueryUI": true,
"bSortClasses": false,
"bAutoWidth":false,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
- { "bSortable": false, "aTargets": ["check"] },
- { "sWidth": "60px", "aTargets": [0,3] },
- { "sWidth": "35px", "aTargets": [1] },
- { "sWidth": "100px", "aTargets": [2,3] }
- ]
+ { "bSortable": false, "aTargets": ["check"] },
+ { "sWidth": "60px", "aTargets": [0] },
+ { "sWidth": "35px", "aTargets": [1] },
+ { "sWidth": "100px", "aTargets": [2,3,4] }
+ ]
});
-
+
dataTable_templates.fnClearTable();
addElement([
spinner,
- '','','','',''],dataTable_templates);
+ '','','','','',''],dataTable_templates);
Sunstone.runAction("Template.list");
-
+
setupCreateTemplateDialog();
- setupTemplateAttributesDialogs();
setTemplateAutorefresh();
-
+
initCheckAllBoxes(dataTable_templates);
tableCheckboxesListener(dataTable_templates);
templateInfoListener();
-
+
})
diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js
index 5368685ca7..85440944c7 100644
--- a/src/sunstone/public/js/plugins/users-tab.js
+++ b/src/sunstone/public/js/plugins/users-tab.js
@@ -19,7 +19,7 @@ var user_list_json = {};
var dataTable_users;
var users_select="";
-var users_tab_content =
+var users_tab_content =
'\
\
\
@@ -29,6 +29,7 @@ var users_tab_content =
All \
ID \
Name \
+ Groups \
\
\
\
@@ -39,18 +40,18 @@ var users_tab_content =
var create_user_tmpl =
'\
\
- \
- Username: \
- \
- Password: \
- \
-
\
- \
- \
- \
- Create \
- Reset \
-
\
+ \
+ Username: \
+ \
+ Password: \
+ \
+
\
+ \
+ \
+ \
+ Create \
+ Reset \
+
\
\
';
@@ -62,19 +63,19 @@ var user_actions = {
error: onError,
notify: true
},
-
+
"User.create_dialog" : {
type: "custom",
call: popUpCreateUserDialog
},
-
+
"User.list" : {
type: "list",
call: OpenNebula.User.list,
callback: updateUsersView,
error: onError
},
-
+
"User.refresh" : {
type: "custom",
call: function () {
@@ -82,7 +83,7 @@ var user_actions = {
Sunstone.runAction("User.list");
},
},
-
+
"User.autorefresh" : {
type: "custom",
call: function(){
@@ -91,7 +92,7 @@ var user_actions = {
condition: function(){ uid == 0 },
notify: false
},
-
+
"User.delete" : {
type: "multiple",
call: OpenNebula.User.delete,
@@ -134,18 +135,46 @@ Sunstone.addMainTab('users_tab',users_tab);
// Returns an array with the values from the user_json ready to be
// added to the dataTable
function userElementArray(user_json){
- var user = user_json.USER;
+ var user = user_json.USER;
if (!user.NAME || user.NAME == {}){
name = "";
} else {
name = user.NAME;
}
-
- return [
- ' ',
- user.ID,
- name
- ]
+
+ var i = 1;
+ var groups_str=getGroupName(user.GID)+", ";
+ var groups_full_str=getGroupName(user.GID)+", ";
+ var group_field;
+
+ if (user.GROUPS.ID){
+ $.each(user.GROUPS.ID,function() {
+ if (i<=5) {
+ groups_str+=getGroupName(this)+", ";
+ };
+ groups_full_str+=getGroupName(this)+", ";
+ i++;
+ });
+ if (i>0){
+ groups_str = groups_str.slice(0, -2);
+ groups_full_str = groups_str.slice(0, -2);
+ };
+ if (i>5){
+ groups_str+="...";
+ group_field = ''+groups_str+'
'+groups_full_str+'
';
+ } else {
+ group_field=groups_str;
+ };
+ }
+
+
+
+ return [
+ ' ',
+ user.ID,
+ name,
+ group_field
+ ]
}
@@ -168,8 +197,8 @@ function deleteUserElement(req){
// Callback to add a single user element
function addUserElement(request,user_json){
- var element = userElementArray(user_json);
- addElement(element,dataTable_users);
+ var element = userElementArray(user_json);
+ addElement(element,dataTable_users);
updateUserSelect();
}
@@ -179,7 +208,7 @@ function updateUsersView(request,users_list){
var user_list_array = [];
$.each(user_list_json,function(){
- user_list_array.push(userElementArray(this));
+ user_list_array.push(userElementArray(this));
});
updateView(user_list_array,dataTable_users);
updateDashboard("users",user_list_json);
@@ -191,31 +220,31 @@ function setupCreateUserDialog(){
$('div#dialogs').append('
');
$('#create_user_dialog').html(create_user_tmpl);
- //Prepare jquery dialog
- $('#create_user_dialog').dialog({
- autoOpen: false,
- modal:true,
- width: 400
- });
-
+ //Prepare jquery dialog
+ $('#create_user_dialog').dialog({
+ autoOpen: false,
+ modal:true,
+ width: 400
+ });
+
$('#create_user_dialog button').button();
-
+
$('#create_user_form').submit(function(){
- var user_name=$('#username',this).val();
- var user_password=$('#pass',this).val();
+ var user_name=$('#username',this).val();
+ var user_password=$('#pass',this).val();
if (!user_name.length && !user_password.length){
notifyError("User name and password must be filled in");
return false;
}
-
- var user_json = { "user" :
- { "name" : user_name,
- "password" : user_password }
- };
- Sunstone.runAction("User.create",user_json);
- $('#create_user_dialog').dialog('close');
- return false;
- });
+
+ var user_json = { "user" :
+ { "name" : user_name,
+ "password" : user_password }
+ };
+ Sunstone.runAction("User.create",user_json);
+ $('#create_user_dialog').dialog('close');
+ return false;
+ });
}
function popUpCreateUserDialog(){
@@ -250,7 +279,7 @@ $(document).ready(function(){
dataTable_users.fnClearTable();
addElement([
spinner,
- '',''],dataTable_users);
+ '','',''],dataTable_users);
Sunstone.runAction("User.list");
@@ -259,5 +288,6 @@ $(document).ready(function(){
initCheckAllBoxes(dataTable_users);
tableCheckboxesListener(dataTable_users);
+ shortenedInfoFields('#datatable_users');
}
})
diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index 65b29f663f..86553419dd 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -47,7 +47,7 @@ var vm_graphs = [
}
];
-var vms_tab_content =
+var vms_tab_content =
'\
\
\
@@ -56,7 +56,8 @@ var vms_tab_content =
\
All \
ID \
- User \
+ Owner \
+ Group \
Name \
Status \
CPU \
@@ -73,19 +74,19 @@ var vms_tab_content =
var create_vm_tmpl ='\
\
- \
-
VM Name: \
-
\
+
\
+ VM Name: \
+ \
Select template: \
- \
+ \
\
-
\
- \
-
\
- \
- Create \
- Reset \
-
\
+ \
+ \
+ \
+ \
+ Create \
+ Reset \
+
\
\
';
@@ -101,33 +102,33 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.create_dialog" : {
type: "custom",
call: popUpCreateVMDialog,
},
-
+
"VM.list" : {
type: "list",
call: OpenNebula.VM.list,
callback: updateVMachinesView,
error: onError
},
-
+
"VM.show" : {
type: "single",
call: OpenNebula.VM.show,
callback: updateVMachineElement,
error: onError
},
-
+
"VM.showinfo" : {
type: "single",
call: OpenNebula.VM.show,
callback: updateVMInfo,
error: onError
},
-
+
"VM.refresh" : {
type: "custom",
call : function (){
@@ -135,14 +136,14 @@ var vm_actions = {
Sunstone.runAction("VM.list");
},
},
-
+
"VM.autorefresh" : {
type: "custom",
call : function() {
OpenNebula.VM.list({timeout: true, success: updateVMachinesView,error: onError});
},
},
-
+
"VM.deploy" : {
type: "multiple",
call: OpenNebula.VM.deploy,
@@ -153,7 +154,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.migrate" : {
type: "multiple",
call: OpenNebula.VM.migrate,
@@ -164,7 +165,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.livemigrate" : {
type: "multiple",
call: OpenNebula.VM.livemigrate,
@@ -175,7 +176,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.hold" : {
type: "multiple",
call: OpenNebula.VM.hold,
@@ -186,7 +187,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.release" : {
type: "multiple",
call: OpenNebula.VM.release,
@@ -197,7 +198,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.suspend" : {
type: "multiple",
call: OpenNebula.VM.suspend,
@@ -208,7 +209,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.resume" : {
type: "multiple",
call: OpenNebula.VM.resume,
@@ -219,7 +220,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.stop" : {
type: "multiple",
call: OpenNebula.VM.stop,
@@ -230,7 +231,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.restart" : {
type: "multiple",
call: OpenNebula.VM.restart,
@@ -241,7 +242,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.resubmit" : {
type: "multiple",
call: OpenNebula.VM.resubmit,
@@ -252,7 +253,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.saveasmultiple" : {
type: "custom",
call: function(){
@@ -261,12 +262,12 @@ var vm_actions = {
},
elements: function() { return getSelectedNodes(dataTable_vMachines); }
},
-
+
"VM.saveas" : {
type: "custom",
call: function(obj) {
OpenNebula.VM.saveas(
- {data:obj,
+ {data:obj,
success: function (req) {
Sunstone.runAction("VM.show",
req.request.data[0][0]);
@@ -293,7 +294,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.cancel" : {
type: "multiple",
call: OpenNebula.VM.cancel,
@@ -304,7 +305,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.delete" : {
type: "multiple",
call: OpenNebula.VM.delete,
@@ -313,7 +314,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.log" : {
type: "single",
call: OpenNebula.VM.log,
@@ -337,7 +338,7 @@ var vm_actions = {
onError(request,error_json);
}
},
-
+
"VM.startvnc" : {
type: "single",
call: OpenNebula.VM.startvnc,
@@ -345,7 +346,7 @@ var vm_actions = {
error: onError,
notify: true
},
-
+
"VM.stopvnc" : {
type: "single",
call: OpenNebula.VM.stopvnc,
@@ -373,6 +374,26 @@ var vm_actions = {
},
error: onError
},
+ "VM.chown" : {
+ type: "multiple",
+ call: OpenNebula.VM.chown,
+ callback: function (req) {
+ Sunstone.runAction("VM.show",req.request.data[0]);
+ },
+ elements: function() { return getSelectedNodes(dataTable_vMachines); },
+ error: onError,
+ notify: true
+ },
+ "VM.chgrp" : {
+ type: "multiple",
+ call: OpenNebula.VM.chgrp,
+ callback: function (req) {
+ Sunstone.runAction("VM.show",req.request.data[0]);
+ },
+ elements: function() { return getSelectedNodes(dataTable_vMachines); },
+ error: onError,
+ notify: true
+ }
}
@@ -384,22 +405,38 @@ var vm_buttons = {
img: "/images/Refresh-icon.png",
condition: True
},
-
+
"VM.create_dialog" : {
type: "action",
text: "+ New",
condition: True,
alwaysActive: true,
-
+
},
-
+
+ "VM.chown" : {
+ type: "confirm_with_select",
+ text: "Change owner",
+ select: function() {return users_select;},
+ tip: "Select the new owner:",
+ condition: True
+ },
+
+ "VM.chgrp" : {
+ type: "confirm_with_select",
+ text: "Change group",
+ select: function() {return groups_select;},
+ tip: "Select the new group:",
+ condition: True
+ },
+
"VM.shutdown" : {
type: "confirm",
text: "Shutdown",
tip: "This will initiate the shutdown process in the selected VMs",
condition: True
},
-
+
"action_list" : {
type: "select",
actions: {
@@ -422,7 +459,7 @@ var vm_buttons = {
else {return ""}
},
condition: True
-
+
},
"VM.livemigrate" : {
type: "confirm_with_select",
@@ -432,49 +469,49 @@ var vm_buttons = {
if (hosts_select){return hosts_select}
else {return ""}
},
- condition: True
+ condition: True
},
"VM.hold" : {
type: "confirm",
text: "Hold",
tip: "This will hold selected pending VMs from being deployed",
- condition: True
+ condition: True
},
"VM.release" : {
type: "confirm",
text: "Release",
tip: "This will release held machines",
- condition: True
+ condition: True
},
"VM.suspend" : {
type: "confirm",
text: "Suspend",
tip: "This will suspend selected machines",
- condition: True
+ condition: True
},
"VM.resume" : {
type: "confirm",
text: "Resume",
tip: "This will resume selected stopped or suspended VMs",
- condition: True
+ condition: True
},
"VM.stop" : {
type: "confirm",
text: "Stop",
tip: "This will stop selected VMs",
- condition: True
+ condition: True
},
"VM.restart" : {
type: "confirm",
text: "Restart",
tip: "This will redeploy selected VMs (in UNKNOWN or BOOT state)",
- condition: True
+ condition: True
},
"VM.resubmit" : {
type: "confirm",
text: "Resubmit",
tip: "This will resubmits VMs to PENDING state",
- condition: True
+ condition: True
},
"VM.saveasmultiple" : {
type: "action",
@@ -485,12 +522,12 @@ var vm_buttons = {
type: "confirm",
text: "Cancel",
tip: "This will cancel selected VMs",
- condition: True
+ condition: True
}
},
condition: True
},
-
+
"VM.delete" : {
type: "confirm",
text: "Delete",
@@ -534,142 +571,145 @@ function str_start_time(vm){
// Returns an array formed by the information contained in the vm_json
// and ready to be introduced in a dataTable
function vMachineElementArray(vm_json){
- var vm = vm_json.VM;
+ var vm = vm_json.VM;
var state = OpenNebula.Helper.resource_state("vm",vm.STATE);
if (state == "ACTIVE") {
state = OpenNebula.Helper.resource_state("vm_lcm",vm.LCM_STATE);
}
-
-
- return [
- ' ',
- vm.ID,
- vm.USERNAME ? vm.USERNAME : getUserName(vm.UID),
- vm.NAME,
- state,
- vm.CPU,
- humanize_size(vm.MEMORY),
- vm.HISTORY ? vm.HISTORY.HOSTNAME : "--",
- str_start_time(vm),
- vncIcon(vm)
- ]
+
+ return [
+ ' ',
+ vm.ID,
+ getUserName(vm.UID),
+ getGroupName(vm.GID),
+ vm.NAME,
+ state,
+ vm.CPU,
+ humanize_size(vm.MEMORY),
+ vm.HISTORY ? vm.HISTORY.HOSTNAME : "--",
+ str_start_time(vm),
+ vncIcon(vm)
+ ];
}
//Creates a listener for the TDs of the VM table
function vMachineInfoListener(){
- $('#tbodyvmachines tr').live("click", function(e){
- if ($(e.target).is('input') || $(e.target).is('a img')) {return true;}
+ $('#tbodyvmachines tr').live("click", function(e){
+ if ($(e.target).is('input') || $(e.target).is('a img')) {return true;}
popDialogLoading();
- var aData = dataTable_vMachines.fnGetData(this);
- var id = $(aData[0]).val();
+ var aData = dataTable_vMachines.fnGetData(this);
+ var id = $(aData[0]).val();
Sunstone.runAction("VM.showinfo",id);
- return false;
- });
+ return false;
+ });
}
// Callback to refresh a single element from the list
function updateVMachineElement(request, vm_json){
- var id = vm_json.VM.ID;
- var element = vMachineElementArray(vm_json);
- updateSingleElement(element,dataTable_vMachines,'#vm_'+id)
+ var id = vm_json.VM.ID;
+ var element = vMachineElementArray(vm_json);
+ updateSingleElement(element,dataTable_vMachines,'#vm_'+id)
}
// Callback to delete a single element from the list
function deleteVMachineElement(req){
- deleteElement(dataTable_vMachines,'#vm_'+req.request.data);
+ deleteElement(dataTable_vMachines,'#vm_'+req.request.data);
}
// Callback to add an element to the list
function addVMachineElement(request,vm_json){
var id = vm_json.VM.ID;
- var element = vMachineElementArray(vm_json);
- addElement(element,dataTable_vMachines);
+ var element = vMachineElementArray(vm_json);
+ addElement(element,dataTable_vMachines);
}
// Callback to refresh the list of Virtual Machines
function updateVMachinesView(request, vmachine_list){
- vmachine_list_json = vmachine_list;
- var vmachine_list_array = [];
+ vmachine_list_json = vmachine_list;
+ var vmachine_list_array = [];
- $.each(vmachine_list,function(){
- vmachine_list_array.push( vMachineElementArray(this));
- });
+ $.each(vmachine_list,function(){
+ vmachine_list_array.push( vMachineElementArray(this));
+ });
- updateView(vmachine_list_array,dataTable_vMachines);
- updateDashboard("vms",vmachine_list_json);
+ updateView(vmachine_list_array,dataTable_vMachines);
+ updateDashboard("vms",vmachine_list_json);
}
// Refreshes the information panel for a VM
function updateVMInfo(request,vm){
- var vm_info = vm.VM;
- var info_tab = {
+ var vm_info = vm.VM;
+ var info_tab = {
title : "VM information",
content: '\
- \
- Virtual Machine information - '+vm_info.NAME+' \
- \
- \
- ID \
- '+vm_info.ID+' \
- \
- \
- Name \
- '+vm_info.NAME+' \
- \
- \
- State \
- '+OpenNebula.Helper.resource_state("vm",vm_info.STATE)+' \
- \
- \
- LCM State \
- '+OpenNebula.Helper.resource_state("vm_lcm",vm_info.LCM_STATE)+' \
- \
- \
- Start time \
- '+pretty_time(vm_info.STIME)+' \
- \
- \
- Deploy ID \
- '+(typeof(vm_info.DEPLOY_ID) == "object" ? "-" : vm_info.DEPLOY_ID)+' \
- \
-
\
- \
- \
- Monitoring information \
- \
- \
- Net_TX \
- '+vm_info.NET_TX+' \
- \
- \
- Net_RX \
- '+vm_info.NET_RX+' \
- \
- \
- Used Memory \
- '+humanize_size(vm_info.MEMORY)+' \
- \
- \
- Used CPU \
- '+vm_info.CPU+' \
- \
- \
- VNC Session \
- '+vncIcon(vm_info)+' \
- \
-
'
+ \
+ Virtual Machine information - '+vm_info.NAME+' \
+ \
+ \
+ \
+ ID \
+ '+vm_info.ID+' \
+ \
+ \
+ Name \
+ '+vm_info.NAME+' \
+ \
+ \
+ State \
+ '+OpenNebula.Helper.resource_state("vm",vm_info.STATE)+' \
+ \
+ \
+ LCM State \
+ '+OpenNebula.Helper.resource_state("vm_lcm",vm_info.LCM_STATE)+' \
+ \
+ \
+ Start time \
+ '+pretty_time(vm_info.STIME)+' \
+ \
+ \
+ Deploy ID \
+ '+(typeof(vm_info.DEPLOY_ID) == "object" ? "-" : vm_info.DEPLOY_ID)+' \
+ \
+ \
+ \
+ \
+ Monitoring information \
+ \
+ \
+ \
+ Net_TX \
+ '+vm_info.NET_TX+' \
+ \
+ \
+ Net_RX \
+ '+vm_info.NET_RX+' \
+ \
+ \
+ Used Memory \
+ '+humanize_size(vm_info.MEMORY)+' \
+ \
+ \
+ Used CPU \
+ '+vm_info.CPU+' \
+ \
+ \
+ VNC Session \
+ '+vncIcon(vm_info)+' \
+ \
+ \
+
'
}
var template_tab = {
title: "VM Template",
content: '\
- VM template '+
- prettyPrintJSON(vm_info.TEMPLATE)+
- '
'
+ VM template '+
+ prettyPrintJSON(vm_info.TEMPLATE)+
+ ''
}
var log_tab = {
@@ -700,30 +740,30 @@ function updateVMInfo(request,vm){
function setupCreateVMDialog(){
$('div#dialogs').append('
');
- //Insert HTML in place
- $('#create_vm_dialog').html(create_vm_tmpl);
+ //Insert HTML in place
+ $('#create_vm_dialog').html(create_vm_tmpl);
+
+ //Prepare jquery dialog
+ $('#create_vm_dialog').dialog({
+ autoOpen: false,
+ modal: true,
+ width: 400
+ });
- //Prepare jquery dialog
- $('#create_vm_dialog').dialog({
- autoOpen: false,
- modal: true,
- width: 400
- });
-
$('#create_vm_dialog button').button();
-
+
$('#create_vm_dialog #create_vm_proceed').click(function(){
var vm_name = $('#create_vm_form #vm_name').val();
var template_id = $('#create_vm_form #template_id').val();
var vm_json = { vm: { vm_name: vm_name, template_id : template_id }};
-
+
Sunstone.runAction("VM.create",vm_json);
$('#create_vm_dialog').dialog('close');
return false;
});
-
+
$('#create_vm_dialog #create_vm_cancel').click(function(){
-
+
});
}
@@ -748,7 +788,7 @@ function setupSaveasDialog(){
\
\
');
-
+
$('#saveas_vm_dialog').dialog({
autoOpen:false,
width:600,
@@ -756,7 +796,7 @@ function setupSaveasDialog(){
height:350,
resizable:true,
});
-
+
$('#saveas_vm_dialog #vm_saveas_proceed').click(function(){
var elems = $('#saveas_vm_dialog #saveas_tabs div.saveas_tab');
var args = [];
@@ -765,7 +805,7 @@ function setupSaveasDialog(){
var disk_id = $('#vm_disk_id',this).val();
var image_name = $('#image_name',this).val();
//var type = $('#image_type',this).val();
-
+
if (!id.length || !disk_id.length || !image_name.length) {
notifyError("Skipping VM "+id+
". No disk id or image name specified");
@@ -784,23 +824,23 @@ function setupSaveasDialog(){
if (args.length > 0){
notifySubmit("VM.saveas",args);
}
-
- $('#saveas_vm_dialog').dialog('close');
+
+ $('#saveas_vm_dialog').dialog('close');
return false;
});
-
+
$('#saveas_vm_dialog #vm_saveas_cancel').click(function(){
- $('#saveas_vm_dialog').dialog('close');
+ $('#saveas_vm_dialog').dialog('close');
return false;
});
-
+
}
function popUpSaveasDialog(elems){
$('#saveas_vm_dialog #saveas_tabs').tabs('destroy');
$('#saveas_vm_dialog #saveas_tabs').empty();
$('#saveas_vm_dialog #saveas_tabs').html('');
-
+
$.each(elems,function(){
var li = 'VM '+this+' '
$('#saveas_vm_dialog #saveas_tabs ul').append(li);
@@ -873,12 +913,12 @@ function saveasDisksCallback(req,response){
//Prepares autorefresh
function setVMAutorefresh(){
setInterval(function(){
- var checked = $('input:checked',dataTable_vMachines.fnGetNodes());
+ var checked = $('input:checked',dataTable_vMachines.fnGetNodes());
var filter = $("#datatable_vmachines_filter input").attr("value");
- if (!checked.length && !filter.length){
+ if (!checked.length && !filter.length){
Sunstone.runAction("VM.autorefresh");
- }
- },INTERVAL+someTime()); //so that not all refreshing is done at the same time
+ }
+ },INTERVAL+someTime()); //so that not all refreshing is done at the same time
}
@@ -920,7 +960,7 @@ function setupVNC(){
//Append to DOM
$('div#dialogs').append('
');
-
+
$('#vnc_dialog').html('\
\
\
@@ -935,12 +975,12 @@ function setupVNC(){
Canvas not supported.\
\
');
-
- $('#sendCtrlAltDelButton').click(function(){
+
+ $('#sendCtrlAltDelButton').click(function(){
rfb.sendCtrlAltDel();
- return false;
+ return false;
});
-
+
$('#vnc_dialog').dialog({
autoOpen:false,
width:700,
@@ -948,13 +988,13 @@ function setupVNC(){
height:500,
resizable:true,
});
-
+
$( "#vnc_dialog" ).bind( "dialogclose", function(event, ui) {
var id = $("#vnc_dialog").attr("vm_id");
Sunstone.runAction("VM.stopvnc",id);
-
+
});
-
+
$('.vnc').live("click",function(){
//Which VM is it?
var id = $(this).attr("vm_id");
@@ -976,19 +1016,19 @@ function vncCallback(request,response){
'updateState': updateVNCState});
//fetch things from clicked element host - port - password
vnc_port = response["port"];
-
+
//Hopefully this is returning sunstone server address, where
//the proxy is running
vnc_host = window.location.hostname;
vnc_pw = response["password"];
-
+
setTimeout(function(){
rfb.connect(vnc_host, vnc_port, vnc_pw);
$('#vnc_dialog').dialog('open');
},4000);
-
-
-
+
+
+
}
function vncIcon(vm){
@@ -1003,37 +1043,37 @@ function vncIcon(vm){
gr_icon = ' ';
}
return gr_icon;
-
+
}
// At this point the DOM is ready and the sunstone.js ready() has been run.
$(document).ready(function(){
-
+
dataTable_vMachines = $("#datatable_vmachines").dataTable({
- "bJQueryUI": true,
- "bSortClasses": false,
- "sPaginationType": "full_numbers",
- "bAutoWidth":false,
- "aoColumnDefs": [
- { "bSortable": false, "aTargets": ["check"] },
- { "sWidth": "60px", "aTargets": [0] },
- { "sWidth": "35px", "aTargets": [1,9] },
- { "sWidth": "100px", "aTargets": [2] }
- ]
+ "bJQueryUI": true,
+ "bSortClasses": false,
+ "sPaginationType": "full_numbers",
+ "bAutoWidth":false,
+ "aoColumnDefs": [
+ { "bSortable": false, "aTargets": ["check"] },
+ { "sWidth": "60px", "aTargets": [0] },
+ { "sWidth": "35px", "aTargets": [1,9] },
+ { "sWidth": "100px", "aTargets": [2,3,4] }
+ ]
});
-
+
dataTable_vMachines.fnClearTable();
addElement([
spinner,
- '','','','','','','','',''],dataTable_vMachines);
- Sunstone.runAction("VM.list");
-
+ '','','','','','','','','',''],dataTable_vMachines);
+ Sunstone.runAction("VM.list");
+
setupCreateVMDialog();
setupSaveasDialog();
setVMAutorefresh();
setupVNC();
-
+
initCheckAllBoxes(dataTable_vMachines);
tableCheckboxesListener(dataTable_vMachines);
vMachineInfoListener();
-})
+})
\ No newline at end of file
diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js
index 3ee670aa0e..bea38b260b 100644
--- a/src/sunstone/public/js/plugins/vnets-tab.js
+++ b/src/sunstone/public/js/plugins/vnets-tab.js
@@ -25,7 +25,8 @@ var vnets_tab_content =
\
All \
ID \
- User \
+ Owner \
+ Group \
Name \
Type \
Bridge \
@@ -221,7 +222,7 @@ var vnet_actions = {
"Network.chgrp" : {
type: "multiple",
- call: OpenNebula.Network.chown,
+ call: OpenNebula.Network.chgrp,
callback: function (req) {
Sunstone.runAction("Network.show",req.request.data[0]);
},
@@ -305,28 +306,24 @@ Sunstone.addInfoPanel('vnet_info_panel',vnet_info_panel);
//returns an array with the VNET information fetched from the JSON object
function vNetworkElementArray(vn_json){
- var network = vn_json.VNET;
+ var network = vn_json.VNET;
var total_leases = "0";
-
+
if (network.TOTAL_LEASES){
total_leases = network.TOTAL_LEASES;
} else if (network.LEASES && network.LEASES.LEASE){
total_leases = network.LEASES.LEASE.length ? network.LEASES.LEASE.length : "1";
}
-
- //Does the JSON bring a username field? Otherwise try
- //to get it from the users dataTable
- var username = network.USERNAME? network.USERNAME : getUserName(network.UID)
-
-
+
return [' ',
- network.ID,
- username,
- network.NAME,
- parseInt(network.TYPE) ? "FIXED" : "RANGED",
- network.BRIDGE,
- parseInt(network.PUBLIC) ? "yes" : "no",
- total_leases ];
+ network.ID,
+ getUserName(network.UID),
+ getGroupName(network.GID),
+ network.NAME,
+ parseInt(network.TYPE) ? "FIXED" : "RANGED",
+ network.BRIDGE,
+ parseInt(network.PUBLIC) ? "yes" : "no",
+ total_leases ];
}
@@ -346,7 +343,7 @@ function vNetworkInfoListener(){
//updates the vnet select different options
function updateNetworkSelect(){
vnetworks_select=
- makeSelectOptions(dataTable_vNetworks,1,3,6,"no",2);
+ makeSelectOptions(dataTable_vNetworks,1,4,7,"no",2);
//update static selectors:
//in the VM creation dialog
@@ -446,134 +443,131 @@ function updateVNetworkInfo(request,vn){
//Prepares the vnet creation dialog
function setupCreateVNetDialog() {
-
$('div#dialogs').append('
');
- $('#create_vn_dialog').html(create_vn_tmpl);
-
-
- //Prepare the jquery-ui dialog. Set style options here.
- $('#create_vn_dialog').dialog({
- autoOpen: false,
- modal: true,
- width: 475,
- height: 500
- });
+ $('#create_vn_dialog').html(create_vn_tmpl);
- //Make the tabs look nice for the creation mode
- $('#vn_tabs').tabs();
+ //Prepare the jquery-ui dialog. Set style options here.
+ $('#create_vn_dialog').dialog({
+ autoOpen: false,
+ modal: true,
+ width: 475,
+ height: 500
+ });
+
+ //Make the tabs look nice for the creation mode
+ $('#vn_tabs').tabs();
$('div#ranged').hide();
$('#fixed_check').click(function(){
- $('div#fixed').show();
- $('div#ranged').hide();
+ $('div#fixed').show();
+ $('div#ranged').hide();
});
$('#ranged_check').click(function(){
$('div#fixed').hide();
$('div#ranged').show();
});
- $('#create_vn_dialog button').button();
-
-
- //When we hit the add lease button...
- $('#add_lease').click(function(){
- var create_form = $('#create_vn_form_easy'); //this is our scope
-
- //Fetch the interesting values
- var lease_ip = $('#leaseip',create_form).val();
- var lease_mac = $('#leasemac',create_form).val();
-
- //We don't add anything to the list if there is nothing to add
- if (lease_ip == null) {
- notifyError("Please provide a lease IP");
- return false;
- };
+ $('#create_vn_dialog button').button();
- var lease = ""; //contains the HTML to be included in the select box
- if (lease_mac == "") {
- lease='' + lease_ip + ' ';
- } else {
- lease='' +
- lease_ip + ',' + lease_mac +
- ' ';
- };
+ //When we hit the add lease button...
+ $('#add_lease').click(function(){
+ var create_form = $('#create_vn_form_easy'); //this is our scope
- //We append the HTML into the select box.
- $('select#leases').append(lease);
- return false;
- });
+ //Fetch the interesting values
+ var lease_ip = $('#leaseip',create_form).val();
+ var lease_mac = $('#leasemac',create_form).val();
- $('#remove_lease').click(function(){
- $('select#leases :selected').remove();
- return false;
- });
+ //We don't add anything to the list if there is nothing to add
+ if (lease_ip == null) {
+ notifyError("Please provide a lease IP");
+ return false;
+ };
- //Handle submission of the easy mode
- $('#create_vn_form_easy').submit(function(){
- //Fetch values
- var name = $('#name',this).val();
+ var lease = ""; //contains the HTML to be included in the select box
+ if (lease_mac == "") {
+ lease='' + lease_ip + ' ';
+ } else {
+ lease='' +
+ lease_ip + ',' + lease_mac +
+ ' ';
+ };
+
+ //We append the HTML into the select box.
+ $('select#leases').append(lease);
+ return false;
+ });
+
+ $('#remove_lease').click(function(){
+ $('select#leases :selected').remove();
+ return false;
+ });
+
+ //Handle submission of the easy mode
+ $('#create_vn_form_easy').submit(function(){
+ //Fetch values
+ var name = $('#name',this).val();
if (!name.length){
notifyError("Virtual Network name missing!");
return false;
}
- var bridge = $('#bridge',this).val();
- var type = $('input:checked',this).val();
+ var bridge = $('#bridge',this).val();
+ var type = $('input:checked',this).val();
- //TODO: Name and bridge provided?!
+ //TODO: Name and bridge provided?!
- var network_json = null;
- if (type == "fixed") {
- var leases = $('#leases option', this);
- var leases_obj=[];
+ var network_json = null;
+ if (type == "fixed") {
+ var leases = $('#leases option', this);
+ var leases_obj=[];
- //for each specified lease we prepare the JSON object
- $.each(leases,function(){
- leases_obj.push({"ip": $(this).val() });
- });
+ //for each specified lease we prepare the JSON object
+ $.each(leases,function(){
+ leases_obj.push({"ip": $(this).val() });
+ });
- //and construct the final data for the request
- network_json = {
- "vnet" : {
- "type" : "FIXED",
- "leases" : leases_obj,
- "bridge" : bridge,
- "name" : name }};
- }
- else { //type ranged
+ //and construct the final data for the request
+ network_json = {
+ "vnet" : {
+ "type" : "FIXED",
+ "leases" : leases_obj,
+ "bridge" : bridge,
+ "name" : name }};
+ }
+ else { //type ranged
- var network_addr = $('#net_address',this).val();
- var network_size = $('#net_size',this).val();
- if (!network_addr.length){
- notifyError("Please provide a network address");
- return false;
- };
+ var network_addr = $('#net_address',this).val();
+ var network_size = $('#net_size',this).val();
+ if (!network_addr.length){
+ notifyError("Please provide a network address");
+ return false;
+ };
- //we form the object for the request
- network_json = {
- "vnet" : {
- "type" : "RANGED",
- "bridge" : bridge,
- "network_size" : network_size,
- "network_address" : network_addr,
- "name" : name }
- };
- };
+ //we form the object for the request
+ network_json = {
+ "vnet" : {
+ "type" : "RANGED",
+ "bridge" : bridge,
+ "network_size" : network_size,
+ "network_address" : network_addr,
+ "name" : name }
+ };
+ };
+
+ //Create the VNetwork.
- //Create the VNetwork.
-
Sunstone.runAction("Network.create",network_json);
- $('#create_vn_dialog').dialog('close');
- return false;
- });
+ $('#create_vn_dialog').dialog('close');
+ return false;
+ });
- $('#create_vn_form_manual').submit(function(){
- var template=$('#template',this).val();
+ $('#create_vn_form_manual').submit(function(){
+ var template=$('#template',this).val();
var vnet_json = {vnet: {vnet_raw: template}};
Sunstone.runAction("Network.create",vnet_json);
$('#create_vn_dialog').dialog('close');
- return false;
- });
+ return false;
+ });
}
function popUpCreateVnetDialog() {
@@ -582,44 +576,44 @@ function popUpCreateVnetDialog() {
function setVNetAutorefresh() {
setInterval(function(){
- var checked = $('input:checked',dataTable_vNetworks.fnGetNodes());
+ var checked = $('input:checked',dataTable_vNetworks.fnGetNodes());
var filter = $("#datatable_vnetworks_filter input").attr("value");
- if (!checked.length && !filter.length){
- Sunstone.runAction("Network.autorefresh");
- }
- },INTERVAL+someTime());
+ if (!checked.length && !filter.length){
+ Sunstone.runAction("Network.autorefresh");
+ }
+ },INTERVAL+someTime());
}
-//The DOM is ready and the ready() from sunstone.js
-//has been executed at this point.
+//The DOM is ready and the ready() from sunstone.js
+//has been executed at this point.
$(document).ready(function(){
-
- dataTable_vNetworks = $("#datatable_vnetworks").dataTable({
- "bJQueryUI": true,
- "bSortClasses": false,
- "bAutoWidth":false,
- "sPaginationType": "full_numbers",
- "aoColumnDefs": [
- { "bSortable": false, "aTargets": ["check"] },
- { "sWidth": "60px", "aTargets": [0,4,5,6,7] },
- { "sWidth": "35px", "aTargets": [1] },
- { "sWidth": "100px", "aTargets": [2] }
- ]
+
+ dataTable_vNetworks = $("#datatable_vnetworks").dataTable({
+ "bJQueryUI": true,
+ "bSortClasses": false,
+ "bAutoWidth":false,
+ "sPaginationType": "full_numbers",
+ "aoColumnDefs": [
+ { "bSortable": false, "aTargets": ["check"] },
+ { "sWidth": "60px", "aTargets": [0,5,6,7,8] },
+ { "sWidth": "35px", "aTargets": [1] },
+ { "sWidth": "100px", "aTargets": [2,3] }
+ ]
});
-
+
dataTable_vNetworks.fnClearTable();
addElement([
spinner,
- '','','','','','',''],dataTable_vNetworks);
+ '','','','','','','',''],dataTable_vNetworks);
Sunstone.runAction("Network.list");
-
-
+
+
setupCreateVNetDialog();
setVNetAutorefresh();
-
+
initCheckAllBoxes(dataTable_vNetworks);
tableCheckboxesListener(dataTable_vNetworks);
vNetworkInfoListener();
-
-
+
+
});
diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js
index 8c809ad71f..8eeebf589c 100644
--- a/src/sunstone/public/js/sunstone-util.js
+++ b/src/sunstone/public/js/sunstone-util.js
@@ -69,13 +69,13 @@ function humanize_size(value) {
//Wrapper to add an element to a dataTable
function addElement(element,data_table){
- data_table.fnAddData(element);
+ data_table.fnAddData(element);
}
//deletes an element with id 'tag' from a dataTable
function deleteElement(data_table,tag){
- var tr = $(tag).parents('tr')[0];
- data_table.fnDeleteRow(tr);
+ var tr = $(tag).parents('tr')[0];
+ data_table.fnDeleteRow(tr);
$('input',data_table).trigger("change");
}
@@ -101,11 +101,11 @@ function tableCheckboxesListener(dataTable){
var context = table.parents('form');
var nodes = $('tr',table);
var total_length = nodes.length;
- var checked_length = $('input:checked',nodes).length;
-
+ var checked_length = $('input:checked',nodes).length;
+
var last_action_b = $('.last_action_button',context);
-
-
+
+
//if all elements are checked we check the check-all box
if (total_length == checked_length && total_length != 0){
$('.check_all',dataTable).attr("checked","checked");
@@ -125,7 +125,7 @@ function tableCheckboxesListener(dataTable){
$('.top_button, .list_button',context).button("disable");
last_action_b.button("disable");
}
-
+
//any case the create dialog buttons should always be enabled.
$('.create_dialog_button',context).button("enable");
$('.alwaysActive',context).button("enable");
@@ -136,19 +136,19 @@ function tableCheckboxesListener(dataTable){
// Updates a data_table, with a 2D array containing the new values
// Does a partial redraw, so the filter and pagination are kept
function updateView(item_list,data_table){
- if (data_table!=null) {
- data_table.fnClearTable();
- data_table.fnAddData(item_list);
- data_table.fnDraw(false);
- };
+ if (data_table!=null) {
+ data_table.fnClearTable();
+ data_table.fnAddData(item_list);
+ data_table.fnDraw(false);
+ };
}
//replaces an element with id 'tag' in a dataTable with a new one
function updateSingleElement(element,data_table,tag){
var nodes = data_table.fnGetNodes();
- var tr = $(tag,nodes).parents('tr')[0];
- var position = data_table.fnGetPosition(tr);
- data_table.fnUpdate(element,position,0,false);
+ var tr = $(tag,nodes).parents('tr')[0];
+ var position = data_table.fnGetPosition(tr);
+ data_table.fnUpdate(element,position,0,false);
$('input',data_table).trigger("change");
}
@@ -156,11 +156,11 @@ function updateSingleElement(element,data_table,tag){
// Returns an string in the form key=value key=value ...
// Does not explore objects in depth.
function stringJSON(json){
- var str = ""
- for (field in json) {
- str+= field + '=' + json[field] + ' ';
- }
- return str;
+ var str = ""
+ for (field in json) {
+ str+= field + '=' + json[field] + ' ';
+ }
+ return str;
}
//Notifications
@@ -223,48 +223,48 @@ function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_to
if (typeof value == 'object'){
//name of field row
str += ' \
- '
- +field+
- ' \
- \
- \
- ';
+ '
+ +field+
+ ' \
+ \
+ \
+ ';
//attributes rows
//empty row - prettyprint - empty row
str += '\
- \
- \
- ' +
- prettyPrintJSON(value,padding+25,"normal","0",1) +
- '\
- \
- \
- ';
- } else {
+ \
+ \
+ ' +
+ prettyPrintJSON(value,padding+25,"normal","0",1) +
+ '\
+ \
+ \
+ ';
+ } else {
str += '\
- '+
- field+
- ' \
- '+
- value+
- ' \
- ';
+ '+
+ field+
+ ' \
+ '+
+ value+
+ ' \
+ ';
};
return str;
@@ -273,27 +273,27 @@ function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_to
//Add a listener to the check-all box of a datatable, enabling it to
//check and uncheck all the checkboxes of its elements.
function initCheckAllBoxes(datatable){
- //not showing nice in that position
- //$('.check_all').button({ icons: {primary : "ui-icon-check" },
- // text : true});
-
- //small css hack
- $('.check_all',datatable).css({"border":"2px"});
- $('.check_all',datatable).click(function(){
- if ($(this).attr("checked")) {
- $('tbody input:checkbox',
- $(this).parents("table")).each(function(){
- $(this).attr("checked","checked");
- });
+ //not showing nice in that position
+ //$('.check_all').button({ icons: {primary : "ui-icon-check" },
+ // text : true});
- } else {
- $('tbody input:checkbox',
- $(this).parents("table")).each(function(){
- $(this).removeAttr("checked");
- });
+ //small css hack
+ $('.check_all',datatable).css({"border":"2px"});
+ $('.check_all',datatable).click(function(){
+ if ($(this).attr("checked")) {
+ $('tbody input:checkbox',
+ $(this).parents("table")).each(function(){
+ $(this).attr("checked","checked");
+ });
+
+ } else {
+ $('tbody input:checkbox',
+ $(this).parents("table")).each(function(){
+ $(this).removeAttr("checked");
+ });
}
$('tbody input:checkbox',$(this).parents("table")).trigger("change");
- });
+ });
}
//standard handling for the server errors on ajax requests.
@@ -309,9 +309,9 @@ function onError(request,error_json) {
//redirect to login if unauthenticated
if (error_json.error.http_status=="401") {
- window.location.href = "/login";
+ window.location.href = "/login";
};
-
+
if (!message){
notifyError("Cannot contact server: is Sunstone server running and reachable?");
return false;
@@ -370,84 +370,81 @@ function onError(request,error_json) {
function waitingNodes(dataTable){
var nodes = dataTable.fnGetData();
for (var i=0;i');
- $(this).append(' ');
- $(this).append(' ');
+ //For each tip in this context
+ $('div.tip',context).each(function(){
+ //store the text
+ var tip = $(this).html();
+ //replace the text with an icon and spans
+ $(this).html(' ');
+ $(this).append(' ');
- //add the text to .tipspan
- $('span.tipspan',this).html(tip);
- //make sure it is not floating in the wrong place
- $(this).parent().append('
');
- //hide the text
- $('span.tipspan',this).hide();
-
- //When the mouse is hovering on the icon we fadein/out
- //the tip text
- $('span.info_icon',this).hover(function(e){
- var top, left;
- top = e.pageY - 15;// - $(this).parents('#create_vm_dialog').offset().top - 15;
- left = e.pageX + 15;// - $(this).parents('#create_vm_dialog').offset().left;
- $(this).next().css(
- {"top":top+"px",
- "left":left+"px"});
- $(this).next().fadeIn();
- },function(){
- $(this).next().fadeOut();
- });
- });
+ $(this).append(' ');
+
+ //add the text to .tipspan
+ $('span.tipspan',this).html(tip);
+ //make sure it is not floating in the wrong place
+ $(this).parent().append('
');
+ //hide the text
+ $('span.tipspan',this).hide();
+
+ //When the mouse is hovering on the icon we fadein/out
+ //the tip text
+ $('span.info_icon',this).hover(function(e){
+ var top, left;
+ top = e.pageY - 15;// - $(this).parents('#create_vm_dialog').offset().top - 15;
+ left = e.pageX + 15;// - $(this).parents('#create_vm_dialog').offset().left;
+ $(this).next().css(
+ {"top":top+"px",
+ "left":left+"px"});
+ $(this).next().fadeIn();
+ },function(){
+ $(this).next().fadeOut();
+ });
+ });
}
//returns an array of ids of selected elements in a dataTable
function getSelectedNodes(dataTable){
var selected_nodes = [];
if (dataTable != null){
- //Which rows of the datatable are checked?
- var nodes = $('input:checked',$('tbody',dataTable));
- $.each(nodes,function(){
- selected_nodes.push($(this).val());
- });
+ //Which rows of the datatable are checked?
+ var nodes = $('input:checked',$('tbody',dataTable));
+ $.each(nodes,function(){
+ selected_nodes.push($(this).val());
+ });
}
return selected_nodes;
}
@@ -455,10 +452,10 @@ function getSelectedNodes(dataTable){
//returns a HTML string with a select input code generated from
//a dataTable
function makeSelectOptions(dataTable,
- id_col,name_col,
- status_col,
- status_bad,
- user_col){
+ id_col,name_col,
+ status_col,
+ status_bad,
+ user_col){
var nodes = dataTable.fnGetData();
var select = "Please select ";
var array;
@@ -471,8 +468,8 @@ function makeSelectOptions(dataTable,
}
var user = user_col > 0 ? this[user_col] : false;
var isMine = user ? (username == user) || (uid == user) : true;
-
-
+
+
if (status_col < 0 || (status != status_bad) || isMine ){
select +=''+name+' ';
}
@@ -488,7 +485,7 @@ function escapeDoubleQuotes(string){
function generateMonitoringDivs(graphs, id_prefix){
var str = "";
- //40% of the width of the screen minus
+ //40% of the width of the screen minus
//129px (left menu size)
var width = ($(window).width()-129)*45/100;
var id_suffix="";
@@ -526,11 +523,11 @@ function plot_graph(data,context,id_prefix,info){
};
var options = {
- legend : { show : true,
+ legend : { show : true,
noColumns: labels_arr.length,
container: $('#legend_'+id_suffix)
},
- xaxis : { mode: "time",
+ xaxis : { mode: "time",
timeformat: "%h:%M"
},
yaxis : { labelWidth: 40,
@@ -544,6 +541,75 @@ function plot_graph(data,context,id_prefix,info){
$.plot($('#'+id, context),series,options);
}
+//Enables showing full information on this type of fields on
+//mouse hover
+function shortenedInfoFields(context){
+ $('.shortened_info',context).live("mouseenter",function(e){
+ var full_info = $(this).next();
+ var top,left;
+ top = (e.pageY-15)+"px";
+ left = (e.pageX+15)+"px";
+ full_info.css({"top":top,"left":left});
+ full_info.fadeIn();
+ });
+
+ $('.shortened_info',context).live("mouseleave",function(e){
+ $(this).next().fadeOut();
+ });
+}
+
+function setupTemplateUpdateDialog(){
+
+ //Append to DOM
+ $('div#dialogs').append('
');
+
+ //Put HTML in place
+ $('#template_update_dialog').html(
+ '\
+ Update the template here: \
+ \
+ Select a template: \
+ \
+
\
+ Select a template \
+ \
+ \
+ \
+ \
+ Update\
+ \
+ Reset \
+
\
+ \
+ ');
+
+ $('#template_update_dialog').dialog({
+ autoOpen:false,
+ width:700,
+ modal:true,
+ height:410,
+ resizable:false,
+ });
+
+ $('#template_update_dialog button').button();
+
+ $('#template_update_dialog #template_update_select').live("change",function(){
+ var id = $(this).val();
+ var resource = $('#template_update_dialog #template_update_button').val();
+ $('#template_update_dialog #template_update_textarea').val("Loading...");
+ Sunstone.runAction(resource+".fetch_template",id);
+ });
+
+ $('#template_update_dialog #template_update_button').click(function(){
+ var new_template = $('#template_update_dialog #template_update_textarea').val();
+ var id = $('#template_update_dialog #template_update_select').val();
+ var resource = $(this).val();
+ Sunstone.runAction(resource+".update",id,new_template);
+ $('#template_update_dialog').dialog('close');
+ return false;
+ });
+}
+
//functions that used as true and false conditions for testing mainly
function True(){
return true;
diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js
index 7add76c027..28616806ba 100644
--- a/src/sunstone/public/js/sunstone.js
+++ b/src/sunstone/public/js/sunstone.js
@@ -195,39 +195,43 @@ var Sunstone = {
// function with an extraparam if defined.
switch (action_cfg.type){
- case "create":
- case "register":
- call({data:data_arg, success: callback, error:err});
- break;
- case "single":
+ case "create":
+ case "register":
+ call({data:data_arg, success: callback, error:err});
+ break;
+ case "single":
+ if (extra_param){
+ call({data:{id:data_arg,extra_param:extra_param}, success: callback,error:err});
+ } else {
call({data:{id:data_arg}, success: callback,error:err});
- break;
- case "list":
- call({success: callback, error:err});
- break;
- case "monitor_global":
- call({timeout: true, success: callback, error:err, data: {monitor: data_arg}});
- break;
- case "monitor":
- case "monitor_single":
- call({timeout: true, success: callback, error:err, data: {id:data_arg, monitor: extra_param}});
- break;
+ };
+ break;
+ case "list":
+ call({success: callback, error:err});
+ break;
+ case "monitor_global":
+ call({timeout: true, success: callback, error:err, data: {monitor: data_arg}});
+ break;
+ case "monitor":
+ case "monitor_single":
+ call({timeout: true, success: callback, error:err, data: {id:data_arg, monitor: extra_param}});
+ break;
case "multiple":
- //run on the list of nodes that come on the data
- $.each(data_arg,function(){
- if (extra_param){
- call({data:{id:this,extra_param:extra_param}, success: callback, error: err});
- } else {
- call({data:{id:this}, success: callback, error:err});
- }
- });
- break;
+ //run on the list of nodes that come on the data
+ $.each(data_arg,function(){
+ if (extra_param){
+ call({data:{id:this,extra_param:extra_param}, success: callback, error: err});
+ } else {
+ call({data:{id:this}, success: callback, error:err});
+ }
+ });
+ break;
default:
- //This action is complemente handled by the "call" function.
+ //This action is complemente handled by the "call" function.
//we pass any data if present.
- if (data_arg && extra_param) {call(data_arg,extra_param);}
- else if (data_arg) {call(data_arg);}
- else {call();}
+ if (data_arg && extra_param) {call(data_arg,extra_param);}
+ else if (data_arg) {call(data_arg);}
+ else {call();}
}
//notify submission
if (notify) {
@@ -290,6 +294,9 @@ $(document).ready(function(){
//Prepare the standard confirmation dialogs
setupConfirmDialogs();
+
+ //This dialog is shared to update templates
+ setupTemplateUpdateDialog();
//Listen for .action_buttons
//An action buttons runs a predefined action. If it has type
diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb
index 0ac9d9bc06..94e1274f4d 100755
--- a/src/sunstone/sunstone-server.rb
+++ b/src/sunstone/sunstone-server.rb
@@ -184,6 +184,11 @@ end
##############################################################################
# GET Resource information
##############################################################################
+
+get '/:resource/:id/template' do
+ @SunstoneServer.get_template(params[:resource], params[:id])
+end
+
get '/:resource/:id' do
@SunstoneServer.get_resource(params[:resource], params[:id])
end