mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 7878: Fixed Basic zone functionality - uservm/systemvm/domR start
status 7878: resolved fixed
This commit is contained in:
parent
02dc187a0c
commit
916b516d13
@ -65,10 +65,10 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the VLAN. Default is an \"untagged\" VLAN.")
|
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the VLAN. Default is an \"untagged\" VLAN.")
|
||||||
private String 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")
|
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the network")
|
||||||
private String accountName;
|
private String accountName;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a VLAN")
|
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a network")
|
||||||
private Long domainId;
|
private Long domainId;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network offering supports vlans")
|
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network offering supports vlans")
|
||||||
|
|||||||
@ -26,8 +26,8 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.NetworkOfferingResponse;
|
import com.cloud.api.response.NetworkOfferingResponse;
|
||||||
import com.cloud.network.Networks.Availability;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.offering.NetworkOffering.Availability;
|
||||||
|
|
||||||
@Implementation(description="Creates a network offering.", responseObject=NetworkOfferingResponse.class)
|
@Implementation(description="Creates a network offering.", responseObject=NetworkOfferingResponse.class)
|
||||||
public class CreateNetworkOfferingCmd extends BaseCmd {
|
public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||||
@ -44,9 +44,6 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||||||
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network offering")
|
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network offering")
|
||||||
private String displayText;
|
private String displayText;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, required=true, description="type of the network. Supported types Virtual, Direct")
|
|
||||||
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.")
|
@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;
|
private String traffictype;
|
||||||
|
|
||||||
@ -78,10 +75,6 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTraffictype() {
|
public String getTraffictype() {
|
||||||
return traffictype;
|
return traffictype;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,8 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.ApiConstants;
|
import com.cloud.api.ApiConstants;
|
||||||
@ -32,10 +30,10 @@ import com.cloud.api.response.SuccessResponse;
|
|||||||
import com.cloud.event.EventTypes;
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
import com.cloud.exception.ResourceAllocationException;
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
import com.cloud.exception.ResourceUnavailableException;
|
||||||
import com.cloud.network.Network;
|
import com.cloud.network.Network;
|
||||||
import com.cloud.user.UserContext;
|
|
||||||
|
|
||||||
@Implementation(description="Reapplies all ip addresses for the particular network", responseObject=IPAddressResponse.class)
|
@Implementation(description="Reapplies all ip addresses for the particular network", responseObject=IPAddressResponse.class)
|
||||||
public class RestartNetworkCmd extends BaseAsyncCmd {
|
public class RestartNetworkCmd extends BaseAsyncCmd {
|
||||||
@ -46,12 +44,6 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
|||||||
//////////////// API parameters /////////////////////
|
//////////////// API parameters /////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account to associate with this IP address")
|
|
||||||
private String accountName;
|
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the domain to associate with this IP address")
|
|
||||||
private Long domainId;
|
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the availability zone you want to acquire an public IP address from")
|
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the availability zone you want to acquire an public IP address from")
|
||||||
private Long zoneId;
|
private Long zoneId;
|
||||||
|
|
||||||
@ -63,20 +55,6 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
|||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
public String getAccountName() {
|
|
||||||
if (accountName != null) {
|
|
||||||
return accountName;
|
|
||||||
}
|
|
||||||
return UserContext.current().getCaller().getAccountName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getDomainId() {
|
|
||||||
if (domainId != null) {
|
|
||||||
return domainId;
|
|
||||||
}
|
|
||||||
return UserContext.current().getCaller().getDomainId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getZoneId() {
|
public long getZoneId() {
|
||||||
return zoneId;
|
return zoneId;
|
||||||
}
|
}
|
||||||
@ -90,26 +68,16 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getEntityOwnerId() {
|
public long getEntityOwnerId() {
|
||||||
List<? extends Network> networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getAccountName(), getDomainId(), getZoneId());
|
return _networkService.getNetwork(networkId).getAccountId();
|
||||||
if (networks.size() == 0) {
|
|
||||||
assert (networks.size() <= 1) : "No virtual network is found";
|
|
||||||
}
|
|
||||||
assert (networks.size() <= 1) : "Too many virtual networks. This logic should be obsolete";
|
|
||||||
|
|
||||||
return networks.get(0).getAccountId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getNetworkId() {
|
public Long getNetworkId() {
|
||||||
if (networkId != null) {
|
Network network = _networkService.getNetwork(networkId);
|
||||||
return networkId;
|
if (network == null) {
|
||||||
|
throw new InvalidParameterValueException("Unable to find network by id " + networkId);
|
||||||
|
} else {
|
||||||
|
return network.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<? extends Network> networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getAccountName(), getDomainId(), getZoneId());
|
|
||||||
if (networks.size() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
assert (networks.size() <= 1) : "Too many virtual networks. This logic should be obsolete";
|
|
||||||
return networks.get(0).getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -26,8 +26,8 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.NetworkOfferingResponse;
|
import com.cloud.api.response.NetworkOfferingResponse;
|
||||||
import com.cloud.network.Networks.Availability;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.offering.NetworkOffering.Availability;
|
||||||
|
|
||||||
@Implementation(description="Updates a network offering.", responseObject=NetworkOfferingResponse.class)
|
@Implementation(description="Updates a network offering.", responseObject=NetworkOfferingResponse.class)
|
||||||
public class UpdateNetworkOfferingCmd extends BaseCmd {
|
public class UpdateNetworkOfferingCmd extends BaseCmd {
|
||||||
|
|||||||
@ -24,9 +24,6 @@ public class NetworkOfferingResponse extends BaseResponse{
|
|||||||
@SerializedName("maxconnections") @Param(description="the max number of concurrent connection the network offering supports")
|
@SerializedName("maxconnections") @Param(description="the max number of concurrent connection the network offering supports")
|
||||||
private Integer maxConnections;
|
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.")
|
@SerializedName("traffictype") @Param(description="the traffic type for the network offering, supported types are Public, Management, Control, Guest, Vlan or Storage.")
|
||||||
private String trafficType;
|
private String trafficType;
|
||||||
|
|
||||||
@ -87,14 +84,6 @@ public class NetworkOfferingResponse extends BaseResponse{
|
|||||||
this.maxConnections = maxConnections;
|
this.maxConnections = maxConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTrafficType() {
|
public String getTrafficType() {
|
||||||
return trafficType;
|
return trafficType;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,4 +55,6 @@ public interface NetworkService {
|
|||||||
|
|
||||||
int getActiveNicsInNetwork(long networkId);
|
int getActiveNicsInNetwork(long networkId);
|
||||||
|
|
||||||
|
Network getNetwork(long networkId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,12 +36,6 @@ public class Networks {
|
|||||||
Firewall
|
Firewall
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Availability {
|
|
||||||
Required,
|
|
||||||
Optional,
|
|
||||||
Unavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Different ways to assign ip address to this network.
|
* Different ways to assign ip address to this network.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -62,4 +62,6 @@ public interface LoadBalancingRulesService {
|
|||||||
*/
|
*/
|
||||||
List<? extends LoadBalancer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
|
List<? extends LoadBalancer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
|
||||||
|
|
||||||
|
List<LoadBalancingRule> listByNetworkId(long networkId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.offering;
|
package com.cloud.offering;
|
||||||
|
|
||||||
import com.cloud.network.Networks.Availability;
|
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,13 +28,23 @@ public interface NetworkOffering {
|
|||||||
public enum GuestIpType {
|
public enum GuestIpType {
|
||||||
Virtual,
|
Virtual,
|
||||||
Direct,
|
Direct,
|
||||||
DirectPodBased,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String DefaultVirtualizedNetworkOffering = "DefaultVirtualizedNetworkOffering";
|
public enum Availability {
|
||||||
public final String DefaultDirectNetworkOffering = "DefaultDirectNetworkOffering";
|
Required,
|
||||||
public final String DefaultDirectPodBasedNetworkOffering = "DefaultDirectPodBasedNetworkOffering";
|
Optional,
|
||||||
public final String DefaultDirectChooseVlanNetworkOffering = "DefaultDirectChooseVlanNetworkOffering";
|
Unavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static String SystemPublicNetwork = "System-Public-Network";
|
||||||
|
public final static String SystemControlNetwork = "System-Control-Network";
|
||||||
|
public final static String SystemManagementNetwork = "System-Management-Network";
|
||||||
|
public final static String SystemStorageNetwork = "System-Storage-Network";
|
||||||
|
public final static String SysteGuestNetwork = "System-Guest-Network";
|
||||||
|
|
||||||
|
public final static String DefaultVirtualizedNetworkOffering = "DefaultVirtualizedNetworkOffering";
|
||||||
|
public final static String DefaultDirectNetworkOffering = "DefaultDirectNetworkOffering";
|
||||||
|
public final static String DefaultDirectChooseVlanNetworkOffering = "DefaultDirectChooseVlanNetworkOffering";
|
||||||
|
|
||||||
long getId();
|
long getId();
|
||||||
|
|
||||||
@ -59,11 +68,6 @@ public interface NetworkOffering {
|
|||||||
*/
|
*/
|
||||||
Integer getMulticastRateMbps();
|
Integer getMulticastRateMbps();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the type of IP address to allocate as the primary ip address to a guest
|
|
||||||
*/
|
|
||||||
GuestIpType getGuestIpType();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return concurrent connections to be supported.
|
* @return concurrent connections to be supported.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -104,7 +104,6 @@ public interface AccountService {
|
|||||||
* @param cmd - the LockAccount command defining the accountId to be locked.
|
* @param cmd - the LockAccount command defining the accountId to be locked.
|
||||||
* @return account object
|
* @return account object
|
||||||
*/
|
*/
|
||||||
//Account lockAccount(LockAccountCmd cmd);
|
|
||||||
Account lockAccount(DisableAccountCmd cmd);
|
Account lockAccount(DisableAccountCmd cmd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,5 +139,13 @@ public interface AccountService {
|
|||||||
User createUser(CreateUserCmd cmd);
|
User createUser(CreateUserCmd cmd);
|
||||||
boolean deleteUser(DeleteUserCmd deleteUserCmd);
|
boolean deleteUser(DeleteUserCmd deleteUserCmd);
|
||||||
|
|
||||||
|
boolean isAdmin(short accountType);
|
||||||
|
|
||||||
|
Account finalizeOwner(Account caller, String accountName, Long domainId);
|
||||||
|
|
||||||
|
Account getActiveAccount(String accountName, Long domainId);
|
||||||
|
|
||||||
|
Account getAccount(Long accountId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
<adapter name="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru"/>
|
<adapter name="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru"/>
|
||||||
<adapter name="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru"/>
|
<adapter name="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru"/>
|
||||||
<adapter name="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru"/>
|
<adapter name="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru"/>
|
||||||
|
<adapter name="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru"/>
|
||||||
</adapters>
|
</adapters>
|
||||||
<adapters key="com.cloud.storage.secondary.SecondaryStorageVmAllocator">
|
<adapters key="com.cloud.storage.secondary.SecondaryStorageVmAllocator">
|
||||||
<adapter name="Balance" class="com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator"/>
|
<adapter name="Balance" class="com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator"/>
|
||||||
|
|||||||
@ -151,6 +151,7 @@ import com.cloud.agent.api.to.VirtualMachineTO;
|
|||||||
import com.cloud.agent.api.to.VirtualMachineTO.Monitor;
|
import com.cloud.agent.api.to.VirtualMachineTO.Monitor;
|
||||||
import com.cloud.agent.api.to.VirtualMachineTO.SshMonitor;
|
import com.cloud.agent.api.to.VirtualMachineTO.SshMonitor;
|
||||||
import com.cloud.agent.api.to.VolumeTO;
|
import com.cloud.agent.api.to.VolumeTO;
|
||||||
|
import com.cloud.dc.Vlan;
|
||||||
import com.cloud.exception.InternalErrorException;
|
import com.cloud.exception.InternalErrorException;
|
||||||
import com.cloud.host.Host.Type;
|
import com.cloud.host.Host.Type;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
@ -2942,7 +2943,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
|||||||
Set<VIF> routerVIFs = router.getVIFs(conn);
|
Set<VIF> routerVIFs = router.getVIFs(conn);
|
||||||
for (VIF vif : routerVIFs) {
|
for (VIF vif : routerVIFs) {
|
||||||
Network vifNetwork = vif.getNetwork(conn);
|
Network vifNetwork = vif.getNetwork(conn);
|
||||||
if (vlanId.equals("untagged")) {
|
if (vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) {
|
||||||
if (vifNetwork.getUuid(conn).equals(_host.publicNetwork)) {
|
if (vifNetwork.getUuid(conn).equals(_host.publicNetwork)) {
|
||||||
return vif;
|
return vif;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -509,7 +509,7 @@ public class ApiDBUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long getPublicNetworkIdByZone(long zoneId) {
|
public static long getPublicNetworkIdByZone(long zoneId) {
|
||||||
return _networkMgr.getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(zoneId, TrafficType.Public, null);
|
return _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Long getVlanNetworkId(long vlanId) {
|
public static Long getVlanNetworkId(long vlanId) {
|
||||||
|
|||||||
@ -113,7 +113,6 @@ import com.cloud.network.security.SecurityGroup;
|
|||||||
import com.cloud.network.security.SecurityGroupRules;
|
import com.cloud.network.security.SecurityGroupRules;
|
||||||
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.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.org.Cluster;
|
import com.cloud.org.Cluster;
|
||||||
import com.cloud.server.Criteria;
|
import com.cloud.server.Criteria;
|
||||||
@ -1090,10 +1089,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
nicResponse.setTrafficType(network.getTrafficType().toString());
|
nicResponse.setTrafficType(network.getTrafficType().toString());
|
||||||
|
|
||||||
//Set type
|
//Set type
|
||||||
NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
|
nicResponse.setType(network.getGuestType().toString());
|
||||||
if (networkOffering.getGuestIpType() != null) {
|
|
||||||
nicResponse.setType(networkOffering.getGuestIpType().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
nicResponse.setObjectName("nic");
|
nicResponse.setObjectName("nic");
|
||||||
|
|
||||||
@ -2174,9 +2170,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
response.setDisplayText(offering.getDisplayText());
|
response.setDisplayText(offering.getDisplayText());
|
||||||
response.setTags(offering.getTags());
|
response.setTags(offering.getTags());
|
||||||
response.setTrafficType(offering.getTrafficType().toString());
|
response.setTrafficType(offering.getTrafficType().toString());
|
||||||
if (offering.getGuestIpType() != null) {
|
|
||||||
response.setType(offering.getGuestIpType().toString());
|
|
||||||
}
|
|
||||||
response.setMaxconnections(offering.getConcurrentConnections());
|
response.setMaxconnections(offering.getConcurrentConnections());
|
||||||
response.setIsDefault(offering.isDefault());
|
response.setIsDefault(offering.isDefault());
|
||||||
response.setSpecifyVlan(offering.getSpecifyVlan());
|
response.setSpecifyVlan(offering.getSpecifyVlan());
|
||||||
|
|||||||
@ -29,9 +29,9 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
|||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.exception.PermissionDeniedException;
|
import com.cloud.exception.PermissionDeniedException;
|
||||||
import com.cloud.network.Networks.Availability;
|
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.offering.DiskOffering;
|
import com.cloud.offering.DiskOffering;
|
||||||
|
import com.cloud.offering.NetworkOffering.Availability;
|
||||||
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.NetworkOfferingVO;
|
||||||
|
|||||||
@ -93,13 +93,13 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||||||
import com.cloud.network.IPAddressVO;
|
import com.cloud.network.IPAddressVO;
|
||||||
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.Availability;
|
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
import com.cloud.network.dao.NetworkDao;
|
import com.cloud.network.dao.NetworkDao;
|
||||||
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.Availability;
|
||||||
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.NetworkOfferingVO;
|
||||||
@ -1212,13 +1212,17 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
} else if (offering.getTrafficType() == TrafficType.Control) {
|
} else if (offering.getTrafficType() == TrafficType.Control) {
|
||||||
broadcastDomainType = BroadcastDomainType.LinkLocal;
|
broadcastDomainType = BroadcastDomainType.LinkLocal;
|
||||||
} else if (offering.getTrafficType() == TrafficType.Public) {
|
} else if (offering.getTrafficType() == TrafficType.Public) {
|
||||||
if (zone.getNetworkType() == NetworkType.Basic && offering.getGuestIpType() == GuestIpType.DirectPodBased) {
|
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||||
broadcastDomainType = BroadcastDomainType.Native;
|
|
||||||
} else if (zone.getNetworkType() == NetworkType.Advanced && offering.getGuestIpType() == null) {
|
|
||||||
broadcastDomainType = BroadcastDomainType.Vlan;
|
broadcastDomainType = BroadcastDomainType.Vlan;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else if (offering.getTrafficType() == TrafficType.Guest) {
|
||||||
|
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||||
|
broadcastDomainType = BroadcastDomainType.Native;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
||||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true);
|
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true);
|
||||||
@ -1648,14 +1652,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
if (forVirtualNetwork){
|
if (forVirtualNetwork){
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
//find default public network in the zone
|
//find default public network in the zone
|
||||||
networkId = _networkMgr.getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(zoneId, TrafficType.Public, null);
|
networkId = _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||||
} else if (network.getGuestType() != null || network.getTrafficType() != TrafficType.Public){
|
} else if (network.getGuestType() != null || network.getTrafficType() != TrafficType.Public){
|
||||||
throw new InvalidParameterValueException("Can't find Public network by id=" + networkId);
|
throw new InvalidParameterValueException("Can't find Public network by id=" + networkId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
if (zone.getNetworkType() == DataCenter.NetworkType.Basic) {
|
if (zone.getNetworkType() == DataCenter.NetworkType.Basic) {
|
||||||
networkId = _networkMgr.getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(zoneId, TrafficType.Public, GuestIpType.DirectPodBased);
|
networkId = _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidParameterValueException("Nework id is required for Direct vlan creation ");
|
throw new InvalidParameterValueException("Nework id is required for Direct vlan creation ");
|
||||||
}
|
}
|
||||||
@ -1677,11 +1681,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
//check if startIp and endIp belong to network Cidr
|
//check if startIp and endIp belong to network Cidr
|
||||||
String networkCidr = network.getCidr();
|
String networkCidr = network.getCidr();
|
||||||
String networkGateway = network.getGateway();
|
String networkGateway = network.getGateway();
|
||||||
|
|
||||||
Long networkZoneId = network.getDataCenterId();
|
Long networkZoneId = network.getDataCenterId();
|
||||||
String[] splitResult = networkCidr.split("\\/");
|
String networkNetmask = NetUtils.getCidrNetmask(networkCidr);
|
||||||
long size = Long.valueOf(splitResult[1]);
|
|
||||||
String networkNetmask = NetUtils.getCidrNetmask(size);
|
|
||||||
|
|
||||||
//Check if ip addresses are in network range
|
//Check if ip addresses are in network range
|
||||||
if (!NetUtils.sameSubnet(startIP, networkGateway, networkNetmask)) {
|
if (!NetUtils.sameSubnet(startIP, networkGateway, networkNetmask)) {
|
||||||
@ -1719,7 +1720,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
throw new InvalidParameterValueException("Please specify a valid pod.");
|
throw new InvalidParameterValueException("Please specify a valid pod.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -1753,7 +1753,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
|
|
||||||
if(hypervisorType.equalsIgnoreCase("xenserver")) {
|
if(hypervisorType.equalsIgnoreCase("xenserver")) {
|
||||||
//check for the vlan being added before going to db, to see if it is untagged
|
//check for the vlan being added before going to db, to see if it is untagged
|
||||||
if(vlanType.toString().equalsIgnoreCase("VirtualNetwork") && vlanId.equalsIgnoreCase("untagged"))
|
if(vlanType.toString().equalsIgnoreCase("VirtualNetwork") && vlanId.equalsIgnoreCase(Vlan.UNTAGGED))
|
||||||
{
|
{
|
||||||
if(_configDao.getValue("xen.public.network.device") == null || _configDao.getValue("xen.public.network.device").equals(""))
|
if(_configDao.getValue("xen.public.network.device") == null || _configDao.getValue("xen.public.network.device").equals(""))
|
||||||
{
|
{
|
||||||
@ -1774,13 +1774,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// //check if the account's domain is a child of the zone's domain, for adding vlan ip ranges
|
|
||||||
// if(domainId != null && !_domainDao.isChildDomain(zone.getDomainId(), domainId)){
|
|
||||||
// //this is for account specific case, as domainId != null
|
|
||||||
// throw new PermissionDeniedException("The account associated with specific domain id:"+domainId+" doesn't have permissions to add vlan ip ranges for the zone:"+zone.getId());
|
|
||||||
// }
|
|
||||||
//ACL check
|
//ACL check
|
||||||
checkAccess(account, zone);
|
checkAccess(account, zone);
|
||||||
|
|
||||||
@ -1909,6 +1902,19 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
throw new InvalidParameterValueException("The VLAN tag " + vlanId + " is already being used for the guest network in zone " + zone.getName());
|
throw new InvalidParameterValueException("The VLAN tag " + vlanId + " is already being used for the guest network in zone " + zone.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//For untagged vlan check if vlan per pod already exists. If yes, verify that new vlan range has the same netmask and gateway
|
||||||
|
if (zone.getNetworkType() == NetworkType.Basic && vlanId.equalsIgnoreCase(Vlan.UNTAGGED) && podId != null){
|
||||||
|
List<VlanVO> podVlans = _vlanDao.listVlansForPodByType(podId, VlanType.DirectAttached);
|
||||||
|
if (podVlans != null && !podVlans.isEmpty()) {
|
||||||
|
VlanVO podVlan = podVlans.get(0);
|
||||||
|
if (!podVlan.getVlanNetmask().equals(vlanNetmask)) {
|
||||||
|
throw new InvalidParameterValueException("Vlan netmask is different from the netmask of Untagged vlan id=" + podVlan.getId() + " existing in the pod " + podId);
|
||||||
|
} else if (!podVlan.getVlanGateway().equals(vlanGateway)) {
|
||||||
|
throw new InvalidParameterValueException("Vlan gateway is different from the gateway of Untagged vlan id=" + podVlan.getId() + " existing in the pod " + podId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Everything was fine, so persist the VLAN
|
// Everything was fine, so persist the VLAN
|
||||||
String ipRange = startIP;
|
String ipRange = startIP;
|
||||||
if (endIP != null) {
|
if (endIP != null) {
|
||||||
@ -2665,7 +2671,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
String name = cmd.getNetworkOfferingName();
|
String name = cmd.getNetworkOfferingName();
|
||||||
String displayText = cmd.getDisplayText();
|
String displayText = cmd.getDisplayText();
|
||||||
String tags = cmd.getTags();
|
String tags = cmd.getTags();
|
||||||
String typeString = cmd.getType();
|
|
||||||
String trafficTypeString = cmd.getTraffictype();
|
String trafficTypeString = cmd.getTraffictype();
|
||||||
Boolean specifyVlan = cmd.getSpecifyVlan();
|
Boolean specifyVlan = cmd.getSpecifyVlan();
|
||||||
String availabilityStr = cmd.getAvailability();
|
String availabilityStr = cmd.getAvailability();
|
||||||
@ -2685,16 +2690,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
throw new InvalidParameterValueException("Invalid value for traffictype. Supported traffic types: Public, Management, Control, Guest, Vlan or Storage");
|
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 || type == GuestIpType.DirectPodBased) {
|
|
||||||
throw new InvalidParameterValueException("Invalid value for type. Supported types: Virtual, Direct");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Verify availability
|
//Verify availability
|
||||||
for (Availability avlb : Availability.values()) {
|
for (Availability avlb : Availability.values()) {
|
||||||
if (avlb.name().equalsIgnoreCase(availabilityStr)) {
|
if (avlb.name().equalsIgnoreCase(availabilityStr)) {
|
||||||
@ -2717,7 +2712,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||||
tags = cleanupTags(tags);
|
tags = cleanupTags(tags);
|
||||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, type, false, specifyVlan, networkRate, multicastRate, maxConnections, false, availability, false, false, false, false, false, false, false);
|
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, false, specifyVlan, networkRate, multicastRate, maxConnections, false, availability, false, false, false, false, false, false, false);
|
||||||
|
|
||||||
if ((offering = _networkOfferingDao.persist(offering)) != null) {
|
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,
|
saveConfigurationEvent(userId, null, EventTypes.EVENT_NETWORK_OFFERING_CREATE, "Successfully created new network offering with name: " + name + ".", "noId=" + offering.getId(), "name=" + name,
|
||||||
|
|||||||
@ -72,6 +72,8 @@ import com.cloud.certificate.dao.CertificateDao;
|
|||||||
import com.cloud.cluster.ClusterManager;
|
import com.cloud.cluster.ClusterManager;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
import com.cloud.dc.DataCenter;
|
||||||
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
@ -697,8 +699,12 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
|
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
||||||
|
|
||||||
List<NetworkOfferingVO> defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork);
|
List<NetworkOfferingVO> defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork);
|
||||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork);
|
if (dc.getNetworkType() == NetworkType.Basic) {
|
||||||
|
defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SysteGuestNetwork);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork);
|
||||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
||||||
NicProfile defaultNic = new NicProfile();
|
NicProfile defaultNic = new NicProfile();
|
||||||
defaultNic.setDefaultNic(true);
|
defaultNic.setDefaultNic(true);
|
||||||
@ -2020,10 +2026,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
cmds.addCommand("checkSsh", check);
|
cmds.addCommand("checkSsh", check);
|
||||||
|
|
||||||
ConsoleProxyVO proxy = profile.getVirtualMachine();
|
ConsoleProxyVO proxy = profile.getVirtualMachine();
|
||||||
|
DataCenter dc = dest.getDataCenter();
|
||||||
List<NicVO> nics = _nicDao.listBy(proxy.getId());
|
List<NicVO> nics = _nicDao.listBy(proxy.getId());
|
||||||
for (NicVO nic : nics) {
|
for (NicVO nic : nics) {
|
||||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||||
if (network.getTrafficType() == TrafficType.Public) {
|
if ((network.getTrafficType() == TrafficType.Public && dc.getNetworkType() == NetworkType.Advanced) || (network.getTrafficType() == TrafficType.Guest && dc.getNetworkType() == NetworkType.Basic)) {
|
||||||
proxy.setPublicIpAddress(nic.getIp4Address());
|
proxy.setPublicIpAddress(nic.getIp4Address());
|
||||||
proxy.setPublicNetmask(nic.getNetmask());
|
proxy.setPublicNetmask(nic.getNetmask());
|
||||||
proxy.setPublicMacAddress(nic.getMacAddress());
|
proxy.setPublicMacAddress(nic.getMacAddress());
|
||||||
|
|||||||
@ -41,12 +41,8 @@ public interface VlanDao extends GenericDao<VlanVO, Long> {
|
|||||||
|
|
||||||
void addToPod(long podId, long vlanDbId);
|
void addToPod(long podId, long vlanDbId);
|
||||||
|
|
||||||
// Pair<String, VlanVO> assignIpAddress(long zoneId, long accountId, long domainId, VlanType vlanType, boolean sourceNat);
|
|
||||||
|
|
||||||
List<VlanVO> listVlansForAccountByType(Long zoneId, long accountId, VlanType vlanType);
|
List<VlanVO> listVlansForAccountByType(Long zoneId, long accountId, VlanType vlanType);
|
||||||
|
|
||||||
// Pair<String, VlanVO> assignPodDirectAttachIpAddress(long zoneId, long podId, long accountId, long domainId);
|
|
||||||
|
|
||||||
boolean zoneHasDirectAttachUntaggedVlans(long zoneId);
|
boolean zoneHasDirectAttachUntaggedVlans(long zoneId);
|
||||||
|
|
||||||
List<VlanVO> listZoneWideVlans(long zoneId, VlanType vlanType, String vlanId);
|
List<VlanVO> listZoneWideVlans(long zoneId, VlanType vlanType, String vlanId);
|
||||||
|
|||||||
@ -33,9 +33,7 @@ import com.cloud.network.Networks.TrafficType;
|
|||||||
import com.cloud.network.addr.PublicIp;
|
import com.cloud.network.addr.PublicIp;
|
||||||
import com.cloud.network.rules.FirewallRule;
|
import com.cloud.network.rules.FirewallRule;
|
||||||
import com.cloud.network.vpn.RemoteAccessVpnElement;
|
import com.cloud.network.vpn.RemoteAccessVpnElement;
|
||||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.AccountVO;
|
import com.cloud.user.AccountVO;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
@ -59,13 +57,14 @@ public interface NetworkManager extends NetworkService {
|
|||||||
* Assigns a new public ip address.
|
* Assigns a new public ip address.
|
||||||
*
|
*
|
||||||
* @param dcId
|
* @param dcId
|
||||||
|
* @param podId TODO
|
||||||
* @param owner
|
* @param owner
|
||||||
* @param type
|
* @param type
|
||||||
* @param networkId
|
* @param networkId
|
||||||
* @return
|
* @return
|
||||||
* @throws InsufficientAddressCapacityException
|
* @throws InsufficientAddressCapacityException
|
||||||
*/
|
*/
|
||||||
PublicIp assignPublicIpAddress(long dcId, Account owner, VlanType type, Long networkId) throws InsufficientAddressCapacityException;
|
PublicIp assignPublicIpAddress(long dcId, Long podId, Account owner, VlanType type, Long networkId) throws InsufficientAddressCapacityException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* assigns a source nat ip address to an account within a network.
|
* assigns a source nat ip address to an account within a network.
|
||||||
@ -126,20 +125,18 @@ public interface NetworkManager extends NetworkService {
|
|||||||
|
|
||||||
List<NetworkVO> getNetworksforOffering(long offeringId, long dataCenterId, long accountId);
|
List<NetworkVO> getNetworksforOffering(long offeringId, long dataCenterId, long accountId);
|
||||||
|
|
||||||
List<NetworkVO> setupNetwork(Account owner, ServiceOfferingVO offering, DeploymentPlan plan) throws ConcurrentOperationException;
|
|
||||||
|
|
||||||
Network getNetwork(long id);
|
|
||||||
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
|
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
|
||||||
|
|
||||||
boolean applyRules(List<? extends FirewallRule> rules, boolean continueOnError) throws ResourceUnavailableException;
|
boolean applyRules(List<? extends FirewallRule> rules, boolean continueOnError) throws ResourceUnavailableException;
|
||||||
|
|
||||||
Map<Service, Map<Capability, String>> getZoneCapabilities(long zoneId);
|
Map<Service, Map<Capability, String>> getZoneCapabilities(long zoneId);
|
||||||
|
|
||||||
long getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(long zoneId, TrafficType trafficType, GuestIpType guestType);
|
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||||
|
|
||||||
List<? extends RemoteAccessVpnElement> getRemoteAccessVpnElements();
|
List<? extends RemoteAccessVpnElement> getRemoteAccessVpnElements();
|
||||||
|
|
||||||
PublicIpAddress getPublicIpAddress(Ip ipAddress);
|
PublicIpAddress getPublicIpAddress(Ip ipAddress);
|
||||||
|
|
||||||
Network getBasicZoneDefaultPublicNetwork(long zoneId);
|
String getPodVlanGateway(long podId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,30 +43,30 @@ import com.cloud.agent.api.to.NicTO;
|
|||||||
import com.cloud.agent.manager.Commands;
|
import com.cloud.agent.manager.Commands;
|
||||||
import com.cloud.alert.AlertManager;
|
import com.cloud.alert.AlertManager;
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.ServerApiException;
|
|
||||||
import com.cloud.api.commands.AssociateIPAddrCmd;
|
import com.cloud.api.commands.AssociateIPAddrCmd;
|
||||||
import com.cloud.api.commands.CreateNetworkCmd;
|
import com.cloud.api.commands.CreateNetworkCmd;
|
||||||
import com.cloud.api.commands.DisassociateIPAddrCmd;
|
import com.cloud.api.commands.DisassociateIPAddrCmd;
|
||||||
import com.cloud.api.commands.ListNetworksCmd;
|
import com.cloud.api.commands.ListNetworksCmd;
|
||||||
import com.cloud.api.commands.RestartNetworkCmd;
|
import com.cloud.api.commands.RestartNetworkCmd;
|
||||||
import com.cloud.capacity.dao.CapacityDao;
|
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.configuration.dao.ResourceLimitDao;
|
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
import com.cloud.dc.DataCenter.NetworkType;
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
|
import com.cloud.dc.PodVlanMapVO;
|
||||||
import com.cloud.dc.Vlan;
|
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.PodVlanMapDao;
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
import com.cloud.deploy.DataCenterDeployment;
|
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.Domain;
|
||||||
import com.cloud.domain.dao.DomainDao;
|
import com.cloud.domain.dao.DomainDao;
|
||||||
import com.cloud.event.EventTypes;
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.event.EventUtils;
|
import com.cloud.event.EventUtils;
|
||||||
@ -87,20 +87,15 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.network.Network.Capability;
|
import com.cloud.network.Network.Capability;
|
||||||
import com.cloud.network.Network.Service;
|
import com.cloud.network.Network.Service;
|
||||||
import com.cloud.network.Networks.AddressFormat;
|
import com.cloud.network.Networks.AddressFormat;
|
||||||
import com.cloud.network.Networks.Availability;
|
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.network.addr.PublicIp;
|
import com.cloud.network.addr.PublicIp;
|
||||||
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.NetworkDao;
|
import com.cloud.network.dao.NetworkDao;
|
||||||
import com.cloud.network.dao.RemoteAccessVpnDao;
|
import com.cloud.network.dao.RemoteAccessVpnDao;
|
||||||
import com.cloud.network.dao.VpnUserDao;
|
|
||||||
import com.cloud.network.element.NetworkElement;
|
import com.cloud.network.element.NetworkElement;
|
||||||
import com.cloud.network.guru.NetworkGuru;
|
import com.cloud.network.guru.NetworkGuru;
|
||||||
import com.cloud.network.lb.LoadBalancingRule;
|
import com.cloud.network.lb.LoadBalancingRule;
|
||||||
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
|
||||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||||
import com.cloud.network.rules.FirewallRule;
|
import com.cloud.network.rules.FirewallRule;
|
||||||
@ -109,13 +104,12 @@ import com.cloud.network.rules.RulesManager;
|
|||||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||||
import com.cloud.network.vpn.RemoteAccessVpnElement;
|
import com.cloud.network.vpn.RemoteAccessVpnElement;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.offering.NetworkOffering.Availability;
|
||||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
import com.cloud.resource.Resource;
|
import com.cloud.resource.Resource;
|
||||||
import com.cloud.resource.Resource.ReservationStrategy;
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.AccountManager;
|
import com.cloud.user.AccountManager;
|
||||||
import com.cloud.user.AccountVO;
|
import com.cloud.user.AccountVO;
|
||||||
@ -170,27 +164,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
@Inject EventDao _eventDao = null;
|
@Inject EventDao _eventDao = null;
|
||||||
@Inject ConfigurationDao _configDao;
|
@Inject ConfigurationDao _configDao;
|
||||||
@Inject UserVmDao _vmDao = null;
|
@Inject UserVmDao _vmDao = null;
|
||||||
@Inject ResourceLimitDao _limitDao = null;
|
|
||||||
@Inject CapacityDao _capacityDao = null;
|
|
||||||
@Inject AgentManager _agentMgr;
|
@Inject AgentManager _agentMgr;
|
||||||
@Inject AlertManager _alertMgr;
|
@Inject AlertManager _alertMgr;
|
||||||
@Inject AccountManager _accountMgr;
|
@Inject AccountManager _accountMgr;
|
||||||
@Inject ConfigurationManager _configMgr;
|
@Inject ConfigurationManager _configMgr;
|
||||||
@Inject ServiceOfferingDao _serviceOfferingDao = null;
|
|
||||||
@Inject AccountVlanMapDao _accountVlanMapDao;
|
@Inject AccountVlanMapDao _accountVlanMapDao;
|
||||||
@Inject UserStatisticsDao _statsDao = null;
|
|
||||||
@Inject NetworkOfferingDao _networkOfferingDao = null;
|
@Inject NetworkOfferingDao _networkOfferingDao = null;
|
||||||
@Inject NetworkDao _networksDao = null;
|
@Inject NetworkDao _networksDao = null;
|
||||||
@Inject NicDao _nicDao = null;
|
@Inject NicDao _nicDao = null;
|
||||||
@Inject RemoteAccessVpnDao _remoteAccessVpnDao = null;
|
@Inject RemoteAccessVpnDao _remoteAccessVpnDao = null;
|
||||||
@Inject VpnUserDao _vpnUsersDao = null;
|
|
||||||
@Inject VirtualNetworkApplianceManager _routerMgr;
|
@Inject VirtualNetworkApplianceManager _routerMgr;
|
||||||
@Inject RulesManager _rulesMgr;
|
@Inject RulesManager _rulesMgr;
|
||||||
@Inject LoadBalancingRulesManager _lbMgr;
|
@Inject LoadBalancingRulesManager _lbMgr;
|
||||||
@Inject FirewallRulesDao _firewallRulesDao;
|
|
||||||
@Inject LoadBalancerDao _lbDao;
|
|
||||||
@Inject PortForwardingRulesDao _pfRulesDao;
|
@Inject PortForwardingRulesDao _pfRulesDao;
|
||||||
@Inject UsageEventDao _usageEventDao;
|
@Inject UsageEventDao _usageEventDao;
|
||||||
|
@Inject PodVlanMapDao _podVlanMapDao;
|
||||||
|
|
||||||
@Inject(adapter=NetworkGuru.class)
|
@Inject(adapter=NetworkGuru.class)
|
||||||
Adapters<NetworkGuru> _networkGurus;
|
Adapters<NetworkGuru> _networkGurus;
|
||||||
@ -203,7 +191,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
|
|
||||||
SearchBuilder<AccountVO> AccountsUsingNetworkSearch;
|
SearchBuilder<AccountVO> AccountsUsingNetworkSearch;
|
||||||
SearchBuilder<IPAddressVO> AssignIpAddressSearch;
|
SearchBuilder<IPAddressVO> AssignIpAddressSearch;
|
||||||
|
SearchBuilder<IPAddressVO> AssignIpAddressFromPodVlanSearch;
|
||||||
SearchBuilder<IPAddressVO> IpAddressSearch;
|
SearchBuilder<IPAddressVO> IpAddressSearch;
|
||||||
|
|
||||||
int _networkGcWait;
|
int _networkGcWait;
|
||||||
int _networkGcInterval;
|
int _networkGcInterval;
|
||||||
|
|
||||||
@ -212,15 +202,22 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
HashMap<Long, Long> _lastNetworkIdsToFree = new HashMap<Long, Long>();
|
HashMap<Long, Long> _lastNetworkIdsToFree = new HashMap<Long, Long>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PublicIp assignPublicIpAddress(long dcId, Account owner, VlanType type, Long networkId) throws InsufficientAddressCapacityException {
|
public PublicIp assignPublicIpAddress(long dcId, Long podId, Account owner, VlanType type, Long networkId) throws InsufficientAddressCapacityException {
|
||||||
return fetchNewPublicIp(dcId, owner, type, networkId, false, true);
|
return fetchNewPublicIp(dcId, podId, owner, type, networkId, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
public PublicIp fetchNewPublicIp(long dcId, Account owner, VlanType vlanUse, Long networkId, boolean sourceNat, boolean assign) throws InsufficientAddressCapacityException {
|
public PublicIp fetchNewPublicIp(long dcId, Long podId, Account owner, VlanType vlanUse, Long networkId, boolean sourceNat, boolean assign) throws InsufficientAddressCapacityException {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
SearchCriteria<IPAddressVO> sc = AssignIpAddressSearch.create();
|
SearchCriteria<IPAddressVO> sc = null;
|
||||||
|
if (podId != null) {
|
||||||
|
sc = AssignIpAddressFromPodVlanSearch.create();
|
||||||
|
sc.setJoinParameters("podVlanMapSB", "podId", podId);
|
||||||
|
} else {
|
||||||
|
sc = AssignIpAddressSearch.create();
|
||||||
|
}
|
||||||
|
|
||||||
sc.setParameters("dc", dcId);
|
sc.setParameters("dc", dcId);
|
||||||
|
|
||||||
//for direct network take ip addresses only from the vlans belonging to the network
|
//for direct network take ip addresses only from the vlans belonging to the network
|
||||||
@ -303,7 +300,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
s_logger.debug("assigning a new ip address in " + dcId + " to " + owner);
|
s_logger.debug("assigning a new ip address in " + dcId + " to " + owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
ip = fetchNewPublicIp(dcId, owner, VlanType.VirtualNetwork, network.getId(), true, false);
|
ip = fetchNewPublicIp(dcId, null, owner, VlanType.VirtualNetwork, network.getId(), true, false);
|
||||||
sourceNat = ip.ip();
|
sourceNat = ip.ip();
|
||||||
sourceNat.setState(IpAddress.State.Allocated);
|
sourceNat.setState(IpAddress.State.Allocated);
|
||||||
_ipAddressDao.update(sourceNat.getAddress(), sourceNat);
|
_ipAddressDao.update(sourceNat.getAddress(), sourceNat);
|
||||||
@ -441,25 +438,23 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
protected Account getAccountForApiCommand(String accountName, Long domainId) throws InvalidParameterValueException, PermissionDeniedException{
|
protected Account getAccountForApiCommand(String accountName, Long domainId) throws InvalidParameterValueException, PermissionDeniedException{
|
||||||
Account account = UserContext.current().getCaller();
|
Account account = UserContext.current().getCaller();
|
||||||
|
|
||||||
if ((account == null) || isAdmin(account.getType())) {
|
if (_accountMgr.isAdmin(account.getType())) {
|
||||||
//The admin is making the call, determine if it is for someone else or for himself
|
//The admin is making the call, determine if it is for someone else or for himself
|
||||||
if (domainId != null) {
|
if (domainId != null) {
|
||||||
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||||
throw new PermissionDeniedException("Invalid domain id (" + domainId + ") given, , permission denied");
|
throw new PermissionDeniedException("Invalid domain id (" + domainId + ") given, , permission denied");
|
||||||
}
|
}
|
||||||
if (accountName != null) {
|
if (accountName != null) {
|
||||||
Account userAccount = _accountDao.findActiveAccount(accountName, domainId);
|
Account userAccount = _accountMgr.getActiveAccount(accountName, domainId);
|
||||||
if (userAccount != null) {
|
if (userAccount != null) {
|
||||||
account = userAccount;
|
account = userAccount;
|
||||||
} else {
|
} else {
|
||||||
throw new PermissionDeniedException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
|
throw new PermissionDeniedException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (account != null) {
|
} else {
|
||||||
// the admin is calling the api on his own behalf
|
// the admin is calling the api on his own behalf
|
||||||
return account;
|
return account;
|
||||||
} else {
|
|
||||||
throw new InvalidParameterValueException("Account information is not specified.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return account;
|
return account;
|
||||||
@ -506,7 +501,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Network> getVirtualNetworksOwnedByAccountInZone(String accountName, long domainId, long zoneId) {
|
public List<? extends Network> getVirtualNetworksOwnedByAccountInZone(String accountName, long domainId, long zoneId) {
|
||||||
Account owner = _accountDao.findActiveAccount(accountName, domainId);
|
Account owner = _accountMgr.getActiveAccount(accountName, domainId);
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
|
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
|
||||||
}
|
}
|
||||||
@ -522,7 +517,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
Account caller = UserContext.current().getCaller();
|
Account caller = UserContext.current().getCaller();
|
||||||
long userId = UserContext.current().getCallerUserId();
|
long userId = UserContext.current().getCallerUserId();
|
||||||
|
|
||||||
Account owner = _accountDao.findActiveAccount(accountName, domainId);
|
Account owner = _accountMgr.getActiveAccount(accountName, domainId);
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
|
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
|
||||||
}
|
}
|
||||||
@ -572,7 +567,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
|
|
||||||
txn.start();
|
txn.start();
|
||||||
ip = fetchNewPublicIp(zoneId, owner, VlanType.VirtualNetwork, network.getId(), false, false);
|
ip = fetchNewPublicIp(zoneId, null, owner, VlanType.VirtualNetwork, network.getId(), false, false);
|
||||||
|
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
throw new InsufficientAddressCapacityException("Unable to find available public IP addresses", DataCenter.class, zoneId);
|
throw new InsufficientAddressCapacityException("Unable to find available public IP addresses", DataCenter.class, zoneId);
|
||||||
@ -701,25 +696,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
_networkGcWait = NumbersUtil.parseInt(_configs.get(Config.NetworkGcWait.key()), 600);
|
_networkGcWait = NumbersUtil.parseInt(_configs.get(Config.NetworkGcWait.key()), 600);
|
||||||
_networkGcInterval = NumbersUtil.parseInt(_configs.get(Config.NetworkGcInterval.key()), 600);
|
_networkGcInterval = NumbersUtil.parseInt(_configs.get(Config.NetworkGcInterval.key()), 600);
|
||||||
|
|
||||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmPublicNetwork, TrafficType.Public, null);
|
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork, TrafficType.Public, null);
|
||||||
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
||||||
_systemNetworks.put(NetworkOfferingVO.SystemVmPublicNetwork, publicNetworkOffering);
|
_systemNetworks.put(NetworkOfferingVO.SystemPublicNetwork, publicNetworkOffering);
|
||||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
|
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemManagementNetwork, TrafficType.Management, null);
|
||||||
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
||||||
_systemNetworks.put(NetworkOfferingVO.SystemVmManagementNetwork, managementNetworkOffering);
|
_systemNetworks.put(NetworkOfferingVO.SystemManagementNetwork, managementNetworkOffering);
|
||||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmControlNetwork, TrafficType.Control, null);
|
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemControlNetwork, TrafficType.Control, null);
|
||||||
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
||||||
_systemNetworks.put(NetworkOfferingVO.SystemVmControlNetwork, controlNetworkOffering);
|
_systemNetworks.put(NetworkOfferingVO.SystemControlNetwork, controlNetworkOffering);
|
||||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmStorageNetwork, TrafficType.Storage, null);
|
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemStorageNetwork, TrafficType.Storage, null);
|
||||||
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
||||||
_systemNetworks.put(NetworkOfferingVO.SystemVmStorageNetwork, storageNetworkOffering);
|
_systemNetworks.put(NetworkOfferingVO.SystemStorageNetwork, storageNetworkOffering);
|
||||||
|
NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SysteGuestNetwork, TrafficType.Guest, null);
|
||||||
|
guestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(guestNetworkOffering);
|
||||||
|
_systemNetworks.put(NetworkOfferingVO.SysteGuestNetwork, guestNetworkOffering);
|
||||||
|
|
||||||
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtual, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
||||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering);
|
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering);
|
||||||
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Public, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Public, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
||||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
|
defaultGuestDirectNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
|
||||||
NetworkOfferingVO defaultGuestDirectPodBasedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectPodBasedNetworkOffering, "DirectPodBased", TrafficType.Public, GuestIpType.DirectPodBased, true, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
|
||||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectPodBasedNetworkOffering);
|
|
||||||
|
|
||||||
AccountsUsingNetworkSearch = _accountDao.createSearchBuilder();
|
AccountsUsingNetworkSearch = _accountDao.createSearchBuilder();
|
||||||
SearchBuilder<NetworkAccountVO> networkAccountSearch = _networksDao.createSearchBuilderForAccount();
|
SearchBuilder<NetworkAccountVO> networkAccountSearch = _networksDao.createSearchBuilderForAccount();
|
||||||
@ -729,14 +725,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
AccountsUsingNetworkSearch.done();
|
AccountsUsingNetworkSearch.done();
|
||||||
|
|
||||||
AssignIpAddressSearch = _ipAddressDao.createSearchBuilder();
|
AssignIpAddressSearch = _ipAddressDao.createSearchBuilder();
|
||||||
SearchBuilder<VlanVO> vlanSearch = _vlanDao.createSearchBuilder();
|
|
||||||
AssignIpAddressSearch.and("dc", AssignIpAddressSearch.entity().getDataCenterId(), Op.EQ);
|
AssignIpAddressSearch.and("dc", AssignIpAddressSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
AssignIpAddressSearch.and("allocated", AssignIpAddressSearch.entity().getAllocatedTime(), Op.NULL);
|
AssignIpAddressSearch.and("allocated", AssignIpAddressSearch.entity().getAllocatedTime(), Op.NULL);
|
||||||
AssignIpAddressSearch.join("vlan", vlanSearch, vlanSearch.entity().getId(), AssignIpAddressSearch.entity().getVlanId(), JoinType.INNER);
|
SearchBuilder<VlanVO> vlanSearch = _vlanDao.createSearchBuilder();
|
||||||
vlanSearch.and("type", vlanSearch.entity().getVlanType(), Op.EQ);
|
vlanSearch.and("type", vlanSearch.entity().getVlanType(), Op.EQ);
|
||||||
vlanSearch.and("networkId", vlanSearch.entity().getNetworkId(), Op.EQ);
|
vlanSearch.and("networkId", vlanSearch.entity().getNetworkId(), Op.EQ);
|
||||||
|
AssignIpAddressSearch.join("vlan", vlanSearch, vlanSearch.entity().getId(), AssignIpAddressSearch.entity().getVlanId(), JoinType.INNER);
|
||||||
AssignIpAddressSearch.done();
|
AssignIpAddressSearch.done();
|
||||||
|
|
||||||
|
AssignIpAddressFromPodVlanSearch = _ipAddressDao.createSearchBuilder();
|
||||||
|
AssignIpAddressFromPodVlanSearch.and("dc", AssignIpAddressFromPodVlanSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
|
AssignIpAddressFromPodVlanSearch.and("allocated", AssignIpAddressFromPodVlanSearch.entity().getAllocatedTime(), Op.NULL);
|
||||||
|
SearchBuilder<VlanVO> podVlanSearch = _vlanDao.createSearchBuilder();
|
||||||
|
podVlanSearch.and("type", podVlanSearch.entity().getVlanType(), Op.EQ);
|
||||||
|
podVlanSearch.and("networkId", podVlanSearch.entity().getNetworkId(), Op.EQ);
|
||||||
|
SearchBuilder<PodVlanMapVO> podVlanMapSB = _podVlanMapDao.createSearchBuilder();
|
||||||
|
podVlanMapSB.and("podId", podVlanMapSB.entity().getPodId(), Op.EQ);
|
||||||
|
AssignIpAddressFromPodVlanSearch.join("podVlanMapSB", podVlanMapSB, podVlanMapSB.entity().getVlanDbId(), AssignIpAddressFromPodVlanSearch.entity().getVlanId(), JoinType.INNER);
|
||||||
|
AssignIpAddressFromPodVlanSearch.join("vlan", podVlanSearch, podVlanSearch.entity().getId(), AssignIpAddressFromPodVlanSearch.entity().getVlanId(), JoinType.INNER);
|
||||||
|
AssignIpAddressFromPodVlanSearch.done();
|
||||||
|
|
||||||
IpAddressSearch = _ipAddressDao.createSearchBuilder();
|
IpAddressSearch = _ipAddressDao.createSearchBuilder();
|
||||||
IpAddressSearch.and("accountId", IpAddressSearch.entity().getAllocatedToAccountId(), Op.EQ);
|
IpAddressSearch.and("accountId", IpAddressSearch.entity().getAllocatedToAccountId(), Op.EQ);
|
||||||
IpAddressSearch.and("dataCenterId", IpAddressSearch.entity().getDataCenterId(), Op.EQ);
|
IpAddressSearch.and("dataCenterId", IpAddressSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
@ -1114,16 +1122,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
return _nicDao.listBy(vm.getId());
|
return _nicDao.listBy(vm.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAdmin(short accountType) {
|
|
||||||
return ((accountType == Account.ACCOUNT_TYPE_ADMIN) ||
|
|
||||||
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) ||
|
|
||||||
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Account findAccountByIpAddress(Ip ipAddress) {
|
private Account findAccountByIpAddress(Ip ipAddress) {
|
||||||
IPAddressVO address = _ipAddressDao.findById(ipAddress);
|
IPAddressVO address = _ipAddressDao.findById(ipAddress);
|
||||||
if ((address != null) && (address.getAllocatedToAccountId() != null)) {
|
if ((address != null) && (address.getAllocatedToAccountId() != null)) {
|
||||||
return _accountDao.findById(address.getAllocatedToAccountId());
|
return _accountMgr.getAccount(address.getAllocatedToAccountId());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1133,29 +1135,23 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
public boolean disassociateIpAddress(DisassociateIPAddrCmd cmd) throws PermissionDeniedException, IllegalArgumentException {
|
public boolean disassociateIpAddress(DisassociateIPAddrCmd cmd) throws PermissionDeniedException, IllegalArgumentException {
|
||||||
|
|
||||||
Long userId = UserContext.current().getCallerUserId();
|
Long userId = UserContext.current().getCallerUserId();
|
||||||
Account account = UserContext.current().getCaller();
|
Account caller = UserContext.current().getCaller();
|
||||||
Ip ipAddress = cmd.getIpAddress();
|
Ip ipAddress = cmd.getIpAddress();
|
||||||
|
|
||||||
// Verify input parameters
|
// Verify input parameters
|
||||||
Account accountByIp = findAccountByIpAddress(ipAddress);
|
Account accountByIp = findAccountByIpAddress(ipAddress);
|
||||||
if(accountByIp == null) {
|
if(accountByIp == null) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find account owner for ip " + ipAddress);
|
throw new InvalidParameterValueException("Unable to find account owner for ip " + ipAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
Long accountId = accountByIp.getId();
|
Long accountId = accountByIp.getId();
|
||||||
if (account != null) {
|
if (!_accountMgr.isAdmin(caller.getType())) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (caller.getId() != accountId.longValue()) {
|
||||||
if (account.getId() != accountId.longValue()) {
|
throw new PermissionDeniedException("account " + caller.getAccountName() + " doesn't own ip address " + ipAddress);
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "account " + account.getAccountName() + " doesn't own ip address " + ipAddress);
|
|
||||||
}
|
}
|
||||||
} else if (!_domainDao.isChildDomain(account.getDomainId(), accountByIp.getDomainId())) {
|
} else {
|
||||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to disassociate IP address " + ipAddress + ", permission denied.");
|
Domain domain = _domainDao.findById(accountByIp.getDomainId());
|
||||||
}
|
_accountMgr.checkAccess(caller, domain);
|
||||||
}
|
|
||||||
|
|
||||||
// If command is executed via 8096 port, set userId to the id of System account (1)
|
|
||||||
if (userId == null) {
|
|
||||||
userId = Long.valueOf(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1168,7 +1164,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Account Account = _accountDao.findById(accountId);
|
Account Account = _accountMgr.getAccount(accountId);
|
||||||
if (Account == null) {
|
if (Account == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1240,12 +1236,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
return _networksDao.getNetworksForOffering(offeringId, dataCenterId, accountId);
|
return _networksDao.getNetworksForOffering(offeringId, dataCenterId, accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<NetworkVO> setupNetwork(Account owner, ServiceOfferingVO offering, DeploymentPlan plan) throws ConcurrentOperationException {
|
|
||||||
NetworkOfferingVO networkOffering = _networkOfferingDao.findByServiceOffering(offering);
|
|
||||||
return setupNetwork(owner, networkOffering, plan, null, null, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NetworkOfferingVO> listNetworkOfferings() {
|
public List<NetworkOfferingVO> listNetworkOfferings() {
|
||||||
return _networkOfferingDao.listNonSystemNetworkOfferings();
|
return _networkOfferingDao.listNonSystemNetworkOfferings();
|
||||||
@ -1312,8 +1302,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
String name = cmd.getNetworkName();
|
String name = cmd.getNetworkName();
|
||||||
String displayText = cmd.getDisplayText();
|
String displayText = cmd.getDisplayText();
|
||||||
Boolean isShared = cmd.getIsShared();
|
Boolean isShared = cmd.getIsShared();
|
||||||
Account owner = null;
|
|
||||||
Long ownerId = null;
|
|
||||||
|
|
||||||
//if end ip is not specified, default it to startIp
|
//if end ip is not specified, default it to startIp
|
||||||
if (endIP == null && startIP != null) {
|
if (endIP == null && startIP != null) {
|
||||||
@ -1331,30 +1319,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
throw new InvalidParameterValueException("Please specify a valid zone.");
|
throw new InvalidParameterValueException("Please specify a valid zone.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check permissions
|
DataCenter zone = _dcDao.findById(zoneId);
|
||||||
if (isAdmin(ctxAccount.getType())) {
|
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||||
if (domainId != null) {
|
throw new InvalidParameterValueException("Network creation is not allowed in zone with network type " + NetworkType.Basic);
|
||||||
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 {
|
|
||||||
//regular user can't create networks for anybody else but himself
|
|
||||||
owner = ctxAccount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ownerId = owner.getId();
|
Account owner = _accountMgr.finalizeOwner(ctxAccount, accountName, domainId);
|
||||||
|
|
||||||
//Don't allow to create network with vlan that already exists in the system
|
//Don't allow to create network with vlan that already exists in the system
|
||||||
if (networkOffering.getGuestIpType() == GuestIpType.Direct && vlanId != null) {
|
if (vlanId != null) {
|
||||||
String uri ="vlan://" + vlanId;
|
String uri ="vlan://" + vlanId;
|
||||||
List<NetworkVO> networks = _networksDao.listBy(zoneId, uri);
|
List<NetworkVO> networks = _networksDao.listBy(zoneId, uri);
|
||||||
if ((networks != null && !networks.isEmpty())) {
|
if ((networks != null && !networks.isEmpty())) {
|
||||||
@ -1362,32 +1335,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if VlanId is Direct untagged, verify if there is already network of this type in the zone
|
|
||||||
if (networkOffering.getGuestIpType() == GuestIpType.DirectPodBased && vlanId != null && vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) {
|
|
||||||
SearchBuilder<NetworkVO> sb = _networksDao.createSearchBuilder();
|
|
||||||
sb.and("broadcastDomainType", sb.entity().getBroadcastDomainType(), SearchCriteria.Op.EQ);
|
|
||||||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
|
||||||
|
|
||||||
SearchBuilder<NetworkOfferingVO> networkSearch = _networkOfferingDao.createSearchBuilder();
|
|
||||||
networkSearch.and("guestIpType", networkSearch.entity().getGuestIpType(), SearchCriteria.Op.EQ);
|
|
||||||
sb.join("networkSearch", networkSearch, sb.entity().getNetworkOfferingId(), networkSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
|
||||||
|
|
||||||
SearchCriteria<NetworkVO> sc = sb.create();
|
|
||||||
sc.setParameters("broadcastDomainType", BroadcastDomainType.Native);
|
|
||||||
sc.setParameters("dataCenterId", zoneId);
|
|
||||||
sc.setJoinParameters("networkSearch", "guestIpType", GuestIpType.DirectPodBased);
|
|
||||||
|
|
||||||
List<NetworkVO> networks = _networksDao.search(sc, null);
|
|
||||||
if (networks!= null && !networks.isEmpty()) {
|
|
||||||
throw new InvalidParameterValueException("Network with untagged vlan already exists for the zone " + zoneId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Regular user can create only network of Virtual type
|
|
||||||
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_NORMAL && networkOffering.getGuestIpType() != GuestIpType.Virtual) {
|
|
||||||
throw new InvalidParameterValueException("Regular user can create only networ of type " + GuestIpType.Virtual);
|
|
||||||
}
|
|
||||||
|
|
||||||
//VlanId can be specified only when network offering supports it
|
//VlanId can be specified only when network offering supports it
|
||||||
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_NORMAL && vlanId != null && !networkOffering.getSpecifyVlan()) {
|
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_NORMAL && vlanId != null && !networkOffering.getSpecifyVlan()) {
|
||||||
throw new InvalidParameterValueException("Can't specify vlan because network offering doesn't support it");
|
throw new InvalidParameterValueException("Can't specify vlan because network offering doesn't support it");
|
||||||
@ -1420,14 +1367,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared);
|
List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared);
|
||||||
Long networkId = null;
|
Long networkId = null;
|
||||||
|
|
||||||
|
Network network = null;
|
||||||
if (networks == null || networks.isEmpty()) {
|
if (networks == null || networks.isEmpty()) {
|
||||||
txn.rollback();
|
txn.rollback();
|
||||||
throw new CloudRuntimeException("Fail to create a network");
|
throw new CloudRuntimeException("Fail to create a network");
|
||||||
} else {
|
} else {
|
||||||
|
network = networks.get(0);
|
||||||
networkId = networks.get(0).getId();
|
networkId = networks.get(0).getId();
|
||||||
}
|
|
||||||
|
|
||||||
for (Network network : networks) {
|
|
||||||
if (network.getGuestType() == GuestIpType.Virtual) {
|
if (network.getGuestType() == GuestIpType.Virtual) {
|
||||||
s_logger.debug("Creating a source natp ip for " + network);
|
s_logger.debug("Creating a source natp ip for " + network);
|
||||||
PublicIp ip = assignSourceNatIpAddress(owner, network, userId);
|
PublicIp ip = assignSourceNatIpAddress(owner, network, userId);
|
||||||
@ -1437,12 +1383,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long ownerId = owner.getId();
|
||||||
//Don't pass owner to create vlan when network offering is of type Direct - done to prevent accountVlanMap entry creation when vlan is mapped to network
|
//Don't pass owner to create vlan when network offering is of type Direct - done to prevent accountVlanMap entry creation when vlan is mapped to network
|
||||||
if (networkOffering.getGuestIpType() == GuestIpType.Direct) {
|
if (network.getGuestType() == GuestIpType.Direct) {
|
||||||
owner = null;
|
owner = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_ADMIN && networkOffering.getGuestIpType() == GuestIpType.Direct && startIP != null && endIP != null && gateway != null) {
|
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_ADMIN && network.getGuestType() == GuestIpType.Direct && startIP != null && endIP != null && gateway != null) {
|
||||||
//Create vlan ip range
|
//Create vlan ip range
|
||||||
Vlan vlan = _configMgr.createVlanAndPublicIpRange(userId, zoneId, null, startIP, endIP, gateway, netmask, false, vlanId, owner, networkId);
|
Vlan vlan = _configMgr.createVlanAndPublicIpRange(userId, zoneId, null, startIP, endIP, gateway, netmask, false, vlanId, owner, networkId);
|
||||||
if (vlan == null) {
|
if (vlan == null) {
|
||||||
@ -1493,14 +1440,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
isSystem = false;
|
isSystem = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin(account.getType())) {
|
if (_accountMgr.isAdmin(account.getType())) {
|
||||||
if (domainId != null) {
|
if (domainId != null) {
|
||||||
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||||
throw new PermissionDeniedException("Invalid domain id (" + domainId + ") given, unable to list networks");
|
throw new PermissionDeniedException("Invalid domain id (" + domainId + ") given, unable to list networks");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accountName != null) {
|
if (accountName != null) {
|
||||||
account = _accountDao.findActiveAccount(accountName, domainId);
|
account = _accountMgr.getActiveAccount(accountName, domainId);
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
||||||
}
|
}
|
||||||
@ -1567,7 +1514,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
@Override @DB
|
@Override @DB
|
||||||
public boolean deleteNetwork(long networkId) throws InvalidParameterValueException, PermissionDeniedException{
|
public boolean deleteNetwork(long networkId) throws InvalidParameterValueException, PermissionDeniedException{
|
||||||
Long userId = UserContext.current().getCallerUserId();
|
Long userId = UserContext.current().getCallerUserId();
|
||||||
Account account = UserContext.current().getCaller();
|
Account caller = UserContext.current().getCaller();
|
||||||
|
|
||||||
//Verify network id
|
//Verify network id
|
||||||
NetworkVO network = _networksDao.findById(networkId);
|
NetworkVO network = _networksDao.findById(networkId);
|
||||||
@ -1580,14 +1527,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
String name = network.getName();
|
String name = network.getName();
|
||||||
|
|
||||||
//Perform permission check
|
//Perform permission check
|
||||||
if (account != null) {
|
if (!_accountMgr.isAdmin(caller.getType())) {
|
||||||
if (!isAdmin(account.getType())) {
|
if (network.getAccountId() != caller.getId()) {
|
||||||
if (network.getAccountId() != account.getId()) {
|
throw new PermissionDeniedException("Account " + caller.getAccountName() + " does not own network id=" + networkId + ", permission denied");
|
||||||
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.");
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Account owner = _accountMgr.getAccount(network.getAccountId());
|
||||||
|
Domain domain = _domainDao.findById(owner.getDomainId());
|
||||||
|
_accountMgr.checkAccess(caller, domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Don't allow to remove network if there are non-destroyed vms using it
|
//Don't allow to remove network if there are non-destroyed vms using it
|
||||||
@ -1757,17 +1704,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
@Override
|
@Override
|
||||||
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException {
|
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||||
//This method reapplies Ip addresses, LoadBalancer and PortForwarding rules
|
//This method reapplies Ip addresses, LoadBalancer and PortForwarding rules
|
||||||
String accountName = cmd.getAccountName();
|
|
||||||
long domainId = cmd.getDomainId();
|
|
||||||
Account caller = UserContext.current().getCaller();
|
Account caller = UserContext.current().getCaller();
|
||||||
|
|
||||||
Account owner = _accountDao.findActiveAccount(accountName, domainId);
|
|
||||||
if (owner == null) {
|
|
||||||
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
|
|
||||||
}
|
|
||||||
|
|
||||||
_accountMgr.checkAccess(caller, owner);
|
|
||||||
|
|
||||||
Long networkId = cmd.getNetworkId();
|
Long networkId = cmd.getNetworkId();
|
||||||
Network network = null;
|
Network network = null;
|
||||||
if (networkId != null) {
|
if (networkId != null) {
|
||||||
@ -1777,28 +1715,28 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
|
||||||
|
if (!_accountMgr.isAdmin(caller.getType())) {
|
||||||
|
_accountMgr.checkAccess(caller, network);
|
||||||
|
} else {
|
||||||
|
Domain domain = _domainDao.findById(owner.getDomainId());
|
||||||
|
_accountMgr.checkAccess(caller, domain);
|
||||||
|
}
|
||||||
|
|
||||||
s_logger.debug("Restarting network " + networkId + "...");
|
s_logger.debug("Restarting network " + networkId + "...");
|
||||||
|
|
||||||
boolean success = true;
|
|
||||||
if (!applyIpAssociations(network, false)) {
|
if (!applyIpAssociations(network, false)) {
|
||||||
s_logger.warn("Failed to apply ips as a part of network " + networkId + " restart");
|
s_logger.warn("Failed to apply ips as a part of network " + networkId + " restart");
|
||||||
success = false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Ip addresses are reapplied successfully as a part of network " + networkId + " restart");
|
s_logger.debug("Ip addresses are reapplied successfully as a part of network " + networkId + " restart");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reapply lb rules
|
List<LoadBalancingRule> lbRules = _lbMgr.listByNetworkId(networkId);
|
||||||
List<LoadBalancerVO> lbs = _lbDao.listByNetworkId(networkId);
|
|
||||||
List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
|
|
||||||
for (LoadBalancerVO lb : lbs) {
|
|
||||||
List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
|
|
||||||
LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList);
|
|
||||||
lbRules.add(loadBalancing);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!applyRules(lbRules, true)) {
|
if (!applyRules(lbRules, true)) {
|
||||||
s_logger.warn("Failed to apply load balancing rules as a part of network " + network.getId() + " restart");
|
s_logger.warn("Failed to apply load balancing rules as a part of network " + network.getId() + " restart");
|
||||||
success = false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Load balancing rules are reapplied successfully as a part of network " + networkId + " restart");
|
s_logger.debug("Load balancing rules are reapplied successfully as a part of network " + networkId + " restart");
|
||||||
}
|
}
|
||||||
@ -1807,15 +1745,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
List<PortForwardingRuleVO> pfRules = _pfRulesDao.listByNetworkId(networkId);
|
List<PortForwardingRuleVO> pfRules = _pfRulesDao.listByNetworkId(networkId);
|
||||||
if (!applyRules(pfRules, true)) {
|
if (!applyRules(pfRules, true)) {
|
||||||
s_logger.warn("Failed to apply port forwarding rules as a part of network " + network.getId() + " restart");
|
s_logger.warn("Failed to apply port forwarding rules as a part of network " + network.getId() + " restart");
|
||||||
success = false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Port forwarding rules are reapplied successfully as a part of network " + networkId + " restart");
|
s_logger.debug("Port forwarding rules are reapplied successfully as a part of network " + networkId + " restart");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success){
|
|
||||||
s_logger.debug("Network " + networkId + " is restarted successfully.");
|
s_logger.debug("Network " + networkId + " is restarted successfully.");
|
||||||
}
|
return true;
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1874,26 +1810,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(long zoneId, TrafficType trafficType, GuestIpType guestType) {
|
public Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType) {
|
||||||
//find system public network offering
|
//find system public network offering
|
||||||
Long networkOfferingId = null;
|
Long networkOfferingId = null;
|
||||||
List<NetworkOfferingVO> offerings = _networkOfferingDao.listSystemNetworkOfferings();
|
List<NetworkOfferingVO> offerings = _networkOfferingDao.listSystemNetworkOfferings();
|
||||||
for (NetworkOfferingVO offering: offerings) {
|
for (NetworkOfferingVO offering: offerings) {
|
||||||
if (offering.getTrafficType() == trafficType && offering.getGuestIpType() == guestType) {
|
if (offering.getTrafficType() == trafficType) {
|
||||||
networkOfferingId = offering.getId();
|
networkOfferingId = offering.getId();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (networkOfferingId == null) {
|
if (networkOfferingId == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find system network offering with traffic type " + trafficType + " and guestIpType " + guestType);
|
throw new InvalidParameterValueException("Unable to find system network offering with traffic type " + trafficType);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NetworkVO> networks = _networksDao.listBy(Account.ACCOUNT_ID_SYSTEM, networkOfferingId, zoneId);
|
List<NetworkVO> networks = _networksDao.listBy(Account.ACCOUNT_ID_SYSTEM, networkOfferingId, zoneId);
|
||||||
if (networks == null) {
|
if (networks == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find network with traffic type " + trafficType + " in zone " + zoneId);
|
throw new InvalidParameterValueException("Unable to find network with traffic type " + trafficType + " in zone " + zoneId);
|
||||||
}
|
}
|
||||||
return networks.get(0).getId();
|
return networks.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1907,21 +1843,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Network getBasicZoneDefaultPublicNetwork(long zoneId) {
|
public String getPodVlanGateway(long podId) {
|
||||||
SearchBuilder<NetworkVO> sb = _networksDao.createSearchBuilder();
|
List<VlanVO> vlans = _vlanDao.listVlansForPodByType(podId, VlanType.DirectAttached);
|
||||||
sb.and("trafficType", sb.entity().getTrafficType(), SearchCriteria.Op.EQ);
|
//we don't allow vlans to have different gateways, so take the value from the first one
|
||||||
sb.and("guestType", sb.entity().getGuestType(), SearchCriteria.Op.EQ);
|
if (vlans == null || !vlans.isEmpty()) {
|
||||||
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
return vlans.get(0).getVlanGateway();
|
||||||
SearchCriteria<NetworkVO> sc = sb.create();
|
|
||||||
sc.setParameters("trafficType", TrafficType.Public);
|
|
||||||
sc.setParameters("guestType", GuestIpType.DirectPodBased);
|
|
||||||
sc.setParameters("dataCenterId", zoneId);
|
|
||||||
|
|
||||||
List<NetworkVO> networks = _networksDao.search(sc, null);
|
|
||||||
if (networks == null || networks.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
} else {
|
} else {
|
||||||
return networks.get(0);
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -142,14 +142,19 @@ public class NetworkVO implements Network {
|
|||||||
* @param broadcastDomainType
|
* @param broadcastDomainType
|
||||||
* @param networkOfferingId
|
* @param networkOfferingId
|
||||||
* @param dataCenterId
|
* @param dataCenterId
|
||||||
|
* @param state TODO
|
||||||
*/
|
*/
|
||||||
public NetworkVO(TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
|
public NetworkVO(TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, State state) {
|
||||||
this.trafficType = trafficType;
|
this.trafficType = trafficType;
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
this.broadcastDomainType = broadcastDomainType;
|
this.broadcastDomainType = broadcastDomainType;
|
||||||
this.networkOfferingId = networkOfferingId;
|
this.networkOfferingId = networkOfferingId;
|
||||||
this.dataCenterId = dataCenterId;
|
this.dataCenterId = dataCenterId;
|
||||||
this.state = State.Allocated;
|
if (state == null) {
|
||||||
|
state = State.Allocated;
|
||||||
|
} else {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
this.id = -1;
|
this.id = -1;
|
||||||
this.guestType = guestType;
|
this.guestType = guestType;
|
||||||
}
|
}
|
||||||
@ -183,7 +188,7 @@ public class NetworkVO implements Network {
|
|||||||
* @param isShared TODO
|
* @param isShared TODO
|
||||||
*/
|
*/
|
||||||
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, Boolean isShared) {
|
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, Boolean isShared) {
|
||||||
this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId);
|
this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId, State.Allocated);
|
||||||
this.domainId = domainId;
|
this.domainId = domainId;
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
this.related = related;
|
this.related = related;
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import javax.ejb.Local;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
@ -35,6 +36,7 @@ import com.cloud.network.Network.Capability;
|
|||||||
import com.cloud.network.Network.Provider;
|
import com.cloud.network.Network.Provider;
|
||||||
import com.cloud.network.Network.Service;
|
import com.cloud.network.Network.Service;
|
||||||
import com.cloud.network.NetworkManager;
|
import com.cloud.network.NetworkManager;
|
||||||
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.network.PublicIpAddress;
|
import com.cloud.network.PublicIpAddress;
|
||||||
import com.cloud.network.dao.NetworkDao;
|
import com.cloud.network.dao.NetworkDao;
|
||||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||||
@ -67,16 +69,24 @@ public class DhcpElement extends AdapterBase implements NetworkElement{
|
|||||||
@Inject UserVmDao _userVmDao;
|
@Inject UserVmDao _userVmDao;
|
||||||
@Inject DomainRouterDao _routerDao;
|
@Inject DomainRouterDao _routerDao;
|
||||||
|
|
||||||
private boolean canHandle(GuestIpType ipType, DeployDestination dest) {
|
private boolean canHandle(GuestIpType ipType, DeployDestination dest, TrafficType trafficType) {
|
||||||
DataCenter dc = dest.getDataCenter();
|
DataCenter dc = dest.getDataCenter();
|
||||||
String provider = dc.getGatewayProvider();
|
String provider = dc.getGatewayProvider();
|
||||||
|
|
||||||
return ((ipType == GuestIpType.Virtual && !provider.equals(Provider.VirtualRouter.getName())) || (provider.equals(Provider.VirtualRouter.getName()) && (ipType == GuestIpType.Direct || ipType == GuestIpType.DirectPodBased)));
|
if (provider.equals(Provider.VirtualRouter.getName())) {
|
||||||
|
if (dc.getNetworkType() == NetworkType.Basic) {
|
||||||
|
return (ipType == GuestIpType.Direct && trafficType == TrafficType.Guest);
|
||||||
|
} else {
|
||||||
|
return (ipType == GuestIpType.Direct);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return (ipType == GuestIpType.Virtual);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
|
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
|
||||||
if (!canHandle(offering.getGuestIpType(), dest)) {
|
if (!canHandle(network.getGuestType(), dest, offering.getTrafficType())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_routerMgr.deployDhcp(network, dest, context.getAccount());
|
_routerMgr.deployDhcp(network, dest, context.getAccount());
|
||||||
@ -85,7 +95,7 @@ public class DhcpElement extends AdapterBase implements NetworkElement{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||||
if (canHandle(network.getGuestType(), dest)) {
|
if (canHandle(network.getGuestType(), dest, network.getTrafficType())) {
|
||||||
|
|
||||||
if (vm.getType() != VirtualMachine.Type.User) {
|
if (vm.getType() != VirtualMachine.Type.User) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -93,7 +93,7 @@ public class VirtualRouterElement extends AdapterBase implements NetworkElement,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
|
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
|
||||||
if (!canHandle(offering.getGuestIpType(), dest.getDataCenter())) {
|
if (!canHandle(guestConfig.getGuestType(), dest.getDataCenter())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_routerMgr.deployVirtualRouter(guestConfig, dest, context.getAccount());
|
_routerMgr.deployVirtualRouter(guestConfig, dest, context.getAccount());
|
||||||
|
|||||||
@ -1,4 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
|
* 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.network.guru;
|
package com.cloud.network.guru;
|
||||||
@ -25,6 +39,7 @@ import com.cloud.network.Networks.BroadcastDomainType;
|
|||||||
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.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
import com.cloud.resource.Resource.ReservationStrategy;
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
@ -40,16 +55,26 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||||||
public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGuru {
|
public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGuru {
|
||||||
private static final Logger s_logger = Logger.getLogger(ControlNetworkGuru.class);
|
private static final Logger s_logger = Logger.getLogger(ControlNetworkGuru.class);
|
||||||
@Inject DataCenterDao _dcDao;
|
@Inject DataCenterDao _dcDao;
|
||||||
|
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||||
String _cidr;
|
String _cidr;
|
||||||
String _gateway;
|
String _gateway;
|
||||||
|
|
||||||
|
protected boolean canHandle(NetworkOffering offering) {
|
||||||
|
if (offering.isSystemOnly() && offering.getTrafficType() == TrafficType.Control) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
s_logger.trace("We only care about System only Control network");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network specifiedConfig, Account owner) {
|
public Network design(NetworkOffering offering, DeploymentPlan plan, Network specifiedConfig, Account owner) {
|
||||||
if (offering.getTrafficType() != TrafficType.Control) {
|
if (!canHandle(offering)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkVO config = new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId());
|
NetworkVO config = new NetworkVO(offering.getTrafficType(), null, Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId(), Network.State.Setup);
|
||||||
config.setCidr(_cidr);
|
config.setCidr(_cidr);
|
||||||
config.setGateway(_gateway);
|
config.setGateway(_gateway);
|
||||||
|
|
||||||
@ -64,7 +89,8 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
|||||||
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException {
|
InsufficientAddressCapacityException {
|
||||||
|
|
||||||
if (config.getTrafficType() != TrafficType.Control) {
|
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(config.getNetworkOfferingId());
|
||||||
|
if (!canHandle(offering)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
|
* 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.network.guru;
|
package com.cloud.network.guru;
|
||||||
@ -8,7 +22,7 @@ import javax.ejb.Local;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.dc.Vlan.VlanType;
|
import com.cloud.dc.Vlan.VlanType;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
@ -31,6 +45,7 @@ import com.cloud.network.addr.PublicIp;
|
|||||||
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.offering.NetworkOffering.GuestIpType;
|
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||||
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
import com.cloud.resource.Resource.ReservationStrategy;
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.AdapterBase;
|
import com.cloud.utils.component.AdapterBase;
|
||||||
@ -48,16 +63,32 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
@Inject VlanDao _vlanDao;
|
@Inject VlanDao _vlanDao;
|
||||||
@Inject NetworkManager _networkMgr;
|
@Inject NetworkManager _networkMgr;
|
||||||
@Inject IPAddressDao _ipAddressDao;
|
@Inject IPAddressDao _ipAddressDao;
|
||||||
|
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||||
|
|
||||||
|
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||||
|
//this guru handles only non-system Public network
|
||||||
|
if (dc.getNetworkType() == NetworkType.Advanced && offering.getTrafficType() == TrafficType.Public && !offering.isSystemOnly()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
s_logger.trace("We only take care of Public Direct networks");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||||
if (!(offering.getTrafficType() == TrafficType.Public && (offering.getGuestIpType() == GuestIpType.Direct || offering.getGuestIpType() == GuestIpType.DirectPodBased))) {
|
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
|
||||||
s_logger.trace("We only take care of public direct network, so this is no ours");
|
|
||||||
|
if (!canHandle(offering, dc)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkVO config = new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Dhcp, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
|
State state = State.Allocated;
|
||||||
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
|
if (offering.isSystemOnly()) {
|
||||||
|
state = State.Setup;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkVO config = new NetworkVO(offering.getTrafficType(), GuestIpType.Direct, Mode.Dhcp, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId(), state);
|
||||||
|
|
||||||
if (userSpecified != null) {
|
if (userSpecified != null) {
|
||||||
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
|
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
|
||||||
@ -92,7 +123,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
|
|
||||||
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||||
if (nic.getIp4Address() == null) {
|
if (nic.getIp4Address() == null) {
|
||||||
PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), vm.getOwner(), VlanType.DirectAttached, network.getId());
|
PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.DirectAttached, network.getId());
|
||||||
nic.setIp4Address(ip.getAddress().toString());
|
nic.setIp4Address(ip.getAddress().toString());
|
||||||
nic.setGateway(ip.getGateway());
|
nic.setGateway(ip.getGateway());
|
||||||
nic.setNetmask(ip.getNetmask());
|
nic.setNetmask(ip.getNetmask());
|
||||||
@ -111,6 +142,12 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException, ConcurrentOperationException {
|
InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||||
|
|
||||||
|
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||||
|
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
|
||||||
|
if (!canHandle(offering, dc)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
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 if (nic.getIp4Address() == null) {
|
} else if (nic.getIp4Address() == null) {
|
||||||
@ -119,7 +156,6 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
nic.setStrategy(ReservationStrategy.Create);
|
nic.setStrategy(ReservationStrategy.Create);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
|
||||||
getIp(nic, dc, vm, network);
|
getIp(nic, dc, vm, network);
|
||||||
|
|
||||||
return nic;
|
return nic;
|
||||||
|
|||||||
123
server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
Normal file
123
server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/**
|
||||||
|
* 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.network.guru;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.ejb.Local;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.dc.DataCenter;
|
||||||
|
import com.cloud.dc.Pod;
|
||||||
|
import com.cloud.dc.Vlan;
|
||||||
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
|
import com.cloud.dc.Vlan.VlanType;
|
||||||
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
|
import com.cloud.dc.dao.VlanDao;
|
||||||
|
import com.cloud.deploy.DeployDestination;
|
||||||
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
|
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||||
|
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||||
|
import com.cloud.network.Network;
|
||||||
|
import com.cloud.network.NetworkManager;
|
||||||
|
import com.cloud.network.Networks.AddressFormat;
|
||||||
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
|
import com.cloud.network.Networks.TrafficType;
|
||||||
|
import com.cloud.network.addr.PublicIp;
|
||||||
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
|
import com.cloud.utils.component.Inject;
|
||||||
|
import com.cloud.vm.NicProfile;
|
||||||
|
import com.cloud.vm.ReservationContext;
|
||||||
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
|
|
||||||
|
@Local(value=NetworkGuru.class)
|
||||||
|
public class DirectPodBasedNetworkGuru extends DirectNetworkGuru{
|
||||||
|
private static final Logger s_logger = Logger.getLogger(DirectPodBasedNetworkGuru.class);
|
||||||
|
|
||||||
|
@Inject DataCenterDao _dcDao;
|
||||||
|
@Inject VlanDao _vlanDao;
|
||||||
|
@Inject NetworkManager _networkMgr;
|
||||||
|
@Inject IPAddressDao _ipAddressDao;
|
||||||
|
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||||
|
//this guru handles system Direct pod based network
|
||||||
|
if (dc.getNetworkType() == NetworkType.Basic && offering.getTrafficType() == TrafficType.Guest && offering.isSystemOnly()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
s_logger.trace("We only take care of Guest Direct Pod based networks");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||||
|
InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||||
|
|
||||||
|
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||||
|
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
|
||||||
|
|
||||||
|
if (!canHandle(offering, dc)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nic == null) {
|
||||||
|
nic = new NicProfile(ReservationStrategy.Start, null, null, null, null);
|
||||||
|
} else {
|
||||||
|
nic.setStrategy(ReservationStrategy.Start);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||||
|
if (nic.getIp4Address() == null) {
|
||||||
|
getIp(nic, dest.getPod(), vm, network);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void getIp(NicProfile nic, Pod pod, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||||
|
DataCenter dc = _dcDao.findById(pod.getDataCenterId());
|
||||||
|
if (nic.getIp4Address() == null) {
|
||||||
|
PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), pod.getId(), vm.getOwner(), VlanType.DirectAttached, network.getId());
|
||||||
|
nic.setIp4Address(ip.getAddress().toString());
|
||||||
|
nic.setGateway(ip.getGateway());
|
||||||
|
nic.setNetmask(ip.getNetmask());
|
||||||
|
if(ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase(Vlan.UNTAGGED)) {
|
||||||
|
nic.setIsolationUri(URI.create("vlan://" + Vlan.UNTAGGED));
|
||||||
|
nic.setBroadcastUri(URI.create("vlan://" + Vlan.UNTAGGED));
|
||||||
|
nic.setBroadcastType(BroadcastDomainType.Native);
|
||||||
|
}
|
||||||
|
nic.setFormat(AddressFormat.Ip4);
|
||||||
|
nic.setReservationId(String.valueOf(ip.getVlanTag()));
|
||||||
|
nic.setMacAddress(ip.getMacAddress());
|
||||||
|
}
|
||||||
|
nic.setDns1(dc.getDns1());
|
||||||
|
nic.setDns2(dc.getDns2());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -24,7 +24,10 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
import com.cloud.dc.DataCenterVO;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.dc.DataCenter;
|
||||||
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
@ -56,6 +59,7 @@ import com.cloud.vm.dao.NicDao;
|
|||||||
|
|
||||||
@Local(value=NetworkGuru.class)
|
@Local(value=NetworkGuru.class)
|
||||||
public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
|
private static final Logger s_logger = Logger.getLogger(GuestNetworkGuru.class);
|
||||||
@Inject protected NetworkManager _networkMgr;
|
@Inject protected NetworkManager _networkMgr;
|
||||||
@Inject protected DataCenterDao _dcDao;
|
@Inject protected DataCenterDao _dcDao;
|
||||||
@Inject protected VlanDao _vlanDao;
|
@Inject protected VlanDao _vlanDao;
|
||||||
@ -69,25 +73,24 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||||
|
//This guru handles only non-system Guest network
|
||||||
|
if (dc.getNetworkType() == NetworkType.Advanced && offering.getTrafficType() == TrafficType.Guest && !offering.isSystemOnly()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
s_logger.trace("We only take care of Guest networks in zone of type " + NetworkType.Advanced);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||||
if (offering.getTrafficType() != TrafficType.Guest || offering.getGuestIpType() != GuestIpType.Virtual) {
|
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
|
||||||
|
if (!canHandle(offering, dc)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BroadcastDomainType broadcastType = null;
|
NetworkVO network = new NetworkVO(offering.getTrafficType(), GuestIpType.Virtual, Mode.Dhcp, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId(), State.Allocated);
|
||||||
Mode mode = null;
|
|
||||||
GuestIpType ipType = offering.getGuestIpType();
|
|
||||||
if (ipType == GuestIpType.Virtual) {
|
|
||||||
mode = Mode.Dhcp;
|
|
||||||
broadcastType = BroadcastDomainType.Vlan;
|
|
||||||
} else {
|
|
||||||
broadcastType = BroadcastDomainType.Native;
|
|
||||||
mode = Mode.Dhcp;
|
|
||||||
}
|
|
||||||
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
|
|
||||||
|
|
||||||
NetworkVO network = new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), mode, broadcastType, offering.getId(), plan.getDataCenterId());
|
|
||||||
if (userSpecified != null) {
|
if (userSpecified != null) {
|
||||||
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
|
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
|
||||||
(userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
|
(userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
|
||||||
@ -135,7 +138,9 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
|
assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
|
||||||
|
|
||||||
long dcId = dest.getDataCenter().getId();
|
long dcId = dest.getDataCenter().getId();
|
||||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getGuestType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), network.getDataCenterId());
|
|
||||||
|
|
||||||
|
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getGuestType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), network.getDataCenterId(), State.Allocated);
|
||||||
|
|
||||||
if (network.getBroadcastUri() == null) {
|
if (network.getBroadcastUri() == null) {
|
||||||
String vnet = _dcDao.allocateVnet(dcId, network.getAccountId(), context.getReservationId());
|
String vnet = _dcDao.allocateVnet(dcId, network.getAccountId(), context.getReservationId());
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkVO config = new NetworkVO(type, offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId());
|
NetworkVO config = new NetworkVO(type, null, Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId(), Network.State.Setup);
|
||||||
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
|
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
|
||||||
config.setDns1(dc.getDns1());
|
config.setDns1(dc.getDns1());
|
||||||
config.setDns2(dc.getDns2());
|
config.setDns2(dc.getDns2());
|
||||||
|
|||||||
@ -3,15 +3,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.network.guru;
|
package com.cloud.network.guru;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
import com.cloud.dc.DataCenter.NetworkType;
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.dc.DataCenterVO;
|
|
||||||
import com.cloud.dc.Vlan.VlanType;
|
import com.cloud.dc.Vlan.VlanType;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
@ -23,6 +20,7 @@ import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
|||||||
import com.cloud.network.Network;
|
import com.cloud.network.Network;
|
||||||
import com.cloud.network.NetworkManager;
|
import com.cloud.network.NetworkManager;
|
||||||
import com.cloud.network.NetworkVO;
|
import com.cloud.network.NetworkVO;
|
||||||
|
import com.cloud.network.Network.State;
|
||||||
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;
|
||||||
@ -31,7 +29,7 @@ import com.cloud.network.Networks.TrafficType;
|
|||||||
import com.cloud.network.addr.PublicIp;
|
import com.cloud.network.addr.PublicIp;
|
||||||
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.offering.NetworkOffering.GuestIpType;
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
import com.cloud.resource.Resource.ReservationStrategy;
|
import com.cloud.resource.Resource.ReservationStrategy;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.AdapterBase;
|
import com.cloud.utils.component.AdapterBase;
|
||||||
@ -50,19 +48,28 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
@Inject VlanDao _vlanDao;
|
@Inject VlanDao _vlanDao;
|
||||||
@Inject NetworkManager _networkMgr;
|
@Inject NetworkManager _networkMgr;
|
||||||
@Inject IPAddressDao _ipAddressDao;
|
@Inject IPAddressDao _ipAddressDao;
|
||||||
|
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||||
|
if (dc.getNetworkType() == NetworkType.Advanced && offering.getTrafficType() == TrafficType.Public && offering.isSystemOnly()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
s_logger.trace("We only take care of System only Public Virtual Network");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network network, Account owner) {
|
public Network design(NetworkOffering offering, DeploymentPlan plan, Network network, Account owner) {
|
||||||
if (offering.getTrafficType() != TrafficType.Public || (offering.getGuestIpType() != null && offering.getGuestIpType() != GuestIpType.Virtual)) {
|
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
|
||||||
s_logger.trace("We only take care of Public Virtual Network");
|
|
||||||
|
if (!canHandle(offering, dc)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offering.getTrafficType() == TrafficType.Public) {
|
if (offering.getTrafficType() == TrafficType.Public) {
|
||||||
NetworkVO ntwk = new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
|
NetworkVO ntwk = new NetworkVO(offering.getTrafficType(), null, Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId(), State.Setup);
|
||||||
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
|
|
||||||
ntwk.setDns1(dc.getDns1());
|
ntwk.setDns1(dc.getDns1());
|
||||||
ntwk.setDns2(dc.getDns2());
|
ntwk.setDns2(dc.getDns2());
|
||||||
return ntwk;
|
return ntwk;
|
||||||
@ -77,20 +84,13 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
|
|
||||||
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||||
if (nic.getIp4Address() == null) {
|
if (nic.getIp4Address() == null) {
|
||||||
PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), vm.getOwner(), dc.getNetworkType().equals(NetworkType.Basic) ? VlanType.DirectAttached : VlanType.VirtualNetwork, null);
|
PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.VirtualNetwork, null);
|
||||||
nic.setIp4Address(ip.getAddress().toString());
|
nic.setIp4Address(ip.getAddress().toString());
|
||||||
nic.setGateway(ip.getGateway());
|
nic.setGateway(ip.getGateway());
|
||||||
nic.setNetmask(ip.getNetmask());
|
nic.setNetmask(ip.getNetmask());
|
||||||
if(ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase("untagged")) {
|
|
||||||
nic.setIsolationUri(URI.create("vlan://untagged"));
|
|
||||||
nic.setBroadcastUri(URI.create("vlan://untagged"));
|
|
||||||
nic.setBroadcastType(BroadcastDomainType.Native);
|
|
||||||
} else if (ip.getVlanTag() != null){
|
|
||||||
nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
||||||
nic.setBroadcastUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
nic.setBroadcastUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
||||||
nic.setBroadcastType(BroadcastDomainType.Vlan);
|
nic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||||
}
|
|
||||||
|
|
||||||
nic.setFormat(AddressFormat.Ip4);
|
nic.setFormat(AddressFormat.Ip4);
|
||||||
nic.setReservationId(String.valueOf(ip.getVlanTag()));
|
nic.setReservationId(String.valueOf(ip.getVlanTag()));
|
||||||
nic.setMacAddress(ip.getMacAddress());
|
nic.setMacAddress(ip.getMacAddress());
|
||||||
@ -102,7 +102,10 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
@Override
|
@Override
|
||||||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException, ConcurrentOperationException {
|
InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||||
if (network.getTrafficType() != TrafficType.Public) {
|
|
||||||
|
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||||
|
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
|
||||||
|
if (!canHandle(offering, dc)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +113,6 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
nic = new NicProfile(ReservationStrategy.Create, null, null, null, null);
|
nic = new NicProfile(ReservationStrategy.Create, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
|
||||||
getIp(nic, dc, vm, network);
|
getIp(nic, dc, vm, network);
|
||||||
|
|
||||||
if (nic.getIp4Address() == null) {
|
if (nic.getIp4Address() == null) {
|
||||||
|
|||||||
@ -1330,17 +1330,16 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
|
|||||||
return _lbDao.search(sc, searchFilter);
|
return _lbDao.search(sc, searchFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
// public LoadBalancerVO findLoadBalancer(Long accountId, String name) {
|
public List<LoadBalancingRule> listByNetworkId(long networkId) {
|
||||||
// SearchCriteria<LoadBalancerVO> sc = _loadBalancerDao.createSearchCriteria();
|
List<LoadBalancerVO> lbs = _lbDao.listByNetworkId(networkId);
|
||||||
// sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
|
List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
|
||||||
// sc.addAnd("name", SearchCriteria.Op.EQ, name);
|
for (LoadBalancerVO lb : lbs) {
|
||||||
// List<LoadBalancerVO> loadBalancers = _loadBalancerDao.search(sc, null);
|
List<LbDestination> dstList = getExistingDestinations(lb.getId());
|
||||||
// if ((loadBalancers != null) && !loadBalancers.isEmpty()) {
|
LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList);
|
||||||
// return loadBalancers.get(0);
|
lbRules.add(loadBalancing);
|
||||||
// }
|
}
|
||||||
// return null;
|
return lbRules;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,8 +72,10 @@ import com.cloud.configuration.ConfigurationManager;
|
|||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.configuration.dao.ResourceLimitDao;
|
import com.cloud.configuration.dao.ResourceLimitDao;
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
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.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;
|
||||||
@ -1022,12 +1024,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
|
|
||||||
PublicIp sourceNatIp = _networkMgr.assignSourceNatIpAddress(owner, guestNetwork, _accountService.getSystemUser().getId());
|
PublicIp sourceNatIp = _networkMgr.assignSourceNatIpAddress(owner, guestNetwork, _accountService.getSystemUser().getId());
|
||||||
|
|
||||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork);
|
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).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.SystemPublicNetwork).get(0);
|
||||||
List<NetworkVO> publicConfigs = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
List<NetworkVO> publicConfigs = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
||||||
NicProfile defaultNic = new NicProfile();
|
NicProfile defaultNic = new NicProfile();
|
||||||
defaultNic.setDefaultNic(true);
|
defaultNic.setDefaultNic(true);
|
||||||
@ -1036,7 +1038,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
defaultNic.setNetmask(sourceNatIp.getNetmask());
|
defaultNic.setNetmask(sourceNatIp.getNetmask());
|
||||||
defaultNic.setTrafficType(TrafficType.Public);
|
defaultNic.setTrafficType(TrafficType.Public);
|
||||||
defaultNic.setMacAddress(sourceNatIp.getMacAddress());
|
defaultNic.setMacAddress(sourceNatIp.getMacAddress());
|
||||||
if (sourceNatIp.getVlanTag().equals("untagged")) {
|
if (sourceNatIp.getVlanTag().equals(Vlan.UNTAGGED)) {
|
||||||
defaultNic.setBroadcastType(BroadcastDomainType.Native);
|
defaultNic.setBroadcastType(BroadcastDomainType.Native);
|
||||||
} else {
|
} else {
|
||||||
defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
|
defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||||
@ -1053,9 +1055,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
gatewayNic.setMode(guestNetwork.getMode());
|
gatewayNic.setMode(guestNetwork.getMode());
|
||||||
|
|
||||||
String gatewayCidr = guestNetwork.getCidr();
|
String gatewayCidr = guestNetwork.getCidr();
|
||||||
String[] cidrPair = gatewayCidr.split("\\/");
|
gatewayNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
|
||||||
long guestCidrSize = Long.parseLong(cidrPair[1]);
|
|
||||||
gatewayNic.setNetmask(NetUtils.getCidrNetmask(guestCidrSize));
|
|
||||||
networks.add(new Pair<NetworkVO, NicProfile>((NetworkVO) guestNetwork, gatewayNic));
|
networks.add(new Pair<NetworkVO, NicProfile>((NetworkVO) guestNetwork, gatewayNic));
|
||||||
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
|
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
|
||||||
|
|
||||||
@ -1096,8 +1096,17 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
+ guestNetwork;
|
+ guestNetwork;
|
||||||
|
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(dcId);
|
DataCenterDeployment plan = new DataCenterDeployment(dcId);
|
||||||
|
DataCenter dc = _dcDao.findById(dcId);
|
||||||
|
DomainRouterVO router = null;
|
||||||
|
Long podId = dest.getPod().getId();
|
||||||
|
|
||||||
|
//In Basic zone and Guest network we have to start domR per pod, not per network
|
||||||
|
if (dc.getNetworkType() == NetworkType.Basic && guestNetwork.getTrafficType() == TrafficType.Guest) {
|
||||||
|
router = _routerDao.findByNetworkConfigurationAndPod(guestNetwork.getId(), podId);
|
||||||
|
} else {
|
||||||
|
router = _routerDao.findByNetworkConfiguration(guestNetwork.getId());
|
||||||
|
}
|
||||||
|
|
||||||
DomainRouterVO router = _routerDao.findByNetworkConfiguration(guestNetwork.getId());
|
|
||||||
if (router == null) {
|
if (router == null) {
|
||||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, owner.getId(), EventTypes.EVENT_ROUTER_CREATE, "Starting to create router for accountId : " +owner.getAccountId());
|
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, owner.getId(), EventTypes.EVENT_ROUTER_CREATE, "Starting to create router for accountId : " +owner.getAccountId());
|
||||||
long id = _routerDao.getNextInSequence(Long.class, "id");
|
long id = _routerDao.getNextInSequence(Long.class, "id");
|
||||||
@ -1105,7 +1114,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
s_logger.debug("Creating the router " + id);
|
s_logger.debug("Creating the router " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork);
|
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||||
|
|
||||||
@ -1147,11 +1156,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
String type = null;
|
String type = null;
|
||||||
String dhcpRange = null;
|
String dhcpRange = null;
|
||||||
|
|
||||||
// get first ip address from network cidr
|
DataCenter dc = dest.getDataCenter();
|
||||||
|
|
||||||
|
if (dc.getNetworkType() == NetworkType.Advanced) {
|
||||||
String cidr = network.getCidr();
|
String cidr = network.getCidr();
|
||||||
String[] splitResult = cidr.split("\\/");
|
dhcpRange = NetUtils.getDhcpRange(cidr);
|
||||||
long size = Long.valueOf(splitResult[1]);
|
}
|
||||||
dhcpRange = NetUtils.getIpRangeStartIpFromCidr(splitResult[0], size);
|
|
||||||
|
|
||||||
String domain = network.getNetworkDomain();
|
String domain = network.getNetworkDomain();
|
||||||
if (router.getRole() == Role.DHCP_USERDATA) {
|
if (router.getRole() == Role.DHCP_USERDATA) {
|
||||||
@ -1176,6 +1186,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
if (nic.getDns2() != null) {
|
if (nic.getDns2() != null) {
|
||||||
buf.append(" dns2=").append(nic.getDns2());
|
buf.append(" dns2=").append(nic.getDns2());
|
||||||
}
|
}
|
||||||
|
if (dc.getNetworkType() == NetworkType.Basic) {
|
||||||
|
long cidrSize = NetUtils.getCidrSize(nic.getNetmask());
|
||||||
|
String cidr = NetUtils.getCidrSubNet(nic.getGateway(), cidrSize);
|
||||||
|
if (cidr != null) {
|
||||||
|
dhcpRange = NetUtils.getIpRangeStartIpFromCidr(cidr, cidrSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (nic.getTrafficType() == TrafficType.Management) {
|
if (nic.getTrafficType() == TrafficType.Management) {
|
||||||
buf.append(" localgw=").append(dest.getPod().getGateway());
|
buf.append(" localgw=").append(dest.getPod().getGateway());
|
||||||
|
|||||||
@ -28,7 +28,6 @@ import javax.persistence.GenerationType;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import com.cloud.network.Networks.Availability;
|
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
@ -37,10 +36,6 @@ import com.cloud.utils.db.GenericDao;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name="network_offerings")
|
@Table(name="network_offerings")
|
||||||
public class NetworkOfferingVO implements NetworkOffering {
|
public class NetworkOfferingVO implements NetworkOffering {
|
||||||
public final static String SystemVmPublicNetwork = "System-Public-Network";
|
|
||||||
public final static String SystemVmControlNetwork = "System-Control-Network";
|
|
||||||
public final static String SystemVmManagementNetwork = "System-Management-Network";
|
|
||||||
public final static String SystemVmStorageNetwork = "System-Storage-Network";
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
@ -62,10 +57,6 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||||||
@Column(name="concurrent_connections")
|
@Column(name="concurrent_connections")
|
||||||
Integer concurrentConnections;
|
Integer concurrentConnections;
|
||||||
|
|
||||||
@Column(name="type")
|
|
||||||
@Enumerated(value=EnumType.STRING)
|
|
||||||
GuestIpType guestIpType;
|
|
||||||
|
|
||||||
@Column(name="traffic_type")
|
@Column(name="traffic_type")
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
TrafficType trafficType;
|
TrafficType trafficType;
|
||||||
@ -121,11 +112,6 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||||||
return displayText;
|
return displayText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public GuestIpType getGuestIpType() {
|
|
||||||
return guestIpType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -200,10 +186,6 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||||||
this.concurrentConnections = concurrentConnections;
|
this.concurrentConnections = concurrentConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGuestIpType(GuestIpType guestIpType) {
|
|
||||||
this.guestIpType = guestIpType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTrafficType(TrafficType trafficType) {
|
public void setTrafficType(TrafficType trafficType) {
|
||||||
this.trafficType = trafficType;
|
this.trafficType = trafficType;
|
||||||
}
|
}
|
||||||
@ -311,10 +293,9 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||||||
this.dhcpService = dhcpService;
|
this.dhcpService = dhcpService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections, boolean isDefault, Availability availability, boolean lbService, boolean gatewayService, boolean dhcpService, boolean firewallService, boolean dnsService, boolean userDataService, boolean vpnService) {
|
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections, boolean isDefault, Availability availability, boolean lbService, boolean gatewayService, boolean dhcpService, boolean firewallService, boolean dnsService, boolean userDataService, boolean vpnService) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.displayText = displayText;
|
this.displayText = displayText;
|
||||||
this.guestIpType = type;
|
|
||||||
this.rateMbps = rateMbps;
|
this.rateMbps = rateMbps;
|
||||||
this.multicastRateMbps = multicastRateMbps;
|
this.multicastRateMbps = multicastRateMbps;
|
||||||
this.concurrentConnections = concurrentConnections;
|
this.concurrentConnections = concurrentConnections;
|
||||||
@ -333,7 +314,7 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, false, Availability.Required, false, false, false, false, false, false, false);
|
this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, false, false, offering.getRateMbps(), offering.getMulticastRateMbps(), null, false, Availability.Required, false, false, false, false, false, false, false);
|
||||||
this.serviceOfferingId = offering.getId();
|
this.serviceOfferingId = offering.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,12 +326,12 @@ 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, false, Availability.Required, false, false, false, false, false, false, false);
|
this(name, "System Offering for " + name, trafficType, true, false, null, null, null, false, Availability.Required, false, false, false, false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder buf = new StringBuilder("[Network Offering [");
|
StringBuilder buf = new StringBuilder("[Network Offering [");
|
||||||
return buf.append(id).append("-").append(trafficType).append("-").append(name).append("-").append(guestIpType).append("]").toString();
|
return buf.append(id).append("-").append(trafficType).append("-").append(name).append("]").toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,9 +5,7 @@ package com.cloud.offerings.dao;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,11 +31,8 @@ public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long>
|
|||||||
*/
|
*/
|
||||||
NetworkOfferingVO persistDefaultNetworkOffering(NetworkOfferingVO offering);
|
NetworkOfferingVO persistDefaultNetworkOffering(NetworkOfferingVO offering);
|
||||||
|
|
||||||
NetworkOfferingVO findByServiceOffering(ServiceOfferingVO offering);
|
|
||||||
|
|
||||||
List<NetworkOfferingVO> listNonSystemNetworkOfferings();
|
List<NetworkOfferingVO> listNonSystemNetworkOfferings();
|
||||||
|
|
||||||
List<NetworkOfferingVO> listSystemNetworkOfferings();
|
List<NetworkOfferingVO> listSystemNetworkOfferings();
|
||||||
|
|
||||||
List<NetworkOfferingVO> findByType(GuestIpType type);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,14 +11,11 @@ import javax.persistence.EntityExistsException;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
|
|
||||||
@Local(value=NetworkOfferingDao.class) @DB(txn=false)
|
@Local(value=NetworkOfferingDao.class) @DB(txn=false)
|
||||||
public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Long> implements NetworkOfferingDao {
|
public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Long> implements NetworkOfferingDao {
|
||||||
@ -26,9 +23,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||||||
private final static Logger s_logger = Logger.getLogger(NetworkOfferingDaoImpl.class);
|
private final static Logger s_logger = Logger.getLogger(NetworkOfferingDaoImpl.class);
|
||||||
|
|
||||||
final SearchBuilder<NetworkOfferingVO> NameSearch;
|
final SearchBuilder<NetworkOfferingVO> NameSearch;
|
||||||
final SearchBuilder<NetworkOfferingVO> ServiceOfferingSearch;
|
|
||||||
final SearchBuilder<NetworkOfferingVO> SystemOfferingSearch;
|
final SearchBuilder<NetworkOfferingVO> SystemOfferingSearch;
|
||||||
final SearchBuilder<NetworkOfferingVO> TypeSearch;
|
|
||||||
|
|
||||||
protected NetworkOfferingDaoImpl() {
|
protected NetworkOfferingDaoImpl() {
|
||||||
super();
|
super();
|
||||||
@ -37,14 +32,6 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||||||
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||||
NameSearch.done();
|
NameSearch.done();
|
||||||
|
|
||||||
TypeSearch = createSearchBuilder();
|
|
||||||
TypeSearch.and("guestIpType", TypeSearch.entity().getGuestIpType(), SearchCriteria.Op.EQ);
|
|
||||||
TypeSearch.done();
|
|
||||||
|
|
||||||
ServiceOfferingSearch = createSearchBuilder();
|
|
||||||
ServiceOfferingSearch.and("serviceoffering", ServiceOfferingSearch.entity().getGuestIpType(), SearchCriteria.Op.EQ);
|
|
||||||
ServiceOfferingSearch.done();
|
|
||||||
|
|
||||||
SystemOfferingSearch = createSearchBuilder();
|
SystemOfferingSearch = createSearchBuilder();
|
||||||
SystemOfferingSearch.and("system", SystemOfferingSearch.entity().isSystemOnly(), SearchCriteria.Op.EQ);
|
SystemOfferingSearch.and("system", SystemOfferingSearch.entity().isSystemOnly(), SearchCriteria.Op.EQ);
|
||||||
SystemOfferingSearch.done();
|
SystemOfferingSearch.done();
|
||||||
@ -76,30 +63,6 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public NetworkOfferingVO findByServiceOffering(ServiceOfferingVO offering) {
|
|
||||||
SearchCriteria<NetworkOfferingVO> sc = ServiceOfferingSearch.create();
|
|
||||||
sc.setParameters("serviceoffering", offering.getGuestIpType());
|
|
||||||
|
|
||||||
NetworkOfferingVO vo = findOneBy(sc);
|
|
||||||
if (vo != null) {
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
vo = new NetworkOfferingVO(offering);
|
|
||||||
try {
|
|
||||||
return persist(vo);
|
|
||||||
} catch (Exception e) {
|
|
||||||
s_logger.debug("Got a persistence exception. Assuming it's because service offering id is duplicate");
|
|
||||||
vo = findOneBy(sc);
|
|
||||||
if (vo != null) {
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new CloudRuntimeException("Unable to persist network offering", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NetworkOfferingVO> listNonSystemNetworkOfferings() {
|
public List<NetworkOfferingVO> listNonSystemNetworkOfferings() {
|
||||||
SearchCriteria<NetworkOfferingVO> sc = SystemOfferingSearch.create();
|
SearchCriteria<NetworkOfferingVO> sc = SystemOfferingSearch.create();
|
||||||
@ -107,13 +70,6 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||||||
return this.listIncludingRemovedBy(sc, null);
|
return this.listIncludingRemovedBy(sc, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<NetworkOfferingVO> findByType(GuestIpType type) {
|
|
||||||
SearchCriteria<NetworkOfferingVO> sc = TypeSearch.create();
|
|
||||||
sc.setParameters("guestIpType", type);
|
|
||||||
return listBy(sc);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NetworkOfferingVO> listSystemNetworkOfferings() {
|
public List<NetworkOfferingVO> listSystemNetworkOfferings() {
|
||||||
SearchCriteria<NetworkOfferingVO> sc = SystemOfferingSearch.create();
|
SearchCriteria<NetworkOfferingVO> sc = SystemOfferingSearch.create();
|
||||||
|
|||||||
@ -47,7 +47,6 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
|||||||
import com.cloud.dc.DataCenter.NetworkType;
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
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.VlanType;
|
|
||||||
import com.cloud.dc.VlanVO;
|
import com.cloud.dc.VlanVO;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
import com.cloud.dc.dao.HostPodDao;
|
||||||
@ -59,13 +58,12 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.network.Network.State;
|
import com.cloud.network.Network.State;
|
||||||
import com.cloud.network.NetworkVO;
|
import com.cloud.network.NetworkVO;
|
||||||
import com.cloud.network.Networks.Availability;
|
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
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.dao.NetworkDao;
|
import com.cloud.network.dao.NetworkDao;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
import com.cloud.offering.NetworkOffering.Availability;
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
@ -694,20 +692,21 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||||||
Integer rateMbps = getIntegerConfigValue(Config.NetworkThrottlingRate.key(), null);
|
Integer rateMbps = getIntegerConfigValue(Config.NetworkThrottlingRate.key(), null);
|
||||||
Integer multicastRateMbps = getIntegerConfigValue(Config.MulticastThrottlingRate.key(), null);
|
Integer multicastRateMbps = getIntegerConfigValue(Config.MulticastThrottlingRate.key(), null);
|
||||||
|
|
||||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmPublicNetwork, TrafficType.Public, null);
|
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork, TrafficType.Public, null);
|
||||||
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
||||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
|
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemManagementNetwork, TrafficType.Management, null);
|
||||||
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
||||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmControlNetwork, TrafficType.Control, null);
|
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemControlNetwork, TrafficType.Control, null);
|
||||||
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
||||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmStorageNetwork, TrafficType.Storage, null);
|
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemStorageNetwork, TrafficType.Storage, null);
|
||||||
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
||||||
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtual, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SysteGuestNetwork, TrafficType.Guest, null);
|
||||||
|
guestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(guestNetworkOffering);
|
||||||
|
|
||||||
|
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
||||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering);
|
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering);
|
||||||
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Public, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Public, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
||||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
|
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
|
||||||
NetworkOfferingVO defaultGuestDirectPodBasedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectPodBasedNetworkOffering, "DirectPodBased", TrafficType.Public, GuestIpType.DirectPodBased, true, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
|
||||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectPodBasedNetworkOffering);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer getIntegerConfigValue(String configKey, Integer dflt) {
|
private Integer getIntegerConfigValue(String configKey, Integer dflt) {
|
||||||
@ -727,6 +726,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||||||
guruNames.put(TrafficType.Management, "PodBasedNetworkGuru-com.cloud.network.guru.PodBasedNetworkGuru");
|
guruNames.put(TrafficType.Management, "PodBasedNetworkGuru-com.cloud.network.guru.PodBasedNetworkGuru");
|
||||||
guruNames.put(TrafficType.Control, "ControlNetworkGuru-com.cloud.network.guru.ControlNetworkGuru");
|
guruNames.put(TrafficType.Control, "ControlNetworkGuru-com.cloud.network.guru.ControlNetworkGuru");
|
||||||
guruNames.put(TrafficType.Storage, "PodBasedNetworkGuru-com.cloud.network.guru.PodBasedNetworkGuru");
|
guruNames.put(TrafficType.Storage, "PodBasedNetworkGuru-com.cloud.network.guru.PodBasedNetworkGuru");
|
||||||
|
guruNames.put(TrafficType.Guest, "DirectPodBasedNetworkGuru-com.cloud.network.guru.DirectPodBasedNetworkGuru");
|
||||||
|
|
||||||
|
|
||||||
for (DataCenterVO zone : zones) {
|
for (DataCenterVO zone : zones) {
|
||||||
long zoneId = zone.getId();
|
long zoneId = zone.getId();
|
||||||
@ -747,24 +748,27 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||||||
|
|
||||||
BroadcastDomainType broadcastDomainType = null;
|
BroadcastDomainType broadcastDomainType = null;
|
||||||
TrafficType trafficType= offering.getTrafficType();
|
TrafficType trafficType= offering.getTrafficType();
|
||||||
GuestIpType guestIpType = offering.getGuestIpType();
|
|
||||||
|
|
||||||
if (trafficType == TrafficType.Management || trafficType == TrafficType.Storage) {
|
if (trafficType == TrafficType.Management || trafficType == TrafficType.Storage) {
|
||||||
broadcastDomainType = BroadcastDomainType.Native;
|
broadcastDomainType = BroadcastDomainType.Native;
|
||||||
} else if (trafficType == TrafficType.Control) {
|
} else if (trafficType == TrafficType.Control) {
|
||||||
broadcastDomainType = BroadcastDomainType.LinkLocal;
|
broadcastDomainType = BroadcastDomainType.LinkLocal;
|
||||||
} else if (offering.getTrafficType() == TrafficType.Public) {
|
} else if (offering.getTrafficType() == TrafficType.Public) {
|
||||||
if (zone.getNetworkType() == NetworkType.Basic && offering.getGuestIpType() == GuestIpType.DirectPodBased) {
|
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||||
broadcastDomainType = BroadcastDomainType.Native;
|
|
||||||
} else if (zone.getNetworkType() == NetworkType.Advanced && offering.getGuestIpType() == null) {
|
|
||||||
broadcastDomainType = BroadcastDomainType.Vlan;
|
broadcastDomainType = BroadcastDomainType.Vlan;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else if (offering.getTrafficType() == TrafficType.Guest) {
|
||||||
|
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||||
|
broadcastDomainType = BroadcastDomainType.Native;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (broadcastDomainType != null) {
|
if (broadcastDomainType != null) {
|
||||||
NetworkVO network = new NetworkVO(id, trafficType, guestIpType, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, true);
|
NetworkVO network = new NetworkVO(id, trafficType, null, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, true);
|
||||||
network.setGuruName(guruNames.get(network.getTrafficType()));
|
network.setGuruName(guruNames.get(network.getTrafficType()));
|
||||||
network.setDns1(zone.getDns1());
|
network.setDns1(zone.getDns1());
|
||||||
network.setDns2(zone.getDns2());
|
network.setDns2(zone.getDns2());
|
||||||
@ -781,33 +785,35 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||||||
private void updateVlanWithNetworkId(VlanVO vlan) {
|
private void updateVlanWithNetworkId(VlanVO vlan) {
|
||||||
long zoneId = vlan.getDataCenterId();
|
long zoneId = vlan.getDataCenterId();
|
||||||
long networkId = 0L;
|
long networkId = 0L;
|
||||||
if (vlan.getVlanType() == VlanType.VirtualNetwork) {
|
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||||
networkId = getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(zoneId, TrafficType.Public, null);
|
|
||||||
} else if (vlan.getVlanType() == VlanType.DirectAttached) {
|
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||||
networkId = getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(zoneId, TrafficType.Public, GuestIpType.DirectPodBased);
|
networkId = getSystemNetworkIdByZoneAndTrafficType(zoneId, TrafficType.Public);
|
||||||
|
} else {
|
||||||
|
networkId = getSystemNetworkIdByZoneAndTrafficType(zoneId, TrafficType.Guest);
|
||||||
}
|
}
|
||||||
|
|
||||||
vlan.setNetworkId(networkId);
|
vlan.setNetworkId(networkId);
|
||||||
_vlanDao.update(vlan.getId(), vlan);
|
_vlanDao.update(vlan.getId(), vlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getSystemNetworkIdByZoneAndTrafficTypeAndGuestType(long zoneId, TrafficType trafficType, GuestIpType guestType) {
|
private long getSystemNetworkIdByZoneAndTrafficType(long zoneId, TrafficType trafficType) {
|
||||||
//find system public network offering
|
//find system public network offering
|
||||||
Long networkOfferingId = null;
|
Long networkOfferingId = null;
|
||||||
List<NetworkOfferingVO> offerings = _networkOfferingDao.listSystemNetworkOfferings();
|
List<NetworkOfferingVO> offerings = _networkOfferingDao.listSystemNetworkOfferings();
|
||||||
for (NetworkOfferingVO offering: offerings) {
|
for (NetworkOfferingVO offering: offerings) {
|
||||||
if (offering.getTrafficType() == trafficType && offering.getGuestIpType() == guestType) {
|
if (offering.getTrafficType() == trafficType) {
|
||||||
networkOfferingId = offering.getId();
|
networkOfferingId = offering.getId();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (networkOfferingId == null) {
|
if (networkOfferingId == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find system network offering with traffic type " + trafficType + " and guestIpType " + guestType);
|
throw new InvalidParameterValueException("Unable to find system network offering with traffic type " + trafficType);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NetworkVO> networks = _networkDao.listBy(Account.ACCOUNT_ID_SYSTEM, networkOfferingId, zoneId);
|
List<NetworkVO> networks = _networkDao.listBy(Account.ACCOUNT_ID_SYSTEM, networkOfferingId, zoneId);
|
||||||
if (networks == null) {
|
if (networks == null || networks.isEmpty()) {
|
||||||
throw new InvalidParameterValueException("Unable to find network with traffic type " + trafficType + " in zone " + zoneId);
|
throw new InvalidParameterValueException("Unable to find network with traffic type " + trafficType + " in zone " + zoneId);
|
||||||
}
|
}
|
||||||
return networks.get(0).getId();
|
return networks.get(0).getId();
|
||||||
|
|||||||
@ -56,6 +56,8 @@ import com.cloud.async.BaseAsyncJobExecutor;
|
|||||||
import com.cloud.cluster.ClusterManager;
|
import com.cloud.cluster.ClusterManager;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
import com.cloud.dc.DataCenter;
|
||||||
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
@ -440,9 +442,14 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||||||
Account systemAcct = _accountMgr.getSystemAccount();
|
Account systemAcct = _accountMgr.getSystemAccount();
|
||||||
|
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
||||||
|
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
|
||||||
|
|
||||||
List<NetworkOfferingVO> defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork);
|
List<NetworkOfferingVO> defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork);
|
||||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork);
|
if (dc.getNetworkType() == NetworkType.Basic) {
|
||||||
|
defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SysteGuestNetwork);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork);
|
||||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
||||||
NicProfile defaultNic = new NicProfile();
|
NicProfile defaultNic = new NicProfile();
|
||||||
defaultNic.setDefaultNic(true);
|
defaultNic.setDefaultNic(true);
|
||||||
@ -1504,10 +1511,11 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||||||
cmds.addCommand("checkSsh", check);
|
cmds.addCommand("checkSsh", check);
|
||||||
|
|
||||||
SecondaryStorageVmVO secVm = profile.getVirtualMachine();
|
SecondaryStorageVmVO secVm = profile.getVirtualMachine();
|
||||||
|
DataCenter dc = dest.getDataCenter();
|
||||||
List<NicVO> nics = _nicDao.listBy(secVm.getId());
|
List<NicVO> nics = _nicDao.listBy(secVm.getId());
|
||||||
for (NicVO nic : nics) {
|
for (NicVO nic : nics) {
|
||||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||||
if (network.getTrafficType() == TrafficType.Public) {
|
if ((network.getTrafficType() == TrafficType.Public && dc.getNetworkType() == NetworkType.Advanced) || (network.getTrafficType() == TrafficType.Guest && dc.getNetworkType() == NetworkType.Basic)) {
|
||||||
secVm.setPublicIpAddress(nic.getIp4Address());
|
secVm.setPublicIpAddress(nic.getIp4Address());
|
||||||
secVm.setPublicNetmask(nic.getNetmask());
|
secVm.setPublicNetmask(nic.getNetmask());
|
||||||
secVm.setPublicMacAddress(nic.getMacAddress());
|
secVm.setPublicMacAddress(nic.getMacAddress());
|
||||||
|
|||||||
@ -98,8 +98,6 @@ public interface AccountManager extends AccountService {
|
|||||||
|
|
||||||
List<ResourceLimitVO> searchForLimits(Criteria c);
|
List<ResourceLimitVO> searchForLimits(Criteria c);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables an account by accountId
|
* Disables an account by accountId
|
||||||
* @param accountId
|
* @param accountId
|
||||||
|
|||||||
@ -74,7 +74,6 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.network.IPAddressVO;
|
import com.cloud.network.IPAddressVO;
|
||||||
import com.cloud.network.NetworkManager;
|
import com.cloud.network.NetworkManager;
|
||||||
import com.cloud.network.NetworkVO;
|
import com.cloud.network.NetworkVO;
|
||||||
import com.cloud.network.VirtualNetworkApplianceService;
|
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
import com.cloud.network.dao.NetworkDao;
|
import com.cloud.network.dao.NetworkDao;
|
||||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||||
@ -674,7 +673,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||||||
return _systemAccount;
|
return _systemAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAdmin(short accountType) {
|
@Override
|
||||||
|
public boolean isAdmin(short accountType) {
|
||||||
return ((accountType == Account.ACCOUNT_TYPE_ADMIN) ||
|
return ((accountType == Account.ACCOUNT_TYPE_ADMIN) ||
|
||||||
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) ||
|
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) ||
|
||||||
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
|
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
|
||||||
@ -1576,4 +1576,49 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Account finalizeOwner(Account caller, String accountName, Long domainId) {
|
||||||
|
if (isAdmin(caller.getType())) {
|
||||||
|
if (domainId != null) {
|
||||||
|
DomainVO domain = _domainDao.findById(domainId);
|
||||||
|
if (domain == null) {
|
||||||
|
throw new InvalidParameterValueException("Unable to find the domain by id=" + domainId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accountName != null) {
|
||||||
|
Account owner = _accountDao.findActiveAccount(accountName, domainId);
|
||||||
|
if (owner == null) {
|
||||||
|
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
||||||
|
}
|
||||||
|
checkAccess(caller, domain);
|
||||||
|
return owner;
|
||||||
|
} else {
|
||||||
|
throw new InvalidParameterValueException("Account have to be specified along with domainId");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return caller;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//regular user can't create resources for other people
|
||||||
|
return caller;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Account getActiveAccount(String accountName, Long domainId) {
|
||||||
|
if (accountName == null || domainId == null) {
|
||||||
|
throw new InvalidParameterValueException("Both accountName and domainId are required for finding active account in the system");
|
||||||
|
} else {
|
||||||
|
return _accountDao.findActiveAccount(accountName, domainId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Account getAccount(Long accountId) {
|
||||||
|
if (accountId == null) {
|
||||||
|
throw new InvalidParameterValueException("AccountId is required by account search");
|
||||||
|
} else {
|
||||||
|
return _accountDao.findById(accountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2239,9 +2239,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
s_logger.debug("Allocating in the DB for vm");
|
s_logger.debug("Allocating in the DB for vm");
|
||||||
|
|
||||||
if (dc.getNetworkType() == NetworkType.Basic && networkList == null) {
|
if (dc.getNetworkType() == NetworkType.Basic && networkList == null) {
|
||||||
Network defaultNetwork = _networkMgr.getBasicZoneDefaultPublicNetwork(dc.getId());
|
Network defaultNetwork = _networkMgr.getSystemNetworkByZoneAndTrafficType(dc.getId(), TrafficType.Guest);
|
||||||
if (defaultNetwork == null) {
|
if (defaultNetwork == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find a default directPodBased network to start a vm");
|
throw new InvalidParameterValueException("Unable to find a default Direct network to start a vm");
|
||||||
} else {
|
} else {
|
||||||
networkList = new ArrayList<Long>();
|
networkList = new ArrayList<Long>();
|
||||||
networkList.add(defaultNetwork.getId());
|
networkList.add(defaultNetwork.getId());
|
||||||
|
|||||||
@ -122,4 +122,6 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long>, State
|
|||||||
DomainRouterVO findByNetworkConfiguration(long networkConfigurationId);
|
DomainRouterVO findByNetworkConfiguration(long networkConfigurationId);
|
||||||
|
|
||||||
DomainRouterVO findByNetworkConfigurationIncludingRemoved(long networkConfigurationId);
|
DomainRouterVO findByNetworkConfigurationIncludingRemoved(long networkConfigurationId);
|
||||||
|
|
||||||
|
DomainRouterVO findByNetworkConfigurationAndPod(long networkConfigurationId, long podId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,6 +126,8 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||||||
|
|
||||||
NetworkConfigSearch = createSearchBuilder();
|
NetworkConfigSearch = createSearchBuilder();
|
||||||
NetworkConfigSearch.and("network", NetworkConfigSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
NetworkConfigSearch.and("network", NetworkConfigSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||||
|
NetworkConfigSearch.and("podId", NetworkConfigSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||||
|
NetworkConfigSearch.done();
|
||||||
|
|
||||||
_updateTimeAttr = _allAttributes.get("updateTime");
|
_updateTimeAttr = _allAttributes.get("updateTime");
|
||||||
assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";
|
assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";
|
||||||
@ -366,4 +368,11 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||||||
sc.setParameters("state", State.Stopped);
|
sc.setParameters("state", State.Stopped);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public DomainRouterVO findByNetworkConfigurationAndPod(long networkConfigurationId, long podId) {
|
||||||
|
SearchCriteria<DomainRouterVO> sc = NetworkConfigSearch.create();
|
||||||
|
sc.setParameters("network", networkConfigurationId);
|
||||||
|
sc.setParameters("podId", podId);
|
||||||
|
return findOneBy(sc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -200,7 +200,6 @@ CREATE TABLE `cloud`.`nics` (
|
|||||||
CREATE TABLE `cloud`.`network_offerings` (
|
CREATE TABLE `cloud`.`network_offerings` (
|
||||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||||
`name` varchar(64) NOT NULL unique COMMENT 'network offering',
|
`name` varchar(64) NOT NULL unique COMMENT 'network offering',
|
||||||
`type` varchar(32) COMMENT 'type of network',
|
|
||||||
`display_text` varchar(255) NOT NULL COMMENT 'text to display to users',
|
`display_text` varchar(255) NOT NULL COMMENT 'text to display to users',
|
||||||
`nw_rate` smallint unsigned COMMENT 'network rate throttle mbits/s',
|
`nw_rate` smallint unsigned COMMENT 'network rate throttle mbits/s',
|
||||||
`mc_rate` smallint unsigned COMMENT 'mcast rate throttle mbits/s',
|
`mc_rate` smallint unsigned COMMENT 'mcast rate throttle mbits/s',
|
||||||
|
|||||||
@ -691,6 +691,12 @@ public class NetUtils {
|
|||||||
return long2Ip(numericNetmask);
|
return long2Ip(numericNetmask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getCidrNetmask(String cidr) {
|
||||||
|
String[] cidrPair = cidr.split("\\/");
|
||||||
|
long guestCidrSize = Long.parseLong(cidrPair[1]);
|
||||||
|
return getCidrNetmask(guestCidrSize);
|
||||||
|
}
|
||||||
|
|
||||||
public static String cidr2Netmask(String cidr) {
|
public static String cidr2Netmask(String cidr) {
|
||||||
String[] tokens = cidr.split("\\/");
|
String[] tokens = cidr.split("\\/");
|
||||||
return getCidrNetmask(Integer.parseInt(tokens[1]));
|
return getCidrNetmask(Integer.parseInt(tokens[1]));
|
||||||
@ -880,5 +886,11 @@ public class NetUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getDhcpRange(String cidr) {
|
||||||
|
String[] splitResult = cidr.split("\\/");
|
||||||
|
long size = Long.valueOf(splitResult[1]);
|
||||||
|
return NetUtils.getIpRangeStartIpFromCidr(splitResult[0], size);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user