Command line exercises
Now, explore several of the IBM Power Virtual Server (PowerVS) command-line interfaces (CLIs).
For this exercise, the IBM Cloud Shell is used. IBM Cloud Shell gives users complete control of their cloud resources, applications, and infrastructure, from any web browser. IBM Cloud Shell provides pre-authenticated access to tools and programming languages for cloud-based development, deployment, and management of services and applications. IBM Cloud Shell is instantly accessible from the IBM Cloud portal. The IBM command-line interface (CLI) along with all the IBM Cloud CLI plug-ins are preinstalled in IBM Cloud Shell, including the PowerVS CLIs.
It is also possible to install the IBM Cloud CLIs and PowerVS CLI plug-in on other systems, like personal desktop and development servers. Learn more about installing the PowerVS CLI locally here.
To get started, first open the IBM Cloud Shell from the IBM Cloud portal:
- Open the IBM Cloud Portal: https://cloud.ibm.com/ and authenticate with your IBM Cloud credentials.
-
Change to the 2305900 - ITZ - ADHOC03 account.
Tip
If the browser window is narrow, this icon: is seen instead of the current account name as shown in the preceding screen capture.
-
Click the IBM Cloud Shell icon .
The next steps are run in the IBM Cloud Shell window that was opened.
To avoid typographical errors copy the command line by using the icon when it is available. Then paste the contents into the IBM Cloud Shell by using Ctrl+v, Cmd+v (may be operating system dependent), or right click and select paste at the prompt in the IBM Cloud Shell.
-
Display all the PowerVS plug-in command-line options.
Tip for novice Linux users!
If you are not familiar with Linux commands, don't worry. The preceding command is two commands. The first is
ibmcloud pi --help
. This command runs the help option of the PowerVS plug-in. The second command ismore
. This command pauses the output being displayed. The "|" or pipe character takes the output from the first command and sends it as input to the second command. Search the internet for Linux primer to learn more about Linux commands. -
Press the space bar to continue the output. Continue to press space bar several times to scroll through the complete output.
Notice the last part of the message: Enter 'ibmcloud pi [command] --help' for more information about a command. Use this to get more help on individual PowerVS plug-in commands.
-
List all the PowerVS workspaces provisioned in the account.
Sample output
To view the PowerVS instances in the workspace, the workspace target must first be set for the PowerVS plug-in.
-
Set the workspace target by using the instance ID of the workspace.
Tip for novice Linux users!
The last command did 5 actions. First, it listed the workspace list like in step 6 and redirected both the error and standard output to the standard output stream (2>&1). Next, the output is filtered (grep) to show the line for the PowerVS-L3-2024. Then the output from the grep command is sent to the cut command where all the output except the first field up to the first space character is ignored (-f -d' '). Finally, the output from the cut command was stored in an environment variable called workspaceID. Why? Because no one wants to type crn:v1:bluemix:public:power-iaas:wdc07:a/ba0e33c9056f470ca19de009747ec654:e7156c4d-eaf3-43e6-a972-a9782efa5e8d:: to run the next command.
-
Use the $workspaceID environment variable to set the target of future PowerVS plug-in commands to the workspace.
Sample output
-
List all the PowerVS instances provisioned in the targeted PowerVS workspace.
Sample output
-
View the details of the AIX-VM instance.
Sample output
Thus far, all of these commands are read commands. The PowerVS CLIs also support create and update commands, but remember user IDs have access restrictions in this shared environment. Try the instance update command and see what happens.
-
Recall that the Power environment consists of three PowerVM instances: AIX-VM, Linux-VM, and IBMi-VM. Up until now, commands were issued against AIX-VM. Given that the testing environment is primarily limited to read-only actions, try inspect one of the other VMs and determine what (if any) differences exist between the various instances.
Issue the following command to the IBM Cloud Shell:
And then issue a second command:
Notice that the two tables are nearly identical, but differences do exist due to the operating systems used on each VSI.
-
There are numerous reasons why one might want to generate an SSH private key for managing a PowerVS environment. In fact, that's exactly what the service's administrators did to authorize your access to the PowerVS instances. Recall when first connecting to the PowerVS virtual machines remotely through the IBM Cloud Shell with the supplied key information.
The IBM Cloud Shell can generate an SSH key that is configured for password-less authentication (in other words, allowing users to authenticate without needing to also supply a password). Using IBM Cloud Shell, or any Linux environment, run the following ssh-keygen command:
Sample output
Use the PowerVS CLIs to create a key for the instance by using an imported RSA public key. Specify the key pair that was generated as the source (newKey). Do so by using the following command. (Note: newKeyPOWER is the name of the CLI-generated key that is to be created; newKey is the SSH key generated earlier by using the IBM Cloud Shell).
SSH keys
The SSH key-pair generated and assigned by this step is specific to IBM Power Systems. These are distinct from ones generated previously by using the IBM Cloud Shell.
Sample output
As expected, the instruction fails to run because of insufficient (locked down) permissions within this demonstration environment. Next, experiment with other IBM Power CLIs.
-
Restart the Linux-VM instance.
Sample output
There are over 100 PowerVS CLIs. Explore more CLIs by using the ITZ environment. Remember, use ibmcloud pi --help
or ibmcloud pi <command> --help
to get detailed information on a command's usage.