Package: aliyuncli
OverviewAliyun Command Line Interfacealiyuncliis a unified tool to manage your Aliyun services. Using this tool you can easily invoke the Aliyun open API to control multiple Aliyun services from the command line and also automate them through scripts, for instance using the Bash shell or Python.Aliyuncli on GithubThealiyunclitool is on Github and anyone can fork the code, subject to the license. You can access it at:https://github.com/aliyun/aliyun-cliHow to Install aliyuncliAliyun provides two ways to install thealiyunclitool:Install using pipInstall from a software packageInstall aliyuncli Using pipIf you have Windows, Linux, or Mac OS and pip is installed in your operating system,
you can installaliyuncliusing pip:Windowspip install aliyuncliTo upgrade the existingaliyuncli, use the--upgradeoption:pip install --upgrade aliyuncliLinux, Mac OS and Unix$ sudo pip install aliyuncliTo upgrade the existingaliyuncli, use the--upgradeoption:$ pip install --upgrade aliyuncliInstall from a Software PackageIf you don’t have the pip tool, you can also installaliyunclifrom an Aliyun supplied software package.Aliyuncli supports several operating systems with the package:WindowsLinuxMac OS.You can find the software package for a free download at the following linkhttp://market.aliyun.com/products/53690006/cmgj000314.html?spm=5176.900004.4.2.esAaC2The package contains three install packages:cli.tar.gzis for Linux and Mac OSAliyunCLI_x86is for Windows 32 bit OSAliyunCLI_x64is for Windows 64 bit OSWindowsFindAliyunCLI.msiand double click the msi. You will go into the installation guide.Click the “next” button and choose your desired path and confirmFinish the installLinux and Mac OSInstall as follows:$ tar -zxvf cli.tar.gz
$ cd cli
$ sudo sh install.shCheck the aliyuncli InstallationConfirm thataliyuncliinstalled correctly by viewing the help file:$ aliyuncli helpor$ aliyuncliHow to Install the Aliyun Python SDKaliyunclirequires the Aliyun Python SDK 2.0.
You should install the SDK after you installaliyuncli, otherwise you can not access the Aliyun service.Install SDK Using pipThe Aliyun Python SDK can only be installed by pip.Since each Aliyun service has their own SDK,
you can install a required SDK individually with no need install all of them.For example, if you need only the ECS SDK, you can install only it as follows:$ sudo pip install aliyun-python-sdk-ecsIf you need only the RDS SDK:$ sudo pip install aliyun-python-sdk-rdsFor SLB:$ sudo pip install aliyun-python-sdk-slbSDK ListProductSDKBatchComputealiyun-python-sdk-batchcomputeBsnaliyun-python-sdk-bsnBssaliyun-python-sdk-bssCmsaliyun-python-sdk-cmsCrmaliyun-python-sdk-crmDrdsaliyun-python-sdk-drdsEcsaliyun-python-sdk-ecsEssaliyun-python-sdk-essFtaliyun-python-sdk-ftOcsaliyun-python-sdk-ocsOmsaliyun-python-sdk-omsOssAdminaliyun-python-sdk-ossadminRamaliyun-python-sdk-ramOcsaliyun-python-sdk-ocsRdsaliyun-python-sdk-rdsRiskaliyun-python-sdk-riskR-kvstorealiyun-python-r-kvstoreSlbaliyun-python-sdk-slbUbsmsaliyun-python-sdk-ubsmsYundunaliyun-python-sdk-yundunInstall SDK on no network environmentFind an internet accessible computer, access the Python Package Index pagehttps://pypi.python.org.Search SDK package name which listed in the above paragraph “SDK List” and download the file (tar.gz compressed file)Download aliyun-python-sdk-core file (a tar.gz compressed file) fromhttps://pypi.python.org/pypi/aliyun-python-sdk-core/Unzip the aliyun-python-sdk-core file and previously downloaded SDK file.Copy these unzipped folders to your aliyuncli installed environment.Open your terminal on your aliyuncli installed environment and go to these folders then execute “pip install .”  command. ( aliyun-python-sdk-core at first then other SDK )Install Python Environmentaliyunclimust run under Python.If you don’t have Python installed, install version 2.6 or 2.7 using one of the following methods. Version 3 is not supported at this time.On Windows or OS X, download the Python package for your operating system from python.org and run the installer.On Linux, OS X, or Unix, install Python using your distribution’s package manager.How to Configure aliyuncliBefore usingaliyuncliyou should create a AccessKey from your console. After login the Aliyun console you can click the like as follows:<insert method here>Then you can create the access key and access secret.Configure the aliyuncliAfter creating the access key and access secret, you may configure aliyuncli:$ aliyuncli configure
Aliyun Access Key ID [None]: <Your aliyun access key id>
Aliyun Access Key Secret [None]: <Your aliyun access key secret>
Default Region Id [None]: cn-hangzhou
Default output format [None]: tableAccess key and access secret are certificates invoking the Aliyun open API.
Region id is the region area of Aliyun ECS.
Output format choices aretableJSONtext.Table format sample:<sample>JSON format sample:<sample>Text format sample:<sample>How to Use aliyuncliAnaliyunclicommand has four parts:Name of the tool “aliyuncli”Service name, such as: ecs, rds, slb, otsAvailable operations for each serviceList of keys and values, with possible multiple keys and values. The values can be number, string, or JSON format.Here are some examples:$ aliyuncli rds DescribeDBInstances --PageSize 50
$ aliyuncli ecs DescribeRegions
$ aliyuncli rds DescribeDBInstanceAttribute --DBInstanceId xxxxxxAdditional Usage Information--filteraliyunclisupports a filter function. When any API is called, the data returned is JSON formatted by default.
The filter function can help the user manipulate the JSON formatted data more easily.Here are some examples:$ aliyuncli ecs DescribeRegions --output json --filter Regions.Region[0]
{
        "LocalName":"\u6df1\u5733"
        "RegionId": "cn-shenzhen"
}
$ aliyuncli ecs DescribeRegions --output json --filter Regions.Region[*].RegionId
[
"cn-shenzhen",
"cn-qingdao",
"cn-beijing",
"cn-hongkong",
"cn-hangzhou",
"us-west-1"
]
$ aliyuncli ecs DescribeRegions --output json --filter Regions.Region[3].RegionId
"cn-hongkong"Command CompletionOn Unix-like systems, thealiyuncliincludes a command-completion feature
that enables you to use theTABkey to complete a partially typed command.
This feature is not automatically installed, so you need to configure it manually.Configuring command completion requires two pieces of information:the name of the shell you are usingthe location ofaliyun_completerscript.Check Your ShellCurrentlyaliyunclisupports these shells:bashzsh.1. To find thealiyun_completer, you can use:$ which aliyun_completer
/usr/local/bin/aliyun_completerTo enable command completion:bash - use the build-in command complete:$ complete -C ‘/usr/local/bin/aliyun_completer’ aliyunclizsh - source bin/aliyun_zsh_completer.sh% source /usr/local/bin/aliyun_zsh_completer.shTest Command Completion$ aliyuncli s<TAB>
ecs     rds     slbThe services display the SDK(s) you installed.Finally, to ensure that completion continues to work after a reboot,
add a configuration command to enable command completion to your shell profile.$ vim ~/.bash_profileAddcomplete-C‘/usr/local/bin/aliyun_completer’ aliyuncliat the end of the file.