0

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

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

有没有办法通过 iControl 管理单元或 API 检查挂起的更改?

4

1 回答 1

0

我在 iControl wiki 中找到了答案。该get_sync_status_overview()方法“获取当前设备在其所属的所有设备组中的存在状态”

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

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

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 主机的身份验证

于 2016-10-25T11:03:38.510 回答