mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' into ui-cisco-asa1000v-support
This commit is contained in:
commit
8811bcc38d
|
|
@ -50,7 +50,9 @@ public interface AsyncJob extends Identity, InternalIdentity {
|
|||
AutoScaleVmProfile,
|
||||
AutoScaleVmGroup,
|
||||
GlobalLoadBalancerRule,
|
||||
LoadBalancerRule,
|
||||
AffinityGroup,
|
||||
InternalLbVm,
|
||||
DedicatedGuestVlanRange
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
// under the License.
|
||||
package com.cloud.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.configuration.Configuration;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Pod;
|
||||
|
|
@ -23,8 +26,18 @@ import com.cloud.dc.StorageNetworkIpRange;
|
|||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.*;
|
||||
import com.cloud.network.as.*;
|
||||
import com.cloud.network.GuestVlan;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkTrafficType;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.as.AutoScaleCounter;
|
||||
import com.cloud.network.as.AutoScalePolicy;
|
||||
import com.cloud.network.as.AutoScaleVmGroup;
|
||||
import com.cloud.network.as.AutoScaleVmProfile;
|
||||
import com.cloud.network.as.Condition;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
|
|
@ -43,9 +56,6 @@ import com.cloud.user.Account;
|
|||
import com.cloud.user.User;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EventTypes {
|
||||
|
||||
//map of Event and corresponding entity for which Event is applicable
|
||||
|
|
@ -389,11 +399,15 @@ public class EventTypes {
|
|||
public static final String EVENT_AFFINITY_GROUP_ASSIGN = "AG.ASSIGN";
|
||||
public static final String EVENT_AFFINITY_GROUP_REMOVE = "AG.REMOVE";
|
||||
public static final String EVENT_VM_AFFINITY_GROUP_UPDATE = "VM.AG.UPDATE";
|
||||
|
||||
public static final String EVENT_INTERNAL_LB_VM_START = "INTERNALLBVM.START";
|
||||
public static final String EVENT_INTERNAL_LB_VM_STOP = "INTERNALLBVM.STOP";
|
||||
|
||||
// Dedicated guest vlan range
|
||||
public static final String EVENT_GUEST_VLAN_RANGE_DEDICATE = "GUESTVLANRANGE.DEDICATE";
|
||||
public static final String EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE = "GUESTVLANRANGE.RELEASE";
|
||||
|
||||
|
||||
static {
|
||||
|
||||
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
|
||||
|
|
|
|||
|
|
@ -81,4 +81,7 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity
|
|||
Long getVpcId();
|
||||
|
||||
String getVmIp();
|
||||
|
||||
Long getNetworkId();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,19 @@
|
|||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* owned by an account.
|
||||
|
|
@ -50,7 +51,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
|||
Capability.MultipleIps, Capability.TrafficStatistics, Capability.SupportedTrafficDirection, Capability.SupportedEgressProtocols);
|
||||
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation,
|
||||
Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps,
|
||||
Capability.SupportedStickinessMethods, Capability.ElasticLb);
|
||||
Capability.SupportedStickinessMethods, Capability.ElasticLb, Capability.LbSchemes);
|
||||
public static final Service UserData = new Service("UserData");
|
||||
public static final Service SourceNat = new Service("SourceNat", Capability.SupportedSourceNatTypes, Capability.RedundantRouter);
|
||||
public static final Service StaticNat = new Service("StaticNat", Capability.ElasticIp);
|
||||
|
|
@ -124,6 +125,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
|||
public static final Provider None = new Provider("None", false);
|
||||
// NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking
|
||||
public static final Provider NiciraNvp = new Provider("NiciraNvp", false);
|
||||
public static final Provider InternalLbVm = new Provider("InternalLbVm", false);
|
||||
public static final Provider CiscoVnmc = new Provider("CiscoVnmc", true);
|
||||
|
||||
private String name;
|
||||
|
|
@ -177,6 +179,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
|||
public static final Capability SupportedTrafficDirection = new Capability("SupportedTrafficDirection");
|
||||
public static final Capability SupportedEgressProtocols = new Capability("SupportedEgressProtocols");
|
||||
public static final Capability HealthCheckPolicy = new Capability("HealthCheckPolicy");
|
||||
public static final Capability LbSchemes = new Capability("LbSchemes");
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.cloud.network.Networks.TrafficType;
|
|||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.UserDataServiceProvider;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
|
@ -264,5 +265,11 @@ public interface NetworkModel {
|
|||
|
||||
Nic getPlaceholderNicForRouter(Network network, Long podId);
|
||||
|
||||
IpAddress getPublicIpAddress(String ipAddress, long zoneId);
|
||||
|
||||
List<String> getUsedIpsInNetwork(Network network);
|
||||
|
||||
Map<Detail, String> getNtwkOffDetails(long offId);
|
||||
|
||||
Networks.IsolationType[] listNetworkIsolationMethods();
|
||||
}
|
||||
|
|
@ -63,5 +63,7 @@ public interface VirtualNetworkApplianceService {
|
|||
VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
VirtualRouter destroyRouter(long routerId, Account caller, Long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
VirtualRouter findRouter(long routerId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ public interface VirtualRouterProvider extends InternalIdentity, Identity {
|
|||
public enum VirtualRouterProviderType {
|
||||
VirtualRouter,
|
||||
ElasticLoadBalancerVm,
|
||||
VPCVirtualRouter
|
||||
VPCVirtualRouter,
|
||||
InternalLbVm
|
||||
}
|
||||
|
||||
public VirtualRouterProviderType getType();
|
||||
|
|
|
|||
|
|
@ -25,111 +25,83 @@ import com.cloud.network.as.Condition;
|
|||
import com.cloud.network.as.Counter;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.net.Ip;
|
||||
|
||||
public class LoadBalancingRule implements FirewallRule, LoadBalancer {
|
||||
public class LoadBalancingRule {
|
||||
private LoadBalancer lb;
|
||||
private Ip sourceIp;
|
||||
private List<LbDestination> destinations;
|
||||
private List<LbStickinessPolicy> stickinessPolicies;
|
||||
private LbAutoScaleVmGroup autoScaleVmGroup;
|
||||
private List<LbHealthCheckPolicy> healthCheckPolicies;
|
||||
|
||||
public LoadBalancingRule(LoadBalancer lb, List<LbDestination> destinations,
|
||||
List<LbStickinessPolicy> stickinessPolicies, List<LbHealthCheckPolicy> healthCheckPolicies) {
|
||||
List<LbStickinessPolicy> stickinessPolicies, List<LbHealthCheckPolicy> healthCheckPolicies, Ip sourceIp) {
|
||||
this.lb = lb;
|
||||
this.destinations = destinations;
|
||||
this.stickinessPolicies = stickinessPolicies;
|
||||
this.healthCheckPolicies = healthCheckPolicies;
|
||||
this.sourceIp = sourceIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return lb.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
return lb.getAccountId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDomainId() {
|
||||
return lb.getDomainId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return lb.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return lb.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultPortStart() {
|
||||
return lb.getDefaultPortStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultPortEnd() {
|
||||
return lb.getDefaultPortEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return lb.getAlgorithm();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return lb.getUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getXid() {
|
||||
return lb.getXid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSourceIpAddressId() {
|
||||
return lb.getSourceIpAddressId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSourcePortStart() {
|
||||
return lb.getSourcePortStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSourcePortEnd() {
|
||||
return lb.getSourcePortEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return lb.getProtocol();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Purpose getPurpose() {
|
||||
return Purpose.LoadBalancing;
|
||||
public FirewallRule.Purpose getPurpose() {
|
||||
return FirewallRule.Purpose.LoadBalancing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
public FirewallRule.State getState() {
|
||||
return lb.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNetworkId() {
|
||||
return lb.getNetworkId();
|
||||
}
|
||||
|
||||
public LoadBalancer getLb() {
|
||||
return lb;
|
||||
}
|
||||
|
||||
public void setDestinations(List<LbDestination> destinations) {
|
||||
this.destinations = destinations;
|
||||
|
|
@ -287,36 +259,6 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getIcmpCode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getIcmpType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSourceCidrList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getRelated() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrafficType getTrafficType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirewallRuleType getType() {
|
||||
return FirewallRuleType.User;
|
||||
}
|
||||
|
||||
public LbAutoScaleVmGroup getAutoScaleVmGroup() {
|
||||
return autoScaleVmGroup;
|
||||
}
|
||||
|
|
@ -473,4 +415,11 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
|
|||
}
|
||||
}
|
||||
|
||||
public Ip getSourceIp() {
|
||||
return sourceIp;
|
||||
}
|
||||
|
||||
public Scheme getScheme() {
|
||||
return lb.getScheme();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
package com.cloud.network.lb;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLBHealthCheckPolicyCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLBStickinessPolicyCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLoadBalancerRuleCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.ListLBHealthCheckPoliciesCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.ListLBStickinessPoliciesCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.ListLoadBalancerRuleInstancesCmd;
|
||||
|
|
@ -30,12 +30,13 @@ import org.apache.cloudstack.api.command.user.loadbalancer.UpdateLoadBalancerRul
|
|||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
|
||||
import com.cloud.network.rules.HealthCheckPolicy;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.net.Ip;
|
||||
|
||||
|
||||
public interface LoadBalancingRulesService {
|
||||
|
|
@ -49,7 +50,9 @@ public interface LoadBalancingRulesService {
|
|||
* @return the newly created LoadBalancerVO if successful, null otherwise
|
||||
* @throws InsufficientAddressCapacityException
|
||||
*/
|
||||
LoadBalancer createLoadBalancerRule(CreateLoadBalancerRuleCmd lb, boolean openFirewall) throws NetworkRuleConflictException, InsufficientAddressCapacityException;
|
||||
LoadBalancer createPublicLoadBalancerRule(String xId, String name, String description,
|
||||
int srcPortStart, int srcPortEnd, int defPortStart, int defPortEnd, Long ipAddrId, String protocol, String algorithm,
|
||||
long networkId, long lbOwnerId, boolean openFirewall) throws NetworkRuleConflictException, InsufficientAddressCapacityException;
|
||||
|
||||
LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd);
|
||||
|
||||
|
|
@ -134,8 +137,9 @@ public interface LoadBalancingRulesService {
|
|||
|
||||
List<? extends HealthCheckPolicy> searchForLBHealthCheckPolicies(ListLBHealthCheckPoliciesCmd cmd);
|
||||
|
||||
List<LoadBalancingRule> listByNetworkId(long networkId);
|
||||
|
||||
LoadBalancer findById(long LoadBalancer);
|
||||
public void updateLBHealthChecks() throws ResourceUnavailableException;
|
||||
|
||||
public void updateLBHealthChecks(Scheme scheme) throws ResourceUnavailableException;
|
||||
|
||||
Map<Ip, UserVm> getLbInstances(long lbId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import com.cloud.vm.VirtualMachine;
|
|||
*/
|
||||
public interface VirtualRouter extends VirtualMachine {
|
||||
public enum Role {
|
||||
VIRTUAL_ROUTER, LB
|
||||
VIRTUAL_ROUTER, LB, INTERNAL_LB_VM
|
||||
}
|
||||
Role getRole();
|
||||
boolean getIsRedundantRouter();
|
||||
|
|
|
|||
|
|
@ -19,16 +19,10 @@ package com.cloud.network.rules;
|
|||
/**
|
||||
* Definition for a LoadBalancer
|
||||
*/
|
||||
public interface LoadBalancer extends FirewallRule {
|
||||
|
||||
String getName();
|
||||
|
||||
String getDescription();
|
||||
|
||||
public interface LoadBalancer extends FirewallRule, LoadBalancerContainer {
|
||||
|
||||
int getDefaultPortStart();
|
||||
|
||||
int getDefaultPortEnd();
|
||||
|
||||
String getAlgorithm();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.network.rules;
|
||||
|
||||
public interface LoadBalancerContainer {
|
||||
|
||||
public enum Scheme {
|
||||
Public, Internal;
|
||||
}
|
||||
|
||||
String getName();
|
||||
|
||||
String getDescription();
|
||||
|
||||
String getAlgorithm();
|
||||
|
||||
Scheme getScheme();
|
||||
|
||||
}
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
// under the License.
|
||||
package com.cloud.offering;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.acl.InfrastructureEntity;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
|
@ -38,6 +40,11 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
|
|||
Disabled,
|
||||
Enabled
|
||||
}
|
||||
|
||||
public enum Detail {
|
||||
InternalLbProvider,
|
||||
PublicLbProvider
|
||||
}
|
||||
|
||||
public final static String SystemPublicNetwork = "System-Public-Network";
|
||||
public final static String SystemControlNetwork = "System-Control-Network";
|
||||
|
|
@ -116,5 +123,9 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
|
|||
boolean isInline();
|
||||
|
||||
boolean getIsPersistent();
|
||||
|
||||
boolean getInternalLb();
|
||||
|
||||
boolean getPublicLb();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
|
|||
public static final String ssvmDefaultOffUniqueName = "Cloud.com-SecondaryStorage";
|
||||
public static final String routerDefaultOffUniqueName = "Cloud.Com-SoftwareRouter";
|
||||
public static final String elbVmDefaultOffUniqueName = "Cloud.Com-ElasticLBVm";
|
||||
public static final String internalLbVmDefaultOffUniqueName = "Cloud.Com-InternalLBVm";
|
||||
|
||||
public enum StorageType {
|
||||
local,
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
|||
SecondaryStorageVm,
|
||||
ElasticIpVm,
|
||||
ElasticLoadBalancerVm,
|
||||
InternalLoadBalancerVm,
|
||||
|
||||
/*
|
||||
* UserBareMetal is only used for selecting VirtualMachineGuru, there is no
|
||||
|
|
@ -196,7 +197,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
|||
public static boolean isSystemVM(VirtualMachine.Type vmtype) {
|
||||
if (DomainRouter.equals(vmtype)
|
||||
|| ConsoleProxy.equals(vmtype)
|
||||
|| SecondaryStorageVm.equals(vmtype)) {
|
||||
|| SecondaryStorageVm.equals(vmtype) || InternalLoadBalancerVm.equals(vmtype)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -480,6 +480,12 @@ public class ApiConstants {
|
|||
public static final String HEALTHCHECK_HEALTHY_THRESHOLD = "healthythreshold";
|
||||
public static final String HEALTHCHECK_UNHEALTHY_THRESHOLD = "unhealthythreshold";
|
||||
public static final String HEALTHCHECK_PINGPATH = "pingpath";
|
||||
public static final String SOURCE_PORT = "sourceport";
|
||||
public static final String INSTANCE_PORT = "instanceport";
|
||||
public static final String SOURCE_IP = "sourceipaddress";
|
||||
public static final String SOURCE_IP_NETWORK_ID = "sourceipaddressnetworkid";
|
||||
public static final String SCHEME = "scheme";
|
||||
public static final String PROVIDER_TYPE = "providertype";
|
||||
public static final String AFFINITY_GROUP_IDS = "affinitygroupids";
|
||||
public static final String AFFINITY_GROUP_NAMES = "affinitygroupnames";
|
||||
public static final String ASA_INSIDE_PORT_PROFILE = "insideportprofile";
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ import java.util.regex.Pattern;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.affinity.AffinityGroupService;
|
||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
|
||||
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
|
||||
import org.apache.cloudstack.query.QueryService;
|
||||
import org.apache.cloudstack.usage.UsageService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -139,7 +142,11 @@ public abstract class BaseCmd {
|
|||
@Inject public VMSnapshotService _vmSnapshotService;
|
||||
@Inject public DataStoreProviderApiService dataStoreProviderApiService;
|
||||
@Inject public VpcProvisioningService _vpcProvSvc;
|
||||
@Inject public ApplicationLoadBalancerService _newLbSvc;
|
||||
@Inject public ApplicationLoadBalancerService _appLbService;
|
||||
@Inject public AffinityGroupService _affinityGroupService;
|
||||
@Inject public InternalLoadBalancerElementService _internalLbElementSvc;
|
||||
@Inject public InternalLoadBalancerVMService _internalLbSvc;
|
||||
@Inject public NetworkModel _ntwkModel;
|
||||
|
||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
||||
|
|
|
|||
|
|
@ -19,14 +19,15 @@ package org.apache.cloudstack.api;
|
|||
import java.text.DecimalFormat;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.vm.NicSecondaryIp;
|
||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.ApiConstants.HostDetails;
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
|
||||
import org.apache.cloudstack.api.response.AccountResponse;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.AsyncJobResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
|
||||
|
|
@ -44,11 +45,15 @@ import org.apache.cloudstack.api.response.EventResponse;
|
|||
import org.apache.cloudstack.api.response.ExtractResponse;
|
||||
import org.apache.cloudstack.api.response.FirewallResponse;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.GuestOSResponse;
|
||||
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
|
||||
import org.apache.cloudstack.api.response.HostForMigrationResponse;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
|
||||
import org.apache.cloudstack.api.response.IPAddressResponse;
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
|
||||
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
|
||||
import org.apache.cloudstack.api.response.IsolationMethodResponse;
|
||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
|
||||
|
|
@ -84,6 +89,7 @@ import org.apache.cloudstack.api.response.SnapshotResponse;
|
|||
import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
|
||||
import org.apache.cloudstack.api.response.StaticRouteResponse;
|
||||
import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.StoragePoolForMigrationResponse;
|
||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||
import org.apache.cloudstack.api.response.SwiftResponse;
|
||||
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
|
||||
|
|
@ -103,6 +109,7 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
|||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
|
||||
import org.apache.cloudstack.region.Region;
|
||||
import org.apache.cloudstack.usage.Usage;
|
||||
|
||||
|
|
@ -119,10 +126,25 @@ import com.cloud.domain.Domain;
|
|||
import com.cloud.event.Event;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.hypervisor.HypervisorCapabilities;
|
||||
import com.cloud.network.*;
|
||||
import com.cloud.network.GuestVlan;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.as.*;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkTrafficType;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.as.AutoScalePolicy;
|
||||
import com.cloud.network.as.AutoScaleVmGroup;
|
||||
import com.cloud.network.as.AutoScaleVmProfile;
|
||||
import com.cloud.network.as.Condition;
|
||||
import com.cloud.network.as.Counter;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.HealthCheckPolicy;
|
||||
|
|
@ -145,7 +167,12 @@ import com.cloud.projects.ProjectAccount;
|
|||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.region.ha.GlobalLoadBalancerRule;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.storage.*;
|
||||
import com.cloud.storage.GuestOS;
|
||||
import com.cloud.storage.S3;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.Swift;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.snapshot.SnapshotPolicy;
|
||||
import com.cloud.storage.snapshot.SnapshotSchedule;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
|
@ -153,11 +180,12 @@ import com.cloud.user.Account;
|
|||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserAccount;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
import com.cloud.vm.NicSecondaryIp;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import org.apache.cloudstack.api.response.*;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
|
||||
public interface ResponseGenerator {
|
||||
UserResponse createUserResponse(UserAccount user);
|
||||
|
|
@ -397,9 +425,13 @@ public interface ResponseGenerator {
|
|||
NicSecondaryIpResponse createSecondaryIPToNicResponse(NicSecondaryIp result);
|
||||
public NicResponse createNicResponse(Nic result);
|
||||
|
||||
ApplicationLoadBalancerResponse createLoadBalancerContainerReponse(ApplicationLoadBalancerRule lb, Map<Ip, UserVm> lbInstances);
|
||||
|
||||
AffinityGroupResponse createAffinityGroupResponse(AffinityGroup group);
|
||||
|
||||
Long getAffinityGroupId(String name, long entityOwnerId);
|
||||
|
||||
InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result);
|
||||
|
||||
IsolationMethodResponse createIsolationMethodResponse(IsolationType method);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.admin.internallb;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
|
||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(name = "configureInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class,
|
||||
description="Configures an Internal Load Balancer element.", since="4.2.0")
|
||||
public class ConfigureInternalLoadBalancerElementCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ConfigureInternalLoadBalancerElementCmd.class.getName());
|
||||
private static final String s_name = "configureinternalloadbalancerelementresponse";
|
||||
|
||||
@Inject
|
||||
private List<InternalLoadBalancerElementService> _service;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = InternalLoadBalancerElementResponse.class,
|
||||
required=true, description="the ID of the internal lb provider")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enables/Disables the Internal Load Balancer element")
|
||||
private Boolean enabled;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_NETWORK_ELEMENT_CONFIGURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "configuring internal load balancer element: " + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
s_logger.debug("hello alena");
|
||||
UserContext.current().setEventDetails("Internal load balancer element: " + id);
|
||||
s_logger.debug("hello alena");
|
||||
VirtualRouterProvider result = _service.get(0).configureInternalLoadBalancerElement(getId(), getEnabled());
|
||||
s_logger.debug("hello alena");
|
||||
if (result != null){
|
||||
InternalLoadBalancerElementResponse routerResponse = _responseGenerator.createInternalLbElementResponse(result);
|
||||
routerResponse.setResponseName(getCommandName());
|
||||
this.setResponseObject(routerResponse);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the internal load balancer element");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.internallb;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
|
||||
import org.apache.cloudstack.api.response.ProviderResponse;
|
||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(name = "createInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class, description="Create an Internal Load Balancer element.",since="4.2.0")
|
||||
public class CreateInternalLoadBalancerElementCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateInternalLoadBalancerElementCmd.class.getName());
|
||||
private static final String s_name = "createinternalloadbalancerelementresponse";
|
||||
|
||||
@Inject
|
||||
private List<InternalLoadBalancerElementService> _service;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.UUID, entityType = ProviderResponse.class, required=true, description="the network service provider ID of the internal load balancer element")
|
||||
private Long nspId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public void setNspId(Long nspId) {
|
||||
this.nspId = nspId;
|
||||
}
|
||||
|
||||
public Long getNspId() {
|
||||
return nspId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
|
||||
VirtualRouterProvider result = _service.get(0).getInternalLoadBalancerElement(getEntityId());
|
||||
if (result != null) {
|
||||
InternalLoadBalancerElementResponse response = _responseGenerator.createInternalLbElementResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VirtualRouterProvider result = _service.get(0).addInternalLoadBalancerElement(getNspId());
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Internal Load Balancer entity to physical network");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Adding physical network element Internal Load Balancer: " + getEntityId();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.internallb;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.api.response.PodResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
|
||||
@APICommand(name = "listInternalLoadBalancerVMs", description="List internal LB VMs.", responseObject=DomainRouterResponse.class)
|
||||
public class ListInternalLBVMsCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListInternalLBVMsCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listinternallbvmssresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class,
|
||||
description="the host ID of the Internal LB VM")
|
||||
private Long hostId;
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class,
|
||||
description="the ID of the Internal LB VM")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the Internal LB VM")
|
||||
private String routerName;
|
||||
|
||||
@Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
|
||||
description="the Pod ID of the Internal LB VM")
|
||||
private Long podId;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the Internal LB VM")
|
||||
private String state;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
|
||||
description="the Zone ID of the Internal LB VM")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType=NetworkResponse.class,
|
||||
description="list by network id")
|
||||
private Long networkId;
|
||||
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType=VpcResponse.class,
|
||||
description="List Internal LB VMs by VPC")
|
||||
private Long vpcId;
|
||||
|
||||
@Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC Internal LB VMs")
|
||||
private Boolean forVpc;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
|
||||
private String zoneType;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getRouterName() {
|
||||
return routerName;
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public Boolean getForVpc() {
|
||||
return forVpc;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return Role.INTERNAL_LB_VM.toString();
|
||||
}
|
||||
|
||||
public String getZoneType() {
|
||||
return zoneType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.DomainRouter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
ListResponse<DomainRouterResponse> response = _queryService.searchForInternalLbVms(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.internallb;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ProviderResponse;
|
||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
|
||||
@APICommand(name = "listInternalLoadBalancerElements", description="Lists all available Internal Load Balancer elements.",
|
||||
responseObject=InternalLoadBalancerElementResponse.class, since="4.2.0")
|
||||
public class ListInternalLoadBalancerElementsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListInternalLoadBalancerElementsCmd.class.getName());
|
||||
private static final String _name = "listinternalloadbalancerelementsresponse";
|
||||
|
||||
@Inject
|
||||
private InternalLoadBalancerElementService _service;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = InternalLoadBalancerElementResponse.class,
|
||||
description="list internal load balancer elements by id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NSP_ID, type=CommandType.UUID, entityType = ProviderResponse.class,
|
||||
description="list internal load balancer elements by network service provider id")
|
||||
private Long nspId;
|
||||
|
||||
@Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, description="list internal load balancer elements by enabled state")
|
||||
private Boolean enabled;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getNspId() {
|
||||
return nspId;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
||||
List<? extends VirtualRouterProvider> providers = _service.searchForInternalLoadBalancerElements(getId(), getNspId(), getEnabled());
|
||||
ListResponse<InternalLoadBalancerElementResponse> response = new ListResponse<InternalLoadBalancerElementResponse>();
|
||||
List<InternalLoadBalancerElementResponse> providerResponses = new ArrayList<InternalLoadBalancerElementResponse>();
|
||||
for (VirtualRouterProvider provider : providers) {
|
||||
InternalLoadBalancerElementResponse providerResponse = _responseGenerator.createInternalLbElementResponse(provider);
|
||||
providerResponses.add(providerResponse);
|
||||
}
|
||||
response.setResponses(providerResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.internallb;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(name = "startInternalLoadBalancerVM", responseObject=DomainRouterResponse.class, description="Starts an existing internal lb vm.")
|
||||
public class StartInternalLBVMCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StartInternalLBVMCmd.class.getName());
|
||||
private static final String s_name = "startinternallbvmresponse";
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=DomainRouterResponse.class,
|
||||
required=true, description="the ID of the internal lb vm")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "router";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
|
||||
if (router != null && router.getRole() == Role.INTERNAL_LB_VM) {
|
||||
return router.getAccountId();
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unable to find internal lb vm by id");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_INTERNAL_LB_VM_START;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "starting internal lb vm: " + getId();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.InternalLbVm;
|
||||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
UserContext.current().setEventDetails("Internal Lb Vm Id: "+getId());
|
||||
VirtualRouter result = null;
|
||||
VirtualRouter router = _routerService.findRouter(getId());
|
||||
if (router == null || router.getRole() != Role.INTERNAL_LB_VM) {
|
||||
throw new InvalidParameterValueException("Can't find internal lb vm by id");
|
||||
} else {
|
||||
result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
|
||||
}
|
||||
|
||||
if (result != null){
|
||||
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
|
||||
routerResponse.setResponseName(getCommandName());
|
||||
this.setResponseObject(routerResponse);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start internal lb vm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.internallb;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(name = "stopInternalLoadBalancerVM", description = "Stops an Internal LB vm.", responseObject = DomainRouterResponse.class)
|
||||
public class StopInternalLBVMCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StopInternalLBVMCmd.class.getName());
|
||||
private static final String s_name = "stopinternallbvmresponse";
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ////////////// API parameters /////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class,
|
||||
required = true, description = "the ID of the internal lb vm")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
|
||||
private Boolean forced;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
VirtualRouter vm = _entityMgr.findById(VirtualRouter.class, getId());
|
||||
if (vm != null && vm.getRole() == Role.INTERNAL_LB_VM) {
|
||||
return vm.getAccountId();
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unable to find internal lb vm by id");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_INTERNAL_LB_VM_STOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "stopping internal lb vm: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.InternalLbVm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
public boolean isForced() {
|
||||
return (forced != null) ? forced : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
UserContext.current().setEventDetails("Internal lb vm Id: "+getId());
|
||||
VirtualRouter result = null;
|
||||
VirtualRouter vm = _routerService.findRouter(getId());
|
||||
if (vm == null || vm.getRole() != Role.INTERNAL_LB_VM) {
|
||||
throw new InvalidParameterValueException("Can't find internal lb vm by id");
|
||||
} else {
|
||||
result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop internal lb vm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,6 @@ import org.apache.cloudstack.api.Parameter;
|
|||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
|
|
@ -95,6 +94,10 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||
|
||||
@Parameter(name=ApiConstants.IS_PERSISTENT, type=CommandType.BOOLEAN, description="true if network offering supports persistent networks; defaulted to false if not specified")
|
||||
private Boolean isPersistent;
|
||||
|
||||
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, since="4.2.0", description="Template details in key/value pairs." +
|
||||
" Supported keys are internallbprovider/publiclbprovider with service provider as a value")
|
||||
protected Map details;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -215,6 +218,16 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||
|
||||
return capabilityMap;
|
||||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
if (details == null || details.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Collection paramsCollection = details.values();
|
||||
Map<String, String> params = (Map<String, String>) (paramsCollection.toArray())[0];
|
||||
return params;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
|
|
@ -52,6 +53,9 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.UUID, entityType = ProviderResponse.class, required=true, description="the network service provider ID of the virtual router element")
|
||||
private Long nspId;
|
||||
|
||||
@Parameter(name=ApiConstants.PROVIDER_TYPE, type=CommandType.UUID, entityType = ProviderResponse.class, description="The provider type. Supported types are VirtualRouter (default) and VPCVirtualRouter")
|
||||
private String providerType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -61,16 +65,27 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
|||
this.nspId = nspId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Long getNspId() {
|
||||
return nspId;
|
||||
}
|
||||
|
||||
public VirtualRouterProviderType getProviderType() {
|
||||
if (providerType != null) {
|
||||
if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VirtualRouter.toString())) {
|
||||
return VirtualRouterProviderType.VirtualRouter;
|
||||
} else if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VPCVirtualRouter.toString())) {
|
||||
return VirtualRouterProviderType.VPCVirtualRouter;
|
||||
} else throw new InvalidParameterValueException("Invalid providerType specified");
|
||||
}
|
||||
return VirtualRouterProviderType.VirtualRouter;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
|
|
@ -96,7 +111,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VirtualRouterProvider result = _service.get(0).addElement(getNspId(), VirtualRouterProviderType.VirtualRouter);
|
||||
VirtualRouterProvider result = _service.get(0).addElement(getNspId(), getProviderType());
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.cloudstack.api.response.ZoneResponse;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
|
||||
@APICommand(name = "listRouters", description="List routers.", responseObject=DomainRouterResponse.class)
|
||||
public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
|
|
@ -77,7 +78,7 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
|
||||
@Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC routers")
|
||||
private Boolean forVpc;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -121,6 +122,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||
public Boolean getForVpc() {
|
||||
return forVpc;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return Role.VIRTUAL_ROUTER.toString();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -29,8 +29,10 @@ import com.cloud.async.AsyncJob;
|
|||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
|
|
@ -100,7 +102,13 @@ public class StartRouterCmd extends BaseAsyncCmd {
|
|||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
UserContext.current().setEventDetails("Router Id: "+getId());
|
||||
VirtualRouter result = _routerService.startRouter(id);
|
||||
VirtualRouter result = null;
|
||||
VirtualRouter router = _routerService.findRouter(getId());
|
||||
if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
|
||||
throw new InvalidParameterValueException("Can't find router by id");
|
||||
} else {
|
||||
result = _routerService.startRouter(getId());
|
||||
}
|
||||
if (result != null){
|
||||
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
|
||||
routerResponse.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -28,8 +28,10 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
|
|
@ -103,7 +105,14 @@ public class StopRouterCmd extends BaseAsyncCmd {
|
|||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
UserContext.current().setEventDetails("Router Id: "+getId());
|
||||
VirtualRouter result = _routerService.stopRouter(getId(), isForced());
|
||||
VirtualRouter result = null;
|
||||
VirtualRouter router = _routerService.findRouter(getId());
|
||||
if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
|
||||
throw new InvalidParameterValueException("Can't find router by id");
|
||||
} else {
|
||||
result = _routerService.stopRouter(getId(), isForced());
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,218 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@APICommand(name = "createLoadBalancer", description="Creates a Load Balancer", responseObject=ApplicationLoadBalancerResponse.class, since="4.2.0")
|
||||
public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateApplicationLoadBalancerCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createloadbalancerresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the Load Balancer")
|
||||
private String loadBalancerName;
|
||||
|
||||
@Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description of the Load Balancer", length=4096)
|
||||
private String description;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, required=true, entityType = NetworkResponse.class,
|
||||
description="The guest network the Load Balancer will be created for")
|
||||
private Long networkId;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_PORT, type=CommandType.INTEGER, required=true, description="the source port the network traffic will be load balanced from")
|
||||
private Integer sourcePort;
|
||||
|
||||
@Parameter(name=ApiConstants.ALGORITHM, type=CommandType.STRING, required=true, description="load balancer algorithm (source, roundrobin, leastconn)")
|
||||
private String algorithm;
|
||||
|
||||
@Parameter(name=ApiConstants.INSTANCE_PORT, type=CommandType.INTEGER, required=true, description="the TCP port of the virtual machine where the network traffic will be load balanced to")
|
||||
private Integer instancePort;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_IP, type=CommandType.STRING, description="the source ip address the network traffic will be load balanced from")
|
||||
private String sourceIp;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_IP_NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class, required=true,
|
||||
description="the network id of the source ip address")
|
||||
private Long sourceIpNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.SCHEME, type=CommandType.STRING, required=true, description="the load balancer scheme. Supported value in this release is Internal")
|
||||
private String scheme;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getLoadBalancerName() {
|
||||
return loadBalancerName;
|
||||
}
|
||||
|
||||
public Integer getPrivatePort() {
|
||||
return instancePort;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return loadBalancerName;
|
||||
}
|
||||
|
||||
public Integer getSourcePort() {
|
||||
return sourcePort.intValue();
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return NetUtils.TCP_PROTO;
|
||||
}
|
||||
|
||||
public long getAccountId() {
|
||||
//get account info from the network object
|
||||
Network ntwk = _networkService.getNetwork(networkId);
|
||||
if (ntwk == null) {
|
||||
throw new InvalidParameterValueException("Invalid network id specified");
|
||||
}
|
||||
|
||||
return ntwk.getAccountId();
|
||||
|
||||
}
|
||||
|
||||
public int getInstancePort() {
|
||||
return instancePort.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_LOAD_BALANCER_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating load balancer: " + getName() + " account: " + getAccountId();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.LoadBalancerRule;
|
||||
}
|
||||
|
||||
public String getSourceIp() {
|
||||
return sourceIp;
|
||||
}
|
||||
|
||||
public long getSourceIpNetworkId() {
|
||||
return sourceIpNetworkId;
|
||||
}
|
||||
|
||||
public Scheme getScheme() {
|
||||
if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) {
|
||||
return Scheme.Internal;
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return getAccountId();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
|
||||
ApplicationLoadBalancerRule rule = null;
|
||||
try {
|
||||
UserContext.current().setEventDetails("Load Balancer Id: " + getEntityId());
|
||||
// State might be different after the rule is applied, so get new object here
|
||||
rule = _entityMgr.findById(ApplicationLoadBalancerRule.class, getEntityId());
|
||||
ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getEntityId()));
|
||||
setResponseObject(lbResponse);
|
||||
lbResponse.setResponseName(getCommandName());
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to create Load Balancer due to exception ", ex);
|
||||
} finally {
|
||||
if (rule == null) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Load Balancer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
try {
|
||||
|
||||
ApplicationLoadBalancerRule result = _appLbService.createApplicationLoadBalancer(getName(), getDescription(), getScheme(),
|
||||
getSourceIpNetworkId(), getSourceIp(), getSourcePort(), getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId());
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
}catch (NetworkRuleConflictException e) {
|
||||
s_logger.warn("Exception: ", e);
|
||||
throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
|
||||
} catch (InsufficientAddressCapacityException e) {
|
||||
s_logger.warn("Exception: ", e);
|
||||
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
|
||||
} catch (InsufficientVirtualNetworkCapcityException e) {
|
||||
s_logger.warn("Exception: ", e);
|
||||
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
|||
}
|
||||
|
||||
|
||||
public Long getNetworkId() {
|
||||
public long getNetworkId() {
|
||||
if (networkId != null) {
|
||||
return networkId;
|
||||
}
|
||||
|
|
@ -278,7 +278,9 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
|||
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
|
||||
}
|
||||
try {
|
||||
LoadBalancer result = _lbService.createLoadBalancerRule(this, getOpenFirewall());
|
||||
LoadBalancer result = _lbService.createPublicLoadBalancerRule(getXid(), getName(), getDescription(),
|
||||
getSourcePortStart(), getSourcePortEnd(), getDefaultPortStart(), getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(),
|
||||
getNetworkId(), getEntityOwnerId(), getOpenFirewall());
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(name = "deleteLoadBalancer", description="Deletes a load balancer", responseObject=SuccessResponse.class, since="4.2.0")
|
||||
public class DeleteApplicationLoadBalancerCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteApplicationLoadBalancerCmd.class.getName());
|
||||
private static final String s_name = "deleteloadbalancerresponse";
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = FirewallRuleResponse.class,
|
||||
required=true, description="the ID of the Load Balancer")
|
||||
private Long id;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
ApplicationLoadBalancerRule lb = _entityMgr.findById(ApplicationLoadBalancerRule.class, getId());
|
||||
if (lb != null) {
|
||||
return lb.getAccountId();
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Can't find load balancer by id specified");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_LOAD_BALANCER_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "deleting load balancer: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Load balancer Id: " + getId());
|
||||
boolean result = _appLbService.deleteApplicationLoadBalancer(getId());
|
||||
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete load balancer");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
ApplicationLoadBalancerRule lb = _appLbService.getApplicationLoadBalancer(id);
|
||||
if(lb == null){
|
||||
throw new InvalidParameterValueException("Unable to find load balancer by id ");
|
||||
}
|
||||
return lb.getNetworkId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.FirewallRule;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@APICommand(name = "listLoadBalancers", description = "Lists Load Balancers", responseObject = ApplicationLoadBalancerResponse.class, since="4.2.0")
|
||||
public class ListApplicationLoadBalancersCmd extends BaseListTaggedResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListApplicationLoadBalancersCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listloadbalancerssresponse";
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ////////////// API parameters /////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class,
|
||||
description = "the ID of the Load Balancer")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the Load Balancer")
|
||||
private String loadBalancerName;
|
||||
|
||||
@Parameter(name = ApiConstants.SOURCE_IP, type = CommandType.STRING, description = "the source ip address of the Load Balancer")
|
||||
private String sourceIp;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_IP_NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
|
||||
description="the network id of the source ip address")
|
||||
private Long sourceIpNetworkId;
|
||||
|
||||
@Parameter(name = ApiConstants.SCHEME, type = CommandType.STRING, description = "the scheme of the Load Balancer. Supported value is Internal in the current release")
|
||||
private String scheme;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
|
||||
description="the network id of the Load Balancer")
|
||||
private Long networkId;
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getLoadBalancerRuleName() {
|
||||
return loadBalancerName;
|
||||
}
|
||||
|
||||
public String getLoadBalancerName() {
|
||||
return loadBalancerName;
|
||||
}
|
||||
|
||||
public String getSourceIp() {
|
||||
return sourceIp;
|
||||
}
|
||||
|
||||
public Long getSourceIpNetworkId() {
|
||||
return sourceIpNetworkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public Scheme getScheme() {
|
||||
if (scheme != null) {
|
||||
if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) {
|
||||
return Scheme.Internal;
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Pair<List<? extends ApplicationLoadBalancerRule>, Integer> loadBalancers = _appLbService.listApplicationLoadBalancers(this);
|
||||
ListResponse<ApplicationLoadBalancerResponse> response = new ListResponse<ApplicationLoadBalancerResponse>();
|
||||
List<ApplicationLoadBalancerResponse> lbResponses = new ArrayList<ApplicationLoadBalancerResponse>();
|
||||
for (ApplicationLoadBalancerRule loadBalancer : loadBalancers.first()) {
|
||||
ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(loadBalancer, _lbService.getLbInstances(loadBalancer.getId()));
|
||||
lbResponse.setObjectName("loadbalancer");
|
||||
lbResponses.add(lbResponse);
|
||||
}
|
||||
response.setResponses(lbResponses, loadBalancers.second());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
*
|
||||
* Load Balancer instance is the User Vm instance participating in the Load Balancer
|
||||
*
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ApplicationLoadBalancerInstanceResponse extends BaseResponse{
|
||||
|
||||
@SerializedName(ApiConstants.ID) @Param(description = "the instance ID")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.NAME) @Param(description = "the name of the instance")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="the state of the instance")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS)
|
||||
@Param(description="the ip address of the instance")
|
||||
private String ipAddress;
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setIpAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ApplicationLoadBalancerResponse extends BaseResponse implements ControlledEntityResponse{
|
||||
@SerializedName(ApiConstants.ID) @Param(description = "the Load Balancer ID")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.NAME) @Param(description = "the name of the Load Balancer")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.DESCRIPTION) @Param(description = "the description of the Load Balancer")
|
||||
private String description;
|
||||
|
||||
@SerializedName(ApiConstants.ALGORITHM) @Param(description = "the load balancer algorithm (source, roundrobin, leastconn)")
|
||||
private String algorithm;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_ID) @Param(description="Load Balancer network id")
|
||||
private String networkId;
|
||||
|
||||
@SerializedName(ApiConstants.SOURCE_IP) @Param(description="Load Balancer source ip")
|
||||
private String sourceIp;
|
||||
|
||||
@SerializedName(ApiConstants.SOURCE_IP_NETWORK_ID) @Param(description="Load Balancer source ip network id")
|
||||
private String sourceIpNetworkId;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT)
|
||||
@Param(description = "the account of the Load Balancer")
|
||||
private String accountName;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the Load Balancer")
|
||||
private String projectId;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the Load Balancer")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
@Param(description = "the domain ID of the Load Balancer")
|
||||
private String domainId;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
@Param(description = "the domain of the Load Balancer")
|
||||
private String domainName;
|
||||
|
||||
@SerializedName("loadbalancerrule") @Param(description="the list of rules associated with the Load Balancer", responseObject = ApplicationLoadBalancerRuleResponse.class)
|
||||
private List<ApplicationLoadBalancerRuleResponse> lbRules;
|
||||
|
||||
@SerializedName("loadbalancerinstance") @Param(description="the list of instances associated with the Load Balancer", responseObject = ApplicationLoadBalancerInstanceResponse.class)
|
||||
private List<ApplicationLoadBalancerInstanceResponse> lbInstances;
|
||||
|
||||
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with the Load Balancer", responseObject = ResourceTagResponse.class)
|
||||
private List<ResourceTagResponse> tags;
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public void setTags(List<ResourceTagResponse> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
public void setNetworkId(String networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public void setSourceIp(String sourceIp) {
|
||||
this.sourceIp = sourceIp;
|
||||
}
|
||||
|
||||
public void setSourceIpNetworkId(String sourceIpNetworkId) {
|
||||
this.sourceIpNetworkId = sourceIpNetworkId;
|
||||
}
|
||||
|
||||
public void setLbRules(List<ApplicationLoadBalancerRuleResponse> lbRules) {
|
||||
this.lbRules = lbRules;
|
||||
}
|
||||
|
||||
public void setLbInstances(List<ApplicationLoadBalancerInstanceResponse> lbInstances) {
|
||||
this.lbInstances = lbInstances;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Subobject of the load balancer container response
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ApplicationLoadBalancerRuleResponse extends BaseResponse{
|
||||
@SerializedName(ApiConstants.SOURCE_PORT) @Param(description = "source port of the load balancer rule")
|
||||
private Integer sourcePort;
|
||||
|
||||
@SerializedName(ApiConstants.INSTANCE_PORT) @Param(description = "instance port of the load balancer rule")
|
||||
private Integer instancePort;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description = "the state of the load balancer rule")
|
||||
private String state;
|
||||
|
||||
public void setSourcePort(Integer sourcePort) {
|
||||
this.sourcePort = sourcePort;
|
||||
}
|
||||
|
||||
public void setInstancePort(Integer instancePort) {
|
||||
this.instancePort = instancePort;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
|
@ -153,8 +153,11 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
|
|||
@SerializedName("scriptsversion") @Param(description="the version of scripts")
|
||||
private String scriptsVersion;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the network belongs to")
|
||||
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the router belongs to")
|
||||
private String vpcId;
|
||||
|
||||
@SerializedName(ApiConstants.ROLE) @Param(description="role of the domain router")
|
||||
private String role;
|
||||
|
||||
@SerializedName("nic") @Param(description="the list of nics associated with the router",
|
||||
responseObject = NicResponse.class, since="4.0")
|
||||
|
|
@ -164,15 +167,11 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
|
|||
nics = new LinkedHashSet<NicResponse>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getObjectId() {
|
||||
return this.getId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -372,4 +371,8 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
|
|||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value=VirtualRouterProvider.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class InternalLoadBalancerElementResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the id of the internal load balancer element")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.NSP_ID) @Param(description="the physical network service provider id of the element")
|
||||
private String nspId;
|
||||
|
||||
@SerializedName(ApiConstants.ENABLED) @Param(description="Enabled/Disabled the element")
|
||||
private Boolean enabled;
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setNspId(String nspId) {
|
||||
this.nspId = nspId;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response;
|
|||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
|
@ -83,6 +84,10 @@ public class NetworkOfferingResponse extends BaseResponse {
|
|||
|
||||
@SerializedName(ApiConstants.IS_PERSISTENT) @Param(description="true if network offering supports persistent networks, false otherwise")
|
||||
private Boolean isPersistent;
|
||||
|
||||
@SerializedName(ApiConstants.DETAILS) @Param(description="additional key/value details tied with network offering", since="4.2.0")
|
||||
private Map details;
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
|
|
@ -156,5 +161,9 @@ public class NetworkOfferingResponse extends BaseResponse {
|
|||
public void setIsPersistent(Boolean isPersistent) {
|
||||
this.isPersistent = isPersistent;
|
||||
}
|
||||
|
||||
public void setDetails(Map details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.cloud.serializer.Param;
|
|||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value=VirtualRouterProvider.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class VirtualRouterProviderResponse extends BaseResponse implements ControlledEntityResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the id of the router")
|
||||
private String id;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.network.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface InternalLoadBalancerElementService extends PluggableService{
|
||||
/**
|
||||
* Configures existing Internal Load Balancer Element (enables or disables it)
|
||||
* @param id
|
||||
* @param enable
|
||||
* @return
|
||||
*/
|
||||
VirtualRouterProvider configureInternalLoadBalancerElement(long id, boolean enable);
|
||||
|
||||
/**
|
||||
* Adds Internal Load Balancer element to the Network Service Provider
|
||||
* @param ntwkSvcProviderId
|
||||
* @return
|
||||
*/
|
||||
VirtualRouterProvider addInternalLoadBalancerElement(long ntwkSvcProviderId);
|
||||
|
||||
/**
|
||||
* Retrieves existing Internal Load Balancer element
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
VirtualRouterProvider getInternalLoadBalancerElement(long id);
|
||||
|
||||
/**
|
||||
* Searches for existing Internal Load Balancer elements based on parameters passed to the call
|
||||
* @param id
|
||||
* @param ntwkSvsProviderId
|
||||
* @param enabled
|
||||
* @return
|
||||
*/
|
||||
List<? extends VirtualRouterProvider> searchForInternalLoadBalancerElements(Long id, Long ntwkSvsProviderId, Boolean enabled);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.network.lb;
|
||||
|
||||
import com.cloud.network.rules.LoadBalancerContainer;
|
||||
import com.cloud.utils.net.Ip;
|
||||
|
||||
public interface ApplicationLoadBalancerContainer extends LoadBalancerContainer{
|
||||
|
||||
public Long getSourceIpNetworkId();
|
||||
|
||||
public Ip getSourceIp();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.network.lb;
|
||||
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
|
||||
public interface ApplicationLoadBalancerRule extends ApplicationLoadBalancerContainer, LoadBalancer{
|
||||
int getInstancePort();
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.network.lb;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.ListApplicationLoadBalancersCmd;
|
||||
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public interface ApplicationLoadBalancerService {
|
||||
|
||||
ApplicationLoadBalancerRule createApplicationLoadBalancer(String name, String description, Scheme scheme, long sourceIpNetworkId, String sourceIp,
|
||||
int sourcePort, int instancePort, String algorithm, long networkId, long lbOwnerId) throws InsufficientAddressCapacityException,
|
||||
NetworkRuleConflictException, InsufficientVirtualNetworkCapcityException;
|
||||
|
||||
boolean deleteApplicationLoadBalancer(long id);
|
||||
|
||||
Pair<List<? extends ApplicationLoadBalancerRule>, Integer> listApplicationLoadBalancers(ListApplicationLoadBalancersCmd cmd);
|
||||
|
||||
ApplicationLoadBalancerRule getApplicationLoadBalancer(long ruleId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.network.lb;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
public interface InternalLoadBalancerVMService {
|
||||
|
||||
VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId)
|
||||
throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
VirtualRouter stopInternalLbVm(long vmId, boolean forced, Account caller, long callerUserId)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ package org.apache.cloudstack.query;
|
|||
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
|
||||
|
|
@ -101,4 +102,6 @@ public interface QueryService {
|
|||
|
||||
public ListResponse<AffinityGroupResponse> listAffinityGroups(Long affinityGroupId, String affinityGroupName,
|
||||
String affinityGroupType, Long vmId, Long startIndex, Long pageSize);
|
||||
|
||||
ListResponse<DomainRouterResponse> searchForInternalLbVms(ListInternalLBVMsCmd cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,11 @@
|
|||
<artifactId>cloud-plugin-network-midonet</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-network-internallb</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-hypervisor-xen</artifactId>
|
||||
|
|
|
|||
|
|
@ -363,6 +363,9 @@
|
|||
<bean id="vpcOfferingServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingServiceMapDaoImpl" />
|
||||
<bean id="vpcServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcServiceMapDaoImpl" />
|
||||
<bean id="vpnUserDaoImpl" class="com.cloud.network.dao.VpnUserDaoImpl" />
|
||||
<bean id="applicationLbRuleDaoImpl" class="org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDaoImpl" />
|
||||
<bean id="networkOfferingDetailsDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDetailsDaoImpl" />
|
||||
|
||||
|
||||
<!--
|
||||
Checkers
|
||||
|
|
@ -406,10 +409,12 @@
|
|||
<bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
|
||||
<property name="name" value="VpcVirtualRouter"/>
|
||||
</bean>
|
||||
|
||||
<bean id="elasticLoadBalancerElement" class="com.cloud.network.element.ElasticLoadBalancerElement">
|
||||
<property name="name" value="ElasticLoadBalancerElement"/>
|
||||
</bean>
|
||||
<bean id="InternalLbVm" class="org.apache.cloudstack.network.element.InternalLoadBalancerElement">
|
||||
<property name="name" value="InternalLbVm"/>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
General allocators
|
||||
|
|
@ -789,6 +794,8 @@
|
|||
<bean id="vMSnapshotManagerImpl" class="com.cloud.vm.snapshot.VMSnapshotManagerImpl" />
|
||||
<bean id="volumeManagerImpl" class="com.cloud.storage.VolumeManagerImpl" />
|
||||
<bean id="ClassicalPrimaryDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl" />
|
||||
<bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" />
|
||||
<bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" />
|
||||
|
||||
|
||||
<!--=======================================================================================================-->
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ getVMPassword=15
|
|||
restoreVirtualMachine=15
|
||||
changeServiceForVirtualMachine=15
|
||||
scaleVirtualMachine=15
|
||||
assignVirtualMachine=1
|
||||
assignVirtualMachine=7
|
||||
migrateVirtualMachine=1
|
||||
migrateVirtualMachineWithVolume=1
|
||||
recoverVirtualMachine=7
|
||||
|
|
@ -577,6 +577,17 @@ revertToVMSnapshot=15
|
|||
#### Baremetal commands
|
||||
addBaremetalHost=1
|
||||
|
||||
#### New Load Balancer commands
|
||||
createLoadBalancer=15
|
||||
listLoadBalancers=15
|
||||
deleteLoadBalancer=15
|
||||
|
||||
#Internal Load Balancer Element commands
|
||||
configureInternalLoadBalancerElement=1
|
||||
createInternalLoadBalancerElement=1
|
||||
listInternalLoadBalancerElements=1
|
||||
|
||||
|
||||
#### Affinity group commands
|
||||
createAffinityGroup=15
|
||||
deleteAffinityGroup=15
|
||||
|
|
@ -594,5 +605,10 @@ addCiscoAsa1000vResource=1
|
|||
deleteCiscoAsa1000vResource=1
|
||||
listCiscoAsa1000vResources=1
|
||||
|
||||
#### Internal LB VM commands
|
||||
stopInternalLoadBalancerVM=1
|
||||
startInternalLoadBalancerVM=1
|
||||
listInternalLoadBalancerVMs=1
|
||||
|
||||
### Network Isolation methods listing
|
||||
listNetworkIsolationMethods=1
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@
|
|||
<ref bean="VirtualRouter"/>
|
||||
<ref bean="VpcVirtualRouter"/>
|
||||
<ref bean="NiciraNvp"/>
|
||||
<ref bean="InternalLbVm"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
|
@ -241,6 +242,7 @@
|
|||
<ref bean="VpcVirtualRouter"/>
|
||||
<ref bean="NiciraNvp" />
|
||||
<ref bean="MidoNetElement"/>
|
||||
<ref bean="InternalLbVm"/>
|
||||
<!--
|
||||
<ref bean="BareMetalDhcp"/>
|
||||
<ref bean="BareMetalPxe"/>
|
||||
|
|
|
|||
|
|
@ -294,6 +294,7 @@
|
|||
<ref bean="VirtualRouter"/>
|
||||
<ref bean="VpcVirtualRouter"/>
|
||||
<ref bean="NiciraNvp"/>
|
||||
<ref bean="InternalLbVm"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
|
@ -343,6 +344,7 @@
|
|||
<ref bean="Ovs"/>
|
||||
<ref bean="SecurityGroupProvider"/>
|
||||
<ref bean="VpcVirtualRouter"/>
|
||||
<ref bean="InternalLbVm"/>
|
||||
<!--
|
||||
<ref bean="BareMetalDhcp"/>
|
||||
<ref bean="BareMetalPxe"/>
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@
|
|||
<ref bean="Ovs"/>
|
||||
<ref bean="SecurityGroupProvider"/>
|
||||
<ref bean="VpcVirtualRouter"/>
|
||||
<ref bean="InternalLbVm"/>
|
||||
<!--
|
||||
<ref bean="BareMetalDhcp"/>
|
||||
<ref bean="BareMetalPxe"/>
|
||||
|
|
|
|||
|
|
@ -91,20 +91,31 @@
|
|||
</listitem>
|
||||
<listitem>
|
||||
<para>listGlobalLoadBalancerRule</para>
|
||||
<para>Lists load balancer rules. account (lists resources by account. Use with the domainId
|
||||
parameter); domainid (lists only resources belonging to the domain specified) id (the unique
|
||||
ID of the global load balancer rule) isrecursive (defaults to false, but if true, lists all
|
||||
resources from the parent specified by the domainId till leaves); keyword (List by keyword);
|
||||
listall (if set to false, list only resources belonging to the command's caller; if set to
|
||||
true - list resources that the caller is authorized to see. Default value is false); page;
|
||||
pagesize; projectid (lists objects by project); regionid (region ID); tags (lists resources
|
||||
by tags: key/value pairs). </para>
|
||||
<para>Lists load balancer rules.</para>
|
||||
<para>The request parameters are: account (lists resources by account. Use with the domainid
|
||||
parameter); domainid (lists only resources belonging to the domain specified); id (the
|
||||
unique ID of the global load balancer rule); isrecursive (defaults to false; but if true,
|
||||
lists all the resources from the parent specified by the domainid); keyword (lists by
|
||||
keyword); listall (if set to false, lists only resources belonging to the command's caller;
|
||||
if set to true, lists resources that the caller is authorized to see. Default value is
|
||||
false); page; pagesize; projectid (lists objects by project); regionid ; tags (lists
|
||||
resources by tags: key/value pairs). </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>updateGlobalLoadBalancerRule</para>
|
||||
<para>Archives the specified events. The request parameters are: ids (allowed to pass one or
|
||||
more IDs separated by comma); type (string); olderthan (yyyy-mm-dd format).</para>
|
||||
<para>The response parameters are: true, false </para>
|
||||
<para>Updates global load balancer rules.</para>
|
||||
<para>The request parameters are: id (the unique ID of the global load balancer rule); account
|
||||
(lists resources by account. Use with the domainid parameter); description (the description
|
||||
of the load balancer rule); domainid (lists only resources belonging to the domain
|
||||
specified); gslblbmethod (the load balancer algorithm that is used to distributed traffic
|
||||
across the zones participating in global server load balancing, if not specified defaults to
|
||||
round robin); gslbstickysessionmethodname (the session sticky method; if not specified
|
||||
defaults to sourceip); isrecursive (defaults to false, but if true, lists all resources from
|
||||
the parent specified by the domainid till leaves); keyword (lists by keyword); listall (if
|
||||
set to false, list only those resources belonging to the command's caller; if set to true,
|
||||
lists resources that the caller is authorized to see. Default value is false); page;
|
||||
pagesize; projectid (lists objects by project); regionid; tags (lists resources by tags:
|
||||
key/value pairs)</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -29,5 +29,6 @@
|
|||
xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="ongoing-config-of-external-firewalls-lb.xml"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="load-balancer-rules.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="autoscale.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
achieve this by extending its functionality of integrating with NetScaler Application Delivery
|
||||
Controller (ADC), which also provides various GSLB capabilities, such as disaster recovery and
|
||||
load balancing. The DNS redirection technique is used to achieve GSLB in &PRODUCT;. </para>
|
||||
<para>In order to support his functionality, region level services and service provider are
|
||||
<para>In order to support this functionality, region level services and service provider are
|
||||
introduced. A new service 'GSLB' is introduced as a region level service. The GSLB service
|
||||
provider is introduced that will provider the GSLB service. Currently, NetScaler is the
|
||||
supported GSLB provider in &PRODUCT;. GSLB functionality works in an Active-Active data center
|
||||
|
|
@ -40,192 +40,456 @@
|
|||
multiple data centers situated at geographically separated locations. GSLB can also provide an
|
||||
alternate location for accessing a resource in the event of a failure, or to provide a means
|
||||
of shifting traffic easily to simplify maintenance, or both.</para>
|
||||
<section id="gslb-comp">
|
||||
<title>Components of GSLB</title>
|
||||
<para>A typical GSLB environment is comprised of the following components:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">GSLB Site</emphasis>: In &PRODUCT;terminology, GSLB sites are
|
||||
represented by zones that are mapped to data centers, each of which has various network
|
||||
appliances. Each GSLB site is managed by a NetScaler appliance that is local to that
|
||||
site. Each of these appliances treats its own site as the local site and all other
|
||||
sites, managed by other appliances, as remote sites. It is the central entity in a GSLB
|
||||
deployment, and is represented by a name and an IP address.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">GSLB Services</emphasis>: A GSLB service is typically
|
||||
represented by a load balancing or content switching virtual server. In a GSLB
|
||||
environment, you can have a local as well as remote GSLB services. A local GSLB service
|
||||
represents a local load balancing or content switching virtual server. A remote GSLB
|
||||
service is the one configured at one of the other sites in the GSLB setup. At each site
|
||||
in the GSLB setup, you can create one local GSLB service and any number of remote GSLB
|
||||
services.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">GSLB Virtual Servers</emphasis>: A GSLB virtual server refers
|
||||
to one or more GSLB services and balances traffic between traffic across the VMs in
|
||||
multiple zones by using the &PRODUCT; functionality. It evaluates the configured GSLB
|
||||
methods or algorithms to select a GSLB service to which to send the client requests. One
|
||||
or more virtual servers from different zones are bound to the GSLB virtual server. GSLB
|
||||
virtual server does not have a public IP associated with it, instead it will have a FQDN
|
||||
DNS name.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Load Balancing or Content Switching Virtual
|
||||
Servers</emphasis>: According to Citrix NetScaler terminology, a load balancing or
|
||||
content switching virtual server represents one or many servers on the local network.
|
||||
Clients send their requests to the load balancing or content switching virtual server’s
|
||||
virtual IP (VIP) address, and the virtual server balances the load across the local
|
||||
servers. After a GSLB virtual server selects a GSLB service representing either a local
|
||||
or a remote load balancing or content switching virtual server, the client sends the
|
||||
request to that virtual server’s VIP address.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">DNS VIPs</emphasis>: DNS virtual IP represents a load
|
||||
balancing DNS virtual server on the GSLB service provider. The DNS requests for domains
|
||||
for which the GSLB service provider is authoritative can be sent to a DNS VIP.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Authoritative DNS</emphasis>: ADNS (Authoritative Domain Name
|
||||
Server) is a service that provides actual answer to DNS queries, such as web site IP
|
||||
address. In a GSLB environment, an ADNS service responds only to DNS requests for
|
||||
domains for which the GSLB service provider is authoritative. When an ADNS service is
|
||||
configured, the service provider owns that IP address and advertises it. When you create
|
||||
an ADNS service, the NetScaler responds to DNS queries on the configured ADNS service IP
|
||||
and port.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="concept-gslb">
|
||||
<title>How Does GSLB Works in &PRODUCT;?</title>
|
||||
<para>Global server load balancing is used to manage the traffic flow to a web site hosted on
|
||||
two separate zones that ideally are in different geographic locations. The following is an
|
||||
illustration of how GLSB functionality is provided in &PRODUCT;: An organization, xyztelco,
|
||||
has set up a public cloud that spans two zones, Zone-1 and Zone-2, across geographically
|
||||
separated data centers that are managed by &PRODUCT;. Tenant-A of the cloud launches a
|
||||
highly available solution by using xyztelco cloud. For that purpose, they launch two
|
||||
instances each in both the zones: VM1 and VM2 in Zone-1 and VM5 and VM6 in Zone-2. Tenant-A
|
||||
acquires a public IP, IP-1 in Zone-1, and configures a load balancer rule to load balance
|
||||
the traffic between VM1 and VM2 instances. &PRODUCT; orchestrates setting up a virtual
|
||||
server on the LB service provider in Zone-1. Virtual server 1 that is set up on the LB
|
||||
service provider in Zone-1 represents a publicly accessible virtual server that client
|
||||
reaches at IP-1. The client traffic to virtual server 1 at IP-1 will be load balanced across
|
||||
VM1 and VM2 instances. </para>
|
||||
<para>Tenant-A acquires another public IP, IP-2 in Zone-2 and sets up a load balancer rule to
|
||||
load balance the traffic between VM5 and VM6 instances. Similarly in Zone-2, &PRODUCT;
|
||||
orchestrates setting up a virtual server on the LB service provider. Virtual server 2 that
|
||||
is setup on the LB service provider in Zone-2 represents a publicly accessible virtual
|
||||
server that client reaches at IP-2. The client traffic that reaches virtual server 2 at IP-2
|
||||
is load balanced across VM5 and VM6 instances. At this point Tenant-A has the service
|
||||
enabled in both the zones, but has no means to set up a disaster recovery plan if one of the
|
||||
zone fails. Additionally, there is no way for Tenant-A to load balance the traffic
|
||||
intelligently to one of the zones based on load, proximity and so on. The cloud
|
||||
administrator of xyztelco provisions a GSLB service provider to both the zones. A GSLB
|
||||
provider is typically an ADC that has the ability to act as an ADNS (Authoritative Domain
|
||||
Name Server) and has the mechanism to monitor health of virtual servers both at local and
|
||||
remote sites. The cloud admin enables GSLB as a service to the tenants that use zones 1 and
|
||||
2. </para>
|
||||
<mediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="./images/gslb.png"/>
|
||||
</imageobject>
|
||||
<textobject>
|
||||
<phrase>gslb.png: GSLB architecture</phrase>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
<para>Tenant-A wishes to leverage the GSLB service provided by the xyztelco cloud. Tenant-A
|
||||
configures a GSLB rule to load balance traffic across virtual server 1 at Zone-1 and virtual
|
||||
server 2 at Zone-2. The domain name is provided as A.xyztelco.com. &PRODUCT; orchestrates
|
||||
setting up GSLB virtual server 1 on the GSLB service provider at Zone-1. &PRODUCT; binds
|
||||
virtual server 1 of Zone-1 and virtual server 2 of Zone-2 to GLSB virtual server 1. GSLB
|
||||
virtual server 1 is configured to start monitoring the health of virtual server 1 and 2 in
|
||||
Zone-1. &PRODUCT; will also orchestrate setting up GSLB virtual server 2 on GSLB service
|
||||
provider at Zone-2. &PRODUCT; will bind virtual server 1 of Zone-1 and virtual server 2 of
|
||||
Zone-2 to GLSB virtual server 2. GSLB virtual server 2 is configured to start monitoring the
|
||||
health of virtual server 1 and 2. &PRODUCT; will bind the domain A.xyztelco.com to both the
|
||||
GSLB virtual server 1 and 2. At this point, Tenant-A service will be globally reachable at
|
||||
A.xyztelco.com. The private DNS server for the domain xyztelcom.com is configured by the
|
||||
admin out-of-band to resolve the domain A.xyztelco.com to the GSLB providers at both the
|
||||
zones, which are configured as ADNS for the domain A.xyztelco.com. A client when sends a DNS
|
||||
request to resolve A.xyztelcom.com, will eventually get DNS delegation to the address of
|
||||
GSLB providers at zone 1 and 2. A client DNS request will be received by the GSLB provider.
|
||||
The GSLB provider, depending on the domain for which it needs to resolve, will pick up the
|
||||
GSLB virtual server associated with the domain. Depending on the health of the virtual
|
||||
servers being load balanced, DNS request for the domain will be resolved to the public IP
|
||||
associated with the selected virtual server.</para>
|
||||
</section>
|
||||
</section>
|
||||
<section id="prereq-gslb">
|
||||
<title>Prerequisites and Guidelines</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>The GSLB functionality is supported both Basic and Advanced zones.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>GSLB is added as a new network service.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>GSLB service provider can be added to a physical network in a zone.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The admin is allowed to enable or disable GSLB functionality at region level.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The admin is allowed to configure a zone as GSLB capable or enabled. </para>
|
||||
<para>A zone shall be considered as GSLB capable only if a GSLB service provider is
|
||||
provisioned in the zone.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>When users have VMs deployed in multiple availability zones which are GSLB enabled,
|
||||
user is allowed to use the GSLB functionality to load balance traffic across the VMs in
|
||||
multiple zones.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The users are allowed to use GSLB to load balance across the VMs across zones in a
|
||||
region only if the admin has enabled GSLB in that region. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The users are allowed to load balance traffic across the availability zones in the
|
||||
same region or different regions.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The admin is allowed to configure DNS name for the entire cloud.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The users can specify an unique name, across the cloud, for a globally load balanced
|
||||
service. The provided name will be used as the domain under the DNS name associated with
|
||||
the cloud.</para>
|
||||
<para>The user-provided name along with the admin-provided DNS name is used to produce a
|
||||
globally resolvable FQDN for the globally load balanced service of the user. For example,
|
||||
if the admin has configured xyztelco.com as the DNS name for the cloud, and user specifies
|
||||
'foo' for the GSLB virtual service, then the FQDN name of the GSLB virtual service is
|
||||
foo.xyztelco.com.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>While setting up GSLB, users can select a load balancing method, such as round robin
|
||||
or least RTT, that would be the load balance traffic used across the zones that are part
|
||||
of GSLB.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The user shall be able to set weight to zone-level virtual server. Weight shall be
|
||||
considered by the load balancing method is distributing the traffic.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The GSLB functionality shall support session persistence, where series of client
|
||||
requests for particular domain name is sent to a virtual server on the same zone. </para>
|
||||
<para>Statistics is collected from each GSLB virtual server.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="gslb-add">
|
||||
<title>Adding a GSLB Rule</title>
|
||||
<section id="gslb-workflow">
|
||||
<title>Configuring GSLB</title>
|
||||
<para>A GSLB deployment is the logical collection of GSLB virtual server, GSLB service, LB
|
||||
virtual server, service, domain, and ADNS service. To create a GSLB site, you must configure
|
||||
load balancing in the zone. You must create GSLB vservers and GSLB services for each site. You
|
||||
must bind GSLB services to GSLB vservers. You must then create an ADNS service that provides
|
||||
the IP address of the best performing site to the client's request. A GSLB vserver is an
|
||||
entity that performs load balancing for the domains bound to it by returning the IP address of
|
||||
the best GSLB service. A GSLB service is a representation of the load balancing/content
|
||||
switching vserver. An LB vserver load balances incoming traffic by identifying the best
|
||||
server, then directs traffic to the corresponding service. It can also load-balance external
|
||||
DNS name servers. Services are entities that represent the servers. The domain is the domain
|
||||
name for which the system is the authoritative DNS server. By creating an ADNS service, the
|
||||
system can be configured as an authoritative DNS server.</para>
|
||||
<para>To configure GSLB in your cloud environment, as a cloud administrator you must perform the
|
||||
following.</para>
|
||||
<para>To configure such a GSLB setup, you must first configure a standard load balancing setup
|
||||
for each zone. This enables you to balance load across the different servers in each zone in
|
||||
the region. Then, configure both NetScaler appliances that you plan to add to each zone as
|
||||
authoritative DNS (ADNS) servers. Next, create a GSLB site for each zone, configure GSLB
|
||||
virtual servers for each site, create GLSB services, and bind the GSLB services to the GSLB
|
||||
virtual servers. Finally, bind the domain to the GSLB virtual servers. The GSLB configurations
|
||||
on the two appliances at the two different sites are identical, although each sites
|
||||
load-balancing configuration is specific to that site.</para>
|
||||
<para>Perform the following as a cloud administrator. As per the above example, the
|
||||
administrator of xyztelco is the one who sets up GSLB:</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Log in to the &PRODUCT; UI as administrator.</para>
|
||||
<para>In the cloud.dns.name global parameter, specify the DNS name of your tenant's cloud
|
||||
that make use of the GSLB service.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In the left navigation pane, click Region.</para>
|
||||
<para>On the NetScaler side, configure GSLB as given in <ulink
|
||||
url="http://support.citrix.com/proddocs/topic/netscaler-traffic-management-10-map/ns-gslb-config-con.html"
|
||||
>Configuring Global Server Load Balancing (GSLB)</ulink>:</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Configuring a standard load balancing setup.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Configure Authoritative DNS, as explained in <ulink
|
||||
url="http://support.citrix.com/proddocs/topic/netscaler-traffic-management-10-map/ns-gslb-config-adns-svc-tsk.html"
|
||||
>Configuring an Authoritative DNS Service</ulink>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Configure a GSLB site with site name formed from the domain name details.</para>
|
||||
<para>For more information, see <ulink
|
||||
url="http://support.citrix.com/proddocs/topic/netscaler-traffic-management-10-map/ns-gslb-config-basic-site-tsk.html"
|
||||
>Configuring a Basic GSLB Site</ulink>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Configure a GSLB virtual server.</para>
|
||||
<para>For more information, see <ulink
|
||||
url="http://support.citrix.com/proddocs/topic/netscaler-traffic-management-10-map/ns-gslb-config-vsvr-tsk.html"
|
||||
>Configuring a GSLB Virtual Server</ulink>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Configure a GSLB service for each virtual server.</para>
|
||||
<para>For more information, see <ulink
|
||||
url="http://support.citrix.com/proddocs/topic/netscaler-traffic-management-10-map/ns-gslb-config-svc-tsk.html"
|
||||
>Configuring a GSLB Service</ulink>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Bind the GSLB services to the GSLB virtual server.</para>
|
||||
<para>For more information, see <ulink
|
||||
url="http://support.citrix.com/proddocs/topic/netscaler-traffic-management-10-map/ns-gslb-bind-svc-vsvr-tsk.html"
|
||||
>Binding GSLB Services to a GSLB Virtual Server</ulink>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Bind domain name to GSLB virtual server. Domain name is obtained from the domain
|
||||
details.</para>
|
||||
<para>For more information, see <ulink
|
||||
url="http://support.citrix.com/proddocs/topic/netscaler-traffic-management-10-map/ns-gslb-bind-dom-vsvr-tsk.html"
|
||||
>Binding a Domain to a GSLB Virtual Server</ulink>.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Select the region for which you want to create a GSLB rule.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In the Details tab, click View GSLB.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click Add GSLB.</para>
|
||||
<para>The Add GSLB page is displayed as follows:</para>
|
||||
<mediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="./images/add-gslb.png"/>
|
||||
</imageobject>
|
||||
<textobject>
|
||||
<phrase>gslb-add.png: adding a gslb rule</phrase>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Specify the following:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Name</emphasis>: Name for the GSLB rule.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Description</emphasis>: (Optional) A short description of
|
||||
the GSLB rule that can be displayed to users.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">GSLB Domain Name</emphasis>: A preferred domain name for the
|
||||
service.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Algorithm</emphasis>: (Optional) The algorithm to use to
|
||||
load balance the traffic across the zones. The options are Round Robin, Least
|
||||
Connection, and Proximity.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Service Type</emphasis>: The transport protocol to use for
|
||||
GSLB. The options are TCP and UDP.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Domain</emphasis>: (Optional) The domain for which you want
|
||||
to create the GSLB rule.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Account</emphasis>: (Optional) The account on which you want
|
||||
to apply the GSLB rule.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click OK to confirm.</para>
|
||||
<para>In each zone that are participating in GSLB, add GSLB-enabled NetScaler device.</para>
|
||||
<para>For more information, see <xref linkend="enable-glsb-ns"/>.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
<section id="assign-lb-gslb">
|
||||
<title>Assigning Load Balancing Rules to GSLB</title>
|
||||
<para/>
|
||||
</section>
|
||||
<section id="concept-gslb">
|
||||
<title>How Does GSLB Works in &PRODUCT;?</title>
|
||||
<para>The following is an illustrated conceptual model of how GLSB functionality is provided in
|
||||
&PRODUCT;: An organization, xyztelco, has set up a public cloud that spans two zones, Zone-1
|
||||
and Zone-2, across geographically separated data centers that are managed by &PRODUCT;.
|
||||
Tenant-A of the cloud launches a highly available solution by using xyztelco cloud. For that
|
||||
purpose, they launch two instances each in both the zones: VM1 and VM2 in Zone-1 and VM5 and
|
||||
VM6 in Zone-2. Tenant-A acquires a public IP, IP-1 in Zone-1, and configures a load balancer
|
||||
rule to load balance the traffic between VM1 and VM2 instances. &PRODUCT; orchestrates setting
|
||||
up a virtual server on the LB service provider in Zone-1. Virtual server 1 that is set up on
|
||||
the LB service provider in Zone-1 represents a publicly accessible virtual server that client
|
||||
reaches at IP-1. The client traffic to virtual server 1 at IP-1 will be load balanced across
|
||||
VM1 and VM2 instances. </para>
|
||||
<para>Tenant-A acquires another public IP, IP-2 in Zone-2 and sets up a load balancer rule to
|
||||
load balance the traffic between VM5 and VM6 instances. Similarly in Zone-2, &PRODUCT;
|
||||
orchestrates setting up a virtual server on the LB service provider. Virtual server 2 that is
|
||||
setup on the LB service provider in Zone-2 represents a publicly accessible virtual server
|
||||
that client reaches at IP-2. The client traffic that reaches virtual server 2 at IP-2 is load
|
||||
balanced across VM5 and VM6 instances. At this point Tenant-A has the service enabled in both
|
||||
the zones, but has no means to set up a disaster recovery plan if one of the zone fails.
|
||||
Additionally, there is no way for Tenant-A to load balance the traffic intelligently to one of
|
||||
the zones based on load, proximity and so on. The cloud administrator of xyztelco provisions a
|
||||
GSLB service provider to both the zones. A GSLB provider is typically an ADC that has the
|
||||
ability to act as an ADNS (Authoritative Domain Name Server) and has the mechanism to monitor
|
||||
health of virtual servers both at local and remote sites. The cloud admin enables GSLB as a
|
||||
service to the tenants that use zones 1 and 2. </para>
|
||||
<mediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="./images/gslb.png"/>
|
||||
</imageobject>
|
||||
<textobject>
|
||||
<phrase>gslb.png: GSLB architecture</phrase>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
<para>Tenant-A wishes to leverage the GSLB service provided by the xyztelco cloud. Tenant-A
|
||||
configures a GSLB rule to load balance traffic across virtual server 1 at Zone-1 and virtual
|
||||
server 2 at Zone-2. The domain name is provided as A.xyztelco.com. &PRODUCT; orchestrates
|
||||
setting up GSLB virtual server 1 on the GSLB service provider at Zone-1. &PRODUCT; binds
|
||||
virtual server 1 of Zone-1 and virtual server 2 of Zone-2 to GLSB virtual server 1. GSLB
|
||||
virtual server 1 is configured to start monitoring the health of virtual server 1 and 2 in
|
||||
Zone-1. &PRODUCT; will also orchestrate setting up GSLB virtual server 2 on GSLB service
|
||||
provider at Zone-2. &PRODUCT; will bind virtual server 1 of Zone-1 and virtual server 2 of
|
||||
Zone-2 to GLSB virtual server 2. GSLB virtual server 2 is configured to start monitoring the
|
||||
health of virtual server 1 and 2. &PRODUCT; will bind the domain A.xyztelco.com to both the
|
||||
GSLB virtual server 1 and 2. At this point, Tenant-A service will be globally reachable at
|
||||
A.xyztelco.com. The private DNS server for the domain xyztelcom.com is configured by the admin
|
||||
out-of-band to resolve the domain A.xyztelco.com to the GSLB providers at both the zones,
|
||||
which are configured as ADNS for the domain A.xyztelco.com. A client when sends a DNS request
|
||||
to resolve A.xyztelcom.com, will eventually get DNS delegation to the address of GSLB
|
||||
providers at Zone 1 and 2. A client DNS request will be received by the GSLB provider. The
|
||||
GSLB provider, depending on the domain for which it needs to resolve, will pick up the GSLB
|
||||
virtual server associated with the domain. Depending on the health of the virtual servers
|
||||
being load balanced, DNS request for the domain will be resolved to the public IP associated
|
||||
with the selected virtual server.</para>
|
||||
<para>As a domain administrator/ user perform the following:</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Add a GSLB rule on both the sites.</para>
|
||||
<para>See <xref linkend="gslb-add"/>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Assign load balancer rules.</para>
|
||||
<para>See <xref linkend="assign-lb-gslb"/>.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<section id="prereq-gslb">
|
||||
<title>Prerequisites and Guidelines</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>The GSLB functionality is supported both Basic and Advanced zones.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>GSLB is added as a new network service.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>GSLB service provider can be added to a physical network in a zone.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The admin is allowed to enable or disable GSLB functionality at region level.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The admin is allowed to configure a zone as GSLB capable or enabled. </para>
|
||||
<para>A zone shall be considered as GSLB capable only if a GSLB service provider is
|
||||
provisioned in the zone.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>When users have VMs deployed in multiple availability zones which are GSLB enabled,
|
||||
they can use the GSLB functionality to load balance traffic across the VMs in multiple
|
||||
zones.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The users can use GSLB to load balance across the VMs across zones in a region only
|
||||
if the admin has enabled GSLB in that region. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The users can load balance traffic across the availability zones in the same region
|
||||
or different regions.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The admin can configure DNS name for the entire cloud.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The users can specify an unique name across the cloud for a globally load balanced
|
||||
service. The provided name is used as the domain name under the DNS name associated with
|
||||
the cloud.</para>
|
||||
<para>The user-provided name along with the admin-provided DNS name is used to produce a
|
||||
globally resolvable FQDN for the globally load balanced service of the user. For
|
||||
example, if the admin has configured xyztelco.com as the DNS name for the cloud, and
|
||||
user specifies 'foo' for the GSLB virtual service, then the FQDN name of the GSLB
|
||||
virtual service is foo.xyztelco.com.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>While setting up GSLB, users can select a load balancing method, such as round
|
||||
robin, for using across the zones that are part of GSLB.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The user shall be able to set weight to zone-level virtual server. Weight shall be
|
||||
considered by the load balancing method for distributing the traffic.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The GSLB functionality shall support session persistence, where series of client
|
||||
requests for particular domain name is sent to a virtual server on the same zone. </para>
|
||||
<para>Statistics is collected from each GSLB virtual server.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="enable-glsb-ns">
|
||||
<title>Enabling GSLB in NetScaler</title>
|
||||
<para>In each zone, add GSLB-enabled NetScaler device for load balancing.</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Log in as administrator to the &PRODUCT; UI.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In the left navigation bar, click Infrastructure.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In Zones, click View More.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Choose the zone you want to work with.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click the Physical Network tab, then click the name of the physical network. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In the Network Service Providers node of the diagram, click Configure. </para>
|
||||
<para>You might have to scroll down to see this.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click NetScaler.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click Add NetScaler device and provide the following:</para>
|
||||
<para>For NetScaler:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">IP Address</emphasis>: The IP address of the SRX.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Username/Password</emphasis>: The authentication
|
||||
credentials to access the device. &PRODUCT; uses these credentials to access the
|
||||
device.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Type</emphasis>: The type of device that is being added.
|
||||
It could be F5 Big Ip Load Balancer, NetScaler VPX, NetScaler MPX, or NetScaler SDX.
|
||||
For a comparison of the NetScaler types, see the &PRODUCT; Administration
|
||||
Guide.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Public interface</emphasis>: Interface of device that is
|
||||
configured to be part of the public network.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Private interface</emphasis>: Interface of device that is
|
||||
configured to be part of the private network.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">GSLB service</emphasis>: Select this option.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">GSLB service Public IP</emphasis>: The public IP address
|
||||
of the NAT translator for a GSLB service that is on a private network.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">GSLB service Private IP</emphasis>: The private IP of the
|
||||
GSLB service.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Number of Retries</emphasis>. Number of times to attempt a
|
||||
command on the device before considering the operation failed. Default is 2.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Capacity</emphasis>: The number of networks the device can
|
||||
handle.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Dedicated</emphasis>: When marked as dedicated, this
|
||||
device will be dedicated to a single account. When Dedicated is checked, the value
|
||||
in the Capacity field has no significance implicitly, its value is 1.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click OK.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
<section id="gslb-add">
|
||||
<title>Adding a GSLB Rule</title>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Log in to the &PRODUCT; UI as a domain administrator or user.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In the left navigation pane, click Region.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Select the region for which you want to create a GSLB rule.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In the Details tab, click View GSLB.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click Add GSLB.</para>
|
||||
<para>The Add GSLB page is displayed as follows:</para>
|
||||
<mediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="./images/add-gslb.png"/>
|
||||
</imageobject>
|
||||
<textobject>
|
||||
<phrase>gslb-add.png: adding a gslb rule</phrase>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Specify the following:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Name</emphasis>: Name for the GSLB rule.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Description</emphasis>: (Optional) A short description of
|
||||
the GSLB rule that can be displayed to users.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">GSLB Domain Name</emphasis>: A preferred domain name for
|
||||
the service.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Algorithm</emphasis>: (Optional) The algorithm to use to
|
||||
load balance the traffic across the zones. The options are Round Robin, Least
|
||||
Connection, and Proximity.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Service Type</emphasis>: The transport protocol to use for
|
||||
GSLB. The options are TCP and UDP.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Domain</emphasis>: (Optional) The domain for which you
|
||||
want to create the GSLB rule.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis role="bold">Account</emphasis>: (Optional) The account on which you
|
||||
want to apply the GSLB rule.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click OK to confirm.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
<section id="assign-lb-gslb">
|
||||
<title>Assigning Load Balancing Rules to GSLB</title>
|
||||
<para/>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Log in to the &PRODUCT; UI as a domain administrator or user.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In the left navigation pane, click Region.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Select the region for which you want to create a GSLB rule.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In the Details tab, click View GSLB.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Select the desired GSLB.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click view assigned load balancing.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click assign more load balancing.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Select the load balancing rule you have created for the zone.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Click OK to confirm.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
</section>
|
||||
<section id="limitation-gslb">
|
||||
<title>Known Limitation</title>
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 59 KiB |
|
|
@ -36,7 +36,8 @@
|
|||
<xi:include href="security-groups.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="external-firewalls-and-load-balancers.xml"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="load-balancer-rules.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="gslb.xml"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="guest-ip-ranges.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="acquire-new-ip-address.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="release-ip-address.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package com.cloud.network.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
|
|||
|
|
@ -31,12 +31,8 @@ import javax.persistence.Temporal;
|
|||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.IpAddress.State;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
/**
|
||||
* A bean representing a public IP Address
|
||||
|
|
@ -304,4 +300,9 @@ public class IPAddressVO implements IpAddress {
|
|||
public void setVmIp(String vmIp) {
|
||||
this.vmIp = vmIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getNetworkId() {
|
||||
return sourceNetworkId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,19 +18,15 @@ package com.cloud.network.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
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);
|
||||
List<LoadBalancerVO> listByNetworkIdAndScheme(long networkId, Scheme scheme);
|
||||
|
||||
LoadBalancerVO findByAccountAndName(Long accountId, String name);
|
||||
|
||||
List<LoadBalancerVO> listByNetworkId(long networkId);
|
||||
|
||||
List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId);
|
||||
List<LoadBalancerVO> listInTransitionStateByNetworkIdAndScheme(long networkId, Scheme scheme);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,39 +16,24 @@
|
|||
// under the License.
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.rules.FirewallRule.State;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Component
|
||||
@Local(value = { LoadBalancerDao.class })
|
||||
public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> implements LoadBalancerDao {
|
||||
private static final Logger s_logger = Logger.getLogger(LoadBalancerDaoImpl.class);
|
||||
private static final String LIST_INSTANCES_BY_LOAD_BALANCER = "SELECT vm.id " +
|
||||
" FROM vm_instance vm, load_balancer lb, ip_forwarding fwd, user_ip_address ip " +
|
||||
" WHERE lb.id = ? AND " +
|
||||
" fwd.group_id = lb.id AND " +
|
||||
" fwd.forwarding = 0 AND " +
|
||||
" fwd.private_ip_address = vm.private_ip_address AND " +
|
||||
" lb.ip_address = ip.public_ip_address AND " +
|
||||
" ip.data_center_id = vm.data_center_id ";
|
||||
private final SearchBuilder<LoadBalancerVO> ListByIp;
|
||||
private final SearchBuilder<LoadBalancerVO> IpAndPublicPortSearch;
|
||||
private final SearchBuilder<LoadBalancerVO> AccountAndNameSearch;
|
||||
protected final SearchBuilder<LoadBalancerVO> TransitionStateSearch;
|
||||
|
||||
@Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao;
|
||||
|
|
@ -57,45 +42,16 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> im
|
|||
ListByIp = createSearchBuilder();
|
||||
ListByIp.and("ipAddressId", ListByIp.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
|
||||
ListByIp.and("networkId", ListByIp.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
ListByIp.and("scheme", ListByIp.entity().getScheme(), SearchCriteria.Op.EQ);
|
||||
ListByIp.done();
|
||||
|
||||
IpAndPublicPortSearch = createSearchBuilder();
|
||||
IpAndPublicPortSearch.and("ipAddressId", IpAndPublicPortSearch.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
|
||||
IpAndPublicPortSearch.and("publicPort", IpAndPublicPortSearch.entity().getSourcePortStart(), SearchCriteria.Op.EQ);
|
||||
IpAndPublicPortSearch.done();
|
||||
|
||||
AccountAndNameSearch = createSearchBuilder();
|
||||
AccountAndNameSearch.and("accountId", AccountAndNameSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountAndNameSearch.and("name", AccountAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
AccountAndNameSearch.done();
|
||||
|
||||
TransitionStateSearch = createSearchBuilder();
|
||||
TransitionStateSearch.and("networkId", TransitionStateSearch.entity().getNetworkId(), Op.EQ);
|
||||
TransitionStateSearch.and("state", TransitionStateSearch.entity().getState(), Op.IN);
|
||||
TransitionStateSearch.and("scheme", TransitionStateSearch.entity().getScheme(), Op.EQ);
|
||||
TransitionStateSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listInstancesByLoadBalancer(long loadBalancerId) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
String sql = LIST_INSTANCES_BY_LOAD_BALANCER;
|
||||
PreparedStatement pstmt = null;
|
||||
List<Long> instanceList = new ArrayList<Long>();
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setLong(1, loadBalancerId);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
Long vmId = rs.getLong(1);
|
||||
instanceList.add(vmId);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("error getting recent usage network stats", ex);
|
||||
}
|
||||
return instanceList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<LoadBalancerVO> listByIpAddress(long ipAddressId) {
|
||||
SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
|
||||
|
|
@ -104,33 +60,19 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> im
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<LoadBalancerVO> listByNetworkId(long networkId) {
|
||||
public List<LoadBalancerVO> listByNetworkIdAndScheme(long networkId, Scheme scheme) {
|
||||
SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
sc.setParameters("scheme", scheme);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort) {
|
||||
SearchCriteria<LoadBalancerVO> sc = IpAndPublicPortSearch.create();
|
||||
sc.setParameters("ipAddressId", ipAddressId);
|
||||
sc.setParameters("publicPort", publicPort);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadBalancerVO findByAccountAndName(Long accountId, String name) {
|
||||
SearchCriteria<LoadBalancerVO> sc = AccountAndNameSearch.create();
|
||||
sc.setParameters("accountId", accountId);
|
||||
sc.setParameters("name", name);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId) {
|
||||
public List<LoadBalancerVO> listInTransitionStateByNetworkIdAndScheme(long networkId, Scheme scheme) {
|
||||
SearchCriteria<LoadBalancerVO> sc = TransitionStateSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
sc.setParameters("state", State.Add.toString(), State.Revoke.toString());
|
||||
sc.setParameters("scheme", scheme);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ package com.cloud.network.dao;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
|
@ -26,6 +28,12 @@ import com.cloud.network.rules.FirewallRuleVO;
|
|||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
/**
|
||||
* This VO represent Public Load Balancer
|
||||
* It references source ip address by its Id.
|
||||
* To get the VO for Internal Load Balancer rule, please refer to LoadBalancerRuleVO
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name=("load_balancing_rules"))
|
||||
@DiscriminatorValue(value="LoadBalancing")
|
||||
|
|
@ -46,6 +54,10 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
|
|||
|
||||
@Column(name="default_port_end")
|
||||
private int defaultPortEnd;
|
||||
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
@Column(name="scheme")
|
||||
Scheme scheme = Scheme.Public;
|
||||
|
||||
public LoadBalancerVO() {
|
||||
}
|
||||
|
|
@ -57,6 +69,7 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
|
|||
this.algorithm = algorithm;
|
||||
this.defaultPortStart = dstPort;
|
||||
this.defaultPortEnd = dstPort;
|
||||
this.scheme = Scheme.Public;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -94,5 +107,10 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
|
|||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scheme getScheme() {
|
||||
return scheme;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,5 @@ public interface NetworkServiceMapDao extends GenericDao<NetworkServiceMapVO, Lo
|
|||
void deleteByNetworkId(long networkId);
|
||||
List<String> getDistinctProviders(long networkId);
|
||||
String isProviderForNetwork(long networkId, Provider provider);
|
||||
List<String> getProvidersForServiceInNetwork(long networkId, Service service);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public class NetworkServiceMapDaoImpl extends GenericDaoBase<NetworkServiceMapVO
|
|||
DistinctProvidersSearch = createSearchBuilder(String.class);
|
||||
DistinctProvidersSearch.and("networkId", DistinctProvidersSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
DistinctProvidersSearch.and("provider", DistinctProvidersSearch.entity().getProvider(), SearchCriteria.Op.EQ);
|
||||
DistinctProvidersSearch.and("service", DistinctProvidersSearch.entity().getService(), SearchCriteria.Op.EQ);
|
||||
DistinctProvidersSearch.selectField(DistinctProvidersSearch.entity().getProvider());
|
||||
DistinctProvidersSearch.done();
|
||||
}
|
||||
|
|
@ -163,5 +164,13 @@ public class NetworkServiceMapDaoImpl extends GenericDaoBase<NetworkServiceMapVO
|
|||
return results.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getProvidersForServiceInNetwork(long networkId, Service service) {
|
||||
SearchCriteria<String> sc = DistinctProvidersSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
sc.setParameters("service", service.getName());
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ import javax.persistence.Transient;
|
|||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
|
|
@ -35,7 +34,6 @@ import javax.persistence.InheritanceType;
|
|||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDao;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.offerings;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
|
||||
@Entity
|
||||
@Table(name="network_offering_details")
|
||||
public class NetworkOfferingDetailsVO implements InternalIdentity {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="network_offering_id")
|
||||
private long offeringId;
|
||||
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
@Column(name="name")
|
||||
private NetworkOffering.Detail name;
|
||||
|
||||
@Column(name="value", length=1024)
|
||||
private String value;
|
||||
|
||||
public NetworkOfferingDetailsVO() {}
|
||||
|
||||
public NetworkOfferingDetailsVO(long offeringId, Detail detailName, String value) {
|
||||
this.offeringId = offeringId;
|
||||
this.name = detailName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getOfferingId() {
|
||||
return offeringId;
|
||||
}
|
||||
|
||||
public NetworkOffering.Detail getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setOfferingId(long offeringId) {
|
||||
this.offeringId = offeringId;
|
||||
}
|
||||
|
||||
public void setName(NetworkOffering.Detail name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,15 +16,23 @@
|
|||
// under the License.
|
||||
package com.cloud.offerings;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "network_offerings")
|
||||
public class NetworkOfferingVO implements NetworkOffering {
|
||||
|
|
@ -126,6 +134,12 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@Column(name = "internal_lb")
|
||||
boolean internalLb;
|
||||
|
||||
@Column(name = "public_lb")
|
||||
boolean publicLb;
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
|
|
@ -262,7 +276,7 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
}
|
||||
|
||||
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 specifyIpRanges, boolean isPersistent) {
|
||||
Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean specifyIpRanges, boolean isPersistent, boolean internalLb, boolean publicLb) {
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.rateMbps = rateMbps;
|
||||
|
|
@ -286,12 +300,14 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
this.inline = false;
|
||||
this.specifyIpRanges = specifyIpRanges;
|
||||
this.isPersistent=isPersistent;
|
||||
this.publicLb = publicLb;
|
||||
this.internalLb = internalLb;
|
||||
}
|
||||
|
||||
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, boolean inline, boolean isPersistent, boolean associatePublicIP) {
|
||||
this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges, isPersistent);
|
||||
boolean specifyIpRanges, boolean inline, boolean isPersistent, boolean associatePublicIP, boolean publicLb, boolean internalLb) {
|
||||
this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges, isPersistent, internalLb, publicLb);
|
||||
this.dedicatedLB = dedicatedLb;
|
||||
this.sharedSourceNat = sharedSourceNat;
|
||||
this.redundantRouter = redundantRouter;
|
||||
|
|
@ -313,13 +329,13 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
* 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, false);
|
||||
this(name, "System Offering for " + name, trafficType, true, false, 0, 0, true, Availability.Required, null, null, true, specifyIpRanges, false, false, false);
|
||||
this.state = State.Enabled;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(String name, Network.GuestType guestType) {
|
||||
this(name, "System Offering for " + name, TrafficType.Guest, true, true, 0, 0, true, Availability.Optional,
|
||||
null, Network.GuestType.Isolated, true, false, false);
|
||||
null, Network.GuestType.Isolated, true, false, false, false, false);
|
||||
this.state = State.Enabled;
|
||||
}
|
||||
|
||||
|
|
@ -388,4 +404,14 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
return isPersistent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getInternalLb() {
|
||||
return internalLb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPublicLb() {
|
||||
return publicLb;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,13 @@
|
|||
package com.cloud.offerings.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
|
|
@ -57,4 +59,6 @@ public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long>
|
|||
|
||||
List<NetworkOfferingVO> listByTrafficTypeGuestTypeAndState(NetworkOffering.State state, TrafficType trafficType, Network.GuestType type);
|
||||
|
||||
NetworkOfferingVO persist(NetworkOfferingVO off, Map<Detail, String> details);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@
|
|||
package com.cloud.offerings.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -27,6 +29,8 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import com.cloud.offerings.NetworkOfferingDetailsVO;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
@ -45,6 +49,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||
final SearchBuilder<NetworkOfferingVO> AvailabilitySearch;
|
||||
final SearchBuilder<NetworkOfferingVO> AllFieldsSearch;
|
||||
private final GenericSearchBuilder<NetworkOfferingVO, Long> UpgradeSearch;
|
||||
@Inject NetworkOfferingDetailsDao _detailsDao;
|
||||
|
||||
protected NetworkOfferingDaoImpl() {
|
||||
super();
|
||||
|
|
@ -165,5 +170,24 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||
sc.setParameters("state", state);
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public NetworkOfferingVO persist(NetworkOfferingVO off, Map<Detail, String> details) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
//1) persist the offering
|
||||
NetworkOfferingVO vo = super.persist(off);
|
||||
|
||||
//2) persist the details
|
||||
if (details != null && !details.isEmpty()) {
|
||||
for (NetworkOffering.Detail detail : details.keySet()) {
|
||||
_detailsDao.persist(new NetworkOfferingDetailsVO(off.getId(), detail, details.get(detail)));
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
return vo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import com.cloud.offerings.NetworkOfferingDetailsVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface NetworkOfferingDetailsDao extends GenericDao<NetworkOfferingDetailsVO, Long>{
|
||||
|
||||
Map<NetworkOffering.Detail,String> getNtwkOffDetails(long offeringId);
|
||||
String getDetail(long offeringId, Detail detailName);
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import com.cloud.offerings.NetworkOfferingDetailsVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
public class NetworkOfferingDetailsDaoImpl extends GenericDaoBase<NetworkOfferingDetailsVO, Long> implements NetworkOfferingDetailsDao{
|
||||
protected final SearchBuilder<NetworkOfferingDetailsVO> DetailSearch;
|
||||
private final GenericSearchBuilder<NetworkOfferingDetailsVO, String> ValueSearch;
|
||||
|
||||
|
||||
public NetworkOfferingDetailsDaoImpl() {
|
||||
|
||||
DetailSearch = createSearchBuilder();
|
||||
DetailSearch.and("offeringId", DetailSearch.entity().getOfferingId(), SearchCriteria.Op.EQ);
|
||||
DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
DetailSearch.done();
|
||||
|
||||
ValueSearch = createSearchBuilder(String.class);
|
||||
ValueSearch.select(null, Func.DISTINCT, ValueSearch.entity().getValue());
|
||||
ValueSearch.and("offeringId", ValueSearch.entity().getOfferingId(), SearchCriteria.Op.EQ);
|
||||
ValueSearch.and("name", ValueSearch.entity().getName(), Op.EQ);
|
||||
ValueSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<NetworkOffering.Detail,String> getNtwkOffDetails(long offeringId) {
|
||||
SearchCriteria<NetworkOfferingDetailsVO> sc = DetailSearch.create();
|
||||
sc.setParameters("offeringId", offeringId);
|
||||
|
||||
List<NetworkOfferingDetailsVO> results = search(sc, null);
|
||||
Map<NetworkOffering.Detail, String> details = new HashMap<NetworkOffering.Detail, String>(results.size());
|
||||
for (NetworkOfferingDetailsVO result : results) {
|
||||
details.put(result.getName(), result.getValue());
|
||||
}
|
||||
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetail(long offeringId, Detail detailName) {
|
||||
SearchCriteria<String> sc = ValueSearch.create();
|
||||
sc.setParameters("name", detailName);
|
||||
sc.setParameters("offeringId", offeringId);
|
||||
List<String> results = customSearch(sc, null);
|
||||
if (results.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return results.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -63,6 +63,7 @@ public class Upgrade302to40 extends Upgrade30xBase implements DbUpgrade {
|
|||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
updateVmWareSystemVms(conn);
|
||||
correctVRProviders(conn);
|
||||
correctMultiplePhysicaNetworkSetups(conn);
|
||||
addHostDetailsUniqueKey(conn);
|
||||
|
|
@ -82,7 +83,55 @@ public class Upgrade302to40 extends Upgrade30xBase implements DbUpgrade {
|
|||
|
||||
return new File[] { new File(script) };
|
||||
}
|
||||
|
||||
|
||||
private void updateVmWareSystemVms(Connection conn){
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
boolean VMware = false;
|
||||
try {
|
||||
pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null");
|
||||
rs = pstmt.executeQuery();
|
||||
while(rs.next()){
|
||||
if("VMware".equals(rs.getString(1))){
|
||||
VMware = true;
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Error while iterating through list of hypervisors in use", e);
|
||||
}
|
||||
// Just update the VMware system template. Other hypervisor templates are unchanged from previous 3.0.x versions.
|
||||
s_logger.debug("Updating VMware System Vms");
|
||||
try {
|
||||
//Get 4.0 VMware system Vm template Id
|
||||
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-vmware-4.0' and removed is null");
|
||||
rs = pstmt.executeQuery();
|
||||
if(rs.next()){
|
||||
long templateId = rs.getLong(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
// change template type to SYSTEM
|
||||
pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
|
||||
pstmt.setLong(1, templateId);
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
// update templete ID of system Vms
|
||||
pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'VMware'");
|
||||
pstmt.setLong(1, templateId);
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
} else {
|
||||
if (VMware){
|
||||
throw new CloudRuntimeException("4.0 VMware SystemVm template not found. Cannot upgrade system Vms");
|
||||
} else {
|
||||
s_logger.warn("4.0 VMware SystemVm template not found. VMware hypervisor is not used, so not failing upgrade");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Error while updating VMware systemVm template", e);
|
||||
}
|
||||
s_logger.debug("Updating System Vm Template IDs Complete");
|
||||
}
|
||||
|
||||
private void correctVRProviders(Connection conn) {
|
||||
PreparedStatement pstmtVR = null;
|
||||
ResultSet rsVR = null;
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@
|
|||
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
|
@ -28,6 +24,11 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
public class Upgrade410to420 implements DbUpgrade {
|
||||
final static Logger s_logger = Logger.getLogger(Upgrade410to420.class);
|
||||
|
||||
|
|
@ -66,6 +67,8 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||
updatePrimaryStore(conn);
|
||||
addEgressFwRulesForSRXGuestNw(conn);
|
||||
upgradeEIPNetworkOfferings(conn);
|
||||
upgradeDefaultVpcOffering(conn);
|
||||
upgradePhysicalNtwksWithInternalLbProvider(conn);
|
||||
}
|
||||
|
||||
private void updateSystemVmTemplates(Connection conn) {
|
||||
|
|
@ -399,4 +402,88 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void upgradeDefaultVpcOffering(Connection conn) {
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
pstmt = conn.prepareStatement("select distinct map.vpc_offering_id from `cloud`.`vpc_offering_service_map` map, `cloud`.`vpc_offerings` off where off.id=map.vpc_offering_id AND service='Lb'");
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
long id = rs.getLong(1);
|
||||
//Add internal LB vm as a supported provider for the load balancer service
|
||||
pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vpc_offering_service_map` (vpc_offering_id, service, provider) VALUES (?,?,?)");
|
||||
pstmt.setLong(1, id);
|
||||
pstmt.setString(2, "Lb");
|
||||
pstmt.setString(3, "InternalLbVm");
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable update the default VPC offering with the internal lb service", e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
if (pstmt != null) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void upgradePhysicalNtwksWithInternalLbProvider(Connection conn) {
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where removed is null");
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
long pNtwkId = rs.getLong(1);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
//Add internal LB VM to the list of physical network service providers
|
||||
pstmt = conn.prepareStatement("INSERT INTO `cloud`.`physical_network_service_providers` " +
|
||||
"(uuid, physical_network_id, provider_name, state, load_balance_service_provided, destination_physical_network_id)" +
|
||||
" VALUES (?, ?, 'InternalLbVm', 'Enabled', 1, 0)");
|
||||
pstmt.setString(1, uuid);
|
||||
pstmt.setLong(2, pNtwkId);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
//Add internal lb vm to the list of physical network elements
|
||||
PreparedStatement pstmt1 = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network_service_providers`" +
|
||||
" WHERE physical_network_id=? AND provider_name='InternalLbVm'");
|
||||
ResultSet rs1 = pstmt1.executeQuery();
|
||||
while (rs1.next()) {
|
||||
long providerId = rs1.getLong(1);
|
||||
uuid = UUID.randomUUID().toString();
|
||||
pstmt1 = conn.prepareStatement("INSERT INTO `cloud`.`virtual_router_providers` (nsp_id, uuid, type, enabled) VALUES (?, ?, 'InternalLbVm', 1)");
|
||||
pstmt1.setLong(1, providerId);
|
||||
pstmt1.setString(2, uuid);
|
||||
pstmt1.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable existing physical networks with internal lb provider", e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
if (pstmt != null) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public interface NicDao extends GenericDao<NicVO, Long> {
|
|||
|
||||
List<NicVO> listByNetworkId(long networkId);
|
||||
|
||||
NicVO findByInstanceIdAndNetworkId(long networkId, long instanceId);
|
||||
NicVO findByNtwkIdAndInstanceId(long networkId, long instanceId);
|
||||
|
||||
NicVO findByInstanceIdAndNetworkIdIncludingRemoved(long networkId, long instanceId);
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NicVO findByInstanceIdAndNetworkId(long networkId, long instanceId) {
|
||||
public NicVO findByNtwkIdAndInstanceId(long networkId, long instanceId) {
|
||||
SearchCriteria<NicVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("network", networkId);
|
||||
sc.setParameters("instance", instanceId);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.lb;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
|
||||
|
||||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
/**
|
||||
* This VO represent Internal Load Balancer rule.
|
||||
* Instead of pointing to the public ip address id directly as External Load Balancer rule does, it refers to the ip address by its value/sourceNetworkid
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name=("load_balancing_rules"))
|
||||
@DiscriminatorValue(value="LoadBalancing")
|
||||
@PrimaryKeyJoinColumn(name="id")
|
||||
public class ApplicationLoadBalancerRuleVO extends FirewallRuleVO implements ApplicationLoadBalancerRule{
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
@Column(name="description", length=4096)
|
||||
private String description;
|
||||
|
||||
@Column(name="algorithm")
|
||||
private String algorithm;
|
||||
|
||||
@Column(name="default_port_start")
|
||||
private int defaultPortStart;
|
||||
|
||||
@Column(name="default_port_end")
|
||||
private int defaultPortEnd;
|
||||
|
||||
@Column(name="source_ip_address_network_id")
|
||||
Long sourceIpNetworkId;
|
||||
|
||||
@Column(name="source_ip_address")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private Ip sourceIp = null;
|
||||
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
@Column(name="scheme")
|
||||
Scheme scheme;
|
||||
|
||||
|
||||
public ApplicationLoadBalancerRuleVO() {
|
||||
}
|
||||
|
||||
public ApplicationLoadBalancerRuleVO(String name, String description, int srcPort, int instancePort, String algorithm,
|
||||
long networkId, long accountId, long domainId, Ip sourceIp, long sourceIpNtwkId, Scheme scheme) {
|
||||
super(null, null, srcPort, srcPort, NetUtils.TCP_PROTO, networkId, accountId, domainId, Purpose.LoadBalancing, null, null,null, null, null);
|
||||
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.algorithm = algorithm;
|
||||
this.defaultPortStart = instancePort;
|
||||
this.defaultPortEnd = instancePort;
|
||||
this.sourceIp = sourceIp;
|
||||
this.sourceIpNetworkId = sourceIpNtwkId;
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long getSourceIpNetworkId() {
|
||||
return sourceIpNetworkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ip getSourceIp() {
|
||||
return sourceIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultPortStart() {
|
||||
return defaultPortStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultPortEnd() {
|
||||
return defaultPortEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scheme getScheme() {
|
||||
return scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstancePort() {
|
||||
return defaultPortStart;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.lb.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
|
||||
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.net.Ip;
|
||||
|
||||
public interface ApplicationLoadBalancerRuleDao extends GenericDao<ApplicationLoadBalancerRuleVO, Long>{
|
||||
List<ApplicationLoadBalancerRuleVO> listBySrcIpSrcNtwkId(Ip sourceIp, long sourceNetworkId);
|
||||
List<String> listLbIpsBySourceIpNetworkId(long sourceIpNetworkId);
|
||||
long countBySourceIp(Ip sourceIp, long sourceIpNetworkId);
|
||||
List<ApplicationLoadBalancerRuleVO> listBySourceIpAndNotRevoked(Ip sourceIp, long sourceNetworkId);
|
||||
List<String> listLbIpsBySourceIpNetworkIdAndScheme(long sourceIpNetworkId, Scheme scheme);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.lb.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.net.Ip;
|
||||
|
||||
@Component
|
||||
@Local(value = { ApplicationLoadBalancerRuleDao.class })
|
||||
public class ApplicationLoadBalancerRuleDaoImpl extends GenericDaoBase<ApplicationLoadBalancerRuleVO, Long> implements ApplicationLoadBalancerRuleDao{
|
||||
protected final SearchBuilder<ApplicationLoadBalancerRuleVO> AllFieldsSearch;
|
||||
final GenericSearchBuilder<ApplicationLoadBalancerRuleVO, String> listIps;
|
||||
final GenericSearchBuilder<ApplicationLoadBalancerRuleVO, Long> CountBy;
|
||||
protected final SearchBuilder<ApplicationLoadBalancerRuleVO> NotRevokedSearch;
|
||||
|
||||
|
||||
|
||||
protected ApplicationLoadBalancerRuleDaoImpl() {
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("sourceIp", AllFieldsSearch.entity().getSourceIp(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("sourceIpNetworkId", AllFieldsSearch.entity().getSourceIpNetworkId(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("scheme", AllFieldsSearch.entity().getScheme(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
listIps = createSearchBuilder(String.class);
|
||||
listIps.select(null, Func.DISTINCT, listIps.entity().getSourceIp());
|
||||
listIps.and("sourceIpNetworkId", listIps.entity().getSourceIpNetworkId(), Op.EQ);
|
||||
listIps.and("scheme", listIps.entity().getScheme(), Op.EQ);
|
||||
listIps.done();
|
||||
|
||||
CountBy = createSearchBuilder(Long.class);
|
||||
CountBy.select(null, Func.COUNT, CountBy.entity().getId());
|
||||
CountBy.and("sourceIp", CountBy.entity().getSourceIp(), Op.EQ);
|
||||
CountBy.and("sourceIpNetworkId", CountBy.entity().getSourceIpNetworkId(), Op.EQ);
|
||||
CountBy.done();
|
||||
|
||||
NotRevokedSearch = createSearchBuilder();
|
||||
NotRevokedSearch.and("sourceIp", NotRevokedSearch.entity().getSourceIp(), SearchCriteria.Op.EQ);
|
||||
NotRevokedSearch.and("sourceIpNetworkId", NotRevokedSearch.entity().getSourceIpNetworkId(), SearchCriteria.Op.EQ);
|
||||
NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), SearchCriteria.Op.NEQ);
|
||||
NotRevokedSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationLoadBalancerRuleVO> listBySrcIpSrcNtwkId(Ip sourceIp, long sourceNetworkId) {
|
||||
SearchCriteria<ApplicationLoadBalancerRuleVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("sourceIp", sourceIp);
|
||||
sc.setParameters("sourceIpNetworkId", sourceNetworkId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listLbIpsBySourceIpNetworkId(long sourceIpNetworkId) {
|
||||
SearchCriteria<String> sc = listIps.create();
|
||||
sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countBySourceIp(Ip sourceIp, long sourceIpNetworkId) {
|
||||
SearchCriteria<Long> sc = CountBy.create();
|
||||
sc.setParameters("sourceIp", sourceIp);
|
||||
sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
|
||||
List<Long> results = customSearch(sc, null);
|
||||
return results.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationLoadBalancerRuleVO> listBySourceIpAndNotRevoked(Ip sourceIp, long sourceNetworkId) {
|
||||
SearchCriteria<ApplicationLoadBalancerRuleVO> sc = NotRevokedSearch.create();
|
||||
sc.setParameters("sourceIp", sourceIp);
|
||||
sc.setParameters("sourceIpNetworkId", sourceNetworkId);
|
||||
sc.setParameters("state", FirewallRule.State.Revoke);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listLbIpsBySourceIpNetworkIdAndScheme(long sourceIpNetworkId, Scheme scheme) {
|
||||
SearchCriteria<String> sc = listIps.create();
|
||||
sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
|
||||
sc.setParameters("scheme", scheme);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ public class DefaultHostListener implements HypervisorHostListener {
|
|||
}
|
||||
|
||||
if (!answer.getResult()) {
|
||||
String msg = "Add host failed due to ModifyStoragePoolCommand failed" + answer.getDetails();
|
||||
String msg = "Unable to attach storage pool" + poolId + " to the host" + hostId;
|
||||
alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, pool.getDataCenterId(), pool.getPodId(), msg, msg);
|
||||
throw new CloudRuntimeException("Unable establish connection from storage head to storage pool " + pool.getId() + " due to " + answer.getDetails() + pool.getId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -901,6 +901,28 @@ setup_elbvm() {
|
|||
chkconfig portmap off
|
||||
}
|
||||
|
||||
setup_ilbvm() {
|
||||
log_it "Setting up Internal Load Balancer system vm"
|
||||
local hyp=$1
|
||||
setup_common eth0 eth1
|
||||
#eth0 = guest network, eth1=control network
|
||||
|
||||
sed -i /$NAME/d /etc/hosts
|
||||
echo "$ETH0_IP $NAME" >> /etc/hosts
|
||||
|
||||
cp /etc/iptables/iptables-ilbvm /etc/iptables/rules.v4
|
||||
cp /etc/iptables/iptables-ilbvm /etc/iptables/rules
|
||||
setup_sshd $ETH1_IP "eth1"
|
||||
|
||||
enable_fwding 0
|
||||
enable_svc haproxy 1
|
||||
enable_svc dnsmasq 0
|
||||
enable_svc cloud-passwd-srvr 0
|
||||
enable_svc cloud 0
|
||||
chkconfig nfs-common off
|
||||
chkconfig portmap off
|
||||
}
|
||||
|
||||
setup_default() {
|
||||
cat > /etc/network/interfaces << EOF
|
||||
auto lo
|
||||
|
|
@ -951,6 +973,10 @@ start() {
|
|||
[ "$NAME" == "" ] && NAME=elb
|
||||
setup_elbvm
|
||||
;;
|
||||
ilbvm)
|
||||
[ "$NAME" == "" ] && NAME=ilb
|
||||
setup_ilbvm
|
||||
;;
|
||||
unknown)
|
||||
[ "$NAME" == "" ] && NAME=systemvm
|
||||
setup_default;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
*nat
|
||||
:PREROUTING ACCEPT [0:0]
|
||||
:POSTROUTING ACCEPT [0:0]
|
||||
:OUTPUT ACCEPT [0:0]
|
||||
COMMIT
|
||||
*filter
|
||||
:INPUT DROP [0:0]
|
||||
:FORWARD DROP [0:0]
|
||||
:OUTPUT ACCEPT [0:0]
|
||||
-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A INPUT -p icmp -j ACCEPT
|
||||
-A INPUT -i lo -j ACCEPT
|
||||
-A INPUT -i eth1 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
|
||||
COMMIT
|
||||
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
#!/usr/bin/env bash
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
source /root/func.sh
|
||||
|
||||
lock="biglock"
|
||||
locked=$(getLockFile $lock)
|
||||
if [ "$locked" != "1" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s: -a <added public ip address ip:port> -d <removed ip:port> -f <load balancer config> -s <stats ip ip:port:cidr> \n" $(basename $0) >&2
|
||||
}
|
||||
|
||||
#set -x
|
||||
|
||||
fw_remove_backup() {
|
||||
logger -t cloud "$(basename $0): Entering fw_remove_backup"
|
||||
local lb_vif_list=eth0
|
||||
for vif in $lb_vif_list; do
|
||||
sudo iptables -F back_load_balancer_$vif 2> /dev/null
|
||||
sudo iptables -D INPUT -i $vif -p tcp -j back_load_balancer_$vif 2> /dev/null
|
||||
sudo iptables -X back_load_balancer_$vif 2> /dev/null
|
||||
done
|
||||
sudo iptables -F back_lb_stats 2> /dev/null
|
||||
sudo iptables -D INPUT -p tcp -j back_lb_stats 2> /dev/null
|
||||
sudo iptables -X back_lb_stats 2> /dev/null
|
||||
}
|
||||
|
||||
fw_restore() {
|
||||
logger -t cloud "$(basename $0): Entering fw_restore"
|
||||
local lb_vif_list="eth0"
|
||||
for vif in $lb_vif_list; do
|
||||
sudo iptables -F load_balancer_$vif 2> /dev/null
|
||||
sudo iptables -D INPUT -i $vif -p tcp -j load_balancer_$vif 2> /dev/null
|
||||
sudo iptables -X load_balancer_$vif 2> /dev/null
|
||||
sudo iptables -E back_load_balancer_$vif load_balancer_$vif 2> /dev/null
|
||||
done
|
||||
sudo iptables -F lb_stats 2> /dev/null
|
||||
sudo iptables -D INPUT -p tcp -j lb_stats 2> /dev/null
|
||||
sudo iptables -X lb_stats 2> /dev/null
|
||||
sudo iptables -E back_lb_stats lb_stats 2> /dev/null
|
||||
}
|
||||
|
||||
# firewall entry to ensure that haproxy can receive on specified port
|
||||
fw_entry() {
|
||||
logger -t cloud "$(basename $0): Entering fw_entry"
|
||||
local added=$1
|
||||
local removed=$2
|
||||
local stats=$3
|
||||
|
||||
if [ "$added" == "none" ]
|
||||
then
|
||||
added=""
|
||||
fi
|
||||
|
||||
if [ "$removed" == "none" ]
|
||||
then
|
||||
removed=""
|
||||
fi
|
||||
|
||||
local a=$(echo $added | cut -d, -f1- --output-delimiter=" ")
|
||||
local r=$(echo $removed | cut -d, -f1- --output-delimiter=" ")
|
||||
|
||||
# back up the iptable rules by renaming before creating new.
|
||||
local lb_vif_list=eth0
|
||||
for vif in $lb_vif_list; do
|
||||
sudo iptables -E load_balancer_$vif back_load_balancer_$vif 2> /dev/null
|
||||
sudo iptables -N load_balancer_$vif 2> /dev/null
|
||||
sudo iptables -A INPUT -i $vif -p tcp -j load_balancer_$vif
|
||||
done
|
||||
sudo iptables -E lb_stats back_lb_stats 2> /dev/null
|
||||
sudo iptables -N lb_stats 2> /dev/null
|
||||
sudo iptables -A INPUT -p tcp -j lb_stats
|
||||
|
||||
for i in $a
|
||||
do
|
||||
local pubIp=$(echo $i | cut -d: -f1)
|
||||
local dport=$(echo $i | cut -d: -f2)
|
||||
local lb_vif_list="eth0"
|
||||
for vif in $lb_vif_list; do
|
||||
sudo iptables -A load_balancer_$vif -p tcp -d $pubIp --dport $dport -j ACCEPT
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
done
|
||||
local pubIp=$(echo $stats | cut -d: -f1)
|
||||
local dport=$(echo $stats | cut -d: -f2)
|
||||
local cidrs=$(echo $stats | cut -d: -f3 | sed 's/-/,/')
|
||||
sudo iptables -A lb_stats -s $cidrs -p tcp -m state --state NEW -d $pubIp --dport $dport -j ACCEPT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#Hot reconfigure HA Proxy in the routing domain
|
||||
reconfig_lb() {
|
||||
/root/reconfigLB.sh
|
||||
return $?
|
||||
}
|
||||
|
||||
# Restore the HA Proxy to its previous state, and revert iptables rules on loadbalancer
|
||||
restore_lb() {
|
||||
logger -t cloud "Restoring HA Proxy to previous state"
|
||||
# Copy the old version of haproxy.cfg into the file that reconfigLB.sh uses
|
||||
cp /etc/haproxy/haproxy.cfg.old /etc/haproxy/haproxy.cfg.new
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
# Run reconfigLB.sh again
|
||||
/root/reconfigLB.sh
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
logger -t cloud "$(basename $0): Entering $(dirname $0)/$(basename $0)"
|
||||
|
||||
iflag=
|
||||
aflag=
|
||||
dflag=
|
||||
sflag=
|
||||
|
||||
while getopts 'i:a:d:s:' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
i) iflag=1
|
||||
domRIp="$OPTARG" #unused but passed in
|
||||
;;
|
||||
a) aflag=1
|
||||
addedIps="$OPTARG"
|
||||
;;
|
||||
d) dflag=1
|
||||
removedIps="$OPTARG"
|
||||
;;
|
||||
|
||||
s) sflag=1
|
||||
statsIp="$OPTARG"
|
||||
;;
|
||||
?) usage
|
||||
unlock_exit 2 $lock $locked
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$aflag$dflag" != "1" && "$aflag$dflag" != "11" ]]
|
||||
then
|
||||
usage
|
||||
unlock_exit 2 $lock $locked
|
||||
fi
|
||||
|
||||
if [ "$addedIps" == "" ]
|
||||
then
|
||||
addedIps="none"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$removedIps" == "" ]
|
||||
then
|
||||
removedIps="none"
|
||||
fi
|
||||
|
||||
|
||||
# hot reconfigure haproxy
|
||||
reconfig_lb $cfgfile
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
logger -t cloud "Reconfiguring ilb failed"
|
||||
unlock_exit 1 $lock $locked
|
||||
fi
|
||||
|
||||
logger -t cloud "HAProxy reconfigured successfully, configuring firewall"
|
||||
|
||||
# iptables entry to ensure that haproxy receives traffic
|
||||
fw_entry $addedIps $removedIps $statsIp
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
logger -t cloud "Failed to apply firewall rules for internal load balancing, reverting HA Proxy config"
|
||||
# Restore the LB
|
||||
restore_lb
|
||||
|
||||
logger -t cloud "Reverting firewall config"
|
||||
fw_restore
|
||||
|
||||
unlock_exit 1 $lock $locked
|
||||
else
|
||||
# Remove backedup iptable rules
|
||||
logger -t cloud "Firewall configured successfully, deleting backup firewall config"
|
||||
fw_remove_backup
|
||||
fi
|
||||
|
||||
unlock_exit 0 $lock $locked
|
||||
|
|
@ -135,6 +135,19 @@ elbvm_svcs() {
|
|||
echo "cloud dnsmasq cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs
|
||||
}
|
||||
|
||||
|
||||
ilbvm_svcs() {
|
||||
chkconfig cloud off
|
||||
chkconfig haproxy on ;
|
||||
chkconfig ssh on
|
||||
chkconfig nfs-common off
|
||||
chkconfig portmap off
|
||||
chkconfig keepalived off
|
||||
chkconfig conntrackd off
|
||||
echo "ssh haproxy" > /var/cache/cloud/enabled_svcs
|
||||
echo "cloud dnsmasq cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs
|
||||
}
|
||||
|
||||
enable_pcihotplug() {
|
||||
sed -i -e "/acpiphp/d" /etc/modules
|
||||
sed -i -e "/pci_hotplug/d" /etc/modules
|
||||
|
|
@ -253,4 +266,14 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ "$TYPE" == "ilbvm" ]
|
||||
then
|
||||
ilbvm_svcs
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to execute ilbvm svcs\n" >$logfile
|
||||
exit 9
|
||||
fi
|
||||
fi
|
||||
|
||||
exit $?
|
||||
|
|
|
|||
|
|
@ -18,6 +18,29 @@
|
|||
|
||||
# @VERSION@
|
||||
|
||||
do_ilb_if_ilb () {
|
||||
local typ=""
|
||||
local pattern="type=(.*)"
|
||||
|
||||
for keyval in $(cat /var/cache/cloud/cmdline)
|
||||
do
|
||||
if [[ $keyval =~ $pattern ]]; then
|
||||
typ=${BASH_REMATCH[1]};
|
||||
fi
|
||||
done
|
||||
if [ "$typ" == "ilbvm" ]
|
||||
then
|
||||
logger -t cloud "$(basename $0): Detected that we are running in an internal load balancer vm"
|
||||
$(dirname $0)/ilb.sh "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
logger -t cloud "$(basename $0): Entering $(dirname $0)/$(basename $0)"
|
||||
|
||||
do_ilb_if_ilb "$@"
|
||||
|
||||
source /root/func.sh
|
||||
source /opt/cloud/bin/vpc_func.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -58,5 +58,15 @@
|
|||
<artifactId>wsdl4j</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ import com.cloud.agent.api.RebootCommand;
|
|||
import com.cloud.agent.api.RebootRouterCommand;
|
||||
import com.cloud.agent.api.RevertToVMSnapshotAnswer;
|
||||
import com.cloud.agent.api.RevertToVMSnapshotCommand;
|
||||
import com.cloud.agent.api.ScaleVmCommand;
|
||||
import com.cloud.agent.api.ScaleVmAnswer;
|
||||
import com.cloud.agent.api.SetupAnswer;
|
||||
import com.cloud.agent.api.SetupCommand;
|
||||
import com.cloud.agent.api.SetupGuestNetworkAnswer;
|
||||
|
|
@ -485,6 +487,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
return execute((ResizeVolumeCommand) cmd);
|
||||
} else if (clz == UnregisterVMCommand.class) {
|
||||
return execute((UnregisterVMCommand) cmd);
|
||||
} else if (clz == ScaleVmCommand.class) {
|
||||
return execute((ScaleVmCommand) cmd);
|
||||
} else {
|
||||
answer = Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
|
|
@ -2088,6 +2092,28 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
return validatedDisks.toArray(new VolumeTO[0]);
|
||||
}
|
||||
|
||||
protected ScaleVmAnswer execute(ScaleVmCommand cmd) {
|
||||
|
||||
VmwareContext context = getServiceContext();
|
||||
VirtualMachineTO vmSpec = cmd.getVirtualMachine();
|
||||
try{
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(context);
|
||||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
|
||||
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
|
||||
int ramMb = (int) (vmSpec.getMinRam());
|
||||
|
||||
VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getSpeed(), vmSpec.getSpeed(),(int) (vmSpec.getMaxRam()), ramMb, vmSpec.getLimitCpuUse());
|
||||
|
||||
if(!vmMo.configureVm(vmConfigSpec)) {
|
||||
throw new Exception("Unable to execute ScaleVmCommand");
|
||||
}
|
||||
}catch(Exception e) {
|
||||
s_logger.error("Unexpected exception: ", e);
|
||||
return new ScaleVmAnswer(cmd, false, "Unable to execute ScaleVmCommand due to " + e.toString());
|
||||
}
|
||||
return new ScaleVmAnswer(cmd, true, null);
|
||||
}
|
||||
|
||||
protected StartAnswer execute(StartCommand cmd) {
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
|
|
@ -2191,7 +2217,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(),
|
||||
vmSpec.getMinSpeed(),(int) (vmSpec.getMaxRam()/(1024*1024)), ramMb,
|
||||
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(), vmSpec.getLimitCpuUse());
|
||||
|
||||
|
||||
vmConfigSpec.setMemoryHotAddEnabled(true);
|
||||
vmConfigSpec.setCpuHotAddEnabled(true);
|
||||
|
||||
if ("true".equals(vmSpec.getDetails().get(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG))) {
|
||||
s_logger.debug("Nested Virtualization enabled in configuration, checking hypervisor capability");
|
||||
ManagedObjectReference hostMor = vmMo.getRunningHost().getMor();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.hypervisor.vmware.resource;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.ScaleVmAnswer;
|
||||
import com.cloud.agent.api.ScaleVmCommand;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
|
||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||
import com.vmware.vim25.VirtualMachineConfigSpec;
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
||||
public class VmwareResourceTest {
|
||||
|
||||
@Spy VmwareResource _resource = new VmwareResource() {
|
||||
|
||||
@Override
|
||||
public ScaleVmAnswer execute(ScaleVmCommand cmd) {
|
||||
return super.execute(cmd);
|
||||
}
|
||||
@Override
|
||||
public VmwareHypervisorHost getHyperHost(VmwareContext context, Command cmd) {
|
||||
return hyperHost;
|
||||
}
|
||||
};
|
||||
|
||||
@Mock VmwareContext context;
|
||||
@Mock ScaleVmCommand cmd;
|
||||
@Mock VirtualMachineTO vmSpec;
|
||||
@Mock
|
||||
VmwareHypervisorHost hyperHost;
|
||||
@Mock VirtualMachineMO vmMo;
|
||||
@Mock VirtualMachineConfigSpec vmConfigSpec;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
MockitoAnnotations.initMocks(this);
|
||||
doReturn(context).when(_resource).getServiceContext(null);
|
||||
when(cmd.getVirtualMachine()).thenReturn(vmSpec);
|
||||
}
|
||||
//Test successful scaling up the vm
|
||||
@Test
|
||||
public void testScaleVMF1() throws Exception {
|
||||
when(_resource.getHyperHost(context, null)).thenReturn(hyperHost);
|
||||
doReturn("i-2-3-VM").when(cmd).getVmName();
|
||||
when(hyperHost.findVmOnHyperHost("i-2-3-VM")).thenReturn(vmMo);
|
||||
doReturn(1024L).when(vmSpec).getMinRam();
|
||||
doReturn(1).when(vmSpec).getCpus();
|
||||
doReturn(1000).when(vmSpec).getSpeed();
|
||||
doReturn(1024L).when(vmSpec).getMaxRam();
|
||||
doReturn(false).when(vmSpec).getLimitCpuUse();
|
||||
when(vmMo.configureVm(vmConfigSpec)).thenReturn(true);
|
||||
|
||||
ScaleVmAnswer answer = _resource.execute(cmd);
|
||||
verify(_resource).execute(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -118,70 +118,38 @@ under the License.
|
|||
<policyNetworkExpression
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2"
|
||||
id="2"
|
||||
opr="eq"
|
||||
opr="range"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-4/nw-expr2/nw-attr-qual">
|
||||
<policyNwAttrQualifier
|
||||
attrEp="source"
|
||||
attrEp="destination"
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2/nw-attr-qual"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-4/nw-expr2/nw-ip-2">
|
||||
<policyIPAddress
|
||||
dataType="string"
|
||||
descr=""
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2/nw-ip-2"
|
||||
id="2"
|
||||
name=""
|
||||
placement="none"
|
||||
status="created"
|
||||
value="%sourceip%"/>
|
||||
</pair>
|
||||
|
||||
<pair key="%aclruledn%/rule-cond-5">
|
||||
<policyRuleCondition
|
||||
dn="%aclruledn%/rule-cond-5"
|
||||
id="5"
|
||||
order="unspecified"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-5/nw-expr2">
|
||||
<policyNetworkExpression
|
||||
dn="%aclruledn%/rule-cond-5/nw-expr2"
|
||||
id="2"
|
||||
opr="range"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-5/nw-expr2/nw-attr-qual">
|
||||
<policyNwAttrQualifier
|
||||
attrEp="source"
|
||||
dn="%aclruledn%/rule-cond-5/nw-expr2/nw-attr-qual"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-5/nw-expr2/nw-port-2">
|
||||
<pair key="%aclruledn%/rule-cond-4/nw-expr2/nw-port-2">
|
||||
<policyNetworkPort
|
||||
appType="Other"
|
||||
dataType="string"
|
||||
descr=""
|
||||
dn="%aclruledn%/rule-cond-5/nw-expr2/nw-port-2"
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2/nw-port-2"
|
||||
id="2"
|
||||
name=""
|
||||
placement="begin"
|
||||
status="created"
|
||||
value="%sourcestartport%"/>
|
||||
value="%deststartport%"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-5/nw-expr2/nw-port-3">
|
||||
<pair key="%aclruledn%/rule-cond-4/nw-expr2/nw-port-3">
|
||||
<policyNetworkPort
|
||||
appType="Other"
|
||||
dataType="string"
|
||||
descr=""
|
||||
dn="%aclruledn%/rule-cond-5/nw-expr2/nw-port-3"
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2/nw-port-3"
|
||||
id="3"
|
||||
name=""
|
||||
placement="end"
|
||||
status="created"
|
||||
value="%sourceendport%"/>
|
||||
value="%destendport%"/>
|
||||
</pair>
|
||||
|
||||
</inConfigs>
|
||||
|
|
@ -195,7 +163,6 @@ under the License.
|
|||
protocolvalue = "TCP" or "UDP"
|
||||
deststartip="destination start ip"
|
||||
destendip="destination end ip"
|
||||
sourcestartport="start port at source"
|
||||
sourceendport="end port at source"
|
||||
sourceip="source ip"
|
||||
deststartport="start port at destination"
|
||||
destendport="end port at destination"
|
||||
--!>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<configConfMos
|
||||
cookie="%cookie%"
|
||||
inHierarchical="false">
|
||||
<inConfigs>
|
||||
|
||||
<pair key="%aclruledn%">
|
||||
<policyRule
|
||||
descr="%descr%"
|
||||
dn="%aclruledn%"
|
||||
name="%aclrulename%"
|
||||
order="%order%"
|
||||
status="created"/>
|
||||
</pair>
|
||||
|
||||
<pair key="%aclruledn%/rule-action-0">
|
||||
<fwpolicyAction
|
||||
actionType="%actiontype%"
|
||||
dn="%aclruledn%/rule-action-0"
|
||||
id="0"
|
||||
status="created"/>
|
||||
</pair>
|
||||
|
||||
<pair key="%aclruledn%/rule-cond-2">
|
||||
<policyRuleCondition
|
||||
dn="%aclruledn%/rule-cond-2"
|
||||
id="2"
|
||||
order="unspecified"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-2/nw-expr2">
|
||||
<policyNetworkExpression
|
||||
dn="%aclruledn%/rule-cond-2/nw-expr2"
|
||||
id="2"
|
||||
opr="range"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-2/nw-expr2/nw-attr-qual">
|
||||
<policyNwAttrQualifier
|
||||
attrEp="destination"
|
||||
dn="%aclruledn%/rule-cond-2/nw-expr2/nw-attr-qual"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-2/nw-expr2/nw-ip-2">
|
||||
<policyIPAddress
|
||||
dataType="string"
|
||||
descr=""
|
||||
dn="%aclruledn%/rule-cond-2/nw-expr2/nw-ip-2"
|
||||
id="2"
|
||||
name=""
|
||||
placement="begin"
|
||||
status="created"
|
||||
value="%deststartip%"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-2/nw-expr2/nw-ip-3">
|
||||
<policyIPAddress
|
||||
dataType="string"
|
||||
descr=""
|
||||
dn="%aclruledn%/rule-cond-2/nw-expr2/nw-ip-3"
|
||||
id="3"
|
||||
name=""
|
||||
placement="end"
|
||||
status="created"
|
||||
value="%destendip%"/>
|
||||
</pair>
|
||||
|
||||
</inConfigs>
|
||||
</configConfMos>
|
||||
|
||||
<!--
|
||||
aclruledn="org-root/org-vlan-123/org-VDC-vlan-123/pol-test_policy/rule-dummy"
|
||||
aclrulename="dummy"
|
||||
descr=value
|
||||
actiontype="drop" or "permit"
|
||||
deststartip="destination start ip"
|
||||
destendip="destination end ip"
|
||||
--!>
|
||||
|
|
@ -118,5 +118,4 @@ under the License.
|
|||
protocolvalue = "TCP" or "UDP" or "ICMP"
|
||||
deststartip="destination start ip"
|
||||
destendip="destination end ip"
|
||||
sourceip="source ip"
|
||||
--!>
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ under the License.
|
|||
<policyNetworkExpression
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2"
|
||||
id="2"
|
||||
opr="eq"
|
||||
opr="range"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-4/nw-expr2/nw-attr-qual">
|
||||
|
|
@ -127,56 +127,24 @@ under the License.
|
|||
dn="%aclruledn%/rule-cond-4/nw-expr2/nw-attr-qual"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-4/nw-expr2/nw-ip-2">
|
||||
<policyIPAddress
|
||||
dataType="string"
|
||||
descr=""
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2/nw-ip-2"
|
||||
id="2"
|
||||
name=""
|
||||
placement="none"
|
||||
status="created"
|
||||
value="%destip%"/>
|
||||
</pair>
|
||||
|
||||
<pair key="%aclruledn%/rule-cond-5">
|
||||
<policyRuleCondition
|
||||
dn="%aclruledn%/rule-cond-5"
|
||||
id="5"
|
||||
order="unspecified"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-5/nw-expr2">
|
||||
<policyNetworkExpression
|
||||
dn="%aclruledn%/rule-cond-5/nw-expr2"
|
||||
id="2"
|
||||
opr="range"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-5/nw-expr2/nw-attr-qual">
|
||||
<policyNwAttrQualifier
|
||||
attrEp="destination"
|
||||
dn="%aclruledn%/rule-cond-5/nw-expr2/nw-attr-qual"
|
||||
status="created"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-5/nw-expr2/nw-port-2">
|
||||
<pair key="%aclruledn%/rule-cond-4/nw-expr2/nw-port-2">
|
||||
<policyNetworkPort
|
||||
appType="Other"
|
||||
dataType="string"
|
||||
descr=""
|
||||
dn="%aclruledn%/rule-cond-5/nw-expr2/nw-port-2"
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2/nw-port-2"
|
||||
id="2"
|
||||
name=""
|
||||
placement="begin"
|
||||
status="created"
|
||||
value="%deststartport%"/>
|
||||
</pair>
|
||||
<pair key="%aclruledn%/rule-cond-5/nw-expr2/nw-port-3">
|
||||
<pair key="%aclruledn%/rule-cond-4/nw-expr2/nw-port-3">
|
||||
<policyNetworkPort
|
||||
appType="Other"
|
||||
dataType="string"
|
||||
descr=""
|
||||
dn="%aclruledn%/rule-cond-5/nw-expr2/nw-port-3"
|
||||
dn="%aclruledn%/rule-cond-4/nw-expr2/nw-port-3"
|
||||
id="3"
|
||||
name=""
|
||||
placement="end"
|
||||
|
|
@ -197,5 +165,4 @@ under the License.
|
|||
sourceendip="source end ip"
|
||||
deststartport="start port at destination"
|
||||
destendport="end port at destination"
|
||||
destip="destination ip"
|
||||
--!>
|
||||
|
|
|
|||
|
|
@ -140,23 +140,23 @@ public interface CiscoVnmcConnection {
|
|||
public boolean createTenantVDCIngressAclRule(String tenantName,
|
||||
String identifier, String policyIdentifier,
|
||||
String protocol, String sourceStartIp, String sourceEndIp,
|
||||
String destStartPort, String destEndPort, String destIp)
|
||||
String destStartPort, String destEndPort)
|
||||
throws ExecutionException;
|
||||
|
||||
public boolean createTenantVDCIngressAclRule(String tenantName,
|
||||
String identifier, String policyIdentifier,
|
||||
String protocol, String sourceStartIp, String sourceEndIp, String destIp)
|
||||
String protocol, String sourceStartIp, String sourceEndIp)
|
||||
throws ExecutionException;
|
||||
|
||||
public boolean createTenantVDCEgressAclRule(String tenantName,
|
||||
String identifier, String policyIdentifier,
|
||||
String protocol, String sourceStartPort, String sourceEndPort, String sourceIp,
|
||||
String destStartIp, String destEndIp)
|
||||
String protocol, String destStartIp, String destEndIp,
|
||||
String destStartPort, String destEndPort)
|
||||
throws ExecutionException;
|
||||
|
||||
public boolean createTenantVDCEgressAclRule(String tenantName,
|
||||
String identifier, String policyIdentifier,
|
||||
String protocol, String sourceIp, String destStartIp, String destEndIp)
|
||||
String protocol, String destStartIp, String destEndIp)
|
||||
throws ExecutionException;
|
||||
|
||||
public boolean deleteTenantVDCAclRule(String tenantName,
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
CREATE_EGRESS_ACL_RULE("create-egress-acl-rule.xml", "policy-mgr"),
|
||||
CREATE_GENERIC_INGRESS_ACL_RULE("create-generic-ingress-acl-rule.xml", "policy-mgr"),
|
||||
CREATE_GENERIC_EGRESS_ACL_RULE("create-generic-egress-acl-rule.xml", "policy-mgr"),
|
||||
CREATE_GENERIC_EGRESS_ACL_NO_PROTOCOL_RULE("create-generic-egress-acl-no-protocol-rule.xml", "policy-mgr"),
|
||||
|
||||
DELETE_RULE("delete-rule.xml", "policy-mgr"),
|
||||
|
||||
|
|
@ -279,7 +280,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
String xml = VnmcXml.CREATE_VDC.getXml();
|
||||
String service = VnmcXml.CREATE_VDC.getService();
|
||||
xml = replaceXmlValue(xml, "cookie", _cookie);
|
||||
xml = replaceXmlValue(xml, "descr", "VDC for Tenant" + tenantName);
|
||||
xml = replaceXmlValue(xml, "descr", "VDC for Tenant " + tenantName);
|
||||
xml = replaceXmlValue(xml, "name", getNameForTenantVDC(tenantName));
|
||||
xml = replaceXmlValue(xml, "dn", getDnForTenantVDC(tenantName));
|
||||
|
||||
|
|
@ -304,7 +305,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
String xml = VnmcXml.CREATE_EDGE_DEVICE_PROFILE.getXml();
|
||||
String service = VnmcXml.CREATE_EDGE_DEVICE_PROFILE.getService();
|
||||
xml = replaceXmlValue(xml, "cookie", _cookie);
|
||||
xml = replaceXmlValue(xml, "descr", "Edge Device Profile for Tenant VDC" + tenantName);
|
||||
xml = replaceXmlValue(xml, "descr", "Edge Device Profile for Tenant VDC " + tenantName);
|
||||
xml = replaceXmlValue(xml, "name", getNameForEdgeDeviceServiceProfile(tenantName));
|
||||
xml = replaceXmlValue(xml, "dn", getDnForTenantVDCEdgeDeviceProfile(tenantName));
|
||||
|
||||
|
|
@ -407,7 +408,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
String xml = VnmcXml.CREATE_EDGE_SECURITY_PROFILE.getXml();
|
||||
String service = VnmcXml.CREATE_EDGE_SECURITY_PROFILE.getService();
|
||||
xml = replaceXmlValue(xml, "cookie", _cookie);
|
||||
xml = replaceXmlValue(xml, "descr", "Edge Security Profile for Tenant VDC" + tenantName);
|
||||
xml = replaceXmlValue(xml, "descr", "Edge Security Profile for Tenant VDC " + tenantName);
|
||||
xml = replaceXmlValue(xml, "name", getNameForEdgeDeviceSecurityProfile(tenantName));
|
||||
xml = replaceXmlValue(xml, "espdn", getDnForTenantVDCEdgeSecurityProfile(tenantName));
|
||||
xml = replaceXmlValue(xml, "egressref", "default-egress");
|
||||
|
|
@ -505,7 +506,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
return createTenantVDCNatPolicyRef(
|
||||
getDnForSourceNatPolicyRef(tenantName),
|
||||
getNameForSourceNatPolicy(tenantName),
|
||||
tenantName);
|
||||
tenantName,
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -545,7 +547,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
String xml = VnmcXml.RESOLVE_NAT_POLICY_SET.getXml();
|
||||
String service = VnmcXml.RESOLVE_NAT_POLICY_SET.getService();
|
||||
xml = replaceXmlValue(xml, "cookie", _cookie);
|
||||
xml = replaceXmlValue(xml, "descr", "Edge Security Profile for Tenant VDC" + tenantName);
|
||||
xml = replaceXmlValue(xml, "descr", "Edge Security Profile for Tenant VDC " + tenantName);
|
||||
xml = replaceXmlValue(xml, "name", getNameForEdgeDeviceSecurityProfile(tenantName));
|
||||
xml = replaceXmlValue(xml, "espdn", getDnForTenantVDCEdgeSecurityProfile(tenantName));
|
||||
xml = replaceXmlValue(xml, "natpolicysetname", getNameForNatPolicySet(tenantName));
|
||||
|
|
@ -656,11 +658,10 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
String xml = VnmcXml.RESOLVE_ACL_POLICY_SET.getXml();
|
||||
String service = VnmcXml.RESOLVE_ACL_POLICY_SET.getService();
|
||||
xml = replaceXmlValue(xml, "cookie", _cookie);
|
||||
xml = replaceXmlValue(xml, "descr", "Edge Security Profile for Tenant VDC" + tenantName);
|
||||
xml = replaceXmlValue(xml, "descr", "Edge Security Profile for Tenant VDC " + tenantName);
|
||||
xml = replaceXmlValue(xml, "name", getNameForEdgeDeviceSecurityProfile(tenantName));
|
||||
xml = replaceXmlValue(xml, "espdn", getDnForTenantVDCEdgeSecurityProfile(tenantName));
|
||||
//xml = replaceXmlValue(xml, "egresspolicysetname", getNameForAclPolicySet(tenantName, false));
|
||||
xml = replaceXmlValue(xml, "egresspolicysetname", "default-egress");
|
||||
xml = replaceXmlValue(xml, "egresspolicysetname", getNameForAclPolicySet(tenantName, false));
|
||||
xml = replaceXmlValue(xml, "ingresspolicysetname", getNameForAclPolicySet(tenantName, true));
|
||||
xml = replaceXmlValue(xml, "natpolicysetname", getNameForNatPolicySet(tenantName));
|
||||
|
||||
|
|
@ -672,7 +673,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
public boolean createTenantVDCIngressAclRule(String tenantName,
|
||||
String identifier, String policyIdentifier,
|
||||
String protocol, String sourceStartIp, String sourceEndIp,
|
||||
String destStartPort, String destEndPort, String destIp) throws ExecutionException {
|
||||
String destStartPort, String destEndPort) throws ExecutionException {
|
||||
String xml = VnmcXml.CREATE_INGRESS_ACL_RULE.getXml();
|
||||
String service = VnmcXml.CREATE_INGRESS_ACL_RULE.getService();
|
||||
|
||||
|
|
@ -686,7 +687,6 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
xml = replaceXmlValue(xml, "sourceendip", sourceEndIp);
|
||||
xml = replaceXmlValue(xml, "deststartport", destStartPort);
|
||||
xml = replaceXmlValue(xml, "destendport", destEndPort);
|
||||
xml = replaceXmlValue(xml, "destip", destIp);
|
||||
|
||||
List<String> rules = listChildren(getDnForAclPolicy(tenantName, policyIdentifier));
|
||||
int order = 100;
|
||||
|
|
@ -702,8 +702,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
@Override
|
||||
public boolean createTenantVDCIngressAclRule(String tenantName,
|
||||
String identifier, String policyIdentifier,
|
||||
String protocol, String sourceStartIp, String sourceEndIp,
|
||||
String destIp) throws ExecutionException {
|
||||
String protocol, String sourceStartIp, String sourceEndIp) throws ExecutionException {
|
||||
String xml = VnmcXml.CREATE_GENERIC_INGRESS_ACL_RULE.getXml();
|
||||
String service = VnmcXml.CREATE_GENERIC_INGRESS_ACL_RULE.getService();
|
||||
|
||||
|
|
@ -730,8 +729,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
@Override
|
||||
public boolean createTenantVDCEgressAclRule(String tenantName,
|
||||
String identifier, String policyIdentifier,
|
||||
String protocol, String sourceStartPort, String sourceEndPort, String sourceIp,
|
||||
String destStartIp, String destEndIp) throws ExecutionException {
|
||||
String protocol, String destStartIp, String destEndIp,
|
||||
String destStartPort, String destEndPort) throws ExecutionException {
|
||||
String xml = VnmcXml.CREATE_EGRESS_ACL_RULE.getXml();
|
||||
String service = VnmcXml.CREATE_EGRESS_ACL_RULE.getService();
|
||||
|
||||
|
|
@ -743,9 +742,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
xml = replaceXmlValue(xml, "protocolvalue", protocol);
|
||||
xml = replaceXmlValue(xml, "deststartip", destStartIp);
|
||||
xml = replaceXmlValue(xml, "destendip", destEndIp);
|
||||
xml = replaceXmlValue(xml, "sourcestartport", sourceStartPort);
|
||||
xml = replaceXmlValue(xml, "sourceendport", sourceEndPort);
|
||||
xml = replaceXmlValue(xml, "sourceip", sourceIp);
|
||||
xml = replaceXmlValue(xml, "deststartport", destStartPort);
|
||||
xml = replaceXmlValue(xml, "destendport", destEndPort);
|
||||
|
||||
List<String> rules = listChildren(getDnForAclPolicy(tenantName, policyIdentifier));
|
||||
int order = 100;
|
||||
|
|
@ -761,17 +759,20 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
@Override
|
||||
public boolean createTenantVDCEgressAclRule(String tenantName,
|
||||
String identifier, String policyIdentifier,
|
||||
String protocol, String sourceIp,
|
||||
String destStartIp, String destEndIp) throws ExecutionException {
|
||||
String protocol, String destStartIp, String destEndIp) throws ExecutionException {
|
||||
String xml = VnmcXml.CREATE_GENERIC_EGRESS_ACL_RULE.getXml();
|
||||
String service = VnmcXml.CREATE_GENERIC_EGRESS_ACL_RULE.getService();
|
||||
|
||||
if (protocol.equalsIgnoreCase("all")) { // any protocol
|
||||
xml = VnmcXml.CREATE_GENERIC_EGRESS_ACL_NO_PROTOCOL_RULE.getXml();
|
||||
service = VnmcXml.CREATE_GENERIC_EGRESS_ACL_NO_PROTOCOL_RULE.getService();
|
||||
} else { // specific protocol
|
||||
xml = replaceXmlValue(xml, "protocolvalue", protocol);
|
||||
}
|
||||
xml = replaceXmlValue(xml, "cookie", _cookie);
|
||||
xml = replaceXmlValue(xml, "aclruledn", getDnForAclRule(tenantName, identifier, policyIdentifier));
|
||||
xml = replaceXmlValue(xml, "aclrulename", getNameForAclRule(tenantName, identifier));
|
||||
xml = replaceXmlValue(xml, "descr", "Egress ACL rule for Tenant VDC " + tenantName);
|
||||
xml = replaceXmlValue(xml, "actiontype", "permit");
|
||||
xml = replaceXmlValue(xml, "protocolvalue", protocol);
|
||||
xml = replaceXmlValue(xml, "deststartip", destStartIp);
|
||||
xml = replaceXmlValue(xml, "destendip", destEndIp);
|
||||
|
||||
|
|
@ -838,17 +839,23 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
return verifySuccess(response);
|
||||
}
|
||||
|
||||
private boolean createTenantVDCNatPolicyRef(String policyRefDn, String name, String tenantName) throws ExecutionException {
|
||||
private boolean createTenantVDCNatPolicyRef(String policyRefDn, String name, String tenantName, boolean isSourceNat) throws ExecutionException {
|
||||
String xml = VnmcXml.CREATE_NAT_POLICY_REF.getXml();
|
||||
String service = VnmcXml.CREATE_NAT_POLICY_REF.getService();
|
||||
xml = replaceXmlValue(xml, "cookie", _cookie);
|
||||
xml = replaceXmlValue(xml, "natpolicyrefdn", policyRefDn);
|
||||
xml = replaceXmlValue(xml, "natpolicyname", name);
|
||||
|
||||
List<String> policies = listNatPolicies(tenantName);
|
||||
int order = 100;
|
||||
if (policies != null) {
|
||||
order += policies.size();
|
||||
// PF and static NAT policies need to come before source NAT, so leaving buffer
|
||||
// and creating source NAT with a high order value.
|
||||
// Initially tried setting MAX_INT as the order but VNMC complains about it
|
||||
int order = 10000; // TODO: For now value should be sufficient, if required may need to increase
|
||||
if (!isSourceNat) {
|
||||
List<String> policies = listNatPolicies(tenantName);
|
||||
order = 100; // order starts at 100
|
||||
if (policies != null) {
|
||||
order += policies.size();
|
||||
}
|
||||
}
|
||||
xml = replaceXmlValue(xml, "order", Integer.toString(order));
|
||||
|
||||
|
|
@ -1062,7 +1069,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
return createTenantVDCNatPolicyRef(
|
||||
getDnForPFPolicyRef(tenantName, identifier),
|
||||
getNameForPFPolicy(tenantName, identifier),
|
||||
tenantName);
|
||||
tenantName,
|
||||
false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1180,7 +1188,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
|
|||
return createTenantVDCNatPolicyRef(
|
||||
getDnForDNatPolicyRef(tenantName, identifier),
|
||||
getNameForDNatPolicy(tenantName, identifier),
|
||||
tenantName);
|
||||
tenantName,
|
||||
false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ import com.cloud.deploy.DeployDestination;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.DetailVO;
|
||||
import com.cloud.host.Host;
|
||||
|
|
@ -104,6 +105,7 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
|||
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
|
||||
import com.cloud.network.resource.CiscoVnmcResource;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.TrafficType;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
|
|
@ -113,6 +115,7 @@ import com.cloud.resource.ResourceStateAdapter;
|
|||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.resource.UnableDeleteHostException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
|
@ -338,10 +341,31 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
|||
publicGateways.add(vlanVO.getVlanGateway());
|
||||
}
|
||||
|
||||
// due to VNMC limitation of not allowing source NAT ip as the outside ip of firewall,
|
||||
// an additional public ip needs to acquired for assigning as firewall outside ip
|
||||
IpAddress outsideIp = null;
|
||||
try {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
long callerUserId = UserContext.current().getCallerUserId();
|
||||
outsideIp = _networkMgr.allocateIp(owner, false, caller, callerUserId, zone);
|
||||
} catch (ResourceAllocationException e) {
|
||||
s_logger.error("Unable to allocate additional public Ip address. Exception details " + e);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
outsideIp = _networkMgr.associateIPToGuestNetwork(outsideIp.getId(), network.getId(), true);
|
||||
} catch (ResourceAllocationException e) {
|
||||
s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details " + e);
|
||||
return false;
|
||||
}
|
||||
|
||||
// create logical edge firewall in VNMC
|
||||
String gatewayNetmask = NetUtils.getCidrNetmask(network.getCidr());
|
||||
// due to ASA limitation of allowing single subnet to be assigned to firewall interfaces,
|
||||
// all public ip addresses must be from same subnet, this essentially means single public subnet in zone
|
||||
if (!createLogicalEdgeFirewall(vlanId, network.getGateway(), gatewayNetmask,
|
||||
sourceNatIp.getAddress().addr(), sourceNatIp.getNetmask(), publicGateways, ciscoVnmcHost.getId())) {
|
||||
outsideIp.getAddress().addr(), sourceNatIp.getNetmask(), publicGateways, ciscoVnmcHost.getId())) {
|
||||
s_logger.error("Failed to create logical edge firewall in Cisco VNMC device for network " + network.getName());
|
||||
return false;
|
||||
}
|
||||
|
|
@ -356,10 +380,10 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
|||
}
|
||||
|
||||
// configure source NAT
|
||||
//if (!configureSourceNat(vlanId, network.getCidr(), sourceNatIp, ciscoVnmcHost.getId())) {
|
||||
// s_logger.error("Failed to configure source NAT in Cisco VNMC device for network " + network.getName());
|
||||
// return false;
|
||||
//}
|
||||
if (!configureSourceNat(vlanId, network.getCidr(), sourceNatIp, ciscoVnmcHost.getId())) {
|
||||
s_logger.error("Failed to configure source NAT in Cisco VNMC device for network " + network.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// associate Asa 1000v instance with logical edge firewall
|
||||
if (!associateAsaWithLogicalEdgeFirewall(vlanId, assignedAsa.getManagementIp(), ciscoVnmcHost.getId())) {
|
||||
|
|
@ -654,8 +678,12 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
|||
|
||||
List<FirewallRuleTO> rulesTO = new ArrayList<FirewallRuleTO>();
|
||||
for (FirewallRule rule : rules) {
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
FirewallRuleTO ruleTO = new FirewallRuleTO(rule, null, sourceIp.getAddress().addr(), rule.getPurpose(), rule.getTrafficType());
|
||||
String address = "0.0.0.0";
|
||||
if (rule.getTrafficType() == TrafficType.Ingress) {
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
address = sourceIp.getAddress().addr();
|
||||
}
|
||||
FirewallRuleTO ruleTO = new FirewallRuleTO(rule, null, address, rule.getPurpose(), rule.getTrafficType());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -368,29 +368,29 @@ public class CiscoVnmcResource implements ServerResource {
|
|||
if (!_connection.createTenantVDCIngressAclRule(tenant,
|
||||
Long.toString(rule.getId()), policyIdentifier,
|
||||
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1],
|
||||
Integer.toString(rule.getSrcPortRange()[0]), Integer.toString(rule.getSrcPortRange()[1]), publicIp)) {
|
||||
Integer.toString(rule.getSrcPortRange()[0]), Integer.toString(rule.getSrcPortRange()[1]))) {
|
||||
throw new Exception("Failed to create ACL ingress rule in VNMC for guest network with vlan " + vlanId);
|
||||
}
|
||||
} else {
|
||||
if (!_connection.createTenantVDCIngressAclRule(tenant,
|
||||
Long.toString(rule.getId()), policyIdentifier,
|
||||
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1], publicIp)) {
|
||||
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1])) {
|
||||
throw new Exception("Failed to create ACL ingress rule in VNMC for guest network with vlan " + vlanId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!rule.getProtocol().equalsIgnoreCase("icmp")) {
|
||||
if (rule.getProtocol().equalsIgnoreCase("tcp") || rule.getProtocol().equalsIgnoreCase("udp")) {
|
||||
if (!_connection.createTenantVDCEgressAclRule(tenant,
|
||||
Long.toString(rule.getId()), policyIdentifier,
|
||||
rule.getProtocol().toUpperCase(),
|
||||
Integer.toString(rule.getSrcPortRange()[0]), Integer.toString(rule.getSrcPortRange()[1]), publicIp,
|
||||
externalIpRange[0], externalIpRange[1])) {
|
||||
externalIpRange[0], externalIpRange[1],
|
||||
Integer.toString(rule.getSrcPortRange()[0]), Integer.toString(rule.getSrcPortRange()[1]))) {
|
||||
throw new Exception("Failed to create ACL egress rule in VNMC for guest network with vlan " + vlanId);
|
||||
}
|
||||
} else {
|
||||
if (!_connection.createTenantVDCEgressAclRule(tenant,
|
||||
Long.toString(rule.getId()), policyIdentifier,
|
||||
rule.getProtocol().toUpperCase(), publicIp, externalIpRange[0], externalIpRange[1])) {
|
||||
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1])) {
|
||||
throw new Exception("Failed to create ACL egress rule in VNMC for guest network with vlan " + vlanId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,11 +171,11 @@ public class CiscoVnmcResourceTest {
|
|||
when(_connection.createTenantVDCIngressAclRule(
|
||||
anyString(), anyString(), anyString(),
|
||||
anyString(), anyString(), anyString(),
|
||||
anyString(), anyString(), anyString())).thenReturn(true);
|
||||
anyString(), anyString())).thenReturn(true);
|
||||
when(_connection.createTenantVDCEgressAclRule(
|
||||
anyString(), anyString(), anyString(),
|
||||
anyString(), anyString(), anyString(),
|
||||
anyString(), anyString(), anyString())).thenReturn(true);
|
||||
anyString(), anyString())).thenReturn(true);
|
||||
when(_connection.associateAclPolicySet(anyString())).thenReturn(true);
|
||||
|
||||
Answer answer = _resource.executeRequest(cmd);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.cloud.deploy.DeployDestination;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.UnsupportedServiceException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
|
|
@ -46,6 +47,7 @@ import com.cloud.network.PublicIpAddress;
|
|||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.lb.ElasticLoadBalancerManager;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.rules.LoadBalancerContainer;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
|
|
@ -68,12 +70,25 @@ public class ElasticLoadBalancerElement extends AdapterBase implements LoadBalan
|
|||
boolean _enabled;
|
||||
TrafficType _frontEndTrafficType = TrafficType.Guest;
|
||||
|
||||
private boolean canHandle(Network network) {
|
||||
private boolean canHandle(Network network, List<LoadBalancingRule> rules) {
|
||||
if (network.getGuestType() != Network.GuestType.Shared|| network.getTrafficType() != TrafficType.Guest) {
|
||||
s_logger.debug("Not handling network with type " + network.getGuestType() + " and traffic type " + network.getTrafficType());
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
|
||||
if (!lbCaps.isEmpty()) {
|
||||
String schemeCaps = lbCaps.get(Capability.LbSchemes);
|
||||
if (schemeCaps != null) {
|
||||
for (LoadBalancingRule rule : rules) {
|
||||
if (!schemeCaps.contains(rule.getScheme().toString())) {
|
||||
s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported by the provider " + this.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +109,7 @@ public class ElasticLoadBalancerElement extends AdapterBase implements LoadBalan
|
|||
lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn,source");
|
||||
lbCapabilities.put(Capability.SupportedLBIsolation, "shared");
|
||||
lbCapabilities.put(Capability.SupportedProtocols, "tcp, udp");
|
||||
lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Public.toString());
|
||||
|
||||
capabilities.put(Service.Lb, lbCapabilities);
|
||||
return capabilities;
|
||||
|
|
@ -139,10 +155,10 @@ public class ElasticLoadBalancerElement extends AdapterBase implements LoadBalan
|
|||
|
||||
@Override
|
||||
public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
|
||||
if (!canHandle(network)) {
|
||||
if (!canHandle(network, rules)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return _lbMgr.applyLoadBalancerRules(network, rules);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ package com.cloud.network.lb;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLoadBalancerRuleCmd;
|
||||
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ public interface ElasticLoadBalancerManager {
|
|||
public static final int DEFAULT_ELB_VM_CPU_MHZ = 256; // 500 MHz
|
||||
|
||||
public boolean applyLoadBalancerRules(Network network,
|
||||
List<? extends FirewallRule> rules)
|
||||
List<LoadBalancingRule> rules)
|
||||
throws ResourceUnavailableException;
|
||||
|
||||
public LoadBalancer handleCreateLoadBalancerRule(CreateLoadBalancerRuleCmd lb, Account caller, long networkId) throws InsufficientAddressCapacityException, NetworkRuleConflictException;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ import com.cloud.network.router.VirtualRouter.RedundantState;
|
|||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
|
|
@ -118,7 +117,6 @@ import com.cloud.user.UserContext;
|
|||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
|
|
@ -126,6 +124,7 @@ import com.cloud.utils.db.SearchBuilder;
|
|||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
|
|
@ -297,8 +296,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
String protocol = rule.getProtocol();
|
||||
String algorithm = rule.getAlgorithm();
|
||||
|
||||
String elbIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress()
|
||||
.addr();
|
||||
String elbIp = rule.getSourceIp().addr();
|
||||
int srcPort = rule.getSourcePortStart();
|
||||
String uuid = rule.getUuid();
|
||||
List<LbDestination> destinations = rule.getDestinations();
|
||||
|
|
@ -331,8 +329,10 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
return sendCommandsToRouter(elbVm, cmds);
|
||||
}
|
||||
|
||||
protected DomainRouterVO findElbVmForLb(FirewallRule lb) {//TODO: use a table to lookup
|
||||
ElasticLbVmMapVO map = _elbVmMapDao.findOneByIp(lb.getSourceIpAddressId());
|
||||
protected DomainRouterVO findElbVmForLb(LoadBalancingRule lb) {//TODO: use a table to lookup
|
||||
Network ntwk = _networkModel.getNetwork(lb.getNetworkId());
|
||||
long sourceIpId = _networkModel.getPublicIpAddress(lb.getSourceIp().addr(), ntwk.getDataCenterId()).getId();
|
||||
ElasticLbVmMapVO map = _elbVmMapDao.findOneByIp(sourceIpId);
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -342,15 +342,11 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
|
||||
@Override
|
||||
public boolean applyLoadBalancerRules(Network network,
|
||||
List<? extends FirewallRule> rules)
|
||||
List<LoadBalancingRule> rules)
|
||||
throws ResourceUnavailableException {
|
||||
if (rules == null || rules.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (rules.get(0).getPurpose() != Purpose.LoadBalancing) {
|
||||
s_logger.warn("ELB: Not handling non-LB firewall rules");
|
||||
return false;
|
||||
}
|
||||
|
||||
DomainRouterVO elbVm = findElbVmForLb(rules.get(0));
|
||||
|
||||
|
|
@ -363,14 +359,16 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
|
||||
if (elbVm.getState() == State.Running) {
|
||||
//resend all rules for the public ip
|
||||
List<LoadBalancerVO> lbs = _lbDao.listByIpAddress(rules.get(0).getSourceIpAddressId());
|
||||
long sourceIpId = _networkModel.getPublicIpAddress(rules.get(0).getSourceIp().addr(), network.getDataCenterId()).getId();
|
||||
List<LoadBalancerVO> lbs = _lbDao.listByIpAddress(sourceIpId);
|
||||
List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
|
||||
for (LoadBalancerVO lb : lbs) {
|
||||
List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
|
||||
List<LbStickinessPolicy> policyList = _lbMgr.getStickinessPolicies(lb.getId());
|
||||
List<LbHealthCheckPolicy> hcPolicyList = _lbMgr.getHealthCheckPolicies(lb.getId());
|
||||
Ip sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
|
||||
LoadBalancingRule loadBalancing = new LoadBalancingRule(
|
||||
lb, dstList, policyList, hcPolicyList);
|
||||
lb, dstList, policyList, hcPolicyList, sourceIp);
|
||||
lbRules.add(loadBalancing);
|
||||
}
|
||||
return applyLBRules(elbVm, lbRules, network.getId());
|
||||
|
|
@ -656,7 +654,10 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
LoadBalancer result = null;
|
||||
try {
|
||||
lb.setSourceIpAddressId(ipId);
|
||||
result = _lbMgr.createLoadBalancer(lb, false);
|
||||
|
||||
result = _lbMgr.createPublicLoadBalancer(lb.getXid(), lb.getName(), lb.getDescription(),
|
||||
lb.getSourcePortStart(), lb.getDefaultPortStart(), ipId.longValue(), lb.getProtocol(),
|
||||
lb.getAlgorithm(), false, UserContext.current());
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
s_logger.warn("Failed to create LB rule, not continuing with ELB deployment");
|
||||
if (newIp) {
|
||||
|
|
@ -943,7 +944,8 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
|
||||
List<LbStickinessPolicy> policyList = _lbMgr.getStickinessPolicies(lb.getId());
|
||||
List<LbHealthCheckPolicy> hcPolicyList = _lbMgr.getHealthCheckPolicies(lb.getId());
|
||||
LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList);
|
||||
Ip sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
|
||||
LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList, sourceIp);
|
||||
lbRules.add(loadBalancing);
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue