通过 iControl PowerShell Snap-in 检查 F5 LTM 中是否有挂起的更改

Check if there are pending changes in F5 LTM through iControl PowerShell Snap-in

我们正在通过 PowerShell iControl 管理单元自动更改备用 F5 LTM 主机。

我们希望在我们的自动化进行任何更改之前以编程方式检查我们的备用和活动 F5 主机之间是否有待处理的更改。

有没有办法通过 iControl 管理单元或 API 检查未决更改?

我在 iControl wiki 中找到了答案。 get_sync_status_overview() 方法 "gets the status of the current device's presence in all device groups in which it is a member"

维基参考: https://devcentral.f5.com/wiki/iControl.Management__DeviceGroup__SyncStatus.ashx

我在 PowerShell 中编写了以下函数,其他人在尝试相同类型的操作时可能会觉得有用。 如果设备是独立的或与其组中的设备同步,它将 return 为真,如果 F5 主机上有更改需要同步到组并抛出错误,它将 return 为假在所有其他情况下:

function Is-DeviceInSync
{
    <#
    .SYNOPSIS
    Gets the sync status of F5 devices within the device group
    #>

    $syncStatus = (Get-F5.iControl).ManagementDeviceGroup.get_sync_status_overview()

    if ($syncStatus.member_state -eq "MEMBER_STATE_STANDALONE")
    {
        write-host "This F5 device is standalone, no sync is required"
        return $true
    }
    elseif ($syncStatus.member_state -eq "MEMBER_STATE_IN_SYNC")
    {
        write-host "This F5 device is in sync with members of its device group, no sync is required"
        return $true
    }
    elseif ($syncStatus.member_state -eq "MEMBER_STATE_NEED_MANUAL_SYNC")
    {
        write-host "This F5 device is not standalone and changes have been made to this device that have not been synced to the device group"
        return $false
    }
    elseif ($syncStatus.member_state -eq "MEMBER_STATE_SYNCING")
    {
        write-host "This F5 device is currently synching with devices in it's group, waiting 10 seconds before checking again..."
        Start-Sleep -Seconds 10
        Is-DeviceInSync
    }
    else
    {
        throw "This F5 device is not in a stable sync state with devices in it's group, please manually verify the sync state of this device before running this script again"
    }
}

注意:此函数假定 Initialize-F5.iControl 函数具有 运行 并且用户已经通过 F5 主机的身份验证