|
|
|
@ -20,6 +20,12 @@ class MachineModel extends Model {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async to_api() {
|
|
|
|
|
let iam_filter = `(|(iamTarget=${this.id})`
|
|
|
|
|
for ( const group of (await this.groups()) ) {
|
|
|
|
|
iam_filter += `(iamTarget=${group.id})`
|
|
|
|
|
}
|
|
|
|
|
iam_filter += ')'
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: this.id,
|
|
|
|
|
name: this.name,
|
|
|
|
@ -27,9 +33,18 @@ class MachineModel extends Model {
|
|
|
|
|
host_name: this.host_name,
|
|
|
|
|
location: this.location,
|
|
|
|
|
ldap_visible: this.ldap_visible,
|
|
|
|
|
iam_filter,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async groups() {
|
|
|
|
|
const MachineGroup = this.models.get('ldap:MachineGroup')
|
|
|
|
|
return MachineGroup.find({
|
|
|
|
|
machine_ids: this.id,
|
|
|
|
|
active: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async set_bind_password(password) {
|
|
|
|
|
this.bind_password = await bcrypt.hash(password, 10)
|
|
|
|
|
return this
|
|
|
|
|