Update network modify with new add flags

This commit is contained in:
Joshua Boniface 2018-10-03 20:22:42 -04:00
parent 5ee8af3b2f
commit a6f7986b87
2 changed files with 24 additions and 8 deletions

View File

@ -638,6 +638,11 @@ def net_add(vni, description, domain, ip_network, ip_gateway, dhcp_flag, dhcp_st
default=None, default=None,
help='Description of the network; should not contain whitespace.' help='Description of the network; should not contain whitespace.'
) )
@click.option(
'-n', '--domain', 'domain',
default=None,
help='Domain name of the network.'
)
@click.option( @click.option(
'-i', '--ipnet', 'ip_network', '-i', '--ipnet', 'ip_network',
default=None, default=None,
@ -648,30 +653,35 @@ def net_add(vni, description, domain, ip_network, ip_gateway, dhcp_flag, dhcp_st
default=None, default=None,
help='Default gateway address for subnet.' help='Default gateway address for subnet.'
) )
@click.option(
'-r', '--router', 'ip_routers',
multiple=True,
help='Router addresses for subnet (specify one or two; mapped to routers in order given).'
)
@click.option( @click.option(
'--dhcp/--no-dhcp', 'dhcp_flag', '--dhcp/--no-dhcp', 'dhcp_flag',
default=None, default=None,
is_flag=True, is_flag=True,
help='Enable/disable DHCP for clients on subnet.' help='Enable/disable DHCP for clients on subnet.'
) )
@click.option(
'--dhcp-start', 'dhcp_start',
default=None,
help='DHCP range start address.'
)
@click.option(
'--dhcp-end', 'dhcp_end',
default=None,
help='DHCP range end address.'
)
@click.argument( @click.argument(
'vni' 'vni'
) )
def net_modify(vni, description, ip_network, ip_gateway, ip_routers, dhcp_flag): def net_modify(vni, description, domain, ip_network, ip_gateway, dhcp_flag, dhcp_start, dhcp_end):
""" """
Modify details of virtual network VNI. All fields optional; only specified fields will be updated. Modify details of virtual network VNI. All fields optional; only specified fields will be updated.
Example: Example:
pvc network modify 1001 --gateway 10.1.1.255 --router 10.1.1.251 --router 10.1.1.252 --no-dhcp pvc network modify 1001 --gateway 10.1.1.1 --dhcp
""" """
zk_conn = pvc_common.startZKConnection(zk_host) zk_conn = pvc_common.startZKConnection(zk_host)
retcode, retmsg = pvc_network.modify_network(zk_conn, vni, description=description, ip_network=ip_network, ip_gateway=ip_gateway, ip_routers=ip_routers, dhcp_flag=dhcp_flag) retcode, retmsg = pvc_network.modify_network(zk_conn, vni, description=description, domain=domain, ip_network=ip_network, ip_gateway=ip_gateway, dhcp_flag=dhcp_flag, dhcp_start=dhcp_start, dhcp_end=dhcp_end)
cleanup(retcode, retmsg, zk_conn) cleanup(retcode, retmsg, zk_conn)
############################################################################### ###############################################################################

View File

@ -433,12 +433,18 @@ def modify_network(zk_conn, vni, **parameters):
zk_data = {} zk_data = {}
if parameters['description'] != None: if parameters['description'] != None:
zk_data.update({'/networks/{}'.format(vni): parameters['description']}) zk_data.update({'/networks/{}'.format(vni): parameters['description']})
if parameters['domain'] != None:
zk_data.update({'/networks/{}/domain'.format(vni): parameters['domain']})
if parameters['ip_network'] != None: if parameters['ip_network'] != None:
zk_data.update({'/networks/{}/ip_network'.format(vni): parameters['ip_network']}) zk_data.update({'/networks/{}/ip_network'.format(vni): parameters['ip_network']})
if parameters['ip_gateway'] != None: if parameters['ip_gateway'] != None:
zk_data.update({'/networks/{}/ip_gateway'.format(vni): parameters['ip_gateway']}) zk_data.update({'/networks/{}/ip_gateway'.format(vni): parameters['ip_gateway']})
if parameters['dhcp_flag'] != None: if parameters['dhcp_flag'] != None:
zk_data.update({'/networks/{}/dhcp_flag'.format(vni): str(parameters['dhcp_flag'])}) zk_data.update({'/networks/{}/dhcp_flag'.format(vni): str(parameters['dhcp_flag'])})
if parameters['dhcp_start'] != None:
zk_data.update({'/networks/{}/dhcp_start'.format(vni): parameters['dhcp_start']})
if parameters['dhcp_end'] != None:
zk_data.update({'/networks/{}/dhcp_end'.format(vni): parameters['dhcp_end']})
zkhandler.writedata(zk_conn, zk_data) zkhandler.writedata(zk_conn, zk_data)