This article describes the installation of a command-line tool to control Morpheus via its API.  A simple example of rebooting a VM is demonstrated.

Step-by-step guide

As a root user, please follow the below steps,

1. Fetch GPG Keys:

# curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import -

2. Download and install Ruby on Rails:

# curl -sSL https://get.rvm.io | bash -s stable --rails

3. Source the environmental variables and install the morpheus-cli gem:

# source /usr/local/rvm/scripts/rvm

# gem install morpheus-cli

4. Run the following commands to log-in as your Morpheus User:

# morpheus remote add

 Name: EUM HCMP

 URL: https://hcmp.icsi.eumetsat.int

 Added remote EUM HCMP

 Inspecting remote appliance https://hcmp.icsi.eumetsat.int ...

 Status is: READY

 Would you like to login now? (yes/no) [yes]: yes

 Enter Morpheus Credentials for EUM HCMP - https://hcmp.icsi.eumetsat.int

 Username: | USERNAME

 Password: | PASSWORD

 Success! Logged in to EUM HCMP as USERNAME.

5. Later on, the user can log in using the following command:

# morpheus login -r 'EUM HCMP' -u 'USERNAME' -p 'PASSWORD'

6. Run the following to restart a VM:

# morpheus instances restart testvm -y

Restarting instance testvm

# morpheus instances get testvm

Instance Details

==================
ID: 5103
Name: testvm
Description:
Group: VIOGRP
Cloud: GPD
Type: Centos ECMWF
Layout: Centos-ECMWF-RAW
Version: Centos-ECMWF-RAW
Plan: s2.medium.1
Environment:
Tags:
Metadata:
Power Schedule:
Created By: ezzat
Date Created: 02/11/20 10:53 AM
Nodes: 1
Connection: 192.168.0.124:
Status: RESTARTING

Instance Usage
---------------------
CPU:[|                                                 ]  0.65%

Memory: [||||||||||||                                      ] 23.58%     228.10 MiB / 967.37 MiB

Storage: [||||||||||                                        ] 18.71%       1.87 GiB / 10.00 GiB

Please find the complete CLI documentation here: https://github.com/gomorpheus/morpheus-cli/wiki/CLI-Manual