Skip to content

Commit

Permalink
Add name option to IP
Browse files Browse the repository at this point in the history
This patch adds a `name` option to the `ip set` command which sets the
name property on the IP address in Proteus. If the value is not set, but
a hostname is set, the hostname will be used as default value.
  • Loading branch information
lkiesow committed Jun 7, 2024
1 parent 3b146ec commit 231a193
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion proteuscmd/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def ip_get(proteus, ip):


@ip.command(name='set')
@click.option('--name', required=False,
help='Name of the host. Defaults to hostname if set.')
@click.option('--admin-email', '-e', required=True,
help='Email address of the host admin')
@click.option('--admin-name', '-n', required=True,
Expand All @@ -117,7 +119,7 @@ def ip_get(proteus, ip):
@click.argument('ip', type=IPV4_TYPE)
@click.argument('mac')
@with_proteus
def ip_set(proteus, admin_email, admin_name, admin_phone, comment, state,
def ip_set(proteus, name, admin_email, admin_name, admin_phone, comment, state,
hostname, view, prop, force, ip, mac):
'''Assign IPv4 address
'''
Expand All @@ -139,6 +141,9 @@ def ip_set(proteus, admin_email, admin_name, admin_phone, comment, state,
'admin_name': admin_name,
'admin_phone': admin_phone,
'comment': comment}
if name or hostname:
# Name defaults to hostname
props['name'] = name or hostname
for extra_prop in prop:
k, v = extra_prop.split('=', 1)
props[k] = v
Expand Down

0 comments on commit 231a193

Please sign in to comment.