+42
-1
@@ -187,7 +187,35 @@ export function removeIpv6(
|
||||
|
||||
// ---- VNIC 管理 ----
|
||||
export function listVnics(cfgId: number, instanceId: string, region?: string): Promise<Vnic[]> {
|
||||
if (mockOn) return mocked([])
|
||||
if (mockOn)
|
||||
return mocked([
|
||||
{
|
||||
attachmentId: 'ocid1.vnicattachment..a1',
|
||||
vnicId: 'ocid1.vnic..v1',
|
||||
displayName: instanceId.slice(-12),
|
||||
isPrimary: true,
|
||||
privateIp: '10.0.0.11',
|
||||
publicIp: '141.147.60.10',
|
||||
ipv6Addresses: ['2603:c020:400d:aa01::1'],
|
||||
subnetId: 'ocid1.subnet..pub',
|
||||
subnetName: 'public-subnet',
|
||||
lifecycleState: 'ATTACHED',
|
||||
timeCreated: '2026-05-20T14:32:00Z',
|
||||
},
|
||||
{
|
||||
attachmentId: 'ocid1.vnicattachment..a2',
|
||||
vnicId: 'ocid1.vnic..v2',
|
||||
displayName: 'vnic-secondary',
|
||||
isPrimary: false,
|
||||
privateIp: '10.0.0.12',
|
||||
publicIp: '',
|
||||
ipv6Addresses: [],
|
||||
subnetId: 'ocid1.subnet..pub',
|
||||
subnetName: 'public-subnet',
|
||||
lifecycleState: 'ATTACHED',
|
||||
timeCreated: '2026-07-20T08:00:00Z',
|
||||
},
|
||||
])
|
||||
return request(`/oci-configs/${cfgId}/instances/${encodeURIComponent(instanceId)}/vnics`, {
|
||||
query: { region },
|
||||
})
|
||||
@@ -213,6 +241,19 @@ export function detachVnic(cfgId: number, attachmentId: string, region?: string)
|
||||
})
|
||||
}
|
||||
|
||||
/** 更换指定 VNIC 的临时公网 IP,返回新地址;绑定保留 IP 的网卡会被拒绝 */
|
||||
export function changeVnicPublicIp(
|
||||
cfgId: number,
|
||||
vnicId: string,
|
||||
region?: string,
|
||||
): Promise<{ publicIp: string }> {
|
||||
if (mockOn) return mocked({ publicIp: '130.61.99.7' }, 800)
|
||||
return request(`/oci-configs/${cfgId}/vnics/${encodeURIComponent(vnicId)}/change-public-ip`, {
|
||||
method: 'POST',
|
||||
body: { region: region ?? '' },
|
||||
})
|
||||
}
|
||||
|
||||
/** 为指定 VNIC 添加 IPv6;address 留空自动分配。删除复用实例级 removeIpv6(按地址遍历全部网卡) */
|
||||
export function addVnicIpv6(
|
||||
cfgId: number,
|
||||
|
||||
Reference in New Issue
Block a user