@@ -961,27 +961,12 @@ public void validateNtkwOffForVpc(long ntwkOffId, String cidr, String networkDom
961961 //1) Validate attributes that has to be passed in when create new guest network
962962 validateNewVpcGuestNetwork (cidr , gateway , networkOwner , vpc , networkDomain );
963963 }
964-
965- //2) Only Isolated networks with Source nat service enabled can be added to vpc
966- if (!(guestNtwkOff .getGuestType () == GuestType .Isolated
967- && _ntwkMgr .areServicesSupportedByNetworkOffering (guestNtwkOff .getId (), Service .SourceNat ))) {
968-
969- throw new InvalidParameterValueException ("Only networks of type " + GuestType .Isolated + " with service "
970- + Service .SourceNat + " can be added as a part of VPC" );
971964
972- }
973-
974- //3) No redundant router support
975- if (guestNtwkOff .getRedundantRouter ()) {
976- throw new InvalidParameterValueException ("No redunant router support when network belnogs to VPC" );
977- }
978-
979- //4) Conserve mode should be off
980- if (guestNtwkOff .isConserveMode ()) {
981- throw new InvalidParameterValueException ("Only networks with conserve mode Off can belong to VPC" );
982- }
983-
984- //5) Check services/providers against VPC providers
965+ //2) validate network offering attributes
966+ List <Service > svcs = _ntwkMgr .listNetworkOfferingServices (guestNtwkOff .getId ());
967+ validateNtwkOffForVpc (guestNtwkOff , svcs );
968+
969+ //3) Check services/providers against VPC providers
985970 List <NetworkOfferingServiceMapVO > networkProviders = _ntwkOffServiceDao .listByNetworkOfferingId (guestNtwkOff .getId ());
986971
987972 for (NetworkOfferingServiceMapVO nSvcVO : networkProviders ) {
@@ -992,8 +977,8 @@ public void validateNtkwOffForVpc(long ntwkOffId, String cidr, String networkDom
992977 pr + " is not supported by VPC " + vpc );
993978 }
994979 }
995-
996- //6 ) Only one network in the VPC can support LB
980+
981+ //4 ) Only one network in the VPC can support LB
997982 if (_ntwkMgr .areServicesSupportedByNetworkOffering (guestNtwkOff .getId (), Service .Lb )) {
998983 List <? extends Network > networks = getVpcNetworks (vpc .getId ());
999984 for (Network network : networks ) {
@@ -1010,6 +995,37 @@ public void validateNtkwOffForVpc(long ntwkOffId, String cidr, String networkDom
1010995 }
1011996 }
1012997
998+ @ Override
999+ public void validateNtwkOffForVpc (NetworkOffering guestNtwkOff , List <Service > supportedSvcs ) {
1000+ //1) in current release, only vpc provider is supported by Vpc offering
1001+ List <Provider > providers = _ntwkMgr .getNtwkOffDistinctProviders (guestNtwkOff .getId ());
1002+ for (Provider provider : providers ) {
1003+ if (provider != Provider .VPCVirtualRouter ) {
1004+ throw new InvalidParameterValueException ("Only provider of type " + Provider .VPCVirtualRouter .getName ()
1005+ + " is supported for network offering that can be used in VPC" );
1006+ }
1007+ }
1008+
1009+ //2) Only Isolated networks with Source nat service enabled can be added to vpc
1010+ if (!(guestNtwkOff .getGuestType () == GuestType .Isolated
1011+ && supportedSvcs .contains (Service .SourceNat ))) {
1012+
1013+ throw new InvalidParameterValueException ("Only network offerings of type " + GuestType .Isolated + " with service "
1014+ + Service .SourceNat .getName () +
1015+ " are valid for vpc " );
1016+ }
1017+
1018+ //3) No redundant router support
1019+ if (guestNtwkOff .getRedundantRouter ()) {
1020+ throw new InvalidParameterValueException ("No redunant router support when network belnogs to VPC" );
1021+ }
1022+
1023+ //4) Conserve mode should be off
1024+ if (guestNtwkOff .isConserveMode ()) {
1025+ throw new InvalidParameterValueException ("Only networks with conserve mode Off can belong to VPC" );
1026+ }
1027+ }
1028+
10131029 @ DB
10141030 protected void validateNewVpcGuestNetwork (String cidr , String gateway , Account networkOwner , Vpc vpc , String networkDomain ) {
10151031
0 commit comments