Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Workaround for PDF export bug

Anchor
TOC
TOC
Include Page
KBCOMMON:KB-CSSstyle
KBCOMMON:KB-CSSstyle

...

Use this option to edit the stop script that will be executed at service shutdown upon manual request or during the Charon Linux server shutdown procedure.

The script is unique and uses the configuration file (full name) to select commands to be executed at guest shutdown (selected by "case in...").

...

To be able to perform a clean shutdown of your Tru64 or OpenVMS virtual machine, you will have either to use the provided scripts (see above) or to add your own shutdown scripts.

If you plan to use the "expect" utility, please read Tips and Tricks - Shutdown guests with Expect tool for more.

(lightbulb) Basic knowledge of shell programming is needed to implement the clean shutdown / stop script.

MethodComments
expect

Requires you pass user and password to the script so that it can connect to the

OPA0

console via "telnet" and execute the shutdown commands. The "guest_shutdown.exp" script, located in the /opt/charon/utils folder, can perform operations to:

log off a user connected on the console
  1. run the shutdown if the prompt is detected,
  2. enter a username/password to login if "
login
  1. Console Login:"
or "username:"
  1. is detected,
  2. execute the shutdown command if the prompt is detected,
  3. detect the
SRM prompt (>>>)
  1. Main Menu or ISL prompt to issue the "
power off
  1. exit" command
(AXP) or send the F6 key (VAX) if enabled
  1. .

This method is useful if the virtual machine has no telnet connection available and cannot handle "rsh" and "ssh" remote connections. For more, please read Tips and Tricks - Shutdown guests with Expect tool.

Important notes:

  1. For MPE/iX systems, this is the only available method. Username and password are then not necessary. A <CTRL-A> will be sent on the console then if the "=" prompt is detected the "SHUTDOWN SYSTEM" command will be sent (other cases are also taken into account like Main menu prompt, ISL> prompt or text garbage on the console)
  2. Note any local existing connection to the console has to be killed before executing the expect script.
  3. If the console is locked from an external connection or if the prompt is not detected after sending a carriage return, the expect script will fail.
rsh

Requires a trust to be created between the Linux server and

the Tru64 or OpenVMS guest (proxy)

the HP-UX guest to issue password free remote commands. For more, please read the Tips and Tricks chapter dedicated to rsh trusts.

(info) If 'rsh' is not installed on the Linux server, please run "# yum install rsh" (CentOS7/RHEL7) or "dnf install rsh" (CentOS8). For RHEL 8, please read the Tips and Tricks chapter dedicated to rsh installation on RHEL8.

ssh

Requires a secured trust to be created between the Linux server and the

Tru64 or OpenVMS

HP-UX guest (key pair)

...

to issue password and passphrase free remote commands. For more, please read the Tips and Tricks chapter dedicated to ssh trusts.


Div
classpagebreak


If your application and server

...

need time to shutdown, it could be necessary to give more time in the service definition to prevent from the service stop procedure to fail due to timeout.

To do so, open the "Manage 'systemd' services" option and edit the service configuration file. You can then add the TimeoutStopSec= parameter in the Service section. The default value is 20 minutes and can be changed in the preferences menu options.

Example:

[Service]
...
TimeoutStopSec=3min

(info) More information can be found using the "# man systemd.service" command on your Linux server


Options

TO BE CONTINUED

Explanation on the example file

Example with SSH, Tru64 guest

(lightbulb) An ssh trust between the CHARON Linux server and the Tru64 guest must have been previously configured in order to use this method. See Tips and Tricks for help to setup the trust.

  1. Check the guest can be reached via "ssh" (adapt the ConnectTimeout value to your needs), if yes, issue the shutdown command, wait a few seconds and check if the guest can be "pinged" and repeat with an interval of 5 seconds. If the guest cannot be pinged, assume the shutdown procedure is complete
  2. Kill the emulator process (Red Hat Enterprise Linux 6.x) or use the service kill command (RHEL 7.x and CentOS 7.x). Note: the shutdown commands does not power off nor stop the emulator process, that's why this operation is needed
  3. Report the stop information within the guest log file

Image Added

  • Options 1 to 3 are explanations on how to setup and prepare the virtual machine and the Charon Linux server (if necessary) to use the three available methods. 
  • Option 4 edits the script. This script is in a form of "case in <configuration filename> do ..."
  • Option 5 is used to test the script. Use with caution on production machines.

You'll find in options 1 to 3 all the details to setup the remote connection: packages to install, proxy settings for rsh, key pair definition for ssh (password and passphrase free), the necessary firewall settings if needed, etc...

Include Page
KBCOMMON:DOC-GoToToc
KBCOMMON:DOC-GoToToc

Div
classpagebreak

Example with SSH, OpenVMS guest

(lightbulb) An ssh trust between the CHARON Linux server and the OpenVMS guest must have been previously configured in order to use this method. See Tips and Tricks for help to setup the trust.

  1. Check the guest can be pinged (an "ssh" command as for the Tru64 example above can also be used), if yes, issue the shutdown command, wait a few seconds and check if the guest can be "pinged" and repeat with an interval of 5 seconds. If the guest cannot be pinged, assume the shutdown procedure is complete
  2. Kill the emulator process (Red Hat Enterprise Linux 6.x) or use the service kill command (RHEL 7.x and CentOS 7.x). Note: the shutdown commands does not power off nor stop the emulator process, that's why this operation is needed
  3. Report the stop information within the guest log file

...

Example with Expect tool, Tru64 guest

  1. Check if there's an active connection to the console on the local host, kill if any.
    Reminder: (warning) If the console is locked from an external connection or if the prompt is not detected after sending a carriage return, the expect script will fail.
  2. Replace the user (EXPUSR), password (EXPPWD) and shell prompt (EXPPRT) with the ones corresponding to your guest (shell prompt is used to determine if a user is logged on the console)
  3. Execute the "expect" script and report all output to /opt/charon/log/console.stop.<guest name>.log. Note: no need to kill the emulator process here as the "power off" command is executed.


Common stop script explanation

When the script is initialized using option 6 or when a new virtual machine is added, the following lines are added:

...

# Parameter $1: contains full path to cfg file
# Parameter $2: contains full path to emulator exe file
#
# Important notes:
# - comments & commands must be on separate lines
# - respect the structure of the file with case/in/esac
# - only place your commands between the selection and the ';;' line
#
. /opt/charon/utils/charon_common
#
case "$1"
in
  <configuration file>)
    #-- Uncomment and complete one of the following lines:
    #${CHARONDIR}/utils/charon_gstop_expect $1 $2 root <password> "<prompt>" <HPUX/MPEIX>
    #${CHARONDIR}/utils/charon_gstop_rsh $1 $2 <hostname> <HPUX/MPEIX>
    #${CHARONDIR}/utils/charon_gstop_ssh $1 $2 <hostname> <HPUX/MPEIX>
    #/<path>/<myscript>
    ;;

...

esac

One of the blue colored lines above has to be uncommented depending on the method chosen. Other lines can remain in the script or can be deleted.

Notes:

  • The values between the < and > signs have to be filled manually.
  • The operating system must be set to either HPUX or MPEIX (case insensitive).
  • If the "rsh" or "ssh" method is used, the <hostname>, corresponding to the virtual machine hostname, must be known by the Charon Linux server.
  • if MPEIX is defined, only the "expect" method can be used. Username, password and prompt can be set to "X" as they are not needed. Example: ${CHARONDIR}/utils/charon_gstop_expect \$1 \$2 X X X MPEIX

Stop script content example:

(info) The editor defined in the Preferences is used to edit the script.

...

#
. /opt/charon/utils/charon_common
#
case "$1"
in
  /charonRP7400/rp7400.cfg)
    ${CHARONDIR}/utils/charon_gstop_ssh $1 $2 rp7400 HPUX
    ;;
  *)
    echo "Invalid parameter '$1'"
    exit 1
    ;;
esac


Div
classpagebreak


Stop script execution example with "ssh" / HP-UX 11.23:

Image Added

Include Page
KBCOMMON:DOC-GoToToc
KBCOMMON:DOC-GoToToc

...

Div
classpagebreak


Stop script execution example with "expect" / MPEiX:

Image Added

Image Added

Provided shutdown scripts explanation

(warning) Whatever the shutdown script execution result is, the stop request sent by the systemctl command will stop the emulator. It is very important then to ensure the stop script has been tested and validated.

charon_gstop_expect

  • Check if there's an active connection to the console on the local host, kill if any.

...

  • Execute the /opt/charon/utils/guest_shutdown.exp expect script with the values provided: username (root), password, prompt (for HP-UX only), operating system (either HPUX or MPEIX). This script is able to send the shutdown command depending on the returned characters on the console.
  • Report all output to /opt/charon/log/console.stop.<guest name>.log.

...

Example with Expect tool, VAX VMS guest

...

Notes:

  • If the "Main Menu" prompt is found, the "exit" command is sent to stop the emulator.
  • If the "ISL>" prompt is found, a "reset" command is sent then waits for the "Main Menu" prompt and sends the "exit" command is sent to stop the emulator.
  • (warning) If the console is locked from an external connection or if the prompt is not detected after sending a carriage return, the expect script will fail.

...

Div
classpagebreak


charon_gstop_rsh

  • Check the guest can be reached via ping, if yes:

    • Issue the shutdown command via "rsh" (depends on the operating system),

    • Wait for a few seconds

    • Check if the guest can be "pinged" and repeat with an interval of 5 seconds

    • If the guest cannot be pinged, assume the shutdown procedure is complete

  • Kill the emulator process and reset the service state. (question) The shutdown commands does not power off nor stop the emulator process, that's why this operation is needed

  • Report the stop information within the guest log file

...

...

classpagebreak

Optional guest display status script

...

charon

...

This status line is the result of the command you executed for that guest (known by its configuration file), for example a ping, an ssh command displaying uptime (Tru64) or boottime (OpenVMS).

Display output example:

...

classpagebreak

Script example:

(lightbulb) In this example, we'll use "ssh" to display the guest "uptime" and the result of the "uname -nr" command (name of the node + release number of the operating system)

(warning) The last 2 lines are mandatory

...

classcommandline

# touch /opt/charon/utils/charon_gstart.chkrun

# chmod 744 /opt/charon/utils/charon_gstart.chkrun

# vim /opt/charon/utils/charon_gstart.chkrun

#!/bin/sh

#

# Parameter $1: contains full path to cfg file

#

case "$1"

in

  /charon/pluto.cfg)

    ssh -o ConnectTimeout=2 pluto "uptime|cut -f1 -d',';echo ' - ';uname -nr" 2>/dev/null

    RETVAL=$?

    ;;

  *)

    echo "Invalid parameter '$1'"

    RETVAL=1

    ;;

esac

echo "==RETVAL=${RETVAL}=="

exit ${RETVAL}

...

classpagebreak

Example file provided (contains example for Tru64 and OpenVMS):

...

Image Removed

...

_gstop_ssh

  • Check the guest can be reached via ping, if yes:

    • Issue the shutdown command via "ssh" (depends on the operating system),

    • Wait for a few seconds

    • Check if the guest can be "pinged" and repeat with an interval of 5 seconds

    • If the guest cannot be pinged, assume the shutdown procedure is complete

  • Kill the emulator process and reset the service state. (question) The shutdown commands does not power off nor stop the emulator process, that's why this operation is needed

  • Report the stop information within the guest log file

Include Page
KBCOMMON:DOC-GoToToc
KBCOMMON:DOC-GoToToc