Not going to explain this one much – basically got asked by a coworker to write up a script real quick for him to update the Deployment Stage against every system in a device group.
#!/opt/opsware/agent/bin/python
import sys
sys.path.append("/opt/opsware/pylibs")
sys.path.append("/opt/opsware/agent/pylibs")
from pytwist import *
from pytwist.com.opsware.device import DeviceGroupRef
ts = twistserver.TwistServer()
ds = ts.device.DeviceGroupService
ss = ts.server.ServerService
# Enter your username and password here
ts.authenticate("username","password")
# Enter the device group object ID for the group you want to iterate over
# You can get this object ID from the GUI
dgref = DeviceGroupRef(#######)
srefs = ds.getDevices(dgref)
for sref in srefs:
svo = ss.getServerVO(sref)
print "Updating %s" % svo.name
# Set the stage. This has to be a valid option - these are always in caps.
svo.stage = "PRODUCTION"
ss.update(sref, svo, 0, 0)