Beispiel #1
0
def __clientRPC(function, params):
    alarm = Alarm()
    timeStamp = TimeStamp()

    ntnv = NTNameValue(function, params)

    # now do issue + wait
    channelRPC = ChannelRPC("masarService")
    channelRPC.issueConnect()
    if not channelRPC.waitConnect(1.0):
        print "error when waiting connection.", channelRPC.getMessage()
        exit(1)
    channelRPC.issueRequest(ntnv.getNTNameValue(), False)
    result = channelRPC.waitResponse()
    if result is None:
        print channelRPC.getMessage()
        exit(1)
#    print "problem to get nttable using getNTTable()"
    if function in ["retrieveSnapshot", "getLiveMachine", "saveSnapshot"]:
        result = NTMultiChannel(result)
    elif function in [
            "retrieveServiceEvents", "retrieveServiceConfigs",
            "retrieveServiceConfigProps"
    ]:
        result = NTTable(result)
        label = result.getLabels()
        print "label", label
        print result.getPVStructure()
    elif function == "updateSnapshotEvent":
        result = NTScalar(result)


#    print "Problem above"
#     print result

    result.getAlarm(alarm)
    # print alarm

    result.getTimeStamp(timeStamp)
    # print timeStamp

    # numberValues = result.getNumberValues()
    # print "numberValues", numberValues

    #
    #    i = 0
    #    while i < numberValues :
    #        value = nttable.getValue(i)
    #        print "value",label[i],value
    #        i += 1
    return result
    def ntnv_asserts(self, function, params):

        alarm = Alarm()
        time_stamp = TimeStamp()
        ntnv = NTNameValue(function, params)
        self.channelRPC.issueRequest(ntnv.getNTNameValue(), False)
        response = self.channelRPC.waitResponse()
        self.assertNotEqual(response, None, "ChannelRPC connection failure.")
        result = NTMultiChannel(response)
        result.getAlarm(alarm)
        result.getTimeStamp(time_stamp)
        self.assertEqual(3, len(str(time_stamp).split(":")))  # Timestamp string format test

        self.assertIn(alarm.getStatus(), alarm.getStatusChoices())
        self.assertIn(alarm.getSeverity(), alarm.getSeverityChoices())
Beispiel #3
0
    def ntnv_asserts(self, function, params):

        alarm = Alarm()
        time_stamp = TimeStamp()
        ntnv = NTNameValue(function, params)
        self.channelRPC.issueRequest(ntnv.getNTNameValue(), False)
        response = self.channelRPC.waitResponse()
        self.assertNotEqual(response, None, "ChannelRPC connection failure.")
        result = NTMultiChannel(response)
        result.getAlarm(alarm)
        result.getTimeStamp(time_stamp)
        self.assertEqual(3, len(
            str(time_stamp).split(":")))  # Timestamp string format test

        self.assertIn(alarm.getStatus(), alarm.getStatusChoices())
        self.assertIn(alarm.getSeverity(), alarm.getSeverityChoices())
def __clientRPC(function, params):
    alarm = Alarm()
    timeStamp = TimeStamp()

    ntnv = NTNameValue(function, params)

    # now do issue + wait
    channelRPC = ChannelRPC("masarService")
    channelRPC.issueConnect()
    if not channelRPC.waitConnect(1.0):
        print "error when waiting connection.", channelRPC.getMessage()
        exit(1)
    channelRPC.issueRequest(ntnv.getNTNameValue(), False)
    result = channelRPC.waitResponse()
    if result is None:
        print channelRPC.getMessage()
        exit(1)
#    print "problem to get nttable using getNTTable()"
    if function in ["retrieveSnapshot", "getLiveMachine", "saveSnapshot"]:
        result = NTMultiChannel(result)
    elif function in ["retrieveServiceEvents", "retrieveServiceConfigs", "retrieveServiceConfigProps"]:
        result = NTTable(result)
        label = result.getLabels()
        print "label", label
        print result.getPVStructure()
    elif function == "updateSnapshotEvent":
        result = NTScalar(result)
#    print "Problem above"
#     print result

    result.getAlarm(alarm)
    # print alarm

    result.getTimeStamp(timeStamp)
    # print timeStamp

    # numberValues = result.getNumberValues()
    # print "numberValues", numberValues

#
#    i = 0
#    while i < numberValues :
#        value = nttable.getValue(i)
#        print "value",label[i],value
#        i += 1
    return result
Beispiel #5
0
def __clientRPC(function, params):
    alarm = Alarm()
    timeStamp = TimeStamp()

    ntnv = NTNameValue(function,params)
    
    # now do issue + wait
    channelRPC = ChannelRPC("masarService","record[process=true]field()")
    channelRPC.issueConnect()
    if not channelRPC.waitConnect(1.0) :
        print channelRPC.getMessage()
        exit(1)
    channelRPC.issueRequest(ntnv.getNTNameValue(),False)
    result = channelRPC.waitRequest()
    if(result==None) :
        print channelRPC.getMessage()
        exit(1)
    nttable = NTTable(result)
    print nttable
    
    nttable.getAlarm(alarm.getAlarmPy())
#    print alarm;
    
    nttable.getTimeStamp(timeStamp.getTimeStampPy())
#    print timeStamp;
    
#    numberValues = nttable.getNumberValues()
#    print "numberValues",numberValues
#    
#    label = nttable.getLabel()
#    print "label",label
#    
#    i = 0
#    while i < numberValues :
#        value = nttable.getValue(i)
#        print "value",label[i],value
#        i += 1
    return nttable
Beispiel #6
0
# testnameValue.py
#

import time

from masarclient.ntnameValue import NTNameValue as NTNameValue
from masarclient.alarm import Alarm as Alarm
from masarclient.timeStamp import TimeStamp as TimeStamp

timeStamp = TimeStamp()
alarm = Alarm()

function = 'saveSnapshot'
params = {'configname': 'sr_test',
          'servicename': 'masar'}

ntnv = NTNameValue(function,params)
print ntnv

newntnv = ntnv.getNTNameValue()
print newntnv
print ntnv.getName()
print ntnv.getValue()

print ntnv.getTimeStamp(timeStamp)
print ntnv.getAlarm(alarm)