Show Table of Contents
2.12. 例: Python を使用したストレージドメインのアクティブ化
ストレージドメインを Red Hat Virtualization に追加してデータセンターにアタッチした後には、それらのストレージドメインをアクティブ化して使用できる状態にする必要があります。
例2.11 Python を使用したストレージドメインのアクティブ化
以下の Python の例は、
data1 という名前のデータストレージドメインおよび iso1 という名前の ISO ストレージドメインをアクティブ化します。これらのストレージドメインはいずれも Default データセンターにアタッチされています。アクティブ化のアクションは、ストレージドメインの activate メソッドを使用して実行されます。
from ovirtsdk.api import API
from ovirtsdk.xml import params
try:
api = API (url="https://HOST",
username="USER@DOMAIN",
password="PASS",
ca_file="ca.crt")
dc = api.datacenters.get(name="Default")
sd_data = dc.storagedomains.get(name="data1")
sd_iso = dc.storagedomains.get(name="iso1")
try:
sd_data.activate()
print "Activated data storage domain '%s' in data center '%s' (Status: %s)." %
(sd_data.get_name(), dc.get_name, sd_data.get_status().get_state())
except Exception as ex:
print "Activating data storage domain in data center failed: %s." % ex
try:
sd_iso.activate()
print "Activated ISO storage domain '%s' in data center '%s' (Status: %s)." %
(sd_iso.get_name(), dc.get_name, sd_iso.get_status().get_state())
except Exception as ex:
print "Activating ISO storage domain in data center failed: %s." % ex
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % exactivate 要求が成功した場合は、スクリプトにより以下のような出力が表示されます。
Activated data storage domain 'data1' in data center 'Default' (Status: active). Activated ISO storage domain 'iso1' in data center 'Default' (Status: active).
status には、ストレージドメインがアクティブ化されたことが表示される点に注意してください。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.