feat(vm): allow self-user to create interface (#650)
See vatesfr/xo-web#2593
This commit is contained in:
parent
43e5398d99
commit
2b4a7c40e1
@ -1232,6 +1232,13 @@ export async function createInterface ({
|
|||||||
allowedIpv4Addresses,
|
allowedIpv4Addresses,
|
||||||
allowedIpv6Addresses,
|
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
|
let ipAddresses
|
||||||
const vif = await this.getXapi(vm).createVif(vm._xapiId, network._xapiId, {
|
const vif = await this.getXapi(vm).createVif(vm._xapiId, network._xapiId, {
|
||||||
mac,
|
mac,
|
||||||
@ -1276,8 +1283,10 @@ createInterface.params = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createInterface.resolve = {
|
createInterface.resolve = {
|
||||||
|
// Not compatible with resource sets.
|
||||||
|
// FIXME: find a workaround.
|
||||||
|
network: ['network', 'network', ''],
|
||||||
vm: ['vm', 'VM', 'administrate'],
|
vm: ['vm', 'VM', 'administrate'],
|
||||||
network: ['network', 'network', 'view'],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user