Go to file
Jose M. Guisado a721957cc4 cli: add server commands
Add OgServer class inside cli/objects/server.py

This OgServer class implements add, list, set and delete commands
related to the server API (/server and /client/server) exposed by the
ogServer. These server endpoints correspond with the "entornos" table and
"identorno" foreign key in the "ordenadores" tables.

To list all rows from the "entornos" table. i.e: Listing all stored
addresses for the ogServer:

	ogcli list servers

	{
	  "servers": [
	    {
	      "address": "192.168.2.240",
	      "id": 1
	    },
	    {
	      "address": "1.1.1.1",
	      "id": 2
	    }
	  ]
	}

To store a new ip address for the ogServer, ogCLI will reply with the
new id:

	ogcli add server --address "10.141.10.1"

	{"id", "2"}

To set a client's associated ogServer address using the server id:

	ogcli set server --id 2 --client-ip 10.141.10.100

To set the associated server of a whole room use --room-id parameter:

	ogcli set server --id 2 --room-id 1

To remove any existing address (which is not currently set as the
ogServer addres for any client) using the server id:

	ogcli delete server --id 2

To determine a client's associated server just list the client's
information (this requires an updated ogServer):

	ogcli list client --client-ip 10.141.10.100

	{
	  "boot": "oglive",
	  "center": 1,
	  ...
	  "server_id": 1
	}
2023-08-24 09:14:49 +02:00
cfg Add ip and port parameters to config 2020-06-19 12:49:49 +02:00
cli cli: add server commands 2023-08-24 09:14:49 +02:00
examples examples: add examples folder 2022-11-13 18:49:59 +01:00
.gitignore add .gitignore 2020-06-18 16:53:41 +02:00
COPYING First commit 2020-06-18 16:44:08 +02:00
README.md README: add setup example and update commands 2022-05-20 08:54:12 +02:00
ogcli format: use autopep8 2022-05-20 10:22:42 +02:00

README.md

ogCLI

Manage your OpenGnsys environment from your command line. A CLI for the ogServer REST API.

Installation

This tool is expected to be executed from the OpenGnsys installation environment.

Before running any command copy ogcli.json inside /opt/opengnsys/etc/

Usage

ogcli {command} {object} [{command object options}]

Commands

usage: ogcli [-h] [{create,list,restore,send,set,setup}]

positional arguments:
  {create,list,restore,send,set,setup}
                        Subcommand to run

options:
  -h, --help            show this help message and exit

create

Create images.

usage: ogcli create [-h] {image}

positional arguments:
  {image}

options:
  -h, --help  show this help message and exit

list

You can list currently connected clients, disk, scope tree, boot modes, hardware/software profiles, images, and specific client information.

usage: ogcli list [-h] {clients,scopes,modes,hardware,client,images,disks}

positional arguments:
  {clients,scopes,modes,hardware,client,images,disks}

options:
  -h, --help            show this help message and exit

restore

Restore an image partition

usage: ogcli restore [-h] {image}

positional arguments:
  {image}

options:
  -h, --help  show this help message and exit

send

Send WoL, poweroff or refresh to a given scope.

usage: ogcli send [-h] {wol,poweroff,refresh}

positional arguments:
  {wol,poweroff,refresh}

options:
  -h, --help            show this help message and exit

set

Set properties of the managed computers.

You can modify boot mode using set.

usage: ogcli set [-h] {modes}

positional arguments:
  {modes}

positional arguments:
  {modes}

optional arguments:
  -h, --help  show this help message and exit

setup

Setup disks of a given scope

usage: ogcli setup [-h] {disk}

positional arguments:
  {disk}

options:
  -h, --help  show this help message and exit

Objects

They are subject to the specified command.

  • clients: Currently connected clients to the ogServer
  • client: Any specific client
  • disk: Client's disks
  • images: Partition images
  • modes: Network boot modes
  • hardware: Hardware profiles
  • scopes: Scope tree of managed computers, rooms and centers.

Examples

Client setup

DOS/MBR, first partition: 40G Linux/ext4, also add a 10G OpenGnsys cache partition. Format each partition.
ogcli setup disk --type dos --part 1,LINUX,EXT4,40G --part 4,CACHE,CACHE,10G --format 1,4 --client-ip 192.168.56.11

Changing the boot mode of computers in a particular classroom

Fetching a classroom id
ogcli list scopes

{'scope': [{'name': 'Unidad Organizativa (Default)', 'type': 'center', 'id': 1, 'scope': [{'name': 'Aula virtual', 'type': 'room', 'id': 1, ...
Fetching net boot modes
ogcli list modes

{'modes': ['11', 'pxe', '00unknown', '19pxeADMIN', '13', '10', '12']}
Changing boot mode of the classroom
ogcli set modes --room-id 1 --mode pxe

License

ogCLI is released under the GNU Affero Public License v3

Authors

Soleta Networks