Automatisation of RecoverPoint Virtual Appliance installation Part 2: Expect

run_expectAs I mentioned in my previous post, automatic installation of virtual appliances is not a trivial task. In automation projects, we tend to concentrate on basic operational tasks, like automating the creation of a multi-tier vApp. But sometimes we need to have new kind of functionality in the environment, like data replication. My previous post showed how we can deploy a virtual appliance from OVF-file using vCenter Orchestrator and ovftool. Now we need to actually implement the appliance. Usually there is a wizard for implementing these appliances, and EMC RecoverPoint is no different. If we can do these configurations from CLI, then automation is possible. Even better, if there is a set of commands that are used from Bash, configuration is easy. When it comes to RecoverPoint however, we do have CLI but it is strictly wizard based and you don’t have access to Bash. One workaround without some serious hacking for this problem is Expect. With this tool, we can emulate a user going through the wizard and making choices during the installation. You cannot install Expect on RecoverPoint appliance, so you need a Linux box that is used as a configuration server and a jump box. I used the same Centos Linux VM that has my ovftool installed. The installation of Expect is straightforward:

yum install expect

You can use SSH and Expect together, so you can form an SSH session to RecoverPoint appliance and run Expect from a remote server. The actual Expect code is easy. You simply wait until a particular string appears on the console, for instance “Enter IP address”. When Expect finds this string, it can insert an answer for that question, i.e. “192.168.0.1”. We need to parse through the configuration process, record the answers we would give and turn that into Expect language. Unfortunately I don’t have a VNX system with iSCSI ports in my lab, so I couldn’t finish my code, but the principle of the solution works, you just need IQNs to integrate. After that we can use the CLI to configure LUNs for RP and start the actual replication of data. When the LUN is protected, we can use vCenter Orchestrator to migrate the selected VMs to protected LUNs and we are done! The necessary files can be found at the end of this post. Have fun!

The bash script that I called from a vCO workflow looks like this:

#!/usr/bin/expect -f
# vRPA login information
set USER "boxmgmt"
set PASSWORD "boxmgmt"
set IP "192.168.0.179"
#VNX settings
set VNXSN "CKM00112233444"
set VNXNAME "VNX5500"
set SPA "192.168.0.124"
set SPB "192.168.0.125"
set CS "192.168.0.123
set ISCSI1VNX "192.168.0.156"
set ISCSI2VNX "192.168.0.157"
set ISCSI3VNX "192.168.0.158"
set ISCSI4VNX "192.168.0.159"
set VNXUSER "sysadmin"
set VNXPASSWORD "sysadmin"
#vRPA LAN/MGMT settings
set LANMASK "255.255.255.0"
set LANGW "192.168.0.1"
set LANVIP "192.168.0180"
set RPA1LAN "192.168.0.181"
set RPA2LAN "192.168.0.182"#vRPA WAN settings
set WANMASK "255.255.255.0"
set WANGW "192.168.0.1"
set RPA1WAN "192.168.0.183"
set RPA2WAN "192.168.0.184"
#vRPA iSCSI settings
set ISCSIMASK "255.255.255.0"
set ISCSIGW "192.168.0.1"
set RPA1ISCSI1 "192.168.0.185"
set RPA1ISCSI2 "192.168.0.186"
set RPA2ISCSI1 "192.168.0.187"
set RPA2ISCSI2 "192.168.0.188"
#vRPA General settings
set DNS1 "192.168.0.4"
set DNS2 ""
set NTP "192.168.0.4"
set DOMAINNAME "demo.lab"
set CLUSTERNAME "RP"
set NUMBEROFRPAS "1"
set TIMEZONE "+2:00"
set CITY "26"

# SSH to RecoverPoint Appliance and start the Configuration Wizard
spawn ssh $USER@$IP
expect "Password:"
send "$PASSWORD\r"
expect "Do you want to configure a temporary IP address?"
send "n\r"
expect "Enter your selection"
send "1\r"
expect "Enter your selection"
send "1\r"
expect "Are you installing the first RPA in the cluster"
send "y\r"

# Cluster settings
expect "Press ENTER to move to next page"
send "\r"
expect "Enter cluster name"
send "$CLUSTERNAME\r"
expect "Enter the number of RPAs in the cluster"
send "$NUMBEROFRPAS\r"
expect "Enter time zone"
send "$TIMEZONE\r"
expect "Enter your selection"
send "$CITY\r"
expect "Enter primary DNS"
send "$DNS1\r"
expect "Enter secondary DNS"
send "$DNS2\r"
expect "Enter domain name"
send "$DOMAINNAME\r"
expect "Enter addresses of host names of NTP servers"
send "$NTP\r"
expect "Press ENTER to move to next page"
send "\r"

# LAN
expect "Select network interface IP version"
send "1\r"
expect "Enter default IPv4 gateway"
send "$LANGW\r"
expect "Enter interface mask"
send "$LANMASK\r"
expect "Enter RPA 1 IP address"
send "$RPA1LAN\r"
expect "Press ENTER to move to next page"
send "\r"

#WAN
expect "Select network interface IP version"
send "1\r"
expect "Enter interface mask"
send "$WANMASK\r"
expect "Enter RPA 1 IP address"
send "$RPA1WAN\r"
expect "Press ENTER to move to next page"
send "\r"

#iSCSI port 1, eth2
expect "Do you want the RPA to require CHAP"
send "n\r"
expect "Select network interface IP version"
send "1\r"
expect "Enter interface mask"
send "$ISCSIMASK\r"
expect "Enter RPA 1 IP address"
send "$RPA1ISCSI1\r"

#iSCSI port 2, eth3
expect "Select network interface IP version"
send "1\r"
expect "Enter interface mask"
send "$ISCSIMASK\r"
expect "Enter RPA 1 IP address"
send "$RPA1ISCSI2\r"
expect "Press ENTER to move to next page"
send "\r"

#VNX
expect "Enter a name for the storage array"
send "$VNXNAME\r"
expect "Does the storage array require CHAP"
send "n\r"

# VNX iSCSI port 1
expect "Select network interface IP version"
send "1\r"
expect "Enter IP address"
send "$ISCSI1VNX\r"
expect "Enter the iSCSI port number"
send "3260\r"

# VNX iSCSI port 2
expect "Select network interface IP version"
send "1\r"
expect "Enter IP address"
send "$ISCSI2VNX\r"
expect "Enter the iSCSI port number"
send "3260\r"

expect "Do you want to add another iSCSI storage port"
send "n\r"
expect "Do you want to add another storage iSCSI configuration"
send "n\r"
expect "Press ENTER to move to next page"
send "\r"

expect "Do you want to add a gateway"
send "n\r"
expect "Press ENTER to move to next page"
send "\r"
expect "Press enter to continue"
send "\r"

expect "Do you want to apply these configuration settings now"
send "y\r"
interact

Here are the workflows for ovftool and Expect.
Deploy vRPA with ovftool
Helper workflow for using ovftool
Run Expect on remote host

Prerequisites for the workflows:

  • a Linux VM with SSH enabled
  • ovftool installed
  • expect installed
  • expect script copied to the VM
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s