snmp.xml revision d81978a0815d5b8a75633c35e3e1f8708d36f017
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "/stax.dtd">
<!--
! 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
! trunk/opends/resource/legal-notices/OpenDS.LICENSE
! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
! 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 Sun Microsystems, Inc.
! -->
<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>
SNMP community/context
</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-map-args>
<sequence>
<!-- 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_DIR,SNMP_OPENDS_JARFILE)
snmpPath='%s/snmp' % remote.java
jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
emma_jarfile='%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
if os.path.exists(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 = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp]
</script>
<message>
'%s %s' % (STAFCmd, STAFCmdParams)
</message>
<call function="'runCommand'" >
{
'name' : 'SNMP Get' ,
'command' : '%s/bin/java' % JAVA_HOME ,
'arguments' : '%s %s' % (STAFCmd, STAFCmdParams) ,
'location' : location ,
'path' : '%s/snmp' % remote.java,
'env' : env ,
'expectedRC' : expectedRC
}
</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>
SNMP community/context
</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>
<!-- 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_DIR,SNMP_OPENDS_JARFILE)
snmpPath='%s/snmp' % remote.java
jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
emma_jarfile='%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
if os.path.exists(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 = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp]
</script>
<message>
'%s %s' % (STAFCmd, STAFCmdParams)
</message>
<call function="'runCommand'" >
{
'name' : 'SNMP Set' ,
'command' : '%s/bin/java' % JAVA_HOME ,
'arguments' : '%s %s' % (STAFCmd, STAFCmdParams) ,
'location' : location ,
'path' : '%s/snmp' % remote.java,
'env' : 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-map-args>
<sequence>
<call function="'ResolveVar'" >
{
'location' : location ,
'type' : 'STRING',
'name' : 'STAF/Config/STAFRoot'
}
</call>
<script>
if is_windows_platform(location):
jstaf_jarfile='%s\\bin\\JSTAF.jar' % STAFResult
else:
jstaf_jarfile='%s/lib/JSTAF.jar' % STAFResult
</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=':'
opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_DIR,SNMP_OPENDS_JARFILE)
snmpPath='%s/snmp' % remote.java
jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
cp = 'CLASSPATH=%s%s%s%s%s%s.' \
% (opends_jarfile,separator,jdmk_jarfile,separator,jstaf_jarfile,separator)
env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp]
</script>
<message>
'%s %s' % (STAFCmd, STAFCmdParams)
</message>
<call function="'runCommand'" >
{
'name' : 'SNMP Trap Listener' ,
'command' : '%s/bin/java' % JAVA_HOME ,
'arguments' : '%s %s' % (STAFCmd, STAFCmdParams) ,
'location' : location ,
'path' : snmpPath ,
'env' : env ,
'outputFile' : outputFile ,
'expectedRC' : expectedRC
}
</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_DIR,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="dsInstancePort" type="required">
<function-arg-description>
Directory server 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-map-args>
<sequence>
<!-- Build the command -->
<script>
STAFCmdParamsList=[]
STAFCmdParams=''
if dsPath:
dsBinPath='%s/%s' % (dsPath,fileFolder)
if dsInstanceHost:
STAFCmdParamsList.append('-h %s' % dsInstanceHost)
if dsInstancePort:
STAFCmdParamsList.append('-p %s' % dsInstancePort)
if dsInstanceDn:
STAFCmdParamsList.append('-D "%s"' % dsInstanceDn)
if dsInstancePswd:
STAFCmdParamsList.append('-w "%s"' % dsInstancePswd)
STAFCmdParamsList.append('-n')
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
}
</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>
SNMP community/context
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
<function-arg-def name="index" type="required">
<function-arg-description>
Index for the out/in bytes check
</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>
<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="'checktestStringNotPresent'">
{
'returnString' : result ,
'testString' : 'ERROR'
}
</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-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>
<tcstatus result="'fail'"></tcstatus>
<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 ,
'name' : 'SendTrap/Complete'
}
</call>
</sequence>
</else>
</if>
</sequence>
<else>
<tcstatus result="'fail'">'Timer failed to begin.'</tcstatus>
</else>
</if>
</sequence>
</function>
</stax>