Device::TermSrvr::ACME.pm - example for terminal server (serial port concentrator) devices
base
$obj = Device::TermSrvr::ACME->new();
Another Cluster Module Example.
Full class name Device::TermSrvr::ACME
This module can be used as an example of how to develop modules for new TermSrvr
type devices in conjunction with the actual device modules that can be found in
this distribution.
The Methods in this module generally override methods that appear in the parent
classes. When developing a class for a TermSrvr type device be sure to use
parent methods whenever possible to exploit code shareing at the highest level
in the hierarchy. The methods in this class will function normally with the
exception of when they require the actual device to interact with in which case
they will just print out informative messages of what they would do if a
device was present.
The vast majority of the code in the ACME modules found in each class
path (Node Power and TermSrvr) is identical. Small additions
and omissions are present (or absent) where they are meaninful to describe
functionality that may be unique to a class.
Please see the code source for detailed information and implementation details.
- power - get/set power attribute, or initiate power control action
-
If passed no arguments, simply returns the object's power attribute, which is
an array ref. If passed an array reference, sets the object's power attribute.
-
If passed a scalar (on, off, cycle, inter, etc.), then the appropriate action
is taken to control the power of the device.
-
This method is largely the same as a power method that would be found in any
functional module. It is included here as an example of a typical
implementation. Most actual device interaction is done in methods called by
the power method which are also found in this module.
-
This method should be almost identical to the power method found in the
Device.pm module. When developing modules please consider using your
parents class methods whenenver appropriate.
- _perform - A ``private'' method used by the methods
off and on to execute the appropriate operation.
-
This method would normally accomplish the actual device interaction
but for the purposes of this class will only print out information to
the user about the operation that would be performed.
- off - Power off method.
-
This method is called by the power method when an argument
of ``off'' is passed. This method calls the _perform method to accomplish its
function. This method is inluded to illustrate a device type that has its own
power control capabilities. Alternatively a different object could be
specified in the power attribute, and that objects off method would be used.
For example if an object of type Device::Power::ACME was specified in the
power attribute, the off method from that class would be executed instead of
this off method.
- on - Power on method.
-
This method is called by the power method when an argument
of ``on'' is passed. This method calls the _perform method to accomplish its
function. This method is inluded to illustrate a device type that has its own
power control capabilities. Alternatively a different object could be
specified in the power attribute, and that objects on method would be used.
For example if an object of type Device::Power::ACME was specified in the
power attribute, the on method from that class would be executed instead of
this on method.
- connect - connect method.
-
This method is used to establish a connection to the device.
This class describes the type of devices that are normally used
to establish the connection to other devices if they are not
directly connected to over a LAN. Typically terminal server
devices provide a connection by attaching to the console
port of a device. Also typically the connection is established
by connecting to (typically with telnet) the terminal server
device and passing a port number that provides the pass-through
connection. This connect method is largly the same as the
connection methods in the other ACME modules with the exception
that it checks the port that was passed to the method for validity.
For device specific examples please see the device modules in
this class path.
- status - Status method
-
This method is used to status a device of this class.
What status actually means is device specific but in
general status should return what state the device is
in. Other methods like discover may need the device to be
in a specific state to perform the required funcitonality.
The status method commonly uses other class methods like
connect.
- discover - Discover method.
-
This method is used to discover a device of this type.
What discovering a device means is very device specific but
generally includes obtaining MAC addresses for one to all
of the interfaces defined in the database for the specific
device. The discover method typically uses other class
methods like status and connect.
- config - config method.
-
This method will accomplish whatever it means to config a
device of this type. Configure in this sense generally means
the basic configuration necessary to allow this device to
act as expected as a member of the cluster.
For a TermSrvr type device this could mean configuring a
termial server to pass through connections to devices that
are connected to it by passing a port that relates
to the physical port the device is connected to on the device.
See device specific modules for detailed examples.
- port - port method
-
This method is used to check the port number passed to the connect subroutine.
This port number may be important in the case of terminal server devices
that use pass through ports to connect to the devices they serve. This
is a common way to configure terminal servers for this application. This
subroutine only checks that the port number is within a valid imaginary
range for this device. The port subroutine can be used for other purposes
as demonstrated in the specific device modules located in this class path.