|
|
@ -4,6 +4,12 @@ $nodeList = docker node ls --format '{{json .}}'| ConvertFrom-Json | ForEach-Obj
|
|
|
|
docker node inspect $_.ID | ConvertFrom-Json
|
|
|
|
docker node inspect $_.ID | ConvertFrom-Json
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$onlineNodeList = $nodeList | Where-Object {$_.Spec.Availability -eq 'active'}
|
|
|
|
$onlineNodeList = $nodeList | Where-Object {$_.Spec.Availability -eq 'active'}
|
|
|
|
|
|
|
|
$offlineNodeList = $nodeList | Where-Object {$_.Spec.Availability -ne 'active'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$offlineNodeList.Count) {
|
|
|
|
|
|
|
|
Write-Output 'all hosts online, nothing to failover'
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$failoverAddressList = (Invoke-RestMethod -Uri 'https://robot-ws.your-server.de/failover' -Authentication Basic -Credential $hetznerCredentials).failover
|
|
|
|
$failoverAddressList = (Invoke-RestMethod -Uri 'https://robot-ws.your-server.de/failover' -Authentication Basic -Credential $hetznerCredentials).failover
|
|
|
|
$offlineAddressList = $failoverAddressList | Where-Object active_server_ip -notin $onlineNodeList.Status.Addr
|
|
|
|
$offlineAddressList = $failoverAddressList | Where-Object active_server_ip -notin $onlineNodeList.Status.Addr
|
|
|
|