Created
December 8, 2017 17:36
-
-
Save mu853/cad35f3e9505a2b9d5618446ce7239d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vCenterとSRMサーバーに接続 | |
# ※注意:リカバリサイト側に接続すること(プライマリ側に接続するとリカバリプランの実行に失敗するため ) | |
Connect-VIServer XXXXX -User administrator@vsphere.local -Password XXXXX | |
$srm = Connect-SrmServer # vCenter接続後にSRMに接続する際はCredential情報は不要 | |
$api = $srm.ExtensionData | |
# リカバリプランの状態を確認 | |
# ※下記はプランが1つだけの例、複数プランがある場合は別途考慮必要 | |
$plan = $api.Recovery.ListPlans() | |
$planinfo = $plan.GetInfo() | |
# $planinfo.Status 見てその後のアクションを決める(=再保護されているか等を判断する) | |
# リカバリプランの実行モードを指定 | |
# 1 - Test | |
# 2 - Cleanup | |
# 3 - Failover | |
# 4 - Reprotect | |
# 5 - Revert | |
$mode = New-Object VMware.VimAutomation.Srm.Views.SrmRecoveryPlanRecoveryMode | |
$mode.value__ = 1 # Test | |
$plan.Start($mode) | |
# 完了するまで $plan.GetInfo().Status を定期的に確認する、とか。 | |
# PowerCLI 6.5(SRM 6.1以降に対応)だと、データ同期の有無を指定可能らしい | |
# $option = New-Object VMware.VimAutomation.Srm.Views.SrmRecoveryOptions | |
# $option.SyncData = $false | |
# $plan.Start($mode, $option) | |
# ref. | |
# https://blogs.vmware.com/vsphere/2014/05/automate-failover-with-srm.html | |
# https://communities.vmware.com/thread/556762 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment