home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
osmp
/
root.2
/
usr
/
lib
/
scoadmin
/
psrsetup
/
psrsetupOsa
/
psrsetupOsa~
Wrap
Text File
|
1998-08-19
|
5KB
|
173 lines
# Copyright (c) 1992-1998 The Santa Cruz Operation, Inc.. All Rights Reserved.
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE
# SANTA CRUZ OPERATION INC.
#
# The copyright notice above does not evidence any actual or intended
# publication of such source code.
#******************************************************************************
#
# Copyright (C) 1992-1998 The Santa Cruz Operation, Inc.
# All Rights Reserved.
#
# The information in this file is provided for the exclusive use of
# the licensees of The Santa Cruz Operation, Inc. Such users have the
# right to use, modify, and incorporate this code into other products
# for purposes authorized by the license agreement provided they include
# this notice and the associated copyright notice with any such product.
# The information in this file is provided "AS IS" without warranty.
#
#===============================================================================
#@package: SCO_PSRSETUPOSA_MSGS SCO_PSRSETUPOSA_MSGS
proc SCO_PSRSETUPOSA_MSGS {} {}
global SCO_PSRSETUPOSA_MSGS
set SCO_PSRSETUPOSA_MSGS(@catalog@) {psrsetupOSA.cat@sa 1}
set SCO_PSRSETUPOSA_MSGS(ERR_NOPROC) {1 {Could not get info on processor %s}}
set SCO_PSRSETUPOSA_MSGS(ERR_NOSTATE) {2 {Could not get state of processor %s}}
set SCO_PSRSETUPOSA_MSGS(ERR_NOOFFLN) {3 {Could not take processor %s offline}}
set SCO_PSRSETUPOSA_MSGS(ERR_NOONLN) {4 {Could not bring processor %s online}}
set SCO_PSRSETUPOSA_MSGS(ERR_NOFORK) {5 {Could not fork process}}
set SCO_PSRSETUPOSA_MSGS(ERR_NOEXEC) {6 {Could not exec %s}}
set SCO_PSRSETUPOSA_MSGS(ERR_NOINFO) {7 {Could not get processor info}}
set sco_psrsetup_CDT(attributes) {}
set sco_psrsetup_CDT(groups) {}
set sco_psrsetup_CDT(operations) {
{
action
{
{ function psrsetup_action }
{ granularity perObject }
}
}
}
set sco_psrsetup_CDT(class) {sco psrsetup}
set sco_psrsetup_CDT(superior) {}
set sco_psrsetup_CDT(subordinates) {}
set localhost [SaHostGetLocalName]
proc psr:GetAllProcessorInfo {} {
set result [misc:ExecCommand /sbin/psrinfo "" 1]
if { [ lindex $result 0 ] != 0 } {
return [list 1 [IntlLocalizeMsg SCO_PSRSETUPOSA_ERR_NOINFO ]]
}
return $result
}
proc psr:GetProcessorInfo { data } {
set psrno [lindex $data 0]
set result [misc:ExecCommand /sbin/psrinfo "-v $psrno" 1]
if { [ lindex $result 0 ] != 0 } {
return [list 1 [IntlLocalizeMsg SCO_PSRSETUPOSA_ERR_NOPROC $psrno] ]
} else {
set info ""
foreach i [lindex $result 1] {
append info $i
append info \n
}
return [list 0 $info]
}
}
proc psr:StartStopProcessor { data } {
set psrno [lindex $data 0]
set result [misc:ExecCommand /sbin/psrinfo "-s $psrno"]
if { [ lindex $result 0 ] != 0 } {
return [list 1 [IntlLocalizeMsg SCO_PSRSETUPOSA_ERR_NOSTATE $psrno] ]
}
set online [lindex $result 1]
if { $online } {
set result [misc:ExecCommand /sbin/psradm "-f $psrno"]
if { [ lindex $result 0 ] != 0 } {
return [list 1 [IntlLocalizeMsg SCO_PSRSETUPOSA_ERR_NOOFFLN $psrno] ]
}
} else {
set result [misc:ExecCommand /sbin/psradm "-n $psrno"]
if { [ lindex $result 0 ] != 0 } {
return [list 1 [IntlLocalizeMsg SCO_PSRSETUPOSA_ERR_NOONLN $psrno] ]
}
}
return $result
}
proc misc:ExecCommand { prog arguments args } {
set l [llength $args]
set multi 0
set resultsfile ""
switch -exact -- $l {
1 {
set multi [lindex $args 0]
}
2 {
set multi [lindex $args 0]
upvar [lindex $args 1] exitcode
}
3 {
set multi [lindex $args 0]
upvar [lindex $args 1] exitcode
set resultsfile [lindex $args 2]
}
}
if { [cequal $resultsfile "" ] } {
set tmpfile "/tmp/.execCommand.out"
} else {
set tmpfile $resultsfile
}
if { [catch "open $tmpfile w" catchres] } {
set msg "Could not open $tmpfile"
return [ list 1 $msg ]
}
set fdout $catchres
set processID [fork]
if { $processID == 0 } {
dup $fdout stdout
dup $fdout stderr
catch {execl "$prog" "$arguments"} catchres
exit 255
} elseif { $processID == -1 } {
return [ list 1 [IntlLocalizeMsg SCO_PSRSETUPOSA_ERR_NOFORK] ]
exit 1
}
set pidinfo [wait $processID]
set exitcode [lindex $pidinfo 2]
close $fdout
switch -exact -- $exitcode {
255 {
set retVal 1
set retMsg [IntlLocalizeMsg SCO_PSRSETUPOSA_ERR_NOEXEC $prog]
}
default {
set fd [ open $tmpfile r ]
if { $multi } {
set retMsg [list]
while { ![ eof $fd ] } {
set foo [gets $fd]
if { ! [ cequal $foo "" ] } {
lappend retMsg $foo
}
}
} else {
set retMsg [gets $fd]
}
close $fd
set retVal $exitcode
}
}
if { [cequal $resultsfile "" ] && [ file exists $tmpfile ] } {
unlink -nocomplain $tmpfile
}
return [list $retVal $retMsg]
}
proc psrsetup_action {class object refObject op subOp data attr attrValueList osaData} {
switch $subOp {
GetAllProcessorInfo {
return [psr:GetAllProcessorInfo]
}
GetProcessorInfo {
return [psr:GetProcessorInfo $data]
}
StartStopProcessor {
return [psr:StartStopProcessor $data]
}
default { ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ACTION $subOp } }
return
}
OFBinding sco_psrsetup_CDT