/* ************************************************************************** */
/* Program: GETHDWRSC                                                         */
/* Title:   Get hardware resource                                             */
/* Pgmr:    MJR                                                               */
/* ************************************************************************** */
PGM (&LPAR)
  DCL        VAR(&SYSTEM) TYPE(*CHAR) LEN(10)
  DCL        VAR(&SYSTEM03) TYPE(*CHAR) LEN(10)
  DCL        VAR(&SYSTEM04) TYPE(*CHAR) LEN(10)
  DCL        VAR(&LPAR) TYPE(*CHAR) LEN(10)
  DCL        VAR(&USER) TYPE(*CHAR) LEN(10)
  DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)
  DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(512)
  DCL        VAR(&SSHKEY) TYPE(*CHAR) LEN(100)
  DCL        VAR(&SSHPREFIX) TYPE(*CHAR) LEN(200) +
               VALUE('ssh -T hmc  chhwres -r io +
               --rsubtype slot -m +
               Server-9406-550-SNxxxxxxx -o')
  DCL        VAR(&QSHCMD) TYPE(*CHAR) LEN(512)
/* ************************************************************************** */
/*  GLOBAL MESSAGE MONITOR                                                    */
/* ************************************************************************** */
  MONMSG     MSGID(CPF0000 RPG0000 QRG0000 RSF0000 +
               MCH0000) EXEC(GOTO CMDLBL(##ERROR))
  GOTO       CMDLBL(##NOERROR)
##ERROR:
  MOVDIAGMSG
  MONMSG     MSGID(CPF0000)
  RSNESCMSG
  MONMSG     MSGID(CPF0000)
  RETURN
##NOERROR:
/* ************************************************************************** */
/*  START OF MAINLINE CODE                                                    */
/* ************************************************************************** */
  RTVJOBA    USER(&USER)
  CHGVAR     VAR(&SSHKEY) VALUE('/home/' *TCAT &USER +
               *TCAT '/.ssh/id_rsa.pub')
  CHKIFSOBJ  OBJ(&SSHKEY)
  MONMSG     MSGID(CPF9897) EXEC(DO)
    CHGVAR     VAR(&MSGDTA) VALUE('You are not set up to +
                 use SSH sessions with the HMC.')
    SNDPGMMSG MSGID(CPF9898) +
                MSGF(QCPFMSG) MSGDTA(&MSGDTA) +
                MSGTYPE(*ESCAPE)
  ENDDO
  CALL       PGM(FINDSLOTID) PARM(&SYSTEM03 &SYSTEM04)
/* If already assigned to the requested system, no need to do any more */
  IF   COND((&SYSTEM03 *EQ &SYSTEM04) *AND (&SYSTEM03 *EQ &LPAR)) THEN(DO)
    CHGVAR     VAR(&MSGDTA) VALUE('Tape drive +
                 already assigned to' *BCAT &LPAR *TCAT '. +
                 No action taken')
    SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSGDTA) +
                 MSGTYPE(*COMP)
    GOTO       CMDLBL(ENDPGM)
  ENDDO
ASSIGN:
  IF   COND(&SYSTEM03 *EQ '          ') THEN(DO)
    CHGVAR     VAR(&QSHCMD) VALUE(&SSHPREFIX *BCAT 'a -p' +
                 *BCAT &LPAR *BCAT '-l 21030021')
    QSH        CMD(&QSHCMD)
    DLYJOB     DLY(15)
    CHGVAR     VAR(&MSGDTA) VALUE(&MSGDTA *BCAT 'C03 added +
                 to' *BCAT &LPAR *TCAT '.')
  ENDDO
  IF   COND(&SYSTEM04 *EQ '          ') THEN(DO)
    CHGVAR     VAR(&QSHCMD) VALUE(&SSHPREFIX *BCAT 'a -p' +
                 *BCAT &LPAR *BCAT '-l 21040021')
    QSH        CMD(&QSHCMD)
    DLYJOB     DLY(15)
    CHGVAR     VAR(&MSGDTA) VALUE(&MSGDTA *BCAT 'C04 added +
                 to' *BCAT &LPAR *TCAT '.')
    SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSGDTA) +
                 MSGTYPE(*COMP)
  ENDDO
MOVE:
/* Move resource(s) as required */
  IF   COND(&SYSTEM04 *NE ' ') THEN(DO)
    CHGVAR     VAR(&QSHCMD) VALUE(&SSHPREFIX *BCAT 'm -p' +
                 *BCAT &SYSTEM04 *BCAT '-t' *BCAT &LPAR +
                 *BCAT '-l 21040021')
    CHGVAR     VAR(&MSGDTA) VALUE(&MSGDTA *BCAT 'C04 moved from' +
                 *BCAT &SYSTEM04 *BCAT 'to' *BCAT &LPAR *TCAT '.')
    QSH        CMD(&QSHCMD)
    DLYJOB     DLY(15)
  ENDDO
  IF   COND(&SYSTEM03 *NE ' ') THEN(DO)
    CHGVAR     VAR(&QSHCMD) VALUE(&SSHPREFIX *BCAT 'm -p' +
                 *BCAT &SYSTEM03 *BCAT '-t' *BCAT &LPAR +
                 *BCAT '-l 21030021')
    QSH        CMD(&QSHCMD)
    CHGVAR     VAR(&MSGDTA) VALUE(&MSGDTA *BCAT 'C03 moved from' +
                 *BCAT &SYSTEM03 *BCAT 'to' *BCAT &LPAR *TCAT '.')
  ENDDO
  SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSGDTA) +
               MSGTYPE(*COMP)
ENDPGM:
  RETURN
ENDPGM
Topic revision: r1 - 05 Feb 2007 - 19:45:51 - MartinRowe
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding DBG/400? Send feedback