summaryrefslogtreecommitdiff
path: root/openstackclient/network/v2
diff options
context:
space:
mode:
authorLIU Yulong <i@liuyulong.me>2017-11-05 12:05:09 +0800
committerDean Troyer <dtroyer@gmail.com>2018-01-11 18:10:11 +0000
commitcf91d7a2f46b4a8546169a4836cc64476fce44d8 (patch)
tree73cf917909abab77be6f594892b94b025637033d /openstackclient/network/v2
parentb13a323128072f6f56619a816f5be165796171a4 (diff)
downloadpython-openstackclient-cf91d7a2f46b4a8546169a4836cc64476fce44d8.tar.gz
Add floating IP qos_policy actions
Now we can associate a qos policy to the floating IP, and dissociate it. The commands are: $ openstack floating ip create --qos-policy ... $ openstack floating ip set --qos-policy ... $ openstack floating ip set --no-qos-policy ... $ openstack floating ip unset --qos-policy These commands are based on the neutron change: I4efe9e49d268dffeb3df4de4ea1780152218633b Partially-Implements blueprint: floating-ip-rate-limit Change-Id: I932b32f78cc5a2b53926feaec1a0b392cf7e8b57
Diffstat (limited to 'openstackclient/network/v2')
-rw-r--r--openstackclient/network/v2/floating_ip.py42
1 files changed, 39 insertions, 3 deletions
diff --git a/openstackclient/network/v2/floating_ip.py b/openstackclient/network/v2/floating_ip.py
index 05b688a6..181f88c0 100644
--- a/openstackclient/network/v2/floating_ip.py
+++ b/openstackclient/network/v2/floating_ip.py
@@ -67,6 +67,10 @@ def _get_attrs(client_manager, parsed_args):
if parsed_args.fixed_ip_address:
attrs['fixed_ip_address'] = parsed_args.fixed_ip_address
+ if parsed_args.qos_policy:
+ attrs['qos_policy_id'] = network_client.find_qos_policy(
+ parsed_args.qos_policy, ignore_missing=False).id
+
if parsed_args.description is not None:
attrs['description'] = parsed_args.description
@@ -170,6 +174,11 @@ class CreateFloatingIP(common.NetworkAndComputeShowOne):
help=_("Fixed IP address mapped to the floating IP")
)
parser.add_argument(
+ '--qos-policy',
+ metavar='<qos-policy>',
+ help=_("Attach QoS policy to the floating IP (name or ID)")
+ )
+ parser.add_argument(
'--description',
metavar='<description>',
help=_('Set floating IP description')
@@ -462,6 +471,17 @@ class SetFloatingIP(command.Command):
help=_("Fixed IP of the port "
"(required only if port has multiple IPs)")
)
+ qos_policy_group = parser.add_mutually_exclusive_group()
+ qos_policy_group.add_argument(
+ '--qos-policy',
+ metavar='<qos-policy>',
+ help=_("Attach QoS policy to the floating IP (name or ID)")
+ )
+ qos_policy_group.add_argument(
+ '--no-qos-policy',
+ action='store_true',
+ help=_("Remove the QoS policy attached to the floating IP")
+ )
return parser
def take_action(self, parsed_args):
@@ -479,6 +499,13 @@ class SetFloatingIP(command.Command):
if parsed_args.fixed_ip_address:
attrs['fixed_ip_address'] = parsed_args.fixed_ip_address
+ if parsed_args.qos_policy:
+ attrs['qos_policy_id'] = client.find_qos_policy(
+ parsed_args.qos_policy, ignore_missing=False).id
+
+ if 'no_qos_policy' in parsed_args and parsed_args.no_qos_policy:
+ attrs['qos_policy_id'] = None
+
client.update_ip(obj, **attrs)
@@ -549,6 +576,12 @@ class UnsetFloatingIP(command.Command):
default=False,
help=_("Disassociate any port associated with the floating IP")
)
+ parser.add_argument(
+ '--qos-policy',
+ action='store_true',
+ default=False,
+ help=_("Remove the QoS policy attached to the floating IP")
+ )
return parser
def take_action(self, parsed_args):
@@ -559,8 +592,11 @@ class UnsetFloatingIP(command.Command):
parsed_args.floating_ip,
ignore_missing=False,
)
+ attrs = {}
if parsed_args.port:
- attrs = {
- 'port_id': None,
- }
+ attrs['port_id'] = None
+ if parsed_args.qos_policy:
+ attrs['qos_policy_id'] = None
+
+ if attrs:
client.update_ip(obj, **attrs)