Questo contenuto non è disponibile nella lingua selezionata.
A.7. Evaluating Virtual Machine Custom Properties in a VDSM Hook
Each key set in the Custom Properties field for a virtual machine is appended as an environment variable when calling hook scripts. Although the regular expressions used to validate the Custom Properties field provide some protection you should ensure that your scripts also validate that the inputs provided match their expectations.
Example A.3. Evaluating Custom Properties
This short Python example checks for the existence of the custom property key1
. If the custom property is set then the value is printed to standard error. If the custom property is not set then no action is taken.
#!/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)