(file) Return to ARM_zOS.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Service

File: [Pegasus] / pegasus / src / Service / ARM_zOS.cpp (download)
Revision: 1.3, Fri Mar 30 16:19:38 2007 UTC (17 years, 3 months ago) by thilo.boehm
Branch: MAIN
CVS Tags: TASK-PEP286_PRIVILEGE_SEPARATION-root, TASK-PEP286_PRIVILEGE_SEPARATION-branch, TASK-Bug2102Final-root, TASK-Bug2102Final-merged_out_to_branch, TASK-Bug2102Final-merged_out_from_trunk, TASK-Bug2102Final-merged_in_to_trunk, TASK-Bug2102Final-merged_in_from_branch, TASK-Bug2102Final-branch
Changes since 1.2: +1 -1 lines
BUG#: 6292
TITLE: Change message PGS12533W to informational.

DESCRIPTION: Change message and log level.

//%2006////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation, The Open Group.
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; VERITAS Software Corporation; The Open Group.
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; Symantec Corporation; The Open Group.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//==============================================================================
//
// Author: Thilo Boehm (tboehm@de.ibm.com)
//
//%/////////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <string.h>
#include <errno.h>
#define _POSIX_SOURCE 
#include <sys/utsname.h> 
#include <leawi.h>
#include <ceeedcct.h>
#include <unistd.h>

#include <Pegasus/Common/Tracer.h>
#include <Pegasus/Common/Logger.h>
#include "AutoRestartMgr_ZOS_ZSERIES_IBM.h"
#include "ARM_zOS.h"


// __arm_status_tags ARM_zOS_Status = NOT_REGISTERED; // ARM stautus for CIM Server Status

#define ARM_ELEMNAME_SIZE 17          // 16 Bytes for ARM element name + '\0'

PEGASUS_NAMESPACE_BEGIN
   
           
//*******************************************************************************
// 
// Methode: void ARM_zOS::Register(void) 
// 
// Description:
// Registration and make element READY for z/OS ARM (Automatic Restart Mangager). 
// 
// Function: 
//            a) do the registration with ARM   
//            b) make the element READY for ARM 
// 
//    All errors are handled inside this routine, a failure to register or    
//    a failure to make READY the element does not impact the further function 
//    of the CIM Server. The success and failures are written to the 
//    z/OS console and the appropriate CIM Server logs.
// 
//    The registration status is saved in the global variable ARM_zOS_Status
//    for further use ( e.g. actions after a restart) within the CIM Server.
//                                                                        
//******************************************************************************
void ARM_zOS::Register(void)
{

    int i;
    
    char arm_elemname[ARM_ELEMNAME_SIZE] = "CFZ_SRV_"; // ARM element name init with base.
    int full_elemname_size;

    char arm_buffer[256];               // ARM buffer
    int arm_ret=0;                      // ARM return code 
    int arm_res=0;                      // ARM reason code 
    struct utsname uts;                 // structure to get the SYSNAME for the element name 
    int rc;

    rc = __osname(&uts);
    if(rc < 0)
    {
        PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
                   "Failed to issue __osname() command:"
                   " rc=%d, errno=%d, reason=%08X",
                   rc,
                   errno,
                   __errno2()));
        ARM_zOS_Status = NOT_REGISTERED;
        return;
    }

    // concatinate the element name base and the nodename to the full element name 
    strcat(arm_elemname,uts.nodename);
    full_elemname_size = strlen(arm_elemname);

    // padd the elementname with spaces 
    memset(arm_elemname+full_elemname_size,' ',ARM_ELEMNAME_SIZE-full_elemname_size);


    // put a Null-termination at Pos 17 to make string printable 
    arm_elemname[ARM_ELEMNAME_SIZE-1] = '\0';


    PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
               "About to register the CIM server with element name \'%s\' with ARM.",
               arm_elemname));

    // CIM server is running in ASCII and the assembler module needs the module in EBCDIC
    __atoe(arm_elemname); 

    __register_arm(arm_elemname, arm_buffer, &arm_ret, &arm_res); 

    // convert back to ascii for further processing.
    __etoa(arm_elemname);

    if(arm_ret <= 0x04)
    {
       Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::INFORMATION,
                     "Common.ARM_zOS.ARM_READY",
                     "The CIM server successfully registered to ARM using element name $0.",arm_elemname);

        if(arm_ret == 0x00)
        {
            // ARM registration at normal startup
            ARM_zOS_Status = REGISTERED;
        } else {

            // ret = 0x04 and reason code 0x104 & 0x108 indicates server restart
            if(arm_res <= 0x108)
            {
                // ARM registration at restart
                ARM_zOS_Status = RESTARTED;
            } else {
                // ret = 0x04 and reason code 0x204 & 0x304 indicates dependen component not started.
                // This can only be happen if somebody define dependencies in the restart policy.
                // CIM Server does not depend on other elements; This is a normal start up.
                ARM_zOS_Status = REGISTERED;
            }

        } // end evaluate return codes.

        // set CIM server ready with ARM
        __ready_arm(arm_buffer, &arm_ret, &arm_res);
        if(arm_ret != 0)
        {
            PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
                       "Failed to set the CIM server ready with ARM: ret=%02X reason=%04X.",
                       arm_ret,arm_res));
            ARM_zOS_Status = NOT_REGISTERED;
        }

    } else
    {

        // ARM registration fails
        char str_arm_ret[4];
        sprintf(str_arm_ret,"%02X",arm_ret);
        char str_arm_res[8];
        sprintf(str_arm_res,"%04X",arm_res);
        Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::INFORMATION,
                      "Common.ARM_zOS.ARM_FAIL",
                      "The CIM server failed to register with ARM using element name $0: return code 0x$1, reason code 0x$2."
                      ,arm_elemname,str_arm_ret,str_arm_res);

        ARM_zOS_Status = NOT_REGISTERED;

    }                

    return;
}


//*******************************************************************************
// 
// Method: void ARM_zOS::DeRegister(void) 
// 
// Description:
// De-Register CIM Server from z/OS ARM (Automatic Restart Mangager). 
// 
// Function: 
//            de-registration with ARM   
// 
//    All errors are handled inside this routine.
// 
//                                                                        
//******************************************************************************

void ARM_zOS::DeRegister(void)
{
    char arm_buffer[256];              
    int arm_ret=0;                     // ARM return code 
    int arm_res=0;                     // ARM reason code 
    
    // If CIM Server is not not registeres -> if it is REGISTERED or RESTARTED.
    if(ARM_zOS_Status != NOT_REGISTERED)
    {
        __deregister_arm(arm_buffer, &arm_ret, &arm_res);
        if(arm_ret != 0)
        {
            // write out errormessage from de-register with ARM
            PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
                       "Failed to de-register CIM Server with ARM: ret=%02X reason=%04X.",
                       arm_ret,arm_res));
        } else {

            PEG_TRACE_CSTRING(TRC_SERVER, Tracer::LEVEL2,
                             "CIM Server sucessfully de-reginster with ARM.");

        }
        ARM_zOS_Status = NOT_REGISTERED;
    }// End if
}


PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2