Exemple #1
0
    def CreateReadOperation(self, session, clientID, path):
        CheckNone(session, "Session is NULL")

        readOperation = self._xmlrpcSession.AwaServerReadOperation_New(session)
        CheckNone(readOperation, "Read Operation is NULL")
        CheckSuccess(
            self._xmlrpcSession.AwaServerReadOperation_AddPath(
                readOperation, clientID, path),
            "Failed to add path to Read Operation: %s (clientID = %s)" %
            (path, clientID))

        result = self._xmlrpcSession.AwaServerReadOperation_Perform(
            readOperation, test_defaults.TIMEOUT)
        response = self._xmlrpcSession.AwaServerReadOperation_GetResponse(
            readOperation, clientID)
        pathResult = None
        pathResultError = AwaError.Unspecified
        pathResultLWM2MError = AwaLWM2MError.Unspecified

        if response != None:
            pathResult = self.GetPathResultFromReadOperation(
                readOperation, clientID, path)
            pathResultError = self.GetPathResultError(pathResult)
            pathResultLWM2MError = self.GetPathResultLWM2MError(pathResult)

        CheckSuccess(result, "Failed to perform Read Operation",
                     pathResultError, pathResultLWM2MError)

        return readOperation
Exemple #2
0
    def WaitForNotificationWithSession(self, session, sessionType, path, resourceInstanceID=None):
        timeout = test_defaults.TIMEOUT

        while timeout > 0:
            #print "Waiting for notification..."
            if sessionType == SessionType.Client:
                result = self._xmlrpcSession.AwaClientSession_Process(session, 1000)
                CheckSuccess(result, "Failed to process client session")
                result = self._xmlrpcSession.AwaClientSession_DispatchCallbacks(session)
                CheckSuccess(result, "Failed to dispatch callbacks for client session")
            else:
                result = self._xmlrpcSession.AwaServerSession_Process(session, 1000)
                CheckSuccess(result, "Failed to process server session")
                result = self._xmlrpcSession.AwaServerSession_DispatchCallbacks(session)
                CheckSuccess(result, "Failed to dispatch callbacks for server session")

            notifyResponse = self.GetNotifyResponse()
            if notifyResponse is not None and path in notifyResponse:
                if resourceInstanceID is None:
                    #print "Got Notify on resource %s with value: %s" % (path, str(notifyResponse[path]))
                    break
                elif resourceInstanceID in notifyResponse[path]:
                    #print "Got Notify on resource %s with value: %s" % (path, str(notifyResponse[path]))
                    #print "Resource instance %d: %s" % (resourceInstanceID, str(notifyResponse[path][resourceInstanceID]))
                    break
            timeout -= 1000
        if timeout <= 0:
            errorMessage = "No notification received for path %s" % (path, )
            if resourceInstanceID != None:
                errorMessage += "(ResourceInstanceID = " + str(resourceInstanceID) + ")"
            raise NoNotificationReceivedException(errorMessage)
Exemple #3
0
    def DeleteEntity(self, session, clientID, path):
        CheckNone(session, "Session is NULL")

        deleteOperation = self._xmlrpcSession.AwaServerDeleteOperation_New(
            session)
        CheckNone(deleteOperation, "Delete Operation is NULL")

        result = self._xmlrpcSession.AwaServerDeleteOperation_AddPath(
            deleteOperation, clientID, path)
        CheckSuccess(result,
                     "Failed to add path to Delete operation: %s" % (path, ))

        result = self._xmlrpcSession.AwaServerDeleteOperation_Perform(
            deleteOperation, test_defaults.TIMEOUT)
        response = self._xmlrpcSession.AwaServerDeleteOperation_GetResponse(
            deleteOperation, clientID)
        pathResult = None
        pathResultError = AwaError.Unspecified
        pathResultLWM2MError = AwaLWM2MError.Unspecified

        if response != None:
            pathResult = self._xmlrpcSession.AwaServerDeleteResponse_GetPathResult(
                response, path)
            pathResultError = self.GetPathResultError(pathResult)
            pathResultLWM2MError = self.GetPathResultLWM2MError(pathResult)

        CheckSuccess(result, "Failed to perform Delete Operation",
                     pathResultError, pathResultLWM2MError)
        CheckSuccess(
            self._xmlrpcSession.AwaServerDeleteOperation_Free(deleteOperation),
            "Failed to free Delete Operation")
Exemple #4
0
    def CreateGetOperation(self, session, path):
        CheckNone(session, "Session is NULL")

        getOperation = self._xmlrpcSession.AwaClientGetOperation_New(session)
        CheckNone(getOperation, "Get Operation is NULL")
        CheckSuccess(
            self._xmlrpcSession.AwaClientGetOperation_AddPath(
                getOperation, path),
            "Failed to add path to Get Operation: %s" % (path, ))

        result = self._xmlrpcSession.AwaClientGetOperation_Perform(
            getOperation, test_defaults.TIMEOUT)
        response = self._xmlrpcSession.AwaClientGetOperation_GetResponse(
            getOperation)
        pathResult = None
        pathResultError = AwaError.Unspecified

        if response != None:
            pathResult = self._xmlrpcSession.AwaClientGetResponse_GetPathResult(
                response, path)
            pathResultError = self.GetPathResultError(pathResult)

        CheckSuccess(result, "Failed to perform Get Operation",
                     pathResultError)

        return getOperation
Exemple #5
0
 def ProcessAndGetNotifyResponse(self, session, timeout):
     result = self._xmlrpcSession.AwaClientSession_Process(session, timeout)
     CheckSuccess(result, "Failed to process client _session")
     result = self._xmlrpcSession.AwaClientSession_DispatchCallbacks(
         session)
     CheckSuccess(result,
                  "Failed to dispatch callbacks for client _session")
     response = self.GetNotifyResponse()
     self._xmlrpcSession.ClearNotifyData()
     return response
Exemple #6
0
 def CreateSession(self, address, port):
     session = self._xmlrpcSession.AwaServerSession_New()
     CheckNone(session, "Session is NULL")
     try:
         CheckSuccess(
             self._xmlrpcSession.AwaServerSession_SetIPCAsUDP(
                 session, address, int(port)),
             "Failed to set _session IPC connection as UDP")
         CheckSuccess(self._xmlrpcSession.AwaServerSession_Connect(session),
                      "Failed to connect _session")
     except AwaUnexpectedErrorException as exception:
         self._xmlrpcSession.AwaServerSession_Free(session)
         raise exception
     return session
Exemple #7
0
    def DefineWithSession(self, session, objectDefinitionSettings,
                          resourceDefinitionSettingsCollection):
        defineOperation = self._xmlrpcSession.AwaServerDefineOperation_New(
            session)
        CheckNone(defineOperation, "Define Operation is NULL")

        objectDefinition = self._xmlrpcSession.AwaObjectDefinition_New(
            objectDefinitionSettings.objectID,
            objectDefinitionSettings.objectName,
            objectDefinitionSettings.minimumInstances,
            objectDefinitionSettings.maximumInstances)
        CheckNone(
            objectDefinition,
            "Could not create object definition for objectID %d" %
            (objectDefinitionSettings.objectID, ))

        for resourceDefinitionSettings in resourceDefinitionSettingsCollection:
            if awa_enums.isArrayResourceType(
                    resourceDefinitionSettings.resourceType):
                self.DefineMultipleInstanceResource(
                    objectDefinition, resourceDefinitionSettings.resourceID,
                    resourceDefinitionSettings.resourceName,
                    resourceDefinitionSettings.resourceType,
                    resourceDefinitionSettings.minimumInstances,
                    resourceDefinitionSettings.maximumInstances,
                    int(resourceDefinitionSettings.supportedOperations),
                    resourceDefinitionSettings.defaultValue)
            else:
                self.DefineSingleInstanceResource(
                    objectDefinition, resourceDefinitionSettings.resourceID,
                    resourceDefinitionSettings.resourceName,
                    resourceDefinitionSettings.resourceType,
                    resourceDefinitionSettings.minimumInstances > 0,
                    int(resourceDefinitionSettings.supportedOperations),
                    resourceDefinitionSettings.defaultValue)

        result = self._xmlrpcSession.AwaServerDefineOperation_Add(
            defineOperation, objectDefinition)
        CheckSuccess(result,
                     "Could not add object definition to Define Operation")

        result = self._xmlrpcSession.AwaServerDefineOperation_Perform(
            defineOperation, test_defaults.TIMEOUT)
        CheckSuccess(result, "Failed to perform Define Operation")

        result = self._xmlrpcSession.AwaServerDefineOperation_Free(
            defineOperation)
        CheckSuccess(result, "Failed to free Define Operation")
Exemple #8
0
    def SetMultipleInstanceResourceValues(self, setOperation, path,
                                          resourceType, values):
        result = AwaError.Unspecified

        for resInstanceID, value in values.iteritems():
            if resourceType == AwaResourceType.IntegerArray:
                result = self._xmlrpcSession.AwaClientSetOperation_AddArrayValueAsInteger(
                    setOperation, path, resInstanceID, int(value))
            elif resourceType == AwaResourceType.StringArray:
                result = self._xmlrpcSession.AwaClientSetOperation_AddArrayValueAsCString(
                    setOperation, path, resInstanceID, str(value))
            elif resourceType == AwaResourceType.FloatArray:
                result = self._xmlrpcSession.AwaClientSetOperation_AddArrayValueAsFloat(
                    setOperation, path, resInstanceID, float(value))
            elif resourceType == AwaResourceType.BooleanArray:
                result = self._xmlrpcSession.AwaClientSetOperation_AddArrayValueAsBoolean(
                    setOperation, path, resInstanceID, bool(value))
            elif resourceType == AwaResourceType.OpaqueArray:
                result = self._xmlrpcSession.AwaClientSetOperation_AddArrayValueAsOpaque(
                    setOperation, path, resInstanceID, value)
            elif resourceType == AwaResourceType.ObjectLinkArray:
                result = self._xmlrpcSession.AwaClientSetOperation_AddArrayValueAsObjectLink(
                    setOperation, path, resInstanceID, value)
            elif resourceType == AwaResourceType.TimeArray:
                result = self._xmlrpcSession.AwaClientSetOperation_AddArrayValueAsTime(
                    setOperation, path, resInstanceID, int(value))
            else:
                raise AwaInvalidArgumentException(
                    "Invalid resource type for key %s:" %
                    (str(resInstanceID), ), resourceType)

        CheckSuccess(
            result, "Failed to add value to Set Operation: %s:%s" %
            (str(resInstanceID), str(value)))
Exemple #9
0
    def WriteMultipleInstanceResourceValues(self, writeOperation, path,
                                            resourceType, values):
        result = AwaError.Unspecified
        array = self.CreateArray(resourceType, values)

        if resourceType == AwaResourceType.IntegerArray:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsIntegerArray(
                writeOperation, path, array)
        elif resourceType == AwaResourceType.StringArray:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsStringArray(
                writeOperation, path, array)
        elif resourceType == AwaResourceType.FloatArray:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsFloatArray(
                writeOperation, path, array)
        elif resourceType == AwaResourceType.BooleanArray:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsBooleanArray(
                writeOperation, path, array)
        elif resourceType == AwaResourceType.OpaqueArray:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsOpaqueArray(
                writeOperation, path, array)
        elif resourceType == AwaResourceType.ObjectLinkArray:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsObjectLinkArray(
                writeOperation, path, array)
        elif resourceType == AwaResourceType.TimeArray:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsTimeArray(
                writeOperation, path, array)
        else:
            raise AwaInvalidArgumentException(
                "%s is not a valid multiple instance resource type" %
                (resourceType, ))

        CheckSuccess(
            result, "Failed to add values as array to Write Operation: %s" %
            (str(values), ))
Exemple #10
0
    def WriteSingleInstanceResourceValue(self, writeOperation, path,
                                         resourceType, value):
        result = AwaError.Unspecified

        if resourceType == AwaResourceType.Integer:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsInteger(
                writeOperation, path, int(value))
        elif resourceType == AwaResourceType.String:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsCString(
                writeOperation, path, str(value))
        elif resourceType == AwaResourceType.Float:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsFloat(
                writeOperation, path, float(value))
        elif resourceType == AwaResourceType.Boolean:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsBoolean(
                writeOperation, path, bool(value))
        elif resourceType == AwaResourceType.Opaque:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsOpaque(
                writeOperation, path, value)
        elif resourceType == AwaResourceType.ObjectLink:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsObjectLink(
                writeOperation, path, value)
        elif resourceType == AwaResourceType.Time:
            result = self._xmlrpcSession.AwaServerWriteOperation_AddValueAsTime(
                writeOperation, path, int(value))
        else:
            raise AwaInvalidArgumentException("Invalid resource type",
                                              resourceType)

        CheckSuccess(
            result,
            "Failed to add value to Write Operation: %s" % (str(value), ))
Exemple #11
0
    def _PerformDeleteOperation(self, deleteOperation, path):
        result = self._xmlrpcSession.AwaClientDeleteOperation_Perform(
            deleteOperation, test_defaults.TIMEOUT)
        response = self._xmlrpcSession.AwaClientDeleteOperation_GetResponse(
            deleteOperation)
        pathResult = None
        pathResultError = AwaError.Unspecified

        if response != None:
            pathResult = self._xmlrpcSession.AwaClientDeleteResponse_GetPathResult(
                response, path)
            pathResultError = self.GetPathResultError(pathResult)

        CheckSuccess(result, "Failed to perform Delete Operation",
                     pathResultError)
        CheckSuccess(
            self._xmlrpcSession.AwaClientDeleteOperation_Free(deleteOperation),
            "Failed to free Delete Operation")
Exemple #12
0
    def PerformSetOperation(self, setOperation, path=None):
        result = self._xmlrpcSession.AwaClientSetOperation_Perform(
            setOperation, test_defaults.TIMEOUT)
        response = self._xmlrpcSession.AwaClientSetOperation_GetResponse(
            setOperation)
        pathResult = None
        pathResultError = AwaError.Unspecified

        if path != None and response != None:
            pathResult = self._xmlrpcSession.AwaClientSetResponse_GetPathResult(
                response, path)
            pathResultError = self.GetPathResultError(pathResult)

        CheckSuccess(result, "Failed to perform Set Operation",
                     pathResultError)
        CheckSuccess(
            self._xmlrpcSession.AwaClientSetOperation_Free(setOperation),
            "Failed to free Set Operation")
Exemple #13
0
    def ListClients(self, session):
        CheckNone(session, "Session is NULL")
        clients = {}
        listClientsOperation = self._xmlrpcSession.AwaServerListClientsOperation_New(
            session)
        CheckNone(listClientsOperation, "List Clients Operation is NULL")
        result = self._xmlrpcSession.AwaServerListClientsOperation_Perform(
            listClientsOperation, test_defaults.TIMEOUT)
        CheckSuccess(result, "Failed to perform List clients operation")

        clientIterator = self._xmlrpcSession.AwaServerListClientsOperation_NewClientIterator(
            listClientsOperation)
        while self._xmlrpcSession.AwaClientIterator_Next(clientIterator):
            clientID = self._xmlrpcSession.AwaClientIterator_GetClientID(
                clientIterator)
            registeredEntities = []
            response = self._xmlrpcSession.AwaServerListClientsOperation_GetResponse(
                listClientsOperation, clientID)
            CheckNone(
                response,
                "No List Clients response for ClientID %s" % (clientID, ))

            entityIterator = self._xmlrpcSession.AwaServerListClientsResponse_NewRegisteredEntityIterator(
                response)
            CheckNone(
                entityIterator,
                "Failed to create Entity Iterator for List Clients response for ClientID %s"
                % (clientID, ))

            while self._xmlrpcSession.AwaRegisteredEntityIterator_Next(
                    entityIterator):
                registeredEntities.append(
                    self._xmlrpcSession.AwaRegisteredEntityIterator_GetPath(
                        entityIterator))
            self._xmlrpcSession.AwaRegisteredEntityIterator_Free(
                entityIterator)

            #print "Client: %s: %s" % (clientID, str(registeredEntities))
            clients[clientID] = registeredEntities
        self._xmlrpcSession.AwaClientIterator_Free(clientIterator)
        CheckSuccess(
            self._xmlrpcSession.AwaServerListClientsOperation_Free(
                listClientsOperation), "Failed to free List Clients Operation")
        return clients
Exemple #14
0
    def PerformWriteOperation(self, writeOperation, clientID, path):
        result = self._xmlrpcSession.AwaServerWriteOperation_Perform(
            writeOperation, clientID, test_defaults.TIMEOUT)
        response = self._xmlrpcSession.AwaServerWriteOperation_GetResponse(
            writeOperation, clientID)
        pathResult = None
        pathResultError = AwaError.Unspecified
        pathResultLWM2MError = AwaLWM2MError.Unspecified

        if response != None:
            pathResult = self._xmlrpcSession.AwaServerWriteResponse_GetPathResult(
                response, path)
            pathResultError = self.GetPathResultError(pathResult)
            pathResultLWM2MError = self.GetPathResultLWM2MError(pathResult)

        CheckSuccess(result, "Failed to perform Write Operation",
                     pathResultError, pathResultLWM2MError)
        CheckSuccess(
            self._xmlrpcSession.AwaServerWriteOperation_Free(writeOperation),
            "Failed to free Write Operation")
Exemple #15
0
    def DeleteEntity(self, session, path):
        CheckNone(session, "Session is NULL")

        deleteOperation = self._xmlrpcSession.AwaClientDeleteOperation_New(
            session)
        CheckNone(deleteOperation, "Delete Operation is NULL")

        result = self._xmlrpcSession.AwaClientDeleteOperation_AddPath(
            deleteOperation, path)
        CheckSuccess(result,
                     "Failed to add path to Delete operation: %s" % (path, ))

        self._PerformDeleteOperation(deleteOperation, path)
Exemple #16
0
    def DeleteResourceInstancesWithArrayRange(self, session, path, startIndex,
                                              count):
        deleteOperation = self._xmlrpcSession.AwaClientDeleteOperation_New(
            session)
        CheckNone(deleteOperation, "Delete Operation is NULL")

        result = self._xmlrpcSession.AwaClientDeleteOperation_AddPathWithArrayRange(
            deleteOperation, path, startIndex, count)
        CheckSuccess(
            result,
            "Failed to add array range to Delete operation on path %s: %d, %d"
            % (path, startIndex, count))

        self._PerformDeleteOperation(deleteOperation, path)
Exemple #17
0
    def CancelObservation(self, session, observation, clientID):
        observeOperation = self._xmlrpcSession.AwaServerObserveOperation_New(
            session)
        CheckNone(observeOperation, "Observe Operation is NULL")

        path = self._xmlrpcSession.AwaServerObservation_GetPath(observation)
        CheckNone(path, "Failed to retrieve path from Observation")

        result = self._xmlrpcSession.AwaServerObserveOperation_AddCancelObservation(
            observeOperation, observation)
        CheckSuccess(
            result,
            "Failed to add Cancel  Observation to Observe Operation for path %s"
            % (path, ))

        self._PerformObserveOperation(observeOperation, clientID, path)
Exemple #18
0
    def SubscribeToChange(self, session, changeSubscription):
        subscribeOperation = self._xmlrpcSession.AwaClientSubscribeOperation_New(
            session)
        CheckNone(subscribeOperation, "Subscribe Operation is NULL")

        path = self._xmlrpcSession.AwaClientChangeSubscription_GetPath(
            changeSubscription)
        CheckNone(path, "Failed to retrieve path from Change Subscription")

        result = self._xmlrpcSession.AwaClientSubscribeOperation_AddChangeSubscription(
            subscribeOperation, changeSubscription)
        CheckSuccess(
            result,
            "Failed to add change subscription to Subscribe Operation for path %s"
            % (path, ))

        self._PerformSubscribeOperation(subscribeOperation, path)
Exemple #19
0
    def CancelSubscribeToExecute(self, session, executeSubscription):
        subscribeOperation = self._xmlrpcSession.AwaClientSubscribeOperation_New(
            session)
        CheckNone(subscribeOperation, "Subscribe Operation is NULL")

        path = self._xmlrpcSession.AwaClientExecuteSubscription_GetPath(
            executeSubscription)
        CheckNone(path, "Failed to retrieve path from Execute Subscription")

        result = self._xmlrpcSession.AwaClientSubscribeOperation_AddCancelExecuteSubscription(
            subscribeOperation, executeSubscription)
        CheckSuccess(
            result,
            "Failed to add Cancel Execute Subscription to Subscribe Operation for path %s"
            % (path, ))

        self._PerformSubscribeOperation(subscribeOperation, path)
Exemple #20
0
    def DefineMultipleInstanceResource(self, objectDefinition, resourceID, resourceName, resourceType, resMinInstance, resMaxInstance, operations, defaultValues):
        defaultArray = self.CreateArray(resourceType, defaultValues)

        if resourceType == AwaResourceType.StringArray:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsStringArray(objectDefinition, resourceID, resourceName, resMinInstance, resMaxInstance, operations, defaultArray)
        elif resourceType == AwaResourceType.IntegerArray:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsIntegerArray(objectDefinition, resourceID, resourceName, resMinInstance, resMaxInstance, operations, defaultArray)
        elif resourceType == AwaResourceType.FloatArray:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsFloatArray(objectDefinition, resourceID, resourceName, resMinInstance, resMaxInstance, operations, defaultArray)
        elif resourceType == AwaResourceType.BooleanArray:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsBooleanArray(objectDefinition, resourceID, resourceName, resMinInstance, resMaxInstance, operations, defaultArray)
        elif resourceType == AwaResourceType.TimeArray:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsTimeArray(objectDefinition, resourceID, resourceName, resMinInstance, resMaxInstance, operations, defaultArray)
        elif resourceType == AwaResourceType.OpaqueArray:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsOpaqueArray(objectDefinition, resourceID, resourceName, resMinInstance, resMaxInstance, operations, defaultArray)
        elif resourceType == AwaResourceType.ObjectLinkArray:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsObjectLinkArray(objectDefinition, resourceID, resourceName, resMinInstance, resMaxInstance, operations, defaultArray)
        else:
            raise AwaInvalidArgumentException("Invalid resource type for single instance resource %s:" % (str(AwaResourceType(resourceType), )))

        CheckSuccess(result, "Could not add resource definition to object definition")
Exemple #21
0
    def DefineSingleInstanceResource(self, objectDefinition, resourceID, resourceName, resourceType, isMandatory, operations, defaultValue):

        if resourceType == AwaResourceType.String:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsString(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
        elif resourceType == AwaResourceType.Integer:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsInteger(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
        elif resourceType == AwaResourceType.Float:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsFloat(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
        elif resourceType == AwaResourceType.Boolean:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsBoolean(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
        elif resourceType == AwaResourceType.Time:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsTime(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
        elif resourceType == AwaResourceType.Opaque:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsOpaque(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
        elif resourceType == AwaResourceType.ObjectLink:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsObjectLink(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
        elif resourceType == AwaResourceType.NoneType:
            result = self._xmlrpcSession.AwaObjectDefinition_AddResourceDefinitionAsNoType(objectDefinition, resourceID, resourceName, isMandatory, operations)
        else:
            raise AwaInvalidArgumentException("Invalid resource type for single instance resource %s:" % (str(AwaResourceType(resourceType), )))

        CheckSuccess(result, "Could not add resource definition to object definition")
Exemple #22
0
    def __GetResourceValueFromReadResponse(self, response, path, resourceType):
        value = None
        if resourceType == AwaResourceType.Integer:
            value, error = self._xmlrpcSession.AwaServerReadResponse_GetValueAsIntegerPointer(
                response, path, None)
            if value != None:
                value = pickle.loads(value)  # deserialise long integer
        elif resourceType == AwaResourceType.String:
            value, error = self._xmlrpcSession.AwaServerReadResponse_GetValueAsCStringPointer(
                response, path, None)
        elif resourceType == AwaResourceType.Float:
            value, error = self._xmlrpcSession.AwaServerReadResponse_GetValueAsFloatPointer(
                response, path, None)
        elif resourceType == AwaResourceType.Boolean:
            value, error = self._xmlrpcSession.AwaServerReadResponse_GetValueAsBooleanPointer(
                response, path, None)
        elif resourceType == AwaResourceType.Opaque:
            value, error = self._xmlrpcSession.AwaServerReadResponse_GetValueAsOpaque(
                response, path, None)
            if value != None:
                value = binascii.a2b_base64(value)  # deserialise opaque base64
        elif resourceType == AwaResourceType.ObjectLink:
            value, error = self._xmlrpcSession.AwaServerReadResponse_GetValueAsObjectLink(
                response, path, None)
        elif resourceType == AwaResourceType.Time:
            value, error = self._xmlrpcSession.AwaServerReadResponse_GetValueAsTimePointer(
                response, path, None)
            if value != None:
                value = pickle.loads(value)  # deserialise long integer
        else:
            raise AwaInvalidArgumentException("Invalid resource type",
                                              resourceType)

        CheckSuccess(error, "Failed to retrieve value on path %s" % (path, ))

        return value
Exemple #23
0
 def FreeReadOperation(self, operation):
     CheckSuccess(
         self._xmlrpcSession.AwaServerReadOperation_Free(operation),
         "Failed to free Read Operation")
Exemple #24
0
 def SetCreateOptionalResource(self, setOperation, path):
     CheckNone(setOperation, "Set Operation is NULL")
     result = self._xmlrpcSession.AwaClientSetOperation_CreateOptionalResource(
         setOperation, path)
     CheckSuccess(result,
                  "Failed to create object instance on path: %s" % (path, ))
Exemple #25
0
 def FreeChangeSubscription(self, changeSubscription):
     result = self._xmlrpcSession.AwaClientChangeSubscription_Free(
         changeSubscription)
     CheckSuccess(result, "Failed to free Change Subscription")
Exemple #26
0
 def FreeExecuteSubscription(self, executeSubscription):
     result = self._xmlrpcSession.AwaClientExecuteSubscription_Free(
         executeSubscription)
     CheckSuccess(result, "Failed to free Execute Subscription")
Exemple #27
0
 def FreeSession(self, session):
     CheckSuccess(self._xmlrpcSession.AwaServerSession_Free(session),
                  "Failed to free Server Session")
Exemple #28
0
 def FreeGetOperation(self, operation):
     CheckSuccess(self._xmlrpcSession.AwaClientGetOperation_Free(operation),
                  "Failed to free Get Operation")
Exemple #29
0
 def FreeObservation(self, observation):
     result = self._xmlrpcSession.AwaServerObservation_Free(observation)
     CheckSuccess(result, "Failed to free Observation")
Exemple #30
0
 def WriteCreateOptionalResource(self, writeOperation, path):
     CheckNone(writeOperation, "Write Operation is NULL")
     result = self._xmlrpcSession.AwaServerWriteOperation_CreateOptionalResource(
         writeOperation, path)
     CheckSuccess(result,
                  "Failed to create object instance on path: %s" % (path, ))