MINI MINI MANI MO
# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
#
# NAME
# asmcmdglobal - ASM CoMmanD line interface (Global Memory Module)
#
# DESCRIPTION
# ASMCMD is a Perl utility that provides easy nagivation of files within
# ASM diskgroups.
#
# This module contains the global configuration variables for the
# modular setup of ASMCMD. Each ASMCMD module defines a number of
# callback functions that are used by the driver module, asmcmdcore.
# References to these callback functions are stored in the global
# variables of this module.
#
# NOTES
# usage: asmcmdcore [-p] [command]
#
# Whenever a new module of ASMCMD commands is added to ASMCMD,
# global arrays in this module needs to be updated with
# callback definitions for these functions:
# 1) Entrance function to call all module-specific commands
# 2) Function to list help messages for module-specific commands
# 3) Function to list all available commands for a module
# 4) Function to determine if a given command is one supported
# by the module
# 5) Function to determine if a given command supports the use
# of wildcard characters in its path argument(s).
# 6) Function to display the correct syntax for a command within
# the module
# 7) Function to display error messages for a module
# 8) Function to display messages for exceptions signalled
# 9) Function to determine if a given command can run without
# an ASM instance available.
# 10) Function to determine if a given command can run without
# an ASM instance.
#
# These arrays should be updated by the means of a module
# initialization function, which is defined within each module and
# referenced in the asmcmdcore:asmcmdcore_init_modules array.
#
# Here is the modular layout of ASMCMD:
#
# asmcmd
# |
# v
# asmcmdcore
# |
# |___________________________________________________________
# | | | | | |
# | v v v v v
# | asmcmdbase asmcmddisk asmcmdambr asmcmdtemplate*|
# | | | | | |
# | |____________|____________|_____________| |
# | | | |
# | | |______________________|
# | | |
# | | v
# | | asmcmdshare
# | | |
# v v v
# |______________________|____________|
# |
# v
# asmcmdglobal
#
# N.B. asmcmdtemplate* represents any new module to be added. Based
# on this modular model, we have these restrictions:
# 1) asmcmdglobal should never use any of the other modules.
# 2) asmcmdshare can use only asmcmdglobal.
# 3) No module can use asmcmdcore.
# 4) The asmcmdtempate* modules must not use each other, e.g.
# asmcmddisk cannot use asmcmdbase.
#
#
# MODIFIED (MM/DD/YY)
# diguzman 09/13/16 - 24570890: add names for disk group types
# diguzman 06/30/16 - 23721855: add global_hash{target} field
# abhmanju 01/28/16 - Bug 21275171 and 21172775: add 8015, 8017, 8018
# and 8019 for setsparseparent
# dacavazo 11/30/15 - 20766180: simplify bg/fg variables
# ykatada 12/20/14 - 15949549: Add ASMCMDGLOBAL_VER_12cR2
# anovelo 08/20/14 - Current ASM version is now set in asmcmdcore
# hppancha 03/28/14 - change spawnutil to utilsucc in global_hash
# pvenkatr 12/03/13 - #17886334 - Added iostat to exclusion list.
# pvenkatr 11/06/13 - #17395893 - Added discover flag for ASMCMD.
# pvenkatr 10/17/13 - #17620861, 17505639 - Add volresize command to
# cp-exclusion list.
# pvenkatr 10/03/13 - #13535543 - deprecated --privilege for orapwusr
# pvenkatr 07/26/13 - Bug # 17227258 Fixed version info of ASMCMD for
# 12.1.0.2.0
# gmengel 05/06/13 - Added global variable $asmcmdglobal_maxub4.
# pvenkatr 02/01/13 - Added spawnutil to asmcmdglobal_hash.
# moreddy 11/22/12 - 14142633: asmcmd needs to reconnect for flex asm
# shmubeen 10/16/12 - Fix for bug# 14184571
# pvenkatr 09/26/12 - LRG#7261918 ASMCMD version changed to 12.1.0.1.0
# adileepk 03/30/12 - Adding a variable $tempdir to store location for temp
# directory.
# pvenkatr 02/29/12 - LRG 6794287 - version bumped to 12.1.0.0.2.
# adileepk 01/09/12 - Fix for lrg-5980983. Excluding the vol commands from
# connection pooling.:x
# adileepk 11/23/11 - Fix for bug-13412679.
# adileepk 09/12/11 - Fix for bug 12970899. Adding option to opt out of
# connection pooling.
# moreddy 09/07/11 - Bug12818129 modify 8009
# adileepk 06/20/11 - Connection Pooling.
# mchimang 05/16/11 - export ASMCMDGLOBAL_VER_12gR1.
# adileepk 02/01/11 - Fix for lrg-5128205.
# moreddy 05/06/10 - bug 8667038 NLS for error messages
# amitroy 04/29/10 - BUG 8933243 - USE DIFFERENT CHARACTER IN ASMCMD TO
# "HIDE COLUMN DETAILS" INSTEAD OF -H
# sanselva 03/15/10 - remove unused global variables
# moreddy 01/19/10 - Adding tracing infrastructure
# pvenkatr 12/03/09 - Bug # 9072284 Added service as optional param for cp#
# sanselva 04/06/09 - add asmcmdglobal_options,asmcmdglobal_deprecated_options
# heyuen 10/14/08 - move CONN_STR to global
# heyuen 09/19/08 - add infinite command indicator in global hash
# heyuen 08/02/08 - add verbose
# heyuen 07/28/08 - use command property array
# heyuen 07/14/08 -
# soye 03/20/08 - update version to 11.2
# heyuen 05/25/07 - add return codes for errors
# hqian 05/24/07 - Update asmcmd version to 11.1.0.6.0
# hqian 03/02/07 - update comments; update ASM version initial value
# jilim 12/11/06 - Add comment on error message for cp
# hqian 07/20/06 - #5397026: new @asmcmdglobal_no_instance_callbacks
# hqian 06/19/06 - Add comments on error message ranges for ambr and
# disk
# hqian 01/20/06 - #4939032: creation of ASMCMD global memory module
#############################################################################
package asmcmdglobal;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(%asmcmdglobal_hash
%asmcmdglobal_cp_excluded_cmds
%asmcmdglobal_reconnect_cmds
%asmcmdglobal_cmds
%asmcmdglobal_options
%asmcmdglobal_deprecated_options
@asmcmdglobal_command_callbacks
@asmcmdglobal_help_callbacks
@asmcmdglobal_command_list_callbacks
@asmcmdglobal_is_command_callbacks
@asmcmdglobal_is_wildcard_callbacks
@asmcmdglobal_syntax_error_callbacks
@asmcmdglobal_no_instance_callbacks
@asmcmdglobal_error_message_callbacks
@asmcmdglobal_signal_exception_callbacks
$ASMCMDGLOBAL_WCARD_CHARS
$ASMCMDGLOBAL_VER_10gR1
$ASMCMDGLOBAL_VER_10gR2
$ASMCMDGLOBAL_VER_11gR1
$ASMCMDGLOBAL_VER_11gR2
$ASMCMDGLOBAL_VER_12gR1
$ASMCMDGLOBAL_VER_12cR2
$ASMCMDGLOBAL_USE_CONN_STR
$ASMCMDGLOBAL_DEFAULT
$ASMCMDGLOBAL_EXTERNAL
$ASMCMDGLOBAL_NORMAL
$ASMCMDGLOBAL_HIGH
$ASMCMDGLOBAL_FLEX
$ASMCMDGLOBAL_EXTENDED
$asmcmdglobal_trace_path
$asmcmdglobal_clsecho
$asmcmdglobal_product
$asmcmdglobal_facility
$asmcmdglobal_maxub4
);
use strict;
######################### ASMCMD Global Constants ############################
our ($ASMCMDGLOBAL_WCARD_CHARS) = '[%*]'; # Set of wildcard characters. #
our ($ASMCMDGLOBAL_VER_10gR1) = '10.1.0.2.0'; # ASM version for 10gR1. #
our ($ASMCMDGLOBAL_VER_10gR2) = '10.2.0.1.0'; # ASM version for 10gR2. #
our ($ASMCMDGLOBAL_VER_11gR1) = '11.1.0.3.0'; # ASM version for 11gR1. #
our ($ASMCMDGLOBAL_VER_11gR2) = '11.2.0.0.0'; # ASM version for 11gR2. #
our ($ASMCMDGLOBAL_VER_12gR1) = '12.1.0.0.0'; # ASM version for 12gR1. #
our ($ASMCMDGLOBAL_VER_12cR2) = '12.2.0.0.0'; # ASM version for 12cR2. #
######
# Globals constants naming disk group types
# These values are used by asmcmdshare_get_redund and its callers to identify
# the disk group type
######
our $ASMCMDGLOBAL_DEFAULT = 1;
our $ASMCMDGLOBAL_EXTERNAL = 1;
our $ASMCMDGLOBAL_NORMAL = 2;
our $ASMCMDGLOBAL_HIGH = 3;
our $ASMCMDGLOBAL_FLEX = 4;
our $ASMCMDGLOBAL_EXTENDED = 5;
######################### ASMCMD Global Variables ############################
#
our %asmcmdglobal_hash = (cwdnm => '', # Current directory name #
cwdref => '', # Current directory reference id #
gname => '', # Group name #
gnum => '', # Group number #
cmd => '', # The current internal command #
lprmt => 'n', # Use long prompt (with cwd)? #
service => '+ASM', # service name #
mode => 'i', # i=interactive,n=non-interactive #
nfnd => 0, # 1 if $level==0 and file not found #
ver => '0.0.0.0.0', # Version of ASM instance, #
# in form #
# xxyz, from format xx.y.0.z; #
# 0 => ASM version known #
endn => '', # Endianness of the system #
acver => '', # ASMCMD version number #
contyp => '', # connection type: sysasm or sysdba #
verbose=> 'normal', # verbose mode #
sth => undef, # statement handler used only by #
# signal handler to cancel #
# statement #
e => 0, # output the error #
running=> 0, #is an infinite command running? #
consistchk => 'n', #run options consistancy check ?#
isdaemon => 0, # whether this is daemon asmcmd #
ispooled => 0, # whether this is a pooled #
# instance #
tempdir => '', # Temp directory (OS specific) #
bgpipe => '', # path to pipe used to communicate #
# with the ASMCMD daemon. #
fgpipe => '', # path to pipe used to communicate #
# with foreground process. #
bgpid => undef,# PID of background process #
fgpid => undef,# PID of foreground process #
nocp => 0, # opt out of connection pooling #
# by default connection pooling will#
# be used #
asmperl => '', # asmperl binary file #
proxy_dbh => undef, # DBI Handle to ASM proxy
# instance #
inst => '', #In Flex ASM, the instance to connect to #
utilsucc => '', # spawned util succeeded
discover => 0, # Use PERL2C to discover conn str
# if 0, use SID, 1 PERL2C.
target => 'ASM', # Use ORACLE_SID to connect the #
# specified instance type. #
);
our %asmcmdglobal_cp_excluded_cmds =
(help => 1, # List of commands to #
cp => 1, # be excluded from #
orapwusr => 1, # connection pooling #
passwd => 1,
pwcopy => 1,
dsset => 1,
rm => 1,
volresize => 1,
iostat => 1, # iostat can continuously run, BG will #
# die automatically in 5 mins and this #
# conflicts, so exclude this for CP #
);
our %asmcmdglobal_reconnect_cmds =
(cp => 1, # List of commands which would require #
pwcreate => 1, # asmcmd to reconnect after they are #
pwcopy => 1, # executed #
pwdelete => 1,
pwmove => 1,
pwset => 1,
spcopy => 1,
spmove => 1,
spset => 1,
spbackup => 1,
dsset => 1,
rm => 1,
setsparseparent => 1,
);
our ($ASMCMDGLOBAL_USE_CONN_STR) = 0; # 1 allows the use of -c option to #
# specify a connect string; 0 dis- #
# allows it.
our ($asmcmdglobal_trace_path) = " ";
our ($asmcmdglobal_clsecho) = "$ENV{'ORACLE_HOME'}/bin/clsecho";
$asmcmdglobal_clsecho .= ".exe" if($^O =~ /win/i);
our ($asmcmdglobal_product) = "RDBMS";
our ($asmcmdglobal_facility) = "ASMCMD";
our ($asmcmdglobal_maxub4) = 4294967295;
# The following arrays hold lists of functions. Each ASMCMD module must
# have exactly one function in each of these arrays.
#
# These functions process ASMCMD commands within their respective modules.
our (@asmcmdglobal_command_callbacks);
# These functions process the help command within their respective modules.
our (@asmcmdglobal_help_callbacks);
# These functions list available ASMCMD commands supported by their
# respective modules.
our (@asmcmdglobal_command_list_callbacks);
# These functions determine if a command is supported by their respective
# modules.
our (@asmcmdglobal_is_command_callbacks);
# These functions determine if a command supports wildcards.
our(@asmcmdglobal_is_wildcard_callbacks);
# These functions display the correct syntax of an ASMCMD command supported
# by their respective modules.
our (@asmcmdglobal_syntax_error_callbacks);
# These functions determine if a command can run even without an ASM
# instance.
our (@asmcmdglobal_no_instance_callbacks);
our (%asmcmdglobal_cmds);
# Global Hash table to store all options for consistency check
our (%asmcmdglobal_options);
# List of deprecated options for 11.2
# Pls update this table with all options that are deprecated
# in the next release so that WARNING can be shown when used
# Delete the entries from the table in the succesive release
# after the deprecation.
# #########################################################
# Format
# ( COMMAND1 => { Option1 => [ GetoptSyntax , NewOption ]
# Option2 => [ GetoptSyntax , NewOption ]
# COMMAND2 => { Option 1 .......
#
# if NewOption is NULL then, option no more supported
#
# Algo for handling deprecated options
#--------------------------------------
# 1. push the current options in @string for GetOptions
# 2. push deprecated options if any
# 3. process args using GetOptions
# 4. if any depr options were used, set the value of the
# corresponding options
# 5. print WARNING for each depcr option used.
#
# Please see init() for each perl module and asmcmdshare_handle_deprecation
#
# Note: There are corner cases where both new option and the
# corresponding deprecated options is used together in a
# command the value that appears later in the order takes
# precedence.
# for eg : ASMCMD> md_backup -G DG1 -g DG2
# ASMCMD> md_backup -G DG1 -G DG2
# ASMCMD> md_backup -g DG1 -G DG2
# In the above examples md_backup will backup DG2 not DG1
###########################################################
our (%asmcmdglobal_deprecated_options) = ( find => { 't'=>
['t=s', 'type']},
ls => { 'r'=>
['r','reverse'],
'c'=> ['c','NULL'],
'a' =>
['a','absolutepath'],
'H'=>
['H','suppressheader']},
lsdg => { 'c'=>
['c','discovery'],
'H'=>
['H','suppressheader']},
lsdsk => { 'c'=>
['c','discovery'],
'd'=> ['d=s','G'],
'm'=>
['m=s','member|candidate'],
'H'=>
['H','suppressheader']},
md_backup => { 'b'=> ['b','NULL'],
'g'=> ['g=s','G']},
md_restore=> { 'b'=> ['b=s','NULL'],
'i'=> ['i','ignore'],
't'=>
['t=s','full|nodg|newdg'],
'f'=> ['f=s','S'],
'g'=> ['g=s','G']},
lsct => { 'H'=>
['H','suppressheader']},
lspwusr => { 'H'=>
['H','suppressheader']},
du => { 'H'=>
['H','suppressheader']},
lsof => { 'H'=>
['H','suppressheader']},
iostat => { 'H'=>
['H','suppressheader']},
lsattr => { 'H'=>
['H','suppressheader']},
lsod => { 'H'=>
['H','suppressheader']},
lstmpl => { 'H'=>
['H','suppressheader']},
lsgrp => { 'H'=>
['H','suppressheader']},
lsusr => { 'H'=>
['H','suppressheader']},
asmcmd => { 'a' =>
['a=s','privilege']},
orapwusr => { 'privilege' =>
[ 'privilege=2',
'grant']}
);
# These functions display error messages for module-specific ASMCMD commands.
# ASMCMD Error Message Numbers:
# 8000-8099 - General ASMCMD errors.
# 8001 - bad diskgroup.
# 8002 - directory/file not found.
# 8003 - connected to non-ASM instance.
# 8004 - invalid alias name.
# 8005 - ambiguous wildcard match for CD.
# 8006 - entry '%s' does not refer to a valid directory.
# 8007 - unclosed single-quote.
# 8008 - local instance not presented for cp cmd
# 8009 - more than one source file and one of them is remote
# 8010 - no user name is specified in connect string
# 8011 - no instance identifier is specified in connect string
# 8012 - can not determine file type for file
# 8013 - can not determine logical block size for file
# 8014 - can not open file
# 8015 - child cannot be on remote instance
# 8016 - copy source file to target file failed
# 8017 - setsparseparent between child and parent failed
# 8018 - more than one child file specified, one of which is remote
# 8019 - parent cannot be on remote instance
#
# 8100-8099 - Non-exception SQL errors.
# 8100 - select statement failed.
#
# 8200-8299 - Exceptions.
# 8200 - connection to Oracle lost.
# 8201 - cannot connect to Oracle.
# 8202 - asmcmd internal error.
#
# 8300-8399 - Volume Device Driver
#
# 8400-8499 - File Access Control
#
# 8551-8600 - Volume Management
#
# 9345-9370 - Metadata Backup
# 9345 - Cannot open Intermediate file: '$arg'
# 9346 - Cannot close Intermediate file: '$arg'!,
# 9347 - Cannot re-create data structures from Intermediate file:
# '$arg'
# 9348 - Override option can only be specified with -t newdg,
# default -t full
# 9349 - Diskgroup '$arg' not discovered by ASM instance, Skipping...
# 9350 - Diskgroup '$arg' not mounted by ASM instance, Skipping...
# 9351 - ASM instance has no diskgroups mounted
# 9352 - Create Diskgroup failed '$arg'
# 9353 - Create/Alter Template failed '$arg'
# 9354 - Create alias directory failed '$arg'
# 9355 - Couldnot find information for diskgroup '$arg' in backup file
# 9356 - Backup file '$arg' is either empty or cannot be interpreted
# 9357 - A file with name '$arg' already exists
# 9358 - Option -t newdg specified without any override options
# 9359 - Invalid diskgroup name '$arg' specified in Override options
#
# 9371-9390 - Disk Operations
# 9371 - disk '$arg1' does not exist in disk group '$arg2'
# 9372 - physical blocks $arg1-$arg2 do not map to a valid ASM file
# 9373 - not all physical blocks submitted for remap
# 9374 - cannot open disk header format file '$arg1' \n$arg2
# 9375 - cannot close disk header format file '$arg1' \n$arg2
# 9376 - cannot re-create data structures from disk header
# format file: '$arg'
# 9377 - disk header format file '$arg' is either empty or
# cannot be interpreted
# 9378 - the scanning of disk headers is supported only on UNIX platforms
# 9379 - character devices are not supported
# 9380 - cannot find 'syscall.ph'; please make sure that
# the Perl utility 'h2ph' \nhas been run to
# convert system .h files to Perl .ph files.
# \n\n$arg
# 9381 - remap command requires ASM software version
# $ASMCMDGLOBAL_VER_11gR1 or later.
#
# Functions for recording errors; does not terminate ASMCMD session.
our (@asmcmdglobal_error_message_callbacks);
# Functions for signaling errors; terminates ASMCMD session.
our (@asmcmdglobal_signal_exception_callbacks);
return 1;
OHA YOOOO