[PYTHON] Introduction of SoftLayer Command Line Interface environment

1.First of all

The main API provided by SoftLayer has many function calls (API Ver3.0: services over 180, 2200 function calls), and most of the functions provided by the portal can be programmed using the API. With this, you can create your own portal and automate operation operations. For example, various uses such as creation, deletion, and modification of instances (servers), operation and maintenance can be assembled according to unique rules. Languages support C #, Perl, PHP, Python, Ruby, VB .Net, and REST, SOAP & XML-RPC interfaces.

Fortunately, a "Command Line Interface" is also provided, so if you incorporate it into a shell program, you can use various functions without programming using the API.

Then, the next problem is that the "Command Line Interface" is written in Python, so we have to create a Python environment. If you're familiar with Python, it's easy to get started, but since I only knew the name Python, I started by finding out what to do.

The client PC system environment uses Windows 7 (32bit).

2. Outline of introduction steps

(1) Obtain the API Key from the user list (Users) on the portal screen. (2) There are Python 2 series and Python 3 series, but this time we introduced 2 series Python 2.7.6. ③ Use wget when introducing the Python tool in the next step (④). (4) Introduction of ez_setup / pip, a tool often used in Python. ⑤ Introduce SoftLayer package with pip. ⑥ Set user ID and API Key. Fig01.jpg

3. Introduction

3-①. Get API Key API Key is a unique alphanumeric identifier that allows users to access using the API "Command Line Interface" uses SoftLayer API, so API Key is required.

-API Key is set and obtained from the "Account" ⇒ "Users" user list on the portal screen. -Click the "Generate" link to the right of the user line to get the API Key. -After a while, it changed from "Generate" to "View" and the API Key was created. -Click the "View" link to display the created API Key.

3-②. Python introduction

We will explain the installation and environment settings so that Python can be used in a Windows 7 (32bit) environment. There are Python 2 series and Python 3 series, but here we will introduce the latest Python 2.7.6 in 2 series.

3-②-1. Download Python 2.7.6

-Download the Python 2.7.6 Windows installer from the http://www.python.org/ site. Click "Quick Links (2.7.6)" ⇒ "Windows Installer" to start downloading.

3-②-2. Python 2.7.6 setup

-Double-click the downloaded "python-2.7.6.msi" to start the installer.

3-②-3. Setting Python environment variables

-"Python.exe" is the execution module. Since it was installed by default, you can see that the installation folder is "c: \ Python27" and "Python.exe" is in it. Pass the environment variable Path through this folder. If you have changed the installation folder, pass the Path to the folder containing "Python.exe".

3-②-4. Confirmation of Python introduction

-Check at the command prompt whether Python has been installed successfully. Type "Python" and press Enter.

If successfully installed, Python's interactive shell will be launched. If the prompt ">>>" is displayed after the version information, the installation is successful. Press the "Ctrl" and "z" buttons and press Enter to exit the interactive shell. When the command prompt appears, click "Exit" to exit.

3-③. Introducing wget

The next step is to introduce the Python tools. Use the wget command to introduce Python tools. Linux is provided as standard as a command, but unfortunately it is not provided as standard on Windows, so download and install it.

3-③-1. wget download

・ Http://gnuwin32.sourceforge.net/packages/wget.htm Download the two files "wget-1.11.4-1-dep.zip" and "wget-1.11.4-1-bin.zip" from the site. You can download it from the following location in the Download section. ・ Binaries Zip ---- "wget-1.11.4-1-bin.zip" ・ Dependencies Zip ----- "wget-1.11.4-1-dep.zip"

3-③-2. Unzip the download file

-Create a C: \ wget_tool folder and unzip the two downloaded files. You can unzip the two Zip files and then delete them.

3-③-3. Rename folder

wget-1.11.4-1-bin renamed the folder to wget

3-③-4. DLL copy

Copy the four dlls from C: \ wget_tool \ wget-1.11.4-1-dep \ bin to C: \ wget_tool \ wget \ bin

3-③-5. Setting wget environment variables

-Select "Variable name Path" from "System environment variables" and click the "Edit" button.

-Add "; C: \ wget_tool \ wget \ bin" to the end of "Variable value" and click the "OK" button.

3-③-6. Confirmation of wget installation

-Check at the command prompt whether Python has been installed successfully. Type wget and press Enter.

3-④. Python tool introduction

Later, we will install the SoftLayer package, but pip is required for its installation, and setuptools is required to use pip. Here, we will install setuptools and pip using wget. As a prerequisite, you need Python and wget.

3-④-1. Installation of setuptools

It's easy to deploy. -Enter the following command at the command prompt.

command


wget --no-check-certificate https://bitbucket.org/pypa/setuptools/raw/
bootstrap/ez_setup.py && Python ez_setup.py ⏎

3-④-2. Introducing pip

It's easy to deploy. -Enter the following command at the command prompt.

command


wget --no-check-certificate https://raw.github.com/pypa/pip/master/contrib/
get-pip.py && python get-pip.py  ⏎

3-⑤. Introduced SoftLayer package

Use Pip to deploy the SoftLayer package. Pip.exe is located in the Python installation directory \ Scripts, so change the directory. (Since this environment was introduced in c: \ Python27, it will be c: \ Python27 \ Scripts.)

-Enter the following command at the command prompt.

command


pip install softlayer  ⏎

3-⑥. Configuration setup

This is the final step in introducing the "Command Line Interface" environment. Here, start the installed SoftLayer package and register the user ID and API Key.

sl.exe is located in the Python installation directory \ Scripts, so change the directory. (Since this environment was introduced in c: \ Python27, it will be c: \ Python27 \ Scripts.)

-Enter the following command at the command prompt.

command


sl config setup  ⏎

-Enter your SoftLayer ID, password (or API Key), and EndPoint.

This completes the introduction of the "Command Line Interface" environment.

3-⑦. Confirmation of function

As an example, let's take a look at the list of currently running Cloud Computer Instances. The command is

command


sl cci list  ⏎

is. Fig02.jpg

4. Conclusion

To understand the many APIs provided by SoftLayer, it is easier to understand by entering from the "Command Line Interface".

Reference: http://sldn.softlayer.com/reference/overview http://www.softlayer.com/about/automation/open-api/ http://knowledgelayer.softlayer.com/topic/developmentapi http://sldn.softlayer.com/ https://softlayer-api-python-client.readthedocs.org/en/latest/

Recommended Posts

Introduction of SoftLayer Command Line Interface environment
Create another version of Python conda environment with one command line
Introduction of Python
Introduction of scikit-optimize
Introduction of PyGMT
Summary of tools used in Command Line vol.8
Summary of tools used in Command Line vol.5
The story of misreading the swap line of the top command
[Introduction to Udemy Python3 + Application] 67. Command line arguments
Introduction of cymel
Think about the selective interface on the command line
Introduction of Python
Used from the introduction of Node.js in WSL environment
Operate mongoDB from python in ubuntu environment ① Introduction of mongoDB
Open Chrome version of LINE from the command line [Linux]
Introduction of trac (Windows + trac 1.0.10)
Command line introductory notes
memorandum of vi command
Unification of Python environment
Introduction of ferenOS 1 (installation)
Introduction of Virtualenv wrapper
Linux command line shortcut
PyTorch introduction (virtual environment)
Allow brew install of command line tools made in Python
Procedure memo to put AWS command line interface in CentOS6