NAME
CPM - Complete module to work with MyPrinterCloud System
SYNOPSIS
use CPM;
my $env=CPM->new();
$env->auto(-verbose=>1);
DESCRIPTION
The CPM module manages the API of MyPrinterCloud, providing the subroutines to collect the information from the networked printers and to transmit it to CPS (Cloud Printing Server). It offers several options to accomplish key design criteria such as non-invasive, open, flexible, standard and scalable.
FUNCTIONALITY
The CPM functionality is completely defined by its configuration file (config.xml) that acts also, as firmware of the module.
Configuration sample
The CPM needs a default configuration file that must be adjusted by the user, at least, including his credentials (valid user in MyPrinterCloud).
<?xml version="1.0" encoding="UTF-8"?> <opt call="http://myprintercloud.nubeprint.com/np/selector.pl" proxy="" > <id comm="call" date="2010-09-10" mode="discover" pass="xxx" type="soft-public" user="demo@nubeprint.com" /> <range from="105" to="115" lan=""/> </opt>
ID section
- comm [email,call]: it defines the communication method
- mode [discover,list]: set if the CPM must discover the network or only collect data from the printers previously identified in a list
- user: email account valid on the CPS or MyPrinterCloud
- pass: password of a valid user of the CPS or MyPrinterCloud
- type: optional
- date: date when the configuration file was built by the CPS.
Communication channel
Communication with the CPS accepts two different forms depending on the needs of the destination network. Also, note that although there are two mechanisms you can activate only one per CPM.
Call
This method is based on the HTTP standard, which operates in real time and is bidirectional. That allows the CPM apply the latest set of OIDs to be queried for a particular machine. Although an HTTP connection is needed, it is a very efficient solution.
<call="http://myprintercloud.nubeprint.com/np/selector.pl"/>
This method is based on the SMTP standard with Auth support. When it's activated, the CPM collects all the information from the networked printers, composes a summary email, and sends it to the CPS. Obviously it is not bidirectional, nor in real-time, but in some cases this solution provides the Administrator an easier way to check or audit the information being transmitted.
<mail pass="yyy" smtp="myprintercloud.com" user="aaa@myprintercloud.com"/>
Modes
Discover
If this method is enabled, the CPM discovers all the networked printers and for each one, it will request information to the CPS (if it's already registered, its model, the set of OIDs, ...). The CPM auto-detects the local net in order to make a scanning of the LAN.
Range
The default discover behaviour can be modified specifying the local range and the subnet in where the CPM should scan. By default the CPM assumes the local net and from 1 to 254.
<range from="105" to="110" lan="192.168.2.0"/>
List
In this case the CPM gets a list of printers (section devices, embedded into the config file) to read, and for each one, it has already all the information needed to make a successful request.
<devices>
<device ip="192.168.2.108" number="0">
<oid name="C1">.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0</oid>
<oid name="C18">.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.2.0</oid>
<oid name="C2">.1.3.6.1.2.1.43.10.2.1.4.1.1</oid>
<oid name="C4">.1.3.6.1.2.1.43.11.1.1.8.1.1</oid>
<oid name="C5">.1.3.6.1.2.1.43.11.1.1.9.1.1</oid>
<oid name="C59">.1.3.6.1.2.1.43.11.1.1.8.1.2</oid>
<oid name="C60">.1.3.6.1.2.1.43.11.1.1.9.1.2</oid>
</device>
<device ip="192.168.2.109" number="1">
<oid name="C1">.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0</oid>
<oid name="C18">.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.2.0</oid>
<oid name="C2">.1.3.6.1.2.1.43.10.2.1.4.1.1</oid>
<oid name="C4">.1.3.6.1.2.1.43.11.1.1.8.1.1</oid>
<oid name="C5">.1.3.6.1.2.1.43.11.1.1.9.1.1</oid>
<oid name="C59">.1.3.6.1.2.1.43.11.1.1.8.1.2</oid>
<oid name="C60">.1.3.6.1.2.1.43.11.1.1.9.1.2</oid>
</device>
</devices>
CLASS
use CPM;
my $env=CPM->new();
HIGH-LEVEL SUBROUTINES
The CPM exports several subroutines to allow the developer to choose the way to handle the different transactions.
- new([-config=>'config.xml'])
-
Create the object to handle the readings and the data transaction
- auto([-verbose=1]
-
Complete the transaction using the directives from the configuration file
- listandcall([-verbose=1])
-
Read printers of a List provided by the configuration file and use the Call method to send the data
- listandmail([-verbose=1])
-
Read printers of a List provided by the configuration file and send the data by email
- discoverandcall([-verbose=1])
-
Discover the networked printers and use the Call method to send the data
- discoverandmail([-verbose=1])
-
Discover the networked printers and send the data by email
MEDIUM-LEVEL SUBROUTINES
- saveconfig
-
Save the configuration data into the xml file
- request($oid,[-type=>MAC|SN])
-
Make an SNMP request to read any OID. If MAC, it converts the hex values into an string like AA:BB:CC:DD If SN, it checks that it's a valid string. Enough lenght, and not resetted. Always converts the hex to ASCII strings
- requesttable
-
Make an SNMP walk request to read a complete branch
- checkip
-
Determinate if exists an actived printer using the IP. If yes, it returns its SN
- getgeneric
-
Read the Generics. It uses the common OIDs to try to identify the printer model and collect the basic information.
- getmodel
-
Read the specific model of printer. This function receives information from the CPS (OIDs of the model) and performs a specific SNMP request.
AUTHOR
Juan Jose 'Peco' San Martin, <peco at cpan.org>
COPYRIGHT
Copyright 2010 NubePrint
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.