File: edit_ip.py

package info (click to toggle)
python-softlayer 6.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,100 kB
  • sloc: python: 53,771; makefile: 289; sh: 57
file content (27 lines) | stat: -rw-r--r-- 688 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Edit ip note"""
# :license: MIT, see LICENSE for more details.

import click

import SoftLayer
from SoftLayer.CLI import environment


@click.command(cls=SoftLayer.CLI.command.SLCommand, )
@click.argument('identifier')
@click.option('--note', help="set ip address note of subnet")
@environment.pass_env
def cli(env, identifier, note):
    """Set the note of the ipAddress"""

    data = {
        'note': note
    }
    mgr = SoftLayer.NetworkManager(env.client)
    ip_id = None
    if str.isdigit(identifier):
        ip_id = identifier
    else:
        ip_object = mgr.get_ip_by_address(identifier)
        ip_id = ip_object.get('id')
    mgr.set_subnet_ipddress_note(ip_id, data)