<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
! add the following below this CDDL HEADER, with the fields enclosed
! by brackets "[]" replaced with your own identifying information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
! Copyright 2008-2010 Sun Microsystems, Inc.
! Portions Copyright 2013 ForgeRock AS
! -->
<stax>
<!-- SNMP Get -->
<function name="SNMPGet" scope="local">
<function-prolog>
This function performs a SNMP get request
</function-prolog>
<function-map-args>
<function-arg-def name="location"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Location of target host
</function-arg-description>
<function-arg-property name="type" value="hostname"/>
</function-arg-def>
<function-arg-def name="snmpVersion" type="required">
<function-arg-description>
SNMP request version
</function-arg-description>
<function-arg-property name="type" value="version" />
</function-arg-def>
<function-arg-def name="snmpHost"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Directory server SNMP hostname or IP address
</function-arg-description>
<function-arg-property name="type" value="hostname" />
</function-arg-def>
<function-arg-def name="snmpPort" type="required">
<function-arg-description>
Directory server SNMP port number
</function-arg-description>
<function-arg-property name="type" value="Port number"/>
</function-arg-def>
<function-arg-def name="snmpOIDs" type="optional">
<function-arg-description>
SNMP OID to query
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpCommunity" type="required">
<function-arg-description>
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpUser" type="optional">
<function-arg-description>
SNMP user used for v3 requests
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpSecurityLevel" type="optional">
<function-arg-description>
SNMP security level used for v3 requests
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpSecurityFile" type="optional">
<function-arg-description>
Path to the SNMP security file
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpStatus" type="required">
<function-arg-description>
Expected status of the SNMP request
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpValidOIDs" type="optional">
<function-arg-description>
Check if the values returned for the OIDs are correct
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpWalk" type="optional">
<function-arg-description>
Perform a walk request
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="expectedRC" type="optional" default="0">
<function-arg-description>
Expected return code value. Default value is 0
Wildcard 'noCheck' to not check the RC
</function-arg-description>
<function-arg-property name="type" value="integer"/>
</function-arg-def>
<function-arg-def name="knownIssue" type="optional" default="None">
<function-arg-description>
Known issue. Corresponds to an issue number.
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<!-- Check if 'emma.jar' exists -->
<call function="'GetEntry'">
{
'location' : STAF_REMOTE_HOSTNAME ,
'attribute' : 'TYPE'
}
</call>
<if expr="RC != 48">
<!-- 'emma.jar' exists -->
<script>
</script>
<else>
<script>
emma_jarfile=None
</script>
</else>
</if>
<!-- Build the command -->
<script>
STAFCmdParamsList=[]
STAFCmdParams=''
if snmpVersion:
STAFCmdParamsList.append('-v %s' % snmpVersion)
if snmpHost:
STAFCmdParamsList.append('-h %s' % snmpHost)
if snmpPort:
STAFCmdParamsList.append('-p %s' % snmpPort)
if snmpOIDs:
STAFCmdParamsList.append('-o %s' % snmpOIDs)
if snmpCommunity:
STAFCmdParamsList.append('-c %s' % snmpCommunity)
if snmpUser:
STAFCmdParamsList.append('-u %s' % snmpUser)
if snmpSecurityLevel:
STAFCmdParamsList.append('-l %s' % snmpSecurityLevel)
if snmpSecurityFile:
STAFCmdParamsList.append('-f %s' % snmpSecurityFile)
if snmpStatus:
STAFCmdParamsList.append('-s %s' % snmpStatus)
if snmpValidOIDs:
STAFCmdParamsList.append('-n %s' % snmpValidOIDs)
if snmpWalk:
STAFCmdParamsList.append('-w %s' % snmpWalk)
STAFCmdParams=' '.join(STAFCmdParamsList)
STAFCmd='SNMPGet'
if is_windows_platform(location):
separator=';'
else:
separator=':'
opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_BIN,SNMP_OPENDS_JARFILE)
jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
if emma_jarfile:
cp = 'CLASSPATH=%s%s%s%s%s%s.' \
% (opends_jarfile,separator,jdmk_jarfile,separator,emma_jarfile,separator)
else:
cp = 'CLASSPATH=%s%s%s%s.' \
% (opends_jarfile,separator,jdmk_jarfile,separator)
env = ['%s' % cp]
</script>
<message>
'%s %s' % (STAFCmd, STAFCmdParams)
</message>
<call function="'runCommand'" >
{
'name' : 'SNMP Get' ,
'arguments' : '%s %s' % (STAFCmd, STAFCmdParams) ,
'location' : location ,
'envCmd' : env ,
'expectedRC' : expectedRC ,
'knownIssue' : knownIssue
}
</call>
<return>
STAXResult
</return>
</sequence>
</function>
<!-- SNMP Set -->
<function name="SNMPSet" scope="local">
<function-prolog>
This function performs a SNMP Set request
</function-prolog>
<function-map-args>
<function-arg-def name="location"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Location of target host
</function-arg-description>
<function-arg-property name="type" value="hostname"/>
</function-arg-def>
<function-arg-def name="snmpVersion" type="required">
<function-arg-description>
SNMP request version
</function-arg-description>
<function-arg-property name="type" value="version" />
</function-arg-def>
<function-arg-def name="snmpHost"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Directory server SNMP hostname or IP address
</function-arg-description>
<function-arg-property name="type" value="hostname" />
</function-arg-def>
<function-arg-def name="snmpPort" type="required">
<function-arg-description>
Directory server SNMP port number
</function-arg-description>
<function-arg-property name="type" value="Port number"/>
</function-arg-def>
<function-arg-def name="snmpOIDs" type="optional">
<function-arg-description>
SNMP OID to query
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpCommunity" type="required">
<function-arg-description>
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpUser" type="optional">
<function-arg-description>
SNMP user used for v3 requests
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpSecurityLevel" type="optional">
<function-arg-description>
SNMP security level used for v3 requests
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpSecurityFile" type="optional">
<function-arg-description>
Path to the SNMP security file
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpStatus" type="required">
<function-arg-description>
Expected status of the SNMP request
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpValidOIDs" type="optional">
<function-arg-description>
Check if the values returned for the OIDs are correct
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="expectedRC" type="optional" default="0">
<function-arg-description>
Expected return code value. Default value is 0
Wildcard 'noCheck' to not check the RC
</function-arg-description>
<function-arg-property name="type" value="integer"/>
</function-arg-def>
</function-map-args>
<sequence>
<!-- Check if 'emma.jar' exists -->
<call function="'GetEntry'">
{
'location' : STAF_REMOTE_HOSTNAME ,
'attribute' : 'TYPE'
}
</call>
<if expr="RC != 48">
<!-- 'emma.jar' exists -->
<script>
</script>
<else>
<script>
emma_jarfile=None
</script>
</else>
</if>
<!-- Build the command -->
<script>
STAFCmdParamsList=[]
STAFCmdParams=''
if snmpVersion:
STAFCmdParamsList.append('-v %s' % snmpVersion)
if snmpHost:
STAFCmdParamsList.append('-h %s' % snmpHost)
if snmpPort:
STAFCmdParamsList.append('-p %s' % snmpPort)
if snmpOIDs:
STAFCmdParamsList.append('-o %s' % snmpOIDs)
if snmpCommunity:
STAFCmdParamsList.append('-c %s' % snmpCommunity)
if snmpUser:
STAFCmdParamsList.append('-u %s' % snmpUser)
if snmpSecurityLevel:
STAFCmdParamsList.append('-l %s' % snmpSecurityLevel)
if snmpSecurityFile:
STAFCmdParamsList.append('-f %s' % snmpSecurityFile)
if snmpStatus:
STAFCmdParamsList.append('-s %s' % snmpStatus)
if snmpValidOIDs:
STAFCmdParamsList.append('-n %s' % snmpValidOIDs)
STAFCmdParams=' '.join(STAFCmdParamsList)
STAFCmd='SNMPSet'
if is_windows_platform(location):
separator=';'
else:
separator=':'
opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_BIN,SNMP_OPENDS_JARFILE)
jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
if emma_jarfile:
cp = 'CLASSPATH=%s%s%s%s%s%s.' \
% (opends_jarfile,separator,jdmk_jarfile,separator,emma_jarfile,separator)
else:
cp = 'CLASSPATH=%s%s%s%s.' \
% (opends_jarfile,separator,jdmk_jarfile,separator)
env = ['%s' % cp]
</script>
<message>
'%s %s' % (STAFCmd, STAFCmdParams)
</message>
<call function="'runCommand'" >
{
'name' : 'SNMP Set' ,
'arguments' : '%s %s' % (STAFCmd, STAFCmdParams) ,
'location' : location ,
'envCmd' : env ,
'expectedRC' : expectedRC
}
</call>
<return>
STAXResult
</return>
</sequence>
</function>
<!-- SNMP Trap listener -->
<function name="SNMPTrapListener" scope="local">
<function-prolog>
This function performs a SNMP Set request
</function-prolog>
<function-map-args>
<function-arg-def name="location"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Location of target host
</function-arg-description>
<function-arg-property name="type" value="hostname"/>
</function-arg-def>
<function-arg-def name="snmpHost" type="required">
<function-arg-description>
Directory server SNMP port number
</function-arg-description>
<function-arg-property name="type" value="hostname"/>
</function-arg-def>
<function-arg-def name="snmpTrapPort" type="required">
<function-arg-description>
Directory server SNMP port number
</function-arg-description>
<function-arg-property name="type" value="Port number"/>
</function-arg-def>
<function-arg-def name="snmpTrapCommunity" type="required">
<function-arg-description>
SNMP trap community
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="snmpTrapNumber" type="required">
<function-arg-description>
Number of expected traps
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="outputFile" type="required">
<function-arg-description>
File to which the output should be written
</function-arg-description>
<function-arg-property name="type" value="filename"/>
</function-arg-def>
<function-arg-def name="expectedRC" type="optional" default="0">
<function-arg-description>
Expected return code value. Default value is 0
Wildcard 'noCheck' to not check the RC
</function-arg-description>
<function-arg-property name="type" value="integer"/>
</function-arg-def>
<function-arg-def name="knownIssue" type="optional" default="None">
<function-arg-description>
Known issue. Corresponds to an issue number.
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<script>
if is_windows_platform(location):
jstaf_jarfile='%s\\bin\\JSTAF.jar' % REMOTE_STAF_ROOT
else:
</script>
<!-- Build the command -->
<script>
STAFCmdParamsList=[]
STAFCmdParams=''
if snmpHost:
STAFCmdParamsList.append('-h %s' % snmpHost)
if snmpTrapPort:
STAFCmdParamsList.append('-p %s' % snmpTrapPort)
if snmpTrapCommunity:
STAFCmdParamsList.append('-c %s' % snmpTrapCommunity)
if snmpTrapNumber:
STAFCmdParamsList.append('-t %s' % snmpTrapNumber)
STAFCmdParams=' '.join(STAFCmdParamsList)
STAFCmd='SNMPTrapListener'
if is_windows_platform(location):
separator=';'
else:
separator=':'
jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
cp = 'CLASSPATH=%s%s%s%s.' \
% (jdmk_jarfile,separator,jstaf_jarfile,separator)
env = ['%s' % cp]
</script>
<message>
'%s %s' % (STAFCmd, STAFCmdParams)
</message>
<call function="'runCommand'" >
{
'name' : 'SNMP Trap Listener' ,
'arguments' : '%s %s' % (STAFCmd, STAFCmdParams) ,
'location' : location ,
'path' : snmpPath ,
'envCmd' : env ,
'outputFile' : outputFile ,
'expectedRC' : expectedRC ,
'knownIssue' : knownIssue
}
</call>
<return>
STAXResult
</return>
</sequence>
</function>
<!-- Restart SNMP Connection Handler -->
<function name="restartSNMPConnectionHandler" scope="local">
<function-prolog>
This function restart the SNMP Connection Handler using dsconfig
</function-prolog>
<function-map-args>
<function-arg-def name="location"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Location of target host
</function-arg-description>
<function-arg-property name="type" value="hostname" />
</function-arg-def>
<function-arg-def name="dsPath"
type="optional"
default="'%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME)">
<function-arg-description>
Pathname to installation root
</function-arg-description>
<function-arg-property name="type" value="filepath" />
</function-arg-def>
<function-arg-def name="dsInstanceHost"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Directory server hostname or IP address
</function-arg-description>
<function-arg-property name="type" value="hostname" />
</function-arg-def>
<function-arg-def name="dsInstanceAdminPort"
type="optional"
default="DIRECTORY_INSTANCE_ADMIN_PORT">
<function-arg-description>
Directory server admin port number
</function-arg-description>
<function-arg-property name="type" value="Port number" />
</function-arg-def>
<function-arg-def name="dsInstanceDn" type="required">
<function-arg-description>
Bind DN
</function-arg-description>
<function-arg-property name="type" value="DN" />
</function-arg-def>
<function-arg-def name="dsInstancePswd" type="required">
<function-arg-description>
Bind password
</function-arg-description>
<function-arg-property name="type" value="string" />
</function-arg-def>
<function-arg-def name="expectedRC" type="optional" default="0">
<function-arg-description>
Expected return code value. Default value is 0.
Wildcard 'noCheck' to not check the RC
</function-arg-description>
<function-arg-property name="type" value="string" />
</function-arg-def>
<function-arg-def name="knownIssue" type="optional" default="None">
<function-arg-description>
Known issue. Corresponds to an issue number.
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<!-- Build the command -->
<script>
STAFCmdParamsList=[]
STAFCmdParams=''
if dsPath:
dsBinPath='%s/%s' % (dsPath,fileFolder)
if dsInstanceHost:
STAFCmdParamsList.append('-h %s' % dsInstanceHost)
if dsInstanceAdminPort:
STAFCmdParamsList.append('-p %s' % dsInstanceAdminPort)
if dsInstanceDn:
STAFCmdParamsList.append('-D "%s"' % dsInstanceDn)
if dsInstancePswd:
STAFCmdParamsList.append('-w "%s"' % dsInstancePswd)
STAFCmdParamsList.append('-n')
STAFCmdParamsList.append('-X')
STAFCmdParamsList.append('set-connection-handler-prop')
STAFCmdParamsList.append('--handler-name "SNMP Connection Handler"')
STAFCmdParams=' '.join(STAFCmdParamsList)
STAFCmd='%s/%s%s' % (dsBinPath,DSCONFIG,fileExt)
</script>
<call function="'runCommand'">
{
'name' : 'Disable the SNMP Connection Handler' ,
'location' : location ,
'command' : STAFCmd ,
'arguments' : '%s --set enabled:false' % STAFCmdParams ,
'expectedRC': expectedRC
}
</call>
<call function="'runCommand'">
{
'name' : 'Enable the SNMP Connection Handler' ,
'location' : location ,
'command' : STAFCmd ,
'arguments' : '%s --set enabled:true' % STAFCmdParams ,
'expectedRC': expectedRC ,
'knownIssue': knownIssue
}
</call>
<return>
STAXResult
</return>
</sequence>
</function>
<!-- Compare SNMP values -->
<function name="compareSNMPValues" scope="local">
<function-prolog>
This function compare SNMP Values
</function-prolog>
<function-map-args>
<function-arg-def name="location"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Location of target host
</function-arg-description>
<function-arg-property name="type" value="hostname" />
</function-arg-def>
<function-arg-def name="snmpHost"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Directory server hostname or IP address
</function-arg-description>
<function-arg-property name="type" value="hostname" />
</function-arg-def>
<function-arg-def name="snmpPort" type="required">
<function-arg-description>
Directory server SNMP port number
</function-arg-description>
<function-arg-property name="type" value="Port number"/>
</function-arg-def>
<function-arg-def name="snmpCommunity" type="required">
<function-arg-description>
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="index" type="required">
<function-arg-description>
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="knownIssue" type="optional" default="None">
<function-arg-description>
Known issue. Corresponds to an issue number.
</function-arg-description>
</function-arg-def>
<function-arg-def name="expectedRC" type="optional" default="0">
<function-arg-description>
Expected return code value. Default value is 0
Wildcard 'noCheck' to not check the RC
</function-arg-description>
<function-arg-property name="type" value="integer"/>
</function-arg-def>
</function-map-args>
<sequence>
<message>
'get the current mib values'
</message>
<call function="'SNMPGet'">
{
'location' : location ,
'snmpVersion' : '1',
'snmpHost' : snmpHost ,
'snmpPort' : snmpPort ,
'snmpCommunity' : snmpCommunity ,
'snmpOIDs' : '' ,
'snmpStatus' : 'noError' ,
'snmpWalk' : 'True' ,
'expectedRC' : expectedRC
}
</call>
<script>
CURRENT_VALUES = {}
CURRENT_VALUES = create_table_fromoutput(STAXResult[0][1])
result = compare_snmp_values(DEFAULT_VALUES, CURRENT_VALUES, index)
</script>
<message>
'result: %s' % result
</message>
<call function="'searchString'">
{
'expectedString' : 'ERROR' ,
'returnString' : result ,
'knownIssue' : knownIssue ,
'expectedRC' : 1
}
</call>
<return>
STAXResult
</return>
</sequence>
</function>
<!-- Check timer result -->
<function name="checkTimerResult" scope="local">
<function-prolog>
This function compare SNMP Values
</function-prolog>
<function-map-args>
<function-arg-def name="location"
type="optional"
default="STAF_REMOTE_HOSTNAME">
<function-arg-description>
Location of target host
</function-arg-description>
<function-arg-property name="type" value="hostname" />
</function-arg-def>
<function-arg-def name="outputFile" type="required">
<function-arg-description>
File containing output
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="timerDuration" type="required">
<function-arg-description>
Timer duration
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="timerRC" type="required">
<function-arg-description>
Return code value of the timer
</function-arg-description>
<function-arg-property name="type" value="integer"/>
</function-arg-def>
<function-arg-def name="issue" type="optional" default="None">
<function-arg-description>
Issue id. Corresponds to an issue number.
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="timerRC == 1 or timerRC == 0">
<sequence>
<if expr="timerRC == 0">
<sequence>
<tcstatus result="'pass'"></tcstatus>
<message>
'Process TrapListener ended before timer duration: %s' \
% timerDuration
</message>
<stafcmd name="'Delete file %s' % outputFile">
<location>location</location>
<service>'FS'</service>
<request>'DELETE ENTRY %s CONFIRM' % outputFile</request>
</stafcmd>
</sequence>
<else>
<sequence>
<if expr="issue == None">
<tcstatus result="'fail'"/>
<else>
<sequence>
<call function="'setKnownIssue'">
{ 'issueId' : issue }
</call>
</sequence>
</else>
</if>
<message>
'Process TrapListener still running after timer duration: %s' \
% timerDuration
</message>
<stafcmd name="'Get output from TrapListener'">
<location>location</location>
<service>'FS'</service>
<request>'GET FILE %s' % outputFile</request>
</stafcmd>
<if expr="RC == 0">
<sequence>
<log message="1">'Output:%s' % STAFResult</log>
<stafcmd name="'Delete file %s' % outputFile">
<location>location</location>
<service>'FS'</service>
<request>'DELETE ENTRY %s CONFIRM' % outputFile</request>
</stafcmd>
</sequence>
<else>
<log message="1">
'STAF %s FS GET FILE %s failed with RC=%s Result=%s' % \
(location, outputFile, RC, STAFResult)
</log>
</else>
</if>
<message>
'Delete event from the trap listener'
</message>
<call function="'DeleteEvent'">
{
'location' : location ,
'name' : 'SNMPTrapListener/Ready'
}
</call>
<message>
'Delete event from the trap listener'
</message>
<call function="'DeleteEvent'">
{
'location' : location ,
}
</call>
</sequence>
</else>
</if>
</sequence>
<else>
<tcstatus result="'fail'"></tcstatus>
</else>
</if>
</sequence>
</function>
</stax>