2525RULE_TYPE_BANDWIDTH_LIMIT = 'bandwidth-limit'
2626RULE_TYPE_DSCP_MARKING = 'dscp-marking'
2727RULE_TYPE_MINIMUM_BANDWIDTH = 'minimum-bandwidth'
28+ RULE_TYPE_MINIMUM_PACKET_RATE = 'minimum-packet-rate'
2829MANDATORY_PARAMETERS = {
2930 RULE_TYPE_MINIMUM_BANDWIDTH : {'min_kbps' , 'direction' },
31+ RULE_TYPE_MINIMUM_PACKET_RATE : {'min_kpps' , 'direction' },
3032 RULE_TYPE_DSCP_MARKING : {'dscp_mark' },
3133 RULE_TYPE_BANDWIDTH_LIMIT : {'max_kbps' }}
3234OPTIONAL_PARAMETERS = {
3335 RULE_TYPE_MINIMUM_BANDWIDTH : set (),
36+ RULE_TYPE_MINIMUM_PACKET_RATE : set (),
3437 RULE_TYPE_DSCP_MARKING : set (),
3538 RULE_TYPE_BANDWIDTH_LIMIT : {'direction' , 'max_burst_kbps' }}
3639DIRECTION_EGRESS = 'egress'
3740DIRECTION_INGRESS = 'ingress'
41+ DIRECTION_ANY = 'any'
3842DSCP_VALID_MARKS = [0 , 8 , 10 , 12 , 14 , 16 , 18 , 20 , 22 , 24 , 26 , 28 , 30 , 32 ,
3943 34 , 36 , 38 , 40 , 46 , 48 , 56 ]
4044
@@ -98,10 +102,20 @@ def _get_attrs(network_client, parsed_args, is_create=False):
98102 attrs ['dscp_mark' ] = parsed_args .dscp_mark
99103 if parsed_args .min_kbps is not None :
100104 attrs ['min_kbps' ] = parsed_args .min_kbps
105+ if parsed_args .min_kpps is not None :
106+ attrs ['min_kpps' ] = parsed_args .min_kpps
101107 if parsed_args .ingress :
102- attrs ['direction' ] = 'ingress'
108+ attrs ['direction' ] = DIRECTION_INGRESS
103109 if parsed_args .egress :
104- attrs ['direction' ] = 'egress'
110+ attrs ['direction' ] = DIRECTION_EGRESS
111+ if parsed_args .any :
112+ if rule_type == RULE_TYPE_MINIMUM_PACKET_RATE :
113+ attrs ['direction' ] = DIRECTION_ANY
114+ else :
115+ msg = (_ ('Direction "any" can only be used with '
116+ '%(rule_type_min_pps)s rule type' ) %
117+ {'rule_type_min_pps' : RULE_TYPE_MINIMUM_PACKET_RATE })
118+ raise exceptions .CommandError (msg )
105119 _check_type_parameters (attrs , rule_type , is_create )
106120 return attrs
107121
@@ -160,6 +174,13 @@ def _add_rule_arguments(parser):
160174 type = int ,
161175 help = _ ('Minimum guaranteed bandwidth in kbps' )
162176 )
177+ parser .add_argument (
178+ '--min-kpps' ,
179+ dest = 'min_kpps' ,
180+ metavar = '<min-kpps>' ,
181+ type = int ,
182+ help = _ ('Minimum guaranteed packet rate in kpps' )
183+ )
163184 direction_group = parser .add_mutually_exclusive_group ()
164185 direction_group .add_argument (
165186 '--ingress' ,
@@ -171,6 +192,12 @@ def _add_rule_arguments(parser):
171192 action = 'store_true' ,
172193 help = _ ("Egress traffic direction from the project point of view" )
173194 )
195+ direction_group .add_argument (
196+ '--any' ,
197+ action = 'store_true' ,
198+ help = _ ("Any traffic direction from the project point of view. Can be "
199+ "used only with minimum packet rate rule." )
200+ )
174201
175202
176203class CreateNetworkQosRule (command .ShowOne ,
@@ -190,6 +217,7 @@ def get_parser(self, prog_name):
190217 metavar = '<type>' ,
191218 required = True ,
192219 choices = [RULE_TYPE_MINIMUM_BANDWIDTH ,
220+ RULE_TYPE_MINIMUM_PACKET_RATE ,
193221 RULE_TYPE_DSCP_MARKING ,
194222 RULE_TYPE_BANDWIDTH_LIMIT ],
195223 help = (_ ('QoS rule type (%s)' ) %
@@ -200,10 +228,10 @@ def get_parser(self, prog_name):
200228
201229 def take_action (self , parsed_args ):
202230 network_client = self .app .client_manager .network
203- attrs = _get_attrs (network_client , parsed_args , is_create = True )
204- attrs .update (
205- self ._parse_extra_properties (parsed_args .extra_properties ))
206231 try :
232+ attrs = _get_attrs (network_client , parsed_args , is_create = True )
233+ attrs .update (
234+ self ._parse_extra_properties (parsed_args .extra_properties ))
207235 obj = _rule_action_call (
208236 network_client , ACTION_CREATE , parsed_args .type )(
209237 attrs .pop ('qos_policy_id' ), ** attrs )
@@ -270,6 +298,7 @@ def take_action(self, parsed_args):
270298 'max_kbps' ,
271299 'max_burst_kbps' ,
272300 'min_kbps' ,
301+ 'min_kpps' ,
273302 'dscp_mark' ,
274303 'direction' ,
275304 )
@@ -280,6 +309,7 @@ def take_action(self, parsed_args):
280309 'Max Kbps' ,
281310 'Max Burst Kbits' ,
282311 'Min Kbps' ,
312+ 'Min Kpps' ,
283313 'DSCP mark' ,
284314 'Direction' ,
285315 )
0 commit comments