I have had the opportunity to work with XtremIO quite a bit lately. One of the benefits of working for an EMC partner is lab gearJ. XtremIO hast a REST based API and I wondered what others in the community had done with the API for XtremIO and PowerShell. I started searching for the available PowerShell functionality and found a couple of different modules.
The first one I ran across is here; a module created by Matt Boren. It has some great functionality and I explored it quite a bit. It is written to take advantage of PowerShell features such as the pipeline. The primary challenge I had was understanding the code well enough to be able to extend it and have a good handle on how it works. It has some complex decision and looping structures which I had difficulty following. The next module I found was here; a module created by Brandon Kvarda. This module also has good functionality and although I did not explore it as much as the module mentioned above, it had some tidbits to leverage. The primary reason I did not want to take this module and run with it was some of the development paradigms. I personally like to use a more “PowerShelly” type of approach utilizing PowerShell objects and leveraging the pipeline differently than this module.
I decided to learn some things from the code and create my own module. The articles and code provided some helpful insight and shortened the learning process. My end goal was to create a module which I better understood and could easily extend, while keeping things as simple as possible. I will provide some examples on using the PowerShell module for XtremIO and you can find it here on GitHub.
The module provides standard CRUD functionality from the XtremIO REST API. It has full coverage of all the HTTP GET functions as well as PUT, POST, and DELETE for the most common objects. To start with I am just ignoring certificate errors and it is on my list to add in use of certificates in the login process for both validation and authentication. I am currently using a simple method to store password information in a file to enable creation of scripts that can be run automatically. So let’s go through the process of setting the module up, preparing a password file and executing some commands.
The first thing that is required is to place the module in your modules folder. I will not go into specifics here as there are many sources of that information. Once the module is loaded the first step is to create a password file. The great thing about this method is the password file is encrypted based on the credentials of the currently logged on user and machine. It cannot be used on another machine or by another account on the same machine. So if you are going to setup a password file to be used in a scheduled task make sure you create the file using the account that will run the scheduled task.
Here is a screenshot of the password file creation process.
Here we see the contents of the encrypted password file.
Now that the authentication is setup and ready to use I will talk about the functionality of the module. If we issue a Get-Command –Module MTSXtremIO it will return a list of all the cmdlets currently included in the module.
The first step is to connect to the XtremIO XMS management server. This is done by using the Set-XIOAPIConnectionInfo cmdlet. The example below shows the connection process and an example of the Get-XIOCluster cmdlet returning some basic information about the cluster.
Now I will show an example of creating a volume folder and some volumes. First we will list the names of the current volume folders.
The next step is to create a new volume folder to hold the volumes. The example below shows this along with a listing of the new folder. Now the folder is ready to create the new volumes.
The example below shows how PowerShell can help to create 8 volumes very quickly.
The screenshot below shows an example of how we can view only the resulting volumes. Also in this example I show the VAAI thin provisioning alert setting. One thing to point out is the REST API does not actually set the various alert settings on volume creation and it is done as an additional task after volume creation.
The example below shows how this is accomplished using the Update-XIOVolume cmdlet and lists the updated volumes.
One note here, the New-XIOVolume and Update-XIOVolume cmdlets will be updated soon to accept pipeline input and not require the use of the foreach-object cmdlet. I discovered this flaw creating this post, Doh! That update will also enable putting the New-XIOVolume and Update-XIOVolume together on the pipeline to allow creation and setting options to happen in a simple one liner.
The other common tasks which can be managed with the module today is LUN mapping and snapshots. I will be working on other functionality and adding it to the module as time permits. I hope folks find this useful and I always appreciate feedback and comments. One last thing, if you have not had a chance to do any testing with an XtremIO all flash array I recommend it highly. It is quite fun.
MTSXtremIO PowerShell Module Download https://github.com/dmuegge/MTSXtremIO/releases
[…] This is done by using the PowerCli and a function from my MTSXtremIO module, read about that here. This function uses the XtremIO REST API to create the snapshot. I also use a couple of other […]
Thank you very much for all the powershell scripts . You have very well documented all scenarios for snapshot creation.
i noticed one issue when using update-xio snapshot or refresh xio snapshot. its creating a new snapshot for every refresh at the same time the old snapshot is still mapped with new data. Is that normal?. could you let me know how to clear this snap as i believe it is going to pile up for every run.
Thanks in advance
Thank you for the information.
Yes, I have noticed this but have not investigated yet. My lab is in a state of flux at the moment, but I will look into it as soon as I get things back in order.
What I have done as a work around is use a snapshot naming policy which includes date and time. Then I can use to run a separate delete job and clean up old copies.
Actually I am trying to SSH into an EMC XtremIO using bash/ Perl… But I don’t care what the script is written in… I have not been successful due to it wanting to authenticate twice… I have not figured a way around it and was wondering if you have any tips?
You can use XtremIO API with CURL for bash scripting.