LoginSignup
0
2

More than 3 years have passed since last update.

PowerCLIでDRSの自動化レベルを切り替える

Posted at

DRS切り替える目的

大規模のリンククローン環境で、Deep Security Virtual Applianceを使用する場合、再構成(recompose)を実行する際はDRSが有効な場合は一時的に手動にすることが推奨されています。
VDI環境で再構成(Recompose)、更新(Refresh)、再分散(Rebalance)を実施する際の注意事項

しかし、全部の作業をGUIで行うのはかなりダルい…
再構成自体は予約が簡単に出来ますので、GUIで予約するとして、じゃあそのタイミングだけDRS止めたいという場合にタスクスケジューラ等に組み込んで使ういたいのでDRSをPowerCLIで切り替えたいと思ったので調べてみました。

MyCluster = "DRSを設定したいクラスタ名"

#DRSを手動にする
Get-Cluster $MyCluster | Set-Cluster -DrsAutomationLevel PartiallyAutomated -Confirm:$false

#DRSを自動にする
Get-Cluster $MyCluster | Set-Cluster -DrsAutomationLevel FullyAutomated -Confirm:$false

実際にこんな感じのスクリプト

DRS手動に変更

DRS-PartiallyAutomated.ps1
#PowerCLIモジュール読み込み
$null = Import-Module VMware.PowerCLI 2>&1
$null = Set-PowerCLIConfiguration -weboperationtimeout 30000 -Scope User -Confirm:$false

#vCenter接続
$vCenterServerAddress = "vCenter01"
$null = Connect-VIServer -Server $vCenterServerAddress -WarningAction 0

#DRS手動設定
MyCluster = "Cluster01"
$null = Get-Cluster $MyCluster | Set-Cluster -DrsAutomationLevel PartiallyAutomated -Confirm:$false

$null = Disconnect-VIServer -Server * -Confirm:$false

DRS自動に変更

DRS-FullyAutomated.ps1
#PowerCLIモジュール読み込み
$null = Import-Module VMware.PowerCLI 2>&1
$null = Set-PowerCLIConfiguration -weboperationtimeout 30000 -Scope User -Confirm:$false

#vCenter接続
$vCenterServerAddress = "vCenter01"
$null = Connect-VIServer -Server $vCenterServerAddress -WarningAction 0

#DRS手動設定
MyCluster = "Cluster01"
$null = Get-Cluster $MyCluster | Set-Cluster -DrsAutomationLevel FullyAutomated -Confirm:$false

$null = Disconnect-VIServer -Server * -Confirm:$false

実際にはログ残したりとか色々仕込むわけですが基本的にはこれだけです。
これをタスクスケジューラでメンテナンス時刻チョイ前にDRS手動に、翌日出勤時間前にはDRS自動にするように仕込んでおけば安心ですね。
再構成までスクリプトに組み込んでも良いんだけど、それはまた別のネタで

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2