This post is more than 5 years old
3 Posts
0
15374
How script Vplexcli
Hi,
Is there a way to script Vplexcli ? Since the commands are executed inside a "restricted shell", do I need to open/close a session for each command executed ?
Thanks,
Gaetano
Kennedy_Doss
79 Posts
0
June 20th, 2012 10:00
I found a suggestion by Russel Peters in the bottom of this thread (below) that I extracted from a Blog. Hope this helps.
An Introduction to the VPLEX CLI
Wednesday, December 22, 2010 in Storage by slowe | 4 comments
The VPLEX command line interface (CLI) is a bit different than a lot of other CLIs with which I’ve worked. In some respects, it’s similar to the scope-based CLI that Cisco uses with Unified Computing System (UCS). In this post, I’d like to explore the VPLEX CLI a bit and provide a brief introduction to the VPLEX CLI. Keep in mind that this is just an introduction—for a complete reference to the VPLEX CLI, I’ll refer you to the VPLEX product area on EMC PowerLink where a complete VPLEX CLI User’s Guide is available in PDF.
In my opinion, there are two things to know about the VPLEX CLI that will help you understand how to use it:
cd
command and list the contents of a context using thels
andll
commands. Just as with a typical filesystem, if you’re in the right context, you can just run a command (say, like theunclaim
command). If you’re not in the right context, you simply specify the full context before the command (I’ll show you some examples later in this post).With these concepts in mind, the real key to using the VPLEX CLI is simply learning where all the various objects reside. For example, in an earlier post on VPLEX storage objects, I discussed the building blocks of storage in a VPLEX environment: storage volumes, extents, devices, and virtual volumes. These reside in different places in the VPLEX contextual tree:
Storage volumes:
/clusters/ /storage-elements/storage-volumes
Extents:
/clusters/ /storage-elements/extents
Devices:
/clusters/ /devices
Distributed devices:
/distributed-storage/distributed-devices
Virtual volumes:
/clusters/ /virtual-volumes
Within each of these contexts, you can use the
ls
andll
commands to view the contents of that context. Thehelp
command will show you what other commands are available in each context.Here’s my first example. When you first log into the VPLEX CLI, you’ll get dropped into a “root context”. Running
ls
here will produce output something like this:VPlexcli:/> ls
clusters data-migrations distributed-storage engines management-server
monitoring notifications system-defaults
Let’s take a look at a few more examples. For example, the following two sets of commands will produce the same output:
cd /clusters
ll
and
ll /clusters
Remember that specifying the context in the command is the same as changing into that context and then running the command. That is why these two commands produce the same output.
To view the list of directors in a cluster:
ll /engines/*/directors
This is an example of using the asterisk to represent a wildcard that matches all entries in that context.
Let’s look at another example of two different commands that produce the same output. To view the status of the ports on a particular director in a cluster, you could use either of these two commands:
ll /engines/ /directors/ /hardware/ports
or
cd /engines/ /directors/ /hardware/ports
ll
By the way, if you haven’t figured it out yet, you can easily get the names of the engines (or the directors) by simply running the
ll
command against theengines
context or thedirectors
context within a specific engine.But what if you wanted to see the status of the ports across multiple directors? Now you won’t want to use the
cd
command. You’ll want to use globbing with wildcards instead, like this:ll /engines/**/ports
While the single asterisk matches anything within a context, the double asterisk matches across multiple contexts. So, in this case, it ends up matching multiple engines and directors within those engines.
And if you wanted to see only some of the front-end ports on all directors:
ls /engines/**/hardware/ports/*1-FC0[0-3]
In some cases, you might need to set an attribute on an object within a context. For example, you might need to enable a port by setting the enabled attribute on that port to True. Here’s how you would do that:
set /engines/ /directors/ /hardware/ports/A0-FC00::enabled true
If you think about it, you could easily combine some globbing to enable multiple ports at the same time:
set /engines/**/hardware/ports/A0-FC0[0-3]::enabled true
You can then verify the operation by using the
-t
parameter to thels
command, which instructs it to include attributes:ls -t /engines/**/hardware/ports/A0-FC0[0-3]::enabled
There are many, many more examples I could share with you, but this should get you started for now. I hope to have a post up soon with a CLI guide to setting up storage volumes, extents, devices, and virtual volumes.
As usual, feel free to speak up in the comments if you have any questions or clarifications. Thank you!
Tags: CLI, EMC, Storage, VPLEX
4 comments
Comments feed for this article
Trackback link: http://blog.scottlowe.org/2010/12/22/an-introduction-to-the-vplex-cli/trackback/
kdossjojo on Thursday, June 30, 2011 at 9:45 am
Lovely – Just what I was looking for. Carry on with your good work. This I am sure will definitely help a lot of people like me – around the world. Thanks.
Is there any way to script the VPLEXCLI? Looking at the CLI PDF it appears that you have to SSH to the management server, then issue the vplexcli command which then prompts for another username/password set.
This looks to make scripting of claims and provisioning difficult.
To my knowledge, there is no way to script the CLI. In version 5 of the VPLEX software (called GeoSynchrony), there is an HTTP REST API, in case you’re interested.
I was also looking for a way to script in the vplexcli and found that Expect is installed on the management console. So this Expect script should help (just replace the string “password_for_service” with the correct password for the service account (or any account you would want to use):
——-
service@TCP-Vplex-MGMT:~> cat vplexcl
#!/usr/bin/expect
set cmd [lindex $argv 0]
spawn telnet localhost 49500
expect “Enter User Name:”
send — “service\r”
expect “Password:”
send — “password_for_service\r”
expect “VPlexcli:/>”
send “$cmd\r”
expect “VPlexcli:/>”
send — “exit\r”
expect “TCP-Vplex-MGMT”
service@TCP-Vplex-MGMT:~>
service@TCP-Vplex-MGMT:~> cd
service@TCP-Vplex-MGMT:~> cat ./vplexcl
#!/usr/bin/expect
set cmd [lindex $argv 0]
spawn telnet localhost 49500
expect “Enter User Name:”
send — “service\r”
expect “Password:”
send — “Mi@Dim7T\r”
expect “VPlexcli:/>”
send “$cmd\r”
expect “VPlexcli:/>”
send — “exit\r”
expect “TCP-Vplex-MGMT”
——
Then you can write scripts that use the expect script like this example.
/home/service/vplexcl “ls /clusters”
Then use awk, perl, or your favorite command line utility to scrape out the information you need.
Or if you want to run the script from another host, you can set-up ssh keys to the service account (or any named account) and run them that way.
The only caveat is that the password is stored in the expect script. However this is only exposed on the vplex management console, which is already password (or ssh-key) protected anyway.
Kennedy_Doss
79 Posts
0
June 20th, 2012 10:00
And take a look at this example:
https://community.emc.com/thread/128550
GMax1
3 Posts
0
June 20th, 2012 23:00
Hi Kennedy and all,
Thanks for your replies.
I tried the Expect script and it works fine![](https://prod-care-community-cdn.sprinklr.com/community/687062f5-603c-4f5f-ab9d-31aa7cacb376/ReHowscriptVplexcli-d3cea6f7-ea8f-4ea3-b501-faaab0fe59c3-1158604285)
For massive provisioning operations it's not probably the better way (using a sequence of statements copied and pasted from an editor is maybe preferrable) since it needs to open/close a single session for each command(s), but it's something really useful when you need to schedule commands at certain times submitting cronjobs.
In order to get information from Vplex I find curl a quite good solution![](https://prod-care-community-cdn.sprinklr.com/community/687062f5-603c-4f5f-ab9d-31aa7cacb376/ReHowscriptVplexcli-8aa805e5-dc46-446f-9dc3-91bacece10ea-1158604285)
Thanks again
Regards
Gaetano
danmjoh
4 Posts
0
July 26th, 2012 01:00
Hi *,
I have also heard about the "REST API" for VPLEX and are interesten in testing it.
Does anyone know where I can find some documentation on the subject?
Regards,
--
Dan
Anonymous
5 Practitioner
5 Practitioner
•
274.2K Posts
0
July 26th, 2012 03:00
Hi,
RESTful API is officially known as VPLEX Element Manager API. You will find a section detailing how to use it at the end of VPLEX CLI Guide there is also sample code in the guide.
If you like to use Curl then you can follow the sample scripts to understand how to do the same with curl.
You can also try using the globing feature with this API.
Thanks
Farooq
danmjoh
4 Posts
0
July 26th, 2012 06:00
Great, Thanks.
That was what I was looking for.
Regards,
--
Dan
Andrew-F
27 Posts
0
July 26th, 2012 08:00
One thing to note is that the latest version of the CLI guide does not include information about the API. Please examine the v5.0.1 or v5.0 CLI guide found on Powerlink.
Ayrton_Senna1
62 Posts
0
August 4th, 2015 14:00
Can you provide instructions on how to setup ssh-key to service account from my solaris host? Please take a look at my question. https://community.emc.com/message/899324?et=watches.email.thread#899324