[IronPython] Using SetPropertyValue and Put()

Michael ironpython at klintoe.eu
Thu Apr 8 23:56:33 CEST 2010


Hi

I'm trying to set some properties on an instance in WMI. I can set the
property, but I can't figure out to call the Put() method, so that the
properties are stored.
As I have only looked at IronPython for a couple of day I would also like
if someone can comment on potential issues with  the code.

Regards

/Michael
 

# Code snippet Begin

class OV_ManagedNode:
    def __init__(self):
        import clr
        clr.AddReference('System.Management')
        global System
        global Management
        import System.Management        

    @classmethod
    def CreateWithNodeType(self,\
                               PrimaryNodeName,\
                               SystemTypeId=11,\
                               OsTypeId=18,\
                               OsVersionId=18052,\
                               HeartBeatMode=0):
        try:
            self.PrimaryNodeName = PrimaryNodeName
            self.SystemTypeId = SystemTypeId
            self.OsTypeId = OsTypeId
            self.OsVersionId = OsVersionId
            self.HeartBeatMode = HeartBeatMode
            self.OV_ManagedNode =
System.Management.ManagementClass('root\HewlettPackard\OpenView\data:OV_ManagedNode')
            self.inParams =
self.OV_ManagedNode.GetMethodParameters('CreateWithNodeType')
            self.inParams['PrimaryNodeName'] = self.PrimaryNodeName
            self.inParams['SystemTypeId'] = self.SystemTypeId
            self.inParams['OsTypeId'] = self.OsTypeId
            self.inParams['OsVersionId'] = self.OsVersionId
            self.inParams['HeartBeatMode'] = self.HeartBeatMode
            self.outParams =
self.OV_ManagedNode.InvokeMethod('CreateWithNodeType', self.inParams, None)
            #Return Instance of the newly created OV_ManagedNode
            return self.outParams['ReturnValue']
        except:
            return False

a = OV_ManagedNode()
b = a.CreateWithNodeType('test')
b.SetPropertyValue('AllowCertAutoGranting', True)


# Code snippet End



More information about the Ironpython-users mailing list