Script for SSH

I wanted to preface my post by saying that I’m a complete newb with suse, and I hope this is the right forum for this question.

I recently set up a vma within our vcenter environment to shut down, through script, our esxi hosts when our UPS goes on battery. If possible, I would also like for it to ssh into our NetApp controllers and shut them down, as well. I believe the controllers are using a version of Unix. The command needed to be executed on the controllers is simply, “halt -t 8”. This script might need to be done in a different file. I’m not sure if this is even possible. Please let me know if I need to explain this better. I’m sure I do.

Below is the script I’m using.

#!/bin/bash

Change directory to directory containing vicfg script files

cd /usr/bin

Resolves “server version unavailable” error caused by perl

module wanting to check a certificate, which may not be

available

export PERL_LWP_SSL_VERIFY_HOSTNAME=0

Trigger the host to shutdown based upon its preconfigured

settings. Be sure to change the server, username and password

parameters before use

./vicfg-hostops --server x.x.x.x --username *"*username" --password “password” --operation shutdown -–force
./vicfg-hostops --server x.x.x.x --username “username” --password “password” --operation shutdown -–force

I appreciate the help in advance.

Are you looking for something like this?

http://www.shellhacks.com/en/Running-Commands-on-a-Remote-Linux-Server-over-SSH

You may have more luck asking this question in the right forum: http://community.netapp.com/

But to answer part of question - Data ONTAP 7G is not Unix and 8 and above have FreeBSD as more or less “hypervisor” and it is not exposed for normal access, in particular you do not shutdown NetApp via underlying FreeBSD. Never.

When setting up a Datacenter solution, the first thing you need to do is know and configure management of your physical machines as opposed to your virtual machines. Your script manages virtual machines. Unless your NetApp is something I’m not familiar with, it’s a physical appliance, not a virtual machine or something installed into a virtual machine.

This means that you should manage your NetApp and maybe even whatever physical machine your vcenter (And, maybe more) is running differently and maybe separately than what your’e doing in your posted script.

The first consideration you should always determine when managing physical machines in a Datacenter is whether any of your machines have Lights Out Management capability. For those machines, they would be managed differently than those without.

Of course, your virtual machines should all be completely (and verified) shut down before any physical machines are powered off.
If any of your Guests are deployed on NetApp appliances, you may want to install the NetApp plugin for VCenter.

In other words, depending on your setup and configuration, plus your vendor mix…
It can get a bit complex working out how your shutdown script should work, and what APIs and commands to use.
But, start with what I mentioned above.

HTH,
TSU

That first command looks like exactly what I’m looking for.

$ ssh [user]@[server] '[command]'

So, these commands will work on my VMA (Suse 11 - 3)?

That’s the basic syntax for remoting into <any> machine using ssh.

But, when you’re talking about <managing> machines whether they are virtual or physical, there are “better” methods that leverage your existing tools and there are ways that only make a mess of things, particularly when you are dealing with physical machines and virtual machines, particularly if any virtual machines are running on the physical machines you want to potentially shut down or utilize resources not entirely within a machine (virtual or physical).

So,
As I tried to suggest…
You need to clearly define and understand your virtual and physical architectures, what is dependent on what, and understand the tools you’re already using or are available to you to accomplish your objectives.

TSU

I have a vma located in my vCenter environment. It’s monitoring a SNMP webcard installed in our Tripp Lite UPS setup. When the UPS goes on battery, the vma waits 2 minutes and then executes the shutdown script. I have auto startup/shutdown configured on each host, so the VMs located on them will gracefully shut down first. After all VM’s are powered off, the hosts themselves will then shut down. What I want the shutdown script to do is shut down my esxi hosts and NetApp appliances. The command I want executed on my two NetApp controllers is “halt -t 8”. Eight minutes is enough time for all VM’s and hosts to be safely powered off.

As I described,
Your first step to managing a NetApp appliance remotely is to first determine if your device supports Lights Out Management.

This descibes what the NetApp LOM is, and how to identify
https://library.netapp.com/ecmdocs/ECMP1368862/html/GUID-E6BBAB62-8494-4DBF-903B-A79F5E91B367.html

This describes what should be pretty obvious
https://library.netapp.com/ecmdocs/ECMP1368862/html/GUID-BF68C5F0-EA71-4B2C-BF02-F0194A2C5745.html

This further describes using Lights Out
https://library.netapp.com/ecmdocs/ECMP1368862/html/GUID-0E6FB7DF-5E75-4B4B-9F84-1108437237EA.html

The above link contains a number of links for doing whatever you might want, but if you read the above, then you might notice that that there is a general category (and list) of management commands you can issue called " Data ONTAP CLI command"

The following is a blog article which contains an SSH session (more or less what you want to do except that it reboots the NetApp instead of shutting it down)

http://blog.thefrontiergroup.com.au/2012/03/lights-out-management-of-a-netapp-fas2020/

Bottom line is,
Without my doing any deeper investigation, if your system supports Data ONTAP CLI commands, that is obviously the set of commands you should be running which would gracefully manage instead of issueing HALT commands which can be disruptive and cause system malfunctions.

Note that the above does not account for wherever you’re running your vcenter which you never described.

HTH,
TSU