Query

Metreos.Native.CiscoDeviceList.Query

Summary

The Query action is used for querying the device information cache located on the Cisco Unified Application Server, in order to retrieve information on one or more devices.

Usage

Query performs a search with the specified device attributes and returns the results in a System.Data.DataTable variable. A common practice is to pass this variable into a CustomCode block for parsing the data within it.

Every action parameter specified in this action is used to further refine the actual query on the underlying Cisco Unified Application Server database using AND logic.

The resulting DataTable is an object comprised of rows and columns, with the number of resulting rows corresponding to the number of devices matched by the query. The name of the colums correspond to device attributes retrieved from the device cache database. The following list is the name of the columns comprising each row in the DataTable, which one would use when using C# to parse out the results from the table:

Name

The name of the device, such as SEPXXXXXXXXXXXX. This should not ever be null.

IP

The IP address of the device. This will be "" if undefined.

Description

The description of the device. This will be "" if undefined.

SearchSpace

The Calling Search Space of the device. This will be "" if undefined.

Pool

The Device Pool of the device. This will be "Unknown" if undefined.

Status

The Status of the device. This will be "0" if undefined.

UserName

The username associated with the device. This will be "" if undefined.

PhysicalAddress

The physical (MAC) address of the device. This will be "" if undefined.

Extn

The extension of the device. This will be "" if undefined.

ExtnInetAddress

The Extension InetAddress of the device. This will be "" if undefined.

TYPE

The type of the device. This will be "1" if undefined.

CCMIP

The IP address of the publisher node of the cluster that the device is registered to. This should not ever be null.

The following code shows how one would retrieve the IP address of a DataTable returned by a successful query with a device name specified of a valid phone in a CustomCode block:

Example 13.1. Retrieving the IP address of a Found Device


public static string Execute(DataTable resultsFromQuery, ref string phoneIp)
{
    if(resultsFromQuery != null && resultsFromQuery.Rows.Count == 1)
    {
        phoneIp = resultsFromQuery.Rows[0]["IP"] as string;
    }
    else
    {
        // if 0 or more than one device matches the device name in the query, then we have an error condition
        // This should of course be dealt with, specific to this application.
    }

    string result = null;
    if(phoneIp != null && phoneIp != String.Empty)
    {
        result = "success";
    }
    else
    {
        result = "failure";
    }

    return result;
}


Remarks

Only Registered and FoundAndUnregistered devices can be returned for Cisco Unified Communications Manager 5.x and 6.x, so for best-case compatibility, you should assume this behavior in your application.

Even though devices are uniquely keyed by DeviceName within a single Cisco Unified Communications Manager cluster, it is possible that multiple devices can be returned for a given device name. This scenario occurs when the Cisco Unified Application Server is polling multiple clusters and the device is configured in two or more of those clusters. You can use the Status parameter to only search for devices that are currently registered or/and specify the publisher IP address in the CallManagerIP action parameter to help isolate the query.

The DeviceListX provider polls every 2 hours (configurable). This means that the local Cisco Unified Application Environment device cache can be out of date with current phone information. If testing and developing with a phone that has just come online, manually invoke a refresh of the database by navigating to mceadmin > Providers > Cisco DeviceListX Provider > Invoke Extension to re-synchronous the cache.

Action Parameters
Parameter Name.NET TypeDefaultDescription
TypeMetreos.Interfaces.ICiscoDeviceList+DeviceTypesThe Type action parameter can be used to restrict the query to only devices of a particular type. Valid values are as follows:
  • Cisco7905
  • Cisco7912
  • Cisco7920
  • Cisco7940
  • Cisco7941
  • Cisco7941G
  • Cisco7960
  • Cisco7961G
  • Cisco7970
  • Cisco7971
  • IPCommunicator
NameSystem.StringThe Name action parameter can be used to restrict the query to devices matching the specified name.
DescriptionSystem.StringThe Description action parameter can be used to restrict the query to devices matching the specified description.
SearchSpaceSystem.StringThe SearchSpace action parameter can be used to restrict the query to devices with a configured CallingSearchSpace matching the specified value.
PoolSystem.StringThe Pool action parameter can be used to restrict the query to devices with a configured Device Pool matching the specified value.
IPSystem.StringThe IP action parameter can be used to restrict the query to devices matching the specified IP address.
UserNameSystem.StringThe UserName action parameter can be used to restrict the query to devices matching the specified UserName.
PhysicalAddressSystem.StringThe PhysicalAddress action parameter can be used to restrict the query to devices matching the specified Physical Address.
ExtnSystem.StringThe Extn action parameter can be used to restrict the query to devices matching the specified Extension.
ExtnInetAddressSystem.StringThe ExtnInetAddress action parameter can be used to restrict the query to devices matching the specified Extn InetAddress.
StatusMetreos.Interfaces.ICiscoDeviceList+StatusCodesRegisteredThe Status action parameter can used to restrict the query to devices matching the specified status value. Note that in Cisco Unified Communications Manager 5.x/6.x, only Registered and FoundAndUnregistered devices are returned so this field has less value for those versions since NotFound is not supported.
NotFound

The device is configured in the Cisco Unified Communications Manager database, but is not registered or connected in any way.

Registered

The device is registered to the Cisco Unified Communications Manager. Only for this status should one expect a valid value for the IP address of the device.

FoundAndUnregistered

The device is or recently was connected to the Cisco Unified Communications Manager, but is not registered.

CallManagerIPSystem.StringThe CallManagerIP action parameter can be used to restrict the query to devices matching the specified Cisco Unified Communications Manager publisher IP address.
Result Data
Parameter Name.NET TypeDescription
ResultDataSystem.Data.DataTableA .NET System.Data.DataTable that contains rows and columns corresponding to the devices and attributes returned for the query.
ResultCountSystem.Int32The number of devices returned in the query.

Branch Conditions 

Success

No description.

Failure

No description.