diff --git a/src/sunstone/public/js/plugins/provision-tab.js b/src/sunstone/public/js/plugins/provision-tab.js
index e93b37b738..d3808b8c0d 100644
--- a/src/sunstone/public/js/plugins/provision-tab.js
+++ b/src/sunstone/public/js/plugins/provision-tab.js
@@ -3324,23 +3324,7 @@ function get_provision_disk_image(data) {
}
function get_provision_ips(data) {
- var nics = []
- if ($.isArray(data.TEMPLATE.NIC))
- nics = data.TEMPLATE.NIC
- else if (!$.isEmptyObject(data.TEMPLATE.NIC))
- nics = [data.TEMPLATE.NIC]
-
- if (nics.length > 0) {
- var ips = [];
- $.each(nics, function(index, nic){
- if (nic.IP)
- ips.push(nic.IP);
- })
-
- return ' ' + ips.join(', ');
- } else {
- return ' -';
- }
+ return ' ' + ip_str(data, " - ");
}
// @params
diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index 2d3ceff0bc..71dad7ff07 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -30,14 +30,6 @@ function loadVNC(){
}
loadVNC();
-function calculate_isHybrid(vm_info){
- return vm_info.USER_TEMPLATE.HYPERVISOR &&
- (vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "vcenter"
- || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "ec2"
- || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "azure"
- || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "softlayer")
-}
-
var VNCstates=[
tr("RUNNING"),
tr("SHUTDOWN"),
@@ -973,63 +965,6 @@ function str_start_time(vm){
return pretty_time(vm.STIME);
};
-
-// Return the IP or several IPs of a VM
-function ip_str(vm){
-
- var isHybrid = calculate_isHybrid(vm);
-
- if (isHybrid)
- {
- switch(vm.USER_TEMPLATE.HYPERVISOR.toLowerCase())
- {
- case "vcenter":
- ip = vm.TEMPLATE.GUEST_IP?vm.TEMPLATE.GUEST_IP:"--";
- break;
- case "ec2":
- ip = vm.TEMPLATE.IP_ADDRESS?vm.TEMPLATE.IP_ADDRESS:"--";
- break;
- case "azure":
- ip = vm.TEMPLATE.IPADDRESS?vm.TEMPLATE.IPADDRESS:"--";
- break;
- case "softlayer":
- ip = vm.TEMPLATE.PRIMARYIPADDRESS?vm.TEMPLATE.PRIMARYIPADDRESS:"--";
- break;
- default:
- ip = "--";
- }
- }
- else
- {
- var nic = vm.TEMPLATE.NIC;
-
- if (nic == undefined){
- return '--';
- }
-
- if (!$.isArray(nic)){
- nic = [nic];
- }
-
- ip = '';
- $.each(nic, function(index,value){
- if (value.IP){
- ip += value.IP+'
';
- }
-
- if (value.IP6_GLOBAL){
- ip += value.IP6_GLOBAL+'
';
- }
-
- if (value.IP6_ULA){
- ip += value.IP6_ULA+'
';
- }
- });
- }
-
- return ip;
-};
-
// Returns an array formed by the information contained in the vm_json
// and ready to be introduced in a dataTable
function vMachineElementArray(vm_json){
diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js
index 31e0e212b3..14a9fb2259 100644
--- a/src/sunstone/public/js/sunstone.js
+++ b/src/sunstone/public/js/sunstone.js
@@ -6804,3 +6804,63 @@ function getInternetExplorerVersion(){
}
return rv;
}
+
+// Return true if the VM has a hybrid section
+function calculate_isHybrid(vm_info){
+ return vm_info.USER_TEMPLATE.HYPERVISOR &&
+ (vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "vcenter"
+ || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "ec2"
+ || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "azure"
+ || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "softlayer")
+}
+
+// Return the IP or several IPs of a VM
+function ip_str(vm, divider){
+ var divider = divider || "
"
+ var isHybrid = calculate_isHybrid(vm);
+ var nic = vm.TEMPLATE.NIC;
+
+ if (nic == undefined) {
+ if (isHybrid) {
+ switch(vm.USER_TEMPLATE.HYPERVISOR.toLowerCase()) {
+ case "vcenter":
+ ip = vm.TEMPLATE.GUEST_IP?vm.TEMPLATE.GUEST_IP:"--";
+ break;
+ case "ec2":
+ ip = vm.TEMPLATE.IP_ADDRESS?vm.TEMPLATE.IP_ADDRESS:"--";
+ break;
+ case "azure":
+ ip = vm.TEMPLATE.IPADDRESS?vm.TEMPLATE.IPADDRESS:"--";
+ break;
+ case "softlayer":
+ ip = vm.TEMPLATE.PRIMARYIPADDRESS?vm.TEMPLATE.PRIMARYIPADDRESS:"--";
+ break;
+ default:
+ ip = "--";
+ }
+ } else {
+ return '--';
+ }
+ } else {
+ if (!$.isArray(nic)){
+ nic = [nic];
+ }
+
+ ip = '';
+ $.each(nic, function(index,value){
+ if (value.IP){
+ ip += value.IP+divider;
+ }
+
+ if (value.IP6_GLOBAL){
+ ip += value.IP6_GLOBAL+divider;
+ }
+
+ if (value.IP6_ULA){
+ ip += value.IP6_ULA+divider;
+ }
+ });
+ }
+
+ return ip;
+};