@@ -151,14 +151,6 @@ def _prepare_fixed_ips(client_manager, parsed_args):
151151
152152
153153def _add_updatable_args (parser ):
154- parser .add_argument (
155- '--fixed-ip' ,
156- metavar = 'subnet=<subnet>,ip-address=<ip-address>' ,
157- action = parseractions .MultiKeyValueAction ,
158- optional_keys = ['subnet' , 'ip-address' ],
159- help = 'Desired IP and/or subnet (name or ID) for this port: '
160- 'subnet=<subnet>,ip-address=<ip-address> '
161- '(this option can be repeated)' )
162154 # NOTE(dtroyer): --device-id is deprecated in Mar 2016. Do not
163155 # remove before 3.x release or Mar 2017.
164156 device_group = parser .add_mutually_exclusive_group ()
@@ -184,12 +176,6 @@ def _add_updatable_args(parser):
184176 help = "VNIC type for this port (direct | direct-physical |"
185177 " macvtap | normal | baremetal). If unspecified during"
186178 " port creation, default value will be 'normal'." )
187- parser .add_argument (
188- '--binding-profile' ,
189- metavar = '<binding-profile>' ,
190- action = parseractions .KeyValueAction ,
191- help = 'Custom data to be passed as binding:profile: <key>=<value> '
192- '(this option can be repeated)' )
193179 # NOTE(dtroyer): --host-id is deprecated in Mar 2016. Do not
194180 # remove before 3.x release or Mar 2017.
195181 host_group = parser .add_mutually_exclusive_group ()
@@ -217,6 +203,20 @@ def get_parser(self, prog_name):
217203 required = True ,
218204 help = 'Network this port belongs to (name or ID)' )
219205 _add_updatable_args (parser )
206+ parser .add_argument (
207+ '--fixed-ip' ,
208+ metavar = 'subnet=<subnet>,ip-address=<ip-address>' ,
209+ action = parseractions .MultiKeyValueAction ,
210+ optional_keys = ['subnet' , 'ip-address' ],
211+ help = 'Desired IP and/or subnet (name or ID) for this port: '
212+ 'subnet=<subnet>,ip-address=<ip-address> '
213+ '(this option can be repeated)' )
214+ parser .add_argument (
215+ '--binding-profile' ,
216+ metavar = '<binding-profile>' ,
217+ action = parseractions .KeyValueAction ,
218+ help = 'Custom data to be passed as binding:profile: <key>=<value> '
219+ '(this option can be repeated)' )
220220 admin_group = parser .add_mutually_exclusive_group ()
221221 admin_group .add_argument (
222222 '--enable' ,
@@ -352,7 +352,30 @@ def get_parser(self, prog_name):
352352 metavar = "<port>" ,
353353 help = ("Port to modify (name or ID)" )
354354 )
355-
355+ fixed_ip = parser .add_mutually_exclusive_group ()
356+ fixed_ip .add_argument (
357+ '--fixed-ip' ,
358+ metavar = 'subnet=<subnet>,ip-address=<ip-address>' ,
359+ action = parseractions .MultiKeyValueAction ,
360+ optional_keys = ['subnet' , 'ip-address' ],
361+ help = 'Desired IP and/or subnet (name or ID) for this port: '
362+ 'subnet=<subnet>,ip-address=<ip-address> '
363+ '(this option can be repeated)' )
364+ fixed_ip .add_argument (
365+ '--no-fixed-ip' ,
366+ action = 'store_true' ,
367+ help = 'Clear existing information of fixed-ips' )
368+ binding_profile = parser .add_mutually_exclusive_group ()
369+ binding_profile .add_argument (
370+ '--binding-profile' ,
371+ metavar = '<binding-profile>' ,
372+ action = parseractions .KeyValueAction ,
373+ help = 'Custom data to be passed as binding:profile: <key>=<value> '
374+ '(this option can be repeated)' )
375+ binding_profile .add_argument (
376+ '--no-binding-profile' ,
377+ action = 'store_true' ,
378+ help = 'Clear existing information of binding:profile' )
356379 return parser
357380
358381 def take_action (self , parsed_args ):
@@ -361,6 +384,11 @@ def take_action(self, parsed_args):
361384 _prepare_fixed_ips (self .app .client_manager , parsed_args )
362385 attrs = _get_attrs (self .app .client_manager , parsed_args )
363386
387+ if parsed_args .no_fixed_ip :
388+ attrs ['fixed_ips' ] = []
389+ if parsed_args .no_binding_profile :
390+ attrs ['binding:profile' ] = {}
391+
364392 if attrs == {}:
365393 msg = "Nothing specified to be set"
366394 raise exceptions .CommandError (msg )
0 commit comments