mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	1) Implemented create/list/deleteNetworkOffering create/delete/listNetwork APIs.
2) Added networkIds parameter to deployVMCmd - accepts list of networks ids separated by coma. 3) Changed domainRouter/systemVm/userVm response to return list of Nics associated with the vm.
This commit is contained in:
		
							parent
							
								
									3f5b1e4c0e
								
							
						
					
					
						commit
						f8a687ab23
					
				| @ -86,6 +86,7 @@ public class ApiConstants { | |||||||
|     public static final String IS_PUBLIC = "ispublic"; |     public static final String IS_PUBLIC = "ispublic"; | ||||||
|     public static final String IS_READY = "isready"; |     public static final String IS_READY = "isready"; | ||||||
|     public static final String IS_RECURSIVE = "isrecursive"; |     public static final String IS_RECURSIVE = "isrecursive"; | ||||||
|  |     public static final String IS_SHARED = "isshared"; | ||||||
|     public static final String ISO_FILTER = "isofilter"; |     public static final String ISO_FILTER = "isofilter"; | ||||||
|     public static final String JOB_ID = "jobid"; |     public static final String JOB_ID = "jobid"; | ||||||
|     public static final String JOB_STATUS = "jobstatus"; |     public static final String JOB_STATUS = "jobstatus"; | ||||||
| @ -165,4 +166,11 @@ public class ApiConstants { | |||||||
|     public static final String NETWORK_TYPE = "networktype"; |     public static final String NETWORK_TYPE = "networktype"; | ||||||
|     public static final String PAGE = "page"; |     public static final String PAGE = "page"; | ||||||
|     public static final String PAGE_SIZE = "pagesize"; |     public static final String PAGE_SIZE = "pagesize"; | ||||||
|  |     public static final String TRAFFIC_TYPE = "traffictype"; | ||||||
|  |     public static final String MAX_CONNECTIONS = "maxconnections"; | ||||||
|  |     public static final String NETWORK_OFFERING_ID = "networkofferingid"; | ||||||
|  |     public static final String NETWORK_IDS = "networkids"; | ||||||
|  |     public static final String SPECIFY_VLAN = "specifyvlan"; | ||||||
|  |     public static final String IS_DEFAULT = "isdefault"; | ||||||
| } | } | ||||||
|  |   | ||||||
|  | |||||||
| @ -40,6 +40,8 @@ import com.cloud.api.response.IpForwardingRuleResponse; | |||||||
| import com.cloud.api.response.ListResponse; | import com.cloud.api.response.ListResponse; | ||||||
| import com.cloud.api.response.LoadBalancerResponse; | import com.cloud.api.response.LoadBalancerResponse; | ||||||
| import com.cloud.api.response.NetworkGroupResponse; | import com.cloud.api.response.NetworkGroupResponse; | ||||||
|  | import com.cloud.api.response.NetworkOfferingResponse; | ||||||
|  | import com.cloud.api.response.NetworkResponse; | ||||||
| import com.cloud.api.response.PodResponse; | import com.cloud.api.response.PodResponse; | ||||||
| import com.cloud.api.response.PreallocatedLunResponse; | import com.cloud.api.response.PreallocatedLunResponse; | ||||||
| import com.cloud.api.response.RemoteAccessVpnResponse; | import com.cloud.api.response.RemoteAccessVpnResponse; | ||||||
| @ -69,6 +71,7 @@ import com.cloud.event.Event; | |||||||
| import com.cloud.host.Host; | import com.cloud.host.Host; | ||||||
| import com.cloud.network.IpAddress; | import com.cloud.network.IpAddress; | ||||||
| import com.cloud.network.LoadBalancer; | import com.cloud.network.LoadBalancer; | ||||||
|  | import com.cloud.network.Network; | ||||||
| import com.cloud.network.RemoteAccessVpn; | import com.cloud.network.RemoteAccessVpn; | ||||||
| import com.cloud.network.VpnUser; | import com.cloud.network.VpnUser; | ||||||
| import com.cloud.network.router.VirtualRouter; | import com.cloud.network.router.VirtualRouter; | ||||||
| @ -77,6 +80,7 @@ import com.cloud.network.security.IngressRule; | |||||||
| import com.cloud.network.security.NetworkGroup; | import com.cloud.network.security.NetworkGroup; | ||||||
| import com.cloud.network.security.NetworkGroupRules; | import com.cloud.network.security.NetworkGroupRules; | ||||||
| import com.cloud.offering.DiskOffering; | import com.cloud.offering.DiskOffering; | ||||||
|  | import com.cloud.offering.NetworkOffering; | ||||||
| import com.cloud.offering.ServiceOffering; | import com.cloud.offering.ServiceOffering; | ||||||
| import com.cloud.org.Cluster; | import com.cloud.org.Cluster; | ||||||
| import com.cloud.storage.Snapshot; | import com.cloud.storage.Snapshot; | ||||||
| @ -201,5 +205,9 @@ public interface ResponseGenerator { | |||||||
|     TemplatePermissionsResponse createTemplatePermissionsResponse(List<String> accountNames, Long id, boolean isAdmin); |     TemplatePermissionsResponse createTemplatePermissionsResponse(List<String> accountNames, Long id, boolean isAdmin); | ||||||
| 
 | 
 | ||||||
|     AsyncJobResponse queryJobResult(QueryAsyncJobResultCmd cmd); |     AsyncJobResponse queryJobResult(QueryAsyncJobResultCmd cmd); | ||||||
|  |      | ||||||
|  |     NetworkOfferingResponse createNetworkOfferingResponse(NetworkOffering offering); | ||||||
|  |      | ||||||
|  |     NetworkResponse createNetworkResponse(Network network); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										155
									
								
								api/src/com/cloud/api/commands/CreateNetworkCmd.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								api/src/com/cloud/api/commands/CreateNetworkCmd.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,155 @@ | |||||||
|  | /** | ||||||
|  |  *  Copyright (C) 2010 Cloud.com, Inc.  All rights reserved. | ||||||
|  |  *  | ||||||
|  |  * This software is licensed under the GNU General Public License v3 or later. | ||||||
|  |  *  | ||||||
|  |  * It is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or any later version. | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  *  | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  *  | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.cloud.api.commands; | ||||||
|  | 
 | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | 
 | ||||||
|  | import com.cloud.api.ApiConstants; | ||||||
|  | import com.cloud.api.BaseCmd; | ||||||
|  | import com.cloud.api.Implementation; | ||||||
|  | import com.cloud.api.Parameter; | ||||||
|  | import com.cloud.api.ServerApiException; | ||||||
|  | import com.cloud.api.response.NetworkResponse; | ||||||
|  | import com.cloud.network.Network; | ||||||
|  | 
 | ||||||
|  | @Implementation(description="Creates a network", responseObject=NetworkResponse.class) | ||||||
|  | public class CreateNetworkCmd extends BaseCmd { | ||||||
|  |     public static final Logger s_logger = Logger.getLogger(CreateNetworkCmd.class.getName()); | ||||||
|  | 
 | ||||||
|  |     private static final String s_name = "createnetworkresponse"; | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     //////////////// API parameters ///////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network")    | ||||||
|  |     private String name; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network")    | ||||||
|  |     private String displayText; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.NETWORK_OFFERING_ID, type=CommandType.LONG, required=true, description="the network offering id") | ||||||
|  |     private Long networkOfferingId; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the Vlan ip range") | ||||||
|  |     private Long zoneId; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID for the Vlan ip range") | ||||||
|  |     private Long podId; | ||||||
|  | 
 | ||||||
|  |     @Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway of the VLAN IP range") | ||||||
|  |     private String gateway; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, description="the cidr of the VLAN IP range") | ||||||
|  |     private String cidr; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the VLAN IP range") | ||||||
|  |     private String netmask; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, description="the beginning IP address in the VLAN IP range") | ||||||
|  |     private String startIp; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the VLAN IP range") | ||||||
|  |     private String endIp; | ||||||
|  | 
 | ||||||
|  |     @Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the VLAN. Default is an \"untagged\" VLAN.") | ||||||
|  |     private String vlan; | ||||||
|  | 
 | ||||||
|  |     @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the VLAN. If VLAN is Zone wide, this parameter should be ommited") | ||||||
|  |     private String accountName; | ||||||
|  | 
 | ||||||
|  |     @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a VLAN") | ||||||
|  |     private Long domainId; | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////////// Accessors /////////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     public Long getNetworkOfferingId() { | ||||||
|  |         return networkOfferingId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getZoneId() { | ||||||
|  |         return zoneId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getPodId() { | ||||||
|  |         return podId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getGateway() { | ||||||
|  |         return gateway; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getCidr() { | ||||||
|  |         return cidr; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getVlan() { | ||||||
|  |         return vlan; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getAccountName() { | ||||||
|  |         return accountName; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getDomainId() { | ||||||
|  |         return domainId; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public String getNetmask() { | ||||||
|  |         return netmask; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getStartIp() { | ||||||
|  |         return startIp; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getEndIp() { | ||||||
|  |         return endIp; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public String getNetworkName() { | ||||||
|  |         return name; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public String getDisplayText() { | ||||||
|  |         return displayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////// API Implementation/////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String getName() { | ||||||
|  |         return s_name; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public void execute(){ | ||||||
|  |         Network result = _networkService.createNetwork(this); | ||||||
|  |         if (result != null) { | ||||||
|  |             NetworkResponse response = _responseGenerator.createNetworkResponse(result); | ||||||
|  |             response.setResponseName(getName()); | ||||||
|  |             this.setResponseObject(response); | ||||||
|  |         }else { | ||||||
|  |             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create network"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										119
									
								
								api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,119 @@ | |||||||
|  | /** | ||||||
|  |  *  Copyright (C) 2010 Cloud.com, Inc.  All rights reserved. | ||||||
|  |  *  | ||||||
|  |  * This software is licensed under the GNU General Public License v3 or later. | ||||||
|  |  *  | ||||||
|  |  * It is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or any later version. | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  *  | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  *  | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.cloud.api.commands; | ||||||
|  | 
 | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | 
 | ||||||
|  | import com.cloud.api.ApiConstants; | ||||||
|  | import com.cloud.api.BaseCmd; | ||||||
|  | import com.cloud.api.Implementation; | ||||||
|  | import com.cloud.api.Parameter; | ||||||
|  | import com.cloud.api.ServerApiException; | ||||||
|  | import com.cloud.api.response.NetworkOfferingResponse; | ||||||
|  | import com.cloud.offering.NetworkOffering; | ||||||
|  | 
 | ||||||
|  | @Implementation(description="Creates a network offering.", responseObject=NetworkOfferingResponse.class) | ||||||
|  | public class CreateNetworkOfferingCmd extends BaseCmd { | ||||||
|  |     public static final Logger s_logger = Logger.getLogger(CreateNetworkOfferingCmd.class.getName()); | ||||||
|  |     private static final String _name = "createnetworkofferingresponse"; | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     //////////////// API parameters ///////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network offering") | ||||||
|  |     private String networkOfferingName; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network offering") | ||||||
|  |     private String displayText; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, required=true, description="type of the network. Supported types Virtualized, DirectSingle, DirectDual") | ||||||
|  |     private String type; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, required=true, description="the traffic type for the network offering, supported types are Public, Management, Control, Guest, Vlan or Storage.") | ||||||
|  |     private String traffictype; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.MAX_CONNECTIONS, type=CommandType.INTEGER, description="maximum number of concurrent connections supported by the network offering") | ||||||
|  |     private Integer maxConnections; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for the network offering.") | ||||||
|  |     private String tags;  | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.SPECIFY_VLAN, type=CommandType.BOOLEAN, description="true is network offering supports vlans") | ||||||
|  |     private Boolean specifyVlan;  | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network offering supports vlans") | ||||||
|  |     private Boolean isShared;  | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////////// Accessors /////////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |      | ||||||
|  |     public String getNetworkOfferingName() { | ||||||
|  |         return networkOfferingName; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public String getDisplayText() { | ||||||
|  |         return displayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getTags() { | ||||||
|  |         return tags; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getType() { | ||||||
|  |         return type; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getTraffictype() { | ||||||
|  |         return traffictype; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Integer getMaxconnections() { | ||||||
|  |         return maxConnections; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public Boolean getSpecifyVlan() { | ||||||
|  |         return specifyVlan; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public Boolean getIsShared() { | ||||||
|  |         return isShared; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////// API Implementation/////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     @Override | ||||||
|  |     public String getName() { | ||||||
|  |         return _name; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void execute(){ | ||||||
|  |         NetworkOffering result = _configService.createNetworkOffering(this); | ||||||
|  |         if (result != null) { | ||||||
|  |             NetworkOfferingResponse response = _responseGenerator.createNetworkOfferingResponse(result); | ||||||
|  |             response.setResponseName(getName()); | ||||||
|  |             this.setResponseObject(response); | ||||||
|  |         } else { | ||||||
|  |             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create network offering"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -49,8 +49,8 @@ public class CreateVlanIpRangeCmd extends BaseCmd { | |||||||
|     @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the VLAN IP range") |     @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the VLAN IP range") | ||||||
|     private String endIp; |     private String endIp; | ||||||
| 
 | 
 | ||||||
|     @Parameter(name=ApiConstants.FOR_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="true if VLAN is of Virtual type, false if Direct") | //    @Parameter(name=ApiConstants.FOR_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="true if VLAN is of Virtual type, false if Direct") | ||||||
|     private Boolean forVirtualNetwork; | //    private Boolean forVirtualNetwork; | ||||||
| 
 | 
 | ||||||
|     @Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway of the VLAN IP range") |     @Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway of the VLAN IP range") | ||||||
|     private String gateway; |     private String gateway; | ||||||
| @ -86,9 +86,9 @@ public class CreateVlanIpRangeCmd extends BaseCmd { | |||||||
|         return endIp; |         return endIp; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Boolean isForVirtualNetwork() { | //    public Boolean isForVirtualNetwork() { | ||||||
|         return forVirtualNetwork; | //        return forVirtualNetwork; | ||||||
|     } | //    } | ||||||
| 
 | 
 | ||||||
|     public String getGateway() { |     public String getGateway() { | ||||||
|         return gateway; |         return gateway; | ||||||
|  | |||||||
							
								
								
									
										71
									
								
								api/src/com/cloud/api/commands/DeleteNetworkCmd.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								api/src/com/cloud/api/commands/DeleteNetworkCmd.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,71 @@ | |||||||
|  | /** | ||||||
|  |  *  Copyright (C) 2010 Cloud.com, Inc.  All rights reserved. | ||||||
|  |  *  | ||||||
|  |  * This software is licensed under the GNU General Public License v3 or later. | ||||||
|  |  *  | ||||||
|  |  * It is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or any later version. | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  *  | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  *  | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.cloud.api.commands; | ||||||
|  | 
 | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | 
 | ||||||
|  | import com.cloud.api.ApiConstants; | ||||||
|  | import com.cloud.api.BaseCmd; | ||||||
|  | import com.cloud.api.Implementation; | ||||||
|  | import com.cloud.api.Parameter; | ||||||
|  | import com.cloud.api.ServerApiException; | ||||||
|  | import com.cloud.api.response.SuccessResponse; | ||||||
|  | 
 | ||||||
|  | @Implementation(description="Deletes a network", responseObject=SuccessResponse.class) | ||||||
|  | public class DeleteNetworkCmd extends BaseCmd{ | ||||||
|  |     public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName()); | ||||||
|  |     private static final String s_name = "deletenetworkresponse"; | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     //////////////// API parameters ///////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network") | ||||||
|  |     private Long id; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////////// Accessors /////////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     public Long getId() { | ||||||
|  |         return id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////// API Implementation/////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String getName() { | ||||||
|  |         return s_name; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public void execute(){ | ||||||
|  |         boolean result = _networkService.deleteNetwork(this); | ||||||
|  |         if (result) { | ||||||
|  |             SuccessResponse response = new SuccessResponse(getName()); | ||||||
|  |             this.setResponseObject(response); | ||||||
|  |         } else { | ||||||
|  |             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										71
									
								
								api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								api/src/com/cloud/api/commands/DeleteNetworkOfferingCmd.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,71 @@ | |||||||
|  | /** | ||||||
|  |  *  Copyright (C) 2010 Cloud.com, Inc.  All rights reserved. | ||||||
|  |  *  | ||||||
|  |  * This software is licensed under the GNU General Public License v3 or later. | ||||||
|  |  *  | ||||||
|  |  * It is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or any later version. | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  *  | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  *  | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.cloud.api.commands; | ||||||
|  | 
 | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | 
 | ||||||
|  | import com.cloud.api.ApiConstants; | ||||||
|  | import com.cloud.api.BaseCmd; | ||||||
|  | import com.cloud.api.Implementation; | ||||||
|  | import com.cloud.api.Parameter; | ||||||
|  | import com.cloud.api.ServerApiException; | ||||||
|  | import com.cloud.api.response.SuccessResponse; | ||||||
|  | 
 | ||||||
|  | @Implementation(description="Deletes a network offering.", responseObject=SuccessResponse.class) | ||||||
|  | public class DeleteNetworkOfferingCmd extends BaseCmd{ | ||||||
|  |     public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName()); | ||||||
|  |     private static final String s_name = "deletenetworkofferingresponse"; | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     //////////////// API parameters ///////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network offering") | ||||||
|  |     private Long id; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////////// Accessors /////////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     public Long getId() { | ||||||
|  |         return id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////// API Implementation/////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String getName() { | ||||||
|  |         return s_name; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public void execute(){ | ||||||
|  |         boolean result = _configService.deleteNetworkOffering(this); | ||||||
|  |         if (result) { | ||||||
|  |             SuccessResponse response = new SuccessResponse(getName()); | ||||||
|  |             this.setResponseObject(response); | ||||||
|  |         } else { | ||||||
|  |             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -84,6 +84,9 @@ public class DeployVMCmd extends BaseAsyncCmd { | |||||||
| 
 | 
 | ||||||
|     @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="availability zone for the virtual machine") |     @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="availability zone for the virtual machine") | ||||||
|     private Long zoneId; |     private Long zoneId; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.NETWORK_IDS, type=CommandType.LIST, collectionType=CommandType.LONG) | ||||||
|  |     private List<Long> networkIds; | ||||||
| 
 | 
 | ||||||
|     // unexposed parameter needed for serializing/deserializing the command |     // unexposed parameter needed for serializing/deserializing the command | ||||||
|     @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, expose=false) |     @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, expose=false) | ||||||
| @ -149,11 +152,19 @@ public class DeployVMCmd extends BaseAsyncCmd { | |||||||
|     public void setPassword(String password) { |     public void setPassword(String password) { | ||||||
|         this.password = password; |         this.password = password; | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     public List<Long> getNetworkIds() { | ||||||
|  |         return networkIds; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNetworkList(List<Long> networkIds) { | ||||||
|  |         this.networkIds = networkIds; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     ///////////////////////////////////////////////////// |     ///////////////////////////////////////////////////// | ||||||
|     /////////////// API Implementation/////////////////// |     /////////////// API Implementation/////////////////// | ||||||
|     ///////////////////////////////////////////////////// |     ///////////////////////////////////////////////////// | ||||||
|      | 
 | ||||||
|     @Override |     @Override | ||||||
|     public String getName() { |     public String getName() { | ||||||
|         return s_name; |         return s_name; | ||||||
| @ -216,12 +227,16 @@ public class DeployVMCmd extends BaseAsyncCmd { | |||||||
|                 throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to deploy vm"); |                 throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to deploy vm"); | ||||||
|             } |             } | ||||||
|         } catch (ResourceAllocationException ex) { |         } catch (ResourceAllocationException ex) { | ||||||
|  |             s_logger.warn("Exception: ", ex); | ||||||
|             throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, ex.getMessage()); |             throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, ex.getMessage()); | ||||||
|         } catch (InsufficientStorageCapacityException ex) { |         } catch (InsufficientStorageCapacityException ex) { | ||||||
|  |             s_logger.warn("Exception: ", ex); | ||||||
|             throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); |             throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); | ||||||
|         } catch (StorageUnavailableException ex) { |         } catch (StorageUnavailableException ex) { | ||||||
|  |             s_logger.warn("Exception: ", ex); | ||||||
|             throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); |             throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); | ||||||
|         } catch (Exception ex) { |         } catch (Exception ex) { | ||||||
|  |             s_logger.warn("Exception: ", ex); | ||||||
|             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); |             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
							
								
								
									
										125
									
								
								api/src/com/cloud/api/commands/ListNetworkOfferingsCmd.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								api/src/com/cloud/api/commands/ListNetworkOfferingsCmd.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,125 @@ | |||||||
|  | /** | ||||||
|  |  *  Copyright (C) 2010 Cloud.com, Inc.  All rights reserved. | ||||||
|  |  *  | ||||||
|  |  * This software is licensed under the GNU General Public License v3 or later. | ||||||
|  |  *  | ||||||
|  |  * It is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or any later version. | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  *  | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  *  | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.cloud.api.commands; | ||||||
|  | 
 | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | 
 | ||||||
|  | import com.cloud.api.ApiConstants; | ||||||
|  | import com.cloud.api.BaseListCmd; | ||||||
|  | import com.cloud.api.Implementation; | ||||||
|  | import com.cloud.api.Parameter; | ||||||
|  | import com.cloud.api.response.ListResponse; | ||||||
|  | import com.cloud.api.response.NetworkOfferingResponse; | ||||||
|  | import com.cloud.offering.NetworkOffering; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @Implementation(description="Lists all available network offerings.", responseObject=NetworkOfferingResponse.class) | ||||||
|  | public class ListNetworkOfferingsCmd extends BaseListCmd { | ||||||
|  |     public static final Logger s_logger = Logger.getLogger(ListNetworkOfferingsCmd.class.getName()); | ||||||
|  |     private static final String _name = "listnetworkofferingsresponse"; | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     //////////////// API parameters ///////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list network offerings by id") | ||||||
|  |     private Long id; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list network offerings by name") | ||||||
|  |     private String networkOfferingName; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="list network offerings by display text") | ||||||
|  |     private String displayText; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="list by type of the network") | ||||||
|  |     private String type; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="list by traffic type") | ||||||
|  |     private String trafficType; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if need to list only default network offerings. Default value is false") | ||||||
|  |     private Boolean isDefault;  | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.SPECIFY_VLAN, type=CommandType.BOOLEAN, description="the tags for the network offering.") | ||||||
|  |     private Boolean specifyVlan; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network offering supports vlans") | ||||||
|  |     private Boolean isShared;  | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////////// Accessors /////////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |      | ||||||
|  |     public String getNetworkOfferingName() { | ||||||
|  |         return networkOfferingName; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public String getDisplayText() { | ||||||
|  |         return displayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getType() { | ||||||
|  |         return type; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getTrafficType() { | ||||||
|  |         return trafficType; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getId() { | ||||||
|  |         return id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Boolean getIsDefault() { | ||||||
|  |         return isDefault; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public Boolean getSpecifyVlan() { | ||||||
|  |         return specifyVlan; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Boolean getIsShared() { | ||||||
|  |         return isShared; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////// API Implementation/////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     @Override | ||||||
|  |     public String getName() { | ||||||
|  |         return _name; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void execute(){ | ||||||
|  |         List<? extends NetworkOffering> offerings = _configService.searchForNetworkOfferings(this); | ||||||
|  |         ListResponse<NetworkOfferingResponse> response = new ListResponse<NetworkOfferingResponse>(); | ||||||
|  |         List<NetworkOfferingResponse> offeringResponses = new ArrayList<NetworkOfferingResponse>(); | ||||||
|  |         for (NetworkOffering offering : offerings) { | ||||||
|  |             NetworkOfferingResponse offeringResponse = _responseGenerator.createNetworkOfferingResponse(offering); | ||||||
|  |             offeringResponses.add(offeringResponse); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         response.setResponses(offeringResponses); | ||||||
|  |         response.setResponseName(getName()); | ||||||
|  |         this.setResponseObject(response); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										89
									
								
								api/src/com/cloud/api/commands/ListNetworksCmd.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								api/src/com/cloud/api/commands/ListNetworksCmd.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,89 @@ | |||||||
|  | /** | ||||||
|  |  *  Copyright (C) 2010 Cloud.com, Inc.  All rights reserved. | ||||||
|  |  *  | ||||||
|  |  * This software is licensed under the GNU General Public License v3 or later. | ||||||
|  |  *  | ||||||
|  |  * It is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or any later version. | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  *  | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  *  | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.cloud.api.commands; | ||||||
|  | 
 | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | 
 | ||||||
|  | import com.cloud.api.ApiConstants; | ||||||
|  | import com.cloud.api.BaseListCmd; | ||||||
|  | import com.cloud.api.Implementation; | ||||||
|  | import com.cloud.api.Parameter; | ||||||
|  | import com.cloud.api.response.ListResponse; | ||||||
|  | import com.cloud.api.response.NetworkResponse; | ||||||
|  | import com.cloud.network.Network; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @Implementation(description="Lists all available networks.", responseObject=NetworkResponse.class) | ||||||
|  | public class ListNetworksCmd extends BaseListCmd { | ||||||
|  |     public static final Logger s_logger = Logger.getLogger(ListNetworksCmd.class.getName()); | ||||||
|  |     private static final String _name = "listnetworksresponse"; | ||||||
|  | 
 | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     //////////////// API parameters ///////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list networks by id") | ||||||
|  |     private Long id; | ||||||
|  |      | ||||||
|  |     @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the VLAN. If VLAN is Zone wide, this parameter should be ommited") | ||||||
|  |     private String accountName; | ||||||
|  | 
 | ||||||
|  |     @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a VLAN") | ||||||
|  |     private Long domainId; | ||||||
|  |     | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////////// Accessors /////////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  | 
 | ||||||
|  |     public Long getId() { | ||||||
|  |         return id; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public String getAccountName() { | ||||||
|  |         return accountName; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public Long getDomainId() { | ||||||
|  |         return domainId; | ||||||
|  |     } | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     /////////////// API Implementation/////////////////// | ||||||
|  |     ///////////////////////////////////////////////////// | ||||||
|  |     @Override | ||||||
|  |     public String getName() { | ||||||
|  |         return _name; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void execute(){ | ||||||
|  |         List<? extends Network> networks = _networkService.searchForNetworks(this); | ||||||
|  |         ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>(); | ||||||
|  |         List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>(); | ||||||
|  |         for (Network network : networks) { | ||||||
|  |             NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(network); | ||||||
|  |             networkResponses.add(networkResponse); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         response.setResponses(networkResponses); | ||||||
|  |         response.setResponseName(getName()); | ||||||
|  |         this.setResponseObject(response); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -110,10 +110,13 @@ public class StartVMCmd extends BaseAsyncCmd { | |||||||
|                 throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start a vm"); |                 throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start a vm"); | ||||||
|             } |             } | ||||||
|         }catch (ConcurrentOperationException ex) { |         }catch (ConcurrentOperationException ex) { | ||||||
|  |             s_logger.warn("Exception: ", ex); | ||||||
|             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); |             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); | ||||||
|         }catch (StorageUnavailableException ex) { |         }catch (StorageUnavailableException ex) { | ||||||
|  |             s_logger.warn("Exception: ", ex); | ||||||
|             throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); |             throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); | ||||||
|         }catch (ExecutionException ex) { |         }catch (ExecutionException ex) { | ||||||
|  |             s_logger.warn("Exception: ", ex); | ||||||
|             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); |             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ | |||||||
| package com.cloud.api.response; | package com.cloud.api.response; | ||||||
| 
 | 
 | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
|  | import java.util.List; | ||||||
| 
 | 
 | ||||||
| import com.cloud.api.ApiConstants; | import com.cloud.api.ApiConstants; | ||||||
| import com.cloud.serializer.Param; | import com.cloud.serializer.Param; | ||||||
| @ -107,6 +108,9 @@ public class DomainRouterResponse extends BaseResponse { | |||||||
|     	return getId(); |     	return getId(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     @SerializedName("nics")  @Param(description="the list of nics associated with domain router") | ||||||
|  |     private List<NicResponse> nics; | ||||||
|  | 
 | ||||||
|     public Long getId() { |     public Long getId() { | ||||||
|         return id; |         return id; | ||||||
|     } |     } | ||||||
| @ -314,4 +318,12 @@ public class DomainRouterResponse extends BaseResponse { | |||||||
|     public void setDomainName(String domainName) { |     public void setDomainName(String domainName) { | ||||||
|         this.domainName = domainName; |         this.domainName = domainName; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public List<NicResponse> getNics() { | ||||||
|  |         return nics; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNics(List<NicResponse> nics) { | ||||||
|  |         this.nics = nics; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										137
									
								
								api/src/com/cloud/api/response/NetworkOfferingResponse.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								api/src/com/cloud/api/response/NetworkOfferingResponse.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,137 @@ | |||||||
|  | package com.cloud.api.response; | ||||||
|  | 
 | ||||||
|  | import java.util.Date; | ||||||
|  | 
 | ||||||
|  | import com.cloud.serializer.Param; | ||||||
|  | import com.google.gson.annotations.SerializedName; | ||||||
|  | 
 | ||||||
|  | public class NetworkOfferingResponse extends BaseResponse{ | ||||||
|  |     @SerializedName("id") @Param(description="the id of the network offering") | ||||||
|  |     private Long id; | ||||||
|  | 
 | ||||||
|  |     @SerializedName("name") @Param(description="the name of the network offering") | ||||||
|  |     private String name; | ||||||
|  |      | ||||||
|  |     @SerializedName("displaytext") @Param(description="an alternate display text of the network offering.") | ||||||
|  |     private String displayText; | ||||||
|  |      | ||||||
|  |     @SerializedName("tags") @Param(description="the tags for the network offering") | ||||||
|  |     private String tags; | ||||||
|  |      | ||||||
|  |     @SerializedName("created") @Param(description="the date this network offering was created") | ||||||
|  |     private Date created; | ||||||
|  |      | ||||||
|  |     @SerializedName("maxconnections") @Param(description="the max number of concurrent connection the network offering supports") | ||||||
|  |     private Integer maxConnections; | ||||||
|  |      | ||||||
|  |     @SerializedName("type") @Param(description="type of the network. Supported types are Virtualized, DirectSingle, DirectDual") | ||||||
|  |     private String type; | ||||||
|  |      | ||||||
|  |     @SerializedName("traffictype") @Param(description="the traffic type for the network offering, supported types are Public, Management, Control, Guest, Vlan or Storage.") | ||||||
|  |     private String trafficType; | ||||||
|  |      | ||||||
|  |     @SerializedName("isdefault") @Param(description="true if network offering is default, false otherwise") | ||||||
|  |     private Boolean isDefault; | ||||||
|  |      | ||||||
|  |     @SerializedName("isshared") @Param(description="true if network offering is shared, false otherwise") | ||||||
|  |     private Boolean isShared; | ||||||
|  |      | ||||||
|  |     @SerializedName("specifyvlan") @Param(description="true if network offering supports vlans, false otherwise") | ||||||
|  |     private Boolean specifyVlan; | ||||||
|  | 
 | ||||||
|  |     public Long getId() { | ||||||
|  |         return id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setId(Long id) { | ||||||
|  |         this.id = id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getName() { | ||||||
|  |         return name; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setName(String name) { | ||||||
|  |         this.name = name; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getDisplayText() { | ||||||
|  |         return displayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setDisplayText(String displayText) { | ||||||
|  |         this.displayText = displayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getTags() { | ||||||
|  |         return tags; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setTags(String tags) { | ||||||
|  |         this.tags = tags; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Date getCreated() { | ||||||
|  |         return created; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setCreated(Date created) { | ||||||
|  |         this.created = created; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Integer getMaxconnections() { | ||||||
|  |         return maxConnections; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setMaxconnections(Integer maxConnections) { | ||||||
|  |         this.maxConnections = maxConnections; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getType() { | ||||||
|  |         return type; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setType(String type) { | ||||||
|  |         this.type = type; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getTrafficType() { | ||||||
|  |         return trafficType; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setTrafficType(String trafficType) { | ||||||
|  |         this.trafficType = trafficType; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Boolean getIsDefault() { | ||||||
|  |         return isDefault; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setIsDefault(Boolean isDefault) { | ||||||
|  |         this.isDefault = isDefault; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Integer getMaxConnections() { | ||||||
|  |         return maxConnections; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setMaxConnections(Integer maxConnections) { | ||||||
|  |         this.maxConnections = maxConnections; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Boolean getSpecifyVlan() { | ||||||
|  |         return specifyVlan; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setSpecifyVlan(Boolean specifyVlan) { | ||||||
|  |         this.specifyVlan = specifyVlan; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Boolean getIsShared() { | ||||||
|  |         return isShared; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setIsShared(Boolean isShared) { | ||||||
|  |         this.isShared = isShared; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										231
									
								
								api/src/com/cloud/api/response/NetworkResponse.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										231
									
								
								api/src/com/cloud/api/response/NetworkResponse.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,231 @@ | |||||||
|  | package com.cloud.api.response; | ||||||
|  | 
 | ||||||
|  | import com.cloud.api.ApiConstants; | ||||||
|  | import com.cloud.serializer.Param; | ||||||
|  | import com.google.gson.annotations.SerializedName; | ||||||
|  | 
 | ||||||
|  | public class NetworkResponse extends BaseResponse{ | ||||||
|  |      | ||||||
|  |     @SerializedName("id") @Param(description="the id of the network") | ||||||
|  |     private Long id; | ||||||
|  |      | ||||||
|  |     @SerializedName("name") @Param(description="the name of the network") | ||||||
|  |     private String name; | ||||||
|  |      | ||||||
|  |     @SerializedName("displaytext") @Param(description="the displaytext of the network") | ||||||
|  |     private String displaytext; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("broadcastdomaintype") | ||||||
|  |     private String broadcastDomainType; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("traffictype") | ||||||
|  |     private String trafficType; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("gateway") | ||||||
|  |     private String gateway; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("cidr") | ||||||
|  |     private String cidr; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("zoneid") | ||||||
|  |     private Long zoneId; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("networkofferingid") | ||||||
|  |     private Long networkOfferingId; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("networkofferingname") | ||||||
|  |     private String networkOfferingName; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("networkofferingdisplaytext") | ||||||
|  |     private String networkOfferingDisplayText; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("state") | ||||||
|  |     private String state; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("related") | ||||||
|  |     private Long related; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("broadcasturi") | ||||||
|  |     private String broadcastUri; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("dns1") | ||||||
|  |     private String dns1; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("dns2") | ||||||
|  |     private String dns2; | ||||||
|  |      | ||||||
|  |     //TODO - add description | ||||||
|  |     @SerializedName("type") | ||||||
|  |     private String type; | ||||||
|  |      | ||||||
|  |     @SerializedName(ApiConstants.ACCOUNT) @Param(description="the account associated with the network") | ||||||
|  |     private String accountName; | ||||||
|  | 
 | ||||||
|  |     @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id associated with the network") | ||||||
|  |     private Long domainId; | ||||||
|  | 
 | ||||||
|  |     public Long getId() { | ||||||
|  |         return id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setId(Long id) { | ||||||
|  |         this.id = id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getName() { | ||||||
|  |         return name; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setName(String name) { | ||||||
|  |         this.name = name; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getBroadcastDomainType() { | ||||||
|  |         return broadcastDomainType; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setBroadcastDomainType(String broadcastDomainType) { | ||||||
|  |         this.broadcastDomainType = broadcastDomainType; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getTrafficType() { | ||||||
|  |         return trafficType; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setTrafficType(String trafficType) { | ||||||
|  |         this.trafficType = trafficType; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getGateway() { | ||||||
|  |         return gateway; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setGateway(String gateway) { | ||||||
|  |         this.gateway = gateway; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getCidr() { | ||||||
|  |         return cidr; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setCidr(String cidr) { | ||||||
|  |         this.cidr = cidr; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getZoneId() { | ||||||
|  |         return zoneId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setZoneId(Long zoneId) { | ||||||
|  |         this.zoneId = zoneId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getNetworkOfferingId() { | ||||||
|  |         return networkOfferingId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNetworkOfferingId(Long networkOfferingId) { | ||||||
|  |         this.networkOfferingId = networkOfferingId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getState() { | ||||||
|  |         return state; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setState(String state) { | ||||||
|  |         this.state = state; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getRelated() { | ||||||
|  |         return related; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setRelated(Long related) { | ||||||
|  |         this.related = related; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getBroadcastUri() { | ||||||
|  |         return broadcastUri; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setBroadcastUri(String broadcastUri) { | ||||||
|  |         this.broadcastUri = broadcastUri; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getDns1() { | ||||||
|  |         return dns1; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setDns1(String dns1) { | ||||||
|  |         this.dns1 = dns1; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getDns2() { | ||||||
|  |         return dns2; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setDns2(String dns2) { | ||||||
|  |         this.dns2 = dns2; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getType() { | ||||||
|  |         return type; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setType(String type) { | ||||||
|  |         this.type = type; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getAccountName() { | ||||||
|  |         return accountName; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setAccountName(String accountName) { | ||||||
|  |         this.accountName = accountName; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getDomainId() { | ||||||
|  |         return domainId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setDomainId(Long domainId) { | ||||||
|  |         this.domainId = domainId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getNetworkOfferingName() { | ||||||
|  |         return networkOfferingName; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNetworkOfferingName(String networkOfferingName) { | ||||||
|  |         this.networkOfferingName = networkOfferingName; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getNetworkOfferingDisplayText() { | ||||||
|  |         return networkOfferingDisplayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNetworkOfferingDisplayText(String networkOfferingDisplayText) { | ||||||
|  |         this.networkOfferingDisplayText = networkOfferingDisplayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getDisplaytext() { | ||||||
|  |         return displaytext; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setDisplaytext(String displaytext) { | ||||||
|  |         this.displaytext = displaytext; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										101
									
								
								api/src/com/cloud/api/response/NicResponse.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								api/src/com/cloud/api/response/NicResponse.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,101 @@ | |||||||
|  | /** | ||||||
|  |  *  Copyright (C) 2010 Cloud.com, Inc.  All rights reserved. | ||||||
|  |  *  | ||||||
|  |  * This software is licensed under the GNU General Public License v3 or later. | ||||||
|  |  *  | ||||||
|  |  * It is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or any later version. | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  *  | ||||||
|  |  * You should have received a copy of the GNU General Public License | ||||||
|  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  *  | ||||||
|  |  */ | ||||||
|  | package com.cloud.api.response; | ||||||
|  | 
 | ||||||
|  | import com.cloud.serializer.Param; | ||||||
|  | import com.google.gson.annotations.SerializedName; | ||||||
|  | 
 | ||||||
|  | public class NicResponse extends BaseResponse { | ||||||
|  |      | ||||||
|  |     @SerializedName("id") @Param(description="the ID of the nic") | ||||||
|  |     private Long id; | ||||||
|  | 
 | ||||||
|  |     @SerializedName("networkid") @Param(description="the ID of the corresponding network") | ||||||
|  |     private Long networkid; | ||||||
|  |      | ||||||
|  |     @SerializedName("netmask") @Param(description="the netmask of the nic") | ||||||
|  |     private String netmask; | ||||||
|  |      | ||||||
|  |     @SerializedName("gateway") @Param(description="the gateway of the nic") | ||||||
|  |     private String gateway; | ||||||
|  |      | ||||||
|  |     @SerializedName("ipaddress") @Param(description="the ip address of the nic") | ||||||
|  |     private String ipaddress; | ||||||
|  |      | ||||||
|  |     @SerializedName("isolationuri") @Param(description="the isolation uri of the nic") | ||||||
|  |     private String isolationUri; | ||||||
|  |      | ||||||
|  |     @SerializedName("broadcasturi") @Param(description="the broadcast uri of the nic") | ||||||
|  |     private String broadcastUri; | ||||||
|  | 
 | ||||||
|  |     public Long getId() { | ||||||
|  |         return id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setId(Long id) { | ||||||
|  |         this.id = id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Long getNetworkid() { | ||||||
|  |         return networkid; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNetworkid(Long networkid) { | ||||||
|  |         this.networkid = networkid; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getNetmask() { | ||||||
|  |         return netmask; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNetmask(String netmask) { | ||||||
|  |         this.netmask = netmask; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getGateway() { | ||||||
|  |         return gateway; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setGateway(String gateway) { | ||||||
|  |         this.gateway = gateway; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getIpaddress() { | ||||||
|  |         return ipaddress; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setIpaddress(String ipaddress) { | ||||||
|  |         this.ipaddress = ipaddress; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getIsolationUri() { | ||||||
|  |         return isolationUri; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setIsolationUri(String isolationUri) { | ||||||
|  |         this.isolationUri = isolationUri; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getBroadcastUri() { | ||||||
|  |         return broadcastUri; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setBroadcastUri(String broadcastUri) { | ||||||
|  |         this.broadcastUri = broadcastUri; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -18,6 +18,7 @@ | |||||||
| package com.cloud.api.response; | package com.cloud.api.response; | ||||||
| 
 | 
 | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
|  | import java.util.List; | ||||||
| 
 | 
 | ||||||
| import com.cloud.serializer.Param; | import com.cloud.serializer.Param; | ||||||
| import com.google.gson.annotations.SerializedName; | import com.google.gson.annotations.SerializedName; | ||||||
| @ -99,6 +100,9 @@ public class SystemVmResponse extends BaseResponse { | |||||||
|     	return getId(); |     	return getId(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     @SerializedName("nics")  @Param(description="the list of nics associated with system vm") | ||||||
|  |     private List<NicResponse> nics; | ||||||
|  | 
 | ||||||
|     public Long getId() { |     public Long getId() { | ||||||
|         return id; |         return id; | ||||||
|     } |     } | ||||||
| @ -290,4 +294,12 @@ public class SystemVmResponse extends BaseResponse { | |||||||
|     public void setActiveViewerSessions(Integer activeViewerSessions) { |     public void setActiveViewerSessions(Integer activeViewerSessions) { | ||||||
|         this.activeViewerSessions = activeViewerSessions; |         this.activeViewerSessions = activeViewerSessions; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public List<NicResponse> getNics() { | ||||||
|  |         return nics; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNics(List<NicResponse> nics) { | ||||||
|  |         this.nics = nics; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ | |||||||
| package com.cloud.api.response; | package com.cloud.api.response; | ||||||
| 
 | 
 | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
|  | import java.util.List; | ||||||
| 
 | 
 | ||||||
| import com.cloud.api.ApiConstants; | import com.cloud.api.ApiConstants; | ||||||
| import com.cloud.serializer.Param; | import com.cloud.serializer.Param; | ||||||
| @ -144,6 +145,9 @@ public class UserVmResponse extends BaseResponse { | |||||||
|     public Long getObjectId() { |     public Long getObjectId() { | ||||||
|     	return getId(); |     	return getId(); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @SerializedName("nics")  @Param(description="the list of nics associated with vm") | ||||||
|  |     private List<NicResponse> nics; | ||||||
|      |      | ||||||
|     public Long getId() { |     public Long getId() { | ||||||
|         return id; |         return id; | ||||||
| @ -456,4 +460,12 @@ public class UserVmResponse extends BaseResponse { | |||||||
|     public void setForVirtualNetwork(Boolean forVirtualNetwork) { |     public void setForVirtualNetwork(Boolean forVirtualNetwork) { | ||||||
|         this.forVirtualNetwork = forVirtualNetwork; |         this.forVirtualNetwork = forVirtualNetwork; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public List<NicResponse> getNics() { | ||||||
|  |         return nics; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNics(List<NicResponse> nics) { | ||||||
|  |         this.nics = nics; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -62,6 +62,9 @@ public class VlanIpRangeResponse extends BaseResponse { | |||||||
| 
 | 
 | ||||||
|     @SerializedName("endip") @Param(description="the end ip of the VLAN IP range") |     @SerializedName("endip") @Param(description="the end ip of the VLAN IP range") | ||||||
|     private String endIp; |     private String endIp; | ||||||
|  |      | ||||||
|  |     @SerializedName("networkid") @Param(description="the network id of vlan range") | ||||||
|  |     private Long networkId; | ||||||
| 
 | 
 | ||||||
|     public Long getId() { |     public Long getId() { | ||||||
|         return id; |         return id; | ||||||
| @ -174,4 +177,12 @@ public class VlanIpRangeResponse extends BaseResponse { | |||||||
|     public void setEndIp(String endIp) { |     public void setEndIp(String endIp) { | ||||||
|         this.endIp = endIp; |         this.endIp = endIp; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public Long getNetworkId() { | ||||||
|  |         return networkId; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNetworkId(Long networkId) { | ||||||
|  |         this.networkId = networkId; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,16 +1,21 @@ | |||||||
| package com.cloud.configuration; | package com.cloud.configuration; | ||||||
| 
 | 
 | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
| import com.cloud.api.commands.CreateCfgCmd; | import com.cloud.api.commands.CreateCfgCmd; | ||||||
| import com.cloud.api.commands.CreateDiskOfferingCmd; | import com.cloud.api.commands.CreateDiskOfferingCmd; | ||||||
|  | import com.cloud.api.commands.CreateNetworkOfferingCmd; | ||||||
| import com.cloud.api.commands.CreatePodCmd; | import com.cloud.api.commands.CreatePodCmd; | ||||||
| import com.cloud.api.commands.CreateServiceOfferingCmd; | import com.cloud.api.commands.CreateServiceOfferingCmd; | ||||||
| import com.cloud.api.commands.CreateVlanIpRangeCmd; | import com.cloud.api.commands.CreateVlanIpRangeCmd; | ||||||
| import com.cloud.api.commands.CreateZoneCmd; | import com.cloud.api.commands.CreateZoneCmd; | ||||||
| import com.cloud.api.commands.DeleteDiskOfferingCmd; | import com.cloud.api.commands.DeleteDiskOfferingCmd; | ||||||
|  | import com.cloud.api.commands.DeleteNetworkOfferingCmd; | ||||||
| import com.cloud.api.commands.DeletePodCmd; | import com.cloud.api.commands.DeletePodCmd; | ||||||
| import com.cloud.api.commands.DeleteServiceOfferingCmd; | import com.cloud.api.commands.DeleteServiceOfferingCmd; | ||||||
| import com.cloud.api.commands.DeleteVlanIpRangeCmd; | import com.cloud.api.commands.DeleteVlanIpRangeCmd; | ||||||
| import com.cloud.api.commands.DeleteZoneCmd; | import com.cloud.api.commands.DeleteZoneCmd; | ||||||
|  | import com.cloud.api.commands.ListNetworkOfferingsCmd; | ||||||
| import com.cloud.api.commands.UpdateCfgCmd; | import com.cloud.api.commands.UpdateCfgCmd; | ||||||
| import com.cloud.api.commands.UpdateDiskOfferingCmd; | import com.cloud.api.commands.UpdateDiskOfferingCmd; | ||||||
| import com.cloud.api.commands.UpdatePodCmd; | import com.cloud.api.commands.UpdatePodCmd; | ||||||
| @ -23,6 +28,7 @@ import com.cloud.exception.ConcurrentOperationException; | |||||||
| import com.cloud.exception.InsufficientCapacityException; | import com.cloud.exception.InsufficientCapacityException; | ||||||
| import com.cloud.exception.InvalidParameterValueException; | import com.cloud.exception.InvalidParameterValueException; | ||||||
| import com.cloud.offering.DiskOffering; | import com.cloud.offering.DiskOffering; | ||||||
|  | import com.cloud.offering.NetworkOffering; | ||||||
| import com.cloud.offering.ServiceOffering; | import com.cloud.offering.ServiceOffering; | ||||||
| 
 | 
 | ||||||
| public interface ConfigurationService { | public interface ConfigurationService { | ||||||
| @ -166,7 +172,14 @@ public interface ConfigurationService { | |||||||
|      * @throws  |      * @throws  | ||||||
|      * @return The new Vlan object |      * @return The new Vlan object | ||||||
|      */ |      */ | ||||||
|     Vlan createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException; |     Vlan createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException; | ||||||
| 
 | 
 | ||||||
|     boolean deleteVlanIpRange(DeleteVlanIpRangeCmd cmd); |     boolean deleteVlanIpRange(DeleteVlanIpRangeCmd cmd); | ||||||
|  |      | ||||||
|  |     NetworkOffering createNetworkOffering(CreateNetworkOfferingCmd cmd); | ||||||
|  |      | ||||||
|  |     List<? extends NetworkOffering> searchForNetworkOfferings(ListNetworkOfferingsCmd cmd); | ||||||
|  |      | ||||||
|  |     boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd); | ||||||
|  |     | ||||||
| } | } | ||||||
|  | |||||||
| @ -43,5 +43,7 @@ public interface Vlan { | |||||||
| 	public void setVlanType(VlanType ipRange); | 	public void setVlanType(VlanType ipRange); | ||||||
| 
 | 
 | ||||||
| 	public VlanType getVlanType(); | 	public VlanType getVlanType(); | ||||||
|  | 	 | ||||||
|  | 	public Long getNetworkId(); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| @ -132,6 +132,11 @@ public class EventTypes { | |||||||
|     public static final String EVENT_DISK_OFFERING_CREATE = "DISK.OFFERING.CREATE"; |     public static final String EVENT_DISK_OFFERING_CREATE = "DISK.OFFERING.CREATE"; | ||||||
|     public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT"; |     public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT"; | ||||||
|     public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE"; |     public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE"; | ||||||
|  |      | ||||||
|  |     //Network offerings | ||||||
|  |     public static final String EVENT_NETWORK_OFFERING_CREATE = "NETWORK.OFFERING.CREATE"; | ||||||
|  |     public static final String EVENT_NETWORK_OFFERING_EDIT = "NETWORK.OFFERING.EDIT"; | ||||||
|  |     public static final String EVENT_NETWORK_OFFERING_DELETE = "NETWORK.OFFERING.DELETE"; | ||||||
| 
 | 
 | ||||||
| 	// Pods | 	// Pods | ||||||
| 	public static final String EVENT_POD_CREATE = "POD.CREATE"; | 	public static final String EVENT_POD_CREATE = "POD.CREATE"; | ||||||
|  | |||||||
| @ -80,6 +80,8 @@ public interface Network extends ControlledEntity { | |||||||
|      * @return id of the network profile.  Null means the network profile is not from the database. |      * @return id of the network profile.  Null means the network profile is not from the database. | ||||||
|      */ |      */ | ||||||
|     long getId(); |     long getId(); | ||||||
|  |      | ||||||
|  |     String getName(); | ||||||
| 
 | 
 | ||||||
|     Mode getMode(); |     Mode getMode(); | ||||||
| 
 | 
 | ||||||
| @ -106,4 +108,6 @@ public interface Network extends ControlledEntity { | |||||||
|     String getDns2(); |     String getDns2(); | ||||||
|      |      | ||||||
|     GuestIpType getGuestType(); |     GuestIpType getGuestType(); | ||||||
|  |      | ||||||
|  |     String getDisplayText(); | ||||||
| } | } | ||||||
|  | |||||||
| @ -23,11 +23,14 @@ import com.cloud.api.commands.AddVpnUserCmd; | |||||||
| import com.cloud.api.commands.AssignToLoadBalancerRuleCmd; | import com.cloud.api.commands.AssignToLoadBalancerRuleCmd; | ||||||
| import com.cloud.api.commands.AssociateIPAddrCmd; | import com.cloud.api.commands.AssociateIPAddrCmd; | ||||||
| import com.cloud.api.commands.CreateLoadBalancerRuleCmd; | import com.cloud.api.commands.CreateLoadBalancerRuleCmd; | ||||||
|  | import com.cloud.api.commands.CreateNetworkCmd; | ||||||
| import com.cloud.api.commands.CreatePortForwardingRuleCmd; | import com.cloud.api.commands.CreatePortForwardingRuleCmd; | ||||||
| import com.cloud.api.commands.CreateRemoteAccessVpnCmd; | import com.cloud.api.commands.CreateRemoteAccessVpnCmd; | ||||||
| import com.cloud.api.commands.DeleteLoadBalancerRuleCmd; | import com.cloud.api.commands.DeleteLoadBalancerRuleCmd; | ||||||
|  | import com.cloud.api.commands.DeleteNetworkCmd; | ||||||
| import com.cloud.api.commands.DeleteRemoteAccessVpnCmd; | import com.cloud.api.commands.DeleteRemoteAccessVpnCmd; | ||||||
| import com.cloud.api.commands.DisassociateIPAddrCmd; | import com.cloud.api.commands.DisassociateIPAddrCmd; | ||||||
|  | import com.cloud.api.commands.ListNetworksCmd; | ||||||
| import com.cloud.api.commands.ListPortForwardingRulesCmd; | import com.cloud.api.commands.ListPortForwardingRulesCmd; | ||||||
| import com.cloud.api.commands.RemoveFromLoadBalancerRuleCmd; | import com.cloud.api.commands.RemoveFromLoadBalancerRuleCmd; | ||||||
| import com.cloud.api.commands.RemoveVpnUserCmd; | import com.cloud.api.commands.RemoveVpnUserCmd; | ||||||
| @ -122,5 +125,9 @@ public interface NetworkService { | |||||||
| 
 | 
 | ||||||
|     boolean deleteIpForwardingRule(Long id); |     boolean deleteIpForwardingRule(Long id); | ||||||
|     boolean deletePortForwardingRule(Long id, boolean sysContext); |     boolean deletePortForwardingRule(Long id, boolean sysContext); | ||||||
|  |      | ||||||
|  |     Network createNetwork(CreateNetworkCmd cmd) throws InvalidParameterValueException, PermissionDeniedException; | ||||||
|  |     List<? extends Network> searchForNetworks(ListNetworksCmd cmd) throws InvalidParameterValueException, PermissionDeniedException; | ||||||
|  |     boolean deleteNetwork(DeleteNetworkCmd cmd) throws InvalidParameterValueException, PermissionDeniedException; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -70,4 +70,10 @@ public interface NetworkOffering { | |||||||
|     TrafficType getTrafficType(); |     TrafficType getTrafficType(); | ||||||
|      |      | ||||||
|     boolean getSpecifyVlan(); |     boolean getSpecifyVlan(); | ||||||
|  |      | ||||||
|  |     String getTags(); | ||||||
|  |      | ||||||
|  |     boolean isShared(); | ||||||
|  |      | ||||||
|  |     boolean isDefault(); | ||||||
| } | } | ||||||
|  | |||||||
| @ -17,6 +17,8 @@ | |||||||
|  */ |  */ | ||||||
| package com.cloud.vm; | package com.cloud.vm; | ||||||
| 
 | 
 | ||||||
|  | import java.net.URI; | ||||||
|  | 
 | ||||||
| import com.cloud.network.Networks.Mode; | import com.cloud.network.Networks.Mode; | ||||||
| import com.cloud.resource.Resource; | import com.cloud.resource.Resource; | ||||||
| 
 | 
 | ||||||
| @ -48,4 +50,9 @@ public interface Nic extends Resource { | |||||||
|     int getDeviceId(); |     int getDeviceId(); | ||||||
|      |      | ||||||
|     Mode getMode(); |     Mode getMode(); | ||||||
|  |      | ||||||
|  |     URI getIsolationUri(); | ||||||
|  |      | ||||||
|  |     URI getBroadcastUri(); | ||||||
|  |      | ||||||
| } | } | ||||||
|  | |||||||
| @ -230,3 +230,13 @@ listRemoteAccessVpns=com.cloud.api.commands.ListRemoteAccessVpnsCmd;15 | |||||||
| addVpnUser=com.cloud.api.commands.AddVpnUserCmd;15 | addVpnUser=com.cloud.api.commands.AddVpnUserCmd;15 | ||||||
| removeVpnUser=com.cloud.api.commands.RemoveVpnUserCmd;15 | removeVpnUser=com.cloud.api.commands.RemoveVpnUserCmd;15 | ||||||
| listVpnUsers=com.cloud.api.commands.ListVpnUsersCmd;15 | listVpnUsers=com.cloud.api.commands.ListVpnUsersCmd;15 | ||||||
|  | 
 | ||||||
|  | #### network offering commands | ||||||
|  | createNetworkOffering=com.cloud.api.commands.CreateNetworkOfferingCmd;1 | ||||||
|  | deleteNetworkOffering=com.cloud.api.commands.DeleteNetworkOfferingCmd;1 | ||||||
|  | listNetworkOfferings=com.cloud.api.commands.ListNetworkOfferingsCmd;15 | ||||||
|  | 
 | ||||||
|  | #### network commands | ||||||
|  | createNetwork=com.cloud.api.commands.CreateNetworkCmd;1 | ||||||
|  | deleteNetwork=com.cloud.api.commands.DeleteNetworkCmd;1 | ||||||
|  | listNetworks=com.cloud.api.commands.ListNetworksCmd;15 | ||||||
| @ -18,7 +18,6 @@ | |||||||
| package com.cloud.agent.api; | package com.cloud.agent.api; | ||||||
| 
 | 
 | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; |  | ||||||
| 
 | 
 | ||||||
| import com.cloud.network.router.VirtualRouter; | import com.cloud.network.router.VirtualRouter; | ||||||
| import com.cloud.offering.ServiceOffering; | import com.cloud.offering.ServiceOffering; | ||||||
| @ -69,8 +68,6 @@ public class StartCommand extends AbstractStartCommand { | |||||||
|         guestMacAddress = vm.getGuestMacAddress(); |         guestMacAddress = vm.getGuestMacAddress(); | ||||||
|         vncPassword = vm.getVncPassword(); |         vncPassword = vm.getVncPassword(); | ||||||
|         hostName = vm.getHostName(); |         hostName = vm.getHostName(); | ||||||
| //        networkRateMbps = offering.getRateMbps(); |  | ||||||
| //        networkRateMulticastMbps = offering.getMulticastRateMbps(); |  | ||||||
|         networkRateMbps = networkRate; |         networkRateMbps = networkRate; | ||||||
|         networkRateMulticastMbps = multicastRate; |         networkRateMulticastMbps = multicastRate; | ||||||
|         if (bits == 32) { |         if (bits == 32) { | ||||||
|  | |||||||
| @ -37,6 +37,8 @@ import com.cloud.network.security.NetworkGroup; | |||||||
| import com.cloud.network.security.NetworkGroupManager; | import com.cloud.network.security.NetworkGroupManager; | ||||||
| import com.cloud.network.security.dao.NetworkGroupDao; | import com.cloud.network.security.dao.NetworkGroupDao; | ||||||
| import com.cloud.offering.ServiceOffering; | import com.cloud.offering.ServiceOffering; | ||||||
|  | import com.cloud.offerings.NetworkOfferingVO; | ||||||
|  | import com.cloud.offerings.dao.NetworkOfferingDao; | ||||||
| import com.cloud.server.Criteria; | import com.cloud.server.Criteria; | ||||||
| import com.cloud.server.ManagementServer; | import com.cloud.server.ManagementServer; | ||||||
| import com.cloud.server.StatsCollector; | import com.cloud.server.StatsCollector; | ||||||
| @ -125,6 +127,7 @@ public class ApiDBUtils { | |||||||
|     private static VlanDao _vlanDao; |     private static VlanDao _vlanDao; | ||||||
|     private static VolumeDao _volumeDao; |     private static VolumeDao _volumeDao; | ||||||
|     private static DataCenterDao _zoneDao; |     private static DataCenterDao _zoneDao; | ||||||
|  |     private static NetworkOfferingDao _networkOfferingDao; | ||||||
| 
 | 
 | ||||||
|     static { |     static { | ||||||
|         _ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name); |         _ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name); | ||||||
| @ -165,6 +168,7 @@ public class ApiDBUtils { | |||||||
|         _volumeDao = locator.getDao(VolumeDao.class); |         _volumeDao = locator.getDao(VolumeDao.class); | ||||||
|         _zoneDao = locator.getDao(DataCenterDao.class); |         _zoneDao = locator.getDao(DataCenterDao.class); | ||||||
|         _networkGroupDao = locator.getDao(NetworkGroupDao.class); |         _networkGroupDao = locator.getDao(NetworkGroupDao.class); | ||||||
|  |         _networkOfferingDao = locator.getDao(NetworkOfferingDao.class); | ||||||
| 
 | 
 | ||||||
|         // Note:  stats collector should already have been initialized by this time, otherwise a null instance is returned |         // Note:  stats collector should already have been initialized by this time, otherwise a null instance is returned | ||||||
|         _statsCollector = StatsCollector.getInstance(); |         _statsCollector = StatsCollector.getInstance(); | ||||||
| @ -487,4 +491,8 @@ public class ApiDBUtils { | |||||||
|         _asyncMgr.syncAsyncJobExecution((AsyncJobVO)job, syncObjType, syncObjId); |         _asyncMgr.syncAsyncJobExecution((AsyncJobVO)job, syncObjType, syncObjId); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     public static NetworkOfferingVO findNetworkOfferingById(long networkOfferingId) { | ||||||
|  |         return _networkOfferingDao.findByIdIncludingRemoved(networkOfferingId); | ||||||
|  |     } | ||||||
|  |      | ||||||
| } | } | ||||||
|  | |||||||
| @ -68,22 +68,22 @@ public class ApiDispatcher { | |||||||
|             cmd.callCreate(); |             cmd.callCreate(); | ||||||
|         } catch (Throwable t) { |         } catch (Throwable t) { | ||||||
|             if (t instanceof  InvalidParameterValueException || t instanceof IllegalArgumentException) { |             if (t instanceof  InvalidParameterValueException || t instanceof IllegalArgumentException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof PermissionDeniedException) { |             }else if (t instanceof PermissionDeniedException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof AccountLimitException) { |             }else if (t instanceof AccountLimitException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof InsufficientCapacityException) { |             }else if (t instanceof InsufficientCapacityException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof ResourceAllocationException) { |             }else if (t instanceof ResourceAllocationException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof ResourceUnavailableException) { |             }else if (t instanceof ResourceUnavailableException) { | ||||||
|                 s_logger.warn(t); |                 s_logger.warn("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof ServerApiException) { |             }else if (t instanceof ServerApiException) { | ||||||
|                 s_logger.warn(t.getClass() + " : " + ((ServerApiException) t).getDescription()); |                 s_logger.warn(t.getClass() + " : " + ((ServerApiException) t).getDescription()); | ||||||
| @ -91,7 +91,6 @@ public class ApiDispatcher { | |||||||
|             }else if (t instanceof AsyncCommandQueued) { |             }else if (t instanceof AsyncCommandQueued) { | ||||||
|                 throw (AsyncCommandQueued)t; |                 throw (AsyncCommandQueued)t; | ||||||
|             }else { |             }else { | ||||||
|                 s_logger.warn(t); |  | ||||||
|                 s_logger.error("Exception while executing " + cmd.getClass().getSimpleName() + ":", t); |                 s_logger.error("Exception while executing " + cmd.getClass().getSimpleName() + ":", t); | ||||||
|                 if (UserContext.current().getAccount() == null || UserContext.current().getAccount().getType() == Account.ACCOUNT_TYPE_ADMIN) |                 if (UserContext.current().getAccount() == null || UserContext.current().getAccount().getType() == Account.ACCOUNT_TYPE_ADMIN) | ||||||
|                     throw new ServerApiException(BaseCmd.INTERNAL_ERROR, t.getMessage()); |                     throw new ServerApiException(BaseCmd.INTERNAL_ERROR, t.getMessage()); | ||||||
| @ -107,22 +106,22 @@ public class ApiDispatcher { | |||||||
|             cmd.execute(); |             cmd.execute(); | ||||||
|         } catch (Throwable t) { |         } catch (Throwable t) { | ||||||
|             if (t instanceof  InvalidParameterValueException || t instanceof IllegalArgumentException) { |             if (t instanceof  InvalidParameterValueException || t instanceof IllegalArgumentException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof PermissionDeniedException) { |             }else if (t instanceof PermissionDeniedException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof AccountLimitException) { |             }else if (t instanceof AccountLimitException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof InsufficientCapacityException) { |             }else if (t instanceof InsufficientCapacityException) { | ||||||
|                 s_logger.info(t); |                 s_logger.info("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof ResourceAllocationException) { |             }else if (t instanceof ResourceAllocationException) { | ||||||
|                 s_logger.warn(t); |                 s_logger.warn("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof ResourceUnavailableException) { |             }else if (t instanceof ResourceUnavailableException) { | ||||||
|                 s_logger.warn(t); |                 s_logger.warn("Exception: ", t); | ||||||
|                 throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, t.getMessage()); |                 throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, t.getMessage()); | ||||||
|             }else if (t instanceof ServerApiException) { |             }else if (t instanceof ServerApiException) { | ||||||
|                 s_logger.warn(t.getClass()  + " : " + ((ServerApiException) t).getDescription()); |                 s_logger.warn(t.getClass()  + " : " + ((ServerApiException) t).getDescription()); | ||||||
| @ -130,7 +129,6 @@ public class ApiDispatcher { | |||||||
|             } else if (t instanceof AsyncCommandQueued) { |             } else if (t instanceof AsyncCommandQueued) { | ||||||
|                 throw (AsyncCommandQueued)t; |                 throw (AsyncCommandQueued)t; | ||||||
|             }else { |             }else { | ||||||
|                 s_logger.warn(t); |  | ||||||
|                 s_logger.error("Exception while executing " + cmd.getClass().getSimpleName() + ":", t); |                 s_logger.error("Exception while executing " + cmd.getClass().getSimpleName() + ":", t); | ||||||
|                 if (UserContext.current().getAccount() == null || UserContext.current().getAccount().getType() == Account.ACCOUNT_TYPE_ADMIN) |                 if (UserContext.current().getAccount() == null || UserContext.current().getAccount().getType() == Account.ACCOUNT_TYPE_ADMIN) | ||||||
|                     throw new ServerApiException(BaseCmd.INTERNAL_ERROR, t.getMessage()); |                     throw new ServerApiException(BaseCmd.INTERNAL_ERROR, t.getMessage()); | ||||||
|  | |||||||
| @ -52,6 +52,9 @@ import com.cloud.api.response.IpForwardingRuleResponse; | |||||||
| import com.cloud.api.response.ListResponse; | import com.cloud.api.response.ListResponse; | ||||||
| import com.cloud.api.response.LoadBalancerResponse; | import com.cloud.api.response.LoadBalancerResponse; | ||||||
| import com.cloud.api.response.NetworkGroupResponse; | import com.cloud.api.response.NetworkGroupResponse; | ||||||
|  | import com.cloud.api.response.NetworkOfferingResponse; | ||||||
|  | import com.cloud.api.response.NetworkResponse; | ||||||
|  | import com.cloud.api.response.NicResponse; | ||||||
| import com.cloud.api.response.PodResponse; | import com.cloud.api.response.PodResponse; | ||||||
| import com.cloud.api.response.PreallocatedLunResponse; | import com.cloud.api.response.PreallocatedLunResponse; | ||||||
| import com.cloud.api.response.RemoteAccessVpnResponse; | import com.cloud.api.response.RemoteAccessVpnResponse; | ||||||
| @ -96,7 +99,6 @@ import com.cloud.host.HostVO; | |||||||
| import com.cloud.network.IpAddress; | import com.cloud.network.IpAddress; | ||||||
| import com.cloud.network.LoadBalancer; | import com.cloud.network.LoadBalancer; | ||||||
| import com.cloud.network.Network; | import com.cloud.network.Network; | ||||||
| import com.cloud.network.Networks.TrafficType; |  | ||||||
| import com.cloud.network.RemoteAccessVpn; | import com.cloud.network.RemoteAccessVpn; | ||||||
| import com.cloud.network.VpnUser; | import com.cloud.network.VpnUser; | ||||||
| import com.cloud.network.router.VirtualRouter; | import com.cloud.network.router.VirtualRouter; | ||||||
| @ -105,6 +107,7 @@ import com.cloud.network.security.IngressRule; | |||||||
| import com.cloud.network.security.NetworkGroup; | import com.cloud.network.security.NetworkGroup; | ||||||
| import com.cloud.network.security.NetworkGroupRules; | import com.cloud.network.security.NetworkGroupRules; | ||||||
| import com.cloud.offering.DiskOffering; | import com.cloud.offering.DiskOffering; | ||||||
|  | import com.cloud.offering.NetworkOffering; | ||||||
| import com.cloud.offering.NetworkOffering.GuestIpType; | import com.cloud.offering.NetworkOffering.GuestIpType; | ||||||
| import com.cloud.offering.ServiceOffering; | import com.cloud.offering.ServiceOffering; | ||||||
| import com.cloud.org.Cluster; | import com.cloud.org.Cluster; | ||||||
| @ -756,6 +759,7 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||||
|         vlanResponse.setGateway(vlan.getVlanGateway()); |         vlanResponse.setGateway(vlan.getVlanGateway()); | ||||||
|         vlanResponse.setNetmask(vlan.getVlanNetmask()); |         vlanResponse.setNetmask(vlan.getVlanNetmask()); | ||||||
|         vlanResponse.setDescription(vlan.getIpRange()); |         vlanResponse.setDescription(vlan.getIpRange()); | ||||||
|  |         vlanResponse.setNetworkId(vlan.getNetworkId()); | ||||||
|         vlanResponse.setObjectName("vlan"); |         vlanResponse.setObjectName("vlan"); | ||||||
| 
 | 
 | ||||||
|         return vlanResponse; |         return vlanResponse; | ||||||
| @ -1199,14 +1203,27 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||||
|         userVmResponse.setNetworkGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(userVm.getId())); |         userVmResponse.setNetworkGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(userVm.getId())); | ||||||
| 
 | 
 | ||||||
|         List<? extends Nic> nics = ApiDBUtils.getNics(userVm); |         List<? extends Nic> nics = ApiDBUtils.getNics(userVm); | ||||||
|  |         List<NicResponse> nicResponses = new ArrayList<NicResponse>(); | ||||||
|         for (Nic singleNic : nics) { |         for (Nic singleNic : nics) { | ||||||
|             Long configId = singleNic.getNetworkId(); |             NicResponse nicResponse = new NicResponse(); | ||||||
|             Network networkConf = ApiDBUtils.getNetwork(configId); |             nicResponse.setId(singleNic.getId()); | ||||||
|             if (networkConf.getTrafficType() == TrafficType.Guest) { |             nicResponse.setIpaddress(singleNic.getIp4Address()); | ||||||
|                 userVmResponse.setIpAddress(singleNic.getIp4Address()); |             nicResponse.setGateway(singleNic.getGateway()); | ||||||
|             } |             nicResponse.setNetmask(singleNic.getNetmask()); | ||||||
|  |             nicResponse.setNetworkid(singleNic.getNetworkId()); | ||||||
|  |             if (acct.getType() == Account.ACCOUNT_TYPE_ADMIN) { | ||||||
|  |                 if (singleNic.getBroadcastUri() != null) { | ||||||
|  |                     nicResponse.setBroadcastUri(singleNic.getBroadcastUri().toString()); | ||||||
|  |                 } | ||||||
|  |                 if (singleNic.getIsolationUri() != null) { | ||||||
|  |                     nicResponse.setIsolationUri(singleNic.getIsolationUri().toString()); | ||||||
|  |                 } | ||||||
|  |             }   | ||||||
|  |             nicResponse.setObjectName("nic"); | ||||||
|  |              | ||||||
|  |             nicResponses.add(nicResponse); | ||||||
|         } |         } | ||||||
| 
 |         userVmResponse.setNics(nicResponses); | ||||||
|         userVmResponse.setObjectName("virtualmachine"); |         userVmResponse.setObjectName("virtualmachine"); | ||||||
|         return userVmResponse; |         return userVmResponse; | ||||||
|     } |     } | ||||||
| @ -1236,35 +1253,31 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         List<? extends Nic> nics = ApiDBUtils.getNics(router); |         List<? extends Nic> nics = ApiDBUtils.getNics(router); | ||||||
|  |         List<NicResponse> nicResponses = new ArrayList<NicResponse>(); | ||||||
|         for (Nic singleNic : nics) { |         for (Nic singleNic : nics) { | ||||||
|             Long configId = singleNic.getNetworkId(); |             NicResponse nicResponse = new NicResponse(); | ||||||
|             Network networkConf = ApiDBUtils.getNetwork(configId); |             nicResponse.setId(singleNic.getId()); | ||||||
| 
 |             nicResponse.setIpaddress(singleNic.getIp4Address()); | ||||||
|             if (networkConf.getTrafficType() == TrafficType.Guest) { |             nicResponse.setGateway(singleNic.getGateway()); | ||||||
|                 routerResponse.setGuestIpAddress(singleNic.getIp4Address()); |             nicResponse.setNetmask(singleNic.getNetmask()); | ||||||
|                 routerResponse.setGuestMacAddress(singleNic.getMacAddress()); |             nicResponse.setNetworkid(singleNic.getNetworkId()); | ||||||
|                 routerResponse.setGuestNetmask(singleNic.getNetmask()); |             if (singleNic.getBroadcastUri() != null) { | ||||||
|  |                 nicResponse.setBroadcastUri(singleNic.getBroadcastUri().toString()); | ||||||
|             } |             } | ||||||
| 
 |             if (singleNic.getIsolationUri() != null) { | ||||||
|             if (networkConf.getTrafficType() == TrafficType.Control) { |                 nicResponse.setIsolationUri(singleNic.getIsolationUri().toString()); | ||||||
|                 routerResponse.setPrivateIp(singleNic.getIp4Address()); |  | ||||||
|                 routerResponse.setPrivateMacAddress(singleNic.getMacAddress()); |  | ||||||
|                 routerResponse.setPrivateNetmask(singleNic.getNetmask()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             if (networkConf.getTrafficType() == TrafficType.Public) { |  | ||||||
|                 routerResponse.setPublicIp(singleNic.getIp4Address()); |  | ||||||
|                 routerResponse.setPublicMacAddress(singleNic.getMacAddress()); |  | ||||||
|                 routerResponse.setPublicNetmask(singleNic.getNetmask()); |  | ||||||
|                 routerResponse.setGateway(singleNic.getGateway()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             DataCenter zone = ApiDBUtils.findZoneById(router.getDataCenterId()); |  | ||||||
|             if (zone != null) { |  | ||||||
|                 routerResponse.setZoneName(zone.getName()); |  | ||||||
|                 routerResponse.setDns1(zone.getDns1()); |  | ||||||
|                 routerResponse.setDns2(zone.getDns2()); |  | ||||||
|             } |             } | ||||||
|  |              | ||||||
|  |             nicResponse.setObjectName("nic");  | ||||||
|  |             nicResponses.add(nicResponse); | ||||||
|  |         } | ||||||
|  |         routerResponse.setNics(nicResponses); | ||||||
|  |          | ||||||
|  |         DataCenter zone = ApiDBUtils.findZoneById(router.getDataCenterId()); | ||||||
|  |         if (zone != null) { | ||||||
|  |             routerResponse.setZoneName(zone.getName()); | ||||||
|  |             routerResponse.setDns1(zone.getDns1()); | ||||||
|  |             routerResponse.setDns2(zone.getDns2()); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         routerResponse.setObjectName("domainrouter"); |         routerResponse.setObjectName("domainrouter"); | ||||||
| @ -1321,25 +1334,26 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             List<? extends Nic> nics = ApiDBUtils.getNics(systemVM); |             List<? extends Nic> nics = ApiDBUtils.getNics(systemVM); | ||||||
|  |             List<NicResponse> nicResponses = new ArrayList<NicResponse>(); | ||||||
|             for (Nic singleNic : nics) { |             for (Nic singleNic : nics) { | ||||||
|                 Long configId = singleNic.getNetworkId(); |                 NicResponse nicResponse = new NicResponse(); | ||||||
|                 Network networkConf = ApiDBUtils.getNetwork(configId); |                 nicResponse.setId(singleNic.getId()); | ||||||
| 
 |                 nicResponse.setIpaddress(singleNic.getIp4Address()); | ||||||
|                 if (networkConf.getTrafficType() == TrafficType.Management) { |                 nicResponse.setGateway(singleNic.getGateway()); | ||||||
|                     vmResponse.setPrivateIp(singleNic.getIp4Address()); |                 nicResponse.setNetmask(singleNic.getNetmask()); | ||||||
|                     vmResponse.setPrivateMacAddress(singleNic.getMacAddress()); |                 nicResponse.setNetworkid(singleNic.getNetworkId()); | ||||||
|                     vmResponse.setPrivateNetmask(singleNic.getNetmask()); |                 if (singleNic.getBroadcastUri() != null) { | ||||||
|  |                     nicResponse.setBroadcastUri(singleNic.getBroadcastUri().toString()); | ||||||
|                 } |                 } | ||||||
| 
 |                 if (singleNic.getIsolationUri() != null) { | ||||||
|                 if (networkConf.getTrafficType() == TrafficType.Public) { |                     nicResponse.setIsolationUri(singleNic.getIsolationUri().toString()); | ||||||
|                     vmResponse.setPublicIp(singleNic.getIp4Address()); |  | ||||||
|                     vmResponse.setPublicMacAddress(singleNic.getMacAddress()); |  | ||||||
|                     vmResponse.setPublicNetmask(singleNic.getNetmask()); |  | ||||||
|                     vmResponse.setGateway(singleNic.getGateway()); |  | ||||||
|                 } |                 } | ||||||
|  |                  | ||||||
|  |                 nicResponse.setObjectName("nic"); | ||||||
|  |                 nicResponses.add(nicResponse); | ||||||
|             } |             } | ||||||
|  |             vmResponse.setNics(nicResponses); | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|         vmResponse.setObjectName("systemvm"); |         vmResponse.setObjectName("systemvm"); | ||||||
|         return vmResponse; |         return vmResponse; | ||||||
|     } |     } | ||||||
| @ -2159,7 +2173,7 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||||
|             capacityResponse.setZoneId(summedCapacity.getDataCenterId()); |             capacityResponse.setZoneId(summedCapacity.getDataCenterId()); | ||||||
|             capacityResponse.setZoneName(ApiDBUtils.findZoneById(summedCapacity.getDataCenterId()).getName()); |             capacityResponse.setZoneName(ApiDBUtils.findZoneById(summedCapacity.getDataCenterId()).getName()); | ||||||
|             if (summedCapacity.getTotalCapacity() != 0) { |             if (summedCapacity.getTotalCapacity() != 0) { | ||||||
|                 float computed = ((float)summedCapacity.getUsedCapacity() / (float)summedCapacity.getTotalCapacity() * 100f); |                 //float computed = ((float)summedCapacity.getUsedCapacity() / (float)summedCapacity.getTotalCapacity() * 100f); | ||||||
|                 capacityResponse.setPercentUsed(format.format((float)summedCapacity.getUsedCapacity() / (float)summedCapacity.getTotalCapacity() * 100f)); |                 capacityResponse.setPercentUsed(format.format((float)summedCapacity.getUsedCapacity() / (float)summedCapacity.getTotalCapacity() * 100f)); | ||||||
|             } else { |             } else { | ||||||
|                 capacityResponse.setPercentUsed(format.format(0L)); |                 capacityResponse.setPercentUsed(format.format(0L)); | ||||||
| @ -2264,4 +2278,68 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||||
|         } |         } | ||||||
|         return response; |         return response; | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public NetworkOfferingResponse createNetworkOfferingResponse(NetworkOffering offering) { | ||||||
|  |         NetworkOfferingResponse response = new NetworkOfferingResponse(); | ||||||
|  |         response.setId(offering.getId()); | ||||||
|  |         response.setName(offering.getName()); | ||||||
|  |         response.setDisplayText(offering.getDisplayText()); | ||||||
|  |         response.setTags(offering.getTags()); | ||||||
|  |         response.setTrafficType(offering.getTrafficType().toString()); | ||||||
|  |         if (offering.getGuestIpType() != null) { | ||||||
|  |             response.setType(offering.getGuestIpType().toString()); | ||||||
|  |         } | ||||||
|  |         response.setMaxconnections(offering.getConcurrentConnections()); | ||||||
|  |         response.setIsDefault(offering.isDefault()); | ||||||
|  |         response.setSpecifyVlan(offering.getSpecifyVlan()); | ||||||
|  |         response.setIsShared(offering.isShared()); | ||||||
|  |         response.setObjectName("networkoffering"); | ||||||
|  |         return response; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public NetworkResponse createNetworkResponse(Network network) { | ||||||
|  |         NetworkResponse response = new NetworkResponse(); | ||||||
|  |         response.setId(network.getId()); | ||||||
|  |         response.setName(network.getName()); | ||||||
|  |         response.setDisplaytext(network.getDisplayText()); | ||||||
|  |         if (network.getBroadcastDomainType() != null) { | ||||||
|  |             response.setBroadcastDomainType(network.getBroadcastDomainType().toString()); | ||||||
|  |         } | ||||||
|  |         if (network.getBroadcastUri() != null) { | ||||||
|  |             response.setBroadcastUri(network.getBroadcastUri().toString()); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (response.getTrafficType() != null) { | ||||||
|  |             response.setTrafficType(network.getTrafficType().toString()); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (response.getType() != null) { | ||||||
|  |             response.setType(network.getGuestType().toString()); | ||||||
|  |         } | ||||||
|  |         response.setGateway(network.getGateway()); | ||||||
|  |         response.setCidr(network.getCidr()); | ||||||
|  |         response.setZoneId(network.getDataCenterId()); | ||||||
|  |          | ||||||
|  |         //populate network offering information | ||||||
|  |         NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId()); | ||||||
|  |         if (networkOffering != null) { | ||||||
|  |             response.setNetworkOfferingId(networkOffering.getId()); | ||||||
|  |             response.setNetworkOfferingName(networkOffering.getName()); | ||||||
|  |             response.setNetworkOfferingDisplayText(networkOffering.getDisplayText()); | ||||||
|  |         } | ||||||
|  |         response.setState(network.getState().toString()); | ||||||
|  |         response.setRelated(network.getRelated()); | ||||||
|  |         response.setDns1(network.getDns1()); | ||||||
|  |         response.setDns2(network.getDns2()); | ||||||
|  | 
 | ||||||
|  |         Account account = ApiDBUtils.findAccountById(network.getAccountId()); | ||||||
|  |         if (account != null) { | ||||||
|  |             response.setAccountName(account.getAccountName()); | ||||||
|  |             response.setDomainId(account.getDomainId()); | ||||||
|  |         } | ||||||
|  |         response.setObjectName("network"); | ||||||
|  |         return response; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -198,7 +198,8 @@ public enum Config { | |||||||
|     SSOKey("Hidden", ManagementServer.class, String.class, "security.singlesignon.key", null, "A Single Sign-On key used for logging into the cloud", null), |     SSOKey("Hidden", ManagementServer.class, String.class, "security.singlesignon.key", null, "A Single Sign-On key used for logging into the cloud", null), | ||||||
|     SSOAuthTolerance("Advanced", ManagementServer.class, Long.class, "security.singlesignon.tolerance.millis", "300000", "The allowable clock difference in milliseconds between when an SSO login request is made and when it is received.", null), |     SSOAuthTolerance("Advanced", ManagementServer.class, Long.class, "security.singlesignon.tolerance.millis", "300000", "The allowable clock difference in milliseconds between when an SSO login request is made and when it is received.", null), | ||||||
| 	NetworkType("Hidden", ManagementServer.class, String.class, "network.type", "vlan", "The type of network that this deployment will use.", "vlan,direct"), | 	NetworkType("Hidden", ManagementServer.class, String.class, "network.type", "vlan", "The type of network that this deployment will use.", "vlan,direct"), | ||||||
| 	HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null); | 	HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null), | ||||||
|  | 	UseNewNetwork("Hidden", NetworkManager.class, Boolean.class, "use.new.networking", "false", null, null); | ||||||
| 	 | 	 | ||||||
| 	private final String _category; | 	private final String _category; | ||||||
| 	private final Class<?> _componentClass; | 	private final Class<?> _componentClass; | ||||||
|  | |||||||
| @ -19,15 +19,22 @@ package com.cloud.configuration; | |||||||
| 
 | 
 | ||||||
| import java.util.List; | import java.util.List; | ||||||
| 
 | 
 | ||||||
|  | import com.cloud.api.commands.CreateVlanIpRangeCmd; | ||||||
| import com.cloud.dc.DataCenter; | import com.cloud.dc.DataCenter; | ||||||
| import com.cloud.dc.DataCenter.DataCenterNetworkType; | import com.cloud.dc.DataCenter.DataCenterNetworkType; | ||||||
| import com.cloud.dc.DataCenterVO; | import com.cloud.dc.DataCenterVO; | ||||||
| import com.cloud.dc.HostPodVO; | import com.cloud.dc.HostPodVO; | ||||||
|  | import com.cloud.dc.Vlan; | ||||||
| import com.cloud.exception.ConcurrentOperationException; | import com.cloud.exception.ConcurrentOperationException; | ||||||
| import com.cloud.exception.InsufficientAddressCapacityException; | import com.cloud.exception.InsufficientAddressCapacityException; | ||||||
|  | import com.cloud.exception.InsufficientCapacityException; | ||||||
|  | import com.cloud.exception.InvalidParameterValueException; | ||||||
| import com.cloud.exception.PermissionDeniedException; | import com.cloud.exception.PermissionDeniedException; | ||||||
| import com.cloud.offering.DiskOffering; | import com.cloud.offering.DiskOffering; | ||||||
| import com.cloud.offering.ServiceOffering; | import com.cloud.offering.ServiceOffering; | ||||||
|  | import com.cloud.network.Networks.TrafficType; | ||||||
|  | import com.cloud.offering.NetworkOffering.GuestIpType; | ||||||
|  | import com.cloud.offerings.NetworkOfferingVO; | ||||||
| import com.cloud.service.ServiceOfferingVO; | import com.cloud.service.ServiceOfferingVO; | ||||||
| import com.cloud.storage.DiskOfferingVO; | import com.cloud.storage.DiskOfferingVO; | ||||||
| import com.cloud.user.Account; | import com.cloud.user.Account; | ||||||
| @ -63,8 +70,6 @@ public interface ConfigurationManager extends Manager { | |||||||
| 	 */ | 	 */ | ||||||
| 	ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean useVirtualNetwork, String tags, Long domainId); | 	ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean useVirtualNetwork, String tags, Long domainId); | ||||||
| 	 | 	 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Creates a new disk offering | 	 * Creates a new disk offering | ||||||
| 	 * @param domainId | 	 * @param domainId | ||||||
| @ -161,4 +166,22 @@ public interface ConfigurationManager extends Manager { | |||||||
| 
 | 
 | ||||||
| 	void checkDiskOfferingAccess(Account caller, DiskOffering dof) | 	void checkDiskOfferingAccess(Account caller, DiskOffering dof) | ||||||
| 			throws PermissionDeniedException; | 			throws PermissionDeniedException; | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	   /** | ||||||
|  |      * Creates a new network offering | ||||||
|  |      * @param id | ||||||
|  |      * @param name | ||||||
|  |      * @param displayText | ||||||
|  |      * @param type | ||||||
|  |      * @param trafficType | ||||||
|  |      * @param tags | ||||||
|  |      * @param maxConnections | ||||||
|  |      * @param specifyVlan; | ||||||
|  |      * @return network offering object | ||||||
|  |      */ | ||||||
|  |     NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, boolean isShared); | ||||||
|  |      | ||||||
|  |     Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException; | ||||||
|  | 	 | ||||||
| } | } | ||||||
|  | |||||||
| @ -34,15 +34,18 @@ import com.cloud.api.BaseCmd; | |||||||
| import com.cloud.api.ServerApiException; | import com.cloud.api.ServerApiException; | ||||||
| import com.cloud.api.commands.CreateCfgCmd; | import com.cloud.api.commands.CreateCfgCmd; | ||||||
| import com.cloud.api.commands.CreateDiskOfferingCmd; | import com.cloud.api.commands.CreateDiskOfferingCmd; | ||||||
|  | import com.cloud.api.commands.CreateNetworkOfferingCmd; | ||||||
| import com.cloud.api.commands.CreatePodCmd; | import com.cloud.api.commands.CreatePodCmd; | ||||||
| import com.cloud.api.commands.CreateServiceOfferingCmd; | import com.cloud.api.commands.CreateServiceOfferingCmd; | ||||||
| import com.cloud.api.commands.CreateVlanIpRangeCmd; | import com.cloud.api.commands.CreateVlanIpRangeCmd; | ||||||
| import com.cloud.api.commands.CreateZoneCmd; | import com.cloud.api.commands.CreateZoneCmd; | ||||||
| import com.cloud.api.commands.DeleteDiskOfferingCmd; | import com.cloud.api.commands.DeleteDiskOfferingCmd; | ||||||
|  | import com.cloud.api.commands.DeleteNetworkOfferingCmd; | ||||||
| import com.cloud.api.commands.DeletePodCmd; | import com.cloud.api.commands.DeletePodCmd; | ||||||
| import com.cloud.api.commands.DeleteServiceOfferingCmd; | import com.cloud.api.commands.DeleteServiceOfferingCmd; | ||||||
| import com.cloud.api.commands.DeleteVlanIpRangeCmd; | import com.cloud.api.commands.DeleteVlanIpRangeCmd; | ||||||
| import com.cloud.api.commands.DeleteZoneCmd; | import com.cloud.api.commands.DeleteZoneCmd; | ||||||
|  | import com.cloud.api.commands.ListNetworkOfferingsCmd; | ||||||
| import com.cloud.api.commands.UpdateCfgCmd; | import com.cloud.api.commands.UpdateCfgCmd; | ||||||
| import com.cloud.api.commands.UpdateDiskOfferingCmd; | import com.cloud.api.commands.UpdateDiskOfferingCmd; | ||||||
| import com.cloud.api.commands.UpdatePodCmd; | import com.cloud.api.commands.UpdatePodCmd; | ||||||
| @ -81,11 +84,14 @@ import com.cloud.exception.InvalidParameterValueException; | |||||||
| import com.cloud.exception.PermissionDeniedException; | import com.cloud.exception.PermissionDeniedException; | ||||||
| import com.cloud.hypervisor.Hypervisor.HypervisorType; | import com.cloud.hypervisor.Hypervisor.HypervisorType; | ||||||
| import com.cloud.network.NetworkManager; | import com.cloud.network.NetworkManager; | ||||||
|  | import com.cloud.network.Networks.TrafficType; | ||||||
| import com.cloud.network.dao.IPAddressDao; | import com.cloud.network.dao.IPAddressDao; | ||||||
| import com.cloud.offering.DiskOffering; | import com.cloud.offering.DiskOffering; | ||||||
| import com.cloud.offering.NetworkOffering; | import com.cloud.offering.NetworkOffering; | ||||||
| import com.cloud.offering.NetworkOffering.GuestIpType; | import com.cloud.offering.NetworkOffering.GuestIpType; | ||||||
| import com.cloud.offering.ServiceOffering; | import com.cloud.offering.ServiceOffering; | ||||||
|  | import com.cloud.offerings.NetworkOfferingVO; | ||||||
|  | import com.cloud.offerings.dao.NetworkOfferingDao; | ||||||
| import com.cloud.service.ServiceOfferingVO; | import com.cloud.service.ServiceOfferingVO; | ||||||
| import com.cloud.service.dao.ServiceOfferingDao; | import com.cloud.service.dao.ServiceOfferingDao; | ||||||
| import com.cloud.storage.DiskOfferingVO; | import com.cloud.storage.DiskOfferingVO; | ||||||
| @ -103,6 +109,8 @@ import com.cloud.utils.component.Adapters; | |||||||
| import com.cloud.utils.component.ComponentLocator; | import com.cloud.utils.component.ComponentLocator; | ||||||
| import com.cloud.utils.component.Inject; | import com.cloud.utils.component.Inject; | ||||||
| import com.cloud.utils.db.DB; | import com.cloud.utils.db.DB; | ||||||
|  | import com.cloud.utils.db.Filter; | ||||||
|  | import com.cloud.utils.db.SearchCriteria; | ||||||
| import com.cloud.utils.db.Transaction; | import com.cloud.utils.db.Transaction; | ||||||
| import com.cloud.utils.exception.CloudRuntimeException; | import com.cloud.utils.exception.CloudRuntimeException; | ||||||
| import com.cloud.utils.net.NetUtils; | import com.cloud.utils.net.NetUtils; | ||||||
| @ -131,6 +139,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
| 	@Inject DomainDao _domainDao; | 	@Inject DomainDao _domainDao; | ||||||
| 	@Inject ServiceOfferingDao _serviceOfferingDao; | 	@Inject ServiceOfferingDao _serviceOfferingDao; | ||||||
| 	@Inject DiskOfferingDao _diskOfferingDao; | 	@Inject DiskOfferingDao _diskOfferingDao; | ||||||
|  | 	@Inject NetworkOfferingDao _networkOfferingDao; | ||||||
| 	@Inject VlanDao _vlanDao; | 	@Inject VlanDao _vlanDao; | ||||||
| 	@Inject IPAddressDao _publicIpAddressDao; | 	@Inject IPAddressDao _publicIpAddressDao; | ||||||
| 	@Inject DataCenterIpAddressDao _privateIpAddressDao; | 	@Inject DataCenterIpAddressDao _privateIpAddressDao; | ||||||
| @ -1053,7 +1062,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|         String internalDns2 = cmd.getInternalDns2(); |         String internalDns2 = cmd.getInternalDns2(); | ||||||
|         String vnetRange = cmd.getVlan(); |         String vnetRange = cmd.getVlan(); | ||||||
|         String guestCidr = cmd.getGuestCidrAddress(); |         String guestCidr = cmd.getGuestCidrAddress(); | ||||||
|         String domain = cmd.getDomain();//we are not passing domain right now, always null |  | ||||||
|         Long domainId = cmd.getDomainId(); |         Long domainId = cmd.getDomainId(); | ||||||
|         String type = cmd.getNetworkType(); |         String type = cmd.getNetworkType(); | ||||||
|         Boolean isBasic = false; |         Boolean isBasic = false; | ||||||
| @ -1412,9 +1420,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
| 			return genChangeRangeSuccessString(problemIPs, add); | 			return genChangeRangeSuccessString(problemIPs, add); | ||||||
| 		} | 		} | ||||||
|     } |     } | ||||||
| 
 |      | ||||||
|     @Override |     @Override | ||||||
|     public Vlan createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException { |     public Vlan createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException { | ||||||
|         Long zoneId = cmd.getZoneId(); |         Long zoneId = cmd.getZoneId(); | ||||||
|         Long podId = cmd.getPodId(); |         Long podId = cmd.getPodId(); | ||||||
|         String startIP = cmd.getStartIp(); |         String startIP = cmd.getStartIp(); | ||||||
| @ -1422,12 +1430,25 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|         String vlanGateway = cmd.getGateway(); |         String vlanGateway = cmd.getGateway(); | ||||||
|         String vlanNetmask = cmd.getNetmask(); |         String vlanNetmask = cmd.getNetmask(); | ||||||
|         Long userId = UserContext.current().getUserId(); |         Long userId = UserContext.current().getUserId(); | ||||||
|          |         String vlanId = cmd.getVlan(); | ||||||
|         if (userId == null) { |         // If an account name and domain ID are specified, look up the account | ||||||
|             userId = Long.valueOf(User.UID_SYSTEM); |         String accountName = cmd.getAccountName(); | ||||||
|  |         Long domainId = cmd.getDomainId(); | ||||||
|  |         Account account = null; | ||||||
|  |         if ((accountName != null) && (domainId != null)) { | ||||||
|  |             account = _accountDao.findActiveAccount(accountName, domainId); | ||||||
|  |             if (account == null) { | ||||||
|  |                 throw new ServerApiException(BaseCmd.PARAM_ERROR, "Please specify a valid account."); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |         return createVlanAndPublicIpRange(userId, zoneId, podId, startIP, endIP, vlanGateway, vlanNetmask, true, vlanId, account, null); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException{ | ||||||
|          |          | ||||||
|      // Check that the pod ID is valid |         // Check that the pod ID is valid | ||||||
|         if (podId != null && ((_podDao.findById(podId)) == null)) { |         if (podId != null && ((_podDao.findById(podId)) == null)) { | ||||||
|             throw new InvalidParameterValueException("Please specify a valid pod."); |             throw new InvalidParameterValueException("Please specify a valid pod."); | ||||||
|         } |         } | ||||||
| @ -1436,15 +1457,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|         if (podId != null && _podDao.findById(podId).getDataCenterId() != zoneId) { |         if (podId != null && _podDao.findById(podId).getDataCenterId() != zoneId) { | ||||||
|             throw new InvalidParameterValueException("Pod id=" + podId + " doesn't belong to zone id=" + zoneId); |             throw new InvalidParameterValueException("Pod id=" + podId + " doesn't belong to zone id=" + zoneId); | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|         // If forVirtualNetworks isn't specified, default it to true |  | ||||||
|         Boolean forVirtualNetwork = cmd.isForVirtualNetwork(); |  | ||||||
|         if (forVirtualNetwork == null) { |  | ||||||
|             forVirtualNetwork = Boolean.TRUE; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         // If the VLAN id is null, default it to untagged |         // If the VLAN id is null, default it to untagged | ||||||
|         String vlanId = cmd.getVlan(); |  | ||||||
|         if (vlanId == null) { |         if (vlanId == null) { | ||||||
|             vlanId = Vlan.UNTAGGED; |             vlanId = Vlan.UNTAGGED; | ||||||
|         } |         } | ||||||
| @ -1466,17 +1479,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|             throw new InvalidParameterValueException("Can't add virtual network to the zone id=" + zone.getId() + " as zone doesn't have guest vlan configured"); |             throw new InvalidParameterValueException("Can't add virtual network to the zone id=" + zone.getId() + " as zone doesn't have guest vlan configured"); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // If an account name and domain ID are specified, look up the account |  | ||||||
|         String accountName = cmd.getAccountName(); |  | ||||||
|         Long domainId = cmd.getDomainId(); |  | ||||||
|         Account account = null; |  | ||||||
|         if ((accountName != null) && (domainId != null)) { |  | ||||||
|             account = _accountDao.findActiveAccount(accountName, domainId); |  | ||||||
|             if (account == null) { |  | ||||||
|                 throw new ServerApiException(BaseCmd.PARAM_ERROR, "Please specify a valid account."); |  | ||||||
|             } |  | ||||||
|         }        |  | ||||||
|          |  | ||||||
|         VlanType vlanType = forVirtualNetwork ? VlanType.VirtualNetwork : VlanType.DirectAttached; |         VlanType vlanType = forVirtualNetwork ? VlanType.VirtualNetwork : VlanType.DirectAttached; | ||||||
|          |          | ||||||
| 
 | 
 | ||||||
| @ -1643,7 +1645,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
| 		if (endIP != null) { | 		if (endIP != null) { | ||||||
| 			ipRange += "-" + endIP; | 			ipRange += "-" + endIP; | ||||||
| 		} | 		} | ||||||
| 		VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange); | 		VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange, networkId); | ||||||
| 		vlan = _vlanDao.persist(vlan); | 		vlan = _vlanDao.persist(vlan); | ||||||
| 		 | 		 | ||||||
| 		// Persist the IP range | 		// Persist the IP range | ||||||
| @ -1685,7 +1687,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
| 	        // if this is an account VLAN, now associate the IP Addresses to the account | 	        // if this is an account VLAN, now associate the IP Addresses to the account | ||||||
| 	        associateIpAddressListToAccount(userId, account.getId(), zoneId, vlan.getId()); | 	        associateIpAddressListToAccount(userId, account.getId(), zoneId, vlan.getId()); | ||||||
| 		} | 		} | ||||||
| 
 |  | ||||||
| 		return vlan; | 		return vlan; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -2378,4 +2379,155 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | |||||||
|         assert false : "How can all of the security checkers pass on checking this caller?"; |         assert false : "How can all of the security checkers pass on checking this caller?"; | ||||||
|         throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to zone:" + zone.getId()); |         throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to zone:" + zone.getId()); | ||||||
|     } |     } | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  |     @Override | ||||||
|  |     public NetworkOffering createNetworkOffering(CreateNetworkOfferingCmd cmd) throws InvalidParameterValueException { | ||||||
|  |         Long userId = UserContext.current().getUserId(); | ||||||
|  |         String name = cmd.getNetworkOfferingName(); | ||||||
|  |         String displayText = cmd.getDisplayText(); | ||||||
|  |         String tags = cmd.getTags(); | ||||||
|  |         String typeString = cmd.getType(); | ||||||
|  |         String trafficTypeString = cmd.getTraffictype(); | ||||||
|  |         Boolean specifyVlan = cmd.getSpecifyVlan(); | ||||||
|  |         Boolean isShared = cmd.getIsShared(); | ||||||
|  |         TrafficType trafficType = null; | ||||||
|  |         GuestIpType type = null; | ||||||
|  |          | ||||||
|  |         //Verify traffic type | ||||||
|  |         for (TrafficType tType : TrafficType.values()) { | ||||||
|  |             if (tType.name().equalsIgnoreCase(trafficTypeString)) { | ||||||
|  |                 trafficType = tType; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         if (trafficType == null) { | ||||||
|  |             throw new InvalidParameterValueException("Invalid value for traffictype. Supported traffic types: Public, Management, Control, Guest, Vlan or Storage"); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //Verify type | ||||||
|  |         for (GuestIpType gType : GuestIpType.values()) { | ||||||
|  |             if (gType.name().equalsIgnoreCase(typeString)) { | ||||||
|  |                 type = gType; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         if (type == null) { | ||||||
|  |             throw new InvalidParameterValueException("Invalid value for type. Supported types: Virtualized, DirectSingle, DirectDual"); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (specifyVlan == null) { | ||||||
|  |             specifyVlan = false; | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (isShared == null) { | ||||||
|  |             isShared = false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         Integer maxConnections = cmd.getMaxconnections(); | ||||||
|  |         return createNetworkOffering(userId, name, displayText, type, trafficType, tags, maxConnections, specifyVlan, isShared); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, boolean isShared) { | ||||||
|  |         String networkRateStr = _configDao.getValue("network.throttling.rate"); | ||||||
|  |         String multicastRateStr = _configDao.getValue("multicast.throttling.rate"); | ||||||
|  |         int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr)); | ||||||
|  |         int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));       | ||||||
|  |         tags = cleanupTags(tags); | ||||||
|  |         NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, type, false, specifyVlan, networkRate, multicastRate, maxConnections, isShared, false); | ||||||
|  |          | ||||||
|  |         if ((offering = _networkOfferingDao.persist(offering)) != null) { | ||||||
|  |             saveConfigurationEvent(userId, null, EventTypes.EVENT_NETWORK_OFFERING_CREATE, "Successfully created new network offering with name: " + name + ".", "noId=" + offering.getId(), "name=" + name, | ||||||
|  |                     "displayText=" + displayText, "tags=" + tags); | ||||||
|  |             return offering; | ||||||
|  |         } else { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public List<? extends NetworkOffering> searchForNetworkOfferings(ListNetworkOfferingsCmd cmd) { | ||||||
|  |         Filter searchFilter = new Filter(NetworkOfferingVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal()); | ||||||
|  |         SearchCriteria<NetworkOfferingVO> sc = _networkOfferingDao.createSearchCriteria(); | ||||||
|  |          | ||||||
|  |         Object id = cmd.getId(); | ||||||
|  |         Object name = cmd.getNetworkOfferingName(); | ||||||
|  |         Object displayText = cmd.getDisplayText(); | ||||||
|  |         Object type = cmd.getType(); | ||||||
|  |         Object trafficType = cmd.getTrafficType(); | ||||||
|  |         Object isDefault = cmd.getIsDefault(); | ||||||
|  |         Object specifyVlan = cmd.getSpecifyVlan(); | ||||||
|  |         Object isShared = cmd.getIsShared(); | ||||||
|  |          | ||||||
|  |         Object keyword = cmd.getKeyword(); | ||||||
|  | 
 | ||||||
|  |         if (keyword != null) { | ||||||
|  |             SearchCriteria<NetworkOfferingVO> ssc = _networkOfferingDao.createSearchCriteria(); | ||||||
|  |             ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%"); | ||||||
|  |             ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); | ||||||
|  | 
 | ||||||
|  |             sc.addAnd("name", SearchCriteria.Op.SC, ssc); | ||||||
|  |         }  | ||||||
|  | 
 | ||||||
|  |         if (id != null) { | ||||||
|  |             sc.addAnd("id", SearchCriteria.Op.EQ, id); | ||||||
|  |         } | ||||||
|  |         if (name != null) { | ||||||
|  |             sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%"); | ||||||
|  |         } | ||||||
|  |         if (displayText != null) { | ||||||
|  |             sc.addAnd("displayText", SearchCriteria.Op.LIKE, "%" + displayText + "%"); | ||||||
|  |         } | ||||||
|  |         if (type != null) { | ||||||
|  |             sc.addAnd("guestIpType", SearchCriteria.Op.EQ, type); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (trafficType != null) { | ||||||
|  |             sc.addAnd("trafficType", SearchCriteria.Op.EQ, trafficType); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (isDefault != null) { | ||||||
|  |             sc.addAnd("isDefault", SearchCriteria.Op.EQ, isDefault); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (specifyVlan != null) { | ||||||
|  |             sc.addAnd("specifyVlan", SearchCriteria.Op.EQ, specifyVlan); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (isShared != null) { | ||||||
|  |             sc.addAnd("isShared", SearchCriteria.Op.EQ, isShared); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //Don't return system network offerings to the user | ||||||
|  |         sc.addAnd("systemOnly", SearchCriteria.Op.EQ, false); | ||||||
|  |          | ||||||
|  |         return _networkOfferingDao.search(sc, searchFilter); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd) throws InvalidParameterValueException{         | ||||||
|  |         Long offeringId = cmd.getId(); | ||||||
|  |         Long userId = UserContext.current().getUserId(); | ||||||
|  | 
 | ||||||
|  |         //Verify network offering id | ||||||
|  |         NetworkOfferingVO offering = _networkOfferingDao.findById(offeringId); | ||||||
|  |         if (offering == null) { | ||||||
|  |             throw new InvalidParameterValueException("unable to find network offering " + offeringId); | ||||||
|  |         } else if (offering.getRemoved() != null || offering.isSystemOnly()) { | ||||||
|  |             throw new InvalidParameterValueException("unable to find network offering " + offeringId); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //Don't allow to delete default network offerings | ||||||
|  |         if (offering.isDefault() == true) { | ||||||
|  |             throw new InvalidParameterValueException("Default network offering can't be deleted"); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (_networkOfferingDao.remove(offeringId)) { | ||||||
|  |             saveConfigurationEvent(userId, null, EventTypes.EVENT_NETWORK_OFFERING_DELETE, "Successfully deleted network offering with name: " + offering.getName(), "noId=" + offeringId, "name=" + offering.getName(), | ||||||
|  |                     "displayText=" + offering.getDisplayText()); | ||||||
|  |             return true; | ||||||
|  |         } else { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1071,9 +1071,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx | |||||||
|         NicProfile defaultNic = new NicProfile(); |         NicProfile defaultNic = new NicProfile(); | ||||||
|         defaultNic.setDefaultNic(true); |         defaultNic.setDefaultNic(true); | ||||||
|         defaultNic.setDeviceId(2); |         defaultNic.setDeviceId(2); | ||||||
|         networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic)); |         networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan, null, null).get(0), defaultNic)); | ||||||
|         for (NetworkOfferingVO offering : offerings) { |         for (NetworkOfferingVO offering : offerings) { | ||||||
|             networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan).get(0), null)); |             networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan, null, null).get(0), null)); | ||||||
|         } |         } | ||||||
|         ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, _template.getId(), _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), 0); |         ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, _template.getId(), _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), 0); | ||||||
|         try { |         try { | ||||||
|  | |||||||
| @ -51,17 +51,21 @@ public class VlanVO implements Vlan { | |||||||
| 	@Column(name="description")  | 	@Column(name="description")  | ||||||
| 	String ipRange; | 	String ipRange; | ||||||
| 	 | 	 | ||||||
|  |     @Column(name="network_id") | ||||||
|  |     Long networkId; | ||||||
|  | 	 | ||||||
| 	@Column(name="vlan_type") | 	@Column(name="vlan_type") | ||||||
| 	@Enumerated(EnumType.STRING)  | 	@Enumerated(EnumType.STRING)  | ||||||
| 	VlanType vlanType; | 	VlanType vlanType; | ||||||
| 	 | 	 | ||||||
| 	public VlanVO(VlanType vlanType, String vlanTag, String vlanGateway, String vlanNetmask, long dataCenterId, String ipRange) { | 	public VlanVO(VlanType vlanType, String vlanTag, String vlanGateway, String vlanNetmask, long dataCenterId, String ipRange, Long networkId) { | ||||||
| 		this.vlanType = vlanType; | 		this.vlanType = vlanType; | ||||||
| 		this.vlanId = vlanTag; | 		this.vlanId = vlanTag; | ||||||
| 		this.vlanGateway = vlanGateway; | 		this.vlanGateway = vlanGateway; | ||||||
| 		this.vlanNetmask = vlanNetmask; | 		this.vlanNetmask = vlanNetmask; | ||||||
| 		this.dataCenterId = dataCenterId; | 		this.dataCenterId = dataCenterId; | ||||||
| 		this.ipRange = ipRange; | 		this.ipRange = ipRange; | ||||||
|  | 		this.networkId = networkId; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public VlanVO() { | 	public VlanVO() { | ||||||
| @ -107,4 +111,8 @@ public class VlanVO implements Vlan { | |||||||
| 	public VlanType getVlanType() { | 	public VlanType getVlanType() { | ||||||
| 		return vlanType; | 		return vlanType; | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  |     public Long getNetworkId() { | ||||||
|  |         return networkId; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -51,4 +51,6 @@ public interface VlanDao extends GenericDao<VlanVO, Long> { | |||||||
| 	List<VlanVO> listZoneWideVlans(long zoneId, VlanType vlanType, String vlanId); | 	List<VlanVO> listZoneWideVlans(long zoneId, VlanType vlanType, String vlanId); | ||||||
| 
 | 
 | ||||||
| 	List<VlanVO> searchForZoneWideVlans(long dcId, String vlanType,String vlanId); | 	List<VlanVO> searchForZoneWideVlans(long dcId, String vlanType,String vlanId); | ||||||
|  | 	 | ||||||
|  | 	List<VlanVO> listVlansByNetworkId(long networkId); | ||||||
| } | } | ||||||
|  | |||||||
| @ -55,6 +55,7 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao | |||||||
| 	protected SearchBuilder<VlanVO> ZoneTypeAllPodsSearch; | 	protected SearchBuilder<VlanVO> ZoneTypeAllPodsSearch; | ||||||
| 	protected SearchBuilder<VlanVO> ZoneTypePodSearch; | 	protected SearchBuilder<VlanVO> ZoneTypePodSearch; | ||||||
| 	protected SearchBuilder<VlanVO> ZoneVlanSearch; | 	protected SearchBuilder<VlanVO> ZoneVlanSearch; | ||||||
|  | 	protected SearchBuilder<VlanVO> NetworkVlanSearch; | ||||||
| 
 | 
 | ||||||
| 	protected PodVlanMapDaoImpl _podVlanMapDao = new PodVlanMapDaoImpl(); | 	protected PodVlanMapDaoImpl _podVlanMapDao = new PodVlanMapDaoImpl(); | ||||||
| 	protected AccountVlanMapDao _accountVlanMapDao = new AccountVlanMapDaoImpl(); | 	protected AccountVlanMapDao _accountVlanMapDao = new AccountVlanMapDaoImpl(); | ||||||
| @ -90,6 +91,9 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao | |||||||
|         ZoneTypeSearch.and("vlanType", ZoneTypeSearch.entity().getVlanType(), SearchCriteria.Op.EQ); |         ZoneTypeSearch.and("vlanType", ZoneTypeSearch.entity().getVlanType(), SearchCriteria.Op.EQ); | ||||||
|         ZoneTypeSearch.done(); |         ZoneTypeSearch.done(); | ||||||
|          |          | ||||||
|  |         NetworkVlanSearch = createSearchBuilder(); | ||||||
|  |         NetworkVlanSearch.and("networkOfferingId", NetworkVlanSearch.entity().getNetworkId(), SearchCriteria.Op.EQ); | ||||||
|  |         NetworkVlanSearch.done(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
| @ -299,7 +303,13 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao | |||||||
| 	    } catch (SQLException e) { | 	    } catch (SQLException e) { | ||||||
| 	        throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e); | 	        throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e); | ||||||
| 	    } | 	    } | ||||||
| 
 |  | ||||||
| 	} | 	} | ||||||
|      |      | ||||||
|  | 	@Override | ||||||
|  |     public List<VlanVO> listVlansByNetworkId(long networkOfferingId) { | ||||||
|  |        SearchCriteria<VlanVO> sc = NetworkVlanSearch.create(); | ||||||
|  |         sc.setParameters("networkOfferingId", networkOfferingId); | ||||||
|  |         return listBy(sc); | ||||||
|  |     } | ||||||
|  | 	 | ||||||
| } | } | ||||||
|  | |||||||
| @ -220,8 +220,8 @@ public interface NetworkManager extends NetworkService { | |||||||
|      */ |      */ | ||||||
|     List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat);	 |     List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat);	 | ||||||
|      |      | ||||||
|     List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan); |     List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText); | ||||||
|     List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan); |     List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText); | ||||||
|      |      | ||||||
|     List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames); |     List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames); | ||||||
|      |      | ||||||
|  | |||||||
| @ -50,11 +50,14 @@ import com.cloud.api.commands.AddVpnUserCmd; | |||||||
| import com.cloud.api.commands.AssignToLoadBalancerRuleCmd; | import com.cloud.api.commands.AssignToLoadBalancerRuleCmd; | ||||||
| import com.cloud.api.commands.AssociateIPAddrCmd; | import com.cloud.api.commands.AssociateIPAddrCmd; | ||||||
| import com.cloud.api.commands.CreateLoadBalancerRuleCmd; | import com.cloud.api.commands.CreateLoadBalancerRuleCmd; | ||||||
|  | import com.cloud.api.commands.CreateNetworkCmd; | ||||||
| import com.cloud.api.commands.CreatePortForwardingRuleCmd; | import com.cloud.api.commands.CreatePortForwardingRuleCmd; | ||||||
| import com.cloud.api.commands.CreateRemoteAccessVpnCmd; | import com.cloud.api.commands.CreateRemoteAccessVpnCmd; | ||||||
| import com.cloud.api.commands.DeleteLoadBalancerRuleCmd; | import com.cloud.api.commands.DeleteLoadBalancerRuleCmd; | ||||||
|  | import com.cloud.api.commands.DeleteNetworkCmd; | ||||||
| import com.cloud.api.commands.DeleteRemoteAccessVpnCmd; | import com.cloud.api.commands.DeleteRemoteAccessVpnCmd; | ||||||
| import com.cloud.api.commands.DisassociateIPAddrCmd; | import com.cloud.api.commands.DisassociateIPAddrCmd; | ||||||
|  | import com.cloud.api.commands.ListNetworksCmd; | ||||||
| import com.cloud.api.commands.ListPortForwardingRulesCmd; | import com.cloud.api.commands.ListPortForwardingRulesCmd; | ||||||
| import com.cloud.api.commands.RemoveFromLoadBalancerRuleCmd; | import com.cloud.api.commands.RemoveFromLoadBalancerRuleCmd; | ||||||
| import com.cloud.api.commands.RemoveVpnUserCmd; | import com.cloud.api.commands.RemoveVpnUserCmd; | ||||||
| @ -69,12 +72,14 @@ import com.cloud.configuration.dao.ResourceLimitDao; | |||||||
| import com.cloud.dc.DataCenter; | import com.cloud.dc.DataCenter; | ||||||
| import com.cloud.dc.DataCenterVO; | import com.cloud.dc.DataCenterVO; | ||||||
| import com.cloud.dc.HostPodVO; | import com.cloud.dc.HostPodVO; | ||||||
|  | import com.cloud.dc.Vlan; | ||||||
| import com.cloud.dc.Vlan.VlanType; | import com.cloud.dc.Vlan.VlanType; | ||||||
| import com.cloud.dc.VlanVO; | import com.cloud.dc.VlanVO; | ||||||
| import com.cloud.dc.dao.AccountVlanMapDao; | import com.cloud.dc.dao.AccountVlanMapDao; | ||||||
| import com.cloud.dc.dao.DataCenterDao; | import com.cloud.dc.dao.DataCenterDao; | ||||||
| import com.cloud.dc.dao.HostPodDao; | import com.cloud.dc.dao.HostPodDao; | ||||||
| import com.cloud.dc.dao.VlanDao; | import com.cloud.dc.dao.VlanDao; | ||||||
|  | import com.cloud.deploy.DataCenterDeployment; | ||||||
| import com.cloud.deploy.DeployDestination; | import com.cloud.deploy.DeployDestination; | ||||||
| import com.cloud.deploy.DeploymentPlan; | import com.cloud.deploy.DeploymentPlan; | ||||||
| import com.cloud.domain.dao.DomainDao; | import com.cloud.domain.dao.DomainDao; | ||||||
| @ -97,6 +102,7 @@ import com.cloud.exception.ResourceUnavailableException; | |||||||
| import com.cloud.host.HostVO; | import com.cloud.host.HostVO; | ||||||
| import com.cloud.host.dao.HostDao; | import com.cloud.host.dao.HostDao; | ||||||
| import com.cloud.hypervisor.Hypervisor.HypervisorType; | import com.cloud.hypervisor.Hypervisor.HypervisorType; | ||||||
|  | import com.cloud.network.Networks.AddressFormat; | ||||||
| import com.cloud.network.Networks.TrafficType; | import com.cloud.network.Networks.TrafficType; | ||||||
| import com.cloud.network.configuration.NetworkGuru; | import com.cloud.network.configuration.NetworkGuru; | ||||||
| import com.cloud.network.dao.FirewallRulesDao; | import com.cloud.network.dao.FirewallRulesDao; | ||||||
| @ -143,6 +149,7 @@ import com.cloud.utils.component.Adapters; | |||||||
| import com.cloud.utils.component.Inject; | import com.cloud.utils.component.Inject; | ||||||
| import com.cloud.utils.component.Manager; | import com.cloud.utils.component.Manager; | ||||||
| import com.cloud.utils.db.DB; | import com.cloud.utils.db.DB; | ||||||
|  | import com.cloud.utils.db.Filter; | ||||||
| import com.cloud.utils.db.JoinBuilder; | import com.cloud.utils.db.JoinBuilder; | ||||||
| import com.cloud.utils.db.JoinBuilder.JoinType; | import com.cloud.utils.db.JoinBuilder.JoinType; | ||||||
| import com.cloud.utils.db.SearchBuilder; | import com.cloud.utils.db.SearchBuilder; | ||||||
| @ -206,7 +213,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|     @Inject UserStatisticsDao _statsDao = null; |     @Inject UserStatisticsDao _statsDao = null; | ||||||
|     @Inject NetworkOfferingDao _networkOfferingDao = null; |     @Inject NetworkOfferingDao _networkOfferingDao = null; | ||||||
|     @Inject NetworkDao _networkConfigDao = null; |     @Inject NetworkDao _networkConfigDao = null; | ||||||
|     @Inject NicDao _nicDao; |     @Inject NicDao _nicDao = null; | ||||||
|     @Inject GuestOSDao _guestOSDao = null; |     @Inject GuestOSDao _guestOSDao = null; | ||||||
|     @Inject RemoteAccessVpnDao _remoteAccessVpnDao = null; |     @Inject RemoteAccessVpnDao _remoteAccessVpnDao = null; | ||||||
|     @Inject VpnUserDao _vpnUsersDao = null; |     @Inject VpnUserDao _vpnUsersDao = null; | ||||||
| @ -1720,9 +1727,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|         storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering); |         storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering); | ||||||
|         _systemNetworks.put(NetworkOfferingVO.SystemVmStorageNetwork, storageNetworkOffering); |         _systemNetworks.put(NetworkOfferingVO.SystemVmStorageNetwork, storageNetworkOffering); | ||||||
| 
 | 
 | ||||||
|         NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtualized, false, false, rateMbps, multicastRateMbps, null); |         NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtualized, false, false, rateMbps, multicastRateMbps, null, false, true); | ||||||
|         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering); |         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering); | ||||||
|         NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, GuestIpType.DirectSingle, false, false, rateMbps, multicastRateMbps, null); |         NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, GuestIpType.DirectSingle, false, false, rateMbps, multicastRateMbps, null, false, true); | ||||||
|         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering); |         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering); | ||||||
| 
 | 
 | ||||||
|         AccountsUsingNetworkConfigurationSearch = _accountDao.createSearchBuilder(); |         AccountsUsingNetworkConfigurationSearch = _accountDao.createSearchBuilder(); | ||||||
| @ -1802,12 +1809,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan) { |     public List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText) { | ||||||
|         return setupNetworkConfiguration(owner, offering, null, plan); |         return setupNetworkConfiguration(owner, offering, null, plan, name, displayText); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan) { |     public List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText) { | ||||||
|         List<NetworkVO> configs = _networkConfigDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId()); |         List<NetworkVO> configs = _networkConfigDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId()); | ||||||
|         if (configs.size() > 0) { |         if (configs.size() > 0) { | ||||||
|             if (s_logger.isDebugEnabled()) { |             if (s_logger.isDebugEnabled()) { | ||||||
| @ -1840,7 +1847,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|                 related = id; |                 related = id; | ||||||
|             }  |             }  | ||||||
| 
 | 
 | ||||||
|             NetworkVO vo = new NetworkVO(id, config, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related); |             NetworkVO vo = new NetworkVO(id, config, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText); | ||||||
|             configs.add(_networkConfigDao.persist(vo)); |             configs.add(_networkConfigDao.persist(vo)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -1881,12 +1888,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|             NetworkVO config = network.first(); |             NetworkVO config = network.first(); | ||||||
|             NetworkGuru concierge = _networkGurus.get(config.getGuruName()); |             NetworkGuru concierge = _networkGurus.get(config.getGuruName()); | ||||||
|             NicProfile requested = network.second(); |             NicProfile requested = network.second(); | ||||||
|  |             if (requested != null && requested.getMode() == null) { | ||||||
|  |                 requested.setMode(config.getMode()); | ||||||
|  |             } | ||||||
|             NicProfile profile = concierge.allocate(config, requested, vm); |             NicProfile profile = concierge.allocate(config, requested, vm); | ||||||
|             if (profile == null) { |             if (profile == null) { | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|             NicVO vo = new NicVO(concierge.getName(), vm.getId(), config.getId()); |             NicVO vo = new NicVO(concierge.getName(), vm.getId(), config.getId()); | ||||||
|             vo.setMode(network.first().getMode()); |  | ||||||
| 
 | 
 | ||||||
|             while (deviceIds[deviceId] && deviceId < deviceIds.length) { |             while (deviceIds[deviceId] && deviceId < deviceIds.length) { | ||||||
|                 deviceId++; |                 deviceId++; | ||||||
| @ -1931,12 +1940,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|         } else if (deviceId != null ) { |         } else if (deviceId != null ) { | ||||||
|             vo.setDeviceId(deviceId++); |             vo.setDeviceId(deviceId++); | ||||||
|         } |         } | ||||||
|  |          | ||||||
|  |         vo.setReservationStrategy(profile.getReservationStrategy()); | ||||||
| 
 | 
 | ||||||
|         vo.setDefaultNic(profile.isDefaultNic()); |         vo.setDefaultNic(profile.isDefaultNic()); | ||||||
| 
 | 
 | ||||||
|         if (profile.getIp4Address() != null) { |         if (profile.getIp4Address() != null) { | ||||||
|             vo.setIp4Address(profile.getIp4Address()); |             vo.setIp4Address(profile.getIp4Address()); | ||||||
|             vo.setState(NicVO.State.Reserved); |             vo.setState(NicVO.State.Reserved); | ||||||
|  |             vo.setAddressFormat(AddressFormat.Ip4); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (profile.getMacAddress() != null) { |         if (profile.getMacAddress() != null) { | ||||||
| @ -2079,6 +2091,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|                     } |                     } | ||||||
|                     element.prepare(config, profile, vmProfile, dest, context); |                     element.prepare(config, profile, vmProfile, dest, context); | ||||||
|                 } |                 } | ||||||
|  |             } else { | ||||||
|  |                 profile = new NicProfile(nic, config, nic.getBroadcastUri(), nic.getIsolationUri()); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             vmProfile.addNic(profile); |             vmProfile.addNic(profile); | ||||||
| @ -2670,7 +2684,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|     @Override |     @Override | ||||||
|     public List<NetworkVO> setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan) { |     public List<NetworkVO> setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan) { | ||||||
|         NetworkOfferingVO networkOffering = _networkOfferingDao.findByServiceOffering(offering); |         NetworkOfferingVO networkOffering = _networkOfferingDao.findByServiceOffering(offering); | ||||||
|         return setupNetworkConfiguration(owner, networkOffering, plan); |         return setupNetworkConfiguration(owner, networkOffering, plan, null, null); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private String [] getGuestIpRange() { |     private String [] getGuestIpRange() { | ||||||
| @ -3289,4 +3303,234 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     @Override @DB | ||||||
|  |     public Network createNetwork(CreateNetworkCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{ | ||||||
|  |         Account ctxAccount = UserContext.current().getAccount(); | ||||||
|  |         Long userId = UserContext.current().getUserId(); | ||||||
|  |         Long networkOfferingId = cmd.getNetworkOfferingId(); | ||||||
|  |         Long zoneId = cmd.getZoneId(); | ||||||
|  |         Long podId = cmd.getPodId(); | ||||||
|  |         String gateway = cmd.getGateway(); | ||||||
|  |         String cidr = cmd.getCidr(); | ||||||
|  |         String startIP = cmd.getStartIp(); | ||||||
|  |         String endIP = cmd.getEndIp(); | ||||||
|  |         String vlanNetmask = cmd.getNetmask(); | ||||||
|  |         String accountName = cmd.getAccountName(); | ||||||
|  |         Long domainId = cmd.getDomainId(); | ||||||
|  |         String vlanId = cmd.getVlan(); | ||||||
|  |         String name = cmd.getNetworkName(); | ||||||
|  |         String displayText = cmd.getDisplayText(); | ||||||
|  |         Account owner = null; | ||||||
|  |          | ||||||
|  |         //Check if network offering exists | ||||||
|  |         NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId); | ||||||
|  |         if (networkOffering == null || networkOffering.isSystemOnly()) { | ||||||
|  |             throw new InvalidParameterValueException("Unable to find network offeirng by id " + networkOfferingId); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //Check if zone exists | ||||||
|  |         if (zoneId == null || ((_dcDao.findById(zoneId)) == null)) { | ||||||
|  |             throw new InvalidParameterValueException("Please specify a valid zone."); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //Check permissions | ||||||
|  |         if (isAdmin(ctxAccount.getType())) { | ||||||
|  |             if (domainId != null) { | ||||||
|  |                 if ((ctxAccount != null) && !_domainDao.isChildDomain(ctxAccount.getDomainId(), domainId)) { | ||||||
|  |                     throw new PermissionDeniedException("Failed to create a newtwork, invalid domain id (" + domainId + ") given."); | ||||||
|  |                 } | ||||||
|  |                 if (accountName != null) { | ||||||
|  |                     owner = _accountDao.findActiveAccount(accountName, domainId); | ||||||
|  |                     if (owner == null) { | ||||||
|  |                         throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  |                 owner = ctxAccount; | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|  |             owner = ctxAccount; | ||||||
|  |         } | ||||||
|  |         | ||||||
|  |         if (owner.getId() == Account.ACCOUNT_ID_SYSTEM && !networkOffering.isShared()) { | ||||||
|  |             throw new InvalidParameterValueException("Non-system account is required when create a network from Dedicated network offering with id=" + networkOfferingId); | ||||||
|  |         }  | ||||||
|  |          | ||||||
|  |        //VlanId can be specified only when network offering supports it | ||||||
|  |         if (vlanId != null && !networkOffering.getSpecifyVlan()) { | ||||||
|  |             throw new InvalidParameterValueException("Can't specify vlan because network offering doesn't support it"); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //If gateway, startIp, endIp are speicified, cidr should be present as well | ||||||
|  |         if (gateway != null && startIP != null && endIP != null && cidr == null) { | ||||||
|  |             throw new InvalidParameterValueException("Cidr is missing"); | ||||||
|  |         } | ||||||
|  |              | ||||||
|  |        Transaction txn = Transaction.currentTxn(); | ||||||
|  |        txn.start(); | ||||||
|  |        try { | ||||||
|  |            //Create network | ||||||
|  |            DataCenterDeployment plan = new DataCenterDeployment(zoneId, null, null, null); | ||||||
|  |            NetworkVO userNetwork = new NetworkVO(); | ||||||
|  |             | ||||||
|  |            //cidr should be set only when the user is admin | ||||||
|  |            if (ctxAccount.getType() == Account.ACCOUNT_TYPE_ADMIN && cidr != null && gateway != null) { | ||||||
|  |                userNetwork.setCidr(cidr); | ||||||
|  |                userNetwork.setGateway(gateway); | ||||||
|  |                if (vlanId != null) { | ||||||
|  |                    userNetwork.setBroadcastUri(URI.create("vlan://" + vlanId)); | ||||||
|  |                } | ||||||
|  |            } | ||||||
|  |             | ||||||
|  |            List<NetworkVO> networks = setupNetworkConfiguration(owner, networkOffering, userNetwork, plan, name, displayText); | ||||||
|  |            Long networkId = null; | ||||||
|  |             | ||||||
|  |            if (networks == null || networks.isEmpty()) { | ||||||
|  |                txn.rollback(); | ||||||
|  |                throw new CloudRuntimeException("Fail to create a network"); | ||||||
|  |            } else { | ||||||
|  |                networkId = networks.get(0).getId(); | ||||||
|  |            } | ||||||
|  |             | ||||||
|  |            //If network offering is shared, don't pass owner account and networkOfferingId for vlan | ||||||
|  |            if (networkOffering.isShared()) { | ||||||
|  |                owner = null; | ||||||
|  |            } | ||||||
|  |             | ||||||
|  |            if (ctxAccount.getType() == Account.ACCOUNT_TYPE_ADMIN && networkOffering.getGuestIpType() != GuestIpType.Virtualized && startIP != null && endIP != null && gateway != null) { | ||||||
|  |                //Create vlan ip range | ||||||
|  |                Vlan vlan = _configMgr.createVlanAndPublicIpRange(userId, zoneId, podId, startIP, endIP, gateway, vlanNetmask, false, vlanId, owner, networkId); | ||||||
|  |                if (vlan == null) { | ||||||
|  |                    txn.rollback(); | ||||||
|  |                    throw new CloudRuntimeException("Fail to create a vlan"); | ||||||
|  |                } | ||||||
|  |            }   | ||||||
|  |            txn.commit(); | ||||||
|  |            return networks.get(0); | ||||||
|  |        } catch (Exception ex) { | ||||||
|  |            s_logger.warn("Unexpected exception while creating network ", ex); | ||||||
|  |            txn.rollback(); | ||||||
|  |        }finally { | ||||||
|  |            txn.close(); | ||||||
|  |        } | ||||||
|  |        return null; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public List<? extends Network> searchForNetworks(ListNetworksCmd cmd) {  | ||||||
|  |         Object id = cmd.getId();  | ||||||
|  |         Object keyword = cmd.getKeyword(); | ||||||
|  |         Account account = UserContext.current().getAccount(); | ||||||
|  |         Long domainId = cmd.getDomainId(); | ||||||
|  |         String accountName = cmd.getAccountName(); | ||||||
|  |         Long accountId = null; | ||||||
|  |         if (isAdmin(account.getType())) { | ||||||
|  |             if (domainId != null) { | ||||||
|  |                 if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) { | ||||||
|  |                     throw new PermissionDeniedException("Invalid domain id (" + domainId + ") given, unable to list networks"); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if (accountName != null) { | ||||||
|  |                     account = _accountDao.findActiveAccount(accountName, domainId); | ||||||
|  |                     if (account == null) { | ||||||
|  |                         throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId); | ||||||
|  |                     } | ||||||
|  |                     accountId = account.getId(); | ||||||
|  |                 } | ||||||
|  |             }  | ||||||
|  |         } else { | ||||||
|  |             accountId = account.getId(); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |          | ||||||
|  |         Filter searchFilter = new Filter(NetworkVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal()); | ||||||
|  |         SearchCriteria<NetworkVO> sc = _networkConfigDao.createSearchCriteria(); | ||||||
|  |          | ||||||
|  |         if (keyword != null) { | ||||||
|  |             SearchCriteria<NetworkVO> ssc = _networkConfigDao.createSearchCriteria(); | ||||||
|  |             ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); | ||||||
|  |             sc.addAnd("name", SearchCriteria.Op.SC, ssc); | ||||||
|  |         }  | ||||||
|  | 
 | ||||||
|  |         if (id != null) { | ||||||
|  |             sc.addAnd("id", SearchCriteria.Op.EQ, id); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (accountId != null) { | ||||||
|  |             sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId); | ||||||
|  |         } | ||||||
|  |         return _networkConfigDao.search(sc, searchFilter); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override @DB | ||||||
|  |     public boolean deleteNetwork(DeleteNetworkCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{         | ||||||
|  |         Long networkId = cmd.getId(); | ||||||
|  |         Long userId = UserContext.current().getUserId(); | ||||||
|  |         Account account = UserContext.current().getAccount(); | ||||||
|  | 
 | ||||||
|  |         //Verify network id | ||||||
|  |         NetworkVO network = _networkConfigDao.findById(networkId); | ||||||
|  |         if (network == null) { | ||||||
|  |             throw new InvalidParameterValueException("unable to find network " + networkId); | ||||||
|  |         }  | ||||||
|  |          | ||||||
|  |         //Perform permission check | ||||||
|  |         if (account != null) { | ||||||
|  |             if (!isAdmin(account.getType())) { | ||||||
|  |                 if (network.getAccountId() != account.getId()) { | ||||||
|  |                     throw new PermissionDeniedException("Account " + account.getAccountName() + " does not own network id=" + networkId + ", permission denied"); | ||||||
|  |                 } | ||||||
|  |             } else if (!(account.getType() == Account.ACCOUNT_TYPE_ADMIN) && !_domainDao.isChildDomain(account.getDomainId(), _accountDao.findById(network.getAccountId()).getId())) { | ||||||
|  |                 throw new PermissionDeniedException("Unable to delete network " + networkId + ", permission denied."); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //Don't allow to remove network if there are non-destroyed vms using it | ||||||
|  |         List<NicVO> nics = _nicDao.listByNetworkId(networkId); | ||||||
|  |         for (NicVO nic : nics) { | ||||||
|  |             UserVm vm = _vmDao.findById(nic.getId()); | ||||||
|  |             if (vm.getState() != State.Destroyed || vm.getState() != State.Expunging || vm.getState() != State.Error) { | ||||||
|  |                 throw new CloudRuntimeException("Can't delete a network; make sure that all vms using the network are destroyed"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //for regular user don't allow to remove network when it's in any other states but allocated | ||||||
|  |         if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) { | ||||||
|  |             if (network.getState() != Network.State.Allocated) { | ||||||
|  |                 throw new InvalidParameterValueException("Non-admin user can delete network in " + Network.State.Allocated + " state only."); | ||||||
|  |             }     | ||||||
|  |         } else { | ||||||
|  |             if (!(network.getState() == Network.State.Allocated || network.getState() == Network.State.Setup)) { | ||||||
|  |                 throw new InvalidParameterValueException("Can delete network in " + Network.State.Allocated + " and " + Network.State.Setup + " states only."); | ||||||
|  |             }     | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         //remove all the vlans associated with the network | ||||||
|  |         Transaction txn = Transaction.currentTxn(); | ||||||
|  |         try { | ||||||
|  |             //remove corresponding vlans | ||||||
|  |             List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId); | ||||||
|  |             for (VlanVO vlan : vlans) { | ||||||
|  |                 boolean result = _configMgr.deleteVlanAndPublicIpRange(userId, vlan.getId()); | ||||||
|  |                 if (result == false) { | ||||||
|  |                     txn.rollback(); | ||||||
|  |                     throw new CloudRuntimeException("Unable to delete a network: failed to delete corresponding vlan with id " + vlan.getId()); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |              | ||||||
|  |             //remove networks | ||||||
|  |             _networkConfigDao.remove(networkId); | ||||||
|  |              | ||||||
|  |             txn.commit(); | ||||||
|  |             return true; | ||||||
|  |         } catch (Exception ex) { | ||||||
|  |             txn.rollback(); | ||||||
|  |             s_logger.warn("Unexpected exception during deleting a network ", ex); | ||||||
|  |             return false; | ||||||
|  |         } finally { | ||||||
|  |             txn.close(); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -62,6 +62,12 @@ public class NetworkVO implements Network { | |||||||
|     @Column(name="guest_type") |     @Column(name="guest_type") | ||||||
|     GuestIpType guestType; |     GuestIpType guestType; | ||||||
|      |      | ||||||
|  |     @Column(name="name") | ||||||
|  |     String name; | ||||||
|  |      | ||||||
|  |     @Column(name="display_text") | ||||||
|  |     String displayText;; | ||||||
|  |      | ||||||
|     @Column(name="broadcast_uri") |     @Column(name="broadcast_uri") | ||||||
|     URI broadcastUri;  |     URI broadcastUri;  | ||||||
|      |      | ||||||
| @ -131,12 +137,13 @@ public class NetworkVO implements Network { | |||||||
|         this.guestType = guestType; |         this.guestType = guestType; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related) { |     public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText) { | ||||||
|         this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related); |         this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText); | ||||||
|         this.gateway = that.getGateway(); |         this.gateway = that.getGateway(); | ||||||
|         this.dns1 = that.getDns1(); |         this.dns1 = that.getDns1(); | ||||||
|         this.dns2 = that.getDns2(); |         this.dns2 = that.getDns2(); | ||||||
|         this.cidr = that.getCidr(); |         this.cidr = that.getCidr(); | ||||||
|  |         this.broadcastUri = that.getBroadcastUri(); | ||||||
|         this.guruName = guruName; |         this.guruName = guruName; | ||||||
|         this.state = that.getState(); |         this.state = that.getState(); | ||||||
|         if (state == null) { |         if (state == null) { | ||||||
| @ -153,13 +160,17 @@ public class NetworkVO implements Network { | |||||||
|      * @param dataCenterId |      * @param dataCenterId | ||||||
|      * @param domainId |      * @param domainId | ||||||
|      * @param accountId |      * @param accountId | ||||||
|  |      * @param name | ||||||
|  |      * @param displayText | ||||||
|      */ |      */ | ||||||
|     public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related) { |     public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related, String name, String displayText) { | ||||||
|         this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId); |         this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId); | ||||||
|         this.domainId = domainId; |         this.domainId = domainId; | ||||||
|         this.accountId = accountId; |         this.accountId = accountId; | ||||||
|         this.related = related; |         this.related = related; | ||||||
|         this.id = id; |         this.id = id; | ||||||
|  |         this.name = name; | ||||||
|  |         this.displayText = displayText; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
| @ -299,8 +310,24 @@ public class NetworkVO implements Network { | |||||||
|         this.dns2 = dns; |         this.dns2 = dns; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     @Override | ||||||
|  |     public String getName() { | ||||||
|  |         return name; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setName(String name) { | ||||||
|  |         this.name = name; | ||||||
|  |     } | ||||||
|      |      | ||||||
|      |     @Override | ||||||
|  |     public String getDisplayText() { | ||||||
|  |         return displayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setDisplayText(String displayText) { | ||||||
|  |         this.displayText = displayText; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     @Override |     @Override | ||||||
|     public boolean equals(Object obj) { |     public boolean equals(Object obj) { | ||||||
|         if (!(obj instanceof NetworkVO)) { |         if (!(obj instanceof NetworkVO)) { | ||||||
|  | |||||||
| @ -101,10 +101,11 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru { | |||||||
|                 String[] cidrTuple = guestNetworkCidr.split("\\/"); |                 String[] cidrTuple = guestNetworkCidr.split("\\/"); | ||||||
|                 config.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1]))); |                 config.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1]))); | ||||||
|                 config.setCidr(guestNetworkCidr); |                 config.setCidr(guestNetworkCidr); | ||||||
|                 config.setDns1(dc.getDns1()); |  | ||||||
|                 config.setDns2(dc.getDns2()); |  | ||||||
|             } |             } | ||||||
|              |              | ||||||
|  |             config.setDns1(dc.getDns1()); | ||||||
|  |             config.setDns2(dc.getDns2()); | ||||||
|  |              | ||||||
|             if (userSpecified.getBroadcastUri() != null) { |             if (userSpecified.getBroadcastUri() != null) { | ||||||
|                 config.setBroadcastUri(userSpecified.getBroadcastUri()); |                 config.setBroadcastUri(userSpecified.getBroadcastUri()); | ||||||
|                 config.setState(State.Setup); |                 config.setState(State.Setup); | ||||||
|  | |||||||
| @ -16,14 +16,14 @@ import com.cloud.deploy.DeployDestination; | |||||||
| import com.cloud.deploy.DeploymentPlan; | import com.cloud.deploy.DeploymentPlan; | ||||||
| import com.cloud.exception.InsufficientAddressCapacityException; | import com.cloud.exception.InsufficientAddressCapacityException; | ||||||
| import com.cloud.exception.InsufficientVirtualNetworkCapcityException; | import com.cloud.exception.InsufficientVirtualNetworkCapcityException; | ||||||
|  | import com.cloud.network.Network; | ||||||
|  | import com.cloud.network.NetworkManager; | ||||||
|  | import com.cloud.network.NetworkVO; | ||||||
| import com.cloud.network.Networks.AddressFormat; | import com.cloud.network.Networks.AddressFormat; | ||||||
| import com.cloud.network.Networks.BroadcastDomainType; | import com.cloud.network.Networks.BroadcastDomainType; | ||||||
| import com.cloud.network.Networks.IsolationType; | import com.cloud.network.Networks.IsolationType; | ||||||
| import com.cloud.network.Networks.Mode; | import com.cloud.network.Networks.Mode; | ||||||
| import com.cloud.network.Networks.TrafficType; | import com.cloud.network.Networks.TrafficType; | ||||||
| import com.cloud.network.Network; |  | ||||||
| import com.cloud.network.NetworkVO; |  | ||||||
| import com.cloud.network.NetworkManager; |  | ||||||
| import com.cloud.network.dao.IPAddressDao; | import com.cloud.network.dao.IPAddressDao; | ||||||
| import com.cloud.offering.NetworkOffering; | import com.cloud.offering.NetworkOffering; | ||||||
| import com.cloud.resource.Resource.ReservationStrategy; | import com.cloud.resource.Resource.ReservationStrategy; | ||||||
| @ -87,8 +87,6 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru { | |||||||
|          |          | ||||||
|         if (nic == null) { |         if (nic == null) { | ||||||
|             nic = new NicProfile(ReservationStrategy.Create, null, null, null, null); |             nic = new NicProfile(ReservationStrategy.Create, null, null, null, null); | ||||||
|         } else { |  | ||||||
|             nic.setStrategy(ReservationStrategy.Create); |  | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId()); |         String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId()); | ||||||
| @ -97,6 +95,12 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru { | |||||||
|         DataCenter dc = _dcDao.findById(config.getDataCenterId()); |         DataCenter dc = _dcDao.findById(config.getDataCenterId()); | ||||||
|         getIp(nic, dc, vm); |         getIp(nic, dc, vm); | ||||||
|          |          | ||||||
|  |         if (nic.getIp4Address() == null) { | ||||||
|  |             nic.setStrategy(ReservationStrategy.Start); | ||||||
|  |         } else { | ||||||
|  |             nic.setStrategy(ReservationStrategy.Create); | ||||||
|  |         } | ||||||
|  |          | ||||||
|         return nic; |         return nic; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -104,7 +108,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru { | |||||||
|     public void reserve(NicProfile nic, Network configuration, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException { |     public void reserve(NicProfile nic, Network configuration, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException { | ||||||
|         if (nic.getIp4Address() == null) { |         if (nic.getIp4Address() == null) { | ||||||
|             getIp(nic, dest.getDataCenter(), vm); |             getIp(nic, dest.getDataCenter(), vm); | ||||||
|         } |         }  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -2047,7 +2047,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute | |||||||
|         if (s_logger.isDebugEnabled()) { |         if (s_logger.isDebugEnabled()) { | ||||||
|             s_logger.debug("Starting a router for network configurations: virtual="  + guestConfig + " in " + dest); |             s_logger.debug("Starting a router for network configurations: virtual="  + guestConfig + " in " + dest); | ||||||
|         } |         } | ||||||
| 	    assert guestConfig.getState() == Network.State.Implemented : "Network is not yet fully implemented: " + guestConfig; | 	    assert guestConfig.getState() == Network.State.Implemented || guestConfig.getState() == Network.State.Setup : "Network is not yet fully implemented: " + guestConfig; | ||||||
| 	    assert guestConfig.getTrafficType() == TrafficType.Guest; | 	    assert guestConfig.getTrafficType() == TrafficType.Guest; | ||||||
| 	     | 	     | ||||||
|         DataCenterDeployment plan = new DataCenterDeployment(dcId); |         DataCenterDeployment plan = new DataCenterDeployment(dcId); | ||||||
| @ -2068,11 +2068,11 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute | |||||||
|          |          | ||||||
|             List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork); |             List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork); | ||||||
|             NetworkOfferingVO controlOffering = offerings.get(0); |             NetworkOfferingVO controlOffering = offerings.get(0); | ||||||
|             NetworkVO controlConfig = _networkMgr.setupNetworkConfiguration(_systemAcct, controlOffering, plan).get(0); |             NetworkVO controlConfig = _networkMgr.setupNetworkConfiguration(_systemAcct, controlOffering, plan, null, null).get(0); | ||||||
|              |              | ||||||
|             List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(3); |             List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(3); | ||||||
|             NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork).get(0); |             NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork).get(0); | ||||||
|             List<NetworkVO> publicConfigs = _networkMgr.setupNetworkConfiguration(_systemAcct, publicOffering, plan); |             List<NetworkVO> publicConfigs = _networkMgr.setupNetworkConfiguration(_systemAcct, publicOffering, plan, null, null); | ||||||
|             NicProfile defaultNic = new NicProfile(); |             NicProfile defaultNic = new NicProfile(); | ||||||
|             defaultNic.setDefaultNic(true); |             defaultNic.setDefaultNic(true); | ||||||
|             //defaultNic.setIp4Address(sourceNatIp); |             //defaultNic.setIp4Address(sourceNatIp); | ||||||
|  | |||||||
| @ -81,6 +81,12 @@ public class NetworkOfferingVO implements NetworkOffering { | |||||||
|     @Column(name="tags") |     @Column(name="tags") | ||||||
|     String tags; |     String tags; | ||||||
|      |      | ||||||
|  |     @Column(name="shared") | ||||||
|  |     boolean isShared; | ||||||
|  |      | ||||||
|  |     @Column(name="default") | ||||||
|  |     boolean isDefault; | ||||||
|  |      | ||||||
|     @Column(name=GenericDao.REMOVED_COLUMN) |     @Column(name=GenericDao.REMOVED_COLUMN) | ||||||
|     Date removed; |     Date removed; | ||||||
|      |      | ||||||
| @ -134,14 +140,6 @@ public class NetworkOfferingVO implements NetworkOffering { | |||||||
|         return removed; |         return removed; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     public Long getServiceOfferingId() { |  | ||||||
|         return serviceOfferingId; |  | ||||||
|     } |  | ||||||
|      |  | ||||||
|     public void setServiceOfferingId(long serviceOfferingId) { |  | ||||||
|         this.serviceOfferingId = serviceOfferingId; |  | ||||||
|     } |  | ||||||
|      |  | ||||||
|     @Override |     @Override | ||||||
|     public Integer getConcurrentConnections() { |     public Integer getConcurrentConnections() { | ||||||
|         return concurrentConnections; |         return concurrentConnections; | ||||||
| @ -190,14 +188,33 @@ public class NetworkOfferingVO implements NetworkOffering { | |||||||
|         this.systemOnly = systemOnly; |         this.systemOnly = systemOnly; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setServiceOfferingId(Long serviceOfferingId) { |  | ||||||
|         this.serviceOfferingId = serviceOfferingId; |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     public void setRemoved(Date removed) { |     public void setRemoved(Date removed) { | ||||||
|         this.removed = removed; |         this.removed = removed; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     public Long getServiceOfferingId() { | ||||||
|  |         return serviceOfferingId; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public void setServiceOfferingId(long serviceOfferingId) { | ||||||
|  |         this.serviceOfferingId = serviceOfferingId; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public boolean isShared() { | ||||||
|  |         return isShared; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setShared(boolean isShared) { | ||||||
|  |         this.isShared = isShared; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public boolean isDefault() { | ||||||
|  |         return isDefault; | ||||||
|  |     } | ||||||
|  |      | ||||||
|     @Override |     @Override | ||||||
|     public boolean getSpecifyVlan() { |     public boolean getSpecifyVlan() { | ||||||
|         return specifyVlan; |         return specifyVlan; | ||||||
| @ -207,7 +224,7 @@ public class NetworkOfferingVO implements NetworkOffering { | |||||||
|         this.created = created; |         this.created = created; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections) { |     public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections, boolean isShared, boolean isDefault) { | ||||||
|         this.name = name; |         this.name = name; | ||||||
|         this.displayText = displayText; |         this.displayText = displayText; | ||||||
|         this.guestIpType = type; |         this.guestIpType = type; | ||||||
| @ -217,13 +234,16 @@ public class NetworkOfferingVO implements NetworkOffering { | |||||||
|         this.trafficType = trafficType; |         this.trafficType = trafficType; | ||||||
|         this.systemOnly = systemOnly; |         this.systemOnly = systemOnly; | ||||||
|         this.specifyVlan = specifyVlan; |         this.specifyVlan = specifyVlan; | ||||||
|  |         this.isDefault = isDefault; | ||||||
|  |         this.isShared = isShared; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     public NetworkOfferingVO(ServiceOfferingVO offering) { |     public NetworkOfferingVO(ServiceOfferingVO offering) { | ||||||
|         this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, false, offering.getRateMbps(), offering.getMulticastRateMbps(), null); |         this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, false, offering.getRateMbps(), offering.getMulticastRateMbps(), null, false, false); | ||||||
|         this.serviceOfferingId = offering.getId(); |         this.serviceOfferingId = offering.getId(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * Network Offering for all system vms. |      * Network Offering for all system vms. | ||||||
|      * @param name |      * @param name | ||||||
| @ -231,7 +251,7 @@ public class NetworkOfferingVO implements NetworkOffering { | |||||||
|      * @param type |      * @param type | ||||||
|      */ |      */ | ||||||
|     public NetworkOfferingVO(String name, TrafficType trafficType, GuestIpType type) { |     public NetworkOfferingVO(String name, TrafficType trafficType, GuestIpType type) { | ||||||
|         this(name, "System Offering for " + name, trafficType, type, true, false, null, null, null); |         this(name, "System Offering for " + name, trafficType, type, true, false, null, null, null, false, false); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -741,9 +741,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V | |||||||
| 	        NicProfile defaultNic = new NicProfile(); | 	        NicProfile defaultNic = new NicProfile(); | ||||||
| 	        defaultNic.setDefaultNic(true); | 	        defaultNic.setDefaultNic(true); | ||||||
| 	        defaultNic.setDeviceId(2); | 	        defaultNic.setDeviceId(2); | ||||||
| 	        networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic)); | 	        networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan, null, null).get(0), defaultNic)); | ||||||
| 	        for (NetworkOfferingVO offering : offerings) { | 	        for (NetworkOfferingVO offering : offerings) { | ||||||
| 	            networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan).get(0), null)); | 	            networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan, null, null).get(0), null)); | ||||||
| 	        } | 	        } | ||||||
| 	        SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, _template.getId(),  | 	        SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, _template.getId(),  | ||||||
| 	        															 _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId()); | 	        															 _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId()); | ||||||
|  | |||||||
| @ -95,6 +95,10 @@ public class NicVO implements Nic { | |||||||
|      |      | ||||||
|     @Column(name="default_nic") |     @Column(name="default_nic") | ||||||
|     boolean defaultNic; |     boolean defaultNic; | ||||||
|  |      | ||||||
|  |     @Column(name="strategy") | ||||||
|  |     @Enumerated(value=EnumType.STRING) | ||||||
|  |     ReservationStrategy strategy; | ||||||
| 
 | 
 | ||||||
|     public NicVO(String reserver, long instanceId, long configurationId) { |     public NicVO(String reserver, long instanceId, long configurationId) { | ||||||
|         this.reserver = reserver; |         this.reserver = reserver; | ||||||
| @ -230,6 +234,11 @@ public class NicVO implements Nic { | |||||||
|         this.reservationId = id; |         this.reservationId = id; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     | ||||||
|  |     public void setReservationStrategy(ReservationStrategy strategy) { | ||||||
|  |         this.strategy = strategy; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public void setDeviceId(int deviceId) { |     public void setDeviceId(int deviceId) { | ||||||
|         this.deviceId = deviceId; |         this.deviceId = deviceId; | ||||||
|     } |     } | ||||||
| @ -254,7 +263,7 @@ public class NicVO implements Nic { | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public ReservationStrategy getReservationStrategy() { |     public ReservationStrategy getReservationStrategy() { | ||||||
|         return ReservationStrategy.Start; |         return strategy; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -134,15 +134,19 @@ import com.cloud.network.IpAddrAllocator; | |||||||
| import com.cloud.network.LoadBalancerVMMapVO; | import com.cloud.network.LoadBalancerVMMapVO; | ||||||
| import com.cloud.network.NetworkManager; | import com.cloud.network.NetworkManager; | ||||||
| import com.cloud.network.NetworkVO; | import com.cloud.network.NetworkVO; | ||||||
|  | import com.cloud.network.Networks.TrafficType; | ||||||
| import com.cloud.network.dao.FirewallRulesDao; | import com.cloud.network.dao.FirewallRulesDao; | ||||||
| import com.cloud.network.dao.IPAddressDao; | import com.cloud.network.dao.IPAddressDao; | ||||||
| import com.cloud.network.dao.LoadBalancerDao; | import com.cloud.network.dao.LoadBalancerDao; | ||||||
| import com.cloud.network.dao.LoadBalancerVMMapDao; | import com.cloud.network.dao.LoadBalancerVMMapDao; | ||||||
|  | import com.cloud.network.dao.NetworkDao; | ||||||
| import com.cloud.network.router.VirtualRouter.Role; | import com.cloud.network.router.VirtualRouter.Role; | ||||||
| import com.cloud.network.security.NetworkGroupManager; | import com.cloud.network.security.NetworkGroupManager; | ||||||
| import com.cloud.network.security.NetworkGroupVO; | import com.cloud.network.security.NetworkGroupVO; | ||||||
| import com.cloud.offering.NetworkOffering; | import com.cloud.offering.NetworkOffering; | ||||||
| import com.cloud.offering.ServiceOffering; | import com.cloud.offering.ServiceOffering; | ||||||
|  | import com.cloud.offerings.NetworkOfferingVO; | ||||||
|  | import com.cloud.offerings.dao.NetworkOfferingDao; | ||||||
| import com.cloud.service.ServiceOfferingVO; | import com.cloud.service.ServiceOfferingVO; | ||||||
| import com.cloud.service.dao.ServiceOfferingDao; | import com.cloud.service.dao.ServiceOfferingDao; | ||||||
| import com.cloud.storage.DiskOfferingVO; | import com.cloud.storage.DiskOfferingVO; | ||||||
| @ -246,10 +250,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM | |||||||
|     @Inject VMTemplateHostDao _vmTemplateHostDao; |     @Inject VMTemplateHostDao _vmTemplateHostDao; | ||||||
|     @Inject NetworkGroupManager _networkGroupMgr; |     @Inject NetworkGroupManager _networkGroupMgr; | ||||||
|     @Inject ServiceOfferingDao _serviceOfferingDao; |     @Inject ServiceOfferingDao _serviceOfferingDao; | ||||||
|  |     @Inject NetworkOfferingDao _networkOfferingDao; | ||||||
|     @Inject EventDao _eventDao = null; |     @Inject EventDao _eventDao = null; | ||||||
|     @Inject InstanceGroupDao _vmGroupDao; |     @Inject InstanceGroupDao _vmGroupDao; | ||||||
|     @Inject InstanceGroupVMMapDao _groupVMMapDao; |     @Inject InstanceGroupVMMapDao _groupVMMapDao; | ||||||
|     @Inject VmManager _itMgr; |     @Inject VmManager _itMgr; | ||||||
|  |     @Inject NetworkDao _networkDao; | ||||||
|      |      | ||||||
|     private IpAddrAllocator _IpAllocator; |     private IpAddrAllocator _IpAllocator; | ||||||
|     ScheduledExecutorService _executor = null; |     ScheduledExecutorService _executor = null; | ||||||
| @ -846,7 +852,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM | |||||||
|         if (s_logger.isDebugEnabled()) { |         if (s_logger.isDebugEnabled()) { | ||||||
|             s_logger.debug("Starting VM: " + vmId); |             s_logger.debug("Starting VM: " + vmId); | ||||||
|         } |         } | ||||||
| 
 |          | ||||||
|         State state = vm.getState(); |         State state = vm.getState(); | ||||||
|         if (state == State.Running) { |         if (state == State.Running) { | ||||||
|             if (s_logger.isDebugEnabled()) { |             if (s_logger.isDebugEnabled()) { | ||||||
| @ -1043,6 +1049,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM | |||||||
|                 } else { |                 } else { | ||||||
|                 	bits = template.getBits(); |                 	bits = template.getBits(); | ||||||
|                 } |                 } | ||||||
|  |                  | ||||||
|  | //                NetworkVO vmNetwork = _networkDao.findById(Long.valueOf(vm.getVnet())); | ||||||
|  | //                NetworkOfferingVO vmNetworkOffering = _networkOfferingDao.findById(vmNetwork.getNetworkOfferingId()); | ||||||
| 
 | 
 | ||||||
|                 StartCommand cmdStart = new StartCommand(vm, vm.getInstanceName(), offering, offering.getRateMbps(), offering.getMulticastRateMbps(), router, storageIps, vol.getFolder(), vm.getVnet(), utilization, cpuWeight, vols, mirroredVols, bits, isoPath, bootFromISO, guestOSDescription); |                 StartCommand cmdStart = new StartCommand(vm, vm.getInstanceName(), offering, offering.getRateMbps(), offering.getMulticastRateMbps(), router, storageIps, vol.getFolder(), vm.getVnet(), utilization, cpuWeight, vols, mirroredVols, bits, isoPath, bootFromISO, guestOSDescription); | ||||||
|                 if (Storage.ImageFormat.ISO.equals(template.getFormat()) || template.isRequiresHvm()) { |                 if (Storage.ImageFormat.ISO.equals(template.getFormat()) || template.isRequiresHvm()) { | ||||||
| @ -3497,6 +3506,34 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM | |||||||
| 	@Override @DB | 	@Override @DB | ||||||
|     public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException { |     public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException { | ||||||
|         Account caller = UserContext.current().getAccount(); |         Account caller = UserContext.current().getAccount(); | ||||||
|  |         String accountName = cmd.getAccountName(); | ||||||
|  |         Long domainId = cmd.getDomainId(); | ||||||
|  |         Account userAccount = null; | ||||||
|  |         Long accountId = null; | ||||||
|  |         List<Long> networkList = cmd.getNetworkIds(); | ||||||
|  |          | ||||||
|  |         if ((caller == null) || isAdmin(caller.getType())) { | ||||||
|  |             if (domainId != null) { | ||||||
|  |                 if ((caller != null) && !_domainDao.isChildDomain(caller.getDomainId(), domainId)) { | ||||||
|  |                     throw new PermissionDeniedException("Failed to deploy VM, invalid domain id (" + domainId + ") given."); | ||||||
|  |                 } | ||||||
|  |                 if (accountName != null) { | ||||||
|  |                     userAccount = _accountDao.findActiveAccount(accountName, domainId); | ||||||
|  |                     if (userAccount == null) { | ||||||
|  |                         throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId); | ||||||
|  |                     } | ||||||
|  |                     accountId = userAccount.getId(); | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  |                 accountId = ((caller != null) ? caller.getId() : null); | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|  |             accountId = caller.getId(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if (accountId == null) { | ||||||
|  |             throw new InvalidParameterValueException("No valid account specified for deploying a virtual machine."); | ||||||
|  |         } | ||||||
|          |          | ||||||
|         AccountVO owner = _accountDao.findById(cmd.getAccountId()); |         AccountVO owner = _accountDao.findById(cmd.getAccountId()); | ||||||
|         if (owner == null || owner.getRemoved() != null) { |         if (owner == null || owner.getRemoved() != null) { | ||||||
| @ -3605,12 +3642,25 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM | |||||||
|          |          | ||||||
|         s_logger.debug("Allocating in the DB for vm"); |         s_logger.debug("Allocating in the DB for vm"); | ||||||
|          |          | ||||||
|         List<NetworkVO> configs = _networkMgr.setupNetworkConfiguration(owner, offering, plan); |         if (networkList == null || networkList.isEmpty()) { | ||||||
|         List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>();  |             throw new InvalidParameterValueException("NetworkIds have to be specified"); | ||||||
|         for (NetworkVO config : configs) { |         } | ||||||
|             networks.add(new Pair<NetworkVO, NicProfile>(config, null)); |          | ||||||
|  |         List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(); | ||||||
|  |         for (Long networkId : networkList) { | ||||||
|  |             NetworkVO network = _networkDao.findById(networkId); | ||||||
|  |             if (network == null) { | ||||||
|  |                 throw new InvalidParameterValueException("Unable to find network by id " + networkId); | ||||||
|  |             } else { | ||||||
|  |                 if (network.getAccountId() != Account.ACCOUNT_ID_SYSTEM && network.getAccountId() != accountId) { | ||||||
|  |                     throw new PermissionDeniedException("Unable to create a vm using network with id " + networkId + ", permission denied"); | ||||||
|  |                 } else if (network.getTrafficType() != TrafficType.Guest) { | ||||||
|  |                     throw new InvalidParameterValueException("Unable to create a vm using network which traffic type is " + network.getTrafficType() + ". " + | ||||||
|  |                     		"Only Guest traffic type is acceptes"); | ||||||
|  |                 } | ||||||
|  |                 networks.add(new Pair<NetworkVO, NicProfile>(network, null)); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|          |          | ||||||
|         long id = _vmDao.getNextInSequence(Long.class, "id"); |         long id = _vmDao.getNextInSequence(Long.class, "id"); | ||||||
|          |          | ||||||
|  | |||||||
| @ -12,4 +12,6 @@ public interface NicDao extends GenericDao<NicVO, Long> { | |||||||
|     List<NicVO> listBy(long instanceId); |     List<NicVO> listBy(long instanceId); | ||||||
|      |      | ||||||
|     List<String> listIpAddressInNetworkConfiguration(long networkConfigId); |     List<String> listIpAddressInNetworkConfiguration(long networkConfigId); | ||||||
|  |      | ||||||
|  |     List<NicVO> listByNetworkId(long networkId); | ||||||
| } | } | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ import com.cloud.vm.NicVO; | |||||||
| public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao { | public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao { | ||||||
|     private final SearchBuilder<NicVO> InstanceSearch; |     private final SearchBuilder<NicVO> InstanceSearch; | ||||||
|     private final GenericSearchBuilder<NicVO, String> IpSearch; |     private final GenericSearchBuilder<NicVO, String> IpSearch; | ||||||
|  |     private final SearchBuilder<NicVO> NetworkSearch; | ||||||
|      |      | ||||||
|     protected NicDaoImpl() { |     protected NicDaoImpl() { | ||||||
|         super(); |         super(); | ||||||
| @ -31,6 +32,10 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao { | |||||||
|         IpSearch.and("nc", IpSearch.entity().getNetworkId(), SearchCriteria.Op.EQ); |         IpSearch.and("nc", IpSearch.entity().getNetworkId(), SearchCriteria.Op.EQ); | ||||||
|         IpSearch.and("address", IpSearch.entity().getIp4Address(), SearchCriteria.Op.NNULL); |         IpSearch.and("address", IpSearch.entity().getIp4Address(), SearchCriteria.Op.NNULL); | ||||||
|         IpSearch.done(); |         IpSearch.done(); | ||||||
|  |          | ||||||
|  |         NetworkSearch = createSearchBuilder(); | ||||||
|  |         NetworkSearch.and("networkId", NetworkSearch.entity().getNetworkId(), SearchCriteria.Op.EQ); | ||||||
|  |         NetworkSearch.done(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
| @ -46,4 +51,11 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao { | |||||||
|         sc.setParameters("nc", networkConfigId); |         sc.setParameters("nc", networkConfigId); | ||||||
|         return customSearch(sc, null); |         return customSearch(sc, null); | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public List<NicVO> listByNetworkId(long networkId) { | ||||||
|  |         SearchCriteria<NicVO> sc = NetworkSearch.create(); | ||||||
|  |         sc.setParameters("networkId", networkId); | ||||||
|  |         return listBy(sc); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -265,3 +265,5 @@ ALTER TABLE `cloud`.`remote_access_vpn` ADD INDEX `i_remote_access_vpn_addr`(`vp | |||||||
| ALTER TABLE `cloud`.`vpn_users` ADD CONSTRAINT `fk_vpn_users___account_id` FOREIGN KEY `fk_vpn_users__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE; | ALTER TABLE `cloud`.`vpn_users` ADD CONSTRAINT `fk_vpn_users___account_id` FOREIGN KEY `fk_vpn_users__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE; | ||||||
| ALTER TABLE `cloud`.`vpn_users` ADD INDEX `i_vpn_users_username`(`username`); | ALTER TABLE `cloud`.`vpn_users` ADD INDEX `i_vpn_users_username`(`username`); | ||||||
| ALTER TABLE `cloud`.`vpn_users` ADD UNIQUE `i_vpn_users__account_id__username`(`account_id`, `username`);  | ALTER TABLE `cloud`.`vpn_users` ADD UNIQUE `i_vpn_users__account_id__username`(`account_id`, `username`);  | ||||||
|  | 
 | ||||||
|  | ALTER TABLE `cloud`.`vlan` ADD CONSTRAINT `fk_vlan__network_offering_id` FOREIGN KEY `fk_vlan__network_offering_id` (`network_offering_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE; | ||||||
|  | |||||||
| @ -112,6 +112,7 @@ CREATE TABLE `cloud`.`op_networks`( | |||||||
| CREATE TABLE `cloud`.`networks` ( | CREATE TABLE `cloud`.`networks` ( | ||||||
|   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', |   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', | ||||||
|   `name` varchar(255) COMMENT 'name for this network', |   `name` varchar(255) COMMENT 'name for this network', | ||||||
|  |   `display_text` varchar(255) COMMENT 'display text for this network', | ||||||
|   `traffic_type` varchar(32) NOT NULL COMMENT 'type of traffic going through this network', |   `traffic_type` varchar(32) NOT NULL COMMENT 'type of traffic going through this network', | ||||||
|   `broadcast_domain_type` varchar(32) NOT NULL COMMENT 'type of broadcast domain used', |   `broadcast_domain_type` varchar(32) NOT NULL COMMENT 'type of broadcast domain used', | ||||||
|   `broadcast_uri` varchar(255) COMMENT 'broadcast domain specifier', |   `broadcast_uri` varchar(255) COMMENT 'broadcast domain specifier', | ||||||
| @ -164,6 +165,7 @@ CREATE TABLE `cloud`.`nics` ( | |||||||
|   `network_id` bigint unsigned NOT NULL COMMENT 'network configuration id', |   `network_id` bigint unsigned NOT NULL COMMENT 'network configuration id', | ||||||
|   `mode` varchar(32) COMMENT 'mode of getting ip address',   |   `mode` varchar(32) COMMENT 'mode of getting ip address',   | ||||||
|   `state` varchar(32) NOT NULL COMMENT 'state of the creation', |   `state` varchar(32) NOT NULL COMMENT 'state of the creation', | ||||||
|  |   `strategy` varchar(32) NOT NULL COMMENT 'reservation strategy', | ||||||
|   `reserver_name` varchar(255) COMMENT 'Name of the component that reserved the ip address', |   `reserver_name` varchar(255) COMMENT 'Name of the component that reserved the ip address', | ||||||
|   `reservation_id` varchar(64) COMMENT 'id for the reservation', |   `reservation_id` varchar(64) COMMENT 'id for the reservation', | ||||||
|   `device_id` int(10) COMMENT 'device id for the network when plugged into the virtual machine', |   `device_id` int(10) COMMENT 'device id for the network when plugged into the virtual machine', | ||||||
| @ -189,6 +191,8 @@ CREATE TABLE `cloud`.`network_offerings` ( | |||||||
|   `service_offering_id` bigint unsigned UNIQUE COMMENT 'service offering id that this network offering is tied to', |   `service_offering_id` bigint unsigned UNIQUE COMMENT 'service offering id that this network offering is tied to', | ||||||
|   `created` datetime NOT NULL COMMENT 'time the entry was created', |   `created` datetime NOT NULL COMMENT 'time the entry was created', | ||||||
|   `removed` datetime DEFAULT NULL COMMENT 'time the entry was removed', |   `removed` datetime DEFAULT NULL COMMENT 'time the entry was removed', | ||||||
|  |   `shared` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '0 if network is shared, 1 if network dedicated', | ||||||
|  |   `default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network is default', | ||||||
|   PRIMARY KEY (`id`) |   PRIMARY KEY (`id`) | ||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||||||
| 
 | 
 | ||||||
| @ -339,6 +343,7 @@ CREATE TABLE `cloud`.`vlan` ( | |||||||
|   `description` varchar(255), |   `description` varchar(255), | ||||||
|   `vlan_type` varchar(255), |   `vlan_type` varchar(255), | ||||||
|   `data_center_id` bigint unsigned NOT NULL, |   `data_center_id` bigint unsigned NOT NULL, | ||||||
|  |   `network_id` bigint unsigned COMMENT 'id of corresponding network offering', | ||||||
|   PRIMARY KEY (`id`) |   PRIMARY KEY (`id`) | ||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user