diff options
author | Bence Romsics <bence.romsics@gmail.com> | 2020-02-20 15:49:51 +0100 |
---|---|---|
committer | ricolin <rico.lin.guanyu@gmail.com> | 2020-04-27 17:00:24 +0800 |
commit | b9d009abc9eb6e14fe3f9226dc1e2b8abc40fc33 (patch) | |
tree | f6b2fc3a25cb04b6c51aa3c1db607be3baa73a60 /heat/engine | |
parent | f5090194ead0d4f7cec4672c0f56959266b9346a (diff) | |
download | heat-b9d009abc9eb6e14fe3f9226dc1e2b8abc40fc33.tar.gz |
New resource OS::Neutron::QoSMinimumBandwidthRule
The 'minimum_bandwidth_rule' QoS rule type of Neutron (supported in both
egress and ingress directions since the Stein release) did not have a
Heat resource yet. This change adds it.
Change-Id: I693fe2f7801f78f827ef1c74e5874018cd9cf51b
Diffstat (limited to 'heat/engine')
-rw-r--r-- | heat/engine/resources/openstack/neutron/qos.py | 89 |
1 files changed, 88 insertions, 1 deletions
diff --git a/heat/engine/resources/openstack/neutron/qos.py b/heat/engine/resources/openstack/neutron/qos.py index 2a75428b1..683aecbf2 100644 --- a/heat/engine/resources/openstack/neutron/qos.py +++ b/heat/engine/resources/openstack/neutron/qos.py @@ -292,9 +292,96 @@ class QoSDscpMarkingRule(QoSRule): return [self.resource_id, self.policy_id] +class QoSMinimumBandwidthRule(QoSRule): + """A resource for guaranteeing bandwidth. + + This rule can be associated with a QoS policy, and then the policy + can be used by a neutron port to provide guaranteed bandwidth QoS + capabilities. + + Depending on drivers the guarantee may be enforced on two levels. + First when a server is placed (scheduled) on physical infrastructure + and/or second in the data plane of the physical hypervisor. For details + please see Neutron documentation: + + https://docs.openstack.org/neutron/latest/admin/config-qos-min-bw.html + + The default policy usage of this resource is limited to + administrators only. + """ + + entity = 'minimum_bandwidth_rule' + + required_service_extension = 'qos-bw-minimum-ingress' + + support_status = support.SupportStatus( + status=support.SUPPORTED, + version='14.0.0', + ) + + PROPERTIES = ( + MIN_BANDWIDTH, DIRECTION + ) = ( + 'min_kbps', 'direction' + ) + + properties_schema = { + MIN_BANDWIDTH: properties.Schema( + properties.Schema.INTEGER, + _('Min bandwidth in kbps.'), + required=True, + update_allowed=True, + constraints=[ + constraints.Range(min=0), + ], + ), + DIRECTION: properties.Schema( + properties.Schema.STRING, + _('Traffic direction from the point of view of the port.'), + update_allowed=True, + constraints=[ + constraints.AllowedValues(['egress', 'ingress']), + ], + default='egress', + ), + } + + properties_schema.update(QoSRule.properties_schema) + + def handle_create(self): + props = self.prepare_properties(self.properties, + self.physical_resource_name()) + props.pop(self.POLICY) + + rule = self.client().create_minimum_bandwidth_rule( + self.policy_id, + {'minimum_bandwidth_rule': props})['minimum_bandwidth_rule'] + + self.resource_id_set(rule['id']) + + def handle_delete(self): + if self.resource_id is None: + return + + with self.client_plugin().ignore_not_found: + self.client().delete_minimum_bandwidth_rule( + self.resource_id, self.policy_id) + + def handle_update(self, json_snippet, tmpl_diff, prop_diff): + if prop_diff: + self.client().update_minimum_bandwidth_rule( + self.resource_id, + self.policy_id, + {'minimum_bandwidth_rule': prop_diff}) + + def _res_get_args(self): + return [self.resource_id, self.policy_id] + + def resource_mapping(): return { 'OS::Neutron::QoSPolicy': QoSPolicy, 'OS::Neutron::QoSBandwidthLimitRule': QoSBandwidthLimitRule, - 'OS::Neutron::QoSDscpMarkingRule': QoSDscpMarkingRule + 'OS::Neutron::QoSDscpMarkingRule': QoSDscpMarkingRule, + 'OS::Neutron::QoSMinimumBandwidthRule': QoSMinimumBandwidthRule, } |