feat(xo-server/PIF): PIF.reconfigureIp handle IPv6
This commit is contained in:
parent
36d6e3779d
commit
b95b1622b1
@ -27,4 +27,6 @@
|
||||
|
||||
<!--packages-start-->
|
||||
|
||||
- xo-server minor
|
||||
|
||||
<!--packages-end-->
|
||||
|
@ -73,9 +73,16 @@ connect.resolve = {
|
||||
// ===================================================================
|
||||
// Reconfigure IP
|
||||
|
||||
export async function reconfigureIp({ pif, mode = 'DHCP', ip = '', netmask = '', gateway = '', dns = '' }) {
|
||||
export async function reconfigureIp({ pif, mode, ip = '', netmask = '', gateway = '', dns = '', ipv6, ipv6Mode }) {
|
||||
const xapi = this.getXapi(pif)
|
||||
await xapi.call('PIF.reconfigure_ip', pif._xapiRef, mode, ip, netmask, gateway, dns)
|
||||
|
||||
if ((ipv6 !== '' && pif.ipv6?.[0] !== ipv6) || (ipv6Mode !== undefined && ipv6Mode !== pif.ipv6Mode)) {
|
||||
await xapi.call('PIF.reconfigure_ipv6', pif._xapiRef, ipv6Mode, ipv6, gateway, dns)
|
||||
}
|
||||
|
||||
if (mode !== undefined && mode !== pif.mode) {
|
||||
await xapi.call('PIF.reconfigure_ip', pif._xapiRef, mode, ip, netmask, gateway, dns)
|
||||
}
|
||||
if (pif.management) {
|
||||
await xapi.call('host.management_reconfigure', pif._xapiRef)
|
||||
}
|
||||
@ -88,6 +95,8 @@ reconfigureIp.params = {
|
||||
netmask: { type: 'string', minLength: 0, optional: true },
|
||||
gateway: { type: 'string', minLength: 0, optional: true },
|
||||
dns: { type: 'string', minLength: 0, optional: true },
|
||||
ipv6: { type: 'string', minLength: 0, default: '' },
|
||||
ipv6Mode: { enum: getIpv6ConfigurationModes(), optional: true },
|
||||
}
|
||||
|
||||
reconfigureIp.resolve = {
|
||||
|
@ -562,15 +562,18 @@ const TRANSFORMS = {
|
||||
disallowUnplug: Boolean(obj.disallow_unplug),
|
||||
gateway: obj.gateway,
|
||||
ip: obj.IP,
|
||||
ipv6: obj.IPv6,
|
||||
mac: obj.MAC,
|
||||
management: Boolean(obj.management), // TODO: find a better name.
|
||||
carrier: Boolean(metrics && metrics.carrier),
|
||||
mode: obj.ip_configuration_mode,
|
||||
ipv6Mode: obj.ipv6_configuration_mode,
|
||||
mtu: +obj.MTU,
|
||||
netmask: obj.netmask,
|
||||
// A non physical PIF is a "copy" of an existing physical PIF (same device)
|
||||
// A physical PIF cannot be unplugged
|
||||
physical: Boolean(obj.physical),
|
||||
primaryAddressType: obj.primary_address_type,
|
||||
vlan: +obj.VLAN,
|
||||
speed: metrics && +metrics.speed,
|
||||
$host: link(obj, 'host'),
|
||||
|
Loading…
Reference in New Issue
Block a user