11// Licensed to the Apache Software Foundation (ASF) under one
2- // or more contributor license agreements. See the NOTICE file
2+ // or more contributor license agreements. See the NOTICE file
33// distributed with this work for additional information
4- // regarding copyright ownership. The ASF licenses this file
4+ // regarding copyright ownership. The ASF licenses this file
55// to you under the Apache License, Version 2.0 (the
66// "License"); you may not use this file except in compliance
7- // with the License. You may obtain a copy of the License at
7+ // with the License. You may obtain a copy of the License at
88//
99// http://www.apache.org/licenses/LICENSE-2.0
1010//
1111// Unless required by applicable law or agreed to in writing,
1212// software distributed under the License is distributed on an
1313// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14- // KIND, either express or implied. See the License for the
14+ // KIND, either express or implied. See the License for the
1515// specific language governing permissions and limitations
1616// under the License.
1717package com .cloud .network ;
@@ -34,30 +34,22 @@ public class VmwareTrafficLabel implements TrafficLabel {
3434 VirtualSwitchType _vSwitchType = VirtualSwitchType .StandardVirtualSwitch ;
3535 String _vSwitchName = DEFAULT_VSWITCH_NAME ;
3636 String _vlanId = Vlan .UNTAGGED ;
37+ boolean _isPrimaryNic = true ; // Flag to identify if this is a primary NIC
38+ int _rateLimit = 1000 ; // Default rate limit in Mbps
39+ int _guaranteedBandwidth = 500 ; // Default guaranteed bandwidth in Mbps
3740
38- public VmwareTrafficLabel (String networkLabel , TrafficType trafficType , VirtualSwitchType defVswitchType ) {
41+ public VmwareTrafficLabel (String networkLabel , TrafficType trafficType , VirtualSwitchType defVswitchType , boolean isPrimaryNic ) {
3942 _trafficType = trafficType ;
43+ _isPrimaryNic = isPrimaryNic ;
4044 _parseLabel (networkLabel , defVswitchType );
4145 }
4246
43- public VmwareTrafficLabel (String networkLabel , TrafficType trafficType ) {
47+ public VmwareTrafficLabel (String networkLabel , TrafficType trafficType , boolean isPrimaryNic ) {
4448 _trafficType = trafficType ;
49+ _isPrimaryNic = isPrimaryNic ;
4550 _parseLabel (networkLabel , VirtualSwitchType .StandardVirtualSwitch );
4651 }
4752
48- public VmwareTrafficLabel (TrafficType trafficType , VirtualSwitchType defVswitchType ) {
49- _trafficType = trafficType ;
50- _parseLabel (null , defVswitchType );
51- }
52-
53- public VmwareTrafficLabel (TrafficType trafficType ) {
54- _trafficType = trafficType ;
55- _parseLabel (null , VirtualSwitchType .StandardVirtualSwitch );
56- }
57-
58- public VmwareTrafficLabel () {
59- }
60-
6153 private void _parseLabel (String networkLabel , VirtualSwitchType defVswitchType ) {
6254 // Set defaults for label in case of distributed vSwitch
6355 if (defVswitchType .equals (VirtualSwitchType .VMwareDistributedVirtualSwitch )) {
@@ -91,6 +83,20 @@ private void _parseLabel(String networkLabel, VirtualSwitchType defVswitchType)
9183 }
9284 }
9385
86+ public void applyTrafficShaping () {
87+ // Ensure traffic shaping is applied to secondary NICs
88+ if (!_isPrimaryNic ) {
89+ // Apply lower rate limits or minimum bandwidth guarantees for secondary NICs
90+ System .out .println ("Applying traffic shaping to secondary NIC:" );
91+ System .out .println ("Rate Limit: " + _rateLimit + " Mbps" );
92+ System .out .println ("Guaranteed Bandwidth: " + _guaranteedBandwidth + " Mbps" );
93+ } else {
94+ // For primary NIC, apply normal rate limits
95+ System .out .println ("Applying traffic shaping to primary NIC:" );
96+ System .out .println ("Rate Limit: " + _rateLimit + " Mbps" );
97+ }
98+ }
99+
94100 @ Override
95101 public TrafficType getTrafficType () {
96102 return _trafficType ;
0 commit comments