3030import com .cloud .api .response .NetworkResponse ;
3131import com .cloud .exception .ConcurrentOperationException ;
3232import com .cloud .exception .InsufficientCapacityException ;
33+ import com .cloud .exception .InvalidParameterValueException ;
3334import com .cloud .network .Network ;
3435import com .cloud .user .UserContext ;
3536
@@ -52,7 +53,7 @@ public class CreateNetworkCmd extends BaseCmd {
5253 @ Parameter (name =ApiConstants .NETWORK_OFFERING_ID , type =CommandType .LONG , required =true , description ="the network offering id" )
5354 private Long networkOfferingId ;
5455
55- @ Parameter (name =ApiConstants .ZONE_ID , type =CommandType .LONG , required = true , description ="the Zone ID for the network" )
56+ @ Parameter (name =ApiConstants .ZONE_ID , type =CommandType .LONG , description ="the Zone ID for the network" )
5657 private Long zoneId ;
5758
5859 @ Parameter (name =ApiConstants .GATEWAY , type =CommandType .STRING , description ="the gateway of the network" )
@@ -90,6 +91,9 @@ public class CreateNetworkCmd extends BaseCmd {
9091
9192 @ Parameter (name =ApiConstants .TAGS , type =CommandType .LIST , collectionType =CommandType .STRING , description ="Tag the network" )
9293 private List <String > tags ;
94+
95+ @ Parameter (name =ApiConstants .PHYSICAL_NETWORK_ID , type =CommandType .LONG , description ="the Physical Network ID the network belongs to" )
96+ private Long physicalNetworkId ;
9397
9498 /////////////////////////////////////////////////////
9599 /////////////////// Accessors ///////////////////////
@@ -102,10 +106,6 @@ public List<String> getTags() {
102106 return tags ;
103107 }
104108
105- public Long getZoneId () {
106- return zoneId ;
107- }
108-
109109 public String getGateway () {
110110 return gateway ;
111111 }
@@ -158,6 +158,16 @@ public Boolean getIsShared() {
158158 return isShared == null ? false : isShared ;
159159 }
160160
161+ public Long getPhysicalNetworkId () {
162+ if (physicalNetworkId != null ) {
163+ return physicalNetworkId ;
164+ } else if (zoneId != null ) {
165+ return _networkService .translateZoneToPhysicalNetwork (zoneId );
166+ } else {
167+ throw new InvalidParameterValueException ("Either zoneId or physicalNetworkId have to be specified" );
168+ }
169+ }
170+
161171 /////////////////////////////////////////////////////
162172 /////////////// API Implementation///////////////////
163173 /////////////////////////////////////////////////////
0 commit comments