diff options
| author | reedip <reedip.banerjee@nectechnologies.in> | 2016-04-01 14:26:16 +0900 |
|---|---|---|
| committer | reedip <reedip.banerjee@nectechnologies.in> | 2016-04-07 10:59:15 +0900 |
| commit | 73d15e3768e28008515781b30e533ddf3d8d4159 (patch) | |
| tree | 7395556cb7a882a4f4dc174719baa0eff43019dd /openstackclient/network | |
| parent | 0edab95fd1989dcc06a166a820b115a75dd17d54 (diff) | |
| download | python-openstackclient-73d15e3768e28008515781b30e533ddf3d8d4159.tar.gz | |
Add option to clear information from ports
This patch adds the option of "no-fixed-ip" and
"no-binding-profile" which is used to clear the
fixed-ip and binding:profile information from the
ports.
Change-Id: I946301eaf6c647bae55e4f416aa0d98e5f06e699
Diffstat (limited to 'openstackclient/network')
| -rw-r--r-- | openstackclient/network/v2/port.py | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/openstackclient/network/v2/port.py b/openstackclient/network/v2/port.py index d7866ccc..a9e80428 100644 --- a/openstackclient/network/v2/port.py +++ b/openstackclient/network/v2/port.py @@ -151,14 +151,6 @@ def _prepare_fixed_ips(client_manager, parsed_args): def _add_updatable_args(parser): - parser.add_argument( - '--fixed-ip', - metavar='subnet=<subnet>,ip-address=<ip-address>', - action=parseractions.MultiKeyValueAction, - optional_keys=['subnet', 'ip-address'], - help='Desired IP and/or subnet (name or ID) for this port: ' - 'subnet=<subnet>,ip-address=<ip-address> ' - '(this option can be repeated)') # NOTE(dtroyer): --device-id is deprecated in Mar 2016. Do not # remove before 3.x release or Mar 2017. device_group = parser.add_mutually_exclusive_group() @@ -184,12 +176,6 @@ def _add_updatable_args(parser): help="VNIC type for this port (direct | direct-physical |" " macvtap | normal | baremetal). If unspecified during" " port creation, default value will be 'normal'.") - parser.add_argument( - '--binding-profile', - metavar='<binding-profile>', - action=parseractions.KeyValueAction, - help='Custom data to be passed as binding:profile: <key>=<value> ' - '(this option can be repeated)') # NOTE(dtroyer): --host-id is deprecated in Mar 2016. Do not # remove before 3.x release or Mar 2017. host_group = parser.add_mutually_exclusive_group() @@ -217,6 +203,20 @@ class CreatePort(command.ShowOne): required=True, help='Network this port belongs to (name or ID)') _add_updatable_args(parser) + parser.add_argument( + '--fixed-ip', + metavar='subnet=<subnet>,ip-address=<ip-address>', + action=parseractions.MultiKeyValueAction, + optional_keys=['subnet', 'ip-address'], + help='Desired IP and/or subnet (name or ID) for this port: ' + 'subnet=<subnet>,ip-address=<ip-address> ' + '(this option can be repeated)') + parser.add_argument( + '--binding-profile', + metavar='<binding-profile>', + action=parseractions.KeyValueAction, + help='Custom data to be passed as binding:profile: <key>=<value> ' + '(this option can be repeated)') admin_group = parser.add_mutually_exclusive_group() admin_group.add_argument( '--enable', @@ -352,7 +352,30 @@ class SetPort(command.Command): metavar="<port>", help=("Port to modify (name or ID)") ) - + fixed_ip = parser.add_mutually_exclusive_group() + fixed_ip.add_argument( + '--fixed-ip', + metavar='subnet=<subnet>,ip-address=<ip-address>', + action=parseractions.MultiKeyValueAction, + optional_keys=['subnet', 'ip-address'], + help='Desired IP and/or subnet (name or ID) for this port: ' + 'subnet=<subnet>,ip-address=<ip-address> ' + '(this option can be repeated)') + fixed_ip.add_argument( + '--no-fixed-ip', + action='store_true', + help='Clear existing information of fixed-ips') + binding_profile = parser.add_mutually_exclusive_group() + binding_profile.add_argument( + '--binding-profile', + metavar='<binding-profile>', + action=parseractions.KeyValueAction, + help='Custom data to be passed as binding:profile: <key>=<value> ' + '(this option can be repeated)') + binding_profile.add_argument( + '--no-binding-profile', + action='store_true', + help='Clear existing information of binding:profile') return parser def take_action(self, parsed_args): @@ -361,6 +384,11 @@ class SetPort(command.Command): _prepare_fixed_ips(self.app.client_manager, parsed_args) attrs = _get_attrs(self.app.client_manager, parsed_args) + if parsed_args.no_fixed_ip: + attrs['fixed_ips'] = [] + if parsed_args.no_binding_profile: + attrs['binding:profile'] = {} + if attrs == {}: msg = "Nothing specified to be set" raise exceptions.CommandError(msg) |
