A.9. VDSM フックの仮想マシンカスタムプロパティーの評価
仮想マシンの カスタムプロパティー フィールドに設定される各キーは、フックスクリプトを呼び出す際の環境変数として追加されます。カスタムプロパティー フィールドの検証に使用される正規表現は、ある程度の保護を提供しますが、スクリプトによって、提供されている入力が適切であることを確認するようにする必要があります。
例A.3 カスタムプロパティーの評価
以下の例は、カスタムプロパティー key1 の有無を確認するための短い Python スクリプトです。このカスタムプロパティーが設定されている場合には、標準エラーにその値が出力されます。このカスタムプロパティーが設定されていない場合は、何も起こりません。
#!/usr/bin/python
import os
import sys
if os.environ.has_key('key1'):
sys.stderr.write('key1 value was : %s\n' % os.environ['key1'])
else:
sys.exit(0)
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.