QuantaStor Custom Scripting / Application Extensions

From OSNEXUS Wiki
Jump to: navigation, search

Custom Scripting / Application Extensions

QuantaStor has script call-outs which you can use to extend the functionality of the appliance for integration with custom applications. For example, you may have an application which needs to be notified before or after a storage pool starts or stops. Or you may have need to call a script before an automated snapshot policy starts in order to quiesce applications.

Note: The QuantaStor process that runs these custom scripts has a timeout value of 300 Seconds to ensure that the process can continue and not pause for an unexpected amount of time. If your scripts when implemented take longer than 300 seconds, please review them and take steps to reduce their execution time.

Security Issues

Scripts are called from the root user account so you must be careful to not allow anyone but the root user to have write access to create files under /var/opt/osnexus/custom. By default the scripts directory has permissions '755'. Your scripts should be configured with file permissions using the command 'chmod 755 scriptname.sh' to prevent non-root user accounts from modifying the scripts. Additionally, if you have sensitive information like a plain text password in your custom script be sure to set the permissions to 700 rather than 755 so only the root user account can read the script.

Timeouts

Scripts must complete within 5 minutes; scripts taking longer are automatically terminated.

Where to install custom scripts

Custom script call-outs are hard-wired to specific file names and must be placed in the custom scripts directory '/var/opt/osnexus/custom' within your QuantaStor appliance. If you have a grid of appliances you'll need to install your script onto all of the appliances.

Custom Scripts Directory:

/var/opt/osnexus/custom

Storage System Custom Scripts

Scripts related to the startup / shutdown of the appliance.

system-poststart.sh

The system poststart script is only called one time when the system boots up. If the management services are restarted it will check against the timestamp in /var/opt/osnexus/quantastor/qs_lastreboot an only call the system-poststart.sh script if it has changed. If you want your poststart script to run every time the management service is restarted you can just delete the qs_lastreboot file in your script.

system-prestop.sh

Called when the user initiates a shutdown or a restart via the web management interface (or CLI). Note that if the admin bypasses the normal shutdown procedure and restarts the appliance at the console using 'reboot' or 'shutdown -P now' or similar command your script won't get called.

Storage Pool Custom Scripts

If you have custom applications running within the appliance which need to attach/detach from the pool or specific directories within a given storage pool these scripts may be helpful to you.

pool-poststart.sh

Called just after a storage pool is started. The UUID of the pool is provided as an input arguement to the script as '--pool=<POOLUUID>'. You can use 'qs pool-get <POOLUUID> --server=localhost,admin,password --xml' to get more detail about the storage pool from within your script. The --xml flag is optional, and you'll need to provide the correct admin password.

pool-prestop.sh

Called just before the pool is stopped.

Snapshot & Replication Schedule Custom Scripts

These scripts provide a mechanism for administrators to customize the Remote Replication and Snapshot Schedule features available with QuantaStor with custom scripting which is invoked at various stages of the process. Starting with QuantaStor 4.0.3 additional functionality has been added to the scheduling features for remote replication and snapshots to take all of the snapshots for Network Shares and Storage Volumes at the same time in order to provide a consistent point-in-time view. We refer to the group of snapshots as a consistency group. Consistency groups are generally accurate to within 1 second across all devices in the Snapshot Schedule / Replication Schedule. For releases Prior to 4.0.3, there was no consistency group and snapshots were taken serially which creates problems for OLTP and other workloads.

schedule-prestart.sh

Command Arguments:

--name=SCHEDULE_NAME --id=SCHEDULE_ID

This script is called just before a snapshot or replication schedule is triggered / executed. This can provide functionality to begin a freeze of your database or application datastore or provide any other customization that your team may require related to the start of a replication or snapshot schedule.

schedule-presnap.sh

Command Arguments:

--name=SCHEDULE_NAME --id=SCHEDULE_ID

This script is called just before snapshots are taken in a snapshot or replication schedule. If you have multiple Storage Volumes and/or Network Shares in the Schedule, QuantaStor will do all prep work related to metadata and QuantaStor Management Objects structures for the Shares/Volumes in the schedule, then trigger your script and finally trigger the snapshots of the Network Shares or Storage Volumes as a group. This schedule-presnap.sh script can provide functionality to begin a 'freeze' of your database or application datastore or provide any other customization that your team may require for snapshotting of your data.

schedule-postsnap.sh

Command Arguments:

--name=SCHEDULE_NAME --id=SCHEDULE_ID

This script is called just after snapshots are taken in a snapshot or replication schedule. If you have multiple Storage Volumes and/or Network Shares in the Schedule, QuantaStor will execute this script just after the snapshots have been taken for the schedule. and then perform final task cleanup tasks and/or begin remote replication tasks to transfer the data to a QuantaStor node at a DR site. This schedule-postsnap.sh script can provide functionality to begin a 'thaw' of your database or application datastore or provide any other customization that your team may require for operations after snapshotting of your data has occurred.