feat(vm): allow self-user to create interface (#650)

See vatesfr/xo-web#2593
This commit is contained in:
Pierre Donias 2018-01-31 13:16:03 +01:00 committed by Julien Fontanet
parent 43e5398d99
commit 2b4a7c40e1

View File

@ -1232,6 +1232,13 @@ export async function createInterface ({
allowedIpv4Addresses,
allowedIpv6Addresses,
}) {
const { resourceSet } = vm
if (resourceSet != null) {
await this.checkResourceSetConstraints(resourceSet, this.user.id, [ network.id ])
} else if (!(await this.hasPermissions(this.user.id, [ [ network.id, 'view' ] ]))) {
throw unauthorized()
}
let ipAddresses
const vif = await this.getXapi(vm).createVif(vm._xapiId, network._xapiId, {
mac,
@ -1276,8 +1283,10 @@ createInterface.params = {
}
createInterface.resolve = {
// Not compatible with resource sets.
// FIXME: find a workaround.
network: ['network', 'network', ''],
vm: ['vm', 'VM', 'administrate'],
network: ['network', 'network', 'view'],
}
// -------------------------------------------------------------------