Tutorial

This page explains the procedures for using msh to control the SACM from a CUI.

Refer to operating conditions noted in the overview regarding msh operating conditions.

Install and setting

Install

msh is installed using gem, a typical package management system in Ruby. You can install using any of the following methods.

acquire (create) gem package

You can acquire a gem package via any of the following methods.

  1. Download a pre-built gem package

wget http://dev.smf.jp/dl/msh-0.5.1.gem
  1. Acquire source from github and build a package

$ git clone git://github.com/seil-smf/msh.git
$ cd msh
$ gem build msh.gemspec

Installing a gem package

Execute the following command from the directory containing the acquired msh gem package.

$ gem install msh

Note

When installing the gem package to the system, you may need root rights depending on the Ruby execution environment.

Confirming installation

$ gem list msh
*** LOCAL GEMS ***

msh (*.*.*)
$

If installed the version displayed

This concludes msh installation procedures. Next is an explanation of configuration files required to run msh.

msh configuration file description

msh configuration file overview

To run msh, you must describe a configuration file that includes an API access key and other settings. The configuration file is saved in “~/.msh/mshrc”.

Required settings information is as follows.

Settings

Description

access_key

Access key for API execution

access_key_secret

Password for API execution

domain

Domain of the API resource

path

Path of the API resource

user_code

Management code

proxy_addr

IP address of the proxy server

proxy_port

Port number of the proxy server

ssl_verify

Whether or not to conduct certificate validation

Configuration information confirmation method

  • access_key, access_key_secret

    The API access key is acquired from the SACM Control Panel.

    How to obtain an API access key

  • domain

    Domain of URL used to login to the OEM control panel. (Ex.: [OEM name].sacm.jp)

  • path

    Currently, this is “/public-api/v1” for all OEMs. This may be updated in the future if the API version changes.

  • proxy_addr, proxy_port

    If the host running msh accesses the internet via a proxy, you must specify the address and port number of the proxy server. Settings are not required if a proxy server is not used(the config line itself must not be written).

  • ssl_verify

    SSL Verify should normally be set to true.

msh configuration file format

$ vi ~/.msh/mshrc
access_key: access_key_string
access_key_secret: access_key_secret_string
domain: demo.sacm.jp
path: /public-api/v1
user_code: tsa********
proxy_addr: proxy.****.jp
proxy_port: 8081
ssl_verify: true

Switch msh configuration file

msh includes a command (set mshrc) for switching configuration files. Using the set mshrc command allows you to reflect msh environment variables on the configuration file. To use this function, you must save a mshrc.* file below “~/.msh/”. (There are no filename restrictions as long as the filename prefix is “mshrc.”)

Basic msh execution method

Interactive mode

After installing with the gem command, the interactive execution environment is launched by executing an msh command from the shell.

$ msh

When msh launches, the following prompt is displayed and the status switches to read for input.

msh(tsa********)>

Inputting a command while in this status allows you to use SACM functions from the command line.

Execute the help command to display a list of executable commands in msh.

msh(tsa********)> help

Input the name of the command into the help command to display more detailed help information

msh(tsa********)> help ping
  help ping

  Name :
    ping - ping command

  SYNOPSIS:
    $ ping <SA Code> <IPAddress> [size <Size>] [count <Count>] [targettime <Target Time>]

msh(tsa********)>

Next, execute the test command to confirm that the test API is executable and that the SACM API is in a state that can be used from the msh. There is no problem with msh host and SACM connectivity if the following output is displayed. Confirm settings if some fields are shown as Failed.

msh(tsa********)> test
GET Test is Successed.
POST Test is Successed.
PUT Test is Successed.
DELETE Test is Successed.
msh(tsa********)>

Input Ctrl+C during execution of a command to cancel execution of the command. To exit interactive mode for msh while it is running, input Ctrl+D at a prompt ready for command input to exit the msh process. You also can close msh by using the exit command or the quit command.

Similar to a normal bash shell, msh allows use of the emacs key bind and command history function. For example, you can search commands from the history by using Ctrl + R or Ctrl + I to display or complete input candidates.

msh(tsa********)> p(Tab key)
msh(tsa********)> ping

Non-interactive mode

You can execute msh commands specified in the argument by delivering an argument to a msh command via bash, zsh, or other unix shell and executing it. The above-mentioned test command can be executed using the following input.

$ msh test

Operation command execution

To use operation commands from msh, the service adaptor that will execute the operation task must be managed by the SACM. Refer to the SACM manual regarding procedures for registering a service adaptor in the SACM.

msh operation commands use the SACM API function of the same name. In general, tasks are registered for immediate execution. The targettime option can be used to specify the execution schedule date/time but in such cases only the registration results are shown and operation task results are not shown.

This tutorial uses the ping command to confirm connectivity and the md-command to execute an md-command on the service adaptor.

  • ping command

    The ping command format is as follows.

msh(tsa********)> ping <SA Code> <IPAddress> [size <Size>] [count <Count>] [targettime <Target Time>]

The ping execution example is as follows. The msh ping command registers a ping task in the SACM and displays operation result.

msh(tsa********)> ping tsw11111111 127.0.0.1
..

5 packets transmitted, 5 packets received, 0.0% packet loss
msh(tsa********)>
  • md-command command

    The md-command command format is as follows.

msh(tsa********)> md-command <SA Code> <Module ID> <Command> [targettime <Target Time>]

The md-command execution example is as follows. Ping command execution using the md-command executes the ping command included in the service adaptor and not the SACM ping task. If count, etc., are not set appropriately this could result in a timeout or the service adaptor becoming inoperable for a long period of time.

msh(tsa********)> md-command tsw00000000 0 ping 127.0.0.1 count 3
.

PING localhost (127.0.0.1): 44 data bytes
56 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.202 ms
56 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.188 ms
56 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.169 ms

----localhost PING Statistics----
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.169/0.187/0.202/0.017 ms
msh(tsa********>

This concludes the tutorial.