Edit this page

SONM CLI Guide

  • help - Help about any command
  • approve - approve Approve tokens (ERC20)
  • deals - Manage deals
  • hub - Hub management
    • acl - Hub acl Worker ACL management
      • list - Show current ACLs
      • deregister - Deregisters a worker credentials
      • register - Deregisters a worker credentials
    • ask-plan - Operations with ask order plan
      • create - Create new plan
      • list - Show current ask plans
      • remove - Remove plan by ID
    • dev - Device properties
      • list - Show Hub's aggregated hardware
      • set - Set Device properties
      • get - Get Device properties
    • status - Show hub status
    • task - Operations with tasks
    • worker - Operations with connected Workersmanagement
      • list - Show connected workers list
      • status - Show worker status
  • login - Open or generate Etherum keys
  • market - Interact with Marketplace
    • create - Place new Bid order on Marketplace
    • processing - Show processing orders
    • search - Search for orders on Marketplace
    • show - Show order details
    • cancel - Cancel order on Marketplace
  • tasks - Manage tasks
    • list - Show active tasks
    • push - Push an image from the filesystem
    • start - Start task
    • status - Show task status
    • logs - Retrieve task logs
    • stop - Stop task
    • pull - Pull committed image from the completed task.
  • version - Show version

Help

Usage: 
    sonm [command]..[command] <parameters> [flags]

Run sonmcli and you'll see the help:

Usage:
    sonmcli [command]

Available Commands:
    approve approve Approve tokens (ERC20)
    deals Manage deals
    help Help about any command
    hub Hub management
    login Open or generate Etherum keys
    market Interact with Marketplace
    tasks Manage tasks
    version Show version

Approve

Only Consumer may use the < sonmcli approve > command.

The approve command sets the limit allowance to the SONM smart contract to take Consumer's SNM test tokens for a deal(s). If the Consumer didn't set allowance, the deal can not be concluded. You may set allowance before each deal, or set it once for all the time.

Usage: 
   sonmcli approve <amount>

The < amount > argument is a quantity of SNM test tokens you want to allow the SONM smart contract to take from your Ethereum address (Rinkeby for MVP).

NOTE: The <amount> value is SNMT*10^18, where SMNT is an integer value of your SNM test tokens you willing to approve. For example: 10 SNMT = 10000000000000000000.

NOTE: The allowance may exceed your SNMT balance (i.e. you may have 100 SNMT but set allowance = 10 000 SNMT).

NOTE: You must have some amount of test Ether coins on your Rinkeby testnet address to perform the sonmcli approve command, as it's a blockchain operation and it costs some Gas.

Deals

Deals is a group of commands to operate deals on SONM platform.

Usage: sonmcli deals [command]

Available Commands:
    finish finish deal
    list Show my deals
    status show deal status

Deals list

Usage: 
   sonmcli deals list

Command output example:

ID: 20
Price: 10000000000000000000
Status: CLOSED
Buyer: 0xedB7Ae4B946Cf249349974A02e354B5FBC577798
Supplier: 0xedB7Ae4B946Cf249349974A02e354B5FBC577798
Start at: 2017-12-18T18:23:24+03:00
End at: 2017-12-18T18:23:24+03:00

ID: 21
Price: 100000000000000000000
Status: ACCEPTED
Buyer: 0xedB7Ae4B946Cf249349974A02e354B5FBC577798
Supplier: 0xedB7Ae4B946Cf249349974A02e354B5FBC577798
Start at: 2017-12-18T19:12:09+03:00
End at: 2017-12-18T19:12:09+03:00

Deals status

Use this command if you want to know deal's details, and you know dial ID. Even if that's not your deal.

Usage: 
    sonmcli deals status <deal_ID>

Command output example:

ID: 21
Price: 100000000000000000000
Status: ACCEPTED
Buyer: 0xedB7Ae4B946Cf249349974A02e354B5FBC577798
Supplier: 0xedB7Ae4B946Cf249349974A02e354B5FBC577798
Start at: 2017-12-18T19:12:09+03:00
End at: 2017-12-18T19:12:09+03:00

Deals finish

The command allows to finish the deal manually.

Usage: 
    sonmcli deals finish <deal_ID>

Hub

Hub is a group of commands for hub management. You may use it if you are interacting with the SONM platform as a computational resource supplier.

Usage:
   sonmcli hub [command]

Available Commands:
    acl Worker ACL management
    ask-plan Operations with ask order plan
    dev Device properties
    status Show hub status
    task Operations with tasks
    worker Operations with connected Workers

Hub ACL

The group of commands to operate the Hub's ACL (Access Control List).

SONM Hub's ACL contains the list of Ethereum addresses of it's workers (SONM Worker nodes attached to the Hub).

Usage:
    sonmcli hub acl [command]

Available Commands:
    deregister Deregisters a worker credentials
    list Show current ACLs
    register Deregisters a worker credentials

ACL list

The command shows the Hub's ACL content.

Usage:
    sonmcli hub acl list

Command output example:

   [email protected]:~$ sonmcli hub acl list
   1) 0xedB7Ae4B946Cf249349974A02e354B5FBC577798

ACL deregister

The command allows to manually deregister SONM Worker from the Hub.

Usage: 
    sonm hub acl deregister <worker_id>

< worker_id > is the Ethereum address of the SONM worker node.

ACL register

The command allows to manually register SONM Worker on the Hub.

Usage:
    sonmcli hub acl register <worker_id>

< worker_id > is the Ethereum address of the SONM worker node.

NOTE: If you, as a supplier of computational resources, has your own SONM Hub and Worker(s), you should use the same keystore (Ethereum address) for both Hub and Worker(s). In that case, you have no need to register Worker on Hub's ACL manually.

Hub ask-plan

The group of commands to operate the ask-order plans.

Supplier must determine his resources provided in the ask-plan. Hub will automatically create "ASK" orders on the Marketplace according to the ask-plan.

Hub removes "ASK" order from the Marketplace when deal is accepted, and publishes it again when deal is closed.

Usage:
    sonmcli hub ask-plan [command]

Available Commands:
    create Create new plan
    list Show current ask plans
    remove Remove plan by ID

Ask-plan create

The command to create ask-plan.

Usage:
    sonmcli hub ask-plan create <price> <slot.yaml>

Where:

  • < price > - the price in SNMT tokens per second. I.e. deal cost with 1 hour duration and price 1 SNM = 1 x 60 x 60 = 3600 SNM
  • < slot.yaml > - configuration file for your slot of resources (see example on GitHub or in the SONM MVP distribution archive for Supplier).

The command output gives the ID of ask-plan created.

Ask-plan list

The command allows to view your ask-plans list.

Usage:
    sonmcli hub ask-plan list

Command output example:

ID: 3125d466-b6d2-47bc-8fce-578b0aad1de0 CPU: 1 Cores
GPU: 0 Devices
RAM: 953.7 MB
Net: NO_NETWORK
   0 B IN
   0 B OUT

Ask-plan remove

The command to remove ask-plan by ID.

Usage:
    sonmcli hub ask-plan remove <order_id>

Hub dev

This is a group of commands to operate device properties controlled by the hub. Device list shows an aggregated pool of all devices from SONM Workers connected to Hub (CPUs and GPUs). If the Worker has several CPUs or GPUs, there will be corresponding number of rows in the list.

Usage:
    sonmcli hub dev [command]

Available Commands:
    get Get Device properties
    list Show Hub's aggregated hardware
    set Set Device properties

NOTE: In current MVP release you may view the list of devices and operate it's properties, but these properties are not taken into account when making deals.

Dev list

Usage: 
   sonmcli hub dev list

Command output example:

[email protected]:~$ sonmcli hub dev list

CPUs:
e8baacdb927faa99a1083f51d13290b8: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
514f08ed33f864f865d805d335d1b7ce: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
No GPUs detected.

Dev set

You may set any device properties (for example, CPU benchmark test result).

Usage:
   sonmcli hub dev set <dev_id> <props.yaml>

Each property is a key-value setting. You can make a file with device properties and apply it to any device in the list by ID.

Example of the file <props.yaml> body:

foo = 123.000000

bar = 909090.000000

Then you should apply the properties to the device:

[email protected]:~$ sonmcli hub dev set e8baacdb927faa99a1083f51d13290b8 props.yaml

OK

Dev get

Use the command to view device current properties.

Usage:
   sonmcli hub dev get <dev_id>

Where <dev_id> is an ID of device from the <sonmcli hub dev list> command output.

Example:

[email protected]:~$ sonmcli hub dev get e8baacdb927faa99a1083f51d13290b8

foo = 123.000000
bar = 909090.00

Hub status

The command allows to inspect the Hub status

Usage:
   sonmcli hub status

Example:

[email protected]:~$ sonmcli hub status

Connected miners: 1
Uptime: 52m55s
Version: v0.2.1.1-784729e linux/amd64/go1.9.2
Eth address: 0xedB7Ae4B946Cf249349974A02e354B5FBC577798

Hub task

The group of commands for Supplier to inspect tasks.

Usage:
    sonmcli hub task [command]

Available Commands:
    list Show task list
    status Show task status

Task list

The command shows Hub's workers and it's current tasks.

 Usage:
     sonmcli hub task list

Example:

[email protected]:~$ sonmcli hub task list

Worker "4c0be87c-ad99-4bf3-bb8f-82cd1951f02d":
1) 614ab8dd-25cd-4a02-9d66-3d9ce9241675
RUNNING httpd:latest (up: 1.549338385s)

Task status

The command shows task status.

Usage:
   sonmcli hub task status <task_id>

<task_id> is an ID of task from the <sonmcli hub task list> command output.

Example:

[email protected]:~$ sonmcli hub task status 614ab8dd-25cd-4a02-9d66-3d9ce9241675

Task 614ab8dd-25cd-4a02-9d66-3d9ce9241675 (on 4c0be87c-ad99-4bf3-bb8f-82cd1951f02d):
Image: httpd:latest
Status: RUNNING
Uptime: 24.595880434s
Resources:
CPU: 61453807
MEM: 11.8 MB
NET:
eth0:
Tx/Rx bytes: 0/3944
Tx/Rx packets: 0/35
Tx/Rx errors: 0/0
Tx/Rx dropped: 0/0
Ports:
80/tcp: 0.0.0.0:32768

Hub worker

The group of commands to inspect SONM Workers connected to the Hub.

Usage:
    sonmcli hub worker [command]

Available Commands:
    list Show connected workers list
    status Show worker status

Worker list

The command shows the list of workers attached to the hub.

Usage:
   sonmcli hub worker list

Output example:

[email protected]:~$ sonmcli hub worker list

Worker: 4c0be87c-ad99-4bf3-bb8f-82cd1951f02d 1 active task(s)

Worker status

The command shows worker startus.

Usage:
    sonmcli hub worker status <worker_id>

where <worker_id> is an ID of the SONM Worker node from the <sonmcli hub worker list> command output.

Example:

[email protected]:~$ sonmcli hub worker status 4c0be87c-ad99-4bf3-bb8f-82cd1951f02d

Worker "4c0be87c-ad99-4bf3-bb8f-82cd1951f02d":
Hardware:
CPU0: 1 x Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
CPU1: 1 x Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
GPU: None
RAM:
Total: 3.0 GB
Used: 2.6 GB
Tasks:
1) 614ab8dd-25cd-4a02-9d66-3d9ce9241675

Login

The <sonmcli login> command allows to open or generate a new Ethereum key.

Usage:
   sonmcli login

If you don't have an Ethereum key file (UTC/JSON) in the keystore, it will be created. You'll be asked for encryption pass-phrase.

Example:

[email protected]:~/keys$ sonmcli login

Using /home/sonm/keys as KeyStore directory
Key passphrase: 
Keystore successfully created
Eth address: 0x9982eCB1211aE239CC2c1c7A35d65f5f1280b8bA

If you already have an Ethereum key file in keystore directory, the command <somncli login> allows to open the keyfile.

[email protected]:~$ sonmcli login

Using /home/sonm/keys as KeyStore directory
Key passphrase:
Keystore successfully opened
Eth address: 0x9982eCB1211aE239CC2c1c7A35d65f5f1280b8bA

Market

This is the group of commands to interact with SONM Marketplace.

Usage:
    sonmcli market [command]

Available Commands:
    cancel Cancel order on Marketplace
    create Place new Bid order on Marketplace
    processing Show processing orders
    search Search for orders on Marketplace
    show Show order details

Market create

The command allows the Consumer to add new BID order to the SONM Marketplace.

Usage:
   sonmcli market create <price> <slot.yaml>
  • < slot.yaml > is the name of the configuration file with slot specification (see example on GitHub).
  • < price > - the price in SNMT tokens per second. I.e. deal cost with 1 hour duration and price 1 SNM = 1 x 60 x 60 = 3600 SNM

Command output gives the ID of BID order created.

Market processing

The command shows to the SONM Consumer his processing orders.

Usage:
   sonmcli market processing

Example:

[email protected]:~/Downloads$ sonmcli market processing
2017-12-20 12:03:53 +0300 MSK c268de0d-d2e8-4043-af32-0f51a1889a80 Done deal ID: 21

Market search

The command allows to search orders on the SONM Marketplace with characteristics specified in configuration file. The command is available both for Consumer and Supplier.

Usage:
   sonmcli market search <slot.yaml> [--flags]

Flags:
   -h, --help      help for search
   --limit uint    Orders count to show (default 10)
   --type string   Orders type to search: BID or ASK (default "BID")

<slot.yaml> is the name of the configuration file with slot specification (see example on GitHub or in the SONM MVP distribution archive for Consumer or Supplier).

Example:

[email protected]:~$ sonmcli market search slot.yaml
1) BID 39b086a5-b558-4ca5-a7c4-5d1f7b8dffc5 | price = 320000000000000000000
2) BID 79a5e5cf-cb4b-4f5c-9203-2474c5c14c39 | price = 500000000000000000000
3) BID 72c71c87-4834-44db-a468-512d767ef07c | price = 100000000000000000000
4) BID c23f3db0-fbf2-4dd7-9839-2650360e5b50 | price = 250000000000000000000    
6) BID cdabe366-0217-421b-ba7f-d36290f24ddf | price = 100000000000000000000    

Market show

The command shows order specifications by order ID.

Usage:
   sonmcli market show <order_id>

Example:

[email protected]:~$ sonmcli market show 4aedfe30-92df-44f4-96c5-8a81450f9d37
ID: 4aedfe30-92df-44f4-96c5-8a81450f9d37
Type: ASK
Price: 99000000000000000000
SupplierID: 0xFd0C80ba15CbF19770319E5E76Ae05012314608F
SupplierRating: 33
BuyerID:
BuyerRating: 22
Resources:
CPU: 1
GPU: 0
RAM: 95.4 MB
Storage: 190.7 MB
Network: INCOMING
In: 9.8 KB
Out: 19.5 KB

Market cancel

The command allows to cancel the order manually by order ID.

NOTE: If deal is accepted, the SONM Hub (from Supplier side) and Client Node (from Consumer side) are canceling their orders on Marketplace automatically.

Usage:
   sonmcli market cancel <order_id>

Example:

[email protected]:~$ sonmcli market cancel 4aedfe30-92df-44f4-96c5-8a81450f9d37
OK

Tasks

The <sonmcli tasks> group of commands allow the Consumer to manage tasks on leased resources.

Usage:
 sonmcli tasks [command]

Available Commands:
 list Show active tasks
 logs Retrieve task logs
 pull Pull committed image from the completed task.
 push Push an image from the filesystem
 start Start task
 status Show task status
 stop Stop task

Tasks list

Command shows the list of current tasks.

Usage:
   sonmcli tasks list

Example:

[email protected]:~$ sonmcli tasks list
Worker "4c0be87c-ad99-4bf3-bb8f-82cd1951f02d":
1) 614ab8dd-25cd-4a02-9d66-3d9ce9241675
RUNNING httpd:latest (up: 2h43m53.89934591s)

Tasks push

The command allows to upload the specific Docker image from Consumer's PC to the leased Worker node. It may be useful when the image is not present on public Docker repository.

NOTE: In this MVP release you should use Docker images included to SONM testnet whitelist.

The only exception is to try both Consumer and Supplier roles (i.e. you must have the same Ethereum address for Consumer's Client node and Supplier's Hub to be able to use your own Docker images).

Usage:
    sonmcli tasks push <deal_id> <archive_path>

Tasks start

The command to start task onto the resources leased.

Usage:
   sonmcli tasks start <deal_id> <task.yaml>

<deal_id> is the ID of a deal (you can find it in <sonmcli deals list> command output) <task.yaml> is the name of the configuration file with task specification (see example on GitHub or in the SONM MVP.RC1 whitelist).

Example:

[email protected]:~$ sonmcli tasks start 34 task.yaml
Task ID: 614ab8dd-25cd-4a02-9d66-3d9ce9241675
Hub Address: 0xedB7Ae4B946Cf249349974A02e354B5FBC577798
Endpoint: 80/tcp->172.17.0.1:32768
Endpoint: 80/tcp->10.0.2.4:32768

Tasks status

The command to the Consumer to inspect the status of the task.

Usage:
   sonmcli tasks status <hub_addr> <task_id>

<hub_addr> is the Ethereum address of a SONM Hub that is providing resources. <task_id> is the ID of a task.

Example:

[email protected]:~$ sonmcli tasks status 0xedB7Ae4B946Cf249349974A02e354B5FBC577798 614ab8dd-25cd-4a02-9d66-3d9ce9241675

Task 614ab8dd-25cd-4a02-9d66-3d9ce9241675 (on 4c0be87c-ad99-4bf3-bb8f-82cd1951f02d):
Image: httpd:latest
Status: RUNNING
Uptime: 3h18m5.208008639s
Resources:
CPU: 587915354
MEM: 11.9 MB
NET:
eth0:
Tx/Rx bytes: 748/7223
Tx/Rx packets: 7/70
Tx/Rx errors: 0/0
Tx/Rx dropped: 0/0
Ports:
80/tcp: 0.0.0.0:32768

Tasks logs

The command to retrieve task log.

Usage:
   sonmcli tasks logs <hub_addr> <task_id>

<hub_addr> is the Ethereum address of a SONM Hub that is providing resources. <task_id> is the ID of a task.

Tasks stop

Consumer should use this command to stop the task specified (by task ID).

Usage:
   sonmcli tasks stop <hub_addr> <task_id>

<hub_addr> is the Ethereum address of a SONM Hub that is providing resources. <task_id> is the ID of a task.

Tasks pull

Consumer should use this command to pull the Docker image of a finished task to the local PC (by task ID). Use this command if you your application running in statefull mode and you need to retrieve results of your task.

Usage:
   sonmcli tasks pull <deal_id> <task_id>

<deal_id> is the ID of a deal (you can find it in <sonmcli deals list> command output) <task_id> is the ID of a task.

Version

The <sonmcli version> command shows the version of your SONM CLI application.

[email protected]:~$ sonmcli version
Version: v0.2.1.1-e7ee9d8