diff options
author | Javier Hernandez <jhernandez@soleta.eu> | 2023-10-27 11:38:24 +0200 |
---|---|---|
committer | Jose M. Guisado <jguisado@soleta.eu> | 2023-10-27 11:57:25 +0200 |
commit | 4bf4f91f5466131bf278a97a6e3685f66106fc6f (patch) | |
tree | 023b0301e1b7be4132c565d35a6b1c0c901c9f46 /cli/utils.py | |
parent | 37c4065f06f7cdaa35a49c7a6168f50394b37565 (diff) |
client: support for adding clientsv0.3.3
Add a new client with command:
$ ogcli add client --repo-id <repo id>
--netmask <netmask>
--room-id <room id>
--hostname <hostname>
--mac <mac address>
--ip <ip address>
--boot-mode <boot mode>
For example: To add a new client with hostname "javipc", netmask
255.255.255.0, mac address a2:54:00:2e:05:7a, ip address 192.168.56.101,
assign it to repo id 1, room id 1 and set its boot mode to oglive
use:
$ ogcli add client --hostname javipc --netmask 255.255.255.0 --mac
a2:54:00:2e:05:7a --ip 192.168.56.101 --repo-id 1 --room-id 1
--boot-mode oglive
Notes:
- ogserver API REST json payload does not allow to specify a server
(table 'entorno') for the client. It will automatically assign
client to server with id 1
- ogserver API REST json payload specifies mac address without ':'.
- payload must contain 'netiface', ogcli specifies 'eth0' is specified
which is the default value in netiface column in db (table 'ordenadores')
- netdriver column uses "generic" as default, this field is not used
anymore, but it is set to "generic" by now.
- ogserver should validate that boot mode set is correct.
Diffstat (limited to 'cli/utils.py')
-rw-r--r-- | cli/utils.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cli/utils.py b/cli/utils.py index 88c15a4..185e7ee 100644 --- a/cli/utils.py +++ b/cli/utils.py @@ -7,6 +7,7 @@ import json import ipaddress +import re def scope_lookup(scope_id, scope_type, d): if scope_id == d.get('id') and scope_type == d.get('type'): @@ -39,3 +40,11 @@ def check_address(addr): return True except: return False + +def check_mac_address(addr): + if re.match("[a-f0-9]{2}(:[a-f0-9]{2}){5}$", addr.lower()): + return True + else: + print(addr.lower()) + return False + |