summaryrefslogtreecommitdiffstats
path: root/cli/utils.py
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2023-10-19 10:21:44 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-10-19 12:26:31 +0200
commit1c2e5c4c96f3c8b114508de7f713dda8ebfcb877 (patch)
treec0171176de8d971dcd734fb573bdd341bf4f0479 /cli/utils.py
parent7c30d569100a351f2a0a6430093abb8791f44fcf (diff)
cli: add room
add functionality to add and remove a room to add a new room use the command: ogcli add room --name <name> --netmask <netmask> --center <center> --gateway <gateway> [--location <location>] [--ntp <ntp>] [--dns <dns>] [--group <group>] for instance, to create a room with name 'dummyroom', netmask '255.255.255.0' and gateway 10.141.10.1 that is inside the center with id 1, use: $ ogcli add room --name dummyroom --netmask 255.255.255.0 --gateway 10.141.10.1 --center 1 Optionally, it is possible to provide additional information such as location (--location <location>), ntp server (--ntp <ntp>), dns server (--dns <dns>), and a group to contain the room (--group <group>). to delete a room use: ogcli delete room --id <id> for instance, to delete room with id 4 use: $ ogcli delete room --id 4
Diffstat (limited to 'cli/utils.py')
-rw-r--r--cli/utils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/cli/utils.py b/cli/utils.py
index b267207..88c15a4 100644
--- a/cli/utils.py
+++ b/cli/utils.py
@@ -6,7 +6,7 @@
# (at your option) any later version.
import json
-
+import ipaddress
def scope_lookup(scope_id, scope_type, d):
if scope_id == d.get('id') and scope_type == d.get('type'):
@@ -32,3 +32,10 @@ def ips_in_scope(scope):
def print_json(text):
payload = json.loads(text)
print(json.dumps(payload, sort_keys=True, indent=2))
+
+def check_address(addr):
+ try:
+ ip = ipaddress.ip_address(addr)
+ return True
+ except:
+ return False