Creating and handling ADS routes

Adding ADS routes via the Automation Interface can be achieved by using the ConsumeXml() method of the ITcSmTreeItem interface. However, it is important to understand the underlying XML structure before adding routes to a remote target.

XML structure

The following code snippets represent sample XML structures for adding routes to a remote target. Please note that you can either specify the IP address or the hostname of the remote target.

This code snippet will add a regular route to a remote target.

Code Snippet (XML):

<TreeItem>
  <ItemName>Route Settings</ItemName>
  <PathName>TIRR</PathName>
  <RoutePrj>
    <TargetList>
      <BroadcastSearch>true</BroadcastSearch>
    </TargetList>
    <AddRoute>
      <RemoteName>RouteName</RemoteName>
      <RemoteNetId>1.2.3.4.5.6</RemoteNetId>
      <RemoteIpAddr>1.2.3.4</RemoteIpAddr>
      <UserName>userName</UserName>
      <Password>password</Password>
      <NoEncryption></NoEncryption>
      <LocalName>LocalName</LocalName>
    </AddRoute>
  </RoutePrj>
</TreeItem>

This code snippet will add a project route to a remote target.

Code Snippet (XML):

<TreeItem>
  <ItemName>Route Settings</ItemName>
  <PathName>TIRR</PathName>
  <RoutePrj>
    <TargetList>
      <BroadcastSearch>true</BroadcastSearch>
    </TargetList>
    <AddProjectRoute>
      <Name>RouteName</Name>
      <NetId>1.2.3.4.5.6</NetId>
      <IpAddr>1.2.3.4</IpAddr>
    </AddProjectRoute>
  </RoutePrj>
</TreeItem>

The following code snippet will use the hostname instead of the IP address.

Code Snippet (XML):

<TreeItem>
  <ItemName>Route Settings</ItemName>
  <PathName>TIRR</PathName>
  <RoutePrj>
    <TargetList>
      <BroadcastSearch>true</BroadcastSearch>
    </TargetList>
    <AddRoute>
      <RemoteName>RouteName</RemoteName>
      <RemoteNetId>1.2.3.4.5.6</RemoteNetId>
      <RemoteHostName>CX-12345</RemoteHostName>
      <UserName>userName</UserName>
      <Password>password</Password>
      <NoEncryption></NoEncryption>
      <LocalName>LocalName</LocalName>
    </AddRoute>
  </RoutePrj>
</TreeItem>

And for project routes.

Code Snippet (XML):

<TreeItem>
  <ItemName>Route Settings</ItemName>
  <PathName>TIRR</PathName>
  <RoutePrj>
    <TargetList>
      <BroadcastSearch>true</BroadcastSearch>
    </TargetList>
    <AddProjectRoute>
      <Name>RouteName</Name>
      <NetId>1.2.3.4.5.6</NetId>
      <HostName>1.2.3.4</HostName>
    </AddProjectRoute>
  </RoutePrj>
</TreeItem>

Please note that the XML structure for regular and project routes may be used simultaneously.

The following code snippet creates an ADS route to a remote target that has been specified by its IP address (10.1.128.217) and its AMS NetId (10.1.128.217.1.1).

Code Snippet (C#):

string xmlString ="<TreeItem><ItemName>Route Settings</ItemName><PathName>TIRR</PathName><RoutePrj><TargetList><BroadcastSearch>true</BroadcastSearch></TargetList><AddRoute><RemoteName>RouteName</RemoteName><RemoteNetId>10.1.128.217.1.1</RemoteNetId><RemoteIpAddr>10.1.128.217</RemoteIpAddr><UserName>Administrator</UserName><Password>1</Password><NoEncryption></NoEncryption></AddRoute></RoutePrj></TreeItem>";
ITcSmTreeItem routes = systemManager.LookupTreeItem("TIRR");
routes.ConsumeXml(xmlString);

Code Snippet (Powershell):

$xmlString ="<TreeItem><ItemName>Route Settings</ItemName><PathName>TIRR</PathName><RoutePrj><TargetList><BroadcastSearch>true</BroadcastSearch></TargetList><AddRoute><RemoteName>RouteName</RemoteName><RemoteNetId>10.1.128.217.1.1</RemoteNetId><RemoteIpAddr>10.1.128.217</RemoteIpAddr><UserName>Administrator</UserName><Password>1</Password><NoEncryption></NoEncryption></AddRoute></RoutePrj></TreeItem>"
$routes = $systemManager.LookupTreeItem("TIRR")
$routes.ConsumeXml($xmlString)