cc/td/doc/product/rtrmgmt/vpnsc/mpls/1_2
hometocprevnextglossaryfeedbacksearchhelp
PDF

Table of Contents

Getting Started using the CORBA APIs

Getting Started using the CORBA APIs

Before beginning to use the APIs for client application development you should have a working knowledge of CORBA and its Interface Definition Language (IDL). To help you with the VPN Solutions Center APIs, this chapter discusses the following:

The CORBA Environment

The VPN Solutions Center servers use Orbix distributed object technology from Iona Technologies PLC. An instance of the Iona Object Request Broker (ORB)—the orbixd daemon—must be executing on each host on which a VPN Solutions Center CORBA server is installed. The executable file for the orbixd daemon is installed as a part of the VPN Solutions Center installation as the user, orbxadm; the directory is orbix/Orbix3.

The startwd script registers the servers in the Orbix Implementation repository. When the servers are launched they provide access to the APIs. Each registers at least one interface in the Orbix Naming Service.

The Naming Server runs under the process name ns; the host on which it is installed is specified as a configuration parameter during installation of each of the VPN Solutions Center servers.

You should be able to compile the IDL files using any CORBA compiler that is IIOP (Internet Inter-ORB Protocol) version 1.1 compliant.


Tips Examples contained in this programming guide may show code or refer to a programming environment that is specific to the Iona Orbix implementation of the CORBA standard. You may need to adjust your code if your CORBA implementation is not either the Iona Orbix or OrbixWeb product. Additionally, some examples are based on an installation of Orbix on a PC running Microsoft Windows NT; other examples are based on a Solaris UNIX installation. This may produce some variance in such things as file names and file extensions.

Creating Target-language Stubs from the API IDL Files

Before you can begin development with the CORBA APIs supplied with the VPN Solutions Center, you must create target-language stubs from the corresponding IDL files for use in the host language of your client-source code. Compile all the necessary IDL files using the IDL compiler supplied with your CORBA implementation.

Using the CORBA APIs in Client Application Code

To use your compiled IDL stub code to add VPN Solutions Center functionality to your client application, you must understand the following:

CORBA Naming Service

Before your client application can bind to any of the VPN Solutions Center server objects, it must know where the Name Server (ns) process is running. How you get this information depends on your CORBA implementation.

You must set to two parameters, these parameters are set by the environment files. The environment variables are:

Context Tree

To obtain an object reference to one of the VPN Solutions Center servers, you first need to find the default naming context, which indicates on which host to find each VPN Solutions Center server process. How you do this is dependent on your CORBA implementation.

There are three ways to connect to the Naming Server:

Use lsit to obtain a list of the servers, use psit to obtain the list of the processes active. Figure 1-1shows the structure of the CORBA context tree for the VPN Solutions Center servers.


Figure 1-1: CORBA Context Tree for VPN Solutions Center Servers


Getting a CORBA Object

With the following code, your client application can obtain a CORBA object name that is bound in the naming tree to a CORBA object.

    // Set the parameters.
    void setParams(unsigned short connType, const String& param)
    {
      nsConnectType = connType;
      nsParam = param;
    }
     
    static CORBA::Object_ptr resolveName(const CosNaming::Name& name)
    {
      CORBA::Object_ptr				corbaObjPtr;
      CosNaming::NamingContext_var rootContextVar;
      if(name.length() <= 0)
      {
        cout<<"Name is blank"<<endl;
        return CORBA::Object::_duplicate(CORBA::Object::_nil());
      }
     
      // Try to connect using one of the three connection techniques.
      try
      {
        if(nsConnectType == RESOLVE_BY_BIND)
        {
          rootContextVar=CosNaming::NamingContext::_bind("root:NS",nsParam);
        }
        else if(nsConnectType == RESOLVE_FROM_IOR)
        {
          // Read the ior of the root context
          char nsIor[500];
          ifstream ior(nsParam);
          if(!ior)
          {
            cout<<"Unable to open the file: "<<endl;
            return CORBA::Object::_duplicate(CORBA::Object::_nil());
          }
          ior>>nsIor;
          corbaObjPtr = CORBA::Orbix.string_to_object(nsIor);
          rootContextVar = CosNaming::NamingContext::_narrow(corbaObjPtr);
        }
        else if(nsConnectType == RESOLVE_BY_DEFAULT)
        {
          corbaObjPtr = CORBA::Orbix.resolve_initial_references("NameService");
          rootContextVar = CosNaming::NamingContext::_narrow(corbaObjPtr);
        }
        else
        {
          cout<<"No option to connect to ns"<<endl;
          return CORBA::Object::_duplicate(CORBA::Object::_nil());
        }
      } // end try
      
      // Catch the exception raised if the connection process fails.
      catch(CORBA::SystemException &se)
      {
        cout<<"System Exception while getting root context: "<<se;
        return CORBA::Object::_duplicate(CORBA::Object::_nil());
      } // end catch
     
      // Catch an Unknown exception.
      catch(...)
      {
        cout<<"Unknown Exception while getting root context"<<endl;
        return CORBA::Object::_duplicate(CORBA::Object::_nil());
      } // end catch
     
      // Try to rsolve the namespace.
      try 
      {
        corbaObjPtr = rootContextVar->resolve(name);
      } // end try
     
      // Catch the CosNaming::NamingContext::NotFound exception.
      catch (CosNaming::NamingContext::NotFound& ex) 
      {
        cerr << "Caught NotFound exception from "
             << "CosNaming::NamingContext::resolve():\n"
             << ex << '\n';
        return CORBA::Object::_duplicate(CORBA::Object::_nil());
      } // end catch
     
      // Catch the CosNaming::NamingContext::CannotProceed exception.
      catch (CosNaming::NamingContext::CannotProceed& ex) 
      {
        cerr << "Caught CannotProceed exception from "
             << "CosNaming::NamingContext::resolve():\n"
             << ex << '\n';
        return CORBA::Object::_duplicate(CORBA::Object::_nil());
      } // end catch
     
      // Catch the CosNaming::NamingContext::InvalidName exception.
      catch (CosNaming::NamingContext::InvalidName& ex) 
      {
        cerr << "Caught InvalidName exception from "
             << "CosNaming::NamingContext::resolve():\n"
             << ex << '\n';
        return CORBA::Object::_duplicate(CORBA::Object::_nil());
      } // end catch
     
      // Catch the CORBA::SystemException exception.
      catch (CORBA::SystemException &se) 
      {
        cout<<"System Exception while getting root context: "<<se;
        return CORBA::Object::_duplicate(CORBA::Object::_nil());
      } // end catch
     
      // Catch an Unknown exception.
      catch (...) 
      {
        cerr << "Caught Unknown exception from "
             << "CosNaming::NamingContext::resolve():\n";
        return CORBA::Object::_duplicate(CORBA::Object::_nil());
      } // end catch
     
      // Success indication: Return CORBA object pointer to a bound, resolved, and
      // narrowed namespace.
      return corbaObjPtr;
    }
     
    

When the context of the Naming Server is obtained by the client application, VPN Solutions Center servers that have public interfaces are automatically registered in the Orbix Naming Service.

Binding to Servers

The VPN Solutions Center servers register themselves in the Naming Service when they are launched. Here is a list of the VPN Solutions Center servers to which your client application can bind:

When binding to each of the these server in your client-application code, you must use the hierarchy shown in Figure 1-1 to narrow the object reference.

VpnInvServer

The C++ code that follows, contacts the Naming Service to bind to the VPN Inventory server. Required input parameters include:

If the vsmServerPtr reference is unable to bind to the to VPN Inventory server, a null pointer is returned.

    CiscoVpnServiceModel::VsmServer_ptr getVpnInvServer(const char* vsmServerName);
     
    {
      // Resolve the VPN Inventory server name to an object reference.
      CORBA::Object_var vsmObjVar;
      CosNaming::Name_var nameVar;
      CiscoVpnServiceModel::VsmServer_ptr vsmServerPtr;
     
      nameVar = new CosNaming::Name(1);
      nameVar->length(1);
     
      nameVar[0].id = CORBA::string_dup(vsmServerName);
      nameVar[0].kind = CORBA::string_dup(vsmServerName);
     
      vsmObjVar = resolveName(*nameVar);
     
      if(CORBA::is_nil(vsmObjVar))
      {
        return CiscoVpnServiceModel::VsmServer::_duplicate(
                 CiscoVpnServiceModel::VsmServer::_nil());
      }
     
      vsmServerPtr = CiscoVpnServiceModel::VsmServer::_narrow(vsmObjVar);
     
      if (CORBA::is_nil(vsmServerPtr)) 
      {
        cerr << "CosNaming::NamingContext::resolve() failed.\n";
        return CiscoVpnServiceModel::VsmServer::_duplicate(
                 CiscoVpnServiceModel::VsmServer::_nil());
      }
     
      return vsmServerPtr;
    }
     
    

CVPIMServer

The C++ code that follows, contacts the Naming Service to bind to the VPIM server. Required input parameters include:

If the vpimServerPtr reference is unable to bind to the to VPIM server, a null pointer is returned.

    CiscoVPIM::VPIMManager_ptr getVpimManager(const char* vpimServerName);
     
    {
      // Resolve the VPIM server name to an object reference.
      CORBA::Object_var vpimObjVar;
      CosNaming::Name_var nameVar;
     
      nameVar = new CosNaming::Name(1);
      nameVar->length(1);
     
      nameVar[0].id = CORBA::string_dup(vpimServerName);
      nameVar[0].kind = CORBA::string_dup(vpimServerName);
     
      vpimObjVar = resolveName(*nameVar);
     
      if(CORBA::is_nil(vpimObjVar))
      {
        return CiscoVPIM::VPIMManager::_duplicate(
                 CiscoVPIM::VPIMManager::_nil());
      }
     
      CiscoVPIM::VPIMManager_ptr vpimManagerPtr;
      vpimManagerPtr = CiscoVPIM::VPIMManager::_narrow(vpimObjVar);
     
      if (CORBA::is_nil(vpimManagerPtr))
      {
        cerr << "CosNaming::NamingContext::resolve() failed.\n";
        return CiscoVPIM::VPIMManager::_duplicate(
                 CiscoVPIM::VPIMManager::_nil());
      }
     
      return vpimManagerPtr;
    }
    

TaskServer

The C++ code that follows, contacts the Naming Service to bind to the Task server. Required input parameters include:

If the taskServerPtr reference is unable to bind to the to Task server, a null pointer is returned.

    CiscoTaskServiceModel::TaskServer_var getTaskServer(const char* taskServerName)
     
    {
      // Resolve the Task server name to an object reference.
      CORBA::Object_var taskObjVar;
      CosNaming::Name_var nameVar;
      CiscoTaskServiceModel::TaskServer_var taskServerVar;
     
      nameVar = new CosNaming::Name(1);
      nameVar->length(1);
     
      nameVar[0].id = CORBA::string_dup(taskServerName);
      nameVar[0].kind = CORBA::string_dup(taskServerName);
     
      taskObjVar = resolveName(*nameVar);
     
      if(CORBA::is_nil(taskObjVar))
      {
        return CiscoTaskServiceModel::TaskServer::_duplicate(
                 CiscoTaskServiceModel::TaskServer::_nil());
      }
     
      taskServerVar = CiscoTaskServiceModel::TaskServer::_narrow(taskObjVar);
     
      if (CORBA::is_nil(taskServerVar))
      {
        cerr << "CosNaming::NamingContext::resolve() failed.\n";
        return CiscoTaskServiceModel::TaskServer::_duplicate(
                 CiscoTaskServiceModel::TaskServer::_nil());
      }
     
      return taskServerVar;
    }
    

SlaBrowser

The C++ code that follows, contacts the Naming Service to bind to the SLA server. Required input parameters include:

If the slaServerPtr reference is unable to bind to the to SLA server, a null pointer is returned.

    CiscoSlaMonitor::SlaBrowser_ptr getSlaMonitor(const char* slaServerName)
     
    {
      // Resolve the SLA Browser server name to an object reference.
      CORBA::Object_var slaBrowserObjVar;
      CosNaming::Name_var nameVar;
     
      nameVar = new CosNaming::Name(1);
      nameVar->length(6);
     
      nameVar[0].id = CORBA::string_dup("CiscoNSMBU");
      nameVar[0].kind = CORBA::string_dup("Company");
     
      nameVar[1].id = CORBA::string_dup("Netsys");
      nameVar[1].kind = CORBA::string_dup("Product");
     
      nameVar[2].id = CORBA::string_dup("Default Solaris repository");
      nameVar[2].kind = CORBA::string_dup("Repository");
     
      nameVar[3].id = CORBA::string_dup("DataCollection");
      nameVar[3].kind = CORBA::string_dup("System");
     
      nameVar[4].id = CORBA::string_dup("DataManager");
      nameVar[4].kind = CORBA::string_dup("SubSystem");
     
      nameVar[5].id = CORBA::string_dup(slaServerName);
      nameVar[5].kind = CORBA::string_dup(slaServerName);
     
      slaBrowserObjVar = resolveName(*nameVar);
      CiscoSlaMonitor::SlaBrowser_ptr slaBrowserPtr;
      slaBrowserPtr = CiscoSlaMonitor::SlaBrowser::_narrow(slaBrowserObjVar);
     
     
      if (CORBA::is_nil(slaBrowserPtr)) 
      {
        cerr << "CosNaming::NamingContext::resolve() failed.\n";
        return CiscoSlaMonitor::SlaBrowser::_duplicate(
                 CiscoSlaMonitor::SlaBrowser::_nil());
      }
     
      return slaBrowserPtr;
    }
    

AcctMonitor

The C++ code that follows, contacts the Naming Service to bind to the Account Monitor server. Required input parameters include:

If theacctMonitorPtr reference is unable to bind to the to Account Monitor server, a null pointer is returned.

    CiscoAcctMonitor::AcctMonitor_ptr getAcctMonitor(const char* acctMonitorServerName)
     
    {
      // resolve Account Monitor server name to an object reference.
      CORBA::Object_var acctMonitorObjVar;
      CosNaming::Name_var nameVar;
     
      nameVar = new CosNaming::Name(1);
      nameVar->length(6);
     
      nameVar[0].id = CORBA::string_dup("CiscoNSMBU");
      nameVar[0].kind = CORBA::string_dup("Company");
     
      nameVar[1].id = CORBA::string_dup("Netsys");
      nameVar[1].kind = CORBA::string_dup("Product");
     
      nameVar[2].id = CORBA::string_dup("Default Solaris repository");
      nameVar[2].kind = CORBA::string_dup("Repository");
     
      nameVar[3].id = CORBA::string_dup("DataCollection");
      nameVar[3].kind = CORBA::string_dup("System");
     
      nameVar[4].id = CORBA::string_dup("DataManager");
      nameVar[4].kind = CORBA::string_dup("SubSystem");
     
      nameVar[5].id = CORBA::string_dup(acctMonitorServerName);
      nameVar[5].kind = CORBA::string_dup(acctMonitorServerName);
     
      acctMonitorObjVar = resolveName(*nameVar);
      CiscoAcctMonitor::AcctMonitor_ptr acctMonitorPtr;
      acctMonitorPtr = CiscoAcctMonitor::AcctMonitor::_narrow(acctMonitorObjVar);
     
      if (CORBA::is_nil(acctMonitorPtr)) 
      {
        cerr << "CosNaming::NamingContext::resolve() failed.\n";
        return CiscoAcctMonitor::AcctMonitor::_duplicate(
                 CiscoAcctMonitor::AcctMonitor::_nil());
      }
     
      return acctMonitorPtr;
    }
    

EventGateway

The C++ code that follows, contacts the Naming Service to bind to the Event Gateway server. Required input parameters include:

If the eventGatewayVar reference is unable to bind to the to Event Gateway server, a null pointer is returned.

    CiscoEventGateway::EventGateway_var 
      getEventGateway(const char* eventGatewayServerName)
     
    {
      // Resolve the Event Gateway server name to an object reference.
      CORBA::Object_var eventGatewayObjVar;
      CosNaming::Name_var nameVar;
      CiscoEventGateway::EventGateway_var eventGatewayVar;
     
      nameVar = new CosNaming::Name(1);
      nameVar->length(1);
     
      nameVar[0].id = CORBA::string_dup(eventGatewayServerName);
      nameVar[0].kind = CORBA::string_dup(eventGatewayServerName);
     
      eventGatewayObjVar = resolveName(*nameVar);
     
      if(CORBA::is_nil(eventGatewayObjVar))
      {
        return CiscoEventGateway::EventGateway::_duplicate(
                 CiscoEventGateway::EventGateway::_nil());
      }
     
      eventGatewayVar = CiscoEventGateway::EventGateway::_narrow(eventGatewayObjVar);
     
      if (CORBA::is_nil(eventGatewayVar))
      {
        cerr << "CosNaming::NamingContext::resolve() failed.\n";
        return CiscoEventGateway::EventGateway::_duplicate(
                 CiscoEventGateway::EventGateway::_nil());
      }
     
      return eventGatewayVar;
    }
    


hometocprevnextglossaryfeedbacksearchhelp
Posted: Fri Sep 22 20:11:49 PDT 2000
Copyright 1989-2000©Cisco Systems Inc.