mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
(cherry picked from commit 2d39e552ddd6ce61ecbefde85bd668a299a76957)
This commit is contained in:
parent
95371fb460
commit
71b8525d3c
@ -164,6 +164,21 @@ class SunstoneGuac < SunstoneRemoteConnections
|
||||
vm_resource["TEMPLATE/NIC_ALIAS[SSH='YES'][1]/EXTERNAL_IP"] ||
|
||||
vm_resource["TEMPLATE/NIC_ALIAS[SSH='YES'][1]/IP"]
|
||||
|
||||
external_port_range = vm_resource['TEMPLATE/
|
||||
NIC[EXTERNAL_PORT_RANGE][1]/
|
||||
EXTERNAL_PORT_RANGE']
|
||||
|
||||
if external_port_range
|
||||
ip = vm_resource['HISTORY_RECORDS/
|
||||
HISTORY[HOSTNAME][last()]/
|
||||
HOSTNAME']
|
||||
|
||||
unless ip.nil?
|
||||
hostname = ip
|
||||
port = Integer(external_port_range.split(':')[0]) + 21
|
||||
end
|
||||
end
|
||||
|
||||
if hostname.nil?
|
||||
error_message = 'Wrong configuration. Cannot find a NIC with SSH'
|
||||
return { :error => error(400, error_message) }
|
||||
@ -177,7 +192,7 @@ class SunstoneGuac < SunstoneRemoteConnections
|
||||
}.merge(
|
||||
{
|
||||
'hostname' => hostname,
|
||||
'port' => vm_resource['TEMPLATE/CONTEXT/SSH_PORT'],
|
||||
'port' => port || vm_resource['TEMPLATE/CONTEXT/SSH_PORT'],
|
||||
'username' => vm_resource['TEMPLATE/CONTEXT/USERNAME'],
|
||||
'password' => vm_resource['TEMPLATE/CONTEXT/PASSWORD']
|
||||
}
|
||||
|
@ -775,28 +775,10 @@ define(function(require) {
|
||||
}
|
||||
},
|
||||
"hostnameStr": function(element) {
|
||||
var state = element.STATE;
|
||||
var hostname = "--";
|
||||
if (state == STATES.ACTIVE || state == STATES.SUSPENDED || state == STATES.POWEROFF) {
|
||||
var history = retrieveLastHistoryRecord(element);
|
||||
if (history) {
|
||||
hostname = history.HOSTNAME;
|
||||
};
|
||||
};
|
||||
|
||||
return hostname;
|
||||
return hostnameStr(element)
|
||||
},
|
||||
"hostnameStrLink": function(element) {
|
||||
var state = element.STATE;
|
||||
var hostname = "--";
|
||||
if (state == STATES.ACTIVE || state == STATES.SUSPENDED || state == STATES.POWEROFF) {
|
||||
var history = retrieveLastHistoryRecord(element);
|
||||
if (history) {
|
||||
hostname = Navigation.link(history.HOSTNAME, "hosts-tab", history.HID);
|
||||
};
|
||||
};
|
||||
|
||||
return hostname;
|
||||
return hostnameStr(element, true)
|
||||
},
|
||||
"clusterStr": function(element) {
|
||||
var state = element.STATE;
|
||||
@ -825,38 +807,75 @@ define(function(require) {
|
||||
"migrateActionStr": function(stateId) {
|
||||
return MIGRATE_ACTION_STR[stateId];
|
||||
},
|
||||
"ipsStr": ipsStr,
|
||||
"ipsDropdown": ipsDropdown,
|
||||
"groupByIpsStr": groupByIpsStr,
|
||||
"retrieveExternalIPs": retrieveExternalIPs,
|
||||
"retrieveExternalNetworkAttrs": retrieveExternalNetworkAttrs,
|
||||
"isNICGraphsSupported": isNICGraphsSupported,
|
||||
"hasConnection": hasConnection,
|
||||
"ipsDropdown": ipsDropdown,
|
||||
"ipsStr": ipsStr,
|
||||
"getSshWithPortForwarding": getSshWithPortForwarding,
|
||||
"isConnectionSupported": isConnectionSupported,
|
||||
"isDiskGraphsSupported": isDiskGraphsSupported,
|
||||
"isNICAttachSupported": isNICAttachSupported,
|
||||
"isVNCSupported": isVNCSupported,
|
||||
"isConnectionSupported": isConnectionSupported,
|
||||
"isVMRCSupported": isVMRCSupported,
|
||||
"isNICGraphsSupported": isNICGraphsSupported,
|
||||
"isSPICESupported": isSPICESupported,
|
||||
"isVMRCSupported": isVMRCSupported,
|
||||
"isVNCSupported": isVNCSupported,
|
||||
"isWFileSupported": isWFileSupported,
|
||||
"hasConnection": hasConnection,
|
||||
"promiseGetVm" : _promiseGetVm,
|
||||
"retrieveExternalIPs": retrieveExternalIPs,
|
||||
"retrieveExternalNetworkAttrs": retrieveExternalNetworkAttrs,
|
||||
"getName": function(id){
|
||||
return OpenNebulaAction.getName(id, RESOURCE);
|
||||
},
|
||||
"isvCenterVM": isVCenterVM,
|
||||
};
|
||||
|
||||
function _promiseGetVm({ id, success, async = true } = {}) {
|
||||
function hostnameStr(element, navigationLink = false) {
|
||||
var state = element.STATE;
|
||||
var hostname = "--";
|
||||
if (state == STATES.ACTIVE || state == STATES.SUSPENDED || state == STATES.POWEROFF) {
|
||||
var history = retrieveLastHistoryRecord(element);
|
||||
if (history) {
|
||||
hostname = navigationLink
|
||||
? Navigation.link(history.HOSTNAME, "hosts-tab", history.HID)
|
||||
: history.HOSTNAME;
|
||||
};
|
||||
};
|
||||
|
||||
return hostname;
|
||||
}
|
||||
|
||||
function getSshWithPortForwarding(vm = {}, navigationLink = false) {
|
||||
var nics = vm.TEMPLATE && vm.TEMPLATE.NIC || [];
|
||||
|
||||
var nic = $.grep(nics, function (v) {
|
||||
return v.EXTERNAL_PORT_RANGE !== undefined;
|
||||
})[0];
|
||||
|
||||
if (nic) {
|
||||
var ip = '<b>' + hostnameStr(vm, navigationLink) + '</b>';
|
||||
var externalPortRange = '<b>' + nic.EXTERNAL_PORT_RANGE + '</b>';
|
||||
var internalPortRange = '<b>' + nic.INTERNAL_PORT_RANGE.split('/')[0].replace('-', ':') + '</b>'
|
||||
|
||||
return ip + ' ports ' + externalPortRange + ' forwarded to VM ports ' + internalPortRange;
|
||||
}
|
||||
}
|
||||
|
||||
function _promiseGetVm(options = {}) {
|
||||
options = $.extend({
|
||||
id: '',
|
||||
async: true
|
||||
}, options);
|
||||
|
||||
return $.ajax({
|
||||
url: "vm/" + id,
|
||||
url: "vm/" + options.id,
|
||||
type: "GET",
|
||||
success: function(response) {
|
||||
if (typeof success === "function") {
|
||||
if (typeof options.success === "function") {
|
||||
var vm = response ? response[RESOURCE] : undefined;
|
||||
success(vm);
|
||||
options.success(vm);
|
||||
}
|
||||
},
|
||||
async: async
|
||||
async: options.async
|
||||
});
|
||||
}
|
||||
|
||||
@ -1039,6 +1058,7 @@ define(function(require) {
|
||||
else if (ips.length === 1)
|
||||
return "<p style=\"margin-bottom:0;\">"+ips[0]+"</p>";
|
||||
|
||||
var sshWithPortForwarding = getSshWithPortForwarding(element) || '';
|
||||
var firstIP = ipsHtml.split("<end_first_ip>")[0];
|
||||
ipsHtml = ipsHtml.split("<end_first_ip>")[1];
|
||||
ipsHtml =
|
||||
@ -1052,6 +1072,9 @@ define(function(require) {
|
||||
"<ul>" +
|
||||
ipsHtml +
|
||||
"</ul>" +
|
||||
"<span style='white-space: nowrap;font-style: italic;'>" +
|
||||
sshWithPortForwarding +
|
||||
"</span>" +
|
||||
"</li>" +
|
||||
"</ul>";
|
||||
return ipsHtml;
|
||||
|
@ -80,6 +80,7 @@ define(function(require) {
|
||||
var lcmStateClass = OpenNebula.VM.lcmStateClass(this.element.LCM_STATE);
|
||||
var hostnameHTML = OpenNebula.VM.hostnameStrLink(this.element);
|
||||
var IP = OpenNebula.VM.ipsStr(this.element, { forceGroup: true });
|
||||
var sshWithPortForwarding = OpenNebula.VM.getSshWithPortForwarding(this.element, true);
|
||||
|
||||
var vrouterHTML = "--";
|
||||
|
||||
@ -139,7 +140,6 @@ define(function(require) {
|
||||
"</div>";
|
||||
}
|
||||
|
||||
|
||||
return TemplateInfo({
|
||||
"element": this.element,
|
||||
"renameTrHTML": renameTrHTML,
|
||||
@ -151,6 +151,7 @@ define(function(require) {
|
||||
"prettyStartTime": prettyStartTime,
|
||||
"deployId": deployId,
|
||||
"IP": IP,
|
||||
"sshWithPortForwarding": sshWithPortForwarding,
|
||||
"resched": resched,
|
||||
"permissionsTableHTML": permissionsTableHTML,
|
||||
"templateTableVcenterHTML": templateTableVcenterHTML,
|
||||
|
@ -69,6 +69,14 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
{{#if sshWithPortForwarding}}
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Port forwarding"}}</td>
|
||||
<td class="value_td">{{{sshWithPortForwarding}}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Start time"}}</td>
|
||||
<td class="value_td">{{prettyStartTime}}</td>
|
||||
|
@ -179,11 +179,11 @@ textarea {
|
||||
}
|
||||
|
||||
.right {
|
||||
float: right !important;
|
||||
float: right !important;
|
||||
}
|
||||
|
||||
.left {
|
||||
float: left !important;
|
||||
float: left !important;
|
||||
}
|
||||
|
||||
.graph {
|
||||
|
Loading…
x
Reference in New Issue
Block a user