mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Fixed format style in a bunch of files (replaced tabs with spaces as a part of it)
This commit is contained in:
parent
1f0ea28cc4
commit
1490e45a1c
@ -1,4 +1,5 @@
|
||||
/**
|
||||
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
@ -25,7 +26,6 @@ import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.api.response.SecurityGroupResponse;
|
||||
import com.cloud.network.security.SecurityGroup;
|
||||
import com.cloud.user.Account;
|
||||
@ -58,7 +58,6 @@ public class CreateSecurityGroupCmd extends BaseCmd {
|
||||
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.LONG, description = "Deploy vm for the project")
|
||||
private Long projectId;
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
@ -83,7 +82,6 @@ public class CreateSecurityGroupCmd extends BaseCmd {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
@ -109,7 +107,8 @@ public class CreateSecurityGroupCmd extends BaseCmd {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
|
||||
// tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -68,7 +68,8 @@ public interface ConfigurationService {
|
||||
* Create a service offering through the API
|
||||
*
|
||||
* @param cmd
|
||||
* the command object that specifies the name, number of cpu cores, amount of RAM, etc. for the service offering
|
||||
* the command object that specifies the name, number of cpu cores, amount of RAM, etc. for the service
|
||||
* offering
|
||||
* @return the newly created service offering if successful, null otherwise
|
||||
*/
|
||||
ServiceOffering createServiceOffering(CreateServiceOfferingCmd cmd);
|
||||
@ -130,13 +131,21 @@ public interface ConfigurationService {
|
||||
|
||||
/**
|
||||
* Creates a new pod based on the parameters specified in the command object
|
||||
* @param zoneId TODO
|
||||
* @param name TODO
|
||||
* @param startIp TODO
|
||||
* @param endIp TODO
|
||||
* @param gateway TODO
|
||||
* @param netmask TODO
|
||||
* @param allocationState TODO
|
||||
*
|
||||
* @param zoneId
|
||||
* TODO
|
||||
* @param name
|
||||
* TODO
|
||||
* @param startIp
|
||||
* TODO
|
||||
* @param endIp
|
||||
* TODO
|
||||
* @param gateway
|
||||
* TODO
|
||||
* @param netmask
|
||||
* TODO
|
||||
* @param allocationState
|
||||
* TODO
|
||||
* @return the new pod if successful, null otherwise
|
||||
* @throws
|
||||
* @throws
|
||||
@ -188,12 +197,14 @@ public interface ConfigurationService {
|
||||
boolean deleteZone(DeleteZoneCmd cmd);
|
||||
|
||||
/**
|
||||
* Adds a VLAN to the database, along with an IP address range. Can add three types of VLANs: (1) zone-wide VLANs on the
|
||||
* Adds a VLAN to the database, along with an IP address range. Can add three types of VLANs: (1) zone-wide VLANs on
|
||||
* the
|
||||
* virtual public network (2) pod-wide direct attached VLANs (3) account-specific direct attached VLANs
|
||||
*
|
||||
* @param userId
|
||||
* @param vlanType
|
||||
* - either "DomR" (VLAN for a virtual public network) or "DirectAttached" (VLAN for IPs that will be directly
|
||||
* - either "DomR" (VLAN for a virtual public network) or "DirectAttached" (VLAN for IPs that will be
|
||||
* directly
|
||||
* attached to UserVMs)
|
||||
* @param zoneId
|
||||
* @param accountId
|
||||
|
||||
@ -132,4 +132,5 @@ public interface NetworkService {
|
||||
Network getExclusiveGuestNetwork(long zoneId);
|
||||
|
||||
List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd);
|
||||
|
||||
}
|
||||
|
||||
@ -10,11 +10,14 @@ import com.cloud.user.Account;
|
||||
|
||||
public interface FirewallService {
|
||||
FirewallRule createFirewallRule(FirewallRule rule) throws NetworkRuleConflictException;
|
||||
|
||||
List<? extends FirewallRule> listFirewallRules(ListFirewallRulesCmd cmd);
|
||||
|
||||
/**
|
||||
* Revokes a firewall rule
|
||||
* @param ruleId the id of the rule to revoke.
|
||||
*
|
||||
* @param ruleId
|
||||
* the id of the rule to revoke.
|
||||
* @return
|
||||
*/
|
||||
boolean revokeFirewallRule(long ruleId, boolean apply);
|
||||
@ -24,4 +27,5 @@ public interface FirewallService {
|
||||
FirewallRule getFirewallRule(long ruleId);
|
||||
|
||||
boolean revokeRelatedFirewallRule(long ruleId, boolean apply);
|
||||
|
||||
}
|
||||
|
||||
@ -18,28 +18,28 @@
|
||||
package com.cloud.network.lb;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.commands.CreateLBStickinessPolicyCmd;
|
||||
import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.ListLBStickinessPoliciesCmd;
|
||||
|
||||
import com.cloud.api.commands.ListLoadBalancerRuleInstancesCmd;
|
||||
import com.cloud.api.commands.ListLoadBalancerRulesCmd;
|
||||
import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
|
||||
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
|
||||
public interface LoadBalancingRulesService {
|
||||
/**
|
||||
* Create a load balancer rule from the given ipAddress/port to the given private port
|
||||
* @param openFirewall TODO
|
||||
* @param cmd the command specifying the ip address, public port, protocol, private port, and algorithm
|
||||
*
|
||||
* @param openFirewall
|
||||
* TODO
|
||||
* @param cmd
|
||||
* the command specifying the ip address, public port, protocol, private port, and algorithm
|
||||
* @return the newly created LoadBalancerVO if successful, null otherwise
|
||||
* @throws InsufficientAddressCapacityException
|
||||
*/
|
||||
@ -48,9 +48,14 @@ public interface LoadBalancingRulesService {
|
||||
LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd);
|
||||
|
||||
boolean deleteLoadBalancerRule(long lbRuleId, boolean apply);
|
||||
|
||||
/**
|
||||
* Create a stickiness policy to a load balancer from the given stickiness method name and parameters in (name,value) pairs.
|
||||
* @param cmd the command specifying the stickiness method name, params (name,value pairs), policy name and description.
|
||||
* Create a stickiness policy to a load balancer from the given stickiness method name and parameters in
|
||||
* (name,value) pairs.
|
||||
*
|
||||
* @param cmd
|
||||
* the command specifying the stickiness method name, params (name,value pairs), policy name and
|
||||
* description.
|
||||
* @return the newly created stickiness policy if successfull, null otherwise
|
||||
* @thows NetworkRuleConflictException
|
||||
*/
|
||||
@ -59,6 +64,7 @@ public interface LoadBalancingRulesService {
|
||||
public boolean applyLBStickinessPolicy(CreateLBStickinessPolicyCmd cmd) throws ResourceUnavailableException;
|
||||
|
||||
boolean deleteLBStickinessPolicy(long stickinessPolicyId);
|
||||
|
||||
/**
|
||||
* Assign a virtual machine, or list of virtual machines, to a load balancer.
|
||||
*/
|
||||
@ -67,8 +73,11 @@ public interface LoadBalancingRulesService {
|
||||
boolean removeFromLoadBalancer(long lbRuleId, List<Long> vmIds);
|
||||
|
||||
boolean applyLoadBalancerConfig(long lbRuleId) throws ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* List instances that have either been applied to a load balancer or are eligible to be assigned to a load balancer.
|
||||
* List instances that have either been applied to a load balancer or are eligible to be assigned to a load
|
||||
* balancer.
|
||||
*
|
||||
* @param cmd
|
||||
* @return list of vm instances that have been or can be applied to a load balancer
|
||||
*/
|
||||
@ -76,19 +85,24 @@ public interface LoadBalancingRulesService {
|
||||
|
||||
/**
|
||||
* List load balancer rules based on the given criteria
|
||||
* @param cmd the command that specifies the criteria to use for listing load balancers. Load balancers can be listed
|
||||
*
|
||||
* @param cmd
|
||||
* the command that specifies the criteria to use for listing load balancers. Load balancers can be
|
||||
* listed
|
||||
* by id, name, public ip, and vm instance id
|
||||
* @return list of load balancers that match the criteria
|
||||
*/
|
||||
List<? extends LoadBalancer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
|
||||
|
||||
/**
|
||||
* List stickiness policies based on the given criteria
|
||||
* @param cmd the command specifies the load balancing rule id.
|
||||
*
|
||||
* @param cmd
|
||||
* the command specifies the load balancing rule id.
|
||||
* @return list of stickiness policies that match the criteria.
|
||||
*/
|
||||
List<? extends StickinessPolicy> searchForLBStickinessPolicies(ListLBStickinessPoliciesCmd cmd);
|
||||
|
||||
|
||||
List<LoadBalancingRule> listByNetworkId(long networkId);
|
||||
|
||||
LoadBalancer findById(long LoadBalancer);
|
||||
|
||||
@ -31,24 +31,34 @@ public interface RulesService {
|
||||
/**
|
||||
* Creates a port forwarding rule between two ip addresses or between
|
||||
* an ip address and a virtual machine.
|
||||
* @param rule rule to be created.
|
||||
* @param vmId vm to be linked to. If specified the destination ip address is ignored.
|
||||
* @param openFirewall TODO
|
||||
*
|
||||
* @param rule
|
||||
* rule to be created.
|
||||
* @param vmId
|
||||
* vm to be linked to. If specified the destination ip address is ignored.
|
||||
* @param openFirewall
|
||||
* TODO
|
||||
* @return PortForwardingRule if created.
|
||||
* @throws NetworkRuleConflictException if conflicts in the network rules are detected.
|
||||
* @throws NetworkRuleConflictException
|
||||
* if conflicts in the network rules are detected.
|
||||
*/
|
||||
PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, boolean openFirewall) throws NetworkRuleConflictException;
|
||||
|
||||
/**
|
||||
* Revokes a port forwarding rule
|
||||
* @param ruleId the id of the rule to revoke.
|
||||
*
|
||||
* @param ruleId
|
||||
* the id of the rule to revoke.
|
||||
* @param caller
|
||||
* @return
|
||||
*/
|
||||
boolean revokePortForwardingRule(long ruleId, boolean apply);
|
||||
|
||||
/**
|
||||
* List port forwarding rules assigned to an ip address
|
||||
* @param cmd the command object holding the criteria for listing port forwarding rules (the ipAddress)
|
||||
*
|
||||
* @param cmd
|
||||
* the command object holding the criteria for listing port forwarding rules (the ipAddress)
|
||||
* @return list of port forwarding rules on the given address, empty list if no rules exist
|
||||
*/
|
||||
public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd);
|
||||
@ -58,6 +68,7 @@ public interface RulesService {
|
||||
boolean enableStaticNat(long ipAddressId, long vmId) throws NetworkRuleConflictException, ResourceUnavailableException;
|
||||
|
||||
PortForwardingRule getPortForwardigRule(long ruleId);
|
||||
|
||||
FirewallRule getFirewallRule(long ruleId);
|
||||
|
||||
StaticNatRule createStaticNatRule(StaticNatRule rule, boolean openFirewall) throws NetworkRuleConflictException;
|
||||
|
||||
@ -104,4 +104,5 @@ public interface NetworkOffering {
|
||||
boolean getElasticLb();
|
||||
|
||||
boolean getSpecifyIpRanges();
|
||||
|
||||
}
|
||||
|
||||
@ -46,4 +46,5 @@ public interface DomainService {
|
||||
|
||||
List<? extends Domain> searchForDomainChildren(ListDomainChildrenCmd cmd)
|
||||
throws PermissionDeniedException;
|
||||
|
||||
}
|
||||
|
||||
@ -29,10 +29,15 @@ public interface ResourceLimitService {
|
||||
|
||||
/**
|
||||
* Updates an existing resource limit with the specified details. If a limit doesn't exist, will create one.
|
||||
* @param accountId TODO
|
||||
* @param domainId TODO
|
||||
* @param resourceType TODO
|
||||
* @param max TODO
|
||||
*
|
||||
* @param accountId
|
||||
* TODO
|
||||
* @param domainId
|
||||
* TODO
|
||||
* @param resourceType
|
||||
* TODO
|
||||
* @param max
|
||||
* TODO
|
||||
*
|
||||
* @return the updated/created resource limit
|
||||
*/
|
||||
@ -40,19 +45,28 @@ public interface ResourceLimitService {
|
||||
|
||||
/**
|
||||
* Updates an existing resource count details for the account/domain
|
||||
* @param accountId TODO
|
||||
* @param domainId TODO
|
||||
* @param typeId TODO
|
||||
*
|
||||
* @param accountId
|
||||
* TODO
|
||||
* @param domainId
|
||||
* TODO
|
||||
* @param typeId
|
||||
* TODO
|
||||
* @return the updated/created resource counts
|
||||
*/
|
||||
List<? extends ResourceCount> recalculateResourceCount(Long accountId, Long domainId, Integer typeId);
|
||||
|
||||
/**
|
||||
* Search for resource limits for the given id and/or account and/or type and/or domain.
|
||||
* @param id TODO
|
||||
* @param accountId TODO
|
||||
* @param domainId TODO
|
||||
* @param type TODO
|
||||
*
|
||||
* @param id
|
||||
* TODO
|
||||
* @param accountId
|
||||
* TODO
|
||||
* @param domainId
|
||||
* TODO
|
||||
* @param type
|
||||
* TODO
|
||||
* @return a list of limits that match the criteria
|
||||
*/
|
||||
public List<? extends ResourceLimit> searchForLimits(Long id, Long accountId, Long domainId, Integer type, Long startIndex, Long pageSizeVal);
|
||||
@ -60,6 +74,7 @@ public interface ResourceLimitService {
|
||||
/**
|
||||
* Finds the resource limit for a specified account and type. If the account has an infinite limit, will check
|
||||
* the account's parent domain, and if that limit is also infinite, will return the ROOT domain's limit.
|
||||
*
|
||||
* @param account
|
||||
* @param type
|
||||
* @return resource limit
|
||||
@ -69,6 +84,7 @@ public interface ResourceLimitService {
|
||||
/**
|
||||
* Finds the resource limit for a specified domain and type. If the domain has an infinite limit, will check
|
||||
* up the domain hierarchy
|
||||
*
|
||||
* @param account
|
||||
* @param type
|
||||
* @return resource limit
|
||||
@ -77,6 +93,7 @@ public interface ResourceLimitService {
|
||||
|
||||
/**
|
||||
* Increments the resource count
|
||||
*
|
||||
* @param accountId
|
||||
* @param type
|
||||
* @param delta
|
||||
@ -85,6 +102,7 @@ public interface ResourceLimitService {
|
||||
|
||||
/**
|
||||
* Decrements the resource count
|
||||
*
|
||||
* @param accountId
|
||||
* @param type
|
||||
* @param delta
|
||||
@ -93,15 +111,19 @@ public interface ResourceLimitService {
|
||||
|
||||
/**
|
||||
* Checks if a limit has been exceeded for an account
|
||||
*
|
||||
* @param account
|
||||
* @param type
|
||||
* @param count the number of resources being allocated, count will be added to current allocation and compared against maximum allowed allocation
|
||||
* @param count
|
||||
* the number of resources being allocated, count will be added to current allocation and compared
|
||||
* against maximum allowed allocation
|
||||
* @throws ResourceAllocationException
|
||||
*/
|
||||
public void checkResourceLimit(Account account, ResourceCount.ResourceType type, long... count) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Gets the count of resources for a resource type and account
|
||||
*
|
||||
* @param account
|
||||
* @param type
|
||||
* @return count of resources
|
||||
|
||||
@ -49,7 +49,8 @@ public class ResourceLimitVO implements ResourceLimit {
|
||||
@Column(name = "max")
|
||||
private Long max;
|
||||
|
||||
public ResourceLimitVO() {}
|
||||
public ResourceLimitVO() {
|
||||
}
|
||||
|
||||
public ResourceLimitVO(ResourceCount.ResourceType type, Long max, long ownerId, ResourceOwnerType ownerType) {
|
||||
this.type = type;
|
||||
|
||||
@ -278,7 +278,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
Long ipTotal = ApiDBUtils.getResourceCount(ResourceType.public_ip, account.getId());
|
||||
|
||||
Long ips = ipLimit - ipTotal;
|
||||
//check how many free ips are left, and if it's less than max allowed number of ips from account - use this value
|
||||
// check how many free ips are left, and if it's less than max allowed number of ips from account - use this
|
||||
// value
|
||||
Long ipsLeft = ApiDBUtils.countFreePublicIps();
|
||||
boolean unlimited = true;
|
||||
if (ips.longValue() > ipsLeft.longValue()) {
|
||||
@ -354,7 +355,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return accountResponse;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserResponse createUserResponse(UserAccount user) {
|
||||
UserResponse userResponse = new UserResponse();
|
||||
@ -529,7 +529,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return policyResponse;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HostResponse createHostResponse(Host host) {
|
||||
return createHostResponse(host, EnumSet.of(HostDetails.all));
|
||||
@ -1209,7 +1208,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVm... userVms) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
@ -1234,8 +1232,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
userVmResponse.setName(userVm.getHostName());
|
||||
userVmResponse.setCreated(userVm.getCreated());
|
||||
|
||||
|
||||
|
||||
userVmResponse.setHaEnable(userVm.isHaEnabled());
|
||||
|
||||
if (userVm.getDisplayName() != null) {
|
||||
@ -1265,7 +1261,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
userVmResponse.setZoneId(zone.getId());
|
||||
userVmResponse.setZoneName(zone.getName());
|
||||
|
||||
|
||||
// if user is an admin, display host id
|
||||
if (((caller == null) || (caller.getType() == Account.ACCOUNT_TYPE_ADMIN)) && (userVm.getHostId() != null)) {
|
||||
Host host = hosts.get(userVm.getHostId());
|
||||
@ -1326,7 +1321,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (details.contains(VMDetails.all) || details.contains(VMDetails.iso)) {
|
||||
// ISO Info
|
||||
VMTemplateVO iso = templates.get(userVm.getIsoId());
|
||||
@ -1493,7 +1487,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return vmResponses;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
@ -1553,7 +1546,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
|
||||
populateOwner(routerResponse, router);
|
||||
|
||||
|
||||
DataCenter zone = ApiDBUtils.findZoneById(router.getDataCenterIdToDeployIn());
|
||||
if (zone != null) {
|
||||
routerResponse.setZoneName(zone.getName());
|
||||
@ -1910,6 +1902,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
responses.add(templateResponse);
|
||||
return responses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateResponse> createIsoResponses(long isoId, Long zoneId, boolean readyOnly) {
|
||||
|
||||
@ -2153,6 +2146,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setResponses(netGrpResponses);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group) {
|
||||
SecurityGroupResponse response = new SecurityGroupResponse();
|
||||
@ -2225,7 +2219,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jobResponse.setObjectName("asyncjobs");
|
||||
return jobResponse;
|
||||
}
|
||||
@ -2272,7 +2265,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return responseEvent;
|
||||
}
|
||||
|
||||
|
||||
private List<CapacityVO> sumCapacities(List<? extends Capacity> hostCapacities) {
|
||||
Map<String, Long> totalCapacityMap = new HashMap<String, Long>();
|
||||
Map<String, Long> usedCapacityMap = new HashMap<String, Long>();
|
||||
@ -2339,11 +2331,16 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
|
||||
if (capacityType == Capacity.CAPACITY_TYPE_CPU || capacityType == Capacity.CAPACITY_TYPE_MEMORY) { // Reserved
|
||||
// Capacity
|
||||
// accounts for
|
||||
// stopped vms
|
||||
// that have been
|
||||
// stopped within
|
||||
// an interval
|
||||
// accounts
|
||||
// for
|
||||
// stopped
|
||||
// vms
|
||||
// that
|
||||
// have been
|
||||
// stopped
|
||||
// within
|
||||
// an
|
||||
// interval
|
||||
usedCapacity += capacity.getReservedCapacity();
|
||||
}
|
||||
|
||||
@ -2376,10 +2373,13 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
// accounts
|
||||
// for
|
||||
// stopped
|
||||
// vms that
|
||||
// have been
|
||||
// vms
|
||||
// that
|
||||
// have
|
||||
// been
|
||||
// stopped
|
||||
// within an
|
||||
// within
|
||||
// an
|
||||
// interval
|
||||
usedCapacity += capacity.getReservedCapacity();
|
||||
}
|
||||
@ -2814,7 +2814,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FirewallResponse createFirewallResponse(FirewallRule fwRule) {
|
||||
FirewallResponse response = new FirewallResponse();
|
||||
@ -2850,8 +2849,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UserVmData newUserVmData(UserVm userVm) {
|
||||
UserVmData userVmData = new UserVmData();
|
||||
userVmData.setId(userVm.getId());
|
||||
@ -3195,7 +3192,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result) {
|
||||
VirtualRouterProviderResponse response = new VirtualRouterProviderResponse();
|
||||
@ -3206,6 +3202,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setObjectName("virtualrouterelement");
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LBStickinessResponse createLBStickinessPolicyResponse(
|
||||
StickinessPolicy stickinessPolicy, LoadBalancer lb) {
|
||||
@ -3236,7 +3233,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
List<? extends StickinessPolicy> stickinessPolicies, LoadBalancer lb) {
|
||||
LBStickinessResponse spResponse = new LBStickinessResponse();
|
||||
|
||||
if (lb == null) return spResponse ;
|
||||
if (lb == null)
|
||||
return spResponse;
|
||||
spResponse.setlbRuleId(lb.getId());
|
||||
Account account = ApiDBUtils.findAccountById(lb.getAccountId());
|
||||
if (account != null) {
|
||||
@ -3285,4 +3283,5 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setObjectName("storagenetworkiprange");
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
/**
|
||||
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
@ -333,7 +334,8 @@ public class ApiServer implements HttpRequestHandler {
|
||||
if ("response".equalsIgnoreCase(paramValue[0])) {
|
||||
responseType = paramValue[1];
|
||||
} else {
|
||||
// according to the servlet spec, the parameter map should be in the form (name=String, value=String[]), so
|
||||
// according to the servlet spec, the parameter map should be in the form (name=String,
|
||||
// value=String[]), so
|
||||
// parameter values will be stored in an array
|
||||
parameterMap.put(/* name */paramValue[0], /* value */new String[] { paramValue[1] });
|
||||
}
|
||||
@ -557,10 +559,13 @@ public class ApiServer implements HttpRequestHandler {
|
||||
auditTrailSb.append(" " + HttpServletResponse.SC_OK + " ");
|
||||
auditTrailSb.append(result);
|
||||
/*
|
||||
* if (command.equals("queryAsyncJobResult")){ //For this command we need to also log job status and job resultcode for
|
||||
* if (command.equals("queryAsyncJobResult")){ //For this command we need to also log job status and job
|
||||
* resultcode for
|
||||
* (Pair<String,Object> pair : resultValues){ String key = pair.first(); if (key.equals("jobstatus")){
|
||||
* auditTrailSb.append(" "); auditTrailSb.append(key); auditTrailSb.append("="); auditTrailSb.append(pair.second());
|
||||
* }else if (key.equals("jobresultcode")){ auditTrailSb.append(" "); auditTrailSb.append(key); auditTrailSb.append("=");
|
||||
* auditTrailSb.append(" "); auditTrailSb.append(key); auditTrailSb.append("=");
|
||||
* auditTrailSb.append(pair.second());
|
||||
* }else if (key.equals("jobresultcode")){ auditTrailSb.append(" "); auditTrailSb.append(key);
|
||||
* auditTrailSb.append("=");
|
||||
* auditTrailSb.append(pair.second()); } } }else { for (Pair<String,Object> pair : resultValues){ if
|
||||
* (pair.first().equals("jobid")){ // Its an async job so report the jobid auditTrailSb.append(" ");
|
||||
* auditTrailSb.append(pair.first()); auditTrailSb.append("="); auditTrailSb.append(pair.second()); } } }
|
||||
@ -861,7 +866,8 @@ public class ApiServer implements HttpRequestHandler {
|
||||
|
||||
// FIXME: the following two threads are copied from
|
||||
// http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java
|
||||
// we have to cite a license if we are using this code directly, so we need to add the appropriate citation or modify the
|
||||
// we have to cite a license if we are using this code directly, so we need to add the appropriate citation or
|
||||
// modify the
|
||||
// code to be very specific to our needs
|
||||
static class ListenerThread extends Thread {
|
||||
private HttpService _httpService = null;
|
||||
|
||||
@ -48,13 +48,15 @@ import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
/**
|
||||
* ConfigurationManager handles adding pods/zones, changing IP ranges, enabling external firewalls, and editing configuration values
|
||||
* ConfigurationManager handles adding pods/zones, changing IP ranges, enabling external firewalls, and editing
|
||||
* configuration values
|
||||
*
|
||||
*/
|
||||
public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
|
||||
/**
|
||||
* Updates a configuration entry with a new value
|
||||
*
|
||||
* @param userId
|
||||
* @param name
|
||||
* @param value
|
||||
@ -63,6 +65,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
|
||||
/**
|
||||
* Creates a new service offering
|
||||
*
|
||||
* @param name
|
||||
* @param cpu
|
||||
* @param ramSize
|
||||
@ -72,15 +75,18 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
* @param offerHA
|
||||
* @param domainId
|
||||
* @param hostTag
|
||||
* @param networkRate TODO
|
||||
* @param networkRate
|
||||
* TODO
|
||||
* @param id
|
||||
* @param useVirtualNetwork
|
||||
* @return ID
|
||||
*/
|
||||
ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean limitResourceUse, String tags, Long domainId, String hostTag, Integer networkRate);
|
||||
ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired,
|
||||
boolean offerHA, boolean limitResourceUse, String tags, Long domainId, String hostTag, Integer networkRate);
|
||||
|
||||
/**
|
||||
* Creates a new disk offering
|
||||
*
|
||||
* @param domainId
|
||||
* @param name
|
||||
* @param description
|
||||
@ -93,6 +99,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
|
||||
/**
|
||||
* Creates a new pod
|
||||
*
|
||||
* @param userId
|
||||
* @param podName
|
||||
* @param zoneId
|
||||
@ -101,13 +108,15 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
* @param startIp
|
||||
* @param endIp
|
||||
* @param allocationState
|
||||
* @param skipGatewayOverlapCheck (true if it is ok to not validate that gateway IP address overlap with Start/End IP of the POD)
|
||||
* @param skipGatewayOverlapCheck
|
||||
* (true if it is ok to not validate that gateway IP address overlap with Start/End IP of the POD)
|
||||
* @return Pod
|
||||
*/
|
||||
HostPodVO createPod(long userId, String podName, long zoneId, String gateway, String cidr, String startIp, String endIp, String allocationState, boolean skipGatewayOverlapCheck);
|
||||
|
||||
/**
|
||||
* Creates a new zone
|
||||
*
|
||||
* @param userId
|
||||
* @param zoneName
|
||||
* @param dns1
|
||||
@ -116,36 +125,44 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
* @param internalDns2
|
||||
* @param zoneType
|
||||
* @param allocationState
|
||||
* @param networkDomain TODO
|
||||
* @param isSecurityGroupEnabled TODO
|
||||
* @param networkDomain
|
||||
* TODO
|
||||
* @param isSecurityGroupEnabled
|
||||
* TODO
|
||||
* @return
|
||||
* @throws
|
||||
* @throws
|
||||
*/
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String domain, Long domainId, NetworkType zoneType, String allocationState, String networkDomain, boolean isSecurityGroupEnabled);
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String domain, Long domainId, NetworkType zoneType, String allocationState,
|
||||
String networkDomain, boolean isSecurityGroupEnabled);
|
||||
|
||||
/**
|
||||
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated IP addresses.
|
||||
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated
|
||||
* IP addresses.
|
||||
*
|
||||
* @param userId
|
||||
* @param vlanDbId
|
||||
* @return success/failure
|
||||
*/
|
||||
boolean deleteVlanAndPublicIpRange(long userId, long vlanDbId);
|
||||
|
||||
|
||||
/**
|
||||
* Adds/deletes private IPs
|
||||
* @param add - either true or false
|
||||
*
|
||||
* @param add
|
||||
* - either true or false
|
||||
* @param podId
|
||||
* @param startIP
|
||||
* @param endIP
|
||||
* @return Message to display to user
|
||||
* @throws if unable to add private ip range
|
||||
* @throws if
|
||||
* unable to add private ip range
|
||||
*/
|
||||
String changePrivateIPRange(boolean add, long podId, String startIP, String endIP);
|
||||
|
||||
/**
|
||||
* Converts a comma separated list of tags to a List
|
||||
*
|
||||
* @param tags
|
||||
* @return List of tags
|
||||
*/
|
||||
@ -153,6 +170,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
|
||||
/**
|
||||
* Converts a List of tags to a comma separated list
|
||||
*
|
||||
* @param tags
|
||||
* @return String containing a comma separated list of tags
|
||||
*/
|
||||
@ -167,29 +185,40 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
void checkDiskOfferingAccess(Account caller, DiskOffering dof)
|
||||
throws PermissionDeniedException;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new network offering
|
||||
*
|
||||
* @param name
|
||||
* @param displayText
|
||||
* @param trafficType
|
||||
* @param tags
|
||||
* @param networkRate TODO
|
||||
* @param serviceProviderMap TODO
|
||||
* @param isDefault TODO
|
||||
* @param type TODO
|
||||
* @param systemOnly TODO
|
||||
* @param networkRate
|
||||
* TODO
|
||||
* @param serviceProviderMap
|
||||
* TODO
|
||||
* @param isDefault
|
||||
* TODO
|
||||
* @param type
|
||||
* TODO
|
||||
* @param systemOnly
|
||||
* TODO
|
||||
* @param serviceOfferingId
|
||||
* @param specifyIpRanges TODO
|
||||
* @param specifyIpRanges
|
||||
* TODO
|
||||
* @param id
|
||||
* @param specifyVlan;
|
||||
* @param conserveMode;
|
||||
* @param specifyVlan
|
||||
* ;
|
||||
* @param conserveMode
|
||||
* ;
|
||||
* @return network offering object
|
||||
*/
|
||||
|
||||
NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, boolean specifyVlan, Availability availability, Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId, boolean conserveMode, Map<Service, Map<Capability, String>> serviceCapabilityMap, boolean specifyIpRanges);
|
||||
NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, boolean specifyVlan, Availability availability, Integer networkRate,
|
||||
Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId, boolean conserveMode,
|
||||
Map<Service, Map<Capability, String>> serviceCapabilityMap, boolean specifyIpRanges);
|
||||
|
||||
Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, long networkId, Long physicalNetworkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
|
||||
Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, long networkId,
|
||||
Long physicalNetworkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
|
||||
|
||||
void createDefaultSystemNetworks(long zoneId) throws ConcurrentOperationException;
|
||||
|
||||
@ -203,6 +232,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
|
||||
/**
|
||||
* Edits a pod in the database. Will not allow you to edit pods that are being used anywhere in the system.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
* @param startIp
|
||||
|
||||
@ -341,7 +341,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
if (Config.XenGuestNetwork.key().equalsIgnoreCase(name)) {
|
||||
String sql = "update host_details set value=? where name=?";
|
||||
@ -705,7 +704,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
String checkPodCIDRs = _configDao.getValue("check.pod.cidrs");
|
||||
if (checkPodCIDRs == null || checkPodCIDRs.trim().isEmpty() || Boolean.parseBoolean(checkPodCIDRs)) {
|
||||
checkPodCidrSubnets(zoneId, podId, cidr);
|
||||
/* Commenting out due to Bug 11593 - CIDR conflicts with zone when extending pod but not when creating it
|
||||
/*
|
||||
* Commenting out due to Bug 11593 - CIDR conflicts with zone when extending pod but not when creating it
|
||||
*
|
||||
* checkCidrVlanOverlap(zoneId, cidr);
|
||||
*/
|
||||
@ -1177,8 +1177,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
List<HostPodVO> podsInZone = _podDao.listByDataCenterId(zoneId);
|
||||
for (HostPodVO hostPod : podsInZone) {
|
||||
String[] IpRange = hostPod.getDescription().split("-");
|
||||
if (IpRange[0]==null || IpRange[1]==null) continue;
|
||||
if (!NetUtils.isValidIp(IpRange[0]) || !NetUtils.isValidIp(IpRange[1])) continue;
|
||||
if (IpRange[0] == null || IpRange[1] == null)
|
||||
continue;
|
||||
if (!NetUtils.isValidIp(IpRange[0]) || !NetUtils.isValidIp(IpRange[1]))
|
||||
continue;
|
||||
if (NetUtils.ipRangesOverlap(startIp, endIp, IpRange[0], IpRange[1])) {
|
||||
throw new InvalidParameterValueException("The Start IP and endIP address range overlap with private IP :" + IpRange[0] + ":" + IpRange[1]);
|
||||
}
|
||||
@ -1228,7 +1230,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean updateLDAP(LDAPConfigCmd cmd) {
|
||||
@ -1266,51 +1267,58 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
DirContext ctx = new InitialDirContext(env);
|
||||
ctx.close();
|
||||
|
||||
|
||||
// store the result in DB COnfiguration
|
||||
ConfigurationVO cvo = _configDao.findByName(LDAPParams.hostname.toString());
|
||||
if (cvo == null) {
|
||||
cvo = new ConfigurationVO("Advanced", "DEFAULT", "management-server", LDAPParams.hostname.toString(), null, "Hostname or ip address of the ldap server eg: my.ldap.com");
|
||||
}
|
||||
cvo.setValue(hostname); _configDao.persist(cvo);
|
||||
cvo.setValue(hostname);
|
||||
_configDao.persist(cvo);
|
||||
|
||||
cvo = _configDao.findByName(LDAPParams.port.toString());
|
||||
if (cvo == null) {
|
||||
cvo = new ConfigurationVO("Advanced", "DEFAULT", "management-server", LDAPParams.port.toString(), null, "Specify the LDAP port if required, default is 389");
|
||||
}
|
||||
cvo.setValue(port.toString()); _configDao.persist(cvo);
|
||||
cvo.setValue(port.toString());
|
||||
_configDao.persist(cvo);
|
||||
|
||||
cvo = _configDao.findByName(LDAPParams.queryfilter.toString());
|
||||
if (cvo == null) {
|
||||
cvo = new ConfigurationVO("Advanced","DEFAULT", "management-server", LDAPParams.queryfilter.toString(), null, "You specify a query filter here, which narrows down the users, who can be part of this domain");
|
||||
cvo = new ConfigurationVO("Advanced", "DEFAULT", "management-server", LDAPParams.queryfilter.toString(), null,
|
||||
"You specify a query filter here, which narrows down the users, who can be part of this domain");
|
||||
}
|
||||
cvo.setValue(queryFilter); _configDao.persist(cvo);
|
||||
cvo.setValue(queryFilter);
|
||||
_configDao.persist(cvo);
|
||||
|
||||
cvo = _configDao.findByName(LDAPParams.searchbase.toString());
|
||||
if (cvo == null) {
|
||||
cvo = new ConfigurationVO("Advanced","DEFAULT", "management-server", LDAPParams.searchbase.toString(), null, "The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.");
|
||||
cvo = new ConfigurationVO("Advanced", "DEFAULT", "management-server", LDAPParams.searchbase.toString(), null,
|
||||
"The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.");
|
||||
}
|
||||
cvo.setValue(searchBase); _configDao.persist(cvo);
|
||||
cvo.setValue(searchBase);
|
||||
_configDao.persist(cvo);
|
||||
|
||||
cvo = _configDao.findByName(LDAPParams.usessl.toString());
|
||||
if (cvo == null) {
|
||||
cvo = new ConfigurationVO("Advanced", "DEFAULT", "management-server", LDAPParams.usessl.toString(), null, "Check Use SSL if the external LDAP server is configured for LDAP over SSL.");
|
||||
}
|
||||
cvo.setValue(useSSL.toString()); _configDao.persist(cvo);
|
||||
cvo.setValue(useSSL.toString());
|
||||
_configDao.persist(cvo);
|
||||
|
||||
cvo = _configDao.findByName(LDAPParams.dn.toString());
|
||||
if (cvo == null) {
|
||||
cvo = new ConfigurationVO("Advanced", "DEFAULT", "management-server", LDAPParams.dn.toString(), null, "Specify the distinguished name of a user with the search permission on the directory");
|
||||
}
|
||||
cvo.setValue(bindDN); _configDao.persist(cvo);
|
||||
cvo.setValue(bindDN);
|
||||
_configDao.persist(cvo);
|
||||
|
||||
cvo = _configDao.findByName(LDAPParams.passwd.toString());
|
||||
if (cvo == null) {
|
||||
cvo = new ConfigurationVO("Advanced", "DEFAULT", "management-server", LDAPParams.passwd.toString(), null, "Enter the password");
|
||||
}
|
||||
cvo.setValue(bindPasswd); _configDao.persist(cvo);
|
||||
}
|
||||
catch (NamingException ne){
|
||||
cvo.setValue(bindPasswd);
|
||||
_configDao.persist(cvo);
|
||||
} catch (NamingException ne) {
|
||||
ne.printStackTrace();
|
||||
throw new InvalidParameterValueException("Naming Exception, check you ldap data ! " + ne.getMessage() + (ne.getCause() != null ? ("Caused by:" + ne.getCause().getMessage()) : ""));
|
||||
}
|
||||
@ -1473,7 +1481,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
_networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
|
||||
} catch (InvalidParameterValueException noStorage) {
|
||||
PhysicalNetworkTrafficTypeVO mgmtTraffic = _trafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Management);
|
||||
_networkMgr.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(), mgmtTraffic.getVmwareNetworkLabel(), mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan());
|
||||
_networkMgr.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(),
|
||||
mgmtTraffic.getVmwareNetworkLabel(), mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan());
|
||||
s_logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network " + mgmtPhyNetwork.getId() + " with same configure of management traffic type");
|
||||
}
|
||||
} catch (InvalidParameterValueException ex) {
|
||||
@ -1547,7 +1556,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createDefaultSystemNetworks(long zoneId) throws ConcurrentOperationException {
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
@ -2399,7 +2407,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
vlan = _vlanDao.persist(vlan);
|
||||
|
||||
if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId, physicalNetworkId)) {
|
||||
throw new CloudRuntimeException("Failed to save IP range. Please contact Cloud Support."); // It can be Direct IP or
|
||||
throw new CloudRuntimeException("Failed to save IP range. Please contact Cloud Support."); // It can be
|
||||
// Direct IP or
|
||||
// Public IP.
|
||||
}
|
||||
|
||||
@ -3126,7 +3135,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void validateStaticNatServiceCapablities(Map<Capability, String> staticNatServiceCapabilityMap) {
|
||||
if (staticNatServiceCapabilityMap != null && !staticNatServiceCapabilityMap.isEmpty()) {
|
||||
if (staticNatServiceCapabilityMap.keySet().size() > 1) {
|
||||
@ -3163,7 +3171,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
throw new InvalidParameterValueException("SpecifyIpRanges should be true if network offering's type is " + type);
|
||||
}
|
||||
|
||||
//specifyVlan should always be true for Shared network offerings and Isolated network offerings with specifyIpRanges = true
|
||||
// specifyVlan should always be true for Shared network offerings and Isolated network offerings with
|
||||
// specifyIpRanges = true
|
||||
if (!specifyVlan) {
|
||||
if (type == GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("SpecifyVlan should be true if network offering's type is " + type);
|
||||
@ -3176,7 +3185,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (availability == NetworkOffering.Availability.Required) {
|
||||
boolean canOffBeRequired = (type == GuestType.Isolated && serviceProviderMap.containsKey(Service.SourceNat));
|
||||
if (!canOffBeRequired) {
|
||||
throw new InvalidParameterValueException("Availability can be " + NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with " + Service.SourceNat.getName() + " enabled");
|
||||
throw new InvalidParameterValueException("Availability can be " + NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
|
||||
+ Service.SourceNat.getName() + " enabled");
|
||||
}
|
||||
|
||||
// only one network offering in the system can be Required
|
||||
@ -3230,7 +3240,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, networkRate, multicastRate, isDefault, availability, tags, type, conserveMode, dedicatedLb, sharedSourceNat, redundantRouter, elasticIp, elasticLb, specifyIpRanges);
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, networkRate, multicastRate, isDefault, availability, tags, type, conserveMode, dedicatedLb,
|
||||
sharedSourceNat, redundantRouter, elasticIp, elasticLb, specifyIpRanges);
|
||||
|
||||
if (serviceOfferingId != null) {
|
||||
offering.setServiceOfferingId(serviceOfferingId);
|
||||
@ -3528,7 +3539,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (availability == NetworkOffering.Availability.Required) {
|
||||
boolean canOffBeRequired = (offeringToUpdate.getGuestType() == GuestType.Isolated && _networkMgr.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
|
||||
if (!canOffBeRequired) {
|
||||
throw new InvalidParameterValueException("Availability can be " + NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with " + Service.SourceNat.getName() + " enabled");
|
||||
throw new InvalidParameterValueException("Availability can be " + NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
|
||||
+ Service.SourceNat.getName() + " enabled");
|
||||
}
|
||||
|
||||
// only one network offering in the system can be Required
|
||||
|
||||
@ -28,7 +28,10 @@ import com.cloud.utils.db.GenericDao;
|
||||
public interface ResourceLimitDao extends GenericDao<ResourceLimitVO, Long> {
|
||||
|
||||
List<ResourceLimitVO> listByOwner(Long ownerId, ResourceOwnerType ownerType);
|
||||
|
||||
boolean update(Long id, Long max);
|
||||
|
||||
ResourceCount.ResourceType getLimitType(String type);
|
||||
|
||||
ResourceLimitVO findByOwnerIdAndType(long ownerId, ResourceOwnerType ownerType, ResourceCount.ResourceType type);
|
||||
}
|
||||
|
||||
@ -59,7 +59,6 @@ public class ResourceLimitDaoImpl extends GenericDaoBase<ResourceLimitVO, Long>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean update(Long id, Long max) {
|
||||
ResourceLimitVO limit = findById(id);
|
||||
|
||||
@ -385,7 +385,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
try {
|
||||
if (deviceMapLock.lock(120)) {
|
||||
try {
|
||||
boolean dedicatedLB = offering.getDedicatedLB(); // does network offering supports a dedicated load balancer?
|
||||
boolean dedicatedLB = offering.getDedicatedLB(); // does network offering supports a dedicated
|
||||
// load balancer?
|
||||
long lbDeviceId;
|
||||
|
||||
txn.start();
|
||||
@ -398,7 +399,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
lbDeviceId = lbDevice.getId();
|
||||
|
||||
// persist the load balancer device id that will be used for this network. Once a network
|
||||
// is implemented on a LB device then later on all rules will be programmed on to same device
|
||||
// is implemented on a LB device then later on all rules will be programmed on to same
|
||||
// device
|
||||
NetworkExternalLoadBalancerVO networkLB = new NetworkExternalLoadBalancerVO(guestConfig.getId(), lbDeviceId);
|
||||
_networkExternalLBDao.persist(networkLB);
|
||||
|
||||
@ -415,11 +417,13 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
// if already attempted to provision load balancer then throw out of capacity exception,
|
||||
if (tryLbProvisioning) {
|
||||
retry = false;
|
||||
//TODO: throwing warning instead of error for now as its possible another provider can service this network
|
||||
// TODO: throwing warning instead of error for now as its possible another provider can
|
||||
// service this network
|
||||
s_logger.warn("There are no load balancer device with the capacity for implementing this network");
|
||||
throw exception;
|
||||
} else {
|
||||
tryLbProvisioning = true; // if possible provision a LB appliance in to the physical network
|
||||
tryLbProvisioning = true; // if possible provision a LB appliance in to the physical
|
||||
// network
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@ -433,14 +437,16 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
deviceMapLock.releaseRef();
|
||||
}
|
||||
|
||||
// there are no LB devices or there is no free capacity on the devices in the physical network so provision a new LB appliance
|
||||
// there are no LB devices or there is no free capacity on the devices in the physical network so provision
|
||||
// a new LB appliance
|
||||
if (tryLbProvisioning) {
|
||||
// check if LB appliance can be dynamically provisioned
|
||||
List<ExternalLoadBalancerDeviceVO> providerLbDevices = _externalLoadBalancerDeviceDao.listByProviderAndDeviceAllocationState(physicalNetworkId, provider, LBDeviceAllocationState.Provider);
|
||||
if ((providerLbDevices != null) && (!providerLbDevices.isEmpty())) {
|
||||
for (ExternalLoadBalancerDeviceVO lbProviderDevice : providerLbDevices) {
|
||||
if (lbProviderDevice.getState() == LBDeviceState.Enabled) {
|
||||
// acquire a private IP from the data center which will be used as management IP of provisioned LB appliance,
|
||||
// acquire a private IP from the data center which will be used as management IP of
|
||||
// provisioned LB appliance,
|
||||
DataCenterIpAddressVO dcPrivateIp = _dcDao.allocatePrivateIpAddress(guestConfig.getDataCenterId(), lbProviderDevice.getUuid());
|
||||
if (dcPrivateIp == null) {
|
||||
throw new InsufficientNetworkCapacityException("failed to acquire a priavate IP in the zone " + guestConfig.getDataCenterId() +
|
||||
@ -470,10 +476,12 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
String publicIf = createLbAnswer.getPublicInterface();
|
||||
String privateIf = createLbAnswer.getPrivateInterface();
|
||||
|
||||
//we have provisioned load balancer so add the appliance as cloudstack provisioned external load balancer
|
||||
// we have provisioned load balancer so add the appliance as cloudstack provisioned external
|
||||
// load balancer
|
||||
String dedicatedLb = offering.getDedicatedLB() ? "true" : "false";
|
||||
|
||||
//acquire a public IP to associate with lb appliance (used as subnet IP to make the appliance part of private network)
|
||||
// acquire a public IP to associate with lb appliance (used as subnet IP to make the
|
||||
// appliance part of private network)
|
||||
PublicIp publicIp = _networkMgr.assignPublicIpAddress(guestConfig.getDataCenterId(), null, _accountMgr.getSystemAccount(), VlanType.VirtualNetwork, null, null, false);
|
||||
String publicIPNetmask = publicIp.getVlanNetmask();
|
||||
String publicIPgateway = publicIp.getVlanGateway();
|
||||
@ -490,7 +498,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
}
|
||||
|
||||
if (lbAppliance != null) {
|
||||
// mark the load balancer as cloudstack managed and set parent host id on which lb appliance is provisioned
|
||||
// mark the load balancer as cloudstack managed and set parent host id on which lb
|
||||
// appliance is provisioned
|
||||
ExternalLoadBalancerDeviceVO managedLb = _externalLoadBalancerDeviceDao.findById(lbAppliance.getId());
|
||||
managedLb.setIsManagedDevice(true);
|
||||
managedLb.setParentHostId(lbProviderDevice.getHostId());
|
||||
@ -504,7 +513,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.warn("Failed to destroy load balancer appliance created");
|
||||
} else {
|
||||
// release the public & private IP back to dc pool, as the load balancer appliance is now destroyed
|
||||
// release the public & private IP back to dc pool, as the load balancer
|
||||
// appliance is now destroyed
|
||||
_dcDao.releasePrivateIpAddress(lbIP, guestConfig.getDataCenterId(), null);
|
||||
_networkMgr.releasePublicIpAddress(publicIp.getId(), _accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount());
|
||||
}
|
||||
@ -583,7 +593,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
}
|
||||
}
|
||||
|
||||
// if we are here then there are no existing LB devices in shared use or the devices in shared use has no free capacity left
|
||||
// if we are here then there are no existing LB devices in shared use or the devices in shared use has no
|
||||
// free capacity left
|
||||
// so allocate a new load balancer configured for shared use from the pool of free LB devices
|
||||
lbDevices = _externalLoadBalancerDeviceDao.listByProviderAndDeviceAllocationState(physicalNetworkId, provider, LBDeviceAllocationState.Free);
|
||||
if (lbDevices != null && !lbDevices.isEmpty()) {
|
||||
@ -619,7 +630,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
boolean lbCloudManaged = lbDevice.getIsManagedDevice();
|
||||
|
||||
if (!lbInUse && !lbCloudManaged) {
|
||||
// this is the last network mapped to the load balancer device so set device allocation state to be free
|
||||
// this is the last network mapped to the load balancer device so set device allocation state to be
|
||||
// free
|
||||
lbDevice.setAllocationState(LBDeviceAllocationState.Free);
|
||||
_externalLoadBalancerDeviceDao.update(lbDevice.getId(), lbDevice);
|
||||
}
|
||||
@ -822,7 +834,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
mapping = new InlineLoadBalancerNicMapVO(rule.getId(), srcIp, loadBalancingIpNic.getId());
|
||||
_inlineLoadBalancerNicMapDao.persist(mapping);
|
||||
|
||||
// On the firewall provider for the network, create a static NAT rule between the source IP address and the load balancing IP address
|
||||
// On the firewall provider for the network, create a static NAT rule between the source IP
|
||||
// address and the load balancing IP address
|
||||
applyStaticNatRuleForInlineLBRule(zone, network, firewallProviderHost, revoked, srcIp, loadBalancingIpNic.getIp4Address());
|
||||
} else {
|
||||
loadBalancingIpNic = _nicDao.findById(mapping.getNicId());
|
||||
@ -832,7 +845,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
// Find the NIC that the mapping refers to
|
||||
loadBalancingIpNic = _nicDao.findById(mapping.getNicId());
|
||||
|
||||
// On the firewall provider for the network, delete the static NAT rule between the source IP address and the load balancing IP address
|
||||
// On the firewall provider for the network, delete the static NAT rule between the source IP
|
||||
// address and the load balancing IP address
|
||||
applyStaticNatRuleForInlineLBRule(zone, network, firewallProviderHost, revoked, srcIp, loadBalancingIpNic.getIp4Address());
|
||||
|
||||
// Delete the mapping between the source IP address and the load balancing IP address
|
||||
@ -1212,7 +1226,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
|
||||
/*
|
||||
* Creates/updates all necessary stats entries for an account and zone.
|
||||
* Stats entries are created for source NAT IP addresses, static NAT rules, port forwarding rules, and load balancing rules
|
||||
* Stats entries are created for source NAT IP addresses, static NAT rules, port forwarding rules, and load
|
||||
* balancing rules
|
||||
*/
|
||||
private boolean manageStatsEntries(boolean create, long accountId, long zoneId, Network network,
|
||||
HostVO externalLoadBalancer, ExternalNetworkResourceUsageAnswer lbAnswer) {
|
||||
@ -1390,4 +1405,5 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
||||
}
|
||||
return new DeleteHostAnswer(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -35,7 +35,6 @@ import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network.Capability;
|
||||
@ -73,11 +72,14 @@ public interface NetworkManager extends NetworkService {
|
||||
* @param owner
|
||||
* @param type
|
||||
* @param networkId
|
||||
* @param requestedIp TODO
|
||||
* @param allocatedBy TODO
|
||||
* @param requestedIp
|
||||
* TODO
|
||||
* @param allocatedBy
|
||||
* TODO
|
||||
* @return
|
||||
* @throws InsufficientAddressCapacityException
|
||||
*/
|
||||
|
||||
PublicIp assignPublicIpAddress(long dcId, Long podId, Account owner, VlanType type, Long networkId, String requestedIp, boolean isElastic) throws InsufficientAddressCapacityException;
|
||||
|
||||
/**
|
||||
@ -169,7 +171,8 @@ public interface NetworkManager extends NetworkService {
|
||||
|
||||
/**
|
||||
* @throws InsufficientCapacityException
|
||||
* Associates an ip address list to an account. The list of ip addresses are all addresses associated with the
|
||||
* Associates an ip address list to an account. The list of ip addresses are all addresses associated
|
||||
* with the
|
||||
* given vlan id.
|
||||
* @param userId
|
||||
* @param accountId
|
||||
|
||||
@ -278,19 +278,32 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
PortForwardingRulesDao _portForwardingDao;
|
||||
@Inject
|
||||
ResourceLimitService _resourceLimitMgr;
|
||||
@Inject DomainRouterDao _routerDao;
|
||||
@Inject DomainManager _domainMgr;
|
||||
@Inject ProjectManager _projectMgr;
|
||||
@Inject NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
|
||||
@Inject PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject PhysicalNetworkServiceProviderDao _pNSPDao;
|
||||
@Inject PortForwardingRulesDao _portForwardingRulesDao;
|
||||
@Inject LoadBalancerDao _lbDao;
|
||||
@Inject PhysicalNetworkTrafficTypeDao _pNTrafficTypeDao;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject StorageNetworkManager _stnwMgr;
|
||||
@Inject
|
||||
DomainRouterDao _routerDao;
|
||||
@Inject
|
||||
DomainManager _domainMgr;
|
||||
@Inject
|
||||
ProjectManager _projectMgr;
|
||||
@Inject
|
||||
NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
PhysicalNetworkServiceProviderDao _pNSPDao;
|
||||
@Inject
|
||||
PortForwardingRulesDao _portForwardingRulesDao;
|
||||
@Inject
|
||||
LoadBalancerDao _lbDao;
|
||||
@Inject
|
||||
PhysicalNetworkTrafficTypeDao _pNTrafficTypeDao;
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
StorageNetworkManager _stnwMgr;
|
||||
|
||||
private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
|
||||
@ -311,7 +324,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
private Map<String, String> _configs;
|
||||
|
||||
|
||||
HashMap<Long, Long> _lastNetworkIdsToFree = new HashMap<Long, Long>();
|
||||
|
||||
private static HashMap<Service, List<Provider>> s_serviceToImplementedProvidersMap = new HashMap<Service, List<Provider>>();
|
||||
@ -378,7 +390,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
sc.setJoinParameters("vlan", "type", vlanUse);
|
||||
|
||||
|
||||
if (requestedIp != null) {
|
||||
sc.addAnd("address", SearchCriteria.Op.EQ, requestedIp);
|
||||
errorMessage.append(": requested ip " + requestedIp + " is not available");
|
||||
@ -426,8 +437,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
long macAddress = NetUtils.createSequenceBasedMacAddress(addr.getMacAddress());
|
||||
|
||||
|
||||
|
||||
return new PublicIp(addr, _vlanDao.findById(addr.getVlanId()), macAddress);
|
||||
}
|
||||
|
||||
@ -598,7 +607,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
markPublicIpAsAllocated(addr);
|
||||
|
||||
} else if (addr.getState() == IpAddress.State.Releasing) {
|
||||
// Cleanup all the resources for ip address if there are any, and only then un-assign ip in the system
|
||||
// Cleanup all the resources for ip address if there are any, and only then un-assign ip in the
|
||||
// system
|
||||
if (cleanupIpResources(addr.getId(), Account.ACCOUNT_ID_SYSTEM, _accountMgr.getSystemAccount())) {
|
||||
_ipAddressDao.unassignIpAddress(addr.getId());
|
||||
} else {
|
||||
@ -665,7 +675,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
ipToServices.put(ip, services);
|
||||
|
||||
//if IP in allocating state then it will not have any rules attached so skip IPAssoc to network service provider
|
||||
// if IP in allocating state then it will not have any rules attached so skip IPAssoc to network service
|
||||
// provider
|
||||
if (ip.getState() == State.Allocating) {
|
||||
continue;
|
||||
}
|
||||
@ -673,18 +684,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
// check if any active rules are applied on the public IP
|
||||
Set<Purpose> purposes = getPublicIpPurposeInRules(ip, false, includingFirewall);
|
||||
if (purposes == null || purposes.isEmpty()) {
|
||||
// since no active rules are there check if any rules are applied on the public IP but are in revoking state
|
||||
// since no active rules are there check if any rules are applied on the public IP but are in
|
||||
// revoking state
|
||||
purposes = getPublicIpPurposeInRules(ip, true, includingFirewall);
|
||||
if (purposes == null || purposes.isEmpty()) {
|
||||
// IP is not being used for any purpose so skip IPAssoc to network service provider
|
||||
continue;
|
||||
} else {
|
||||
if (rulesRevoked) {
|
||||
// no active rules/revoked rules are associated with this public IP, so remove the association with the provider
|
||||
// no active rules/revoked rules are associated with this public IP, so remove the
|
||||
// association with the provider
|
||||
ip.setState(State.Releasing);
|
||||
} else {
|
||||
if (ip.getState() == State.Releasing) {
|
||||
// rules are not revoked yet, so don't let the network service provider revoke the IP association
|
||||
// rules are not revoked yet, so don't let the network service provider revoke the IP
|
||||
// association
|
||||
// mark IP is allocated so that IP association will not be removed from the provider
|
||||
ip.setState(State.Allocated);
|
||||
}
|
||||
@ -945,10 +959,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
// In Advance zone only allow to do IP assoc for Isolated networks with source nat service enabled
|
||||
if (zone.getNetworkType() == NetworkType.Advanced && !(network.getGuestType() == GuestType.Isolated && areServicesSupportedInNetwork(network.getId(), Service.SourceNat))) {
|
||||
throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + " ip address can be associated only to the network of guest type " + GuestType.Isolated + " with the " + Service.SourceNat.getName() + " enabled");
|
||||
throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + " ip address can be associated only to the network of guest type " + GuestType.Isolated + " with the "
|
||||
+ Service.SourceNat.getName() + " enabled");
|
||||
}
|
||||
|
||||
// Check that network belongs to IP owner - skip this check for Basic zone as there is just one guest network, and it
|
||||
// Check that network belongs to IP owner - skip this check for Basic zone as there is just one guest network,
|
||||
// and it
|
||||
// belongs to the system
|
||||
if (zone.getNetworkType() != NetworkType.Basic && network.getAccountId() != ipOwner.getId()) {
|
||||
throw new InvalidParameterValueException("The owner of the network is not the same as owner of the IP");
|
||||
@ -1058,7 +1074,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
s_logger.warn("Failed to associate ip address " + ip);
|
||||
_ipAddressDao.markAsUnavailable(ip.getId());
|
||||
if (!applyIpAssociations(network, true)) {
|
||||
// if fail to apply ip assciations again, unassign ip address without updating resource count and
|
||||
// if fail to apply ip assciations again, unassign ip address without updating resource
|
||||
// count and
|
||||
// generating usage event as there is no need to keep it in the db
|
||||
_ipAddressDao.unassignIpAddress(ip.getId());
|
||||
}
|
||||
@ -1112,7 +1129,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
|
||||
@ -1178,25 +1196,29 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
NetworkOfferingVO offering = null;
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOfferingWithSGService) == null) {
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks", TrafficType.Guest, null, true, Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true);
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks", TrafficType.Guest,
|
||||
null, true, Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, null, true, Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true);
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, null, true, Availability.Optional,
|
||||
null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService) == null) {
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM,NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService, "Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Required, null, defaultIsolatedSourceNatEnabledNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, false);
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService, "Offering for Isolated networks with Source Nat service enabled",
|
||||
TrafficType.Guest, null, false, Availability.Required, null, defaultIsolatedSourceNatEnabledNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, false);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest, null, true, Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, true);
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest, null,
|
||||
true, Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, true);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
@ -1338,7 +1360,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
try {
|
||||
if (predefined == null || (offering.getTrafficType() != TrafficType.Guest && predefined.getCidr() == null && predefined.getBroadcastUri() == null && predefined.getBroadcastDomainType() != BroadcastDomainType.Vlan)) {
|
||||
if (predefined == null
|
||||
|| (offering.getTrafficType() != TrafficType.Guest && predefined.getCidr() == null && predefined.getBroadcastUri() == null && predefined.getBroadcastDomainType() != BroadcastDomainType.Vlan)) {
|
||||
List<NetworkVO> configs = _networksDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
|
||||
if (configs.size() > 0) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -1495,7 +1518,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
nics.add(vo);
|
||||
|
||||
Integer networkRate = getNetworkRate(config.getId(), vm.getId());
|
||||
vm.addNic(new NicProfile(vo, network.first(), vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, isSecurityGroupSupportedInNetwork(network.first()), getNetworkTag(vm.getHypervisorType(), network.first())));
|
||||
vm.addNic(new NicProfile(vo, network.first(), vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, isSecurityGroupSupportedInNetwork(network.first()), getNetworkTag(vm.getHypervisorType(),
|
||||
network.first())));
|
||||
}
|
||||
|
||||
if (nics.size() != networks.size()) {
|
||||
@ -1660,7 +1684,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, NetworkVO network, NetworkOfferingVO offering)
|
||||
throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
// If this is a 1) guest virtual network 2) network has sourceNat service 3) network offering does not support a Shared source NAT rule,
|
||||
// If this is a 1) guest virtual network 2) network has sourceNat service 3) network offering does not support a
|
||||
// Shared source NAT rule,
|
||||
// associate a source NAT IP (if one isn't already associated with the network)
|
||||
|
||||
boolean sharedSourceNat = offering.getSharedSourceNat();
|
||||
@ -1737,7 +1762,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
List<NicVO> nics = _nicDao.listByVmId(vmProfile.getId());
|
||||
|
||||
// we have to implement default nics first - to ensure that default network elements start up first in multiple nics
|
||||
// we have to implement default nics first - to ensure that default network elements start up first in multiple
|
||||
// nics
|
||||
// case)
|
||||
// (need for setting DNS on Dhcp to domR's Ip4 address)
|
||||
Collections.sort(nics, new Comparator<NicVO>() {
|
||||
@ -1933,7 +1959,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated // No one is using this method.
|
||||
@Deprecated
|
||||
// No one is using this method.
|
||||
public AccountVO getNetworkOwner(long networkId) {
|
||||
SearchCriteria<AccountVO> sc = AccountsUsingNetworkSearch.create();
|
||||
sc.setJoinParameters("nc", "config", networkId);
|
||||
@ -1942,7 +1969,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return accounts.size() != 0 ? accounts.get(0) : null;
|
||||
}
|
||||
|
||||
@Deprecated // No one is using this method.
|
||||
@Deprecated
|
||||
// No one is using this method.
|
||||
public List<NetworkVO> getNetworksforOffering(long offeringId, long dataCenterId, long accountId) {
|
||||
return _networksDao.getNetworksForOffering(offeringId, dataCenterId, accountId);
|
||||
}
|
||||
@ -2201,7 +2229,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
// Regular user can create Guest Isolated Source Nat enabled network only
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getGuestType() != Network.GuestType.Isolated && areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))) {
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL
|
||||
&& (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getGuestType() != Network.GuestType.Isolated
|
||||
&& areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))) {
|
||||
throw new InvalidParameterValueException("Regular user can create a network only from the network offering having traffic type " + TrafficType.Guest + " and network type "
|
||||
+ Network.GuestType.Isolated + " with a service " + Service.SourceNat.getName() + " enabled");
|
||||
}
|
||||
@ -2304,7 +2334,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
// if zone is basic, only Shared network offerings w/o source nat service are allowed
|
||||
if (!(networkOffering.getGuestType() == GuestType.Shared && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat))) {
|
||||
throw new InvalidParameterValueException("For zone of type " + NetworkType.Basic + " only offerings of guestType " + GuestType.Shared + " with disabled " + Service.SourceNat.getName() + " service are allowed");
|
||||
throw new InvalidParameterValueException("For zone of type " + NetworkType.Basic + " only offerings of guestType " + GuestType.Shared + " with disabled " + Service.SourceNat.getName()
|
||||
+ " service are allowed");
|
||||
}
|
||||
|
||||
// In Basic zone the network should have aclType=Domain, domainId=1, subdomainAccess=true
|
||||
@ -2332,7 +2363,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
} else if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||
if (zone.isSecurityGroupEnabled()) {
|
||||
//Only Account specific Isolated network with sourceNat service disabled are allowed in security group enabled zone
|
||||
// Only Account specific Isolated network with sourceNat service disabled are allowed in security group
|
||||
// enabled zone
|
||||
boolean allowCreation = (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat));
|
||||
if (!allowCreation) {
|
||||
throw new InvalidParameterValueException("Only Account specific Isolated network with sourceNat service disabled are allowed in security group enabled zone");
|
||||
@ -2391,11 +2423,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
// In Advance zone Cidr for Shared networks and Isolated networks w/o source nat service can't be NULL - 2.2.x limitation, remove after we introduce support for multiple ip ranges
|
||||
// In Advance zone Cidr for Shared networks and Isolated networks w/o source nat service can't be NULL - 2.2.x
|
||||
// limitation, remove after we introduce support for multiple ip ranges
|
||||
// with different Cidrs for the same Shared network
|
||||
boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced && networkOffering.getTrafficType() == TrafficType.Guest && (networkOffering.getGuestType() == GuestType.Shared || (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)));
|
||||
boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced && networkOffering.getTrafficType() == TrafficType.Guest
|
||||
&& (networkOffering.getGuestType() == GuestType.Shared || (networkOffering.getGuestType() == GuestType.Isolated && !areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)));
|
||||
if (cidr == null && cidrRequired) {
|
||||
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of type " + Network.GuestType.Shared + " and network of type " + GuestType.Isolated + " with service " + Service.SourceNat.getName() + " disabled");
|
||||
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of type " + Network.GuestType.Shared + " and network of type " + GuestType.Isolated + " with service "
|
||||
+ Service.SourceNat.getName() + " disabled");
|
||||
}
|
||||
|
||||
// No cidr can be specified in Basic zone
|
||||
@ -2574,16 +2609,24 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (isSystem == null || !isSystem) {
|
||||
// Get domain level networks
|
||||
if (domainId != null) {
|
||||
networksToReturn.addAll(listDomainLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges), searchFilter, domainId));
|
||||
networksToReturn
|
||||
.addAll(listDomainLevelNetworks(
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges), searchFilter,
|
||||
domainId));
|
||||
}
|
||||
|
||||
if (!permittedAccounts.isEmpty()) {
|
||||
networksToReturn.addAll(listAccountSpecificNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges), searchFilter, permittedAccounts));
|
||||
networksToReturn.addAll(listAccountSpecificNetworks(
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges), searchFilter,
|
||||
permittedAccounts));
|
||||
} else if (domainId == null || listAll) {
|
||||
networksToReturn.addAll(listAccountSpecificNetworksByDomainPath(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges), searchFilter, path, isRecursive));
|
||||
networksToReturn.addAll(listAccountSpecificNetworksByDomainPath(
|
||||
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges), searchFilter, path,
|
||||
isRecursive));
|
||||
}
|
||||
} else {
|
||||
networksToReturn = _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, null, skipProjectNetworks, restartRequired, specifyIpRanges), searchFilter);
|
||||
networksToReturn = _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, null, skipProjectNetworks, restartRequired, specifyIpRanges),
|
||||
searchFilter);
|
||||
}
|
||||
|
||||
if (supportedServicesStr != null && !supportedServicesStr.isEmpty() && !networksToReturn.isEmpty()) {
|
||||
@ -2612,7 +2655,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
private SearchCriteria<NetworkVO> buildNetworkSearchCriteria(SearchBuilder<NetworkVO> sb, String keyword, Long id, Boolean isSystem, Long zoneId, String guestIpType, String trafficType, Long physicalNetworkId, String aclType, boolean skipProjectNetworks, Boolean restartRequired, Boolean specifyIpRanges) {
|
||||
private SearchCriteria<NetworkVO> buildNetworkSearchCriteria(SearchBuilder<NetworkVO> sb, String keyword, Long id, Boolean isSystem, Long zoneId, String guestIpType, String trafficType, Long physicalNetworkId,
|
||||
String aclType, boolean skipProjectNetworks, Boolean restartRequired, Boolean specifyIpRanges) {
|
||||
SearchCriteria<NetworkVO> sc = sb.create();
|
||||
|
||||
if (isSystem != null) {
|
||||
@ -2664,7 +2708,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return sc;
|
||||
}
|
||||
|
||||
|
||||
private List<NetworkVO> listDomainLevelNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, long domainId) {
|
||||
List<Long> networkIds = new ArrayList<Long>();
|
||||
Set<Long> allowedDomains = _domainMgr.getDomainParentIds(domainId);
|
||||
@ -2790,7 +2833,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
private boolean shutdownNetworkElementsAndResources(ReservationContext context, boolean cleanupElements, NetworkVO network) {
|
||||
//1) Cleanup all the rules for the network. If it fails, just log the failure and proceed with shutting down the elements
|
||||
// 1) Cleanup all the rules for the network. If it fails, just log the failure and proceed with shutting down
|
||||
// the elements
|
||||
boolean cleanupResult = true;
|
||||
try {
|
||||
cleanupResult = shutdownNetworkResources(network.getId(), context.getAccount(), context.getCaller().getId());
|
||||
@ -2811,7 +2855,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (providersToShutdown.contains(element.getProvider())) {
|
||||
try {
|
||||
if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network), "VirtualRouter")) {
|
||||
s_logger.warn("Unable to complete shutdown of the network elements due to element: " + element.getName() + " either doesn't exist or not enabled in the physical network " + getPhysicalNetworkId(network));
|
||||
s_logger.warn("Unable to complete shutdown of the network elements due to element: " + element.getName() + " either doesn't exist or not enabled in the physical network "
|
||||
+ getPhysicalNetworkId(network));
|
||||
success = false;
|
||||
}
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -2886,7 +2931,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (providersToDestroy.contains(element.getProvider())) {
|
||||
try {
|
||||
if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network), "VirtualRouter")) {
|
||||
s_logger.warn("Unable to complete destroy of the network elements due to element: " + element.getName() + " either doesn't exist or not enabled in the physical network " + getPhysicalNetworkId(network));
|
||||
s_logger.warn("Unable to complete destroy of the network elements due to element: " + element.getName() + " either doesn't exist or not enabled in the physical network "
|
||||
+ getPhysicalNetworkId(network));
|
||||
success = false;
|
||||
}
|
||||
|
||||
@ -2968,6 +3014,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* The rules here is only the same kind of rule, e.g. all load balancing rules or all port forwarding rules */
|
||||
public boolean applyRules(List<? extends FirewallRule> rules, boolean continueOnError) throws ResourceUnavailableException {
|
||||
@ -3211,7 +3258,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
_networksDao.update(network.getId(), network);
|
||||
}
|
||||
|
||||
|
||||
// This method re-programs the rules/ips for existing network
|
||||
protected boolean reprogramNetworkRules(long networkId, Account caller, NetworkVO network) throws ResourceUnavailableException {
|
||||
boolean success = true;
|
||||
@ -3271,7 +3317,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return _networksDao.getActiveNicsIn(networkId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId) {
|
||||
|
||||
@ -3283,7 +3328,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Service service = Service.getService(instance.getService());
|
||||
NetworkElement element = getElementImplementingProvider(instance.getProvider());
|
||||
if (element != null) {
|
||||
Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();;
|
||||
Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();
|
||||
;
|
||||
if (elementCapabilities != null) {
|
||||
networkCapabilities.put(service, elementCapabilities.get(service));
|
||||
}
|
||||
@ -3307,7 +3353,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
NetworkElement element = getElementImplementingProvider(provider);
|
||||
if (element != null) {
|
||||
Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();;
|
||||
Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();
|
||||
;
|
||||
|
||||
if (elementCapabilities == null || !elementCapabilities.containsKey(service)) {
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider);
|
||||
@ -3333,13 +3380,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new InvalidParameterValueException("Service " + service.getName() + " is not supported by the network offering " + offering);
|
||||
}
|
||||
|
||||
//FIXME - in post 3.0 we are going to support multiple providers for the same service per network offering, so we have to calculate capabilities for all of them
|
||||
// FIXME - in post 3.0 we are going to support multiple providers for the same service per network offering, so
|
||||
// we have to calculate capabilities for all of them
|
||||
String provider = providers.get(0);
|
||||
|
||||
//FIXME we return the capabilities of the first provider of the service - what if we have multiple providers for same Service?
|
||||
// FIXME we return the capabilities of the first provider of the service - what if we have multiple providers
|
||||
// for same Service?
|
||||
NetworkElement element = getElementImplementingProvider(provider);
|
||||
if (element != null) {
|
||||
Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();;
|
||||
Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();
|
||||
;
|
||||
|
||||
if (elementCapabilities == null || !elementCapabilities.containsKey(service)) {
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider);
|
||||
@ -3439,7 +3489,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return guestNic.getIp4Address();
|
||||
}
|
||||
|
||||
|
||||
private Nic getNicInNetworkIncludingRemoved(long vmId, long networkId) {
|
||||
return _nicDao.findByInstanceIdAndNetworkIdIncludingRemoved(networkId, vmId);
|
||||
}
|
||||
@ -3468,7 +3517,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (createNetwork) {
|
||||
List<? extends NetworkOffering> offerings = _configMgr.listNetworkOfferings(TrafficType.Guest, false);
|
||||
PhysicalNetwork physicalNetwork = translateZoneIdToPhysicalNetwork(zoneId);
|
||||
network = createGuestNetwork(offerings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, null, owner, false, null, physicalNetwork, zoneId, ACLType.Account, null);
|
||||
network = createGuestNetwork(offerings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, null, owner, false, null, physicalNetwork, zoneId,
|
||||
ACLType.Account, null);
|
||||
|
||||
if (network == null) {
|
||||
s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId);
|
||||
@ -3578,7 +3628,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return elements;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId) {
|
||||
boolean netscalerInNetwork = isProviderForNetwork(Network.Provider.Netscaler, networkId);
|
||||
@ -3649,7 +3698,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
// remote access vpn can be enabled only for static nat ip, so this part should never be executed under normal
|
||||
// conditions
|
||||
// only when ip address failed to be cleaned up as a part of account destroy and was marked as Releasing, this part of
|
||||
// only when ip address failed to be cleaned up as a part of account destroy and was marked as Releasing, this
|
||||
// part of
|
||||
// the code would be triggered
|
||||
s_logger.debug("Cleaning up remote access vpns as a part of public IP id=" + ipId + " release...");
|
||||
try {
|
||||
@ -3781,7 +3831,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_UPDATE, eventDescription = "updating network", async = true)
|
||||
public Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser, String domainSuffix, Long networkOfferingId) {
|
||||
boolean restartNetwork = false;
|
||||
@ -3881,7 +3932,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
|
||||
//1) Shutdown all the elements and cleanup all the rules. Don't allow to shutdown network in intermediate states - Shutdown and Implementing
|
||||
// 1) Shutdown all the elements and cleanup all the rules. Don't allow to shutdown network in intermediate
|
||||
// states - Shutdown and Implementing
|
||||
boolean validStateToShutdown = (network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup || network.getState() == Network.State.Allocated);
|
||||
if (restartNetwork) {
|
||||
if (validStateToShutdown) {
|
||||
@ -3962,7 +4014,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Network network = getNetwork(networkId);
|
||||
NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
|
||||
// For default userVm Default network and domR guest/public network, get rate information from the service offering; for other situations get information
|
||||
// For default userVm Default network and domR guest/public network, get rate information from the service
|
||||
// offering; for other situations get information
|
||||
// from the network offering
|
||||
boolean isUserVmsDefaultNetwork = false;
|
||||
boolean isDomRGuestOrPublicNetwork = false;
|
||||
@ -4031,7 +4084,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private String getZoneNetworkDomain(long zoneId) {
|
||||
return _dcDao.findById(zoneId).getDomain();
|
||||
}
|
||||
@ -4103,7 +4155,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
// static NAT rules can not programmed unless IP is associated with network service provider, so run IP association for
|
||||
// static NAT rules can not programmed unless IP is associated with network service provider, so run IP
|
||||
// association for
|
||||
// the network so as to ensure IP is associated before applying rules (in add state)
|
||||
applyIpAssociations(network, false, continueOnError, publicIps);
|
||||
|
||||
@ -4261,7 +4314,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return canIpsUseOffering(publicIps, newNetworkOfferingId);
|
||||
}
|
||||
|
||||
|
||||
protected boolean canUpgradeProviders(long oldNetworkOfferingId, long newNetworkOfferingId) {
|
||||
// list of services and providers should be the same
|
||||
Map<Service, Set<Provider>> newServices = getNetworkOfferingServiceProvidersMap(newNetworkOfferingId);
|
||||
@ -4454,11 +4506,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (newVnetRangeString != null) {
|
||||
if (zone.getNetworkType() == NetworkType.Basic
|
||||
|| (zone.getNetworkType() == NetworkType.Advanced && zone.isSecurityGroupEnabled())) {
|
||||
throw new InvalidParameterValueException("Can't add vnet range to the physical network in the zone that supports " + zone.getNetworkType() + " network, Security Group enabled: "+ zone.isSecurityGroupEnabled());
|
||||
throw new InvalidParameterValueException("Can't add vnet range to the physical network in the zone that supports " + zone.getNetworkType() + " network, Security Group enabled: "
|
||||
+ zone.isSecurityGroupEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tags != null && tags.size() > 1) {
|
||||
throw new InvalidParameterException("Unable to support more than one tag on network yet");
|
||||
}
|
||||
@ -4545,7 +4597,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
network.setVnet(newVnetRangeString);
|
||||
}
|
||||
|
||||
|
||||
_physicalNetworkDao.update(id, network);
|
||||
|
||||
if (replaceVnet) {
|
||||
@ -4554,7 +4605,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
for (Pair<Integer, Integer> vnetToAdd : vnetsToAdd) {
|
||||
s_logger.debug("Adding vnet range " + vnetToAdd.first() + "-" + vnetToAdd.second() + " for the physicalNetwork id= "+id +" and zone id=" + network.getDataCenterId() + " as a part of updatePhysicalNetwork call");
|
||||
s_logger.debug("Adding vnet range " + vnetToAdd.first() + "-" + vnetToAdd.second() + " for the physicalNetwork id= " + id + " and zone id=" + network.getDataCenterId()
|
||||
+ " as a part of updatePhysicalNetwork call");
|
||||
_dcDao.addVnet(network.getDataCenterId(), network.getId(), vnetToAdd.first(), vnetToAdd.second());
|
||||
}
|
||||
|
||||
@ -4578,7 +4630,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
checkIfPhysicalNetworkIsDeletable(physicalNetworkId);
|
||||
|
||||
|
||||
// delete vlans for this zone
|
||||
List<VlanVO> vlans = _vlanDao.listVlansByPhysicalNetworkId(physicalNetworkId);
|
||||
for (VlanVO vlan : vlans) {
|
||||
@ -4602,10 +4653,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
// delete traffic types
|
||||
_pNTrafficTypeDao.deleteTrafficTypes(physicalNetworkId);
|
||||
|
||||
|
||||
boolean success = _physicalNetworkDao.remove(physicalNetworkId);
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -4625,11 +4674,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
networks.add(2, "there are networks associated to this physical network");
|
||||
tablesToCheck.add(networks);
|
||||
|
||||
/*List<String> privateIP = new ArrayList<String>();
|
||||
privateIP.add(0, "op_dc_ip_address_alloc");
|
||||
privateIP.add(1, "data_center_id");
|
||||
privateIP.add(2, "there are private IP addresses allocated for this zone");
|
||||
tablesToCheck.add(privateIP);*/
|
||||
/*
|
||||
* List<String> privateIP = new ArrayList<String>();
|
||||
* privateIP.add(0, "op_dc_ip_address_alloc");
|
||||
* privateIP.add(1, "data_center_id");
|
||||
* privateIP.add(2, "there are private IP addresses allocated for this zone");
|
||||
* tablesToCheck.add(privateIP);
|
||||
*/
|
||||
|
||||
List<String> publicIP = new ArrayList<String>();
|
||||
publicIP.add(0, "user_ip_address");
|
||||
@ -4637,8 +4688,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
publicIP.add(2, "there are public IP addresses allocated for this physical network");
|
||||
tablesToCheck.add(publicIP);
|
||||
|
||||
|
||||
|
||||
for (List<String> table : tablesToCheck) {
|
||||
String tableName = table.get(0);
|
||||
String column = table.get(1);
|
||||
@ -4982,7 +5031,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return getPhysicalNetworkServiceProvider(providerId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long findPhysicalNetworkId(long zoneId, String tag) {
|
||||
List<PhysicalNetworkVO> pNtwks = _physicalNetworkDao.listByZone(zoneId);
|
||||
@ -5046,7 +5094,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return offeringsToReturn;
|
||||
}
|
||||
|
||||
|
||||
private boolean cleanupNetworkResources(long networkId, Account caller, long callerUserId) {
|
||||
boolean success = true;
|
||||
Network network = getNetwork(networkId);
|
||||
@ -5107,7 +5154,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
private boolean shutdownNetworkResources(long networkId, Account caller, long callerUserId) {
|
||||
// This method cleans up network rules on the backend w/o touching them in the DB
|
||||
boolean success = true;
|
||||
@ -5265,7 +5311,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new InvalidParameterValueException("Physical Network id=" + physicalNetworkId + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
|
||||
Networks.TrafficType trafficType = null;
|
||||
if (trafficTypeStr != null && !trafficTypeStr.isEmpty()) {
|
||||
try {
|
||||
@ -5278,7 +5323,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (_pNTrafficTypeDao.isTrafficTypeSupported(physicalNetworkId, trafficType)) {
|
||||
throw new CloudRuntimeException("This physical network already supports the traffic type: " + trafficType);
|
||||
}
|
||||
//For Storage, Control, Management, Public check if the zone has any other physical network with this traffictype already present
|
||||
// For Storage, Control, Management, Public check if the zone has any other physical network with this
|
||||
// traffictype already present
|
||||
// If yes, we cant add these traffics to one more physical network in the zone.
|
||||
|
||||
if (TrafficType.isSystemNetwork(trafficType) || TrafficType.Public.equals(trafficType) || TrafficType.Storage.equals(trafficType)) {
|
||||
@ -5290,7 +5336,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (TrafficType.Storage.equals(trafficType)) {
|
||||
List<SecondaryStorageVmVO> ssvms = _stnwMgr.getSSVMWithNoStorageNetwork(network.getDataCenterId());
|
||||
if (!ssvms.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder("Cannot add " + trafficType + " traffic type as there are below secondary storage vm still running. Please stop them all and add Storage traffic type again, then destory them all to allow CloudStack recreate them with storage network(If you have added storage network ip range)");
|
||||
StringBuilder sb = new StringBuilder(
|
||||
"Cannot add "
|
||||
+ trafficType
|
||||
+ " traffic type as there are below secondary storage vm still running. Please stop them all and add Storage traffic type again, then destory them all to allow CloudStack recreate them with storage network(If you have added storage network ip range)");
|
||||
sb.append("SSVMs:");
|
||||
for (SecondaryStorageVmVO ssvm : ssvms) {
|
||||
sb.append(ssvm.getInstanceName()).append(":").append(ssvm.getState());
|
||||
@ -5321,15 +5370,20 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
private String getDefaultXenNetworkLabel(TrafficType trafficType) {
|
||||
String xenLabel = null;
|
||||
switch (trafficType) {
|
||||
case Public: xenLabel = _configDao.getValue(Config.XenPublicNetwork.key());
|
||||
case Public:
|
||||
xenLabel = _configDao.getValue(Config.XenPublicNetwork.key());
|
||||
break;
|
||||
case Guest: xenLabel = _configDao.getValue(Config.XenGuestNetwork.key());
|
||||
case Guest:
|
||||
xenLabel = _configDao.getValue(Config.XenGuestNetwork.key());
|
||||
break;
|
||||
case Storage: xenLabel = _configDao.getValue(Config.XenStorageNetwork1.key());
|
||||
case Storage:
|
||||
xenLabel = _configDao.getValue(Config.XenStorageNetwork1.key());
|
||||
break;
|
||||
case Management: xenLabel = _configDao.getValue(Config.XenPrivateNetwork.key());
|
||||
case Management:
|
||||
xenLabel = _configDao.getValue(Config.XenPrivateNetwork.key());
|
||||
break;
|
||||
case Control: xenLabel = "cloud_link_local_network";
|
||||
case Control:
|
||||
xenLabel = "cloud_link_local_network";
|
||||
break;
|
||||
}
|
||||
return xenLabel;
|
||||
@ -5398,7 +5452,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return _pNTrafficTypeDao.listBy(physicalNetworkId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType) {
|
||||
|
||||
@ -5559,7 +5612,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
private boolean isProviderEnabled(PhysicalNetworkServiceProvider provider) {
|
||||
if (provider == null || provider.getState() != PhysicalNetworkServiceProvider.State.Enabled) { //TODO: check for other states: Shutdown?
|
||||
if (provider == null || provider.getState() != PhysicalNetworkServiceProvider.State.Enabled) { // TODO: check
|
||||
// for other states: Shutdown?
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -5592,7 +5646,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getNetworkTag(HypervisorType hType, Network network) {
|
||||
// no network tag for control traffic type
|
||||
@ -5631,7 +5684,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
physicalNetworkId = pNtwks.get(0).getId();
|
||||
} else {
|
||||
// locate physicalNetwork with supported traffic type
|
||||
//We can make this assumptions based on the fact that Public/Management/Control traffic types are supported only in one physical network in the zone in 3.0
|
||||
// We can make this assumptions based on the fact that Public/Management/Control traffic types are
|
||||
// supported only in one physical network in the zone in 3.0
|
||||
for (PhysicalNetworkVO pNtwk : pNtwks) {
|
||||
if (_pNTrafficTypeDao.isTrafficTypeSupported(pNtwk.getId(), network.getTrafficType())) {
|
||||
physicalNetworkId = pNtwk.getId();
|
||||
@ -5643,7 +5697,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NetworkVO getExclusiveGuestNetwork(long zoneId) {
|
||||
List<NetworkVO> networks = _networksDao.listBy(Account.ACCOUNT_ID_SYSTEM, zoneId, GuestType.Shared, TrafficType.Guest);
|
||||
@ -5700,7 +5753,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
for (NetworkOfferingServiceMapVO serviceMap : servicesMap) {
|
||||
if (svcProviders.containsKey(serviceMap.getService())) {
|
||||
//FIXME - right now we pick up the first provider from the list, need to add more logic based on provider load, etc
|
||||
// FIXME - right now we pick up the first provider from the list, need to add more logic based on
|
||||
// provider load, etc
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -5824,7 +5878,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
servicesSet.delete(servicesSet.toString().length() - 2, servicesSet.toString().length());
|
||||
|
||||
throw new InvalidParameterValueException("Cannot enable subset of Services, Please specify the complete list of Services: " + servicesSet.toString() + " for Service Provider " + provider.getName());
|
||||
throw new InvalidParameterValueException("Cannot enable subset of Services, Please specify the complete list of Services: " + servicesSet.toString() + " for Service Provider "
|
||||
+ provider.getName());
|
||||
}
|
||||
}
|
||||
for (Service service : enabledServices) {
|
||||
@ -5929,13 +5984,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
String value = serviceCapabilities.get(cap);
|
||||
if (value == null || value.isEmpty()) {
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " doesn't have capability " + cap.getName() + " for element=" + element.getName() + " implementing Provider=" + provider.getName());
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " doesn't have capability " + cap.getName() + " for element=" + element.getName() + " implementing Provider="
|
||||
+ provider.getName());
|
||||
}
|
||||
|
||||
capValue = capValue.toLowerCase();
|
||||
|
||||
if (!value.contains(capValue)) {
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " doesn't support value " + capValue + " for capability " + cap.getName() + " for element=" + element.getName() + " implementing Provider=" + provider.getName());
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " doesn't support value " + capValue + " for capability " + cap.getName() + " for element=" + element.getName()
|
||||
+ " implementing Provider=" + provider.getName());
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedServiceException("Unable to find network element for provider " + provider.getName());
|
||||
|
||||
@ -56,4 +56,5 @@ public interface FirewallRulesDao extends GenericDao<FirewallRuleVO, Long> {
|
||||
List<FirewallRuleVO> listByIpAndNotRevoked(long ipAddressId);
|
||||
|
||||
long countRulesByIpId(long sourceIpId);
|
||||
|
||||
}
|
||||
|
||||
@ -39,7 +39,8 @@ import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Local(value=FirewallRulesDao.class) @DB(txn=false)
|
||||
@Local(value = FirewallRulesDao.class)
|
||||
@DB(txn = false)
|
||||
public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> implements FirewallRulesDao {
|
||||
|
||||
protected final SearchBuilder<FirewallRuleVO> AllFieldsSearch;
|
||||
@ -196,7 +197,8 @@ public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> i
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public FirewallRuleVO persist(FirewallRuleVO firewallRule) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
@ -208,7 +210,6 @@ public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> i
|
||||
return dbfirewallRule;
|
||||
}
|
||||
|
||||
|
||||
public void saveSourceCidrs(FirewallRuleVO firewallRule, List<String> cidrList) {
|
||||
if (cidrList == null) {
|
||||
return;
|
||||
@ -216,7 +217,6 @@ public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> i
|
||||
_firewallRulesCidrsDao.persist(firewallRule.getId(), cidrList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<FirewallRuleVO> listByIpPurposeAndProtocolAndNotRevoked(long ipAddressId, Integer startPort, Integer endPort, String protocol, FirewallRule.Purpose purpose) {
|
||||
SearchCriteria<FirewallRuleVO> sc = NotRevokedSearch.create();
|
||||
@ -270,4 +270,5 @@ public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> i
|
||||
sc.setParameters("ipAddressId", sourceIpId);
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,9 +25,15 @@ import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface LoadBalancerDao extends GenericDao<LoadBalancerVO, Long> {
|
||||
List<Long> listInstancesByLoadBalancer(long loadBalancerId);
|
||||
|
||||
List<LoadBalancerVO> listByIpAddress(long ipAddressId);
|
||||
|
||||
LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort);
|
||||
|
||||
LoadBalancerVO findByAccountAndName(Long accountId, String name);
|
||||
|
||||
List<LoadBalancerVO> listByNetworkId(long networkId);
|
||||
|
||||
List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId);
|
||||
|
||||
}
|
||||
|
||||
@ -134,4 +134,5 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> im
|
||||
sc.setParameters("state", State.Add.toString(), State.Revoke.toString());
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -91,4 +91,5 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long> {
|
||||
boolean update(Long networkId, NetworkVO network, Map<String, String> serviceProviderMap);
|
||||
|
||||
List<NetworkVO> listByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
}
|
||||
|
||||
@ -49,7 +49,8 @@ import com.cloud.utils.db.SequenceFetcher;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Local(value=NetworkDao.class) @DB(txn=false)
|
||||
@Local(value = NetworkDao.class)
|
||||
@DB(txn = false)
|
||||
public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements NetworkDao {
|
||||
final SearchBuilder<NetworkVO> AllFieldsSearch;
|
||||
final SearchBuilder<NetworkVO> AccountSearch;
|
||||
@ -109,7 +110,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
AccountNetworkSearch.join("networkSearch", mapJoin, AccountNetworkSearch.entity().getId(), mapJoin.entity().getNetworkId(), JoinBuilder.JoinType.INNER);
|
||||
AccountNetworkSearch.done();
|
||||
|
||||
|
||||
ZoneBroadcastUriSearch = createSearchBuilder();
|
||||
ZoneBroadcastUriSearch.and("dataCenterId", ZoneBroadcastUriSearch.entity().getDataCenterId(), Op.EQ);
|
||||
ZoneBroadcastUriSearch.and("broadcastUri", ZoneBroadcastUriSearch.entity().getBroadcastUri(), Op.EQ);
|
||||
@ -128,7 +128,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
CountByOfferingId.and("removed", CountByOfferingId.entity().getRemoved(), Op.NULL);
|
||||
CountByOfferingId.done();
|
||||
|
||||
|
||||
PhysicalNetworkSearch = createSearchBuilder();
|
||||
PhysicalNetworkSearch.and("physicalNetworkId", PhysicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||
PhysicalNetworkSearch.done();
|
||||
@ -184,7 +183,8 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public NetworkVO persist(NetworkVO network, boolean gc, Map<String, String> serviceProviderMap) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
@ -203,8 +203,8 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
return newNetwork;
|
||||
}
|
||||
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public boolean update(Long networkId, NetworkVO network, Map<String, String> serviceProviderMap) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
@ -395,4 +395,5 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -79,23 +79,32 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
public class CloudZonesNetworkElement extends AdapterBase implements NetworkElement, UserDataServiceProvider {
|
||||
private static final Logger s_logger = Logger.getLogger(CloudZonesNetworkElement.class);
|
||||
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject NetworkDao _networkConfigDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject VirtualNetworkApplianceManager _routerMgr;
|
||||
@Inject UserVmManager _userVmMgr;
|
||||
@Inject UserVmDao _userVmDao;
|
||||
@Inject DomainRouterDao _routerDao;
|
||||
@Inject ConfigurationManager _configMgr;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject AgentManager _agentManager;
|
||||
@Inject ServiceOfferingDao _serviceOfferingDao;
|
||||
@Inject
|
||||
NetworkDao _networkConfigDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
VirtualNetworkApplianceManager _routerMgr;
|
||||
@Inject
|
||||
UserVmManager _userVmMgr;
|
||||
@Inject
|
||||
UserVmDao _userVmDao;
|
||||
@Inject
|
||||
DomainRouterDao _routerDao;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
AgentManager _agentManager;
|
||||
@Inject
|
||||
ServiceOfferingDao _serviceOfferingDao;
|
||||
|
||||
private boolean canHandle(DeployDestination dest, TrafficType trafficType) {
|
||||
DataCenterVO dc = (DataCenterVO) dest.getDataCenter();
|
||||
@ -112,7 +121,8 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
|
||||
}
|
||||
|
||||
@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(dest, offering.getTrafficType())) {
|
||||
return false;
|
||||
}
|
||||
@ -121,7 +131,8 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
InsufficientCapacityException, ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -219,7 +230,8 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
|
||||
|
||||
cmds.addCommand(
|
||||
"vmdata",
|
||||
generateVmDataCommand(nic.getIp4Address(), userData, serviceOffering, zoneName, nic.getIp4Address(), uservm.getVirtualMachine().getHostName(), uservm.getVirtualMachine().getInstanceName(), uservm.getId(), sshPublicKey));
|
||||
generateVmDataCommand(nic.getIp4Address(), userData, serviceOffering, zoneName, nic.getIp4Address(), uservm.getVirtualMachine().getHostName(), uservm.getVirtualMachine().getInstanceName(),
|
||||
uservm.getId(), sshPublicKey));
|
||||
try {
|
||||
_agentManager.send(dest.getHost().getId(), cmds);
|
||||
} catch (OperationTimedoutException e) {
|
||||
@ -247,4 +259,5 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
|
||||
public boolean verifyServicesCombination(List<String> services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -55,7 +55,8 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
@Local(value = NetworkElement.class)
|
||||
public class ExternalDhcpElement extends AdapterBase implements NetworkElement, DhcpServiceProvider {
|
||||
private static final Logger s_logger = Logger.getLogger(ExternalDhcpElement.class);
|
||||
@Inject ExternalDhcpManager _dhcpMgr;
|
||||
@Inject
|
||||
ExternalDhcpManager _dhcpMgr;
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType networkType) {
|
||||
@ -114,7 +115,6 @@ public class ExternalDhcpElement extends AdapterBase implements NetworkElement,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean destroy(Network network) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
return true;
|
||||
|
||||
@ -41,7 +41,6 @@ import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
@ -57,15 +56,15 @@ import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceManager;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.network.NetworkExternalLoadBalancerVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceVO.LBDeviceState;
|
||||
import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkExternalLoadBalancerVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkVO;
|
||||
@ -96,17 +95,28 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(F5ExternalLoadBalancerElement.class);
|
||||
|
||||
@Inject NetworkManager _networkManager;
|
||||
@Inject ConfigurationManager _configMgr;
|
||||
@Inject NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject ExternalLoadBalancerDeviceDao _lbDeviceDao;
|
||||
@Inject NetworkExternalLoadBalancerDao _networkLBDao;
|
||||
@Inject NetworkDao _networkDao;
|
||||
@Inject HostDetailsDao _detailsDao;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
ExternalLoadBalancerDeviceDao _lbDeviceDao;
|
||||
@Inject
|
||||
NetworkExternalLoadBalancerDao _networkLBDao;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
HostDetailsDao _detailsDao;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
|
||||
private boolean canHandle(Network config) {
|
||||
if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) {
|
||||
@ -114,12 +124,12 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
|
||||
return false;
|
||||
}
|
||||
|
||||
return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) &&
|
||||
_ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.F5BigIp));
|
||||
return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) && _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.F5BigIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientNetworkCapacityException {
|
||||
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
InsufficientNetworkCapacityException {
|
||||
|
||||
if (!canHandle(guestConfig)) {
|
||||
return false;
|
||||
@ -128,13 +138,15 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
|
||||
try {
|
||||
return manageGuestNetworkWithExternalLoadBalancer(true, guestConfig);
|
||||
} catch (InsufficientCapacityException capacityException) {
|
||||
// TODO: handle out of capacity exception in graceful manner when multiple providers are avaialble for the network
|
||||
// TODO: handle out of capacity exception in graceful manner when multiple providers are avaialble for the
|
||||
// network
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.commands.AddExternalFirewallCmd;
|
||||
@ -41,8 +42,8 @@ import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
@ -54,14 +55,14 @@ import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.ExternalFirewallDeviceManagerImpl;
|
||||
import com.cloud.network.ExternalFirewallDeviceVO;
|
||||
import com.cloud.network.ExternalFirewallDeviceVO.FirewallDeviceState;
|
||||
import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.ExternalFirewallDeviceManagerImpl;
|
||||
import com.cloud.network.ExternalFirewallDeviceVO;
|
||||
import com.cloud.network.NetworkExternalFirewallVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
@ -98,19 +99,32 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject NetworkManager _networkManager;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject ConfigurationManager _configMgr;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject NetworkDao _networksDao;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject ExternalFirewallDeviceDao _fwDevicesDao;
|
||||
@Inject NetworkExternalFirewallDao _networkFirewallDao;
|
||||
@Inject NetworkDao _networkDao;
|
||||
@Inject NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject HostDetailsDao _hostDetailDao;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject
|
||||
NetworkDao _networksDao;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
ExternalFirewallDeviceDao _fwDevicesDao;
|
||||
@Inject
|
||||
NetworkExternalFirewallDao _networkFirewallDao;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
HostDetailsDao _hostDetailDao;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
|
||||
private boolean canHandle(Network network, Service service) {
|
||||
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
|
||||
@ -135,7 +149,8 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientNetworkCapacityException {
|
||||
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
InsufficientNetworkCapacityException {
|
||||
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
|
||||
|
||||
// don't have to implement network is Basic zone
|
||||
@ -151,13 +166,15 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
try {
|
||||
return manageGuestNetworkWithExternalFirewall(true, network);
|
||||
} catch (InsufficientCapacityException capacityException) {
|
||||
// TODO: handle out of capacity exception in more gracefule manner when multiple providers are present for the network
|
||||
// TODO: handle out of capacity exception in more gracefule manner when multiple providers are present for
|
||||
// the network
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -317,7 +334,8 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated // should use more generic addNetworkDevice command to add firewall
|
||||
@Deprecated
|
||||
// should use more generic addNetworkDevice command to add firewall
|
||||
public Host addExternalFirewall(AddExternalFirewallCmd cmd) {
|
||||
Long zoneId = cmd.getZoneId();
|
||||
DataCenterVO zone = null;
|
||||
@ -351,7 +369,8 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated // should use more generic listNetworkDevice command
|
||||
@Deprecated
|
||||
// should use more generic listNetworkDevice command
|
||||
public List<Host> listExternalFirewalls(ListExternalFirewallsCmd cmd) {
|
||||
List<Host> firewallHosts = new ArrayList<Host>();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
||||
@ -31,15 +31,12 @@ import javax.ejb.Local;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.AgentManager.OnError;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.agent.api.to.StaticNatRuleTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.commands.AddNetscalerLoadBalancerCmd;
|
||||
import com.cloud.api.commands.ConfigureNetscalerLoadBalancerCmd;
|
||||
@ -51,7 +48,6 @@ import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
@ -67,9 +63,9 @@ import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceManager;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.ExternalLoadBalancerDeviceVO.LBDeviceState;
|
||||
import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
@ -90,8 +86,8 @@ import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
||||
import com.cloud.network.resource.NetscalerResource;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.LbStickinessMethod;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.LbStickinessMethod;
|
||||
import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
@ -109,23 +105,37 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, NetscalerLoadBalancerElementService, ExternalLoadBalancerDeviceManager, IpDeployer, StaticNatServiceProvider {
|
||||
public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, NetscalerLoadBalancerElementService, ExternalLoadBalancerDeviceManager, IpDeployer,
|
||||
StaticNatServiceProvider {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(NetscalerElement.class);
|
||||
|
||||
@Inject NetworkManager _networkManager;
|
||||
@Inject ConfigurationManager _configMgr;
|
||||
@Inject NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject ExternalLoadBalancerDeviceDao _lbDeviceDao;
|
||||
@Inject NetworkExternalLoadBalancerDao _networkLBDao;
|
||||
@Inject PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject NetworkDao _networkDao;
|
||||
@Inject HostDetailsDao _detailsDao;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
ExternalLoadBalancerDeviceDao _lbDeviceDao;
|
||||
@Inject
|
||||
NetworkExternalLoadBalancerDao _networkLBDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
HostDetailsDao _detailsDao;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
|
||||
private boolean canHandle(Network config, Service service) {
|
||||
DataCenter zone = _dcDao.findById(config.getDataCenterId());
|
||||
@ -137,8 +147,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
||||
return false;
|
||||
}
|
||||
|
||||
return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) &&
|
||||
_ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), service, Network.Provider.Netscaler));
|
||||
return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) && _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), service, Network.Provider.Netscaler));
|
||||
}
|
||||
|
||||
private boolean isBasicZoneNetwok(Network config) {
|
||||
@ -147,7 +156,8 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientNetworkCapacityException {
|
||||
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
InsufficientNetworkCapacityException {
|
||||
|
||||
if (!canHandle(guestConfig, Service.Lb)) {
|
||||
return false;
|
||||
@ -162,7 +172,8 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -256,7 +267,6 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
||||
staticNatCapabilities.put(Capability.ElasticIp, "true");
|
||||
capabilities.put(Service.StaticNat, staticNatCapabilities);
|
||||
|
||||
|
||||
// TODO - Murali, please put correct capabilities here
|
||||
Map<Capability, String> firewallCapabilities = new HashMap<Capability, String>();
|
||||
firewallCapabilities.put(Capability.TrafficStatistics, "per public ip");
|
||||
@ -489,7 +499,8 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
||||
public boolean isReady(PhysicalNetworkServiceProvider provider) {
|
||||
List<ExternalLoadBalancerDeviceVO> lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), Provider.Netscaler.getName());
|
||||
|
||||
// true if at-least one Netscaler device is added in to physical network and is in configured (in enabled state) state
|
||||
// true if at-least one Netscaler device is added in to physical network and is in configured (in enabled state)
|
||||
// state
|
||||
if (lbDevices != null && !lbDevices.isEmpty()) {
|
||||
for (ExternalLoadBalancerDeviceVO lbDevice : lbDevices) {
|
||||
if (lbDevice.getState() == LBDeviceState.Enabled) {
|
||||
@ -652,4 +663,5 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -46,8 +46,10 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
public class OvsElement extends AdapterBase implements NetworkElement {
|
||||
@Inject OvsNetworkManager _ovsVlanMgr;
|
||||
@Inject OvsTunnelManager _ovsTunnelMgr;
|
||||
@Inject
|
||||
OvsNetworkManager _ovsVlanMgr;
|
||||
@Inject
|
||||
OvsTunnelManager _ovsTunnelMgr;
|
||||
|
||||
@Override
|
||||
public boolean destroy(Network network)
|
||||
@ -114,7 +116,6 @@ public class OvsElement extends AdapterBase implements NetworkElement {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shutdown(Network network, ReservationContext context, boolean cleanup)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
@ -54,14 +54,14 @@ import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDao;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.rules.LbStickinessMethod;
|
||||
import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.LbStickinessMethod;
|
||||
import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
@ -88,28 +88,43 @@ import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider, UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider, LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer {
|
||||
public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider, UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider,
|
||||
LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualRouterElement.class);
|
||||
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject NetworkDao _networksDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject LoadBalancingRulesManager _lbMgr;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject VirtualNetworkApplianceManager _routerMgr;
|
||||
@Inject ConfigurationManager _configMgr;
|
||||
@Inject RulesManager _rulesMgr;
|
||||
@Inject UserVmManager _userVmMgr;
|
||||
@Inject UserVmDao _userVmDao;
|
||||
@Inject DomainRouterDao _routerDao;
|
||||
@Inject LoadBalancerDao _lbDao;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject VirtualRouterProviderDao _vrProviderDao;
|
||||
@Inject
|
||||
NetworkDao _networksDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
LoadBalancingRulesManager _lbMgr;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject
|
||||
VirtualNetworkApplianceManager _routerMgr;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
RulesManager _rulesMgr;
|
||||
@Inject
|
||||
UserVmManager _userVmMgr;
|
||||
@Inject
|
||||
UserVmDao _userVmDao;
|
||||
@Inject
|
||||
DomainRouterDao _routerDao;
|
||||
@Inject
|
||||
LoadBalancerDao _lbDao;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
VirtualRouterProviderDao _vrProviderDao;
|
||||
|
||||
protected boolean canHandle(Network network, Service service) {
|
||||
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(network);
|
||||
@ -137,7 +152,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
}
|
||||
|
||||
@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 (offering.isSystemOnly()) {
|
||||
return false;
|
||||
}
|
||||
@ -150,9 +166,9 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@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 (vm.getType() != VirtualMachine.Type.User) {
|
||||
return false;
|
||||
}
|
||||
@ -196,6 +212,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function detects numbers like 12 ,32h ,42m .. etc,. 1) plain
|
||||
* number like 12 2) time or tablesize like 12h, 34m, 45k, 54m , here
|
||||
@ -324,7 +341,6 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] applyVpnUsers(RemoteAccessVpn vpn, List<? extends VpnUser> users) throws ResourceUnavailableException {
|
||||
Network network = _networksDao.findById(vpn.getNetworkId());
|
||||
@ -410,20 +426,54 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
|
||||
method = new LbStickinessMethod(StickinessMethodType.LBCookieBased, "This is loadbalancer cookie based stickiness method.");
|
||||
method.addParam("cookie-name", false, "Cookie name passed in http header by the LB to the client.", false);
|
||||
method.addParam("mode", false, "Valid values: insert, rewrite, prefix. Default value: insert. In the insert mode cookie will be created by the LB. In other modes, cookie will be created by the server and LB modifies it.", false);
|
||||
method.addParam("nocache", false, "This option is recommended in conjunction with the insert mode when there is a cache between the client and HAProxy, as it ensures that a cacheable response will be tagged non-cacheable if a cookie needs to be inserted. This is important because if all persistence cookies are added on a cacheable home page for instance, then all customers will then fetch the page from an outer cache and will all share the same persistence cookie, leading to one server receiving much more traffic than others. See also the insert and postonly options. ", true);
|
||||
method.addParam("indirect", false, "When this option is specified in insert mode, cookies will only be added when the server was not reached after a direct access, which means that only when a server is elected after applying a load-balancing algorithm, or after a redispatch, then the cookie will be inserted. If the client has all the required information to connect to the same server next time, no further cookie will be inserted. In all cases, when the indirect option is used in insert mode, the cookie is always removed from the requests transmitted to the server. The persistence mechanism then becomes totally transparent from the application point of view.", true);
|
||||
method.addParam("postonly",false, "This option ensures that cookie insertion will only be performed on responses to POST requests. It is an alternative to the nocache option, because POST responses are not cacheable, so this ensures that the persistence cookie will never get cached.Since most sites do not need any sort of persistence before the first POST which generally is a login request, this is a very efficient method to optimize caching without risking to find a persistence cookie in the cache. See also the insert and nocache options.", true);
|
||||
method.addParam("domain",false, "This option allows to specify the domain at which a cookie is inserted. It requires exactly one parameter: a valid domain name. If the domain begins with a dot, the browser is allowed to use it for any host ending with that name. It is also possible to specify several domain names by invoking this option multiple times. Some browsers might have small limits on the number of domains, so be careful when doing that. For the record, sending 10 domains to MSIE 6 or Firefox 2 works as expected.", false);
|
||||
method.addParam("mode", false,
|
||||
"Valid values: insert, rewrite, prefix. Default value: insert. In the insert mode cookie will be created by the LB. In other modes, cookie will be created by the server and LB modifies it.", false);
|
||||
method.addParam(
|
||||
"nocache",
|
||||
false,
|
||||
"This option is recommended in conjunction with the insert mode when there is a cache between the client and HAProxy, as it ensures that a cacheable response will be tagged non-cacheable if a cookie needs to be inserted. This is important because if all persistence cookies are added on a cacheable home page for instance, then all customers will then fetch the page from an outer cache and will all share the same persistence cookie, leading to one server receiving much more traffic than others. See also the insert and postonly options. ",
|
||||
true);
|
||||
method.addParam(
|
||||
"indirect",
|
||||
false,
|
||||
"When this option is specified in insert mode, cookies will only be added when the server was not reached after a direct access, which means that only when a server is elected after applying a load-balancing algorithm, or after a redispatch, then the cookie will be inserted. If the client has all the required information to connect to the same server next time, no further cookie will be inserted. In all cases, when the indirect option is used in insert mode, the cookie is always removed from the requests transmitted to the server. The persistence mechanism then becomes totally transparent from the application point of view.",
|
||||
true);
|
||||
method.addParam(
|
||||
"postonly",
|
||||
false,
|
||||
"This option ensures that cookie insertion will only be performed on responses to POST requests. It is an alternative to the nocache option, because POST responses are not cacheable, so this ensures that the persistence cookie will never get cached.Since most sites do not need any sort of persistence before the first POST which generally is a login request, this is a very efficient method to optimize caching without risking to find a persistence cookie in the cache. See also the insert and nocache options.",
|
||||
true);
|
||||
method.addParam(
|
||||
"domain",
|
||||
false,
|
||||
"This option allows to specify the domain at which a cookie is inserted. It requires exactly one parameter: a valid domain name. If the domain begins with a dot, the browser is allowed to use it for any host ending with that name. It is also possible to specify several domain names by invoking this option multiple times. Some browsers might have small limits on the number of domains, so be careful when doing that. For the record, sending 10 domains to MSIE 6 or Firefox 2 works as expected.",
|
||||
false);
|
||||
methodList.add(method);
|
||||
|
||||
method = new LbStickinessMethod(StickinessMethodType.AppCookieBased, "This is App session based sticky method. Define session stickiness on an existing application cookie. It can be used only for a specific http traffic");
|
||||
method = new LbStickinessMethod(StickinessMethodType.AppCookieBased,
|
||||
"This is App session based sticky method. Define session stickiness on an existing application cookie. It can be used only for a specific http traffic");
|
||||
method.addParam("cookie-name", true, "This is the name of the cookie used by the application and which LB will have to learn for each new session", false);
|
||||
method.addParam("length", true, "This is the max number of characters that will be memorized and checked in each cookie value", false);
|
||||
method.addParam("holdtime", true, "This is the time after which the cookie will be removed from memory if unused. The value should be in the format Example : 20s or 30m or 4h or 5d . only seconds(s), minutes(m) hours(h) and days(d) are valid , cannot use th combinations like 20h30m. ", false);
|
||||
method.addParam("request-learn", false, "If this option is specified, then haproxy will be able to learn the cookie found in the request in case the server does not specify any in response. This is typically what happens with PHPSESSID cookies, or when haproxy's session expires before the application's session and the correct server is selected. It is recommended to specify this option to improve reliability", true);
|
||||
method.addParam("prefix", false, "When this option is specified, haproxy will match on the cookie prefix (or URL parameter prefix). The appsession value is the data following this prefix. Example : appsession ASPSESSIONID len 64 timeout 3h prefix This will match the cookie ASPSESSIONIDXXXX=XXXXX, the appsession value will be XXXX=XXXXX.", true);
|
||||
method.addParam("mode", false, "This option allows to change the URL parser mode. 2 modes are currently supported : - path-parameters : The parser looks for the appsession in the path parameters part (each parameter is separated by a semi-colon), which is convenient for JSESSIONID for example.This is the default mode if the option is not set. - query-string : In this mode, the parser will look for the appsession in the query string.", false);
|
||||
method.addParam(
|
||||
"holdtime",
|
||||
true,
|
||||
"This is the time after which the cookie will be removed from memory if unused. The value should be in the format Example : 20s or 30m or 4h or 5d . only seconds(s), minutes(m) hours(h) and days(d) are valid , cannot use th combinations like 20h30m. ",
|
||||
false);
|
||||
method.addParam(
|
||||
"request-learn",
|
||||
false,
|
||||
"If this option is specified, then haproxy will be able to learn the cookie found in the request in case the server does not specify any in response. This is typically what happens with PHPSESSID cookies, or when haproxy's session expires before the application's session and the correct server is selected. It is recommended to specify this option to improve reliability",
|
||||
true);
|
||||
method.addParam(
|
||||
"prefix",
|
||||
false,
|
||||
"When this option is specified, haproxy will match on the cookie prefix (or URL parameter prefix). The appsession value is the data following this prefix. Example : appsession ASPSESSIONID len 64 timeout 3h prefix This will match the cookie ASPSESSIONIDXXXX=XXXXX, the appsession value will be XXXX=XXXXX.",
|
||||
true);
|
||||
method.addParam(
|
||||
"mode",
|
||||
false,
|
||||
"This option allows to change the URL parser mode. 2 modes are currently supported : - path-parameters : The parser looks for the appsession in the path parameters part (each parameter is separated by a semi-colon), which is convenient for JSESSIONID for example.This is the default mode if the option is not set. - query-string : In this mode, the parser will look for the appsession in the query string.",
|
||||
false);
|
||||
methodList.add(method);
|
||||
|
||||
method = new LbStickinessMethod(StickinessMethodType.SourceBased, "This is source based Stickiness method, it can be used for any type of protocol.");
|
||||
@ -435,6 +485,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
String capability = gson.toJson(methodList);
|
||||
return capability;
|
||||
}
|
||||
|
||||
private static Map<Service, Map<Capability, String>> setCapabilities() {
|
||||
Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
|
||||
@ -676,7 +727,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
}
|
||||
}
|
||||
|
||||
//for Basic zone, add all Running routers - we have to send Dhcp/vmData/password info to them when network.dns.basiczone.updates is set to "all"
|
||||
// for Basic zone, add all Running routers - we have to send Dhcp/vmData/password info to them when
|
||||
// network.dns.basiczone.updates is set to "all"
|
||||
Long podId = dest.getPod().getId();
|
||||
if (isPodBased && _routerMgr.getDnsBasicZoneUpdate().equalsIgnoreCase("all")) {
|
||||
List<DomainRouterVO> allRunningRoutersOutsideThePod = _routerDao.findByNetworkOutsideThePod(network.getId(), podId, State.Running, Role.VIRTUAL_ROUTER);
|
||||
@ -724,7 +776,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||
}
|
||||
}
|
||||
|
||||
//for Basic zone, add all Running routers - we have to send Dhcp/vmData/password info to them when network.dns.basiczone.updates is set to "all"
|
||||
// for Basic zone, add all Running routers - we have to send Dhcp/vmData/password info to them when
|
||||
// network.dns.basiczone.updates is set to "all"
|
||||
Long podId = dest.getPod().getId();
|
||||
if (isPodBased && _routerMgr.getDnsBasicZoneUpdate().equalsIgnoreCase("all")) {
|
||||
List<DomainRouterVO> allRunningRoutersOutsideThePod = _routerDao.findByNetworkOutsideThePod(network.getId(), podId, State.Running, Role.VIRTUAL_ROUTER);
|
||||
|
||||
@ -137,13 +137,15 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
public FirewallRule createFirewallRule(FirewallRule rule) throws NetworkRuleConflictException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
return createFirewallRule(rule.getSourceIpAddressId(), caller, rule.getXid(), rule.getSourcePortStart() ,rule.getSourcePortEnd(), rule.getProtocol(), rule.getSourceCidrList(), rule.getIcmpCode(), rule.getIcmpType(), null, rule.getType());
|
||||
return createFirewallRule(rule.getSourceIpAddressId(), caller, rule.getXid(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getProtocol(), rule.getSourceCidrList(), rule.getIcmpCode(),
|
||||
rule.getIcmpType(), null, rule.getType());
|
||||
}
|
||||
|
||||
@DB
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_FIREWALL_OPEN, eventDescription = "creating firewall rule", create = true)
|
||||
public FirewallRule createFirewallRule(long ipAddrId, Account caller, String xId, Integer portStart,Integer portEnd, String protocol, List<String> sourceCidrList, Integer icmpCode, Integer icmpType, Long relatedRuleId, FirewallRule.FirewallRuleType type) throws NetworkRuleConflictException{
|
||||
public FirewallRule createFirewallRule(long ipAddrId, Account caller, String xId, Integer portStart, Integer portEnd, String protocol, List<String> sourceCidrList, Integer icmpCode, Integer icmpType,
|
||||
Long relatedRuleId, FirewallRule.FirewallRuleType type) throws NetworkRuleConflictException {
|
||||
IPAddressVO ipAddress = _ipAddressDao.findById(ipAddrId);
|
||||
|
||||
// Validate ip address
|
||||
@ -252,7 +254,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
continue; // Skips my own rule.
|
||||
}
|
||||
|
||||
boolean oneOfRulesIsFirewall = ((rule.getPurpose() == Purpose.Firewall || newRule.getPurpose() == Purpose.Firewall) && ((newRule.getPurpose() != rule.getPurpose()) || (!newRule.getProtocol().equalsIgnoreCase(rule.getProtocol()))));
|
||||
boolean oneOfRulesIsFirewall = ((rule.getPurpose() == Purpose.Firewall || newRule.getPurpose() == Purpose.Firewall) && ((newRule.getPurpose() != rule.getPurpose()) || (!newRule.getProtocol()
|
||||
.equalsIgnoreCase(rule.getProtocol()))));
|
||||
|
||||
// if both rules are firewall and their cidrs are different, we can skip port ranges verification
|
||||
boolean bothRulesFirewall = (rule.getPurpose() == newRule.getPurpose() && rule.getPurpose() == Purpose.Firewall);
|
||||
@ -287,7 +290,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
}
|
||||
|
||||
if (newRule.getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO) && newRule.getProtocol().equalsIgnoreCase(rule.getProtocol())) {
|
||||
if (newRule.getIcmpCode().longValue() == rule.getIcmpCode().longValue() && newRule.getIcmpType().longValue() == rule.getIcmpType().longValue() && newRule.getProtocol().equalsIgnoreCase(rule.getProtocol()) && duplicatedCidrs) {
|
||||
if (newRule.getIcmpCode().longValue() == rule.getIcmpCode().longValue() && newRule.getIcmpType().longValue() == rule.getIcmpType().longValue()
|
||||
&& newRule.getProtocol().equalsIgnoreCase(rule.getProtocol()) && duplicatedCidrs) {
|
||||
throw new InvalidParameterValueException("New rule conflicts with existing rule id=" + rule.getId());
|
||||
}
|
||||
}
|
||||
@ -295,7 +299,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
boolean notNullPorts = (newRule.getSourcePortStart() != null && newRule.getSourcePortEnd() != null && rule.getSourcePortStart() != null && rule.getSourcePortEnd() != null);
|
||||
if (!notNullPorts) {
|
||||
continue;
|
||||
} else if (!oneOfRulesIsFirewall && !(bothRulesFirewall && !duplicatedCidrs) && ((rule.getSourcePortStart().intValue() <= newRule.getSourcePortStart().intValue() && rule.getSourcePortEnd().intValue() >= newRule.getSourcePortStart().intValue())
|
||||
} else if (!oneOfRulesIsFirewall && !(bothRulesFirewall && !duplicatedCidrs)
|
||||
&& ((rule.getSourcePortStart().intValue() <= newRule.getSourcePortStart().intValue() && rule.getSourcePortEnd().intValue() >= newRule.getSourcePortStart().intValue())
|
||||
|| (rule.getSourcePortStart().intValue() <= newRule.getSourcePortEnd().intValue() && rule.getSourcePortEnd().intValue() >= newRule.getSourcePortEnd().intValue())
|
||||
|| (newRule.getSourcePortStart().intValue() <= rule.getSourcePortStart().intValue() && newRule.getSourcePortEnd().intValue() >= rule.getSourcePortStart().intValue())
|
||||
|| (newRule.getSourcePortStart().intValue() <= rule.getSourcePortEnd().intValue() && newRule.getSourcePortEnd().intValue() >= rule.getSourcePortEnd().intValue()))) {
|
||||
@ -316,7 +321,6 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validateFirewallRule(Account caller, IPAddressVO ipAddress, Integer portStart, Integer portEnd, String proto, Purpose purpose, FirewallRuleType type) {
|
||||
if (portStart != null && !NetUtils.isValidPort(portStart)) {
|
||||
@ -347,7 +351,6 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
assert network != null : "Can't create port forwarding rule as network associated with public ip address is null?";
|
||||
|
||||
|
||||
// Verify that the network guru supports the protocol specified
|
||||
Map<Network.Capability, String> protocolCapabilities = null;
|
||||
|
||||
@ -406,7 +409,6 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
return applyFirewallRules(rules, false, caller);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applyFirewallRules(List<FirewallRuleVO> rules, boolean continueOnError, Account caller) {
|
||||
|
||||
@ -504,7 +506,6 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FirewallRule getFirewallRule(long ruleId) {
|
||||
return _firewallDao.findById(ruleId);
|
||||
@ -520,7 +521,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
}
|
||||
|
||||
for (FirewallRuleVO rule : fwRules) {
|
||||
// Mark all Firewall rules as Revoke, but don't revoke them yet - we have to revoke all rules for ip, no need to send them one by one
|
||||
// Mark all Firewall rules as Revoke, but don't revoke them yet - we have to revoke all rules for ip, no
|
||||
// need to send them one by one
|
||||
revokeFirewallRule(rule.getId(), false, caller, Account.ACCOUNT_ID_SYSTEM);
|
||||
}
|
||||
|
||||
@ -539,7 +541,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, Long relatedRuleId) throws NetworkRuleConflictException{
|
||||
public FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, Long relatedRuleId)
|
||||
throws NetworkRuleConflictException {
|
||||
|
||||
// If firwallRule for this port range already exists, return it
|
||||
List<FirewallRuleVO> rules = _firewallDao.listByIpPurposeAndProtocolAndNotRevoked(ipAddrId, startPort, endPort, protocol, Purpose.Firewall);
|
||||
@ -562,7 +565,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
}
|
||||
|
||||
for (FirewallRuleVO rule : fwRules) {
|
||||
// Mark all Firewall rules as Revoke, but don't revoke them yet - we have to revoke all rules for ip, no need to send them one by one
|
||||
// Mark all Firewall rules as Revoke, but don't revoke them yet - we have to revoke all rules for ip, no
|
||||
// need to send them one by one
|
||||
revokeFirewallRule(rule.getId(), false, caller, Account.ACCOUNT_ID_SYSTEM);
|
||||
}
|
||||
|
||||
@ -594,7 +598,6 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean revokeFirewallRulesForVm(long vmId) {
|
||||
boolean success = true;
|
||||
@ -622,7 +625,6 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Set<Long> ipsToReprogram = new HashSet<Long>();
|
||||
|
||||
if (firewallRules.isEmpty()) {
|
||||
@ -665,4 +667,5 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -600,7 +600,6 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_LOAD_BALANCER_CREATE, eventDescription = "creating load balancer")
|
||||
public LoadBalancer createLoadBalancerRule(CreateLoadBalancerRuleCmd lb, boolean openFirewall) throws NetworkRuleConflictException, InsufficientAddressCapacityException {
|
||||
@ -681,7 +680,6 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
|
||||
_firewallMgr.validateFirewallRule(caller.getCaller(), ipAddr, srcPortStart, srcPortEnd, lb.getProtocol(), Purpose.LoadBalancing, FirewallRuleType.User);
|
||||
|
||||
|
||||
networkId = ipAddr.getAssociatedWithNetworkId();
|
||||
if (networkId == null) {
|
||||
throw new InvalidParameterValueException("Unable to create load balancer rule ; ip id=" + sourceIpId + " is not associated with any network");
|
||||
@ -1037,13 +1035,16 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
||||
|
||||
return loadBalancerInstances;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LbStickinessMethod> getStickinessMethods(long networkid)
|
||||
{
|
||||
String capability = getLBStickinessCapability(networkid);
|
||||
if (capability == null) return null;
|
||||
if (capability == null)
|
||||
return null;
|
||||
Gson gson = new Gson();
|
||||
java.lang.reflect.Type listType = new TypeToken<List<LbStickinessMethod>>() {}.getType();
|
||||
java.lang.reflect.Type listType = new TypeToken<List<LbStickinessMethod>>() {
|
||||
}.getType();
|
||||
List<LbStickinessMethod> result = gson.fromJson(capability, listType);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -42,8 +42,10 @@ public interface FirewallManager extends FirewallService{
|
||||
* only roll back one of the rules. However, the chances of that is low
|
||||
* and the user can simply re-add one of the rules themselves.
|
||||
*
|
||||
* @param newRule the new rule created.
|
||||
* @param ipAddress ip address that back up the new rule.
|
||||
* @param newRule
|
||||
* the new rule created.
|
||||
* @param ipAddress
|
||||
* ip address that back up the new rule.
|
||||
* @throws NetworkRuleConflictException
|
||||
*/
|
||||
void detectRulesConflict(FirewallRule newRule, IpAddress ipAddress) throws NetworkRuleConflictException;
|
||||
@ -60,14 +62,19 @@ public interface FirewallManager extends FirewallService{
|
||||
|
||||
/**
|
||||
* Revokes a firewall rule
|
||||
* @param ruleId the id of the rule to revoke.
|
||||
* @param caller TODO
|
||||
* @param userId TODO
|
||||
*
|
||||
* @param ruleId
|
||||
* the id of the rule to revoke.
|
||||
* @param caller
|
||||
* TODO
|
||||
* @param userId
|
||||
* TODO
|
||||
* @return
|
||||
*/
|
||||
boolean revokeFirewallRule(long ruleId, boolean apply, Account caller, long userId);
|
||||
|
||||
FirewallRule createFirewallRule(long ipAddrId, Account caller, String xId, Integer portStart, Integer portEnd, String protocol, List<String> sourceCidrList, Integer icmpCode, Integer icmpType, Long relatedRuleId, FirewallRule.FirewallRuleType type)
|
||||
FirewallRule createFirewallRule(long ipAddrId, Account caller, String xId, Integer portStart, Integer portEnd, String protocol, List<String> sourceCidrList, Integer icmpCode, Integer icmpType, Long relatedRuleId,
|
||||
FirewallRule.FirewallRuleType type)
|
||||
throws NetworkRuleConflictException;
|
||||
|
||||
FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, Long relatedRuleId) throws NetworkRuleConflictException;
|
||||
@ -77,4 +84,5 @@ public interface FirewallManager extends FirewallService{
|
||||
boolean revokeFirewallRulesForVm(long vmId);
|
||||
|
||||
boolean addSystemFirewallRules(IPAddressVO ip, Account acct);
|
||||
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import com.cloud.network.IpAddress;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
|
||||
/**
|
||||
* Rules Manager manages the network rules created for different networks.
|
||||
*/
|
||||
@ -41,6 +40,7 @@ public interface RulesManager extends RulesService {
|
||||
boolean applyStaticNatRulesForNetwork(long networkId, boolean continueOnError, Account caller);
|
||||
|
||||
void checkIpAndUserVm(IpAddress ipAddress, UserVm userVm, Account caller);
|
||||
|
||||
void checkRuleAndUserVm(FirewallRule rule, UserVm userVm, Account caller);
|
||||
|
||||
boolean revokeAllPFAndStaticNatRulesForIp(long ipId, long userId, Account caller) throws ResourceUnavailableException;
|
||||
@ -52,6 +52,7 @@ public interface RulesManager extends RulesService {
|
||||
/**
|
||||
* Returns a list of port forwarding rules that are ready for application
|
||||
* to the network elements for this ip.
|
||||
*
|
||||
* @param ip
|
||||
* @return List of PortForwardingRule
|
||||
*/
|
||||
@ -64,6 +65,7 @@ public interface RulesManager extends RulesService {
|
||||
boolean revokeStaticNatRulesForVm(long vmId);
|
||||
|
||||
FirewallRule[] reservePorts(IpAddress ip, String protocol, FirewallRule.Purpose purpose, boolean openFirewall, Account caller, int... ports) throws NetworkRuleConflictException;
|
||||
|
||||
boolean releasePorts(long ipId, String protocol, FirewallRule.Purpose purpose, int... ports);
|
||||
|
||||
List<PortForwardingRuleVO> listByNetworkId(long networkId);
|
||||
|
||||
@ -155,7 +155,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NET_RULE_ADD, eventDescription = "creating forwarding rule", create = true)
|
||||
public PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, boolean openFirewall) throws NetworkRuleConflictException {
|
||||
UserContext ctx = UserContext.current();
|
||||
@ -231,7 +232,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
return newRule;
|
||||
} catch (Exception e) {
|
||||
|
||||
|
||||
if (newRule != null) {
|
||||
|
||||
txn.start();
|
||||
@ -249,7 +249,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NET_RULE_ADD, eventDescription = "creating static nat rule", create = true)
|
||||
public StaticNatRule createStaticNatRule(StaticNatRule rule, boolean openFirewall) throws NetworkRuleConflictException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
@ -284,7 +285,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
|
||||
FirewallRuleVO newRule = new FirewallRuleVO(rule.getXid(), rule.getSourceIpAddressId(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getProtocol().toLowerCase(),
|
||||
networkId, accountId, domainId, rule.getPurpose(), null, null, null, null);
|
||||
|
||||
@ -295,7 +295,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
_firewallMgr.createRuleForAllCidrs(ipAddrId, caller, rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getProtocol(), null, null, newRule.getId());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
_firewallMgr.detectRulesConflict(newRule, ipAddress);
|
||||
if (!_firewallDao.setStateToAdd(newRule)) {
|
||||
@ -410,7 +409,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vmId);
|
||||
|
||||
if (oldIP != null) {
|
||||
//If elasticIP functionality is supported in the network, we always have to disable static nat on the old ip in order to re-enable it on the new one
|
||||
// If elasticIP functionality is supported in the network, we always have to disable static nat on the old
|
||||
// ip in order to re-enable it on the new one
|
||||
Long networkId = oldIP.getAssociatedWithNetworkId();
|
||||
boolean reassignStaticNat = false;
|
||||
if (networkId != null) {
|
||||
@ -433,7 +433,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NET_RULE_DELETE, eventDescription = "revoking forwarding rule", async = true)
|
||||
public boolean revokePortForwardingRule(long ruleId, boolean apply) {
|
||||
@ -638,7 +637,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (caller != null) {
|
||||
_accountMgr.checkAccess(caller, null, true, rules.toArray(new PortForwardingRuleVO[rules.size()]));
|
||||
}
|
||||
@ -739,7 +737,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applyStaticNatsForNetwork(long networkId, boolean continueOnError, Account caller) {
|
||||
List<IPAddressVO> ips = _ipAddressDao.listStaticNatPublicIps(networkId);
|
||||
@ -799,7 +796,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
|
||||
sb.and("id", sb.entity().getId(), Op.EQ);
|
||||
|
||||
|
||||
if (vmId != null) {
|
||||
SearchBuilder<IPAddressVO> ipSearch = _ipAddressDao.createSearchBuilder();
|
||||
ipSearch.and("associatedWithVmId", ipSearch.entity().getAssociatedWithVmId(), Op.EQ);
|
||||
@ -862,7 +858,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
s_logger.debug("Releasing " + staticNatRules.size() + " static nat rules for ip id=" + ipId);
|
||||
}
|
||||
|
||||
|
||||
for (FirewallRuleVO rule : staticNatRules) {
|
||||
// Mark all static nat rules as Revoke, but don't revoke them yet
|
||||
revokeStaticNatRuleInternal(rule.getId(), caller, userId, false);
|
||||
@ -1040,7 +1035,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
throw new InvalidParameterValueException("IP address " + ipAddress + " is not associated with any vm Id");
|
||||
}
|
||||
|
||||
//if network has elastic IP functionality supported, we first have to disable static nat on old ip in order to re-enable it on the new one
|
||||
// if network has elastic IP functionality supported, we first have to disable static nat on old ip in order to
|
||||
// re-enable it on the new one
|
||||
// enable static nat takes care of that
|
||||
Network guestNetwork = _networkMgr.getNetwork(ipAddress.getAssociatedWithNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
@ -1052,7 +1048,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public boolean disableStaticNat(long ipId, Account caller, long callerUserId, boolean releaseIpIfElastic) throws ResourceUnavailableException {
|
||||
boolean success = true;
|
||||
|
||||
@ -1177,7 +1174,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void enableElasticIpAndStaticNatForVm(UserVm vm, boolean getNewIp) throws InsufficientAddressCapacityException {
|
||||
boolean success = true;
|
||||
|
||||
@ -287,7 +287,8 @@ public class NetworkOfferingVO implements NetworkOffering, Identity {
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault,
|
||||
Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean dedicatedLb, boolean sharedSourceNat, boolean redundantRouter, boolean elasticIp, boolean elasticLb, boolean specifyIpRanges) {
|
||||
Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean dedicatedLb, boolean sharedSourceNat, boolean redundantRouter, boolean elasticIp, boolean elasticLb,
|
||||
boolean specifyIpRanges) {
|
||||
this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges);
|
||||
this.dedicatedLB = dedicatedLb;
|
||||
this.sharedSourceNat = sharedSourceNat;
|
||||
@ -301,9 +302,11 @@ public class NetworkOfferingVO implements NetworkOffering, Identity {
|
||||
|
||||
/**
|
||||
* Network Offering for all system vms.
|
||||
*
|
||||
* @param name
|
||||
* @param trafficType
|
||||
* @param specifyIpRanges TODO
|
||||
* @param specifyIpRanges
|
||||
* TODO
|
||||
*/
|
||||
public NetworkOfferingVO(String name, TrafficType trafficType, boolean specifyIpRanges) {
|
||||
this(name, "System Offering for " + name, trafficType, true, false, 0, 0, true, Availability.Required, null, null, true, specifyIpRanges);
|
||||
@ -356,4 +359,5 @@ public class NetworkOfferingVO implements NetworkOffering, Identity {
|
||||
public boolean getSpecifyIpRanges() {
|
||||
return specifyIpRanges;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -38,7 +38,9 @@ import com.cloud.utils.db.GenericDao;
|
||||
public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long> {
|
||||
/**
|
||||
* Returns the network offering that matches the name.
|
||||
* @param uniqueName name
|
||||
*
|
||||
* @param uniqueName
|
||||
* name
|
||||
* @return NetworkOfferingVO
|
||||
*/
|
||||
NetworkOfferingVO findByUniqueName(String uniqueName);
|
||||
@ -48,7 +50,8 @@ public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long>
|
||||
* is already there, then it returns the correct one in the database.
|
||||
* If not, then it persists it into the database.
|
||||
*
|
||||
* @param offering network offering to persist if not in the database.
|
||||
* @param offering
|
||||
* network offering to persist if not in the database.
|
||||
* @return NetworkOfferingVO backed by a row in the database
|
||||
*/
|
||||
NetworkOfferingVO persistDefaultNetworkOffering(NetworkOfferingVO offering);
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
@ -40,7 +39,8 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Local(value=NetworkOfferingDao.class) @DB(txn=false)
|
||||
@Local(value = NetworkOfferingDao.class)
|
||||
@DB(txn = false)
|
||||
public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Long> implements NetworkOfferingDao {
|
||||
final SearchBuilder<NetworkOfferingVO> NameSearch;
|
||||
final SearchBuilder<NetworkOfferingVO> SystemOfferingSearch;
|
||||
@ -123,7 +123,8 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public boolean remove(Long networkOfferingId) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
@ -163,4 +164,5 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
sc.setParameters("state", state);
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -117,7 +117,6 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{
|
||||
@Inject
|
||||
private ProjectAccountDao _projectAccountDao;
|
||||
|
||||
|
||||
protected SearchBuilder<ResourceCountVO> ResourceCountSearch;
|
||||
ScheduledExecutorService _rcExecutor;
|
||||
long _resourceCountCheckInterval = 0;
|
||||
@ -261,7 +260,8 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public void checkResourceLimit(Account account, ResourceType type, long... count) throws ResourceAllocationException {
|
||||
long numResources = ((count.length == 0) ? 1 : count[0]);
|
||||
Project project = null;
|
||||
@ -518,7 +518,6 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{
|
||||
throw new PermissionDeniedException("Cannot update resource limit for ROOT domain " + domainId + ", permission denied");
|
||||
}
|
||||
|
||||
|
||||
if ((caller.getDomainId() == domainId.longValue()) && caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
|
||||
// if the admin is trying to update their own domain, disallow...
|
||||
throw new PermissionDeniedException("Unable to update resource limit for domain " + domainId + ", permission denied");
|
||||
|
||||
@ -29,7 +29,9 @@ public interface ConfigurationServer {
|
||||
|
||||
/**
|
||||
* Persists default values for the configuration table, pods/zones, and VLANs
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void persistDefaultValues() throws InternalErrorException;
|
||||
|
||||
}
|
||||
|
||||
@ -143,7 +143,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
_identityDao = locator.getDao(IdentityDao.class);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public void persistDefaultValues() throws InternalErrorException {
|
||||
|
||||
// Create system user and admin user
|
||||
@ -194,7 +195,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
_configDao.update("secstorage.secure.copy.cert", "realhostip");
|
||||
s_logger.debug("ConfigurationServer made secondary storage copy use realhostip.");
|
||||
|
||||
|
||||
// Save default service offerings
|
||||
createServiceOffering(User.UID_SYSTEM, "Small Instance", 1, 512, 500, "Small Instance", false, false, null);
|
||||
createServiceOffering(User.UID_SYSTEM, "Medium Instance", 1, 1024, 1000, "Medium Instance", false, false, null);
|
||||
@ -229,7 +229,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
|
||||
// Create userIpAddress ranges
|
||||
|
||||
|
||||
// Update existing vlans with networkId
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
@ -272,7 +271,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
|
||||
updateUuids();
|
||||
|
||||
|
||||
// Set init to true
|
||||
_configDao.update("init", "Hidden", "true");
|
||||
}
|
||||
@ -320,7 +318,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@DB
|
||||
protected void saveUser() {
|
||||
// insert system account
|
||||
@ -377,7 +374,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
insertSql = "INSERT INTO `cloud`.`user` (id, username, password, account_id, firstname, lastname, created) " +
|
||||
"VALUES (" + id + ",'" + username + "','" + sb.toString() + "', 2, '" + firstname + "','" + lastname + "',now())";
|
||||
|
||||
|
||||
txn = Transaction.currentTxn();
|
||||
try {
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
|
||||
@ -385,8 +381,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
} catch (SQLException ex) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
String tableName = "security_group";
|
||||
try {
|
||||
@ -873,8 +867,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
netscalerServiceProviders.put(Service.StaticNat, Provider.Netscaler);
|
||||
netscalerServiceProviders.put(Service.Lb, Provider.Netscaler);
|
||||
|
||||
|
||||
//The only one diff between 1 and 2 network offerings is that the first one has SG enabled. In Basic zone only first network offering has to be enabled, in Advance zone - the second one
|
||||
// The only one diff between 1 and 2 network offerings is that the first one has SG enabled. In Basic zone only
|
||||
// first network offering has to be enabled, in Advance zone - the second one
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
@ -923,7 +917,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
defaultIsolatedSourceNatEnabledNetworkOffering.setState(NetworkOffering.State.Enabled);
|
||||
defaultIsolatedSourceNatEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedSourceNatEnabledNetworkOffering);
|
||||
|
||||
|
||||
for (Service service : defaultIsolatedSourceNatEnabledNetworkOfferingProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service, defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
@ -1018,7 +1011,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
|
||||
if (broadcastDomainType != null) {
|
||||
NetworkVO network = new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, networkDomain, Network.GuestType.Shared, zoneId, null, null, specifyIpRanges);
|
||||
NetworkVO network = new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, networkDomain, Network.GuestType.Shared, zoneId, null,
|
||||
null, specifyIpRanges);
|
||||
network.setGuruName(guruNames.get(network.getTrafficType()));
|
||||
network.setDns1(zone.getDns1());
|
||||
network.setDns2(zone.getDns2());
|
||||
@ -1031,7 +1025,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateVlanWithNetworkId(VlanVO vlan) {
|
||||
long zoneId = vlan.getDataCenterId();
|
||||
long networkId = 0L;
|
||||
@ -1069,7 +1062,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
return networks.get(0).getId();
|
||||
}
|
||||
|
||||
|
||||
@DB
|
||||
public void updateResourceCount() {
|
||||
ResourceType[] resourceTypes = Resource.ResourceType.values();
|
||||
@ -1090,7 +1082,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int accountExpectedCount = accountSupportedResourceTypes.size();
|
||||
int domainExpectedCount = domainSupportedResourceTypes.size();
|
||||
|
||||
|
||||
@ -334,7 +334,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
private int _customDiskOfferingMinSize = 1;
|
||||
private int _customDiskOfferingMaxSize = 1024;
|
||||
|
||||
|
||||
public boolean share(VMInstanceVO vm, List<VolumeVO> vols, HostVO host, boolean cancelPreviousShare) throws StorageUnavailableException {
|
||||
|
||||
// if pool is in maintenance and it is the ONLY pool available; reject
|
||||
@ -830,7 +829,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Can't find the vm where host resides on(vm is destroyed? or volume is detached from vm), randomly choose a host
|
||||
* Can't find the vm where host resides on(vm is destroyed? or volume is detached from vm), randomly choose
|
||||
* a host
|
||||
* to send the cmd
|
||||
*/
|
||||
}
|
||||
@ -888,8 +888,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
String time = configs.get("storage.cleanup.interval");
|
||||
_storageCleanupInterval = NumbersUtil.parseInt(time, 86400);
|
||||
|
||||
|
||||
|
||||
s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval: " + _storageCleanupInterval + ", template cleanup enabled: " + _templateCleanupEnabled);
|
||||
|
||||
String workers = configs.get("expunge.workers");
|
||||
@ -1591,8 +1589,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
@Override
|
||||
public VolumeVO moveVolume(VolumeVO volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException {
|
||||
|
||||
|
||||
|
||||
// Find a destination storage pool with the specified criteria
|
||||
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
|
||||
DiskProfile dskCh = new DiskProfile(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(), diskOffering.getDiskSize(), diskOffering.getTagsArray(),
|
||||
@ -1617,10 +1613,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
|
||||
/*
|
||||
* Just allocate a volume in the database, don't send the createvolume cmd to hypervisor. The volume will be finally created
|
||||
* Just allocate a volume in the database, don't send the createvolume cmd to hypervisor. The volume will be finally
|
||||
* created
|
||||
* only when it's attached to a VM.
|
||||
*/
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_CREATE, eventDescription = "creating volume", create = true)
|
||||
public VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException {
|
||||
// FIXME: some of the scheduled event stuff might be missing here...
|
||||
@ -1709,11 +1707,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
_accountMgr.checkAccess(caller, null, true, snapshotCheck);
|
||||
|
||||
/*
|
||||
// bug #11428. Operation not supported if vmware and snapshots parent volume = ROOT
|
||||
if(snapshotCheck.getHypervisorType() == HypervisorType.VMware
|
||||
&& _volumeDao.findByIdIncludingRemoved(snapshotCheck.getVolumeId()).getVolumeType() == Type.ROOT){
|
||||
throw new UnsupportedServiceException("operation not supported, snapshot with id " + snapshotId + " is created from ROOT volume");
|
||||
}
|
||||
* // bug #11428. Operation not supported if vmware and snapshots parent volume = ROOT
|
||||
* if(snapshotCheck.getHypervisorType() == HypervisorType.VMware
|
||||
* && _volumeDao.findByIdIncludingRemoved(snapshotCheck.getVolumeId()).getVolumeType() == Type.ROOT){
|
||||
* throw new UnsupportedServiceException("operation not supported, snapshot with id " + snapshotId +
|
||||
* " is created from ROOT volume");
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
@ -1873,7 +1872,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
long totalOverProvCapacity;
|
||||
if (storagePool.getPoolType() == StoragePoolType.NetworkFilesystem) {
|
||||
totalOverProvCapacity = _overProvisioningFactor.multiply(new BigDecimal(storagePool.getCapacityBytes())).longValue();// All this for the inaccuracy of floats for big number multiplication.
|
||||
totalOverProvCapacity = _overProvisioningFactor.multiply(new BigDecimal(storagePool.getCapacityBytes())).longValue();// All
|
||||
// this for the inaccuracy of floats for big number multiplication.
|
||||
} else {
|
||||
totalOverProvCapacity = storagePool.getCapacityBytes();
|
||||
}
|
||||
@ -1900,7 +1900,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
+ storagePool.getDataCenterId() + ", HostOrPoolId - " + storagePool.getId() + ", PodId " + storagePool.getPodId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Long> getUpHostsInPool(long poolId) {
|
||||
SearchCriteria<Long> sc = UpHostsInPoolSearch.create();
|
||||
@ -2032,7 +2031,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
}
|
||||
|
||||
|
||||
List<String> findAllSnapshotForVolume(Long volumeId) {
|
||||
String sql = "SELECT backup_snap_id FROM snapshots WHERE volume_id=? and backup_snap_id is not NULL";
|
||||
try {
|
||||
@ -2186,7 +2184,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
throw new InvalidParameterValueException("Primary storage with id " + primaryStorageId + " is not ready for migration, as the status is:" + primaryStorage.getStatus().toString());
|
||||
}
|
||||
|
||||
|
||||
List<HostVO> hosts = _resourceMgr.listHostsInClusterByStatus(primaryStorage.getClusterId(), Status.Up);
|
||||
if (hosts == null || hosts.size() == 0) {
|
||||
primaryStorage.setStatus(StoragePoolStatus.Maintenance);
|
||||
@ -2867,7 +2864,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3204,7 +3200,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onManagementNodeJoined(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
||||
// TODO Auto-generated method stub
|
||||
@ -3304,10 +3299,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
return capacity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public StoragePool getStoragePool(long id) {
|
||||
return _storagePoolDao.findById(id);
|
||||
}
|
||||
@ -3357,6 +3349,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
sc.setJoinParameters("vmVolume", "poolId", storagePoolId);
|
||||
return _vmInstanceDao.search(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public StoragePoolVO findLocalStorageOnHost(long hostId) {
|
||||
@ -3508,4 +3501,5 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
return _volumeDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -318,7 +318,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
|
||||
for (ControlledEntity entity : entities) {
|
||||
long domainId = entity.getDomainId();
|
||||
if (entity.getAccountId() != -1 && domainId == -1){ // If account exists domainId should too so calculate it. This condition might be hit for templates or entities which miss domainId in their tables
|
||||
if (entity.getAccountId() != -1 && domainId == -1) { // If account exists domainId should too so calculate
|
||||
// it. This condition might be hit for templates or entities which miss domainId in their tables
|
||||
Account account = ApiDBUtils.findAccountById(entity.getAccountId());
|
||||
domainId = account != null ? account.getDomainId() : -1;
|
||||
}
|
||||
@ -580,7 +581,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
// delete account specific Virtual vlans (belong to system Public Network) - only when networks are cleaned up
|
||||
// delete account specific Virtual vlans (belong to system Public Network) - only when networks are cleaned
|
||||
// up
|
||||
// successfully
|
||||
if (networksDeleted) {
|
||||
if (!_configMgr.deleteAccountSpecificVirtualRanges(accountId)) {
|
||||
@ -658,7 +660,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account")
|
||||
public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain, Map<String, String> details) {
|
||||
public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
|
||||
Map<String, String> details) {
|
||||
|
||||
if (accountName == null) {
|
||||
accountName = userName;
|
||||
@ -676,7 +679,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
// Check permissions
|
||||
checkAccess(UserContext.current().getCaller(), domain);
|
||||
|
||||
|
||||
if (!_userAccountDao.validateUsernameInDomain(userName, domainId)) {
|
||||
throw new InvalidParameterValueException("The user " + userName + " already exists in domain " + domainId);
|
||||
}
|
||||
@ -815,7 +817,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
user.setSecretKey(secretKey);
|
||||
}
|
||||
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("updating user with id: " + id);
|
||||
}
|
||||
@ -876,7 +877,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_USER_ENABLE, eventDescription = "enabling User")
|
||||
public UserAccount enableUser(long userId) {
|
||||
|
||||
@ -944,7 +946,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
checkAccess(caller, null, true, account);
|
||||
|
||||
// make sure the account is enabled too
|
||||
// if the user is either locked already or disabled already, don't change state...only lock currently enabled users
|
||||
// if the user is either locked already or disabled already, don't change state...only lock currently enabled
|
||||
// users
|
||||
boolean success = true;
|
||||
if (user.getState().equals(State.locked)) {
|
||||
// already locked...no-op
|
||||
@ -1107,7 +1110,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public AccountVO updateAccount(UpdateAccountCmd cmd) {
|
||||
Long accountId = cmd.getId();
|
||||
Long domainId = cmd.getDomainId();
|
||||
@ -1213,7 +1217,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
return _userDao.remove(id);
|
||||
}
|
||||
|
||||
|
||||
public class ResourceCountCalculateTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -1479,7 +1482,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
_userDao.update(Long.valueOf(userId), userForUpdate);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override
|
||||
@DB
|
||||
public Account createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details) {
|
||||
// Validate domain
|
||||
Domain domain = _domainMgr.getDomain(domainId);
|
||||
@ -1542,7 +1546,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
// Create default security group
|
||||
_networkGroupMgr.createDefaultSecurityGroup(accountId);
|
||||
|
||||
|
||||
txn.commit();
|
||||
|
||||
return account;
|
||||
@ -1559,7 +1562,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void logoutUser(Long userId) {
|
||||
UserAccount userAcct = _userAccountDao.findById(userId);
|
||||
@ -1599,7 +1601,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
|
||||
String singleSignOnTolerance = _configDao.getValue("security.singlesignon.tolerance.millis");
|
||||
if (singleSignOnTolerance == null) {
|
||||
// the SSO tolerance is gone (how much time before/after system time we'll allow the login request to be valid),
|
||||
// the SSO tolerance is gone (how much time before/after system time we'll allow the login request to be
|
||||
// valid),
|
||||
// don't authenticate
|
||||
return null;
|
||||
}
|
||||
@ -1939,7 +1942,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
public List<UserAccountVO> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
|
||||
Long domainId = cmd.getDomainId();
|
||||
if (domainId != null) {
|
||||
Domain domain = _domainDao.findById(domainId);
|
||||
@ -2101,7 +2103,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildACLSearchParameters(Account caller, Long id, String accountName, Long projectId, List<Long> permittedAccounts, Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject, boolean listAll) {
|
||||
public void buildACLSearchParameters(Account caller, Long id, String accountName, Long projectId, List<Long> permittedAccounts, Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject,
|
||||
boolean listAll) {
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
|
||||
if (domainId != null) {
|
||||
@ -2171,6 +2174,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,6 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{
|
||||
|
||||
_accountMgr.checkAccess(caller, parentDomain);
|
||||
|
||||
|
||||
return createDomain(name, parentId, caller.getId(), networkDomain);
|
||||
|
||||
}
|
||||
@ -178,7 +177,6 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{
|
||||
return domain;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DomainVO findDomainByPath(String domainPath) {
|
||||
return _domainDao.findDomainByPath(domainPath);
|
||||
@ -438,4 +436,5 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{
|
||||
|
||||
return _domainDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package com.cloud.upgrade;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@ -37,12 +36,14 @@ import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class Test2214To30DBUpgrade extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(Test2214To30DBUpgrade.class);
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(Test2214To30DBUpgrade.class);
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/clean-db.sql", false, true);
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/clean-db.sql", false,
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,10 +53,15 @@ public class Test2214To30DBUpgrade extends TestCase {
|
||||
|
||||
public void test2213to30Upgrade() throws SQLException {
|
||||
s_logger.debug("Finding sample data from 2.2.14");
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/2.2.14/cloud_usage_2214.sql", false, true);
|
||||
DbTestUtils.executeScript("PreviousDatabaseSchema/2.2.14/advance_zone_2.2.14.sql", false, true);
|
||||
DbTestUtils.executeScript(
|
||||
"PreviousDatabaseSchema/2.2.14/cloud_usage_2214.sql", false,
|
||||
true);
|
||||
DbTestUtils.executeScript(
|
||||
"PreviousDatabaseSchema/2.2.14/advance_zone_2.2.14.sql", false,
|
||||
true);
|
||||
|
||||
DatabaseUpgradeChecker checker = ComponentLocator.inject(DatabaseUpgradeChecker.class);
|
||||
DatabaseUpgradeChecker checker = ComponentLocator
|
||||
.inject(DatabaseUpgradeChecker.class);
|
||||
|
||||
checker.upgrade("2.2.14", "3.0.0");
|
||||
|
||||
@ -77,10 +83,12 @@ public class Test2214To30DBUpgrade extends TestCase {
|
||||
protected void checkPhysicalNetworks(Connection conn) throws SQLException {
|
||||
PreparedStatement pstmt;
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT version FROM version ORDER BY id DESC LIMIT 1");
|
||||
pstmt = conn
|
||||
.prepareStatement("SELECT version FROM version ORDER BY id DESC LIMIT 1");
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
assert rs.next() : "No version selected";
|
||||
assert rs.getString(1).equals("3.0.0") : "VERSION stored is not 3.0.0: " + rs.getString(1);
|
||||
assert rs.getString(1).equals("3.0.0") : "VERSION stored is not 3.0.0: "
|
||||
+ rs.getString(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
@ -90,7 +98,6 @@ public class Test2214To30DBUpgrade extends TestCase {
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void checkNetworkOfferings(Connection conn) throws SQLException {
|
||||
@ -125,11 +132,13 @@ public class Test2214To30DBUpgrade extends TestCase {
|
||||
|
||||
PreparedStatement pstmt;
|
||||
for (String field : fields) {
|
||||
pstmt = conn.prepareStatement("SHOW COLUMNS FROM network_offerings LIKE ?");
|
||||
pstmt = conn
|
||||
.prepareStatement("SHOW COLUMNS FROM network_offerings LIKE ?");
|
||||
pstmt.setString(1, field);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (!rs.next()) {
|
||||
throw new CloudRuntimeException("Field " + field + " is missing in upgraded network_offerings table");
|
||||
throw new CloudRuntimeException("Field " + field
|
||||
+ " is missing in upgraded network_offerings table");
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
@ -145,6 +154,7 @@ public class Test2214To30DBUpgrade extends TestCase {
|
||||
List<String> fields = new ArrayList<String>();
|
||||
fields.add("id");
|
||||
fields.add("name");
|
||||
|
||||
fields.add("mode");
|
||||
fields.add("broadcast_domain_type");
|
||||
fields.add("traffic_type");
|
||||
@ -181,15 +191,14 @@ public class Test2214To30DBUpgrade extends TestCase {
|
||||
pstmt.setString(1, field);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (!rs.next()) {
|
||||
throw new CloudRuntimeException("Field " + field + " is missing in upgraded networks table");
|
||||
throw new CloudRuntimeException("Field " + field
|
||||
+ " is missing in upgraded networks table");
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user