diff --git a/src/api/vif.js b/src/api/vif.js index 064cd8c69..2612a1f5b 100644 --- a/src/api/vif.js +++ b/src/api/vif.js @@ -41,3 +41,31 @@ connect.params = { connect.resolve = { vif: ['id', 'VIF', 'operate'] } + +// ------------------------------------------------------------------- + +export const set = ({ vif, allowedIpv4Addresses, allowedIpv6Addresses }) => ( + this.getXapi(vif._xapiId).editVif({ + ipv4Allowed: allowedIpv4Addresses, + ipv6Allowed: allowedIpv6Addresses + }) +) + +set.params = { + allowedIpv4Addresses: { + type: 'array', + items: { + type: 'string' + } + }, + allowedIpv6Addresses: { + type: 'array', + items: { + type: 'string' + } + } +} + +set.resolve = { + vif: ['id', 'VIF', 'operate'] +} diff --git a/src/xapi-object-to-xo.js b/src/xapi-object-to-xo.js index 71c24afdc..451161973 100644 --- a/src/xapi-object-to-xo.js +++ b/src/xapi-object-to-xo.js @@ -464,6 +464,8 @@ const TRANSFORMS = { return { type: 'VIF', + allowedIpv4Addresses: obj.ipv4_allowed, + allowedIpv6Addresses: obj.ipv6_allowed, attached: Boolean(obj.currently_attached), device: obj.device, // TODO: should it be cast to a number? MAC: obj.MAC, diff --git a/src/xapi/mixins/networking.js b/src/xapi/mixins/networking.js new file mode 100644 index 000000000..6592c8792 --- /dev/null +++ b/src/xapi/mixins/networking.js @@ -0,0 +1,10 @@ +import { + makeEditObject +} from '../utils' + +export default { + editVif: makeEditObject({ + ipv4Allowed: true, + ipv6Allowed: true + }) +}