Commit 2d250381 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Support multiple image users in js models

methods that used to return user specific information modified to return
arrays of objects based on identified image users. Image space delimited
`users` metadata key is now the primary point to identify existing image
users.
parent ba721963
......@@ -43,7 +43,9 @@
},
display_users: function() {
return this.get_meta('users').split(' ').join(", ");
try {
return this.get_meta('users').split(' ').join(", ");
} catch(err) { console.log(err); return ''}
}
})
......
......@@ -295,8 +295,12 @@
return this.get_meta('GUI');
},
get_created_user: function() {
return synnefo.config.os_created_users[this.get_os()] || "root";
get_created_users: function() {
try {
var users = this.get_meta('users').split(" ");
} catch (err) { users = null }
if (!users) { users = [synnefo.config.os_created_users[this.get_os()] || "root"]}
return users;
},
get_sort_order: function() {
......@@ -318,12 +322,15 @@
return this.get('status') == "DELETED"
},
ssh_keys_path: function() {
prepend = '';
if (this.get_created_user() != 'root') {
prepend = '/home'
}
return '{1}/{0}/.ssh/authorized_keys'.format(this.get_created_user(), prepend);
ssh_keys_paths: function() {
return _.map(this.get_created_users(), function(username) {
prepend = '';
if (username != 'root') {
prepend = '/home'
}
return '{1}/{0}/.ssh/authorized_keys'.format(username,
prepend);
});
},
_supports_ssh: function() {
......@@ -344,16 +351,18 @@
},
personality_data_for_keys: function(keys) {
contents = '';
_.each(keys, function(key){
contents = contents + key.get("content") + "\n"
});
contents = $.base64.encode(contents);
return _.map(this.ssh_keys_paths(), function(path) {
var contents = '';
_.each(keys, function(key){
contents = contents + key.get("content") + "\n"
});
contents = $.base64.encode(contents);
return {
path: this.ssh_keys_path(),
contents: contents
}
return {
path: path,
contents: contents
}
});
}
});
......
......@@ -1285,7 +1285,7 @@
}
if (personality.length) {
extra['personality'] = personality;
extra['personality'] = _.flatten(personality);
}
storage.vms.create(data.name, data.image, data.flavor, meta, extra, _.bind(function(data){
......
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