Table Of Contents
Sample Client Program in Perl
Sample Code for Error Code/Messages
DeviceStatus
GroupStatus
IDStatus
LicenseStatus
LicLineStatus
PAKStatus
PolicyStatus
RehostInfoStatus
ReportStatus
Sample Client Program in Perl
The following text is a client program in Perl. When you connect to Cisco License Manager Server, you must provide the following information:
•
IP address of the Cisco License Manager host
•
Login name, password, port, idle-timeout and EulaInfo
use Cisco::CLM; ## should be the first 'use' statement
$eula_info = Cisco::CLM::Common::EulaInfo->new;
print "\n Eula Text: ".$eula_info->get_eula_statement;
$eula_info->set_eula_accepted(1);
$eula_info->set_do_not_ask_again(1);
$lic_manager = Cisco::CLM::SDK::LicenseManager->new;
$token =lic_manager->login("admin","password","localhost",1099,0,$eula_info);
###################################################################
create_devices_by_ip_address
###################################################################
my $user_info1 = Cisco::CLM::Common::UserPwd->new(''lab'',''lab'');
my $user_info2 = Cisco::CLM::Common::UserPwd->new(''cisco'',''cisco'');
push @usr_pwd, $user_info1;
push @usr_pwd, $user_info2;
my $ip = ''192.19.199.27'';
my $discovery_info = Cisco::CLM::Common::DiscoveryAuthInfo->new([@usr_pwd],[@en_pwds]);
push @transport_info, $Cisco::CLM::Common::Device::TransportMethod::HTTP;
my $dev_status =
$lic_manager->create_device_by_ip_addr($token,$ip,''Default'',$discovery_info,[@transport_
info]);
my $dev_status_item = $dev_status->get_device_status_items;
my $dev_id = $$dev_status_item[0]->get_device_id;
###################################################################
###################################################################
push @pak_id, "3XXXREE4B64";
my $pak_status = $licMang->create_paks($token,[@pak_id]);
my $pak_status_items = $pak_status->get_pak_status_items;
foreach my $x (@{$pak_status_items}){
my $id = $pak->get_pak_id;
###################################################################
###################################################################
my $id_status = $lic_manager->download_pak_info($token,[@pak_ids]);
## wait until download is complete
##NOTE: download_pak_info is a blocking call. It blocks until the IDStatus is returned by
the server.
my $id_status_items = $id_status->get_id_status_items;
###################################################################
###################################################################
my $lic_request = Cisco::CLM::Common::LicenseRequest-> new ;
push @lic_requests, $lic_request;
my $pak_1 = $$pak_status_items[0]->get_pak;
my $sku_list = $pak_1->get_sku_list;
$lic_requests[0]->set_sku_selection(\@skus);
$lic_requests[0]->set_device_id($dev_id);
### obtain license and deploy it
my $status = $lic_manager->obtain_license($token,[@lic_requests],1);
#### Wait for operation to complete
##NOTE: obtain_license is a blocking call. It blocks until the IDStatus is returned by the
server.
$lic_manager->logout($token);
Sample Code for Error Code/Messages
The following section describes the procedure for obtaining error codes/messages contained in the following "Status" objects:
•
DeviceStatus
•
GroupStatus
•
IDStatus
•
LicenseStatus
•
LicLineStatus
•
PAKStatus
•
PolicyStatus
•
RehostInfoStatus
•
ReportStatus
DeviceStatus
The following example shows how to read error code and message from DeviceStatus object:
# The general error code of the operation.
my $err_code = $device_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $device_status->get_error_message;
# A list of status for each individual element in the
my $device_status_items = $id_status->get_device_status_items;
# Iterate through the list to get individual status.
foreach my $k (@{$device_status_items}){
# Get the individual Device object returned by the operation.
my $device = $k->get_device;
#Get the individual error code corresponding to
my $item_err_code = $k->get_error_code;
# Get the individual error message corresponding to
my $item_err_msg = $k->get_error_message;
GroupStatus
The following example shows how to read error code and message from GroupStatus object:
# The general error code of the operation.
my $err_code = $group_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $group_status->get_error_message;
# A list of status for each individual element in the
my $group_status_items = $group_status->get_group_status_items;
# Iterate through the list to get individual status.
foreach my $k (@{$group_status_items}){
#Get the individual error code corresponding to
my $item_err_code = $k->get_error_code;
# Get the individual error message corresponding to
my $item_err_msg = $k->get_error_message;
IDStatus
The following example shows how to read error code and message from IDStatus object:
# The general error code of the operation.
my $err_code = $id_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $id_status->get_error_message;
# A list of status for each individual element in the
my $id_status_items = $id_status->get_id_status_items;
# Iterate through the list to get individual status.
foreach my $k (@{$id_status_items}){
# Get the individual object ID returned by the operation.
#Get the individual error code corresponding to
my $item_err_code = $k->get_error_code;
# Get the individual error message corresponding to
my $item_err_msg = $k->get_error_message;
LicenseStatus
The following example shows how to read error code and message from LicenseStatus object:
# The general error code of the operation.
my $err_code = $license_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $license_status->get_error_message;
# A list of status for each individual element in the
my $license_status_items = $license_status->get_license_status_items;
# Iterate through the list to get individual status.
foreach my $k (@{$license_status_items}){
# Get the individual License object returned by the operation.
my $license = $k->get_license;
#Get the individual error code corresponding to
my $item_err_code = $k->get_error_code;
# Get the individual error message corresponding to
my $item_err_msg = $k->get_error_message;
LicLineStatus
The following example shows how to read error code and message from LicLineStatus object:
# The general error code of the operation.
my $err_code = $lic_line_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $lic_line_status->get_error_message;
# A list of status for each individual element in the
my $lic_line_status_items = $lic_line_status->get_lic_line_status_items;
# Iterate through the list to get individual status.
foreach my $k (@{$lic_line_status_items}){
# Get the individual LicenseLine object returned by the operation.
my $lic_line = $k->get_lic_line;
#Get the individual error code corresponding to
my $item_err_code = $k->get_error_code;
# Get the individual error message corresponding to
my $item_err_msg = $k->get_error_message;
PAKStatus
The following example shows how to read error code and message from PAKStatus object:
# The general error code of the operation.
my $err_code = $pak_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $pak_status->get_error_message;
# A list of status for each individual element in the
my $pak_status_items = $pak_status->get_pak_status_items;
# Iterate through the list to get individual status.
foreach my $k (@{$pak_status_items}){
# Get the individual PAk object returned by the operation.
#Get the individual error code corresponding to
my $item_err_code = $k->get_error_code;
# Get the individual error message corresponding to
my $item_err_msg = $k->get_error_message;
PolicyStatus
The following example shows how to read error code and message from PolicyStatus object:
my $policy = $policy_status->get_policy;
# The general error code of the operation.
my $err_code = $policy_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $policy_status->get_error_message;
RehostInfoStatus
The following example shows how to read error code and message from RehostInfoStatus object:
# The general error code of the operation.
my $err_code = $rehost_info_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $rehost_info_status->get_error_message;
# A list of status for each individual element in the
my $rehost_info_status_items = $rehost_info_status->get_rehost_info_status_items;
# Iterate through the list to get individual status.
foreach my $k (@{$rehost_info_status_items}){
# Get the individual RehostInfo object returned by the operation.
my $rehost_info = $k->get_rehost_info;
#Get the individual error code corresponding to
my $item_err_code = $k->get_error_code;
# Get the individual error message corresponding to
my $item_err_msg = $k->get_error_message;
ReportStatus
The following example shows how to read error code and message from ReportStatus object:
# The general error code of the operation.
my $err_code = $report_status->get_error_code;
# The general error message of the operation.
my $err_msg = = $report_status->get_error_message;
# Get the content of the report
my $content = $report_status->get_content