Below is a brief outline on installing EMC’s ECS CLI package. I have another blog post that outlines all of the ECSCLI commands here.
Getting Started
Prerequisites:
- Install Python 2.7.x from https://www.python.org/downloads/.
Install Python Requests Package:
- Versions of ECSCLI prior to 3.x may require a manual install of the python requests package. When I installed v3.1.9, the PIP install process appears to have taken care of installing the python requests package for me, but I saw reports of this issue while reading other documentation. Either way, you can manually install the requests package either by using “pip install requests” or downloading the code from GitHub and running “python setup.py install”.
Install ECSCLI using Python PIP:
- There are frequent updates and fixes being made to the ECSCLI package. The latest version of ECSCLI can always be downloaded and installed via pip using “pip install ecscli” from a windows command prompt. PIP will be in your system path once you’ve installed python so it can be run from any directory. If you want to archive a copy, use “pip download ecscli” rather than “pip install ecscli”. As an alternative, you can also find the ECSCLI install package available for download at EMC’s support site (v2 is available here).
ECS CLI PIP Installation and Configuration
You will need to set up a configuration profile once ECSCLI is installed. Configuration profiles address issues with older versions of the ECSCLI regarding authentication and python dependencies. A profile simply contains the hostname and port along with an existing management user who will be authenticating to that host. Several profiles can be created but only one can be active. Once the active profile is set, ECSCLI will then use that profile for authenticating and sending commands.
To install the ecscli via pip:
pip install ecscli
Collecting ecscli Downloading ecscli-2.2.0a5.tar.gz (241kB) 100% |████████████████████████████████| 245kB 568kB/s Requirement already satisfied (use --upgrade to upgrade): requests in ./anaconda/envs/ecscli_demoenv/lib/python2.7/site-packages (from ecscli) Building wheels for collected packages: ecscli Running setup.py bdist_wheel for ecscli ... done Stored in directory: /Users/conerj/Library/Caches/pip/wheels/92/7f/c3/129ffe5cd1b3b20506264398078bdd886c27fefe89b062b711 Successfully built ecscli Installing collected packages: ecscli Successfully installed ecscli-2.2.0a5
To see a list of profiles:
ecscli config list
Running without an acive config profile list of existing configuration profiles:
Since the ecscli was just installed, no profiles exist yet.
Once you have an active profile, the output will look like this:
Running with config profile: C:\python\ecscli/ecscliconfig_demouser_.json user: root host:port: 10.10.10.1:4443 list of existing configuration profiles: ACTIVE |PROFILE |HOSTNAME |PORT |MGMT USER |ECS VERSION ---------------------------------------------------------------- |demouser |10.10.10.1 |4443 |root |3.0
To create a profile:
ecscli config -pf demoprofile
Running without an acive config profile Please enter the default ECS hostname or ip (127.0.0.1):10.10.10.11 Please enter the default command port (4443): Please enter the default user for the profile (root): Entered saveConfig profileName = demoprofile will be saved to base path: /Users/demo_user/ecscliconfig_ Saving profile config to: /Users/demo_user/ecscliconfig_demoprofile_.json list of existing configuration profiles: * demoprofile2 - hostname:10.10.10.11:4443 user:root
Normally one profile will always be active. Because this is the first time a profile is being created, ECSCLI will run without an active profile. The CLI will prompt the user to enter the hostname, IP, port and management user for the profile. The “*” shows the active profile that will be used. Several profiles can be configured, however only one profile can be active at a time. The profiles are stored in .json files in the home directory with the name prefix “ecscliconfig_”.
To see a list of profiles and the active profile:
ecscli config list
Running with config profile: demoprofile user: demo_user host:port: 10.10.10.10:4443 list of existing configuration profiles: * demoprofile2 - hostname:10.10.10.11:4443 user:demouser demoprofile - hostname:10.10.10.10:4443 user:root
The currently active profile is denoted by “*” before the profile name.
To change the active profile:
ecscli config set -pf mydemoprofile
Running with config profile: demoprofile2 user: demo_user host:port: 10.10.10.11:4443 list of existing configuration profiles: demo_profile2 - hostname:10.10.10.11:4443 user:demouser demo_profile - hostname:10.10.10.10:4443 user:root
To delete a profile:
ecscli config delete -pf mydemoprofile
Running with config profile: demoprofile user: root host:port: 10.10.10.10:4443 list of existing configuration profiles: * demoprofile2 - hostname:10.10.10.11:4443 user:demouser
Since the currently active profile was deleted in this example, the ecscli chose another profile to set as the active profile.
Ecscli configuration handles the “–hostname” and “–port” arguments and manages the tokens for subsequent management requests. Authentication is still required. This as well as all other requests are simplified since cookie related arguments are no longer required.
To Authenticate:
ecscli authenticate
Running with config profile: demoprofile2 user: root host:port: 10.10.10.10:4443 Password : authentication result: root : Authenticated Successfully /Users/demo_user/demo_profile/rootcookie : Cookie saved successfully
Another sample command:
This command example will list the storage pools:
ecscli objectvpool list
Running with config profile: demo_rofile user: root host:port: 10.10.10.10:4443 {'global_data_vpool': [{'isAllowAllNamespaces': True, 'remote': None, 'name': 'lab_env', 'enable_rebalancing': True, 'global': None, 'creation_time': 1033186012844, 'isFullRep': False, 'vdc': None, 'inactive': False, 'varrayMappings': [{'name': 'urn:storageos:VirtualDataCenterData:823c6f4c-bda2-6ca2-69d7-110df3e9f022', 'value': 'urn:storageos:VirtualArray:19f03490-3f30-25dd-5f5c-8b208f64e3f0'}], 'id': 'urn:storageos:ReplicationGroupInfo:8066234b-bdc2-6234-f066-81f0aa61e7bf:global', 'description': ''}]}