Esempio n. 1
0
class RunningDevice(Device):

    ValidAttributes = [
        'deviceRequestID', 'allowKeyAction', 'KeyDeliveryStatus', 'integrity',
        'deviceKeyRequestState'
    ]

    def __init__(self, connection, tag='runningVMDevice'):
        Device.__init__(self, connection, tag)
        self.deviceRequestID = None
        self.allowKeyAction = None
        self.KeyDeliveryStatus = None
        self.integrity = None
        self.deviceKeyRequestState = None
        # Device list
        self.device = None

    def startElement(self, name, attrs, connection):
        ret = Device.startElement(self, name, attrs, connection)
        if ret is not None:
            return ret

        if name == self.tag:
            for key, value in attrs.items():
                setattr(self, key, value)
        elif name == 'device':
            self.device = Device(connection)
            self.device.startElement(name, attrs, connection)
            return self.device
        else:
            return None

    def endElement(self, name, value, connection):
        setattr(self, name, value)

    def buildElements(self):
        runningVMDevice = ElementTree.Element('runningVMDevice')

        # Set all valid attributes
        for attr in self.ValidAttributes:
            if getattr(self, attr):
                runningVMDevice.attrib[attr] = getattr(self, attr)

                # append inner objects
        if getattr(self, 'device'):
            runningVMDevice.append(self.device.buildElements())

        return runningVMDevice
Esempio n. 2
0
class RunningDevice(Device):

    ValidAttributes = ['deviceRequestID', 'allowKeyAction', 'KeyDeliveryStatus',
                       'integrity', 'deviceKeyRequestState']

    def __init__(self, connection, tag='runningVMDevice'):
        Device.__init__(self, connection, tag)
        self.deviceRequestID = None
        self.allowKeyAction = None
        self.KeyDeliveryStatus = None
        self.integrity = None
        self.deviceKeyRequestState = None
         # Device list
        self.device = None

    def startElement(self, name, attrs, connection):
        ret = Device.startElement(self, name, attrs, connection)
        if ret is not None:
            return ret

        if name == self.tag:
            for key, value in attrs.items():
                setattr(self, key, value)
        elif name == 'device':
            self.device = Device(connection)
            self.device.startElement(name, attrs, connection)
            return self.device
        else:
            return None

    def endElement(self, name, value, connection):
        setattr(self, name, value)

    def buildElements(self):
        runningVMDevice = ElementTree.Element('runningVMDevice')

        # Set all valid attributes
        for attr in self.ValidAttributes:
            if getattr(self, attr):
                runningVMDevice.attrib[attr] = getattr(self, attr)

                # append inner objects
        if getattr(self, 'device'):
            runningVMDevice.append(self.device.buildElements())

        return runningVMDevice
Esempio n. 3
0
    def startElement(self, name, attrs, connection):
        ret = Device.startElement(self, name, attrs, connection)
        if ret is not None:
            return ret

        if name == self.tag:
            for key, value in attrs.items():
                setattr(self, key, value)
        elif name == 'device':
            self.device = Device(connection)
            self.device.startElement(name, attrs, connection)
            return self.device
        else:
            return None
Esempio n. 4
0
    def startElement(self, name, attrs, connection):
        ret = Device.startElement(self, name, attrs, connection)
        if ret is not None:
            return ret

        if name == self.tag:
            for key, value in attrs.items():
                setattr(self, key, value)
        elif name == 'device':
            self.device = Device(connection)
            self.device.startElement(name, attrs, connection)
            return self.device
        else:
            return None