@@ -361,13 +361,7 @@ public boolean generateVMSetupCommand(Long ssAHostId) {
361361
362362 SecStorageVMSetupCommand setupCmd = new SecStorageVMSetupCommand ();
363363 if (_allowedInternalSites != null ) {
364- List <String > allowedCidrs = new ArrayList <>();
365- String [] cidrs = _allowedInternalSites .split ("," );
366- for (String cidr : cidrs ) {
367- if (NetUtils .isValidIp4Cidr (cidr ) || NetUtils .isValidIp4 (cidr ) || !cidr .startsWith ("0.0.0.0" )) {
368- allowedCidrs .add (cidr );
369- }
370- }
364+ List <String > allowedCidrs = getAllowedInternalSiteCidrs ();
371365 setupCmd .setAllowedInternalSites (allowedCidrs .toArray (new String [allowedCidrs .size ()]));
372366 }
373367 String copyPasswd = _configDao .getValue ("secstorage.copy.password" );
@@ -388,6 +382,20 @@ public boolean generateVMSetupCommand(Long ssAHostId) {
388382 }
389383 }
390384
385+ private List <String > getAllowedInternalSiteCidrs () {
386+ List <String > allowedCidrs = new ArrayList <>();
387+ if (_allowedInternalSites == null ) {
388+ return allowedCidrs ;
389+ }
390+ String [] cidrs = _allowedInternalSites .split ("," );
391+ for (String cidr : cidrs ) {
392+ if (NetUtils .isValidIp4Cidr (cidr ) || NetUtils .isValidIp4 (cidr ) || !cidr .startsWith ("0.0.0.0" )) {
393+ allowedCidrs .add (cidr );
394+ }
395+ }
396+ return allowedCidrs ;
397+ }
398+
391399 @ Override
392400 public Pair <HostVO , SecondaryStorageVmVO > assignSecStorageVm (long zoneId , Command cmd ) {
393401 return null ;
@@ -412,6 +420,9 @@ public boolean generateFirewallConfiguration(Long ssAHostId) {
412420 SecStorageFirewallCfgCommand thiscpc = new SecStorageFirewallCfgCommand (true );
413421 thiscpc .addPortConfig (thisSecStorageVm .getPublicIpAddress (), copyPort , true , TemplateConstants .DEFAULT_TMPLT_COPY_INTF );
414422
423+ List <String > allowedCidrs = getAllowedInternalSiteCidrs ();
424+ addPortConfigForPrivateIpToCommand (thiscpc , allowedCidrs , thisSecStorageVm .getPrivateIpAddress (), thisSecStorageVm .getPublicIpAddress (), copyPort );
425+
415426 QueryBuilder <HostVO > sc = QueryBuilder .create (HostVO .class );
416427 sc .and (sc .entity ().getType (), Op .EQ , Host .Type .SecondaryStorageVM );
417428 sc .and (sc .entity ().getStatus (), Op .IN , Status .Up , Status .Connecting );
@@ -441,6 +452,7 @@ public boolean generateFirewallConfiguration(Long ssAHostId) {
441452 continue ;
442453 }
443454 allSSVMIpList .addPortConfig (ssvm .getPublicIpAddress (), copyPort , true , TemplateConstants .DEFAULT_TMPLT_COPY_INTF );
455+ addPortConfigForPrivateIpToCommand (allSSVMIpList , allowedCidrs , ssvm .getPrivateIpAddress (), ssvm .getPublicIpAddress (), copyPort );
444456 }
445457
446458 hostName = thisSecStorageVm .getHostName ();
@@ -461,6 +473,16 @@ public boolean generateFirewallConfiguration(Long ssAHostId) {
461473
462474 }
463475
476+ private void addPortConfigForPrivateIpToCommand (SecStorageFirewallCfgCommand command , List <String > allowedCidrs ,
477+ String privateIpAddress , String publicIpAddress , String copyPort ) {
478+ for (String allowCidr : allowedCidrs ) {
479+ if (NetUtils .isIpWithInCidrRange (publicIpAddress , allowCidr )) {
480+ command .addPortConfig (privateIpAddress , copyPort , true , TemplateConstants .TMPLT_COPY_INTF_PRIVATE );
481+ break ;
482+ }
483+ }
484+ }
485+
464486 protected boolean isSecondaryStorageVmRequired (long dcId ) {
465487 DataCenterVO dc = _dcDao .findById (dcId );
466488 _dcDao .loadDetails (dc );
0 commit comments