From 2b4a7c40e1d164df96deee0ff692653f088f9310 Mon Sep 17 00:00:00 2001 From: Pierre Donias Date: Wed, 31 Jan 2018 13:16:03 +0100 Subject: [PATCH] feat(vm): allow self-user to create interface (#650) See vatesfr/xo-web#2593 --- src/api/vm.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/api/vm.js b/src/api/vm.js index 067034c64..a790eaf40 100644 --- a/src/api/vm.js +++ b/src/api/vm.js @@ -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'], } // -------------------------------------------------------------------