summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-12 11:42:30 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-12 11:42:30 +0200
commit175a38606ace0f14b538da2e613aaf9421b174e6 (patch)
tree38ba718760f36d960279be44cd5c4de9e162dd39 /cli
parent7f09d148b4ec2b6bca500a7bb33f97072930bc9e (diff)
repo: server: replace --address with --ip
Make flag format uniform for all the commands.
Diffstat (limited to 'cli')
-rw-r--r--cli/objects/repo.py42
-rw-r--r--cli/objects/server.py8
2 files changed, 25 insertions, 25 deletions
diff --git a/cli/objects/repo.py b/cli/objects/repo.py
index e77f6fa..7085633 100644
--- a/cli/objects/repo.py
+++ b/cli/objects/repo.py
@@ -19,16 +19,16 @@ class OgRepo():
@staticmethod
def _add_repo(rest, parsed_args):
payload = {
- 'addr': parsed_args.address,
+ 'addr': parsed_args.ip,
'name': parsed_args.name,
}
rest.post('/repository/add', payload=payload)
@staticmethod
def _add_repo_ip(rest, parsed_args):
- for address in parsed_args.address:
- if not check_address(address):
- print(f'Invalid IP address: {address}')
+ for ip in parsed_args.ip:
+ if not check_address(ip):
+ print(f'Invalid IP address: {ip}')
return
r = rest.get('/repositories')
@@ -42,14 +42,14 @@ class OgRepo():
print('Invalid repository id specified')
return
- for address in parsed_args.address:
- if address in target_repo['addr']:
- print(f'The repository already contains the address {address}')
+ for ip in parsed_args.ip:
+ if ip in target_repo['addr']:
+ print(f'The repository already contains the address {ip}')
return
payload = {
'id': parsed_args.id,
- 'addr': target_repo['addr'] + parsed_args.address,
+ 'addr': target_repo['addr'] + parsed_args.ip,
'name': target_repo['name'],
}
rest.post('/repository/update', payload=payload)
@@ -66,7 +66,7 @@ class OgRepo():
group.add_argument('--id',
type=int,
help='repo id (list repos using "ogcli list repos")')
- parser.add_argument('--address',
+ parser.add_argument('--ip',
nargs='+',
required=True,
help='IP list separated by spaces')
@@ -86,7 +86,7 @@ class OgRepo():
nargs='?',
required=True,
help='repo id (list repos using "ogcli list repos")')
- parser.add_argument('--address',
+ parser.add_argument('--ip',
nargs='+',
required=True,
help='IP list separated by spaces')
@@ -97,7 +97,7 @@ class OgRepo():
parsed_args = parser.parse_args(args)
payload = {
'id': parsed_args.id,
- 'addr': parsed_args.address,
+ 'addr': parsed_args.ip,
'name': parsed_args.name,
}
@@ -105,9 +105,9 @@ class OgRepo():
@staticmethod
def _delete_repo_ip(rest, parsed_args):
- for address in parsed_args.address:
- if not check_address(address):
- print(f'Invalid IP address: {address}')
+ for ip in parsed_args.ip:
+ if not check_address(ip):
+ print(f'Invalid IP address: {ip}')
return
r = rest.get('/repositories')
@@ -121,12 +121,12 @@ class OgRepo():
print('Invalid repository id specified')
return
- for address in parsed_args.address:
- if address not in target_repo['addr']:
- print(f'Invalid address {address}: The repository has the following IPs: {target_repo["addr"]}')
+ for ip in parsed_args.ip:
+ if ip not in target_repo['addr']:
+ print(f'Invalid address {ip}: The repository has the following IPs: {target_repo["addr"]}')
return
- target_repo['addr'].remove(address)
+ target_repo['addr'].remove(ip)
payload = {
'id': parsed_args.id,
@@ -149,15 +149,15 @@ class OgRepo():
required=True,
help='repo id (list repos using "ogcli list repos")')
- # --address is optional; if provided, the IP will be removed, otherwise,
+ # --ip is optional; if provided, the IP will be removed, otherwise,
# the repo will be deleted
- parser.add_argument('--address',
+ parser.add_argument('--ip',
nargs='+',
help='IP address to remove from the repository')
parsed_args = parser.parse_args(args)
- if parsed_args.address:
+ if parsed_args.ip:
OgRepo._delete_repo_ip(rest, parsed_args)
else:
OgRepo._delete_repo(rest, parsed_args)
diff --git a/cli/objects/server.py b/cli/objects/server.py
index c3f83a8..468ff00 100644
--- a/cli/objects/server.py
+++ b/cli/objects/server.py
@@ -19,17 +19,17 @@ class OgServer():
@staticmethod
def add_server(rest, args):
parser = argparse.ArgumentParser(prog='ogcli add server')
- parser.add_argument('--address',
+ parser.add_argument('--ip',
nargs='?',
required=True,
help='valid ogserver ip address')
parsed_args = parser.parse_args(args)
- if not check_address(parsed_args.address):
- print(f'Invalid IP address: {parsed_args.address}')
+ if not check_address(parsed_args.ip):
+ print(f'Invalid IP address: {parsed_args.ip}')
return
- payload = {'address': parsed_args.address}
+ payload = {'address': parsed_args.ip}
rest.post('/server', payload=payload)
@staticmethod