merge master

This commit is contained in:
Nitin Mehta 2013-05-11 15:28:43 +05:30
parent 836a3f1252
commit c11dbad9c9
1283 changed files with 28184 additions and 12953 deletions

6
.gitignore vendored
View File

@ -18,10 +18,7 @@
build/replace.properties
build/build.number
bin/
cloudstack-proprietary/
premium/
.lock-wscript
artifacts/
.waf-*
waf-*
target/
@ -37,7 +34,7 @@ cloud-*.tar.bz2
*.egg-info/
*.prefs
build.number
api.log.*.gz
*.log.*.gz
cloud.log.*.*
unittest
deps/cloud.userlibraries
@ -59,6 +56,7 @@ tools/cli/build/
*.iso
*.tar.gz
*.tgz
.*
target-eclipse
awsapi/modules/*
!.gitignore

View File

@ -78,7 +78,7 @@ domr.scripts.dir=scripts/network/domr/kvm
# a sensible default will be selected based on the network.bridge.type but can
# be overridden here.
# native = com.cloud.hypervisor.kvm.resource.BridgeVifDriver
# openvswitch = com.cloud.hypervisor.kvm.resource.OvsBridgeDriver
# openvswitch = com.cloud.hypervisor.kvm.resource.OvsVifDriver
#libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.BridgeVifDriver
# set the hypervisor type, values are: kvm, lxc

View File

@ -14,18 +14,13 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.vm;
package com.cloud.agent.api.storage;
import com.cloud.storage.Storage;
import com.cloud.agent.api.Answer;
public class CreateVolumeOVAAnswer extends Answer {
public CreateVolumeOVAAnswer(CreateVolumeOVACommand cmd, boolean result, String details) {
super(cmd, result, details);
}
/**
* VirtualDisk describes the disks that are plugged into
* the virtual machine.
*
*/
public class VirtualDisk {
public Storage.ImageFormat format;
public String url;
public boolean bootable;
public long size;
}

View File

@ -0,0 +1,60 @@
// 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.agent.api.storage;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.storage.StoragePool;
public class CreateVolumeOVACommand extends Command {
String secUrl;
String volPath;
String volName;
StorageFilerTO pool;
public CreateVolumeOVACommand() {
}
public CreateVolumeOVACommand(String secUrl, String volPath, String volName, StoragePool pool, int wait) {
this.secUrl = secUrl;
this.volPath = volPath;
this.volName = volName;
this.pool = new StorageFilerTO(pool);
setWait(wait);
}
@Override
public boolean executeInSequence() {
return true;
}
public String getVolPath() {
return this.volPath;
}
public String getVolName() {
return this.volName;
}
public String getSecondaryStorageUrl() {
return this.secUrl;
}
public StorageFilerTO getPool() {
return pool;
}
}

View File

@ -14,10 +14,13 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.maint;
package com.cloud.agent.api.storage;
import com.cloud.utils.mgmt.ManagementBean;
import com.cloud.agent.api.Answer;
public class PrepareOVAPackingAnswer extends Answer {
public PrepareOVAPackingAnswer(PrepareOVAPackingCommand cmd, boolean result, String details) {
super(cmd, result, details);
}
public interface UpgradeManagerMBean extends ManagementBean {
public String deployNewAgent(String location);
}

View File

@ -14,33 +14,35 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.storage.snapshot;
package com.cloud.agent.api.storage;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.agent.api.Command;
import java.util.Date;
public class PrepareOVAPackingCommand extends Command {
private String templatePath;
private String secUrl;
public interface SnapshotSchedule extends InternalIdentity, Identity {
public PrepareOVAPackingCommand() {
}
Long getVolumeId();
public PrepareOVAPackingCommand(String secUrl, String templatePath) {
this.secUrl = secUrl;
this.templatePath = templatePath;
}
Long getPolicyId();
@Override
public boolean executeInSequence() {
return true;
}
void setPolicyId(long policyId);
public String getTemplatePath() {
return this.templatePath;
}
/**
* @return the scheduledTimestamp
*/
Date getScheduledTimestamp();
public String getSecondaryStorageUrl() {
return this.secUrl;
}
void setScheduledTimestamp(Date scheduledTimestamp);
Long getAsyncJobId();
void setAsyncJobId(Long asyncJobId);
Long getSnapshotId();
void setSnapshotId(Long snapshotId);
}

View File

@ -50,7 +50,10 @@ public interface AsyncJob extends Identity, InternalIdentity {
AutoScaleVmProfile,
AutoScaleVmGroup,
GlobalLoadBalancerRule,
AffinityGroup
LoadBalancerRule,
AffinityGroup,
InternalLbVm,
DedicatedGuestVlanRange
}
long getUserId();

View File

@ -20,6 +20,11 @@ import java.util.List;
import javax.naming.NamingException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.ResourceAllocationException;
import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
@ -46,10 +51,6 @@ import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
import com.cloud.dc.Vlan;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
@ -65,7 +66,7 @@ public interface ConfigurationService {
* - the command wrapping name and value parameters
* @return updated configuration object if successful
*/
Configuration updateConfiguration(UpdateCfgCmd cmd);
Configuration updateConfiguration(UpdateCfgCmd cmd) throws InvalidParameterValueException;
/**
* Create a service offering through the API
@ -250,7 +251,7 @@ public interface ConfigurationService {
NetworkOffering getNetworkOffering(long id);
Integer getNetworkOfferingNetworkRate(long networkOfferingId);
Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId);
Account getVlanAccount(long vlanId);
@ -262,7 +263,7 @@ public interface ConfigurationService {
Long getDefaultPageSize();
Integer getServiceOfferingNetworkRate(long serviceOfferingId);
Integer getServiceOfferingNetworkRate(long serviceOfferingId, Long dataCenterId);
DiskOffering getDiskOffering(long diskOfferingId);

View File

@ -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
@ -401,6 +411,14 @@ public class EventTypes {
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
@ -701,6 +719,9 @@ public class EventTypes {
entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_UPDATE, AutoScaleVmGroup.class.getName());
entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_ENABLE, AutoScaleVmGroup.class.getName());
entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_DISABLE, AutoScaleVmGroup.class.getName());
entityEventDetails.put(EVENT_GUEST_VLAN_RANGE_DEDICATE, GuestVlan.class.getName());
entityEventDetails.put(EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, GuestVlan.class.getName());
}
public static String getEntityForEvent (String eventName) {

View File

@ -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.network;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
public interface GuestVlan extends InternalIdentity, Identity {
public long getId();
public long getAccountId();
public String getGuestVlanRange();
public long getPhysicalNetworkId();
}

View File

@ -81,4 +81,7 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity
Long getVpcId();
String getVmIp();
Long getNetworkId();
}

View File

@ -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;

View File

@ -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;
@ -181,7 +182,7 @@ public interface NetworkModel {
/**
* @return
*/
String getDefaultNetworkDomain();
String getDefaultNetworkDomain(long zoneId);
/**
* @param ntwkOffId
@ -263,4 +264,12 @@ public interface NetworkModel {
boolean isProviderEnabledInZone(long zoneId, String provider);
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();
}

View File

@ -18,6 +18,8 @@ package com.cloud.network;
import java.util.List;
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
import org.apache.cloudstack.api.command.user.network.*;
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
@ -27,6 +29,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.GuestVlan;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.TrafficType;
import com.cloud.user.Account;
@ -112,6 +115,12 @@ public interface NetworkService {
boolean deletePhysicalNetworkTrafficType(Long id);
GuestVlan dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd);
Pair<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd);
boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId);
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId);
@ -136,6 +145,7 @@ public interface NetworkService {
ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException;
/**
*
* @param networkName
* @param displayText
* @param physicalNetworkId
@ -146,17 +156,18 @@ public interface NetworkService {
* @param netmask
* @param networkOwnerId
* @param vpcId TODO
* @param sourceNat
* @return
* @throws InsufficientCapacityException
* @throws ConcurrentOperationException
* @throws ResourceAllocationException
*/
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId)
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
/* Requests an IP address for the guest nic */
String allocateSecondaryGuestIP(Account account, long zoneId, Long nicId,
NicSecondaryIp allocateSecondaryGuestIP(Account account, long zoneId, Long nicId,
Long networkId, String ipaddress) throws InsufficientAddressCapacityException;
boolean releaseSecondaryIpFromNic(long ipAddressId);

View File

@ -64,4 +64,6 @@ public interface VirtualNetworkApplianceService {
VirtualRouter destroyRouter(long routerId, Account caller, Long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException;
VirtualRouter findRouter(long routerId);
}

View File

@ -23,7 +23,8 @@ public interface VirtualRouterProvider extends InternalIdentity, Identity {
public enum VirtualRouterProviderType {
VirtualRouter,
ElasticLoadBalancerVm,
VPCVirtualRouter
VPCVirtualRouter,
InternalLbVm
}
public VirtualRouterProviderType getType();

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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();
}

View File

@ -14,17 +14,20 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.storage;
package com.cloud.network.rules;
public interface SecondaryStorage {
public interface LoadBalancerContainer {
String getBackupPath();
public enum Scheme {
Public, Internal;
}
String getTemplatePath();
String getName();
String getIsoPath();
String getDescription();
void createTemplate();
String getAlgorithm();
Scheme getScheme();
void destroyTemplate();
}

View File

@ -67,7 +67,7 @@ public interface RulesService {
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
PortForwardingRule getPortForwardigRule(long ruleId);

View File

@ -31,6 +31,8 @@ public interface SecurityGroupRules extends InternalIdentity {
Long getRuleId();
String getRuleUuid();
int getStartPort();
int getEndPort();

View File

@ -44,5 +44,6 @@ public interface PrivateIp {
String getMacAddress();
long getNetworkId();
boolean getSourceNat();
}

View File

@ -77,4 +77,8 @@ public interface VpcGateway extends Identity, ControlledEntity, InternalIdentity
* @return
*/
State getState();
/**
* @return
*/
boolean getSourceNat();
}

View File

@ -26,6 +26,7 @@ public interface VpcOffering extends InternalIdentity, Identity {
}
public static final String defaultVPCOfferingName = "Default VPC offering";
public static final String defaultVPCNSOfferingName = "Default VPC offering with Netscaler";
/**
*

View File

@ -163,6 +163,7 @@ public interface VpcService {
/**
* Persists VPC private gateway in the Database.
*
*
* @param vpcId TODO
* @param physicalNetworkId
* @param vlan
@ -170,13 +171,14 @@ public interface VpcService {
* @param gateway
* @param netmask
* @param gatewayOwnerId
* @param isSourceNat
* @return
* @throws InsufficientCapacityException
* @throws ConcurrentOperationException
* @throws ResourceAllocationException
*/
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress,
String gateway, String netmask, long gatewayOwnerId) throws ResourceAllocationException,
String gateway, String netmask, long gatewayOwnerId, Boolean isSourceNat) throws ResourceAllocationException,
ConcurrentOperationException, InsufficientCapacityException;
/**

View File

@ -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;
@ -39,6 +41,11 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
Enabled
}
public enum Detail {
InternalLbProvider,
PublicLbProvider
}
public final static String SystemPublicNetwork = "System-Public-Network";
public final static String SystemControlNetwork = "System-Control-Network";
public final static String SystemManagementNetwork = "System-Management-Network";
@ -117,4 +124,8 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
boolean getIsPersistent();
boolean getInternalLb();
boolean getPublicLb();
}

View File

@ -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,

View File

@ -19,8 +19,6 @@ package com.cloud.storage;
import java.net.URI;
import java.util.Map;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import com.cloud.exception.DiscoveryException;
import com.cloud.utils.component.Adapter;
@ -29,7 +27,7 @@ import com.cloud.utils.component.Adapter;
*/
public interface StoragePoolDiscoverer extends Adapter {
Map<StoragePoolVO, Map<String, String>> find(long dcId, Long podId, URI uri, Map<String, String> details) throws DiscoveryException;
Map<? extends StoragePool, Map<String, String>> find(long dcId, Long podId, URI uri, Map<String, String> details) throws DiscoveryException;
Map<StoragePoolVO, Map<String, String>> find(long dcId, Long podId, URI uri, Map<String, String> details, String username, String password) throws DiscoveryException;
Map<? extends StoragePool, Map<String, String>> find(long dcId, Long podId, URI uri, Map<String, String> details, String username, String password) throws DiscoveryException;
}

View File

@ -16,12 +16,12 @@
// under the License.
package com.cloud.storage.snapshot;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
public interface SnapshotSchedule {
long getId();
String getUuid();
public interface SnapshotSchedule extends InternalIdentity, Identity {
Long getVolumeId();
@ -38,10 +38,9 @@ public interface SnapshotSchedule {
Long getAsyncJobId();
void setAsyncJobId(long asyncJobId);
void setAsyncJobId(Long asyncJobId);
Long getSnapshotId();
void setSnapshotId(Long snapshotId);
}

View File

@ -459,8 +459,8 @@ public interface UserVmService {
VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool);
UserVm restoreVM(RestoreVMCmd cmd);
UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException;
UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
boolean upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
}

View File

@ -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;

View File

@ -90,6 +90,7 @@ public class ApiConstants {
public static final String GSLB_SERVICE_TYPE = "gslbservicetype";
public static final String GSLB_STICKY_SESSION_METHOD = "gslbstickysessionmethodname";
public static final String GUEST_CIDR_ADDRESS = "guestcidraddress";
public static final String GUEST_VLAN_RANGE = "guestvlanrange";
public static final String HA_ENABLE = "haenable";
public static final String HOST_ID = "hostid";
public static final String HOST_NAME = "hostname";
@ -226,6 +227,7 @@ public class ApiConstants {
public static final String VIRTUAL_MACHINE_ID = "virtualmachineid";
public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids";
public static final String VLAN = "vlan";
public static final String VLAN_RANGE = "vlanrange";
public static final String REMOVE_VLAN="removevlan";
public static final String VLAN_ID = "vlanid";
public static final String VM_AVAILABLE = "vmavailable";
@ -483,6 +485,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";

View File

@ -29,6 +29,9 @@ import javax.inject.Inject;
import org.apache.cloudstack.affinity.AffinityGroupService;
import com.cloud.server.ResourceMetaDataService;
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;
@ -43,6 +46,7 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.NetworkModel;
import com.cloud.network.NetworkService;
import com.cloud.network.NetworkUsageService;
import com.cloud.network.StorageNetworkService;
@ -140,7 +144,12 @@ 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;

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api;
import java.text.DecimalFormat;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@ -26,6 +27,7 @@ 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;
@ -43,12 +45,17 @@ 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;
import org.apache.cloudstack.api.response.LBStickinessResponse;
import org.apache.cloudstack.api.response.LDAPConfigResponse;
@ -82,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;
@ -101,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;
@ -117,9 +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.as.*;
import com.cloud.network.Networks.IsolationType;
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;
@ -142,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;
@ -150,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);
@ -197,6 +228,8 @@ public interface ResponseGenerator {
IPAddressResponse createIPAddressResponse(IpAddress ipAddress);
GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan result);
GlobalLoadBalancerResponse createGlobalLoadBalancerResponse(GlobalLoadBalancerRule globalLoadBalancerRule);
LoadBalancerResponse createLoadBalancerResponse(LoadBalancer loadBalancer);
@ -389,11 +422,16 @@ public interface ResponseGenerator {
TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor);
VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot);
NicSecondaryIpResponse createSecondaryIPToNicResponse(String ip,
Long nicId, Long networkId);
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);
}

View File

@ -70,6 +70,9 @@ public class ListClustersCmd extends BaseListCmd {
@Parameter(name=ApiConstants.MANAGED_STATE, type=CommandType.STRING, description="whether this cluster is managed by cloudstack")
private String managedState;
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
private String zoneType;
@Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the clusters")
private Boolean showCapacities;
@ -114,6 +117,9 @@ public class ListClustersCmd extends BaseListCmd {
this.managedState = managedstate;
}
public String getZoneType() {
return zoneType;
}
public Boolean getShowCapacities() {
return showCapacities;

View File

@ -45,11 +45,17 @@ public class ListCfgsByCmd extends BaseListCmd {
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists configuration by name")
private String configName;
@Parameter(name=ApiConstants.SCOPE, type = CommandType.STRING, description = "scope(zone/cluster/pool/account) of the parameter that needs to be updated")
private String scope;
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class, description="the ID of the Zone to update the parameter value for corresponding zone")
private Long zone_id;
@Parameter(name=ApiConstants.ID, type = CommandType.UUID, entityType = {ZoneResponse.class, ClusterResponse.class, StoragePoolResponse.class, AccountResponse.class}, description = "corresponding ID of the scope")
private Long id;
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType=ClusterResponse.class, description="the ID of the Cluster to update the parameter value for corresponding cluster")
private Long cluster_id;
@Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.UUID, entityType=StoragePoolResponse.class, description="the ID of the Storage pool to update the parameter value for corresponding storage pool")
private Long storagepool_id;
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.UUID, entityType=AccountResponse.class, description="the ID of the Account to update the parameter value for corresponding account")
private Long account_id;
// ///////////////////////////////////////////////////
@ -64,14 +70,21 @@ public class ListCfgsByCmd extends BaseListCmd {
return configName;
}
public String getScope() {
return scope;
public Long getZoneId() {
return zone_id;
}
public Long getId() {
return id;
public Long getClusterId() {
return cluster_id;
}
public Long getStoragepoolId() {
return storagepool_id;
}
public Long getAccountId() {
return account_id;
}
@Override
public Long getPageSizeVal() {
@ -100,10 +113,17 @@ public class ListCfgsByCmd extends BaseListCmd {
for (Configuration cfg : result.first()) {
ConfigurationResponse cfgResponse = _responseGenerator.createConfigurationResponse(cfg);
cfgResponse.setObjectName("configuration");
if (scope != null) {
cfgResponse.setScope(scope);
} else {
cfgResponse.setScope("global");
if(getZoneId() != null) {
cfgResponse.setScope("zone");
}
if(getClusterId() != null) {
cfgResponse.setScope("cluster");
}
if(getStoragepoolId() != null) {
cfgResponse.setScope("storagepool");
}
if(getAccountId() != null) {
cfgResponse.setScope("account");
}
configResponses.add(cfgResponse);
}

View File

@ -43,11 +43,17 @@ public class UpdateCfgCmd extends BaseCmd {
@Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, description="the value of the configuration", length=4095)
private String value;
@Parameter(name=ApiConstants.SCOPE, type = CommandType.STRING, description = "scope(zone/cluster/pool/account) of the parameter that needs to be updated")
private String scope;
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class, description="the ID of the Zone to update the parameter value for corresponding zone")
private Long zone_id;
@Parameter(name=ApiConstants.ID, type = CommandType.UUID, entityType = {ZoneResponse.class, ClusterResponse.class, StoragePoolResponse.class, AccountResponse.class}, description = "corresponding ID of the scope")
private Long id;
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType=ClusterResponse.class, description="the ID of the Cluster to update the parameter value for corresponding cluster")
private Long cluster_id;
@Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.UUID, entityType=StoragePoolResponse.class, description="the ID of the Storage pool to update the parameter value for corresponding storage pool")
private Long storagepool_id;
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.UUID, entityType=AccountResponse.class, description="the ID of the Account to update the parameter value for corresponding account")
private Long account_id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -61,12 +67,20 @@ public class UpdateCfgCmd extends BaseCmd {
return value;
}
public String getScope() {
return scope;
public Long getZoneId() {
return zone_id;
}
public Long getId() {
return id;
public Long getClusterId() {
return cluster_id;
}
public Long getStoragepoolId() {
return storagepool_id;
}
public Long getAccountId() {
return account_id;
}
/////////////////////////////////////////////////////
@ -89,12 +103,19 @@ public class UpdateCfgCmd extends BaseCmd {
if (cfg != null) {
ConfigurationResponse response = _responseGenerator.createConfigurationResponse(cfg);
response.setResponseName(getCommandName());
if (scope != null) {
response.setScope(scope);
response.setValue(value);
} else {
response.setScope("global");
if(getZoneId() != null) {
response.setScope("zone");
}
if(getClusterId() != null) {
response.setScope("cluster");
}
if(getStoragepoolId() != null) {
response.setScope("storagepool");
}
if(getAccountId() != null) {
response.setScope("account");
}
response.setValue(value);
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update config");

View File

@ -75,6 +75,9 @@ public class ListHostsCmd extends BaseListCmd {
description="the Zone ID for the host")
private Long zoneId;
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
private String zoneType;
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType = UserVmResponse.class,
required=false, description="lists hosts in the same cluster as this VM and flag hosts with enough CPU/RAm to host this VM")
private Long virtualMachineId;
@ -124,6 +127,10 @@ public class ListHostsCmd extends BaseListCmd {
return zoneId;
}
public String getZoneType() {
return zoneType;
}
public Long getVirtualMachineId() {
return virtualMachineId;
}

View File

@ -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");
}
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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;
@ -96,6 +95,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 ///////////////////////
/////////////////////////////////////////////////////
@ -216,6 +219,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///////////////////
/////////////////////////////////////////////////////

View File

@ -0,0 +1,118 @@
/*
* 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.network;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.GuestVlan;
import com.cloud.user.Account;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.log4j.Logger;
@APICommand(name = "dedicateGuestVlanRange", description="Dedicates a guest vlan range to an account", responseObject=GuestVlanRangeResponse.class)
public class DedicateGuestVlanRangeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DedicateGuestVlanRangeCmd.class.getName());
private static final String s_name = "dedicateguestvlanrangeresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.VLAN_RANGE, type=CommandType.STRING, required=true,
description="guest vlan range to be dedicated")
private String vlan;
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, required=true,
description="account who will own the VLAN")
private String accountName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
description="project who will own the VLAN")
private Long projectId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
required=true, description="domain ID of the account owning a VLAN")
private Long domainId;
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType = PhysicalNetworkResponse.class,
required=true, description="physical network ID of the vlan")
private Long physicalNetworkId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getVlan() {
return vlan;
}
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
public Long getPhysicalNetworkId() {
return physicalNetworkId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
GuestVlan result = _networkService.dedicateGuestVlanRange(this);
if (result != null) {
GuestVlanRangeResponse response = _responseGenerator.createDedicatedGuestVlanRangeResponse(result);
response.setResponseName(getCommandName());
response.setObjectName("dedicatedguestvlanrange");
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate guest vlan range");
}
}
}

View File

@ -0,0 +1,129 @@
// 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.network;
import com.cloud.network.GuestVlan;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import org.apache.cloudstack.api.*;
import org.apache.cloudstack.api.response.*;
import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
@APICommand(name = "listDedicatedGuestVlanRanges", description="Lists dedicated guest vlan ranges", responseObject=GuestVlanRangeResponse.class)
public class ListDedicatedGuestVlanRangesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDedicatedGuestVlanRangesCmd.class.getName());
private static final String s_name = "listdedicatedguestvlanrangesresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=GuestVlanRangeResponse.class,
description="list dedicated guest vlan ranges by id")
private Long id;
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account with which the guest VLAN range is associated. Must be used with the domainId parameter.")
private String accountName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
description="project who will own the guest VLAN range")
private Long projectId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
description="the domain ID with which the guest VLAN range is associated. If used with the account parameter, returns all guest VLAN ranges for that account in the specified domain.")
private Long domainId;
@Parameter(name=ApiConstants.GUEST_VLAN_RANGE, type=CommandType.STRING, description="the dedicated guest vlan range")
private String guestVlanRange;
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType = PhysicalNetworkResponse.class,
description="physical network id of the guest VLAN range")
private Long physicalNetworkId;
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
description="zone of the guest VLAN range")
private Long zoneId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
public Long getProjectId() {
return projectId;
}
public String getGuestVlanRange() {
return guestVlanRange;
}
public Long getPhysicalNetworkId() {
return physicalNetworkId;
}
public Long getZoneId() {
return zoneId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute(){
Pair<List<? extends GuestVlan>, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this);
ListResponse<GuestVlanRangeResponse> response = new ListResponse<GuestVlanRangeResponse>();
List<GuestVlanRangeResponse> guestVlanResponses = new ArrayList<GuestVlanRangeResponse>();
for (GuestVlan vlan : vlans.first()) {
GuestVlanRangeResponse guestVlanResponse = _responseGenerator.createDedicatedGuestVlanRangeResponse(vlan);
guestVlanResponse.setObjectName("dedicatedguestvlanrange");
guestVlanResponses.add(guestVlanResponse);
}
response.setResponses(guestVlanResponses, vlans.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}

View File

@ -0,0 +1,58 @@
// 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.network;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.IsolationMethodResponse;
import org.apache.cloudstack.api.response.ListResponse;
import com.cloud.network.Networks;
@APICommand(name = "listNetworkIsolationMethods", description="Lists supported methods of network isolation",
responseObject=IsolationMethodResponse.class, since="4.2.0")
public class ListNetworkIsolationMethodsCmd extends BaseListCmd{
private static final String s_name = "listnetworkisolationmethodsresponse";
@Override
public void execute() {
Networks.IsolationType[] methods = _ntwkModel.listNetworkIsolationMethods();
ListResponse<IsolationMethodResponse> response = new ListResponse<IsolationMethodResponse>();
List<IsolationMethodResponse> isolationResponses = new ArrayList<IsolationMethodResponse>();
if (methods != null) {
for (Networks.IsolationType method : methods) {
IsolationMethodResponse isolationMethod = _responseGenerator.createIsolationMethodResponse(method);
isolationResponses.add(isolationMethod);
}
}
response.setResponses(isolationResponses, methods.length);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
@Override
public String getCommandName() {
return s_name;
}
}

View File

@ -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.
package org.apache.cloudstack.api.command.admin.network;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceInUseException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import org.apache.cloudstack.api.*;
import org.apache.cloudstack.api.response.CounterResponse;
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
@APICommand(name = "releaseDedicatedGuestVlanRange", description = "Releases a dedicated guest vlan range to the system", responseObject = SuccessResponse.class)
public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedGuestVlanRangeCmd.class.getName());
private static final String s_name = "releasededicatedguestvlanrangeresponse";
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=GuestVlanRangeResponse.class,
required=true, description="the ID of the dedicated guest vlan range")
private Long id;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
public Long getId() {
return id;
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.DedicatedGuestVlanRange;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public String getEventType() {
return EventTypes.EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE;
}
@Override
public String getEventDescription() {
return "Releasing a dedicated guest vlan range.";
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute(){
UserContext.current().setEventDetails("Dedicated guest vlan range Id: " + id);
boolean result = _networkService.releaseDedicatedGuestVlanRange(getId());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release dedicated guest vlan range");
}
}
}

View File

@ -55,6 +55,9 @@ public class ListPodsByCmd extends BaseListCmd {
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="list pods by allocation state")
private String allocationState;
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
private String zoneType;
@Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the pods")
private Boolean showCapacities;
@ -78,6 +81,10 @@ public class ListPodsByCmd extends BaseListCmd {
return allocationState;
}
public String getZoneType() {
return zoneType;
}
public Boolean getShowCapacities() {
return showCapacities;
}

View File

@ -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;
@ -53,6 +54,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());

View File

@ -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 {
@ -64,6 +65,9 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
description="the Zone ID of the router")
private Long zoneId;
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
private String zoneType;
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType=NetworkResponse.class,
description="list by network id")
private Long networkId;
@ -103,6 +107,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
return zoneId;
}
public String getZoneType() {
return zoneType;
}
public Long getNetworkId() {
return networkId;
}
@ -115,6 +123,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
return forVpc;
}
public String getRole() {
return Role.VIRTUAL_ROUTER.toString();
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -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());

View File

@ -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());

View File

@ -74,6 +74,9 @@ public class ListSystemVMsCmd extends BaseListCmd {
description="the storage ID where vm's volumes belong to", since="3.0.1")
private Long storageId;
@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 ///////////////////////
/////////////////////////////////////////////////////
@ -110,6 +113,10 @@ public class ListSystemVMsCmd extends BaseListCmd {
return storageId;
}
public String getZoneType() {
return zoneType;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -69,6 +69,11 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
required=true, description="the VPC network belongs to")
private Long vpcId;
@Parameter(name=ApiConstants.SOURCE_NAT_SUPPORTED, type=CommandType.BOOLEAN, required=false,
description="source NAT supported value. Default value false. If 'true' source NAT is enabled on the private gateway" +
" 'false': sourcenat is not supported")
private Boolean isSourceNat;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -97,6 +102,13 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
return vpcId;
}
public Boolean getIsSourceNat () {
if (isSourceNat == null) {
return false;
}
return true;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -111,7 +123,7 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
PrivateGateway result = null;
try {
result = _vpcService.createVpcPrivateGateway(getVpcId(), getPhysicalNetworkId(),
getVlan(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId());
getVlan(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId(), getIsSourceNat());
} catch (InsufficientCapacityException ex){
s_logger.info(ex);
s_logger.trace(ex);

View File

@ -78,6 +78,9 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
description="the ID of the zone")
private Long zoneId;
@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 ///////////////////////
/////////////////////////////////////////////////////
@ -115,6 +118,10 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
return zoneId;
}
public String getZoneType() {
return zoneType;
}
public boolean listInReadyState() {
Account account = UserContext.current().getCaller();
// It is account specific if account is admin type and domainId and accountName are not null

View File

@ -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());
}
}
}

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -120,7 +120,7 @@ public class EnableStaticNatCmd extends BaseCmd{
@Override
public void execute() throws ResourceUnavailableException{
try {
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), false, getVmSecondaryIp());
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), getVmSecondaryIp());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);

View File

@ -48,6 +48,9 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd {
description="the Zone ID of the network")
private Long zoneId;
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
private String zoneType;
@Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the type of the network. Supported values are: Isolated and Shared")
private String guestIpType;
@ -96,6 +99,10 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd {
return zoneId;
}
public String getZoneType() {
return zoneType;
}
public String getGuestIpType() {
return guestIpType;
}

View File

@ -163,6 +163,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
@Override
public void execute() {
s_logger.info("VOLSS: createSnapshotCmd starts:" + System.currentTimeMillis());
UserContext.current().setEventDetails("Volume Id: "+getVolumeId());
Snapshot snapshot = _snapshotService.createSnapshot(getVolumeId(), getPolicyId(), getEntityId(), _accountService.getAccount(getEntityOwnerId()));
if (snapshot != null) {
@ -172,6 +173,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot for volume " + volumeId);
}
s_logger.info("VOLSS: backupSnapshotCmd finishes:" + System.currentTimeMillis());
}

View File

@ -59,6 +59,9 @@ public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd {
description="the ID of the disk volume")
private Long volumeId;
@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 ///////////////////////
/////////////////////////////////////////////////////
@ -83,6 +86,10 @@ public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd {
return volumeId;
}
public String getZoneType() {
return zoneType;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -68,6 +68,10 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
description="list templates by zoneId")
private Long zoneId;
@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 ///////////////////////
/////////////////////////////////////////////////////
@ -92,6 +96,10 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
return zoneId;
}
public String getZoneType() {
return zoneType;
}
public boolean listInReadyState() {
Account account = UserContext.current().getCaller();

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.user.vm;
import com.cloud.vm.NicSecondaryIp;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -146,6 +147,7 @@ public class AddIpToVmNicCmd extends BaseAsyncCmd {
UserContext.current().setEventDetails("Nic Id: " + getNicId() );
String ip;
NicSecondaryIp result;
String secondaryIp = null;
if ((ip = getIpaddress()) != null) {
if (!NetUtils.isValidIp(ip)) {
@ -154,12 +156,13 @@ public class AddIpToVmNicCmd extends BaseAsyncCmd {
}
try {
secondaryIp = _networkService.allocateSecondaryGuestIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNicId(), getNetworkId(), getIpaddress());
result = _networkService.allocateSecondaryGuestIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNicId(), getNetworkId(), getIpaddress());
} catch (InsufficientAddressCapacityException e) {
throw new InvalidParameterValueException("Allocating guest ip for nic failed");
}
if (secondaryIp != null) {
if (result != null) {
secondaryIp = result.getIp4Address();
if (getNetworkType() == NetworkType.Basic) {
// add security group rules for the secondary ip addresses
boolean success = false;
@ -171,7 +174,7 @@ public class AddIpToVmNicCmd extends BaseAsyncCmd {
s_logger.info("Associated ip address to NIC : " + secondaryIp);
NicSecondaryIpResponse response = new NicSecondaryIpResponse();
response = _responseGenerator.createSecondaryIPToNicResponse(secondaryIp, getNicId(), getNetworkId());
response = _responseGenerator.createSecondaryIPToNicResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {

View File

@ -22,11 +22,12 @@ import com.cloud.user.UserContext;
import com.cloud.uservm.UserVm;
import org.apache.cloudstack.api.*;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.log4j.Logger;
@APICommand(name = "scaleVirtualMachine", description="Scales the virtual machine to a new service offering.", responseObject=UserVmResponse.class)
@APICommand(name = "scaleVirtualMachine", description="Scales the virtual machine to a new service offering.", responseObject=SuccessResponse.class)
public class ScaleVMCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName());
private static final String s_name = "scalevirtualmachineresponse";
@ -83,7 +84,7 @@ public class ScaleVMCmd extends BaseCmd {
@Override
public void execute(){
//UserContext.current().setEventDetails("Vm Id: "+getId());
UserVm result = null;
boolean result;
try {
result = _userVmService.upgradeVirtualMachine(this);
} catch (ResourceUnavailableException ex) {
@ -99,9 +100,8 @@ public class ScaleVMCmd extends BaseCmd {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
if (result != null){
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
response.setResponseName(getCommandName());
if (result){
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to scale vm");

View File

@ -37,11 +37,11 @@ import com.cloud.user.UserContext;
import com.cloud.uservm.UserVm;
import com.cloud.vm.snapshot.VMSnapshot;
@APICommand(name = "revertToSnapshot",description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class, since="4.2.0")
public class RevertToSnapshotCmd extends BaseAsyncCmd {
@APICommand(name = "revertToVMSnapshot",description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class, since="4.2.0")
public class RevertToVMSnapshotCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger
.getLogger(RevertToSnapshotCmd.class.getName());
private static final String s_name = "reverttosnapshotresponse";
.getLogger(RevertToVMSnapshotCmd.class.getName());
private static final String s_name = "reverttovmsnapshotresponse";
@Parameter(name = ApiConstants.VM_SNAPSHOT_ID, type = CommandType.UUID, required = true,entityType=VMSnapshotResponse.class,description = "The ID of the vm snapshot")
private Long vmSnapShotId;

View File

@ -23,6 +23,7 @@ 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.BaseCmd.CommandType;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
@ -56,6 +57,9 @@ public class ListZonesByCmd extends BaseListCmd {
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the zone")
private String name;
@Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
private String zoneType;
@Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the zones")
private Boolean showCapacities;
@ -79,6 +83,10 @@ public class ListZonesByCmd extends BaseListCmd {
return name;
}
public String getZoneType() {
return zoneType;
}
public Boolean getShowCapacities() {
return showCapacities;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -35,6 +35,9 @@ public class ConfigurationResponse extends BaseResponse {
@SerializedName(ApiConstants.SCOPE) @Param(description="scope(zone/cluster/pool/account) of the parameter that needs to be updated")
private String scope;
@SerializedName(ApiConstants.ID) @Param(description="the value of the configuration")
private Long id;
@SerializedName(ApiConstants.DESCRIPTION) @Param(description="the description of the configuration")
private String description;

View File

@ -153,9 +153,12 @@ 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")
private Set<NicResponse> nics;
@ -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;
}
}

View File

@ -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.
package org.apache.cloudstack.api.response;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import com.cloud.network.GuestVlan;
@EntityReference(value=GuestVlan.class)
@SuppressWarnings("unused")
public class GuestVlanRangeResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the guest VLAN range")
private String id;
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account of the guest VLAN range")
private String accountName;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID of the guest VLAN range")
private String domainId;
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the guest VLAN range")
private String domainName;
@SerializedName(ApiConstants.GUEST_VLAN_RANGE) @Param(description="the guest VLAN range")
private String guestVlanRange;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the guest vlan range")
private String projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the guest vlan range")
private String projectName;
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network of the guest vlan range")
private Long physicalNetworkId;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the zone of the guest vlan range")
private Long zoneId;
public void setId(String id) {
this.id = id;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public void setGuestVlanRange(String guestVlanRange) {
this.guestVlanRange = guestVlanRange;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public void setPhysicalNetworkId(Long physicalNetworkId) {
this.physicalNetworkId = physicalNetworkId;
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
}
}

View File

@ -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;
}
}

View File

@ -14,18 +14,20 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent;
package org.apache.cloudstack.api.response;
import com.cloud.agent.api.Command;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
public interface RecoveryHandler {
/**
* Perform the necessary recovery because the success of this command
* is not known.
*
* @param agentId agent the commands were sent to.
* @param seq sequence number.
* @param cmds commands that failed.
*/
public void handle(long agentId, long seq, Command[] cmds);
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
public class IsolationMethodResponse extends BaseResponse{
@SerializedName(ApiConstants.NAME) @Param(description="Network isolation method name")
private String name;
public void setIsolationMethodName(String isolationMethodName) {
this.name = isolationMethodName;
}
}

View File

@ -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;
@ -84,6 +85,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;
}
@ -157,4 +162,8 @@ public class NetworkOfferingResponse extends BaseResponse {
this.isPersistent = isPersistent;
}
public void setDetails(Map details) {
this.details = details;
}
}

View File

@ -76,6 +76,10 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
private String state;
@SerializedName(ApiConstants.SOURCE_NAT_SUPPORTED) @Param(description = "Souce Nat enable status")
private Boolean sourceNat;
@Override
public String getObjectId() {
return this.id;
@ -145,5 +149,11 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
public void setState(String state) {
this.state = state;
}
public void setSourceNat(Boolean sourceNat) {
this.sourceNat = sourceNat;
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -14,21 +14,15 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.maint;
package org.apache.cloudstack.network.lb;
/**
* has been released.
*
*/
public class UpgradeMonitor implements Runnable {
private String _url;
private long _period;
import com.cloud.network.rules.LoadBalancerContainer;
import com.cloud.utils.net.Ip;
public UpgradeMonitor(String url, long period) {
_url = url;
}
public interface ApplicationLoadBalancerContainer extends LoadBalancerContainer{
public void run() {
public Long getSourceIpNetworkId();
public Ip getSourceIp();
}
}

View File

@ -14,10 +14,11 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.maint.dao;
import com.cloud.maint.AgentUpgradeVO;
import com.cloud.utils.db.GenericDao;
package org.apache.cloudstack.network.lb;
public interface AgentUpgradeDao extends GenericDao<AgentUpgradeVO, Long> {
import com.cloud.network.rules.LoadBalancer;
public interface ApplicationLoadBalancerRule extends ApplicationLoadBalancerContainer, LoadBalancer{
int getInstancePort();
}

View File

@ -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);
}

View File

@ -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;
}

Some files were not shown because too many files have changed in this diff Show More