Commit faa25f0f authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

cyclades ui: Prefer os meta to identify connection user

How vm connection user gets resolved:

- Use the last user in `users` vm metadata if exists
- Use the last user in `users` vm image metadata if exists
- Use root if vm's image osfamily metadata is Linux
- Use Administrator if vm's image osfamily metadata is windows
parent b71fbaf8
......@@ -307,7 +307,14 @@
try {
var users = this.get_meta('users').split(" ");
} catch (err) { users = null }
if (!users) { users = [synnefo.config.os_created_users[this.get_os()] || "root"]}
if (!users) {
var osfamily = this.get_meta('osfamily');
if (osfamily == 'windows') {
users = ['Administrator'];
} else {
users = ['root'];
}
}
return users;
},
......@@ -1498,8 +1505,25 @@
return this.url() + "/diagnostics";
},
get_users: function() {
var image;
var users = [];
try {
var users = this.get_meta('users').split(" ");
} catch (err) { users = null }
if (!users) {
image = this.get_image();
if (image) {
users = image.get_created_users();
}
}
return users;
},
get_connection_info: function(host_os, success, error) {
var url = synnefo.config.ui_connect_url;
var users = this.get_users();
params = {
ip_address: this.get_public_nic().get('ipv4'),
hostname: this.get_hostname(),
......@@ -1507,6 +1531,10 @@
host_os: host_os,
srv: this.id
}
if (users.length) {
params['username'] = _.last(users)
}
url = url + "?" + $.param(params);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment