@@ -188,6 +188,21 @@ protected boolean isValidProtocolAndVnetId(final String vNetId, final String pro
188188 return vNetId != null && protocol != null && !vNetId .equalsIgnoreCase ("untagged" );
189189 }
190190
191+ protected String createStorageVnetBridgeIfNeeded (NicTO nic , String trafficLabel ,
192+ String storageBrName ) throws InternalErrorException {
193+ if (!Networks .BroadcastDomainType .Storage .equals (nic .getBroadcastType ()) || nic .getBroadcastUri () == null ) {
194+ return storageBrName ;
195+ }
196+ String vNetId = Networks .BroadcastDomainType .getValue (nic .getBroadcastUri ());
197+ String protocol = Networks .BroadcastDomainType .Vlan .scheme ();
198+ if (!isValidProtocolAndVnetId (vNetId , protocol )) {
199+ return storageBrName ;
200+ }
201+ logger .debug (String .format ("creating a vNet dev and bridge for %s traffic per traffic label %s" ,
202+ Networks .TrafficType .Storage .name (), trafficLabel ));
203+ return createVnetBr (vNetId , storageBrName , protocol );
204+ }
205+
191206 @ Override
192207 public LibvirtVMDef .InterfaceDef plug (NicTO nic , String guestOsType , String nicAdapter , Map <String , String > extraConfig ) throws InternalErrorException , LibvirtException {
193208
@@ -254,15 +269,7 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
254269 intf .defBridgeNet (_bridges .get ("private" ), null , nic .getMac (), getGuestNicModel (guestOsType , nicAdapter ));
255270 } else if (nic .getType () == Networks .TrafficType .Storage ) {
256271 String storageBrName = nic .getName () == null ? _bridges .get ("private" ) : nic .getName ();
257- if (nic .getBroadcastType () == Networks .BroadcastDomainType .Storage ) {
258- vNetId = Networks .BroadcastDomainType .getValue (nic .getBroadcastUri ());
259- protocol = Networks .BroadcastDomainType .Vlan .scheme ();
260- }
261- if (isValidProtocolAndVnetId (vNetId , protocol )) {
262- logger .debug (String .format ("creating a vNet dev and bridge for %s traffic per traffic label %s" ,
263- Networks .TrafficType .Storage .name (), trafficLabel ));
264- storageBrName = createVnetBr (vNetId , storageBrName , protocol );
265- }
272+ storageBrName = createStorageVnetBridgeIfNeeded (nic , trafficLabel , storageBrName );
266273 intf .defBridgeNet (storageBrName , null , nic .getMac (), getGuestNicModel (guestOsType , nicAdapter ));
267274 }
268275 if (nic .getPxeDisable ()) {
@@ -295,7 +302,7 @@ private String generateVxnetBrName(String pifName, String vnetId) {
295302 return "brvx-" + vnetId ;
296303 }
297304
298- private String createVnetBr (String vNetId , String pifKey , String protocol ) throws InternalErrorException {
305+ protected String createVnetBr (String vNetId , String pifKey , String protocol ) throws InternalErrorException {
299306 String nic = _pifs .get (pifKey );
300307 if (nic == null || isVxlanOrNetris (protocol )) {
301308 // if not found in bridge map, maybe traffic label refers to pif already?
0 commit comments