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).
(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.
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.
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.
-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.
-Double-click the downloaded "python-2.7.6.msi" to start the installer.
-"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".
-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.
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.
・ 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"
-Create a C: \ wget_tool folder and unzip the two downloaded files. You can unzip the two Zip files and then delete them.
wget-1.11.4-1-bin renamed the folder to wget
Copy the four dlls from C: \ wget_tool \ wget-1.11.4-1-dep \ bin to C: \ wget_tool \ wget \ bin
-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.
-Check at the command prompt whether Python has been installed successfully. Type wget and press Enter.
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.
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 ⏎
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 ⏎
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 ⏎
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.
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.
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