Identify the Base Server Scoping Instance

The following pseudocode shows how to traverse the association to arrive at the Base Server Scoping Instance. This pseudocode depends on the pseudocode in Make a Connection to the CIMOM.

To identify the Base Server Scoping Instance

Procedure

  1. Connect to the server URL.

    Specify the Interop namespace, supplied as a parameter, for the connection.

    use wbemlib
    use sys
    use connection renamed cnx
    connection = Null
    
    params = cnx.get_params()
    if params is Null 
       sys.exit(-1)
    interop_params = params
    interop_params['namespace'] = 'root/interop'
    connection = cnx.connect_to_host( interop_params )
    if connection is Null 
       print 'Failed to connect to: ' + params['host'] + ' as user: ' + params['user']
       sys.exit(-1)
  2. Enumerate instances of CIM_RegisteredProfile.
    use registered_profiles renamed prof
    
    profile_instance_names = prof.get_registered_profile_names( connection )
    if profile_instance_names is Null
       print ‘No registered profiles found.’
       sys.exit(-1)
  3. Select the instance that corresponds to the Base Server profile.
    function isolate_base_server_registration( connection, instance_names ) 
       ///Isolate the Base Server registration.///
       for instance_name in instance_names 
          instance = connection.GetInstance( instance_name )
          if instance[ 'RegisteredName' ] == 'Base Server'
             return instance_name
       return Null
    
    profile_instance_name = isolate_base_server_registration( connection, \
                                                              profile_instance_names )
    if profile_instance_name is Null 
       print 'Base Server profile is not registered in namespace ' + namespace
       sys.exit(-1) 
  4. Traverse the CIM_ElementConformsToProfile association to reach the Scoping Instance.
    function associate_to_scoping_instance( connection, profile_name ) 
       ///Follow ElementConformsToProfile from RegisteredProfile to ComputerSystem.///
       instance_names = connection.AssociatorNames( profile_name, \
                                   AssocClass = 'CIM_ElementConformsToProfile', \
                                   ResultRole = 'ManagedElement' )
       if len( instance_names ) > 1 
          print 'Error:  %d Scoping Instances found.' % len( instance_names )
          sys.exit(-1)
       return instance_names.pop()
    
    function print_instance( instance ) 
       print '\n' + ' [' + instance.classname + '] ='
       for prop in instance.keys() 
          print ' %30s = %s' % ( prop, instance[prop] )
    
    scoping_instance_name = associate_to_scoping_instance( connection, profile_instance_name )
    if scoping_instance_name is Null 
       print 'Failed to find Scoping Instance.'
       sys.exit(-1)
    else
       print_instance( connection.GetInstance( scoping_instance_name )