setproperty.py :
#
# Sample EMCLI Python script file for mass update a property value
#
# check number of arguments
if len(sys.argv) <> 3:
print 'Usage: emcli @setproperty.py hostname "propertyname" propertyvalue'
exit()
# assign the arguments to variables (for readability)
hostname = sys.argv[0]
propertyname = sys.argv[1]
propertyvalue = sys.argv[2]
# login to the OMS
login( username="SYSMAN", password="welcome1" )
# find the targets running on a given host
targets = list( sql="select target_name || '@' || target_type as target from MGMT$TARGET where host_name = '" + hostname + "' and target_name <> host_name" )
# set the target property for each target
for t in targets.out()['data']:
print "Setting property " + propertyname + " for " + t['TARGET'].split(':')[0]
set_target_property_value( property_records= t['TARGET'] + "@" + propertyname + "@" + propertyvalue, subseparator="property_records=@" )
|
Laisser un commentaire