Tags

It’s fairly inconvenient to set the Properites for an OEM target.  When you discover a new host or configure connection to a new database you aren’t prompted for LifeCycle Status, Department, Location, not any of the other ‘Properties’ assignable to a target.

As a result, some of your targets may not have current or accurate values in those fields.  Here’s a query that uses string logic to derive LifeCycle Status from the host name.  In this example Production hosts are named oraprod01, oraprod02, etc.  Test and development hosts enjoy the same common naming standard.  BTW:  Naming standards like this flash a signal to hackers saying “Don’t waste your time on that dev/test server – all my production data is over here!”  This is just an example.

CREATE OR REPLACE VIEW scoop.properties_reconciliation AS
SELECT target_name,
       host_name,
       CASE SUBSTR ( host_name, 0, 7 )
            WHEN 'oraprod' THEN 'Production'
            WHEN 'oratest' THEN 'Test'
            WHEN 'oradevl' THEN 'Development'
        ELSE 'Not defined'
        END  AS host_lifecycle,
        property_value AS oem_property,
        CASE SUBSTR ( host_name, 0, 6 )
           WHEN 'oraprod' THEN
            DECODE ( property_value, 'Production', NULL, 'set target_property_value -property_records="' || target_name ||':oracle_database:LifeCycle Status:Production"' )
           WHEN 'oratest' THEN
            DECODE ( property_value,'Test', NULL,'set_target_property_value -property_records="' || target_name ||':oracle_database:LifeCycle Status:Test"' )
           WHEN 'oradevl' THEN
             DECODE ( property_value,'Development', NULL,'set_target_property_value -property_records="' || target_name ||':oracle_database:LifeCycle Status:Development"' )
        ELSE ''Not defined'
        END  AS corrective_action
FROM    sysman.gc$target_properties a,
        sysman.gc$target b
WHERE   a.target_guid = b.target_guid
 AND    b.target_type = 'oracle_database'
 AND    a.property_name = 'orcl_gtp_lifecycle_status'
ORDER BY target_name;

Create an EM CLI argfile from the values in the CORRECTIVE_ACTION column, by spooling everything from that column into a file.

Then execute that file as an emcli argfile, like this:

sqlplus -S ${SYSMAN_CONNECT} <<EOF 1>/dev/null
SET ECHO OFF
SET FEEDBACK OFF HEADING OFF LINES 250 PAGES 999
SPOOL ${ARGFILE01}
    SELECT DISTINCT corrective_action
    FROM scoop.properties_reconciliation;
SPOOL OFF
EOF

if [ `cat ${ARGFILE01} | wc -l` -gt 0 ]; then
    emcli login -user=sysman -pass=${CONSOLE_PWD} 2>/dev/null
    emcli argfile ${ARGFILE01}
    emcli logout
fi